Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't treat StrcturedBuffer<IFoo> as a specializable param. #5645

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading