summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/slang/legalize-types.cpp4
-rw-r--r--tests/compute/buffer-type-splitting.slang29
-rw-r--r--tests/compute/buffer-type-splitting.slang.expected.txt4
-rw-r--r--tools/render-test/render-d3d11.cpp10
4 files changed, 47 insertions, 0 deletions
diff --git a/source/slang/legalize-types.cpp b/source/slang/legalize-types.cpp
index 76fda18e3..d0cf2ab69 100644
--- a/source/slang/legalize-types.cpp
+++ b/source/slang/legalize-types.cpp
@@ -91,6 +91,10 @@ static bool isResourceType(Type* type)
{
return true;
}
+ else if(auto untypedBufferType = type->As<UntypedBufferResourceType>())
+ {
+ return true;
+ }
// TODO: need more comprehensive coverage here
diff --git a/tests/compute/buffer-type-splitting.slang b/tests/compute/buffer-type-splitting.slang
new file mode 100644
index 000000000..c7577a0b2
--- /dev/null
+++ b/tests/compute/buffer-type-splitting.slang
@@ -0,0 +1,29 @@
+//TEST(compute):COMPARE_COMPUTE:
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+//TEST_INPUT:ubuffer(data=[0 2 3 3]):dxbinding(1),glbinding(1)
+//TEST_INPUT:ubuffer(data=[4 5 6 7]):dxbinding(2),glbinding(2)
+//TEST_INPUT:ubuffer(data=[8 9 10 11]):dxbinding(3),glbinding(3)
+//TEST_INPUT:ubuffer(data=[12 13 14 15]):dxbinding(4),glbinding(4)
+
+RWStructuredBuffer<int> outputBuffer;
+
+struct S
+{
+ RWByteAddressBuffer a;
+ RWByteAddressBuffer b;
+};
+S s[2];
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint i = dispatchThreadID.x;
+
+ int val =
+ s[0].a.Load(i * 4)
+ + s[1].a.Load(i * 4)*16
+ + s[0].b.Load(i * 4)*256
+ + s[1].b.Load(i * 4)*4096;
+
+ outputBuffer[i] = val;
+} \ No newline at end of file
diff --git a/tests/compute/buffer-type-splitting.slang.expected.txt b/tests/compute/buffer-type-splitting.slang.expected.txt
new file mode 100644
index 000000000..4bc5fcbf9
--- /dev/null
+++ b/tests/compute/buffer-type-splitting.slang.expected.txt
@@ -0,0 +1,4 @@
+C840
+D952
+EA63
+FB73
diff --git a/tools/render-test/render-d3d11.cpp b/tools/render-test/render-d3d11.cpp
index d0280a770..7d5c79b19 100644
--- a/tools/render-test/render-d3d11.cpp
+++ b/tools/render-test/render-d3d11.cpp
@@ -815,6 +815,16 @@ public:
viewDesc.Buffer.Flags = 0;
viewDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
viewDesc.Format = DXGI_FORMAT_UNKNOWN;
+
+ if( bufferDesc.stride == 0 )
+ {
+ // TODO: are there UAV cases we need to handle that are neither
+ // raw nor structured? RWBuffer<T> would be one...
+
+ viewDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
+ viewDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ }
+
dxDevice->CreateUnorderedAccessView(bufferOut, &viewDesc, &viewOut);
}
if (bufferDesc.type != InputBufferType::ConstantBuffer)