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.
[SPIRV] Implement out variables in patch control functions
The documentation for the patch control functions only mentions > The outputs are usually defined by a structure and is identified by HS_CONSTANT_DATA_OUTPUT in this example; the structure depends on the domain type and would be different for triangle or isoline domains. This is why we did not realize that we needed to implement out variables as well. This commit implement the alternate method of having an output. Fixes microsoft#3743
- Loading branch information
Showing
3 changed files
with
95 additions
and
24 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
39 changes: 39 additions & 0 deletions
39
tools/clang/test/CodeGenSPIRV/hs.const.output-patch.out.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,39 @@ | ||
// RUN: %dxc -T hs_6_0 -E Hull -fcgl %s -spirv | FileCheck %s | ||
|
||
struct ControlPoint { float4 position : POSITION; }; | ||
|
||
// CHECK: %param_var_edge = OpVariable %_ptr_Function__arr_float_uint_3 Function | ||
// CHECK: %param_var_inside = OpVariable %_ptr_Function_float Function | ||
// CHECK: %param_var_myFloat = OpVariable %_ptr_Function_float Function | ||
// CHECK: OpFunctionCall %void %HullConst %param_var_edge %param_var_inside %param_var_myFloat | ||
// CHECK: [[edges:%[0-9]+]] = OpLoad %_arr_float_uint_3 %param_var_edge | ||
// CHECK: [[addr:%[0-9]+]] = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %uint_0 | ||
// CHECK: [[val:%[0-9]+]] = OpCompositeExtract %float %66 0 | ||
// CHECK: OpStore [[addr]] [[val]] | ||
// CHECK: [[addr:%[0-9]+]] = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %uint_1 | ||
// CHECK: [[val:%[0-9]+]] = OpCompositeExtract %float %66 1 | ||
// CHECK: OpStore [[addr]] [[val]] | ||
// CHECK: [[addr:%[0-9]+]] = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %uint_2 | ||
// CHECK: [[val:%[0-9]+]] = OpCompositeExtract %float %66 2 | ||
// CHECK: OpStore [[addr]] [[val]] | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %float %param_var_inside | ||
// CHECK: [[addr:%[0-9]+]] = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %uint_0 | ||
// CHECK: OpStore [[addr]] [[val]] | ||
// CHECK: [[val:%[0-9]+]] = OpLoad %float %param_var_myFloat | ||
// CHECK: OpStore %out_var_MY_FLOAT [[val]] | ||
|
||
void HullConst (out float edge [3] : SV_TessFactor, out float inside : SV_InsideTessFactor, out float myFloat : MY_FLOAT) | ||
{ | ||
edge[0] = 2; | ||
edge[1] = 2; | ||
edge[2] = 2; | ||
inside = 2; | ||
myFloat = .2; | ||
} | ||
|
||
[domain("tri")] | ||
[partitioning("fractional_odd")] | ||
[outputtopology("triangle_ccw")] | ||
[patchconstantfunc("HullConst")] | ||
[outputcontrolpoints(3)] | ||
ControlPoint Hull (InputPatch<ControlPoint,3> v, uint id : SV_OutputControlPointID) { return v[id]; } |