diff options
| author | Yong He <yonghe@outlook.com> | 2024-09-27 19:26:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-27 19:26:59 -0700 |
| commit | 5a84e520a808e28e0cc60f86981e4d8db81f8ad3 (patch) | |
| tree | 745571c74c04f8ba258368a7b50b62b3908e82eb | |
| parent | afb1405bf7974d714cee10fcce0c61fe28cd075d (diff) | |
Fix hull shader spirv legalization bug. (#5180)
| -rw-r--r-- | source/slang/slang-ir-glsl-legalize.cpp | 2 | ||||
| -rw-r--r-- | tests/spirv/hull-shader.slang | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index d8c1aa91e..2d7e0c804 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -951,7 +951,7 @@ IRInst* getOrCreateBuiltinParamForHullShader(GLSLLegalizationContext* context, U { IRBuilder builder(context->entryPointFunc); auto paramType = builder.getIntType(); - builder.setInsertInto(context->entryPointFunc->getFirstBlock()->getFirstOrdinaryInst()); + builder.setInsertBefore(context->entryPointFunc->getFirstBlock()->getFirstOrdinaryInst()); outputControlPointIdParam = builder.emitParam(paramType); IRStructTypeLayout::Builder typeBuilder(&builder); auto typeLayout = typeBuilder.build(); diff --git a/tests/spirv/hull-shader.slang b/tests/spirv/hull-shader.slang new file mode 100644 index 000000000..d76e92242 --- /dev/null +++ b/tests/spirv/hull-shader.slang @@ -0,0 +1,44 @@ +//TEST:SIMPLE(filecheck=SPIRV):-target spirv -entry hullMain -stage hull -allow-glsl + +// SPIRV: OpDecorate %entryPointParam_hullMain_pos Location 0 +// SPIRV: OpDecorate %entryPointParam_hullMain_hm Location 1 +// SPIRV: OpDecorate %entryPointParam_constants_instanceId Location 2 + +struct HsOut +{ + float2 pos; + float2 hm; +}; + +struct HscOut +{ + float EdgeTessFactor[4] : SV_TessFactor; + float InsideTessFactor[2] : SV_InsideTessFactor; + uint instanceId; +}; + +[domain("quad")] +[partitioning("integer")] +[outputtopology("triangle_ccw")] +[outputcontrolpoints(4)] +[patchconstantfunc("constants")] +HsOut hullMain() +{ + HsOut o; + o.pos = 1; + o.hm = 2; + return o; +} + +HscOut constants() +{ + HscOut o; + o.instanceId = 123; + o.EdgeTessFactor[0] = 1; + o.EdgeTessFactor[1] = 2; + o.EdgeTessFactor[2] = 3; + o.EdgeTessFactor[3] = 4; + o.InsideTessFactor[0] = 0.5; + o.InsideTessFactor[1] = 0.5; + return o; +}
\ No newline at end of file |
