Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion source/slang/slang-emit-spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4850,7 +4850,15 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex
if (mode == SpvExecutionModeMax)
return;

requireSPIRVExecutionMode(nullptr, getIRInstSpvID(entryPoint), mode);
// Vulkan spec requires DepthReplacing exec mode when storing to FragDepth,
// in addition to DepthLess/DepthGreater modes.
requireSPIRVExecutionMode(
nullptr,
getIRInstSpvID(entryPoint),
SpvExecutionModeDepthReplacing);

if (mode != SpvExecutionModeDepthReplacing)
requireSPIRVExecutionMode(nullptr, getIRInstSpvID(entryPoint), mode);
}

// Make user type name conform to `SPV_GOOGLE_user_type` spec.
Expand Down
16 changes: 16 additions & 0 deletions tests/spirv/depth-replacing-gt-lt.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST:SIMPLE(filecheck=CHECK): -target spirv
// CHECK: OpExecutionMode {{.*}} DepthReplacing
// CHECK: OpExecutionMode %FS_WriteDepthGt DepthGreater
// CHECK: OpExecutionMode %FS_WriteDepthLt DepthLess

[shader("fragment")]
void FS_WriteDepthGt(out float depth: SV_DepthGreaterEqual)
{
depth = 0.5;
}

[shader("fragment")]
void FS_WriteDepthLt(out float depth: SV_DepthLessEqual)
{
depth = 0.5;
}
Loading