Commit 99a98963 by Shahbaz Youssefi Committed by Angle LUCI CQ

Vulkan: SPIR-V Gen: Support discard

This is simply done with OpKill. If-else blocks now check if the block is already terminated (through return, discard, continue or break) before adding the branch to merge block. Bug: angleproject:4889 Change-Id: I713286cf38e40f9048486d2914a4355ddbc686ac Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2953369 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 1529a30c
...@@ -1148,12 +1148,15 @@ void SPIRVBuilder::writeBranchConditional(spirv::IdRef conditionValue, ...@@ -1148,12 +1148,15 @@ void SPIRVBuilder::writeBranchConditional(spirv::IdRef conditionValue,
void SPIRVBuilder::writeBranchConditionalBlockEnd() void SPIRVBuilder::writeBranchConditionalBlockEnd()
{ {
// Insert a branch to the merge block at the end of each if-else block. if (!isCurrentFunctionBlockTerminated())
const spirv::IdRef mergeBlock = getCurrentConditional()->blockIds.back(); {
// Insert a branch to the merge block at the end of each if-else block, unless the block is
// already terminated, such as with a return or discard.
const spirv::IdRef mergeBlock = getCurrentConditional()->blockIds.back();
ASSERT(!isCurrentFunctionBlockTerminated()); spirv::WriteBranch(getSpirvCurrentFunctionBlock(), mergeBlock);
spirv::WriteBranch(getSpirvCurrentFunctionBlock(), mergeBlock); terminateCurrentFunctionBlock();
terminateCurrentFunctionBlock(); }
// Move on to the next block. // Move on to the next block.
nextConditionalBlock(); nextConditionalBlock();
......
...@@ -3018,8 +3018,8 @@ bool OutputSPIRVTraverser::visitBranch(Visit visit, TIntermBranch *node) ...@@ -3018,8 +3018,8 @@ bool OutputSPIRVTraverser::visitBranch(Visit visit, TIntermBranch *node)
switch (node->getFlowOp()) switch (node->getFlowOp())
{ {
case EOpKill: case EOpKill:
// TODO: http://anglebug.com/4889 spirv::WriteKill(mBuilder.getSpirvCurrentFunctionBlock());
UNIMPLEMENTED(); mBuilder.terminateCurrentFunctionBlock();
break; break;
case EOpBreak: case EOpBreak:
// TODO: http://anglebug.com/4889 // TODO: http://anglebug.com/4889
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment