diff options
| author | Yong He <yonghe@outlook.com> | 2024-05-01 16:44:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-01 16:44:22 -0700 |
| commit | 0bb826f8b92aec330875d0b966c1f4a6b99988bf (patch) | |
| tree | f0d086d4bfb93e302fcb8232816842ccfc182480 /tools/render-test | |
| parent | 4533c825fe628e08228037b846ee9d10004fd56f (diff) | |
SPIRV: Fix performance issue when handling large arrays. (#4064)
* SPIRV: Fix performance issue when handling large arrays.
* Add test for packing.
* Fix clang.
Diffstat (limited to 'tools/render-test')
| -rw-r--r-- | tools/render-test/render-test-main.cpp | 6 | ||||
| -rw-r--r-- | tools/render-test/shader-input-layout.cpp | 5 | ||||
| -rw-r--r-- | tools/render-test/shader-input-layout.h | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 02c0ea86a..fcdd4b54d 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -207,7 +207,10 @@ struct AssignValsFromLayoutContext { const InputBufferDesc& srcBuffer = srcVal->bufferDesc; auto& bufferData = srcVal->bufferData; - const size_t bufferSize = bufferData.getCount() * sizeof(uint32_t); + const size_t bufferSize = Math::Max((size_t)bufferData.getCount() * sizeof(uint32_t), (size_t)(srcBuffer.elementCount * srcBuffer.stride)); + bufferData.reserve(bufferSize / sizeof(uint32_t)); + for (size_t i = bufferData.getCount(); i < bufferSize / sizeof(uint32_t); i++) + bufferData.add(0); ComPtr<IBufferResource> bufferResource; SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBufferResource(srcBuffer, /*entry.isOutput,*/ bufferSize, bufferData.getBuffer(), device, bufferResource)); @@ -232,6 +235,7 @@ struct AssignValsFromLayoutContext const InputBufferDesc& counterBufferDesc{ InputBufferType::StorageBuffer, sizeof(uint32_t), + 1, Format::Unknown, }; SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBufferResource( diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp index 96f5db6e0..3012d45a4 100644 --- a/tools/render-test/shader-input-layout.cpp +++ b/tools/render-test/shader-input-layout.cpp @@ -222,6 +222,11 @@ namespace renderer_test parser.Read("="); val->bufferDesc.stride = parser.ReadInt(); } + else if (word == "count") + { + parser.Read("="); + val->bufferDesc.elementCount = parser.ReadInt(); + } else if (word == "counter") { parser.Read("="); diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h index de1da3da9..996635b94 100644 --- a/tools/render-test/shader-input-layout.h +++ b/tools/render-test/shader-input-layout.h @@ -68,6 +68,7 @@ struct InputBufferDesc { InputBufferType type = InputBufferType::StorageBuffer; int stride = 0; // stride == 0 indicates an unstructured buffer. + int elementCount = 1; Format format = Format::Unknown; // For RWStructuredBuffer, AppendStructuredBuffer, ConsumeStructuredBuffer // the default value of 0xffffffff indicates that a counter buffer should |
