summaryrefslogtreecommitdiff
path: root/tools/render-test
diff options
context:
space:
mode:
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/shader-input-layout.cpp5
-rw-r--r--tools/render-test/shader-input-layout.h3
-rw-r--r--tools/render-test/shader-renderer-util.cpp26
3 files changed, 33 insertions, 1 deletions
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 4c68899ef..5e487f1ad 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -140,6 +140,11 @@ namespace renderer_test
entry.type = ShaderInputType::Buffer;
entry.bufferDesc.type = InputBufferType::ConstantBuffer;
}
+ else if (parser.LookAhead("root_constants"))
+ {
+ entry.type = ShaderInputType::Buffer;
+ entry.bufferDesc.type = InputBufferType::RootConstantBuffer;
+ }
else if (parser.LookAhead("ubuffer"))
{
entry.type = ShaderInputType::Buffer;
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index 0831f73bb..4c8d0dfa2 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -42,7 +42,8 @@ struct InputTextureDesc
enum class InputBufferType
{
- ConstantBuffer, StorageBuffer
+ ConstantBuffer, StorageBuffer,
+ RootConstantBuffer,
};
struct InputBufferDesc
diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp
index 987b63b48..b2911ffd5 100644
--- a/tools/render-test/shader-renderer-util.cpp
+++ b/tools/render-test/shader-renderer-util.cpp
@@ -195,6 +195,18 @@ static RefPtr<SamplerState> _createSamplerState(
case InputBufferType::StorageBuffer:
slotRangeDesc.type = DescriptorSlotType::StorageBuffer;
break;
+
+ case InputBufferType::RootConstantBuffer:
+ {
+ // A root constant buffer maps to a root constant range
+ // where the `count` of slots is equal to the number
+ // of bytes of data.
+ //
+ Slang::UInt size = srcEntry.bufferData.getCount() * sizeof(srcEntry.bufferData[0]);
+ slotRangeDesc.type = DescriptorSlotType::RootConstant;
+ slotRangeDesc.count = size;
+ }
+ break;
}
}
break;
@@ -269,6 +281,20 @@ static RefPtr<SamplerState> _createSamplerState(
const InputBufferDesc& srcBuffer = srcEntry.bufferDesc;
const size_t bufferSize = srcEntry.bufferData.getCount() * sizeof(uint32_t);
+ if( srcBuffer.type == InputBufferType::RootConstantBuffer )
+ {
+ // A root constant buffer at the HLSL/Slang level actually
+ // maps to root constant data stored directly in the descriptor
+ // set, and thus does not need/want us to allocate a buffer
+ // to hold the data.
+ //
+ // Instead, we set the data directly here and then bypass
+ // the logic that handles the buffer-backed cases below.
+ //
+ descriptorSet->setRootConstants(rangeIndex, 0, bufferSize, srcEntry.bufferData.getBuffer());
+ break;
+ }
+
RefPtr<BufferResource> bufferResource;
SLANG_RETURN_ON_FAIL(createBufferResource(srcEntry.bufferDesc, srcEntry.isOutput, bufferSize, srcEntry.bufferData.getBuffer(), renderer, bufferResource));