summaryrefslogtreecommitdiffstats
path: root/tools/render-test
diff options
context:
space:
mode:
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/render-test-main.cpp42
-rw-r--r--tools/render-test/shader-input-layout.cpp5
-rw-r--r--tools/render-test/shader-input-layout.h4
3 files changed, 49 insertions, 2 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 3bdcdba07..1f2b3a5ae 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -209,11 +209,49 @@ struct AssignValsFromLayoutContext
ComPtr<IBufferResource> bufferResource;
SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBufferResource(srcBuffer, /*entry.isOutput,*/ bufferSize, bufferData.getBuffer(), device, bufferResource));
+ ComPtr<IBufferResource> counterResource;
+ const auto explicitCounterCursor = dstCursor.getExplicitCounter();
+ if(srcBuffer.counter != ~0u)
+ {
+ if(explicitCounterCursor.isValid())
+ {
+ // If this cursor has a full buffer object associated with the
+ // resource, then assign to that.
+ ShaderInputLayout::BufferVal counterVal;
+ counterVal.bufferData.add(srcBuffer.counter);
+ assignBuffer(explicitCounterCursor, &counterVal);
+ }
+ else
+ {
+ // Otherwise, this API (D3D) must be handling the buffer object
+ // specially, in which case create the buffer resource to pass
+ // into `createBufferView`
+ const InputBufferDesc& counterBufferDesc{
+ InputBufferType::StorageBuffer,
+ sizeof(uint32_t),
+ Format::Unknown,
+ };
+ SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBufferResource(
+ counterBufferDesc,
+ sizeof(srcBuffer.counter),
+ &srcBuffer.counter,
+ device,
+ counterResource
+ ));
+ }
+ }
+ else if(explicitCounterCursor.isValid())
+ {
+ // If we know we require a counter for this resource but haven't
+ // been given one, error
+ return SLANG_E_INVALID_ARG;
+ }
+
IResourceView::Desc viewDesc = {};
viewDesc.type = IResourceView::Type::UnorderedAccess;
viewDesc.format = srcBuffer.format;
viewDesc.bufferElementSize = srcVal->bufferDesc.stride;
- auto bufferView = device->createBufferView(bufferResource, nullptr, viewDesc);
+ auto bufferView = device->createBufferView(bufferResource, counterResource, viewDesc);
dstCursor.setResource(bufferView);
maybeAddOutput(dstCursor, srcVal, bufferResource);
@@ -977,7 +1015,7 @@ Result RenderTestApp::writeBindingOutput(const String& fileName)
m_transientHeap->finish();
m_transientHeap->synchronizeAndReset();
- m_device->readBufferResource(stagingBuffer, 0, bufferSize, blob.writeRef());
+ SLANG_RETURN_ON_FAIL(m_device->readBufferResource(stagingBuffer, 0, bufferSize, blob.writeRef()));
}
if (!blob)
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index b8c505607..80ce4e316 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -203,6 +203,11 @@ namespace renderer_test
parser.Read("=");
val->bufferDesc.stride = parser.ReadInt();
}
+ else if (word == "counter")
+ {
+ parser.Read("=");
+ val->bufferDesc.counter = parser.ReadInt();
+ }
else if (word == "random")
{
parser.Read("(");
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index 78d545114..2803d1915 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -58,6 +58,10 @@ struct InputBufferDesc
InputBufferType type = InputBufferType::StorageBuffer;
int stride = 0; // stride == 0 indicates an unstructured buffer.
Format format = Format::Unknown;
+ // For RWStructuredBuffer, AppendStructuredBuffer, ConsumeStructuredBuffer
+ // the default value of 0xffffffff indicates that a counter buffer should
+ // not be assigned
+ uint32_t counter = ~0u;
};
struct InputSamplerDesc