-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIR-V] add -fvk-support-nonzero-base-vertex option (#6865)
There is already a workaround for the SV_BaseInstance inconsistency between HLSL and SPIR-V. The same issue applies to SV_BaseVertex, but no such option is available. This commit adds the -fvk-support-nonzero-base-vertex option, which behaves the same as the -fvk-support-nonzero-base-instance option.
- Loading branch information
1 parent
b766b43
commit bb3a0c3
Showing
7 changed files
with
138 additions
and
15 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
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
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.nonzero-base-vertex.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-vertex -fcgl %s -spirv | FileCheck %s | ||
|
||
// CHECK: OpEntryPoint Vertex %main "main" | ||
// CHECK-SAME: %gl_VertexIndex | ||
// CHECK-SAME: [[gl_BaseVertex:%[0-9]+]] | ||
// CHECK-SAME: %out_var_A | ||
|
||
// CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex | ||
// CHECK: OpDecorate [[gl_BaseVertex]] BuiltIn BaseVertex | ||
// CHECK: OpDecorate %out_var_A Location 0 | ||
|
||
// CHECK: %gl_VertexIndex = OpVariable %_ptr_Input_int Input | ||
// CHECK: [[gl_BaseVertex]] = OpVariable %_ptr_Input_int Input | ||
// CHECK: %out_var_A = OpVariable %_ptr_Output_int Output | ||
|
||
// CHECK: %main = OpFunction | ||
// CHECK: %SV_VertexID = OpVariable %_ptr_Function_int Function | ||
// CHECK: [[gl_VertexIndex:%[0-9]+]] = OpLoad %int %gl_VertexIndex | ||
// CHECK: [[base_vertex:%[0-9]+]] = OpLoad %int [[gl_BaseVertex]] | ||
// CHECK: [[vertex_id:%[0-9]+]] = OpISub %int [[gl_VertexIndex]] [[base_vertex]] | ||
// CHECK: OpStore %SV_VertexID [[vertex_id]] | ||
// CHECK: [[vertex_id_0:%[0-9]+]] = OpLoad %int %SV_VertexID | ||
// CHECK: OpStore %param_var_input [[vertex_id_0]] | ||
// CHECK: {{%[0-9]+}} = OpFunctionCall %int %src_main %param_var_input | ||
|
||
int main(int input: SV_VertexID) : A { | ||
return input; | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
tools/clang/test/CodeGenSPIRV/semantic.unsigned-nonzero-base-vertex.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-vertex -fcgl %s -spirv | FileCheck %s | ||
|
||
// CHECK: OpEntryPoint Vertex %main "main" | ||
// CHECK-SAME: %gl_VertexIndex | ||
// CHECK-SAME: [[gl_BaseVertex:%[0-9]+]] | ||
// CHECK-SAME: %out_var_A | ||
|
||
// CHECK: OpDecorate %gl_VertexIndex BuiltIn VertexIndex | ||
// CHECK: OpDecorate [[gl_BaseVertex]] BuiltIn BaseVertex | ||
// CHECK: OpDecorate %out_var_A Location 0 | ||
|
||
// CHECK: %gl_VertexIndex = OpVariable %_ptr_Input_uint Input | ||
// CHECK: [[gl_BaseVertex]] = OpVariable %_ptr_Input_uint Input | ||
// CHECK: %out_var_A = OpVariable %_ptr_Output_uint Output | ||
|
||
// CHECK: %main = OpFunction | ||
// CHECK: %SV_VertexID = OpVariable %_ptr_Function_uint Function | ||
// CHECK: [[gl_VertexIndex:%[0-9]+]] = OpLoad %uint %gl_VertexIndex | ||
// CHECK: [[base_vertex:%[0-9]+]] = OpLoad %uint [[gl_BaseVertex]] | ||
// CHECK: [[vertex_id:%[0-9]+]] = OpISub %uint [[gl_VertexIndex]] [[base_vertex]] | ||
// CHECK: OpStore %SV_VertexID [[vertex_id]] | ||
// CHECK: [[vertex_id_0:%[0-9]+]] = OpLoad %uint %SV_VertexID | ||
// CHECK: OpStore %param_var_input [[vertex_id_0]] | ||
// CHECK: {{%[0-9]+}} = OpFunctionCall %uint %src_main %param_var_input | ||
|
||
unsigned int main(unsigned int input: SV_VertexID) : A { | ||
return input; | ||
} | ||
|