summaryrefslogtreecommitdiffstats
path: root/tools/gfx-unit-test/gfx-test-util.cpp
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2021-12-08 11:38:14 -0800
committerGitHub <noreply@github.com>2021-12-08 11:38:14 -0800
commit9606401e1de1002e3ad070bc5c6384fa5bc4d9ff (patch)
tree7a557a14fadf5220a34f6df9faf1a5535100743f /tools/gfx-unit-test/gfx-test-util.cpp
parent90d8af888b40c83b33f9f0c037bd2ab8c19a35f4 (diff)
D3D12 and Vulkan to CUDA Texture Sharing (#2038)
Diffstat (limited to 'tools/gfx-unit-test/gfx-test-util.cpp')
-rw-r--r--tools/gfx-unit-test/gfx-test-util.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp
index aafa3fc59..952638fd8 100644
--- a/tools/gfx-unit-test/gfx-test-util.cpp
+++ b/tools/gfx-unit-test/gfx-test-util.cpp
@@ -66,6 +66,20 @@ namespace gfx_test
return SLANG_OK;
}
+ void compareComputeResult(gfx::IDevice* device, gfx::ITextureResource* texture, gfx::ResourceState state, float* expectedResult, size_t expectedBufferSize)
+ {
+ // Read back the results.
+ ComPtr<ISlangBlob> resultBlob;
+ size_t rowPitch = 0;
+ size_t pixelSize = 0;
+ GFX_CHECK_CALL_ABORT(device->readTextureResource(
+ texture, state, resultBlob.writeRef(), &rowPitch, &pixelSize));
+ SLANG_CHECK(resultBlob->getBufferSize() == expectedBufferSize);
+ auto result = (float*)resultBlob->getBufferPointer();
+ // Compare results.
+ SLANG_CHECK(memcmp(resultBlob->getBufferPointer(), expectedResult, expectedBufferSize) == 0);
+ }
+
void compareComputeResult(gfx::IDevice* device, gfx::IBufferResource* buffer, uint8_t* expectedResult, size_t expectedBufferSize)
{
// Read back the results.