From 9606401e1de1002e3ad070bc5c6384fa5bc4d9ff Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Wed, 8 Dec 2021 11:38:14 -0800 Subject: D3D12 and Vulkan to CUDA Texture Sharing (#2038) --- tools/gfx-unit-test/gfx-test-util.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/gfx-unit-test/gfx-test-util.cpp') 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 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. -- cgit v1.2.3