diff options
| author | Yong He <yonghe@outlook.com> | 2024-11-22 15:14:48 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-22 15:14:48 -0800 |
| commit | 43728fbda5b9af19eded18fe82ca67b66cc6d0f7 (patch) | |
| tree | 13354573300776f7f293b886109c85be760933fc | |
| parent | 756cb32e92f42a622d10b1cca52c7b7e926725d2 (diff) | |
Don't treat StrcturedBuffer<IFoo> as a specializable param. (#5645)
* Don't treat StrcturedBuffer<IFoo> as a specializable param.
* Fix RHI.
| m--------- | external/slang-rhi | 0 | ||||
| -rw-r--r-- | source/slang/slang-check-shader.cpp | 9 | ||||
| -rw-r--r-- | source/slang/slang-mangle.cpp | 1 | ||||
| -rw-r--r-- | tests/bugs/dyn-dispatch-single-conformance.slang | 27 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-13.slang | 1 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-14.slang | 4 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-15.slang | 2 | ||||
| -rw-r--r-- | tests/compute/interface-assoc-type-param.slang | 3 | ||||
| -rw-r--r-- | tests/language-feature/interfaces/empty-type-conformance.slang | 4 |
9 files changed, 34 insertions, 17 deletions
diff --git a/external/slang-rhi b/external/slang-rhi -Subproject 3bb34bb0c2e75e4f75dc4f180071111592b86ba +Subproject 5b77d09cea9a309b98b65469e8438835d972cac diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp index 52a70034a..50382f9c1 100644 --- a/source/slang/slang-check-shader.cpp +++ b/source/slang/slang-check-shader.cpp @@ -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)) { diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index 4257f5dc2..7d4587480 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -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(); } diff --git a/tests/bugs/dyn-dispatch-single-conformance.slang b/tests/bugs/dyn-dispatch-single-conformance.slang new file mode 100644 index 000000000..eae0fee07 --- /dev/null +++ b/tests/bugs/dyn-dispatch-single-conformance.slang @@ -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; +}
\ No newline at end of file diff --git a/tests/compute/dynamic-dispatch-13.slang b/tests/compute/dynamic-dispatch-13.slang index 20d78e0ad..eff5218a0 100644 --- a/tests/compute/dynamic-dispatch-13.slang +++ b/tests/compute/dynamic-dispatch-13.slang @@ -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; diff --git a/tests/compute/dynamic-dispatch-14.slang b/tests/compute/dynamic-dispatch-14.slang index 641fe938c..16703aa2a 100644 --- a/tests/compute/dynamic-dispatch-14.slang +++ b/tests/compute/dynamic-dispatch-14.slang @@ -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)] diff --git a/tests/compute/dynamic-dispatch-15.slang b/tests/compute/dynamic-dispatch-15.slang index 2ab169281..46e209a8a 100644 --- a/tests/compute/dynamic-dispatch-15.slang +++ b/tests/compute/dynamic-dispatch-15.slang @@ -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)] diff --git a/tests/compute/interface-assoc-type-param.slang b/tests/compute/interface-assoc-type-param.slang index a234d457f..6f7443e1f 100644 --- a/tests/compute/interface-assoc-type-param.slang +++ b/tests/compute/interface-assoc-type-param.slang @@ -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 diff --git a/tests/language-feature/interfaces/empty-type-conformance.slang b/tests/language-feature/interfaces/empty-type-conformance.slang index 9fee04607..ae529a496 100644 --- a/tests/language-feature/interfaces/empty-type-conformance.slang +++ b/tests/language-feature/interfaces/empty-type-conformance.slang @@ -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 @@ -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) |
