Skip to content

Commit

Permalink
Don't treat StrcturedBuffer<IFoo> as a specializable param. (#5645)
Browse files Browse the repository at this point in the history
* Don't treat StrcturedBuffer<IFoo> as a specializable param.

* Fix RHI.
  • Loading branch information
csyonghe authored Nov 22, 2024
1 parent 756cb32 commit 43728fb
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 18 deletions.
9 changes: 0 additions & 9 deletions source/slang/slang-check-shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ static void _collectExistentialSpecializationParamsRec(
loc);
return;
}
else if (auto structuredBufferType = as<HLSLStructuredBufferTypeBase>(type))
{
_collectExistentialSpecializationParamsRec(
astBuilder,
ioSpecializationParams,
structuredBufferType->getElementType(),
loc);
return;
}

if (auto declRefType = as<DeclRefType>(type))
{
Expand Down
1 change: 1 addition & 0 deletions source/slang/slang-mangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ String getMangledTypeName(ASTBuilder* astBuilder, Type* type)
{
SLANG_AST_BUILDER_RAII(astBuilder);
ManglingContext context(astBuilder);
emitRaw(&context, "_ST");
emitType(&context, type);
return context.sb.produceString();
}
Expand Down
27 changes: 27 additions & 0 deletions tests/bugs/dyn-dispatch-single-conformance.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type

interface IFoo
{
float3 get();
}

struct Foo : IFoo
{
float3 val;
float3 get() { return val; }
};

//TEST_INPUT: type_conformance Foo:IFoo=0

//TEST_INPUT:set foo = ubuffer(data=[0 0 0 0 1.0 2.0 3.0 0.0], stride=4)
StructuredBuffer<IFoo> foo;

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;

[numthreads(1,1,1)]
void computeMain()
{
// CHECK: 1.0
outputBuffer[0] = foo[0].get().x;
}
1 change: 0 additions & 1 deletion tests/compute/dynamic-dispatch-13.slang
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface IInterface
RWStructuredBuffer<int> gOutputBuffer;
//TEST_INPUT: set gCb = new StructuredBuffer<IInterface>{new MyImpl{1}};
RWStructuredBuffer<IInterface> gCb;
// Add two elements into the structured buffer to prevent specialization.
//TEST_INPUT: set gCb1 = new StructuredBuffer<IInterface>{new MyImpl{1}, new MyImpl2{2}};
RWStructuredBuffer<IInterface> gCb1;

Expand Down
4 changes: 1 addition & 3 deletions tests/compute/dynamic-dispatch-14.slang
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ interface IInterface
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<int> gOutputBuffer;


// Specialize gCb1, but not gCb2
//TEST_INPUT: set gCb = new StructuredBuffer<IInterface>{new MyImpl{1}};
RWStructuredBuffer<IInterface> gCb;

//TEST_INPUT: set gCb1 = dynamic new StructuredBuffer<IInterface>{new MyImpl{1}}
//TEST_INPUT: set gCb1 = new StructuredBuffer<IInterface>{new MyImpl{1}}
RWStructuredBuffer<IInterface> gCb1;

[numthreads(4, 1, 1)]
Expand Down
2 changes: 1 addition & 1 deletion tests/compute/dynamic-dispatch-15.slang
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IInterface
//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<float> gOutputBuffer;

//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]}];
//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]}];
RWStructuredBuffer<IInterface> gObj;

[numthreads(1, 1, 1)]
Expand Down
3 changes: 2 additions & 1 deletion tests/compute/interface-assoc-type-param.slang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ interface IEval
uint eval();
}

export struct Impl : IInterface
//TEST_INPUT: type_conformance Impl:IInterface = 0
struct Impl : IInterface
{
uint val;
struct TEval : IEval
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Test that we allow empty type conformances.

//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-dx11 -compute -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -output-using-type

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

//TEST_INPUT: type_conformance TestImplementation:TestInterface=0

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
Expand Down

0 comments on commit 43728fb

Please sign in to comment.