Skip to content

Commit 43728fb

Browse files
authored
Don't treat StrcturedBuffer<IFoo> as a specializable param. (shader-slang#5645)
* Don't treat StrcturedBuffer<IFoo> as a specializable param. * Fix RHI.
1 parent 756cb32 commit 43728fb

9 files changed

+35
-18
lines changed

source/slang/slang-check-shader.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,6 @@ static void _collectExistentialSpecializationParamsRec(
7979
loc);
8080
return;
8181
}
82-
else if (auto structuredBufferType = as<HLSLStructuredBufferTypeBase>(type))
83-
{
84-
_collectExistentialSpecializationParamsRec(
85-
astBuilder,
86-
ioSpecializationParams,
87-
structuredBufferType->getElementType(),
88-
loc);
89-
return;
90-
}
9182

9283
if (auto declRefType = as<DeclRefType>(type))
9384
{

source/slang/slang-mangle.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ String getMangledTypeName(ASTBuilder* astBuilder, Type* type)
817817
{
818818
SLANG_AST_BUILDER_RAII(astBuilder);
819819
ManglingContext context(astBuilder);
820+
emitRaw(&context, "_ST");
820821
emitType(&context, type);
821822
return context.sb.produceString();
822823
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type
2+
3+
interface IFoo
4+
{
5+
float3 get();
6+
}
7+
8+
struct Foo : IFoo
9+
{
10+
float3 val;
11+
float3 get() { return val; }
12+
};
13+
14+
//TEST_INPUT: type_conformance Foo:IFoo=0
15+
16+
//TEST_INPUT:set foo = ubuffer(data=[0 0 0 0 1.0 2.0 3.0 0.0], stride=4)
17+
StructuredBuffer<IFoo> foo;
18+
19+
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
20+
RWStructuredBuffer<float> outputBuffer;
21+
22+
[numthreads(1,1,1)]
23+
void computeMain()
24+
{
25+
// CHECK: 1.0
26+
outputBuffer[0] = foo[0].get().x;
27+
}

tests/compute/dynamic-dispatch-13.slang

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ interface IInterface
1717
RWStructuredBuffer<int> gOutputBuffer;
1818
//TEST_INPUT: set gCb = new StructuredBuffer<IInterface>{new MyImpl{1}};
1919
RWStructuredBuffer<IInterface> gCb;
20-
// Add two elements into the structured buffer to prevent specialization.
2120
//TEST_INPUT: set gCb1 = new StructuredBuffer<IInterface>{new MyImpl{1}, new MyImpl2{2}};
2221
RWStructuredBuffer<IInterface> gCb1;
2322

tests/compute/dynamic-dispatch-14.slang

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ interface IInterface
2323
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
2424
RWStructuredBuffer<int> gOutputBuffer;
2525

26-
27-
// Specialize gCb1, but not gCb2
2826
//TEST_INPUT: set gCb = new StructuredBuffer<IInterface>{new MyImpl{1}};
2927
RWStructuredBuffer<IInterface> gCb;
3028

31-
//TEST_INPUT: set gCb1 = dynamic new StructuredBuffer<IInterface>{new MyImpl{1}}
29+
//TEST_INPUT: set gCb1 = new StructuredBuffer<IInterface>{new MyImpl{1}}
3230
RWStructuredBuffer<IInterface> gCb1;
3331

3432
[numthreads(4, 1, 1)]

tests/compute/dynamic-dispatch-15.slang

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface IInterface
1414
//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
1515
RWStructuredBuffer<float> gOutputBuffer;
1616

17-
//TEST_INPUT: set gObj = dynamic new StructuredBuffer<IInterface>[new FloatVal{1.0}, new Float4Val{{[2.0, 3.0, 4.0, 5.0]}}, new IntVal{6}, new Int4Val{[7,8,9,10]}];
17+
//TEST_INPUT: set gObj = new StructuredBuffer<IInterface>[new FloatVal{1.0}, new Float4Val{{[2.0, 3.0, 4.0, 5.0]}}, new IntVal{6}, new Int4Val{[7,8,9,10]}];
1818
RWStructuredBuffer<IInterface> gObj;
1919

2020
[numthreads(1, 1, 1)]

tests/compute/interface-assoc-type-param.slang

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interface IEval
1616
uint eval();
1717
}
1818

19-
export struct Impl : IInterface
19+
//TEST_INPUT: type_conformance Impl:IInterface = 0
20+
struct Impl : IInterface
2021
{
2122
uint val;
2223
struct TEval : IEval

tests/language-feature/interfaces/empty-type-conformance.slang

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Test that we allow empty type conformances.
2-
31
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-dx11 -compute -output-using-type
42
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -output-using-type
53

@@ -18,6 +16,8 @@ StructuredBuffer<TestInterface> inBuffer;
1816
//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4);
1917
RWStructuredBuffer<float> outputBuffer;
2018

19+
//TEST_INPUT: type_conformance TestImplementation:TestInterface=0
20+
2121
[shader("compute")]
2222
[numthreads(1, 1, 1)]
2323
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)

0 commit comments

Comments
 (0)