forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow unsigned int for nonzero base instance
A regression was introduced by Refactor create stage vars (microsoft#6059) because it created the BaseInstance variable as an int in all cases it was created for the option vk-support-nonzero-base-instance enabled. In some cases it was used as an unsigned int. This comment get the type for BaseInstance from the type of the instance id variable, and adds a test for unsigned. Fixes microsoft#6118.
- Loading branch information
Showing
3 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tools/clang/test/CodeGenSPIRV/semantic.unsigned-nonzero-base-instance.vs.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %dxc -T vs_6_0 -E main -fvk-support-nonzero-base-instance -fcgl %s -spirv | FileCheck %s | ||
|
||
// CHECK: OpEntryPoint Vertex %main "main" | ||
// CHECK-SAME: %gl_InstanceIndex | ||
// CHECK-SAME: %gl_BaseInstance | ||
// CHECK-SAME: %out_var_SV_InstanceID | ||
|
||
// CHECK: OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex | ||
// CHECK: OpDecorate %gl_BaseInstance BuiltIn BaseInstance | ||
// CHECK: OpDecorate %out_var_SV_InstanceID Location 0 | ||
|
||
// CHECK: %gl_InstanceIndex = OpVariable %_ptr_Input_uint Input | ||
// CHECK: %gl_BaseInstance = OpVariable %_ptr_Input_uint Input | ||
// CHECK: %out_var_SV_InstanceID = OpVariable %_ptr_Output_uint Output | ||
|
||
// CHECK: %main = OpFunction | ||
// CHECK: %SV_InstanceID = OpVariable %_ptr_Function_uint Function | ||
// CHECK: [[gl_InstanceIndex:%[0-9]+]] = OpLoad %uint %gl_InstanceIndex | ||
// CHECK: [[gl_BaseInstance:%[0-9]+]] = OpLoad %uint %gl_BaseInstance | ||
// CHECK: [[instance_id:%[0-9]+]] = OpISub %uint [[gl_InstanceIndex]] [[gl_BaseInstance]] | ||
// CHECK: OpStore %SV_InstanceID [[instance_id]] | ||
// CHECK: [[instance_id_0:%[0-9]+]] = OpLoad %uint %SV_InstanceID | ||
// CHECK: OpStore %param_var_input [[instance_id_0]] | ||
// CHECK: {{%[0-9]+}} = OpFunctionCall %uint %src_main %param_var_input | ||
|
||
unsigned int main(unsigned int input: SV_InstanceID) : SV_InstanceID { | ||
return input; | ||
} | ||
|