summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2021-10-26 16:30:59 -0700
committerGitHub <noreply@github.com>2021-10-26 16:30:59 -0700
commitdcc2b854a64b3e4e890215ff21cf4b219724f524 (patch)
treefe958a184f46f4a1bbf10f6c7174d31283df76dc
parentfe6d5f1cf8865567e08cf210a2639ffde2886fc3 (diff)
Expanded gfx::Format to include additional formats (#1982)
* Format list updated with additional formats supported by both D3D and Vulkan; D3DUtil::getMapFormat() and VkUtil::getVkFormat() updated to include additional formats; GFX_FORMAT() updated with all additional formats (BC compression unfinished) * Finished updating GFX_FORMAT with newly added formats and sizes; Pixel size is now tracked using the FormatPixelSize struct containing the values for bytes per block and pixels per block to accomodate BC formats; Updated gfxGetFormatSize and associated sub-calls to return FormatPixelSize instead of uint8_t; Most calls to gfxGetFormatSize() updated to reflect changes, a couple calls still unupdated * Changes to accommodate new formats finished, debugging slang-literal unit test * First format unit test working * One test added for BC1Unorm and RGBA8Unorm_SRGB, both passing * Refactored format testing code to merge BC1Unorm and RGBA8Unorm SRGB into a single file * All unit tests added for BC and Srgb formats * Most tests added and working; Added five additional formats (still need tests) and made the appropriate changes to support these; createTextureView() modified for D3D11, D3D12, and Vulkan to take into account the format specified in the texture view desc when the texture's format is typeless * Format enums renamed to more closely match their D3D counterparts; Added a universal float and uint buffer and buffer view for use across all Format tests * Remaining tests added; D3D12 tests pass, but Vulkan crashes in BC1_UNORM and D3D11 spits out a bunch of D3D11 Errors (but supposedly passes) * re-run premake * Added Sint versions of test shaders; Vulkan and D3D11 tests also pass * Size struct for format unit tests no longer use initializer lists * Fixed a Size struct missed in the previous pass * Fixed minor bugs causing tests to fail * Added documentation detailing all currently unsupported formats * Skip tests causing unsupported format warnings due to swiftshader * updated several test using old Format enum names * Revert change to compareComputeResult() that was added for debugging purposes * DEBUGGING: Added prints to identify which formats are failing on CI * Reverted attempted debugging changes; Fixed texture2d-gather.hlsl to use updated Format enums * Fixed incorrect array sizes in d3d11 _initSrvDesc() * Commented out further tests that produce unexpected results when tested for Vulkan with swiftshader * Revert "Merge branch 'expanded-format-support' of https://github.com/lucy96chen/slang into expanded-format-support" This reverts commit 20008f0d3ecc3b1405ecac8c138edaa3cd37ed6b, reversing changes made to 6081e95827315fee50e18409394d5abd62fac787. * Added a fuzzy comparison function for use with floats * submodule update * Revert messed up changes caused by previous revert after automatically merging on github
-rw-r--r--build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj2
-rw-r--r--build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters6
-rw-r--r--docs/gfx-user-guide/unsupported-formats.md264
-rw-r--r--examples/example-base/example-base.cpp8
-rw-r--r--examples/model-viewer/main.cpp8
-rw-r--r--examples/ray-tracing-pipeline/main.cpp8
-rw-r--r--examples/ray-tracing/main.cpp8
-rw-r--r--examples/shader-toy/main.cpp2
-rw-r--r--examples/triangle/main.cpp4
-rw-r--r--slang-gfx.h242
-rw-r--r--tests/bugs/texture2d-gather.hlsl2
-rw-r--r--tests/compute/half-rw-texture-convert.slang6
-rw-r--r--tests/compute/half-rw-texture-convert2.slang6
-rw-r--r--tests/compute/half-rw-texture-simple.slang6
-rw-r--r--tests/compute/rw-texture-simple.slang6
-rw-r--r--tools/gfx-unit-test/format-test-shaders.slang220
-rw-r--r--tools/gfx-unit-test/format-unit-tests.cpp1110
-rw-r--r--tools/gfx-unit-test/get-texture-resource-handle-test.cpp2
-rw-r--r--tools/gfx-unit-test/gfx-test-util.cpp15
-rw-r--r--tools/gfx-unit-test/gfx-test-util.h8
-rw-r--r--tools/gfx/cpu/render-cpu.cpp32
-rw-r--r--tools/gfx/cuda/render-cuda.cpp26
-rw-r--r--tools/gfx/d3d/d3d-util.cpp116
-rw-r--r--tools/gfx/d3d11/render-d3d11.cpp82
-rw-r--r--tools/gfx/d3d12/render-d3d12.cpp21
-rw-r--r--tools/gfx/debug-layer.cpp22
-rw-r--r--tools/gfx/open-gl/render-gl.cpp21
-rw-r--r--tools/gfx/render.cpp173
-rw-r--r--tools/gfx/vulkan/render-vk.cpp35
-rw-r--r--tools/gfx/vulkan/vk-util.cpp111
-rw-r--r--tools/platform/gui.cpp10
-rw-r--r--tools/platform/model.cpp2
-rw-r--r--tools/render-test/render-test-main.cpp20
-rw-r--r--tools/render-test/shader-input-layout.cpp26
-rw-r--r--tools/render-test/shader-input-layout.h6
-rw-r--r--tools/render-test/shader-renderer-util.cpp4
36 files changed, 2396 insertions, 244 deletions
diff --git a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj
index 4ce8c25a5..9c99a1978 100644
--- a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj
+++ b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj
@@ -275,6 +275,7 @@
<ClCompile Include="..\..\..\tools\gfx-unit-test\buffer-barrier-test.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\compute-smoke.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\existing-device-handle-test.cpp" />
+ <ClCompile Include="..\..\..\tools\gfx-unit-test\format-unit-tests.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\get-buffer-resource-handle-test.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\get-cmd-buffer-handle-test.cpp" />
<ClCompile Include="..\..\..\tools\gfx-unit-test\get-cmd-queue-handle-test.cpp" />
@@ -286,6 +287,7 @@
<ItemGroup>
<None Include="..\..\..\tools\gfx-unit-test\buffer-barrier-test.slang" />
<None Include="..\..\..\tools\gfx-unit-test\compute-smoke.slang" />
+ <None Include="..\..\..\tools\gfx-unit-test\format-test-shaders.slang" />
<None Include="..\..\..\tools\gfx-unit-test\mutable-shader-object.slang" />
</ItemGroup>
<ItemGroup>
diff --git a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters
index 7418406e0..280da6d60 100644
--- a/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters
+++ b/build/visual-studio/gfx-unit-test-tool/gfx-unit-test-tool.vcxproj.filters
@@ -26,6 +26,9 @@
<ClCompile Include="..\..\..\tools\gfx-unit-test\existing-device-handle-test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\tools\gfx-unit-test\format-unit-tests.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\..\..\tools\gfx-unit-test\get-buffer-resource-handle-test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -55,6 +58,9 @@
<None Include="..\..\..\tools\gfx-unit-test\compute-smoke.slang">
<Filter>Source Files</Filter>
</None>
+ <None Include="..\..\..\tools\gfx-unit-test\format-test-shaders.slang">
+ <Filter>Source Files</Filter>
+ </None>
<None Include="..\..\..\tools\gfx-unit-test\mutable-shader-object.slang">
<Filter>Source Files</Filter>
</None>
diff --git a/docs/gfx-user-guide/unsupported-formats.md b/docs/gfx-user-guide/unsupported-formats.md
new file mode 100644
index 000000000..a7a51e20d
--- /dev/null
+++ b/docs/gfx-user-guide/unsupported-formats.md
@@ -0,0 +1,264 @@
+Unsupported Formats
+======================
+GFX currently does not support the following listed D3D and Vulkan formats. With the exception of D24_UNORM_S8_UINT, these formats have been omitted as their counterpart API does not have a corresponding format. D24_UNORM_S8_UINT has been omitted as it is only supported by Nvidia.
+
+DXGI_FORMAT_R32G8X24_TYPELESS \
+DXGI_FORMAT_D32_FLOAT_S8X24_UINT \
+DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS \
+DXGI_FORMAT_X32_TYPELESS_G8X24_UINT \
+DXGI_FORMAT_R24G8_TYPELESS \
+DXGI_FORMAT_D24_UNORM_S8_UINT \
+DXGI_FORMAT_R24_UNORM_X8_TYPELESS \
+DXGI_FORMAT_X24_TYPELESS_G8_UINT \
+DXGI_FORMAT_A8_UNORM \
+DXGI_FORMAT_R1_UNORM \
+DXGI_FORMAT_R8G8_B8G8_UNORM \
+DXGI_FORMAT_G8R8_G8B8_UNORM \
+DXGI_FORMAT_BC1_TYPELESS \
+DXGI_FORMAT_BC2_TYPELESS \
+DXGI_FORMAT_BC3_TYPELESS \
+DXGI_FORMAT_BC4_TYPELESS \
+DXGI_FORMAT_BC5_TYPELESS \
+DXGI_FORMAT_B8G8R8X8_UNORM \
+DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM \
+DXGI_FORMAT_B8G8R8X8_TYPELESS \
+DXGI_FORMAT_B8G8R8X8_UNORM_SRGB \
+DXGI_FORMAT_BC6H_TYPELESS \
+DXGI_FORMAT_BC7_TYPELESS \
+DXGI_FORMAT_AYUV \
+DXGI_FORMAT_Y410 \
+DXGI_FORMAT_Y416 \
+DXGI_FORMAT_NV12 \
+DXGI_FORMAT_P010 \
+DXGI_FORMAT_P016 \
+DXGI_FORMAT_420_OPAQUE \
+DXGI_FORMAT_YUY2 \
+DXGI_FORMAT_Y210 \
+DXGI_FORMAT_Y216 \
+DXGI_FORMAT_NV11 \
+DXGI_FORMAT_AI44 \
+DXGI_FORMAT_IA44 \
+DXGI_FORMAT_P8 \
+DXGI_FORMAT_A8P8 \
+DXGI_FORMAT_P208 \
+DXGI_FORMAT_V208 \
+DXGI_FORMAT_V408 \
+DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE \
+DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE \
+
+VK_FORMAT_R4G4_UNORM_PACK8 \
+VK_FORMAT_R4G4B4A4_UNORM_PACK16 \
+VK_FORMAT_B4G4R4A4_UNORM_PACK16 \
+VK_FORMAT_B5G6R5_UNORM_PACK16 \
+VK_FORMAT_R5G5B5A1_UNORM_PACK16 \
+VK_FORMAT_B5G5R5A1_UNORM_PACK16 \
+VK_FORMAT_R8_USCALED \
+VK_FORMAT_R8_SSCALED \
+VK_FORMAT_R8_SRGB \
+VK_FORMAT_R8G8_USCALED \
+VK_FORMAT_R8G8_SSCALED \
+VK_FORMAT_R8G8_SRGB \
+VK_FORMAT_R8G8B8_UNORM \
+VK_FORMAT_R8G8B8_SNORM \
+VK_FORMAT_R8G8B8_USCALED \
+VK_FORMAT_R8G8B8_SSCALED \
+VK_FORMAT_R8G8B8_UINT \
+VK_FORMAT_R8G8B8_SINT \
+VK_FORMAT_R8G8B8_SRGB \
+VK_FORMAT_B8G8R8_UNORM \
+VK_FORMAT_B8G8R8_SNORM \
+VK_FORMAT_B8G8R8_USCALED \
+VK_FORMAT_B8G8R8_SSCALED \
+VK_FORMAT_B8G8R8_UINT \
+VK_FORMAT_B8G8R8_SINT \
+VK_FORMAT_B8G8R8_SRGB \
+VK_FORMAT_R8G8B8A8_USCALED \
+VK_FORMAT_R8G8B8A8_SSCALED \
+VK_FORMAT_B8G8R8A8_SNORM \
+VK_FORMAT_B8G8R8A8_USCALED \
+VK_FORMAT_B8G8R8A8_SSCALED \
+VK_FORMAT_B8G8R8A8_UINT \
+VK_FORMAT_B8G8R8A8_SINT \
+VK_FORMAT_B8G8R8A8_SRGB \
+VK_FORMAT_A8B8G8R8_UNORM_PACK32 \
+VK_FORMAT_A8B8G8R8_SNORM_PACK32 \
+VK_FORMAT_A8B8G8R8_USCALED_PACK32 \
+VK_FORMAT_A8B8G8R8_SSCALED_PACK32 \
+VK_FORMAT_A8B8G8R8_UINT_PACK32 \
+VK_FORMAT_A8B8G8R8_SINT_PACK32 \
+VK_FORMAT_A8B8G8R8_SRGB_PACK32 \
+VK_FORMAT_A2R10G10B10_UNORM_PACK32 \
+VK_FORMAT_A2R10G10B10_SNORM_PACK32 \
+VK_FORMAT_A2R10G10B10_USCALED_PACK32 \
+VK_FORMAT_A2R10G10B10_SSCALED_PACK32 \
+VK_FORMAT_A2R10G10B10_UINT_PACK32 \
+VK_FORMAT_A2R10G10B10_SINT_PACK32 \
+VK_FORMAT_A2B10G10R10_SNORM_PACK32 \
+VK_FORMAT_A2B10G10R10_USCALED_PACK32 \
+VK_FORMAT_A2B10G10R10_SSCALED_PACK32 \
+VK_FORMAT_A2B10G10R10_SINT_PACK32 \
+VK_FORMAT_R16_USCALED \
+VK_FORMAT_R16_SSCALED \
+VK_FORMAT_R16G16_USCALED \
+VK_FORMAT_R16G16_SSCALED \
+VK_FORMAT_R16G16B16_UNORM \
+VK_FORMAT_R16G16B16_SNORM \
+VK_FORMAT_R16G16B16_USCALED \
+VK_FORMAT_R16G16B16_SSCALED \
+VK_FORMAT_R16G16B16_UINT \
+VK_FORMAT_R16G16B16_SINT \
+VK_FORMAT_R16G16B16_SFLOAT \
+VK_FORMAT_R16G16B16A16_USCALED \
+VK_FORMAT_R16G16B16A16_SSCALED \
+VK_FORMAT_R64_UINT \
+VK_FORMAT_R64_SINT \
+VK_FORMAT_R64_SFLOAT \
+VK_FORMAT_R64G64_UINT \
+VK_FORMAT_R64G64_SINT \
+VK_FORMAT_R64G64_SFLOAT \
+VK_FORMAT_R64G64B64_UINT \
+VK_FORMAT_R64G64B64_SINT \
+VK_FORMAT_R64G64B64_SFLOAT \
+VK_FORMAT_R64G64B64A64_UINT \
+VK_FORMAT_R64G64B64A64_SINT \
+VK_FORMAT_R64G64B64A64_SFLOAT \
+VK_FORMAT_X8_D24_UNORM_PACK32 \
+VK_FORMAT_S8_UINT \
+VK_FORMAT_D16_UNORM_S8_UINT \
+VK_FORMAT_D24_UNORM_S8_UINT \
+VK_FORMAT_D32_SFLOAT_S8_UINT \
+VK_FORMAT_BC1_RGB_UNORM_BLOCK \
+VK_FORMAT_BC1_RGB_SRGB_BLOCK \
+VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK \
+VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK \
+VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK \
+VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK \
+VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK \
+VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK \
+VK_FORMAT_EAC_R11_UNORM_BLOCK \
+VK_FORMAT_EAC_R11_SNORM_BLOCK \
+VK_FORMAT_EAC_R11G11_UNORM_BLOCK \
+VK_FORMAT_EAC_R11G11_SNORM_BLOCK \
+VK_FORMAT_ASTC_4x4_UNORM_BLOCK \
+VK_FORMAT_ASTC_4x4_SRGB_BLOCK \
+VK_FORMAT_ASTC_5x4_UNORM_BLOCK \
+VK_FORMAT_ASTC_5x4_SRGB_BLOCK \
+VK_FORMAT_ASTC_5x5_UNORM_BLOCK \
+VK_FORMAT_ASTC_5x5_SRGB_BLOCK \
+VK_FORMAT_ASTC_6x5_UNORM_BLOCK \
+VK_FORMAT_ASTC_6x5_SRGB_BLOCK \
+VK_FORMAT_ASTC_6x6_UNORM_BLOCK \
+VK_FORMAT_ASTC_6x6_SRGB_BLOCK \
+VK_FORMAT_ASTC_8x5_UNORM_BLOCK \
+VK_FORMAT_ASTC_8x5_SRGB_BLOCK \
+VK_FORMAT_ASTC_8x6_UNORM_BLOCK \
+VK_FORMAT_ASTC_8x6_SRGB_BLOCK \
+VK_FORMAT_ASTC_8x8_UNORM_BLOCK \
+VK_FORMAT_ASTC_8x8_SRGB_BLOCK \
+VK_FORMAT_ASTC_10x5_UNORM_BLOCK \
+VK_FORMAT_ASTC_10x5_SRGB_BLOCK \
+VK_FORMAT_ASTC_10x6_UNORM_BLOCK \
+VK_FORMAT_ASTC_10x6_SRGB_BLOCK \
+VK_FORMAT_ASTC_10x8_UNORM_BLOCK \
+VK_FORMAT_ASTC_10x8_SRGB_BLOCK \
+VK_FORMAT_ASTC_10x10_UNORM_BLOCK \
+VK_FORMAT_ASTC_10x10_SRGB_BLOCK \
+VK_FORMAT_ASTC_12x10_UNORM_BLOCK \
+VK_FORMAT_ASTC_12x10_SRGB_BLOCK \
+VK_FORMAT_ASTC_12x12_UNORM_BLOCK \
+VK_FORMAT_ASTC_12x12_SRGB_BLOCK \
+VK_FORMAT_G8B8G8R8_422_UNORM \
+VK_FORMAT_B8G8R8G8_422_UNORM \
+VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM \
+VK_FORMAT_G8_B8R8_2PLANE_420_UNORM \
+VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM \
+VK_FORMAT_G8_B8R8_2PLANE_422_UNORM \
+VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM \
+VK_FORMAT_R10X6_UNORM_PACK16 \
+VK_FORMAT_R10X6G10X6_UNORM_2PACK16 \
+VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 \
+VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 \
+VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 \
+VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 \
+VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 \
+VK_FORMAT_R12X4_UNORM_PACK16 \
+VK_FORMAT_R12X4G12X4_UNORM_2PACK16 \
+VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 \
+VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 \
+VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 \
+VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 \
+VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 \
+VK_FORMAT_G16B16G16R16_422_UNORM \
+VK_FORMAT_B16G16R16G16_422_UNORM \
+VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM \
+VK_FORMAT_G16_B16R16_2PLANE_420_UNORM \
+VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM \
+VK_FORMAT_G16_B16R16_2PLANE_422_UNORM \
+VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM \
+VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG \
+VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG \
+VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG \
+VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG \
+VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG \
+VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG \
+VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG \
+VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG \
+VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT \
+VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT \
+VK_FORMAT_G8_B8R8_2PLANE_444_UNORM_EXT \
+VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT \
+VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT \
+VK_FORMAT_G16_B16R16_2PLANE_444_UNORM_EXT \
+VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT \
+VK_FORMAT_G8B8G8R8_422_UNORM_KHR \
+VK_FORMAT_B8G8R8G8_422_UNORM_KHR \
+VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR \
+VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR \
+VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR \
+VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR \
+VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR \
+VK_FORMAT_R10X6_UNORM_PACK16_KHR \
+VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR \
+VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR \
+VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR \
+VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR \
+VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR \
+VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR \
+VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR \
+VK_FORMAT_R12X4_UNORM_PACK16_KHR \
+VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR \
+VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR \
+VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR \
+VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR \
+VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR \
+VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR \
+VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR \
+VK_FORMAT_G16B16G16R16_422_UNORM_KHR \
+VK_FORMAT_B16G16R16G16_422_UNORM_KHR \
+VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR \
+VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR \
+VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR \
+VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR \
+VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR \ No newline at end of file
diff --git a/examples/example-base/example-base.cpp b/examples/example-base/example-base.cpp
index c45e3cc27..a7a8e7673 100644
--- a/examples/example-base/example-base.cpp
+++ b/examples/example-base/example-base.cpp
@@ -50,7 +50,7 @@ Slang::Result WindowedAppBase::initializeBase(
// Create swapchain and framebuffers.
gfx::ISwapchain::Desc swapchainDesc = {};
- swapchainDesc.format = gfx::Format::RGBA_Unorm_UInt8;
+ swapchainDesc.format = gfx::Format::R8G8B8A8_UNORM;
swapchainDesc.width = width;
swapchainDesc.height = height;
swapchainDesc.imageCount = kSwapchainImageCount;
@@ -59,7 +59,7 @@ Slang::Result WindowedAppBase::initializeBase(
gSwapchain = gDevice->createSwapchain(swapchainDesc, windowHandle);
IFramebufferLayout::AttachmentLayout renderTargetLayout = {gSwapchain->getDesc().format, 1};
- IFramebufferLayout::AttachmentLayout depthLayout = {gfx::Format::D_Float32, 1};
+ IFramebufferLayout::AttachmentLayout depthLayout = {gfx::Format::D32_FLOAT, 1};
IFramebufferLayout::Desc framebufferLayoutDesc;
framebufferLayoutDesc.renderTargetCount = 1;
framebufferLayoutDesc.renderTargets = &renderTargetLayout;
@@ -117,7 +117,7 @@ void WindowedAppBase::createSwapchainFramebuffers()
depthBufferDesc.size.width = gSwapchain->getDesc().width;
depthBufferDesc.size.height = gSwapchain->getDesc().height;
depthBufferDesc.size.depth = 1;
- depthBufferDesc.format = gfx::Format::D_Float32;
+ depthBufferDesc.format = gfx::Format::D32_FLOAT;
depthBufferDesc.defaultState = ResourceState::DepthWrite;
depthBufferDesc.allowedStates = ResourceStateSet(ResourceState::DepthWrite);
@@ -136,7 +136,7 @@ void WindowedAppBase::createSwapchainFramebuffers()
gfx::IResourceView::Desc depthBufferViewDesc;
memset(&depthBufferViewDesc, 0, sizeof(depthBufferViewDesc));
- depthBufferViewDesc.format = gfx::Format::D_Float32;
+ depthBufferViewDesc.format = gfx::Format::D32_FLOAT;
depthBufferViewDesc.renderTarget.shape = gfx::IResource::Type::Texture2D;
depthBufferViewDesc.type = gfx::IResourceView::Type::DepthStencil;
ComPtr<gfx::IResourceView> dsv =
diff --git a/examples/model-viewer/main.cpp b/examples/model-viewer/main.cpp
index 6e21f9050..76b8fca05 100644
--- a/examples/model-viewer/main.cpp
+++ b/examples/model-viewer/main.cpp
@@ -744,9 +744,9 @@ Result initialize()
SLANG_RETURN_ON_FAIL(context.init(gDevice));
InputElementDesc inputElements[] = {
- {"POSITION", 0, Format::RGB_Float32, offsetof(Model::Vertex, position) },
- {"NORMAL", 0, Format::RGB_Float32, offsetof(Model::Vertex, normal) },
- {"UV", 0, Format::RG_Float32, offsetof(Model::Vertex, uv) },
+ {"POSITION", 0, Format::R32G32B32_FLOAT, offsetof(Model::Vertex, position) },
+ {"NORMAL", 0, Format::R32G32B32_FLOAT, offsetof(Model::Vertex, normal) },
+ {"UV", 0, Format::R32G32_FLOAT, offsetof(Model::Vertex, uv) },
};
auto inputLayout = gDevice->createInputLayout(
&inputElements[0],
@@ -870,7 +870,7 @@ void renderFrame(int frameIndex) override
for(auto& model : gModels)
{
drawCommandEncoder->setVertexBuffer(0, model->vertexBuffer, sizeof(Model::Vertex));
- drawCommandEncoder->setIndexBuffer(model->indexBuffer, Format::R_UInt32);
+ drawCommandEncoder->setIndexBuffer(model->indexBuffer, Format::R32_UINT);
// For each model we provide a parameter
// block that holds the per-model transformation
// parameters, corresponding to the `PerModel` type
diff --git a/examples/ray-tracing-pipeline/main.cpp b/examples/ray-tracing-pipeline/main.cpp
index 3c83447b4..a1539f6a7 100644
--- a/examples/ray-tracing-pipeline/main.cpp
+++ b/examples/ray-tracing-pipeline/main.cpp
@@ -352,10 +352,10 @@ Slang::Result initialize()
geomDesc.type = IAccelerationStructure::GeometryType::Triangles;
geomDesc.content.triangles.indexCount = kIndexCount;
geomDesc.content.triangles.indexData = gIndexBuffer->getDeviceAddress();
- geomDesc.content.triangles.indexFormat = Format::R_UInt32;
+ geomDesc.content.triangles.indexFormat = Format::R32_UINT;
geomDesc.content.triangles.vertexCount = kVertexCount;
geomDesc.content.triangles.vertexData = gVertexBuffer->getDeviceAddress();
- geomDesc.content.triangles.vertexFormat = Format::RGB_Float32;
+ geomDesc.content.triangles.vertexFormat = Format::R32G32B32_FLOAT;
geomDesc.content.triangles.vertexStride = sizeof(Vertex);
geomDesc.content.triangles.transform3x4 = gTransformBuffer->getDeviceAddress();
accelerationStructureBuildInputs.geometryDescs = &geomDesc;
@@ -505,7 +505,7 @@ Slang::Result initialize()
return SLANG_FAIL;
InputElementDesc inputElements[] = {
- {"POSITION", 0, Format::RG_Float32, offsetof(FullScreenTriangle::Vertex, position)},
+ {"POSITION", 0, Format::R32G32_FLOAT, offsetof(FullScreenTriangle::Vertex, position)},
};
auto inputLayout = gDevice->createInputLayout(&inputElements[0], SLANG_COUNT_OF(inputElements));
if (!inputLayout)
@@ -554,7 +554,7 @@ void createResultTexture()
resultTextureDesc.size.height = windowHeight;
resultTextureDesc.size.depth = 1;
resultTextureDesc.defaultState = ResourceState::UnorderedAccess;
- resultTextureDesc.format = Format::RGBA_Float16;
+ resultTextureDesc.format = Format::R16G16B16A16_FLOAT;
gResultTexture = gDevice->createTextureResource(resultTextureDesc);
IResourceView::Desc resultUAVDesc = {};
resultUAVDesc.format = resultTextureDesc.format;
diff --git a/examples/ray-tracing/main.cpp b/examples/ray-tracing/main.cpp
index bb02e157a..e51a601a2 100644
--- a/examples/ray-tracing/main.cpp
+++ b/examples/ray-tracing/main.cpp
@@ -344,10 +344,10 @@ Slang::Result initialize()
geomDesc.type = IAccelerationStructure::GeometryType::Triangles;
geomDesc.content.triangles.indexCount = kIndexCount;
geomDesc.content.triangles.indexData = gIndexBuffer->getDeviceAddress();
- geomDesc.content.triangles.indexFormat = Format::R_UInt32;
+ geomDesc.content.triangles.indexFormat = Format::R32_UINT;
geomDesc.content.triangles.vertexCount = kVertexCount;
geomDesc.content.triangles.vertexData = gVertexBuffer->getDeviceAddress();
- geomDesc.content.triangles.vertexFormat = Format::RGB_Float32;
+ geomDesc.content.triangles.vertexFormat = Format::R32G32B32_FLOAT;
geomDesc.content.triangles.vertexStride = sizeof(Vertex);
geomDesc.content.triangles.transform3x4 = gTransformBuffer->getDeviceAddress();
accelerationStructureBuildInputs.geometryDescs = &geomDesc;
@@ -497,7 +497,7 @@ Slang::Result initialize()
return SLANG_FAIL;
InputElementDesc inputElements[] = {
- {"POSITION", 0, Format::RG_Float32, offsetof(FullScreenTriangle::Vertex, position)},
+ {"POSITION", 0, Format::R32G32_FLOAT, offsetof(FullScreenTriangle::Vertex, position)},
};
auto inputLayout = gDevice->createInputLayout(&inputElements[0], SLANG_COUNT_OF(inputElements));
if (!inputLayout)
@@ -535,7 +535,7 @@ void createResultTexture()
resultTextureDesc.size.height = windowHeight;
resultTextureDesc.size.depth = 1;
resultTextureDesc.defaultState = ResourceState::UnorderedAccess;
- resultTextureDesc.format = Format::RGBA_Float16;
+ resultTextureDesc.format = Format::R16G16B16A16_FLOAT;
gResultTexture = gDevice->createTextureResource(resultTextureDesc);
IResourceView::Desc resultUAVDesc = {};
resultUAVDesc.format = resultTextureDesc.format;
diff --git a/examples/shader-toy/main.cpp b/examples/shader-toy/main.cpp
index c41bd71ca..e4e2cafcc 100644
--- a/examples/shader-toy/main.cpp
+++ b/examples/shader-toy/main.cpp
@@ -282,7 +282,7 @@ Result initialize()
gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) { handleEvent(e); };
InputElementDesc inputElements[] = {
- { "POSITION", 0, Format::RG_Float32, offsetof(FullScreenTriangle::Vertex, position) },
+ { "POSITION", 0, Format::R32G32_FLOAT, offsetof(FullScreenTriangle::Vertex, position) },
};
auto inputLayout = gDevice->createInputLayout(
&inputElements[0],
diff --git a/examples/triangle/main.cpp b/examples/triangle/main.cpp
index 0f6c31809..f182e0a0a 100644
--- a/examples/triangle/main.cpp
+++ b/examples/triangle/main.cpp
@@ -224,8 +224,8 @@ Slang::Result initialize()
// First, we create an input layout:
//
InputElementDesc inputElements[] = {
- { "POSITION", 0, Format::RGB_Float32, offsetof(Vertex, position) },
- { "COLOR", 0, Format::RGB_Float32, offsetof(Vertex, color) },
+ { "POSITION", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, position) },
+ { "COLOR", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, color) },
};
auto inputLayout = gDevice->createInputLayout(
&inputElements[0],
diff --git a/slang-gfx.h b/slang-gfx.h
index cf77113f0..5dd3319fb 100644
--- a/slang-gfx.h
+++ b/slang-gfx.h
@@ -128,62 +128,219 @@ public:
// Dont' change without keeping in sync with Format
#define GFX_FORMAT(x) \
- x( Unknown, 0) \
+ x( Unknown, 0, 0) \
\
- x(RGBA_Float32, sizeof(float) * 4) \
- x(RGB_Float32, sizeof(float) * 3) \
- x(RG_Float32, sizeof(float) * 2) \
- x(R_Float32, sizeof(float)) \
+ x(R32G32B32A32_TYPELESS, 16, 1) \
+ x(R32G32B32_TYPELESS, 12, 1) \
+ x(R32G32_TYPELESS, 8, 1) \
+ x(R32_TYPELESS, 4, 1) \
\
- x(RGBA_Float16, sizeof(uint16_t) * 4) \
- x(RG_Float16, sizeof(uint16_t) * 2) \
- x(R_Float16, sizeof(uint16_t)) \
+ x(R16G16B16A16_TYPELESS, 8, 1) \
+ x(R16G16_TYPELESS, 4, 1) \
+ x(R16_TYPELESS, 2, 1) \
\
- x(RGBA_Unorm_UInt8, sizeof(uint32_t)) \
- x(BGRA_Unorm_UInt8, sizeof(uint32_t)) \
- x(RGBA_Snorm_UInt16, sizeof(uint32_t)*2) \
- x(RG_Snorm_UInt16, sizeof(uint32_t)) \
+ x(R8G8B8A8_TYPELESS, 4, 1) \
+ x(R8G8_TYPELESS, 2, 1) \
+ x(R8_TYPELESS, 1, 1) \
+ x(B8G8R8A8_TYPELESS, 4, 1) \
\
- x(R_UInt16, sizeof(uint16_t)) \
- x(R_UInt32, sizeof(uint32_t)) \
+ x(R32G32B32A32_FLOAT, 16, 1) \
+ x(R32G32B32_FLOAT, 12, 1) \
+ x(R32G32_FLOAT, 8, 1) \
+ x(R32_FLOAT, 4, 1) \
\
- x(D_Float32, sizeof(float)) \
- x(D_Unorm24_S8, sizeof(uint32_t))
+ x(R16G16B16A16_FLOAT, 8, 1) \
+ x(R16G16_FLOAT, 4, 1) \
+ x(R16_FLOAT, 2, 1) \
+ \
+ x(R32G32B32A32_UINT, 16, 1) \
+ x(R32G32B32_UINT, 12, 1) \
+ x(R32G32_UINT, 8, 1) \
+ x(R32_UINT, 4, 1) \
+ \
+ x(R16G16B16A16_UINT, 8, 1) \
+ x(R16G16_UINT, 4, 1) \
+ x(R16_UINT, 2, 1) \
+ \
+ x(R8G8B8A8_UINT, 4, 1) \
+ x(R8G8_UINT, 2, 1) \
+ x(R8_UINT, 1, 1) \
+ \
+ x(R32G32B32A32_SINT, 16, 1) \
+ x(R32G32B32_SINT, 12, 1) \
+ x(R32G32_SINT, 8, 1) \
+ x(R32_SINT, 4, 1) \
+ \
+ x(R16G16B16A16_SINT, 8, 1) \
+ x(R16G16_SINT, 4, 1) \
+ x(R16_SINT, 2, 1) \
+ \
+ x(R8G8B8A8_SINT, 4, 1) \
+ x(R8G8_SINT, 2, 1) \
+ x(R8_SINT, 1, 1) \
+ \
+ x(R16G16B16A16_UNORM, 8, 1) \
+ x(R16G16_UNORM, 4, 1) \
+ x(R16_UNORM, 2, 1) \
+ \
+ x(R8G8B8A8_UNORM, 4, 1) \
+ x(R8G8B8A8_UNORM_SRGB, 4, 1) \
+ x(R8G8_UNORM, 2, 1) \
+ x(R8_UNORM, 1, 1) \
+ x(B8G8R8A8_UNORM, 4, 1) \
+ \
+ x(R16G16B16A16_SNORM, 8, 1) \
+ x(R16G16_SNORM, 4, 1) \
+ x(R16_SNORM, 2, 1) \
+ \
+ x(R8G8B8A8_SNORM, 4, 1) \
+ x(R8G8_SNORM, 2, 1) \
+ x(R8_SNORM, 1, 1) \
+ \
+ x(D32_FLOAT, 4, 1) \
+ x(D16_UNORM, 2, 1) \
+ \
+ x(B4G4R4A4_UNORM, 2, 1) \
+ x(B5G6R5_UNORM, 2, 1) \
+ x(B5G5R5A1_UNORM, 2, 1) \
+ \
+ x(R9G9B9E5_SHAREDEXP, 4, 1) \
+ x(R10G10B10A2_TYPELESS, 4, 1) \
+ x(R10G10B10A2_UNORM, 4, 1) \
+ x(R10G10B10A2_UINT, 4, 1) \
+ x(R11G11B10_FLOAT, 4, 1) \
+ \
+ x(BC1_UNORM, 8, 16) \
+ x(BC1_UNORM_SRGB, 8, 16) \
+ x(BC2_UNORM, 16, 16) \
+ x(BC2_UNORM_SRGB, 16, 16) \
+ x(BC3_UNORM, 16, 16) \
+ x(BC3_UNORM_SRGB, 16, 16) \
+ x(BC4_UNORM, 8, 16) \
+ x(BC4_SNORM, 8, 16) \
+ x(BC5_UNORM, 16, 16) \
+ x(BC5_SNORM, 16, 16) \
+ x(BC6H_UF16, 16, 16) \
+ x(BC6H_SF16, 16, 16) \
+ x(BC7_UNORM, 16, 16) \
+ x(BC7_UNORM_SRGB, 16, 16)
/// Different formats of things like pixels or elements of vertices
/// NOTE! Any change to this type (adding, removing, changing order) - must also be reflected in changes GFX_FORMAT
enum class Format
{
+ // D3D formats omitted: 19-22, 44-47, 65-66, 68-70, 73, 76, 79, 82, 88-89, 92-94, 97, 100-114
+ // These formats are omitted due to lack of a corresponding Vulkan format. D24_UNORM_S8_UINT (DXGI_FORMAT 45)
+ // has a matching Vulkan format but is also omitted as it is only supported by Nvidia.
Unknown,
- RGBA_Float32,
- RGB_Float32,
- RG_Float32,
- R_Float32,
-
- RGBA_Float16,
- RG_Float16,
- R_Float16,
-
- RGBA_Unorm_UInt8,
- BGRA_Unorm_UInt8,
-
- RGBA_Snorm_UInt16,
- RG_Snorm_UInt16,
-
- R_UInt16,
- R_UInt32,
-
- D_Float32,
- D_Unorm24_S8,
+ R32G32B32A32_TYPELESS,
+ R32G32B32_TYPELESS,
+ R32G32_TYPELESS,
+ R32_TYPELESS,
+
+ R16G16B16A16_TYPELESS,
+ R16G16_TYPELESS,
+ R16_TYPELESS,
+
+ R8G8B8A8_TYPELESS,
+ R8G8_TYPELESS,
+ R8_TYPELESS,
+ B8G8R8A8_TYPELESS,
+
+ R32G32B32A32_FLOAT,
+ R32G32B32_FLOAT,
+ R32G32_FLOAT,
+ R32_FLOAT,
+
+ R16G16B16A16_FLOAT,
+ R16G16_FLOAT,
+ R16_FLOAT,
+
+ R32G32B32A32_UINT,
+ R32G32B32_UINT,
+ R32G32_UINT,
+ R32_UINT,
+
+ R16G16B16A16_UINT,
+ R16G16_UINT,
+ R16_UINT,
+
+ R8G8B8A8_UINT,
+ R8G8_UINT,
+ R8_UINT,
+
+ R32G32B32A32_SINT,
+ R32G32B32_SINT,
+ R32G32_SINT,
+ R32_SINT,
+
+ R16G16B16A16_SINT,
+ R16G16_SINT,
+ R16_SINT,
+
+ R8G8B8A8_SINT,
+ R8G8_SINT,
+ R8_SINT,
+
+ R16G16B16A16_UNORM,
+ R16G16_UNORM,
+ R16_UNORM,
+
+ R8G8B8A8_UNORM,
+ R8G8B8A8_UNORM_SRGB,
+ R8G8_UNORM,
+ R8_UNORM,
+ B8G8R8A8_UNORM,
+
+ R16G16B16A16_SNORM,
+ R16G16_SNORM,
+ R16_SNORM,
+
+ R8G8B8A8_SNORM,
+ R8G8_SNORM,
+ R8_SNORM,
+
+ D32_FLOAT,
+ D16_UNORM,
+
+ B4G4R4A4_UNORM,
+ B5G6R5_UNORM,
+ B5G5R5A1_UNORM,
+
+ R9G9B9E5_SHAREDEXP,
+ R10G10B10A2_TYPELESS,
+ R10G10B10A2_UNORM,
+ R10G10B10A2_UINT,
+ R11G11B10_FLOAT,
+
+ BC1_UNORM,
+ BC1_UNORM_SRGB,
+ BC2_UNORM,
+ BC2_UNORM_SRGB,
+ BC3_UNORM,
+ BC3_UNORM_SRGB,
+ BC4_UNORM,
+ BC4_SNORM,
+ BC5_UNORM,
+ BC5_SNORM,
+ BC6H_UF16,
+ BC6H_SF16,
+ BC7_UNORM,
+ BC7_UNORM_SRGB,
CountOf,
};
struct FormatInfo
{
- uint8_t channelCount; ///< The amount of channels in the format. Only set if the channelType is set
- uint8_t channelType; ///< One of SlangScalarType None if type isn't made up of elements of type.
+ uint8_t channelCount; ///< The amount of channels in the format. Only set if the channelType is set
+ uint8_t channelType; ///< One of SlangScalarType None if type isn't made up of elements of type.
+
+ uint32_t blockSizeInBytes; ///< The size of a block in bytes.
+ uint32_t pixelsPerBlock; ///< The number of pixels contained in a block.
+ uint32_t blockWidth;
+ uint32_t blockHeight;
};
struct InputElementDesc
@@ -1774,11 +1931,14 @@ public:
extern "C"
{
- /// Gets the size in bytes of a Format type. Returns 0 if a size is not defined/invalid
- SLANG_GFX_API size_t SLANG_MCALL gfxGetFormatSize(Format format);
+ /// Checks if format is compressed
+ SLANG_GFX_API bool gfxIsCompressedFormat(Format format);
+
+ /// Checks if format is typeless
+ SLANG_GFX_API bool gfxIsTypelessFormat(Format format);
/// Gets information about the format
- SLANG_GFX_API FormatInfo gfxGetFormatInfo(Format format);
+ SLANG_GFX_API SlangResult gfxGetFormatInfo(Format format, FormatInfo* outInfo);
/// Given a type returns a function that can construct it, or nullptr if there isn't one
SLANG_GFX_API SlangResult SLANG_MCALL
diff --git a/tests/bugs/texture2d-gather.hlsl b/tests/bugs/texture2d-gather.hlsl
index 6eb8b1af7..d84c122b5 100644
--- a/tests/bugs/texture2d-gather.hlsl
+++ b/tests/bugs/texture2d-gather.hlsl
@@ -1,5 +1,5 @@
//TEST(smoke):COMPARE_HLSL_RENDER:
-//TEST_INPUT: Texture2D(size=16, content=chessboard, format=R_Float32):name g_texture
+//TEST_INPUT: Texture2D(size=16, content=chessboard, format=R32_FLOAT):name g_texture
//TEST_INPUT: Sampler :name g_sampler
Texture2D<float> g_texture : register(t0);
diff --git a/tests/compute/half-rw-texture-convert.slang b/tests/compute/half-rw-texture-convert.slang
index 063f2329e..f3d8eedb5 100644
--- a/tests/compute/half-rw-texture-convert.slang
+++ b/tests/compute/half-rw-texture-convert.slang
@@ -11,15 +11,15 @@
// Note that this test is a little silly. The output does not confirm that the write actually worked.
// half-rw-texture-convert2.slang tests this
-//TEST_INPUT: RWTexture2D(format=R_Float16, size=4, content = one, mipMaps = 1):name rwt2D
+//TEST_INPUT: RWTexture2D(format=R16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D
[format("r16f")]
RWTexture2D<float> rwt2D;
-//TEST_INPUT: RWTexture2D(format=RG_Float16, size=4, content = one, mipMaps = 1):name rwt2D_2
+//TEST_INPUT: RWTexture2D(format=R16G16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D_2
[format("rg16f")]
RWTexture2D<float2> rwt2D_2;
-//TEST_INPUT: RWTexture2D(format=RGBA_Float16, size=4, content = one, mipMaps = 1):name rwt2D_4
+//TEST_INPUT: RWTexture2D(format=R16G16B16A16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D_4
[format("rgba16f")]
RWTexture2D<float4> rwt2D_4;
diff --git a/tests/compute/half-rw-texture-convert2.slang b/tests/compute/half-rw-texture-convert2.slang
index c190cf37b..1937b4c8e 100644
--- a/tests/compute/half-rw-texture-convert2.slang
+++ b/tests/compute/half-rw-texture-convert2.slang
@@ -8,15 +8,15 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj -render-features half
-//TEST_INPUT: RWTexture2D(format=R_Float16, size=4, content = one, mipMaps = 1):name rwt2D
+//TEST_INPUT: RWTexture2D(format=R16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D
[format("r16f")]
RWTexture2D<float> rwt2D;
-//TEST_INPUT: RWTexture2D(format=RG_Float16, size=4, content = one, mipMaps = 1):name rwt2D_2
+//TEST_INPUT: RWTexture2D(format=R16G16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D_2
[format("rg16f")]
RWTexture2D<float2> rwt2D_2;
-//TEST_INPUT: RWTexture2D(format=RGBA_Float16, size=4, content = one, mipMaps = 1):name rwt2D_4
+//TEST_INPUT: RWTexture2D(format=R16G16B16A16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D_4
[format("rgba16f")]
RWTexture2D<float4> rwt2D_4;
diff --git a/tests/compute/half-rw-texture-simple.slang b/tests/compute/half-rw-texture-simple.slang
index f9b393529..8077b36a6 100644
--- a/tests/compute/half-rw-texture-simple.slang
+++ b/tests/compute/half-rw-texture-simple.slang
@@ -10,13 +10,13 @@
//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj -render-features half
-//TEST_INPUT: RWTexture1D(format=R_Float16, size=4, content = one, mipMaps = 1):name rwt1D
+//TEST_INPUT: RWTexture1D(format=R16_FLOAT, size=4, content = one, mipMaps = 1):name rwt1D
RWTexture1D<half> rwt1D;
-//TEST_INPUT: RWTexture2D(format=R_Float16, size=4, content = one, mipMaps = 1):name rwt2D
+//TEST_INPUT: RWTexture2D(format=R16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D
RWTexture2D<half> rwt2D;
-//TEST_INPUT: RWTexture2D(format=RGBA_Float16, size=4, content = one, mipMaps = 1):name rwt2D_4
+//TEST_INPUT: RWTexture2D(format=R16G16B16A16_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D_4
RWTexture2D<half4> rwt2D_4;
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
diff --git a/tests/compute/rw-texture-simple.slang b/tests/compute/rw-texture-simple.slang
index aba12eee7..268337956 100644
--- a/tests/compute/rw-texture-simple.slang
+++ b/tests/compute/rw-texture-simple.slang
@@ -8,11 +8,11 @@
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj
-//TEST_INPUT: RWTexture1D(format=R_Float32, size=4, content = one, mipMaps = 1):name rwt1D
+//TEST_INPUT: RWTexture1D(format=R32_FLOAT, size=4, content = one, mipMaps = 1):name rwt1D
RWTexture1D<float> rwt1D;
-//TEST_INPUT: RWTexture2D(format=R_Float32, size=4, content = one, mipMaps = 1):name rwt2D
+//TEST_INPUT: RWTexture2D(format=R32_FLOAT, size=4, content = one, mipMaps = 1):name rwt2D
RWTexture2D<float> rwt2D;
-//TEST_INPUT: RWTexture3D(format=R_Float32, size=4, content = one, mipMaps = 1):name rwt3D
+//TEST_INPUT: RWTexture3D(format=R32_FLOAT, size=4, content = one, mipMaps = 1):name rwt3D
RWTexture3D<float> rwt3D;
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
diff --git a/tools/gfx-unit-test/format-test-shaders.slang b/tools/gfx-unit-test/format-test-shaders.slang
new file mode 100644
index 000000000..49d4f6b69
--- /dev/null
+++ b/tools/gfx-unit-test/format-test-shaders.slang
@@ -0,0 +1,220 @@
+// format-test-shaders.slang - Shaders used by the unit tests in format-uint-tests.cpp
+
+// Copy the contents of "tex" into "buffer". These are for textures containing UINT data.
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexUint4(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<uint4> tex,
+ uniform RWStructuredBuffer<uint> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ uint4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 4] = result.r;
+ buffer[sv_dispatchThreadID.x * 4 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 4 + 2] = result.b;
+ buffer[sv_dispatchThreadID.x * 4 + 3] = result.a;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexUint3(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<uint4> tex,
+ uniform RWStructuredBuffer<uint> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ uint4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 3] = result.r;
+ buffer[sv_dispatchThreadID.x * 3 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 3 + 2] = result.b;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexUint2(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<uint2> tex,
+ uniform RWStructuredBuffer<uint> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ uint2 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 2] = result.r;
+ buffer[sv_dispatchThreadID.x * 2 + 1] = result.g;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexUint(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<uint> tex,
+ uniform RWStructuredBuffer<uint> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ buffer[sv_dispatchThreadID.x] = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+}
+
+// Copy the contents of "tex" into "buffer". These are for textures containing SINT data.
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexInt4(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<int4> tex,
+ uniform RWStructuredBuffer<int> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ int4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 4] = result.r;
+ buffer[sv_dispatchThreadID.x * 4 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 4 + 2] = result.b;
+ buffer[sv_dispatchThreadID.x * 4 + 3] = result.a;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexInt3(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<int4> tex,
+ uniform RWStructuredBuffer<int> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ int4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 3] = result.r;
+ buffer[sv_dispatchThreadID.x * 3 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 3 + 2] = result.b;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexInt2(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<int2> tex,
+ uniform RWStructuredBuffer<int> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ int2 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 2] = result.r;
+ buffer[sv_dispatchThreadID.x * 2 + 1] = result.g;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexInt(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<int> tex,
+ uniform RWStructuredBuffer<int> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ buffer[sv_dispatchThreadID.x] = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+}
+
+// Copy the contents of "tex" into "buffer". These are for textures containing FLOAT data.
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexFloat4(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float4> tex,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ float4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 4] = result.r;
+ buffer[sv_dispatchThreadID.x * 4 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 4 + 2] = result.b;
+ buffer[sv_dispatchThreadID.x * 4 + 3] = result.a;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexFloat3(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float4> tex,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ float4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 3] = result.r;
+ buffer[sv_dispatchThreadID.x * 3 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 3 + 2] = result.b;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexFloat2(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float2> tex,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ float2 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+ buffer[sv_dispatchThreadID.x * 2] = result.r;
+ buffer[sv_dispatchThreadID.x * 2 + 1] = result.g;
+}
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void copyTexFloat(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float> tex,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ uint width;
+ uint height;
+ tex.GetDimensions(width, height);
+ buffer[sv_dispatchThreadID.x] = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)];
+}
+
+// Sample from "tex" at texture coordinates (0.5, 0.5) and save the results in "buffer".
+[shader("compute")]
+[numthreads(4,1,1)]
+void sampleTex(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float4> tex,
+ uniform SamplerState sampler,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ float4 result = tex.SampleLevel(sampler, float2(0.5, 0.5), 0);
+ buffer[sv_dispatchThreadID.x * 4] = result.r;
+ buffer[sv_dispatchThreadID.x * 4 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 4 + 2] = result.b;
+ buffer[sv_dispatchThreadID.x * 4 + 3] = result.a;
+}
+
+// Sample from "tex" at texture coordinates (0.5, 0.5) and save the resuls in "buffer".
+// This should only be used with textures containing two mip levels.
+[shader("compute")]
+[numthreads(2,1,1)]
+void sampleMips(
+ uint3 sv_dispatchThreadID : SV_DispatchThreadID,
+ uniform Texture2D<float4> tex,
+ uniform SamplerState sampler,
+ uniform RWStructuredBuffer<float> buffer)
+{
+ float4 result = tex.SampleLevel(sampler, float2(0.5, 0.5), float(sv_dispatchThreadID.x));
+ buffer[sv_dispatchThreadID.x * 4] = result.r;
+ buffer[sv_dispatchThreadID.x * 4 + 1] = result.g;
+ buffer[sv_dispatchThreadID.x * 4 + 2] = result.b;
+ buffer[sv_dispatchThreadID.x * 4 + 3] = result.a;
+}
diff --git a/tools/gfx-unit-test/format-unit-tests.cpp b/tools/gfx-unit-test/format-unit-tests.cpp
new file mode 100644
index 000000000..0498bc670
--- /dev/null
+++ b/tools/gfx-unit-test/format-unit-tests.cpp
@@ -0,0 +1,1110 @@
+#include "tools/unit-test/slang-unit-test.h"
+
+#include "slang-gfx.h"
+#include "gfx-test-util.h"
+#include "tools/gfx-util/shader-cursor.h"
+#include "source/core/slang-basic.h"
+
+using namespace gfx;
+
+namespace gfx_test
+{
+ gfx::Format convertTypelessFormat(gfx::Format format)
+ {
+ switch (format)
+ {
+ case gfx::Format::R32G32B32A32_TYPELESS:
+ return gfx::Format::R32G32B32A32_FLOAT;
+ case gfx::Format::R32G32B32_TYPELESS:
+ return gfx::Format::R32G32B32_FLOAT;
+ case gfx::Format::R32G32_TYPELESS:
+ return gfx::Format::R32G32_FLOAT;
+ case gfx::Format::R32_TYPELESS:
+ return gfx::Format::R32_FLOAT;
+ case gfx::Format::R16G16B16A16_TYPELESS:
+ return gfx::Format::R16G16B16A16_FLOAT;
+ case gfx::Format::R16G16_TYPELESS:
+ return gfx::Format::R16G16_FLOAT;
+ case gfx::Format::R16_TYPELESS:
+ return gfx::Format::R16_FLOAT;
+ case gfx::Format::R8G8B8A8_TYPELESS:
+ return gfx::Format::R8G8B8A8_UNORM;
+ case gfx::Format::R8G8_TYPELESS:
+ return gfx::Format::R8G8_UNORM;
+ case gfx::Format::R8_TYPELESS:
+ return gfx::Format::R8_UNORM;
+ case gfx::Format::B8G8R8A8_TYPELESS:
+ return gfx::Format::B8G8R8A8_UNORM;
+ case gfx::Format::R10G10B10A2_TYPELESS:
+ return gfx::Format::R10G10B10A2_UINT;
+ default:
+ return gfx::Format::Unknown;
+ }
+ }
+
+ void setUpAndRunTest(
+ IDevice* device,
+ ComPtr<IResourceView> texView,
+ ComPtr<IResourceView> bufferView,
+ const char* entryPoint,
+ ComPtr<ISamplerState> sampler = nullptr)
+ {
+ Slang::ComPtr<ITransientResourceHeap> transientHeap;
+ ITransientResourceHeap::Desc transientHeapDesc = {};
+ transientHeapDesc.constantBufferSize = 4096;
+ GFX_CHECK_CALL_ABORT(
+ device->createTransientResourceHeap(transientHeapDesc, transientHeap.writeRef()));
+
+ ComPtr<IShaderProgram> shaderProgram;
+ slang::ProgramLayout* slangReflection;
+ GFX_CHECK_CALL_ABORT(loadComputeProgram(device, shaderProgram, "format-test-shaders", entryPoint, slangReflection));
+
+ ComputePipelineStateDesc pipelineDesc = {};
+ pipelineDesc.program = shaderProgram.get();
+ ComPtr<gfx::IPipelineState> pipelineState;
+ GFX_CHECK_CALL_ABORT(
+ device->createComputePipelineState(pipelineDesc, pipelineState.writeRef()));
+
+ // We have done all the set up work, now it is time to start recording a command buffer for
+ // GPU execution.
+ {
+ ICommandQueue::Desc queueDesc = { ICommandQueue::QueueType::Graphics };
+ auto queue = device->createCommandQueue(queueDesc);
+
+ auto commandBuffer = transientHeap->createCommandBuffer();
+ auto encoder = commandBuffer->encodeComputeCommands();
+
+ auto rootObject = encoder->bindPipeline(pipelineState);
+
+ ShaderCursor entryPointCursor(
+ rootObject->getEntryPoint(0)); // get a cursor the the first entry-point.
+
+ // Bind texture view to the entry point
+ entryPointCursor.getPath("tex").setResource(texView);
+
+ if (sampler) entryPointCursor.getPath("sampler").setSampler(sampler);
+
+ // Bind buffer view to the entry point.
+ entryPointCursor.getPath("buffer").setResource(bufferView);
+
+ encoder->dispatchCompute(1, 1, 1);
+ encoder->endEncoding();
+ commandBuffer->close();
+ queue->executeCommandBuffer(commandBuffer);
+ queue->wait();
+ }
+ }
+
+ ComPtr<IResourceView> createTexView(
+ IDevice* device,
+ ITextureResource::Size size,
+ gfx::Format format,
+ ITextureResource::SubresourceData* data,
+ int mips = 1)
+ {
+ ITextureResource::Desc texDesc = {};
+ texDesc.type = IResource::Type::Texture2D;
+ texDesc.numMipLevels = mips;
+ texDesc.arraySize = 1;
+ texDesc.size = size;
+ texDesc.defaultState = ResourceState::ShaderResource;
+ texDesc.format = format;
+
+ ComPtr<ITextureResource> inTex;
+ GFX_CHECK_CALL_ABORT(device->createTextureResource(
+ texDesc,
+ data,
+ inTex.writeRef()));
+
+ ComPtr<IResourceView> texView;
+ IResourceView::Desc texViewDesc = {};
+ texViewDesc.type = IResourceView::Type::ShaderResource;
+ texViewDesc.format = gfxIsTypelessFormat(format) ? convertTypelessFormat(format) : format;
+ GFX_CHECK_CALL_ABORT(device->createTextureView(inTex, texViewDesc, texView.writeRef()));
+ return texView;
+ }
+
+ template <typename T>
+ ComPtr<IBufferResource> createBuffer(IDevice* device, int size, void* initialData)
+ {
+ IBufferResource::Desc bufferDesc = {};
+ bufferDesc.sizeInBytes = size * sizeof(T);
+ bufferDesc.format = gfx::Format::Unknown;
+ bufferDesc.elementSize = sizeof(T);
+ bufferDesc.allowedStates = ResourceStateSet(
+ ResourceState::ShaderResource,
+ ResourceState::UnorderedAccess,
+ ResourceState::CopyDestination,
+ ResourceState::CopySource);
+ bufferDesc.defaultState = ResourceState::UnorderedAccess;
+ bufferDesc.cpuAccessFlags = AccessFlag::Write | AccessFlag::Read;
+
+ ComPtr<IBufferResource> outBuffer;
+ GFX_CHECK_CALL_ABORT(device->createBufferResource(
+ bufferDesc,
+ initialData,
+ outBuffer.writeRef()));
+ return outBuffer;
+ }
+
+ ComPtr<IResourceView> createBufferView(IDevice* device, ComPtr<IBufferResource> outBuffer)
+ {
+ ComPtr<IResourceView> bufferView;
+ IResourceView::Desc viewDesc = {};
+ viewDesc.type = IResourceView::Type::UnorderedAccess;
+ viewDesc.format = Format::Unknown;
+ GFX_CHECK_CALL_ABORT(device->createBufferView(outBuffer, viewDesc, bufferView.writeRef()));
+ return bufferView;
+ }
+
+ void formatTestsImpl(IDevice* device, UnitTestContext* context)
+ {
+ ISamplerState::Desc samplerDesc;
+ auto sampler = device->createSamplerState(samplerDesc);
+
+ float initFloatData[16] = { 0.0f };
+ auto floatResults = createBuffer<float>(device, 16, initFloatData);
+ auto floatBufferView = createBufferView(device, floatResults);
+
+ uint32_t initUintData[16] = { 0u };
+ auto uintResults = createBuffer<uint32_t>(device, 16, initUintData);
+ auto uintBufferView = createBufferView(device, uintResults);
+
+ int32_t initIntData[16] = { 0 };
+ auto intResults = createBuffer<uint32_t>(device, 16, initIntData);
+ auto intBufferView = createBufferView(device, intResults);
+
+ ITextureResource::Size size = {};
+ size.width = 2;
+ size.height = 2;
+ size.depth = 1;
+
+ ITextureResource::Size bcSize = {};
+ bcSize.width = 4;
+ bcSize.height = 4;
+ bcSize.depth = 1;
+
+ // Note: D32_FLOAT and D16_UNORM are not directly tested as they are only used for raster. These
+ // are the same as R32_FLOAT and R16_UNORM, respectively, when passed to a shader.
+ {
+ float texData[] = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f };
+ ITextureResource::SubresourceData subData = { (void*)texData, 32, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32A32_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f));
+
+ texView = createTexView(device, size, gfx::Format::R32G32B32A32_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces unsupported format warnings for this test.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ float texData[] = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f };
+ ITextureResource::SubresourceData subData = { (void*)texData, 24, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat3");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f));
+
+ texView = createTexView(device, size, gfx::Format::R32G32B32_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat3");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f));
+ }
+
+ {
+ float texData[] = { 1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.5f, 0.5f };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.5f, 0.5f));
+
+ texView = createTexView(device, size, gfx::Format::R32G32_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.5f, 0.5f));
+ }
+
+ {
+ float texData[] = { 1.0f, 0.0f, 0.5f, 0.25f };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.5f, 0.25f));
+
+ texView = createTexView(device, size, gfx::Format::R32_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.5f, 0.25f));
+ }
+
+ {
+ uint16_t texData[] = { 15360u, 0u, 0u, 15360u, 0u, 15360u, 0u, 15360u,
+ 0u, 0u, 15360u, 15360u, 14336u, 14336u, 14336u, 15360u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16B16A16_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f));
+
+ texView = createTexView(device, size, gfx::Format::R16G16B16A16_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f));
+ }
+
+ {
+ uint16_t texData[] = { 15360u, 0u, 0u, 15360u,
+ 15360u, 15360u, 14336u, 14336u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.5f, 0.5f));
+
+ texView = createTexView(device, size, gfx::Format::R16G16_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.5f, 0.5f));
+ }
+
+ {
+ uint16_t texData[] = { 15360u, 0u, 14336u, 13312u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.5f, 0.25f));
+
+ texView = createTexView(device, size, gfx::Format::R16_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.5f, 0.25f));
+ }
+
+ {
+ uint32_t texData[] = { 255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 32, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32A32_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint4");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces unsupported format warnings for this test.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint32_t texData[] = { 255u, 0u, 0u, 0u, 255u, 0u,
+ 0u, 0u, 255u, 127u, 127u, 127u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 24, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint3");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 0u, 255u, 0u,
+ 0u, 0u, 255u, 127u, 127u, 127u));
+ }
+
+ {
+ uint32_t texData[] = { 255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint2");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u));
+ }
+
+ {
+ uint32_t texData[] = { 255u, 0u, 127u, 73u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 127u, 73u));
+ }
+
+ {
+ uint16_t texData[] = { 255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16B16A16_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint4");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u));
+ }
+
+ {
+ uint16_t texData[] = { 255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint2");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u));
+ }
+
+ {
+ uint16_t texData[] = { 255u, 0u, 127u, 73u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 127u, 73u));
+ }
+
+ {
+ uint8_t texData[] = { 255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8B8A8_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint4");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
+ 0u, 0u, 255u, 255u, 127u, 127u, 127u, 255u));
+ }
+
+ {
+ uint8_t texData[] = { 255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint2");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 0u, 255u,
+ 255u, 255u, 127u, 127u));
+ }
+
+ {
+ uint8_t texData[] = { 255u, 0u, 127u, 73u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 2, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(255u, 0u, 127u, 73u));
+ }
+
+ {
+ int32_t texData[] = { 255, 0, 0, 255, 0, 255, 0, 255,
+ 0, 0, 255, 255, 127, 127, 127, 255 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 32, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32A32_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt4");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 0, 255, 0, 255, 0, 255,
+ 0, 0, 255, 255, 127, 127, 127, 255));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces unsupported format warnings for this test.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ int32_t texData[] = { 255, 0, 0, 0, 255, 0,
+ 0, 0, 255, 127, 127, 127 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 24, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32B32_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt3");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 0, 0, 255, 0,
+ 0, 0, 255, 127, 127, 127));
+ }
+
+ {
+ int32_t texData[] = { 255, 0, 0, 255,
+ 255, 255, 127, 127 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32G32_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt2");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 0, 255,
+ 255, 255, 127, 127));
+ }
+
+ {
+ int32_t texData[] = { 255, 0, 127, 73 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R32_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 127, 73));
+ }
+
+ {
+ int16_t texData[] = { 255, 0, 0, 255, 0, 255, 0, 255,
+ 0, 0, 255, 255, 127, 127, 127, 255 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16B16A16_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt4");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 0, 255, 0, 255, 0, 255,
+ 0, 0, 255, 255, 127, 127, 127, 255));
+ }
+
+ {
+ int16_t texData[] = { 255, 0, 0, 255,
+ 255, 255, 127, 127 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt2");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 0, 255,
+ 255, 255, 127, 127));
+ }
+
+ {
+ int16_t texData[] = { 255, 0, 127, 73 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(255, 0, 127, 73));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, 0, 127, 0, 127, 0, 127,
+ 0, 0, 127, 127, 0, 0, 0, 127 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8B8A8_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt4");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(127, 0, 0, 127, 0, 127, 0, 127,
+ 0, 0, 127, 127, 0, 0, 0, 127));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, 0, 127,
+ 127, 127, 73, 73 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt2");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(127, 0, 0, 127,
+ 127, 127, 73, 73));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, 73, 25 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 2, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8_SINT, &subData);
+ setUpAndRunTest(device, texView, intBufferView, "copyTexInt");
+ compareComputeResult(
+ device,
+ intResults,
+ Slang::makeArray<int32_t>(127, 0, 73, 25));
+ }
+
+ {
+ uint16_t texData[] = { 65535u, 0u, 0u, 65535u, 0u, 65535u, 0u, 65535u,
+ 0u, 0u, 65535u, 65535u, 32767u, 32767u, 32767u, 32767u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16B16A16_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, 0.499992371f, 0.499992371f, 0.499992371f, 0.499992371f));
+ }
+
+ {
+ uint16_t texData[] = { 65535u, 0u, 0u, 65535u,
+ 65535u, 65535u, 32767u, 32767u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f,
+ 1.0f, 1.0f, 0.499992371f, 0.499992371f));
+ }
+
+ {
+ uint16_t texData[] = { 65535u, 0u, 32767u, 16383u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.499992371f, 0.249988556f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 0u, 0u, 0u, 255u, 127u, 127u, 127u, 255u,
+ 255u, 255u, 255u, 255u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0};
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8B8A8_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.0f, 1.0f, 0.498039216f, 0.498039216f, 0.498039216f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+ texView = createTexView(device, size, gfx::Format::R8G8B8A8_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.0f, 1.0f, 0.498039216f, 0.498039216f, 0.498039216f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+ texView = createTexView(device, size, gfx::Format::R8G8B8A8_UNORM_SRGB, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.0f, 1.0f, 0.211914062f, 0.211914062f, 0.211914062f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 255u, 0u, 0u, 255u, 255u, 255u, 127u, 127u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.498039216f, 0.498039216f));
+
+ texView = createTexView(device, size, gfx::Format::R8G8_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.498039216f, 0.498039216f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 255u, 0u, 127u, 63u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 2, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.498039216f, 0.247058824f));
+
+ texView = createTexView(device, size, gfx::Format::R8_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.498039216f, 0.247058824f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 0u, 0u, 0u, 255u, 127u, 127u, 127u, 255u,
+ 255u, 255u, 255u, 255u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::B8G8R8A8_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.0f, 1.0f, 0.498039216f, 0.498039216f, 0.498039216f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+
+ texView = createTexView(device, size, gfx::Format::B8G8R8A8_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.0f, 1.0f, 0.498039216f, 0.498039216f, 0.498039216f, 1.0f,
+ 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f));
+ }
+
+ {
+ int16_t texData[] = { 32767, 0, 0, 32767, 0, 32767, 0, 32767,
+ 0, 0, 32767, 32767, -32768, -32768, 0, 32767 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16B16A16_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f));
+ }
+
+ {
+ int16_t texData[] = { 32767, 0, 0, 32767,
+ 32767, 32767, -32768, -32768 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16G16_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f));
+ }
+
+ {
+ int16_t texData[] = { 32767, 0, -32768, 0};
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R16_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, -1.0f, 0.0f));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, 0, 127, 0, 127, 0, 127,
+ 0, 0, 127, 127, -128, -128, 0, 127 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8B8A8_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, 0, 127,
+ 127, 127, -128, -128 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8G8_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat2");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f));
+ }
+
+ {
+ int8_t texData[] = { 127, 0, -128, 0 };
+ ITextureResource::SubresourceData subData = { (void*)texData, 2, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R8_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, -1.0f, 0.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces unsupported format warnings for this test.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 15u, 240u, 240u, 240u, 0u, 255u, 119u, 119u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::B4G4R4A4_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
+ 1.0f, 0.0f, 0.0f, 1.0f, 0.466666669f, 0.466666669f, 0.466666669f, 0.466666669f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint16_t texData[] = { 31u, 2016u, 63488u, 31727u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 4, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::B5G6R5_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat3");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f, 0.482352942f, 0.490196079f, 0.482352942f));
+
+ texView = createTexView(device, size, gfx::Format::B5G5R5A1_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 1.0f, 0.0f, 0.0313725509f, 1.0f, 0.0f, 0.0f,
+ 0.968627453f, 0.0f, 0.0f, 1.0f, 0.968627453f, 1.0f, 0.482352942f, 0.0f));
+ }
+
+ {
+ uint32_t texData[] = { 2950951416u, 2013265920u, 3086219772u, 3087007228u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R9G9B9E5_SHAREDEXP, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat3");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(63.0f, 63.0f, 63.0f, 0.0f, 0.0f, 0.0f,
+ 127.0f, 127.0f, 127.0f, 127.0f, 127.5f, 127.75f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint32_t texData[] = { 4294967295u, 0u, 2683829759u, 1193046471u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R10G10B10A2_TYPELESS, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint4");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(1023u, 1023u, 1023u, 3u, 0u, 0u, 0u, 0u,
+ 511u, 511u, 511u, 2u, 455u, 796u, 113u, 1u));
+
+ texView = createTexView(device, size, gfx::Format::R10G10B10A2_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat4");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.499511242f, 0.499511242f, 0.499511242f, 0.666666687f,
+ 0.444770277f, 0.778103590f, 0.110459432f, 0.333333343f));
+
+ texView = createTexView(device, size, gfx::Format::R10G10B10A2_UINT, &subData);
+ setUpAndRunTest(device, texView, uintBufferView, "copyTexUint4");
+ compareComputeResult(
+ device,
+ uintResults,
+ Slang::makeArray<uint32_t>(1023u, 1023u, 1023u, 3u, 0u, 0u, 0u, 0u,
+ 511u, 511u, 511u, 2u, 455u, 796u, 113u, 1u));
+ }
+
+ {
+ uint32_t texData[] = { 3085827519u, 0u, 2951478655u, 1880884096u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, size, gfx::Format::R11G11B10_FLOAT, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "copyTexFloat3");
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(254.0f, 254.0f, 252.0f, 0.0f, 0.0f, 0.0f, 127.0f, 127.0f, 126.0f, 0.5f, 0.5f, 0.5f));
+ }
+
+ // These BC1 tests also check that mipmaps are working correctly for compressed formats.
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
+ 255u, 255u, 255u, 255u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData[] = {
+ ITextureResource::SubresourceData {(void*)texData, 16, 32},
+ ITextureResource::SubresourceData {(void*)(texData + 32), 8, 0}
+ };
+ ITextureResource::Size size = {};
+ size.width = 8;
+ size.height = 8;
+ size.depth = 1;
+
+ auto texView = createTexView(device, size, gfx::Format::BC1_UNORM, subData, 2);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleMips", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.517647088f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
+
+ texView = createTexView(device, size, gfx::Format::BC1_UNORM_SRGB, subData, 2);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleMips", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.230468750f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 255u, 255u, 255u, 255u, 255u, 255u, 255u, 255u,
+ 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC2_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.517647088f, 1.0f));
+
+ texView = createTexView(device, bcSize, gfx::Format::BC2_UNORM_SRGB, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.230468750f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 0u, 255u, 255u, 255u, 255u, 255u, 255u, 255u,
+ 16u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC3_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.517647088f, 1.0f));
+
+ texView = createTexView(device, bcSize, gfx::Format::BC3_UNORM_SRGB, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0f, 0.230468750f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 127u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 8, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC4_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.498039216f, 0.0f, 0.0f, 1.0f));
+
+ texView = createTexView(device, bcSize, gfx::Format::BC4_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 0.0f, 0.0f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 127u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 127u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC5_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.498039216f, 0.498039216f, 0.0f, 1.0f, 0.498039216f, 0.498039216f, 0.0f, 1.0f));
+
+ texView = createTexView(device, bcSize, gfx::Format::BC5_SNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f));
+ }
+
+ // BC6H_UF16 and BC6H_SF16 are tested separately due to requiring different texture data.
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 98u, 238u, 232u, 77u, 240u, 66u, 148u, 31u,
+ 124u, 95u, 2u, 224u, 255u, 107u, 77u, 250u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC6H_UF16, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.336669922f, 0.911132812f, 2.13867188f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 107u, 238u, 232u, 77u, 240u, 71u, 128u, 127u,
+ 1u, 0u, 255u, 255u, 170u, 218u, 221u, 254u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC6H_SF16, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.336914062f, 0.910644531f, 2.14062500f, 1.0f));
+ }
+
+ // Ignore this test on swiftshader. Swiftshader produces different results than expected.
+ if (!Slang::String(device->getDeviceInfo().adapterName).toLower().contains("swiftshader"))
+ {
+ uint8_t texData[] = { 104u, 0u, 0u, 0u, 64u, 163u, 209u, 104u,
+ 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u };
+ ITextureResource::SubresourceData subData = { (void*)texData, 16, 0 };
+
+ auto texView = createTexView(device, bcSize, gfx::Format::BC7_UNORM, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.101960786f, 0.0f, 1.0f));
+
+ texView = createTexView(device, bcSize, gfx::Format::BC7_UNORM_SRGB, &subData);
+ setUpAndRunTest(device, texView, floatBufferView, "sampleTex", sampler);
+ compareComputeResult(
+ device,
+ floatResults,
+ Slang::makeArray<float>(0.0f, 0.0103149414f, 0.0f, 1.0f));
+ }
+ }
+
+ SLANG_UNIT_TEST(FormatTestsD3D11)
+ {
+ runTestImpl(formatTestsImpl, unitTestContext, Slang::RenderApiFlag::D3D11);
+ }
+
+#if SLANG_WINDOWS_FAMILY
+ SLANG_UNIT_TEST(FormatTestsD3D12)
+ {
+ runTestImpl(formatTestsImpl, unitTestContext, Slang::RenderApiFlag::D3D12);
+ }
+#endif
+
+ SLANG_UNIT_TEST(FormatTestsVulkan)
+ {
+ runTestImpl(formatTestsImpl, unitTestContext, Slang::RenderApiFlag::Vulkan);
+ }
+
+}
diff --git a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
index 4677bd97b..537585f2a 100644
--- a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
+++ b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp
@@ -22,7 +22,7 @@ namespace gfx_test
desc.size.height = 1;
desc.size.depth = 1;
desc.defaultState = ResourceState::UnorderedAccess;
- desc.format = Format::RGBA_Float16;
+ desc.format = Format::R16G16B16A16_FLOAT;
Slang::ComPtr<ITextureResource> buffer;
buffer = device->createTextureResource(desc);
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp
index f1dd6be58..aafa3fc59 100644
--- a/tools/gfx-unit-test/gfx-test-util.cpp
+++ b/tools/gfx-unit-test/gfx-test-util.cpp
@@ -77,6 +77,21 @@ namespace gfx_test
SLANG_CHECK(memcmp(resultBlob->getBufferPointer(), expectedResult, expectedBufferSize) == 0);
}
+ void compareComputeResultFuzzy(gfx::IDevice* device, gfx::IBufferResource* buffer, float* expectedResult, size_t expectedBufferSize)
+ {
+ // Read back the results.
+ ComPtr<ISlangBlob> resultBlob;
+ GFX_CHECK_CALL_ABORT(device->readBufferResource(
+ buffer, 0, expectedBufferSize, resultBlob.writeRef()));
+ SLANG_CHECK(resultBlob->getBufferSize() == expectedBufferSize);
+ // Compare results with a tolerance of 0.01.
+ auto result = (float*)resultBlob->getBufferPointer();
+ for (int i = 0; i < expectedBufferSize / sizeof(float); ++i)
+ {
+ SLANG_CHECK(abs(result[i] - expectedResult[i]) <= 0.01);
+ }
+ }
+
Slang::ComPtr<gfx::IDevice> createTestingDevice(UnitTestContext* context, Slang::RenderApiFlag::Enum api)
{
Slang::ComPtr<gfx::IDevice> device;
diff --git a/tools/gfx-unit-test/gfx-test-util.h b/tools/gfx-unit-test/gfx-test-util.h
index b357a310a..01a367915 100644
--- a/tools/gfx-unit-test/gfx-test-util.h
+++ b/tools/gfx-unit-test/gfx-test-util.h
@@ -25,6 +25,13 @@ namespace gfx_test
uint8_t* expectedResult,
size_t expectedBufferSize);
+ /// Reads back the content of `buffer` and compares it against `expectedResult` with a set tolerance.
+ void compareComputeResultFuzzy(
+ gfx::IDevice* device,
+ gfx::IBufferResource* buffer,
+ float* expectedResult,
+ size_t expectedBufferSize);
+
template<typename T, Slang::Index count>
void compareComputeResult(
gfx::IDevice* device,
@@ -35,6 +42,7 @@ namespace gfx_test
size_t bufferSize = sizeof(T) * count;
expectedBuffer.setCount(bufferSize);
memcpy(expectedBuffer.getBuffer(), expectedResult.begin(), bufferSize);
+ if (std::is_same<T, float>::value) return compareComputeResultFuzzy(device, buffer, (float*)expectedBuffer.getBuffer(), bufferSize);
return compareComputeResult(device, buffer, expectedBuffer.getBuffer(), bufferSize);
}
diff --git a/tools/gfx/cpu/render-cpu.cpp b/tools/gfx/cpu/render-cpu.cpp
index c6662b851..ccc7a4abd 100644
--- a/tools/gfx/cpu/render-cpu.cpp
+++ b/tools/gfx/cpu/render-cpu.cpp
@@ -169,21 +169,21 @@ struct CPUFormatInfoMap
{
memset(m_infos, 0, sizeof(m_infos));
- set(Format::RGBA_Float32, &_unpackFloatTexel<4>);
- set(Format::RGB_Float32, &_unpackFloatTexel<3>);
+ set(Format::R32G32B32A32_FLOAT, &_unpackFloatTexel<4>);
+ set(Format::R32G32B32_FLOAT, &_unpackFloatTexel<3>);
- set(Format::RG_Float32, &_unpackFloatTexel<2>);
- set(Format::R_Float32, &_unpackFloatTexel<1>);
+ set(Format::R32G32_FLOAT, &_unpackFloatTexel<2>);
+ set(Format::R32_FLOAT, &_unpackFloatTexel<1>);
- set(Format::RGBA_Float16, &_unpackFloat16Texel<4>);
- set(Format::RG_Float16, &_unpackFloat16Texel<2>);
- set(Format::R_Float16, &_unpackFloat16Texel<1>);
+ set(Format::R16G16B16A16_FLOAT, &_unpackFloat16Texel<4>);
+ set(Format::R16G16_FLOAT, &_unpackFloat16Texel<2>);
+ set(Format::R16_FLOAT, &_unpackFloat16Texel<1>);
- set(Format::RGBA_Unorm_UInt8, &_unpackUnorm8Texel<4>);
- set(Format::BGRA_Unorm_UInt8, &_unpackUnormBGRA8Texel);
- set(Format::R_UInt16, &_unpackUInt16Texel<1>);
- set(Format::R_UInt32, &_unpackUInt32Texel<1>);
- set(Format::D_Float32, &_unpackFloatTexel<1>);
+ set(Format::R8G8B8A8_UNORM, &_unpackUnorm8Texel<4>);
+ set(Format::B8G8R8A8_UNORM, &_unpackUnormBGRA8Texel);
+ set(Format::R16_UINT, &_unpackUInt16Texel<1>);
+ set(Format::R32_UINT, &_unpackUInt32Texel<1>);
+ set(Format::D32_FLOAT, &_unpackFloatTexel<1>);
}
void set(Format format, CPUTextureUnpackFunc func)
@@ -233,8 +233,10 @@ public:
// the block extents would be 1 along each axis.
//
auto format = desc.format;
- auto texelSize = gfxGetFormatSize(format);
- m_texelSize = (int32_t) texelSize;
+ FormatInfo texelInfo;
+ gfxGetFormatInfo(format, &texelInfo);
+ uint32_t texelSize = uint32_t(texelInfo.blockSizeInBytes / texelInfo.pixelsPerBlock);
+ m_texelSize = texelSize;
int32_t formatBlockSize[kMaxRank] = { 1, 1, 1 };
@@ -353,7 +355,7 @@ public:
CPUTextureBaseShapeInfo const* m_baseShape;
CPUTextureFormatInfo const* m_formatInfo;
int32_t m_effectiveArrayElementCount = 0;
- int32_t m_texelSize = 0;
+ uint32_t m_texelSize = 0;
struct MipLevel
{
diff --git a/tools/gfx/cuda/render-cuda.cpp b/tools/gfx/cuda/render-cuda.cpp
index ed22495cb..47c309d34 100644
--- a/tools/gfx/cuda/render-cuda.cpp
+++ b/tools/gfx/cuda/render-cuda.cpp
@@ -1362,29 +1362,31 @@ public:
switch (desc.format)
{
- case Format::RGBA_Float32:
- case Format::RGB_Float32:
- case Format::RG_Float32:
- case Format::R_Float32:
- case Format::D_Float32:
+ case Format::R32G32B32A32_FLOAT:
+ case Format::R32G32B32_FLOAT:
+ case Format::R32G32_FLOAT:
+ case Format::R32_FLOAT:
+ case Format::D32_FLOAT:
{
- const FormatInfo info = gfxGetFormatInfo(desc.format);
+ FormatInfo info;
+ gfxGetFormatInfo(desc.format, &info);
format = CU_AD_FORMAT_FLOAT;
numChannels = info.channelCount;
elementSize = sizeof(float) * numChannels;
break;
}
- case Format::RGBA_Float16:
- case Format::RG_Float16:
- case Format::R_Float16:
+ case Format::R16G16B16A16_FLOAT:
+ case Format::R16G16_FLOAT:
+ case Format::R16_FLOAT:
{
- const FormatInfo info = gfxGetFormatInfo(desc.format);
+ FormatInfo info;
+ gfxGetFormatInfo(desc.format, &info);
format = CU_AD_FORMAT_HALF;
numChannels = info.channelCount;
elementSize = sizeof(uint16_t) * numChannels;
break;
}
- case Format::RGBA_Unorm_UInt8:
+ case Format::R8G8B8A8_UNORM:
{
format = CU_AD_FORMAT_UNSIGNED_INT8;
numChannels = 4;
@@ -1393,7 +1395,7 @@ public:
}
default:
{
- SLANG_ASSERT(!"Only support R_Float32/RGBA_Unorm_UInt8 formats for now");
+ SLANG_ASSERT(!"Only support R32_FLOAT/R8G8B8A8_UNORM formats for now");
return SLANG_FAIL;
}
}
diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp
index 1f8e5bf7b..d73b3f519 100644
--- a/tools/gfx/d3d/d3d-util.cpp
+++ b/tools/gfx/d3d/d3d-util.cpp
@@ -108,26 +108,102 @@ D3D12_DEPTH_STENCILOP_DESC D3DUtil::translateStencilOpDesc(DepthStencilOpDesc de
{
switch (format)
{
- case Format::RGBA_Float32: return DXGI_FORMAT_R32G32B32A32_FLOAT;
- case Format::RGB_Float32: return DXGI_FORMAT_R32G32B32_FLOAT;
- case Format::RG_Float32: return DXGI_FORMAT_R32G32_FLOAT;
- case Format::R_Float32: return DXGI_FORMAT_R32_FLOAT;
- case Format::RGBA_Unorm_UInt8: return DXGI_FORMAT_R8G8B8A8_UNORM;
- case Format::BGRA_Unorm_UInt8: return DXGI_FORMAT_B8G8R8A8_UNORM;
- case Format::RGBA_Snorm_UInt16: return DXGI_FORMAT_R16G16B16A16_SNORM;
- case Format::RG_Snorm_UInt16: return DXGI_FORMAT_R16G16_SNORM;
-
- case Format::RGBA_Float16: return DXGI_FORMAT_R16G16B16A16_FLOAT;
- case Format::RG_Float16: return DXGI_FORMAT_R16G16_FLOAT;
- case Format::R_Float16: return DXGI_FORMAT_R16_FLOAT;
-
- case Format::R_UInt16: return DXGI_FORMAT_R16_UINT;
- case Format::R_UInt32: return DXGI_FORMAT_R32_UINT;
-
- case Format::D_Float32: return DXGI_FORMAT_D32_FLOAT;
- case Format::D_Unorm24_S8: return DXGI_FORMAT_D24_UNORM_S8_UINT;
-
- default: return DXGI_FORMAT_UNKNOWN;
+ case Format::R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_TYPELESS;
+ case Format::R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_TYPELESS;
+ case Format::R32G32_TYPELESS: return DXGI_FORMAT_R32G32_TYPELESS;
+ case Format::R32_TYPELESS: return DXGI_FORMAT_R32_TYPELESS;
+
+ case Format::R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_TYPELESS;
+ case Format::R16G16_TYPELESS: return DXGI_FORMAT_R16G16_TYPELESS;
+ case Format::R16_TYPELESS: return DXGI_FORMAT_R16_TYPELESS;
+
+ case Format::R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_TYPELESS;
+ case Format::R8G8_TYPELESS: return DXGI_FORMAT_R8G8_TYPELESS;
+ case Format::R8_TYPELESS: return DXGI_FORMAT_R8_TYPELESS;
+ case Format::B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_TYPELESS;
+
+ case Format::R32G32B32A32_FLOAT: return DXGI_FORMAT_R32G32B32A32_FLOAT;
+ case Format::R32G32B32_FLOAT: return DXGI_FORMAT_R32G32B32_FLOAT;
+ case Format::R32G32_FLOAT: return DXGI_FORMAT_R32G32_FLOAT;
+ case Format::R32_FLOAT: return DXGI_FORMAT_R32_FLOAT;
+
+ case Format::R16G16B16A16_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT;
+ case Format::R16G16_FLOAT: return DXGI_FORMAT_R16G16_FLOAT;
+ case Format::R16_FLOAT: return DXGI_FORMAT_R16_FLOAT;
+
+ case Format::R32G32B32A32_UINT: return DXGI_FORMAT_R32G32B32A32_UINT;
+ case Format::R32G32B32_UINT: return DXGI_FORMAT_R32G32B32_UINT;
+ case Format::R32G32_UINT: return DXGI_FORMAT_R32G32_UINT;
+ case Format::R32_UINT: return DXGI_FORMAT_R32_UINT;
+
+ case Format::R16G16B16A16_UINT: return DXGI_FORMAT_R16G16B16A16_UINT;
+ case Format::R16G16_UINT: return DXGI_FORMAT_R16G16_UINT;
+ case Format::R16_UINT: return DXGI_FORMAT_R16_UINT;
+
+ case Format::R8G8B8A8_UINT: return DXGI_FORMAT_R8G8B8A8_UINT;
+ case Format::R8G8_UINT: return DXGI_FORMAT_R8G8_UINT;
+ case Format::R8_UINT: return DXGI_FORMAT_R8_UINT;
+
+ case Format::R32G32B32A32_SINT: return DXGI_FORMAT_R32G32B32A32_SINT;
+ case Format::R32G32B32_SINT: return DXGI_FORMAT_R32G32B32_SINT;
+ case Format::R32G32_SINT: return DXGI_FORMAT_R32G32_SINT;
+ case Format::R32_SINT: return DXGI_FORMAT_R32_SINT;
+
+ case Format::R16G16B16A16_SINT: return DXGI_FORMAT_R16G16B16A16_SINT;
+ case Format::R16G16_SINT: return DXGI_FORMAT_R16G16_SINT;
+ case Format::R16_SINT: return DXGI_FORMAT_R16_SINT;
+
+ case Format::R8G8B8A8_SINT: return DXGI_FORMAT_R8G8B8A8_SINT;
+ case Format::R8G8_SINT: return DXGI_FORMAT_R8G8_SINT;
+ case Format::R8_SINT: return DXGI_FORMAT_R8_SINT;
+
+ case Format::R16G16B16A16_UNORM: return DXGI_FORMAT_R16G16B16A16_UNORM;
+ case Format::R16G16_UNORM: return DXGI_FORMAT_R16G16_UNORM;
+ case Format::R16_UNORM: return DXGI_FORMAT_R16_UNORM;
+
+ case Format::R8G8B8A8_UNORM: return DXGI_FORMAT_R8G8B8A8_UNORM;
+ case Format::R8G8B8A8_UNORM_SRGB: return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
+ case Format::R8G8_UNORM: return DXGI_FORMAT_R8G8_UNORM;
+ case Format::R8_UNORM: return DXGI_FORMAT_R8_UNORM;
+ case Format::B8G8R8A8_UNORM: return DXGI_FORMAT_B8G8R8A8_UNORM;
+
+ case Format::R16G16B16A16_SNORM: return DXGI_FORMAT_R16G16B16A16_SNORM;
+ case Format::R16G16_SNORM: return DXGI_FORMAT_R16G16_SNORM;
+ case Format::R16_SNORM: return DXGI_FORMAT_R16_SNORM;
+
+ case Format::R8G8B8A8_SNORM: return DXGI_FORMAT_R8G8B8A8_SNORM;
+ case Format::R8G8_SNORM: return DXGI_FORMAT_R8G8_SNORM;
+ case Format::R8_SNORM: return DXGI_FORMAT_R8_SNORM;
+
+ case Format::D32_FLOAT: return DXGI_FORMAT_D32_FLOAT;
+ case Format::D16_UNORM: return DXGI_FORMAT_D16_UNORM;
+
+ case Format::B4G4R4A4_UNORM: return DXGI_FORMAT_B4G4R4A4_UNORM;
+ case Format::B5G6R5_UNORM: return DXGI_FORMAT_B5G6R5_UNORM;
+ case Format::B5G5R5A1_UNORM: return DXGI_FORMAT_B5G5R5A1_UNORM;
+
+ case Format::R9G9B9E5_SHAREDEXP: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP;
+ case Format::R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_TYPELESS;
+ case Format::R10G10B10A2_UINT: return DXGI_FORMAT_R10G10B10A2_UINT;
+ case Format::R10G10B10A2_UNORM: return DXGI_FORMAT_R10G10B10A2_UNORM;
+ case Format::R11G11B10_FLOAT: return DXGI_FORMAT_R11G11B10_FLOAT;
+
+ case Format::BC1_UNORM: return DXGI_FORMAT_BC1_UNORM;
+ case Format::BC1_UNORM_SRGB: return DXGI_FORMAT_BC1_UNORM_SRGB;
+ case Format::BC2_UNORM: return DXGI_FORMAT_BC2_UNORM;
+ case Format::BC2_UNORM_SRGB: return DXGI_FORMAT_BC2_UNORM_SRGB;
+ case Format::BC3_UNORM: return DXGI_FORMAT_BC3_UNORM;
+ case Format::BC3_UNORM_SRGB: return DXGI_FORMAT_BC3_UNORM_SRGB;
+ case Format::BC4_UNORM: return DXGI_FORMAT_BC4_UNORM;
+ case Format::BC4_SNORM: return DXGI_FORMAT_BC4_SNORM;
+ case Format::BC5_UNORM: return DXGI_FORMAT_BC5_UNORM;
+ case Format::BC5_SNORM: return DXGI_FORMAT_BC5_SNORM;
+ case Format::BC6H_UF16: return DXGI_FORMAT_BC6H_UF16;
+ case Format::BC6H_SF16: return DXGI_FORMAT_BC6H_SF16;
+ case Format::BC7_UNORM: return DXGI_FORMAT_BC7_UNORM;
+ case Format::BC7_UNORM_SRGB: return DXGI_FORMAT_BC7_UNORM_SRGB;
+
+ default: return DXGI_FORMAT_UNKNOWN;
}
}
diff --git a/tools/gfx/d3d11/render-d3d11.cpp b/tools/gfx/d3d11/render-d3d11.cpp
index ec89c0879..b2bd042e6 100644
--- a/tools/gfx/d3d11/render-d3d11.cpp
+++ b/tools/gfx/d3d11/render-d3d11.cpp
@@ -2024,6 +2024,65 @@ SlangResult SLANG_MCALL createD3D11Device(const IDevice::Desc* desc, IDevice** o
return SLANG_OK;
}
+static void _initSrvDesc(IResource::Type resourceType, const ITextureResource::Desc& textureDesc, DXGI_FORMAT pixelFormat, D3D11_SHADER_RESOURCE_VIEW_DESC& descOut)
+{
+ // create SRV
+ descOut = D3D11_SHADER_RESOURCE_VIEW_DESC();
+
+ descOut.Format = (pixelFormat == DXGI_FORMAT_UNKNOWN) ? D3DUtil::calcFormat(D3DUtil::USAGE_SRV, D3DUtil::getMapFormat(textureDesc.format)) : pixelFormat;
+ const int arraySize = calcEffectiveArraySize(textureDesc);
+ if (arraySize <= 1)
+ {
+ switch (textureDesc.type)
+ {
+ case IResource::Type::Texture1D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; break;
+ case IResource::Type::Texture2D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; break;
+ case IResource::Type::Texture3D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; break;
+ default: assert(!"Unknown dimension");
+ }
+
+ descOut.Texture2D.MipLevels = textureDesc.numMipLevels;
+ descOut.Texture2D.MostDetailedMip = 0;
+ }
+ else if (resourceType == IResource::Type::TextureCube)
+ {
+ if (textureDesc.arraySize > 1)
+ {
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
+
+ descOut.TextureCubeArray.NumCubes = textureDesc.arraySize;
+ descOut.TextureCubeArray.First2DArrayFace = 0;
+ descOut.TextureCubeArray.MipLevels = textureDesc.numMipLevels;
+ descOut.TextureCubeArray.MostDetailedMip = 0;
+ }
+ else
+ {
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
+
+ descOut.TextureCube.MipLevels = textureDesc.numMipLevels;
+ descOut.TextureCube.MostDetailedMip = 0;
+ }
+ }
+ else
+ {
+ assert(textureDesc.size.depth > 1 || arraySize > 1);
+
+ switch (textureDesc.type)
+ {
+ case IResource::Type::Texture1D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY; break;
+ case IResource::Type::Texture2D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; break;
+ case IResource::Type::Texture3D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; break;
+
+ default: assert(!"Unknown dimension");
+ }
+
+ descOut.Texture2DArray.ArraySize = max(textureDesc.size.depth, arraySize);
+ descOut.Texture2DArray.MostDetailedMip = 0;
+ descOut.Texture2DArray.MipLevels = textureDesc.numMipLevels;
+ descOut.Texture2DArray.FirstArraySlice = 0;
+ }
+}
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ScopeNVAPI !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SlangResult D3D11Device::ScopeNVAPI::init(D3D11Device* device, Index regIndex)
@@ -2884,8 +2943,11 @@ Result D3D11Device::createTextureView(ITextureResource* texture, IResourceView::
case IResourceView::Type::ShaderResource:
{
+ D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+ _initSrvDesc(resourceImpl->getType(), *resourceImpl->getDesc(), D3DUtil::getMapFormat(desc.format), srvDesc);
+
ComPtr<ID3D11ShaderResourceView> srv;
- SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(resourceImpl->m_resource, nullptr, srv.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(resourceImpl->m_resource, &srvDesc, srv.writeRef()));
RefPtr<ShaderResourceViewImpl> viewImpl = new ShaderResourceViewImpl();
viewImpl->m_type = ResourceViewImpl::Type::SRV;
@@ -2928,7 +2990,9 @@ Result D3D11Device::createBufferView(IBufferResource* buffer, IResourceView::Des
}
else
{
- uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / gfxGetFormatSize(desc.format));
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
}
ComPtr<ID3D11UnorderedAccessView> uav;
@@ -2975,7 +3039,9 @@ Result D3D11Device::createBufferView(IBufferResource* buffer, IResourceView::Des
}
else
{
- srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / gfxGetFormatSize(desc.format));
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
}
ComPtr<ID3D11ShaderResourceView> srv;
@@ -3019,17 +3085,17 @@ Result D3D11Device::createInputLayout(const InputElementDesc* inputElementsIn, U
char const* typeName = "Unknown";
switch (inputElementsIn[ii].format)
{
- case Format::RGBA_Float32:
- case Format::RGBA_Unorm_UInt8:
+ case Format::R32G32B32A32_FLOAT:
+ case Format::R8G8B8A8_UNORM:
typeName = "float4";
break;
- case Format::RGB_Float32:
+ case Format::R32G32B32_FLOAT:
typeName = "float3";
break;
- case Format::RG_Float32:
+ case Format::R32G32_FLOAT:
typeName = "float2";
break;
- case Format::R_Float32:
+ case Format::R32_FLOAT:
typeName = "float";
break;
default:
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp
index 8029826a3..aa945fd85 100644
--- a/tools/gfx/d3d12/render-d3d12.cpp
+++ b/tools/gfx/d3d12/render-d3d12.cpp
@@ -4711,7 +4711,12 @@ Result D3D12Device::createTextureResource(const ITextureResource::Desc& descIn,
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT& layout = layouts[j];
const D3D12_SUBRESOURCE_FOOTPRINT& footprint = layout.Footprint;
- const TextureResource::Size mipSize = calcMipSize(srcDesc.size, j);
+ TextureResource::Size mipSize = calcMipSize(srcDesc.size, j);
+ if (gfxIsCompressedFormat(descIn.format))
+ {
+ mipSize.width = int(D3DUtil::calcAligned(mipSize.width, 4));
+ mipSize.height = int(D3DUtil::calcAligned(mipSize.height, 4));
+ }
assert(footprint.Width == mipSize.width && footprint.Height == mipSize.height && footprint.Depth == mipSize.depth);
@@ -4733,7 +4738,8 @@ Result D3D12Device::createTextureResource(const ITextureResource::Desc& descIn,
//
const uint8_t* srcRow = srcLayer;
uint8_t* dstRow = dstLayer;
- for (int k = 0; k < mipSize.height; ++k)
+ int j = gfxIsCompressedFormat(descIn.format) ? 4 : 1; // BC compressed formats are organized into 4x4 blocks
+ for (int k = 0; k < mipSize.height; k += j)
{
::memcpy(dstRow, srcRow, (size_t)mipRowSize);
@@ -5022,7 +5028,8 @@ Result D3D12Device::createTextureView(ITextureResource* texture, IResourceView::
// Need to construct the D3D12_SHADER_RESOURCE_VIEW_DESC because otherwise TextureCube is not accessed
// appropriately (rather than just passing nullptr to CreateShaderResourceView)
const D3D12_RESOURCE_DESC resourceDesc = resourceImpl->m_resource.getResource()->GetDesc();
- const DXGI_FORMAT pixelFormat = resourceDesc.Format;
+ const DXGI_FORMAT pixelFormat =
+ gfxIsTypelessFormat(texture->getDesc()->format) ? D3DUtil::getMapFormat(desc.format) : resourceDesc.Format;
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
_initSrvDesc(resourceImpl->getType(), *resourceImpl->getDesc(), resourceDesc, pixelFormat, srvDesc);
@@ -5070,7 +5077,9 @@ Result D3D12Device::createBufferView(IBufferResource* buffer, IResourceView::Des
}
else
{
- uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / gfxGetFormatSize(desc.format));
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
}
@@ -5104,7 +5113,9 @@ Result D3D12Device::createBufferView(IBufferResource* buffer, IResourceView::Des
}
else
{
- srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / gfxGetFormatSize(desc.format));
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
}
SLANG_RETURN_ON_FAIL(m_cpuViewHeap->allocate(&viewImpl->m_descriptor));
diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp
index 5f5b0505e..daf86b60d 100644
--- a/tools/gfx/debug-layer.cpp
+++ b/tools/gfx/debug-layer.cpp
@@ -205,30 +205,30 @@ void validateAccelerationStructureBuildInputs(
case IAccelerationStructure::GeometryType::Triangles:
switch (buildInputs.geometryDescs[i].content.triangles.vertexFormat)
{
- case Format::RGB_Float32:
- case Format::RG_Float32:
- case Format::RGBA_Float16:
- case Format::RG_Float16:
- case Format::RGBA_Snorm_UInt16:
- case Format::RG_Snorm_UInt16:
+ case Format::R32G32B32_FLOAT:
+ case Format::R32G32_FLOAT:
+ case Format::R16G16B16A16_FLOAT:
+ case Format::R16G16_FLOAT:
+ case Format::R16G16B16A16_SNORM:
+ case Format::R16G16_SNORM:
break;
default:
GFX_DIAGNOSE_ERROR(
"Unsupported IAccelerationStructure::TriangleDesc::vertexFormat. Valid "
- "values are RGB_Float32, RG_Float32, RGBA_Float16, RG_Float16, "
- "RGBA_Snorm_UInt16 or RG_Snorm_UInt16.");
+ "values are R32G32B32_FLOAT, R32G32_FLOAT, R16G16B16A16_FLOAT, R16G16_FLOAT, "
+ "R16G16B16A16_SNORM or R16G16_SNORM.");
}
if (buildInputs.geometryDescs[i].content.triangles.indexCount)
{
switch (buildInputs.geometryDescs[i].content.triangles.indexFormat)
{
- case Format::R_UInt32:
- case Format::R_UInt16:
+ case Format::R32_UINT:
+ case Format::R16_UINT:
break;
default:
GFX_DIAGNOSE_ERROR(
"Unsupported IAccelerationStructure::TriangleDesc::indexFormat. Valid "
- "values are Unknown, R_UInt32 or R_UInt16.");
+ "values are Unknown, R32_UINT or R16_UINT.");
}
if (!buildInputs.geometryDescs[i].content.triangles.indexData)
{
diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp
index a5d5ae368..afcb8c781 100644
--- a/tools/gfx/open-gl/render-gl.cpp
+++ b/tools/gfx/open-gl/render-gl.cpp
@@ -1532,8 +1532,8 @@ public:
enum class GlPixelFormat
{
Unknown,
- RGBA_Unorm_UInt8,
- D_Float32,
+ R8G8B8A8_UNORM,
+ D32_FLOAT,
D_Unorm24_S8,
CountOf,
};
@@ -1600,9 +1600,8 @@ public:
{
switch (format)
{
- case Format::RGBA_Unorm_UInt8: return GlPixelFormat::RGBA_Unorm_UInt8;
- case Format::D_Float32: return GlPixelFormat::D_Float32;
- case Format::D_Unorm24_S8: return GlPixelFormat::D_Unorm24_S8;
+ case Format::R8G8B8A8_UNORM: return GlPixelFormat::R8G8B8A8_UNORM;
+ case Format::D32_FLOAT: return GlPixelFormat::D32_FLOAT;
default: return GlPixelFormat::Unknown;
}
@@ -1612,8 +1611,8 @@ public:
{
// internalType, format, formatType
{ 0, 0, 0}, // GlPixelFormat::Unknown
- { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE }, // GlPixelFormat::RGBA_Unorm_UInt8
- { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE}, // GlPixelFormat::D_Float32
+ { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE }, // GlPixelFormat::R8G8B8A8_UNORM
+ { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE}, // GlPixelFormat::D32_FLOAT
{ GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE}, // GlPixelFormat::D_Unorm24_S8
};
@@ -1651,10 +1650,10 @@ void GLDevice::debugCallback(GLenum source, GLenum type, GLuint id, GLenum sever
#define CASE(NAME, COUNT, TYPE, NORMALIZED) \
case Format::NAME: do { VertexAttributeFormat result = {COUNT, TYPE, NORMALIZED}; return result; } while (0)
- CASE(RGBA_Float32, 4, GL_FLOAT, GL_FALSE);
- CASE(RGB_Float32, 3, GL_FLOAT, GL_FALSE);
- CASE(RG_Float32, 2, GL_FLOAT, GL_FALSE);
- CASE(R_Float32, 1, GL_FLOAT, GL_FALSE);
+ CASE(R32G32B32A32_FLOAT, 4, GL_FLOAT, GL_FALSE);
+ CASE(R32G32B32_FLOAT, 3, GL_FLOAT, GL_FALSE);
+ CASE(R32G32_FLOAT, 2, GL_FLOAT, GL_FALSE);
+ CASE(R32_FLOAT, 1, GL_FLOAT, GL_FALSE);
#undef CASE
}
}
diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp
index cbf1c6d26..6fef96f0b 100644
--- a/tools/gfx/render.cpp
+++ b/tools/gfx/render.cpp
@@ -19,9 +19,9 @@ static bool debugLayerEnabled = false;
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Global Renderer Functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-#define GFX_FORMAT_SIZE(name, size) uint8_t(size),
+#define GFX_FORMAT_SIZE(name, blockSizeInBytes, pixelsPerBlock) {blockSizeInBytes, pixelsPerBlock},
-static const uint8_t s_formatSize[] =
+static const uint32_t s_formatSizeInfo[][2] =
{
GFX_FORMAT(GFX_FORMAT_SIZE)
};
@@ -32,7 +32,7 @@ static bool _checkFormat()
Index count = 0;
// Check the values are in the same order
-#define GFX_FORMAT_CHECK(name, size) count += Index(Index(Format::name) == value++);
+#define GFX_FORMAT_CHECK(name, blockSizeInBytes, pixelsPerblock) count += Index(Index(Format::name) == value++);
GFX_FORMAT(GFX_FORMAT_CHECK)
const bool r = (count == Index(Format::CountOf));
@@ -54,26 +54,113 @@ struct FormatInfoMap
info.channelType = SLANG_SCALAR_TYPE_NONE;
}
- set(Format::RGBA_Float16, SLANG_SCALAR_TYPE_FLOAT16, 4);
- set(Format::RG_Float16, SLANG_SCALAR_TYPE_FLOAT16, 2);
- set(Format::R_Float16, SLANG_SCALAR_TYPE_FLOAT16, 1);
-
- set(Format::RGBA_Float32, SLANG_SCALAR_TYPE_FLOAT32, 4);
- set(Format::RGB_Float32, SLANG_SCALAR_TYPE_FLOAT32, 3);
- set(Format::RG_Float32, SLANG_SCALAR_TYPE_FLOAT32, 2);
- set(Format::R_Float32, SLANG_SCALAR_TYPE_FLOAT32, 1);
-
- set(Format::R_UInt16, SLANG_SCALAR_TYPE_UINT16, 1);
- set(Format::R_UInt32, SLANG_SCALAR_TYPE_UINT32, 1);
-
- set(Format::D_Float32, SLANG_SCALAR_TYPE_FLOAT32, 1);
+ set(Format::R32G32B32A32_TYPELESS, SLANG_SCALAR_TYPE_UINT32, 4);
+ set(Format::R32G32B32_TYPELESS, SLANG_SCALAR_TYPE_UINT32, 3);
+ set(Format::R32G32_TYPELESS, SLANG_SCALAR_TYPE_UINT32, 2);
+ set(Format::R32_TYPELESS, SLANG_SCALAR_TYPE_UINT32, 1);
+
+ set(Format::R16G16B16A16_TYPELESS, SLANG_SCALAR_TYPE_UINT16, 4);
+ set(Format::R16G16_TYPELESS, SLANG_SCALAR_TYPE_UINT16, 2);
+ set(Format::R16_TYPELESS, SLANG_SCALAR_TYPE_UINT16, 1);
+
+ set(Format::R8G8B8A8_TYPELESS, SLANG_SCALAR_TYPE_UINT8, 4);
+ set(Format::R8G8_TYPELESS, SLANG_SCALAR_TYPE_UINT8, 2);
+ set(Format::R8_TYPELESS, SLANG_SCALAR_TYPE_UINT8, 1);
+ set(Format::B8G8R8A8_TYPELESS, SLANG_SCALAR_TYPE_UINT8, 4);
+
+ set(Format::R32G32B32A32_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R32G32B32_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 3);
+ set(Format::R32G32_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 2);
+ set(Format::R32_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 1);
+
+ set(Format::R16G16B16A16_FLOAT, SLANG_SCALAR_TYPE_FLOAT16, 4);
+ set(Format::R16G16_FLOAT, SLANG_SCALAR_TYPE_FLOAT16, 2);
+ set(Format::R16_FLOAT, SLANG_SCALAR_TYPE_FLOAT16, 1);
+
+ set(Format::R32G32B32A32_UINT, SLANG_SCALAR_TYPE_UINT32, 4);
+ set(Format::R32G32B32_UINT, SLANG_SCALAR_TYPE_UINT32, 3);
+ set(Format::R32G32_UINT, SLANG_SCALAR_TYPE_UINT32, 2);
+ set(Format::R32_UINT, SLANG_SCALAR_TYPE_UINT32, 1);
+
+ set(Format::R16G16B16A16_UINT, SLANG_SCALAR_TYPE_UINT16, 4);
+ set(Format::R16G16_UINT, SLANG_SCALAR_TYPE_UINT16, 2);
+ set(Format::R16_UINT, SLANG_SCALAR_TYPE_UINT16, 1);
+
+ set(Format::R8G8B8A8_UINT, SLANG_SCALAR_TYPE_UINT8, 4);
+ set(Format::R8G8_UINT, SLANG_SCALAR_TYPE_UINT8, 2);
+ set(Format::R8_UINT, SLANG_SCALAR_TYPE_UINT8, 1);
+
+ set(Format::R32G32B32A32_SINT, SLANG_SCALAR_TYPE_INT32, 4);
+ set(Format::R32G32B32_SINT, SLANG_SCALAR_TYPE_INT32, 3);
+ set(Format::R32G32_SINT, SLANG_SCALAR_TYPE_INT32, 2);
+ set(Format::R32_SINT, SLANG_SCALAR_TYPE_INT32, 1);
+
+ set(Format::R16G16B16A16_SINT, SLANG_SCALAR_TYPE_INT16, 4);
+ set(Format::R16G16_SINT, SLANG_SCALAR_TYPE_INT16, 2);
+ set(Format::R16_SINT, SLANG_SCALAR_TYPE_INT16, 1);
+
+ set(Format::R8G8B8A8_SINT, SLANG_SCALAR_TYPE_INT8, 4);
+ set(Format::R8G8_SINT, SLANG_SCALAR_TYPE_INT8, 2);
+ set(Format::R8_SINT, SLANG_SCALAR_TYPE_INT8, 1);
+
+ set(Format::R16G16B16A16_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R16G16_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 2);
+ set(Format::R16_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 1);
+
+ set(Format::R8G8B8A8_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R8G8B8A8_UNORM_SRGB, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R8G8_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 2);
+ set(Format::R8_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 1);
+ set(Format::B8G8R8A8_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+
+ set(Format::R16G16B16A16_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R16G16_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 2);
+ set(Format::R16_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 1);
+
+ set(Format::R8G8B8A8_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R8G8_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 2);
+ set(Format::R8_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 1);
+
+ set(Format::D32_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 1);
+ set(Format::D16_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 1);
+
+ set(Format::B4G4R4A4_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::B5G6R5_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 3);
+ set(Format::B5G5R5A1_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+
+ set(Format::R9G9B9E5_SHAREDEXP, SLANG_SCALAR_TYPE_FLOAT32, 3);
+ set(Format::R10G10B10A2_TYPELESS, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R10G10B10A2_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4);
+ set(Format::R10G10B10A2_UINT, SLANG_SCALAR_TYPE_UINT32, 4);
+ set(Format::R11G11B10_FLOAT, SLANG_SCALAR_TYPE_FLOAT32, 3);
+
+ set(Format::BC1_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC1_UNORM_SRGB, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC2_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC2_UNORM_SRGB, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC3_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC3_UNORM_SRGB, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC4_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 1, 4, 4);
+ set(Format::BC4_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 1, 4, 4);
+ set(Format::BC5_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 2, 4, 4);
+ set(Format::BC5_SNORM, SLANG_SCALAR_TYPE_FLOAT32, 2, 4, 4);
+ set(Format::BC6H_UF16, SLANG_SCALAR_TYPE_FLOAT32, 3, 4, 4);
+ set(Format::BC6H_SF16, SLANG_SCALAR_TYPE_FLOAT32, 3, 4, 4);
+ set(Format::BC7_UNORM, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
+ set(Format::BC7_UNORM_SRGB, SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
}
- void set(Format format, SlangScalarType type, Index channelCount)
+ void set(Format format, SlangScalarType type, Index channelCount, uint32_t blockWidth = 1, uint32_t blockHeight = 1)
{
FormatInfo& info = m_infos[Index(format)];
info.channelCount = uint8_t(channelCount);
info.channelType = uint8_t(type);
+
+ auto sizeInfo = s_formatSizeInfo[Index(format)];
+ info.blockSizeInBytes = sizeInfo[0];
+ info.pixelsPerBlock = sizeInfo[1];
+ info.blockWidth = blockWidth;
+ info.blockHeight = blockHeight;
}
const FormatInfo& get(Format format) const { return m_infos[Index(format)]; }
@@ -85,19 +172,61 @@ static const FormatInfoMap s_formatInfoMap;
static void _compileTimeAsserts()
{
- SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(s_formatSize) == int(Format::CountOf));
+ SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(s_formatSizeInfo) == int(Format::CountOf));
}
extern "C"
{
- size_t SLANG_MCALL gfxGetFormatSize(Format format)
+ SLANG_GFX_API bool gfxIsCompressedFormat(Format format)
+ {
+ switch (format)
+ {
+ case Format::BC1_UNORM:
+ case Format::BC1_UNORM_SRGB:
+ case Format::BC2_UNORM:
+ case Format::BC2_UNORM_SRGB:
+ case Format::BC3_UNORM:
+ case Format::BC3_UNORM_SRGB:
+ case Format::BC4_UNORM:
+ case Format::BC4_SNORM:
+ case Format::BC5_UNORM:
+ case Format::BC5_SNORM:
+ case Format::BC6H_UF16:
+ case Format::BC6H_SF16:
+ case Format::BC7_UNORM:
+ case Format::BC7_UNORM_SRGB:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ SLANG_GFX_API bool gfxIsTypelessFormat(Format format)
{
- return s_formatSize[int(format)];
+ switch (format)
+ {
+ case Format::R32G32B32A32_TYPELESS:
+ case Format::R32G32B32_TYPELESS:
+ case Format::R32G32_TYPELESS:
+ case Format::R32_TYPELESS:
+ case Format::R16G16B16A16_TYPELESS:
+ case Format::R16G16_TYPELESS:
+ case Format::R16_TYPELESS:
+ case Format::R8G8B8A8_TYPELESS:
+ case Format::R8G8_TYPELESS:
+ case Format::R8_TYPELESS:
+ case Format::B8G8R8A8_TYPELESS:
+ case Format::R10G10B10A2_TYPELESS:
+ return true;
+ default:
+ return false;
+ }
}
- SLANG_GFX_API FormatInfo gfxGetFormatInfo(Format format)
+ SLANG_GFX_API SlangResult gfxGetFormatInfo(Format format, FormatInfo* outInfo)
{
- return s_formatInfoMap.get(format);
+ *outInfo = s_formatInfoMap.get(format);
+ return SLANG_OK;
}
SlangResult _createDevice(const IDevice::Desc* desc, IDevice** outDevice)
diff --git a/tools/gfx/vulkan/render-vk.cpp b/tools/gfx/vulkan/render-vk.cpp
index 03f193ca6..3a1557a3c 100644
--- a/tools/gfx/vulkan/render-vk.cpp
+++ b/tools/gfx/vulkan/render-vk.cpp
@@ -3800,10 +3800,10 @@ public:
{
switch (indexFormat)
{
- case Format::R_UInt16:
+ case Format::R16_UINT:
m_boundIndexFormat = VK_INDEX_TYPE_UINT16;
break;
- case Format::R_UInt32:
+ case Format::R32_UINT:
m_boundIndexFormat = VK_INDEX_TYPE_UINT32;
break;
default:
@@ -5026,7 +5026,7 @@ public:
List<VkFormat> formats;
formats.add(VulkanUtil::getVkFormat(desc.format));
// HACK! To check for a different format if couldn't be found
- if (desc.format == Format::RGBA_Unorm_UInt8)
+ if (desc.format == Format::R8G8B8A8_UNORM)
{
formats.add(VK_FORMAT_B8G8R8A8_UNORM);
}
@@ -5047,10 +5047,10 @@ public:
// Save the desc
m_desc = desc;
- if (m_desc.format == Format::RGBA_Unorm_UInt8 &&
+ if (m_desc.format == Format::R8G8B8A8_UNORM &&
m_vkformat == VK_FORMAT_B8G8R8A8_UNORM)
{
- m_desc.format = Format::BGRA_Unorm_UInt8;
+ m_desc.format = Format::B8G8R8A8_UNORM;
}
SLANG_RETURN_ON_FAIL(createSwapchainAndImages());
@@ -5763,7 +5763,6 @@ Result VKDevice::initVulkanInstanceAndDevice(const NativeHandle handles, bool us
deviceExtensions.add(VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME);
m_features.add("shader-subgroup-extended-types");
}
-
if (extendedFeatures.accelerationStructureFeatures.accelerationStructure)
{
extendedFeatures.accelerationStructureFeatures.pNext = (void*)deviceCreateInfo.pNext;
@@ -5781,7 +5780,6 @@ Result VKDevice::initVulkanInstanceAndDevice(const NativeHandle handles, bool us
m_features.add("ray-query");
m_features.add("ray-tracing");
}
-
if (extendedFeatures.bufferDeviceAddressFeatures.bufferDeviceAddress)
{
extendedFeatures.bufferDeviceAddressFeatures.pNext = (void*)deviceCreateInfo.pNext;
@@ -6373,17 +6371,16 @@ void VKDevice::_transitionImageLayout(VkImage image, VkFormat format, const Text
size_t calcRowSize(Format format, int width)
{
- size_t pixelSize = gfxGetFormatSize(format);
- if (pixelSize == 0)
- {
- return 0;
- }
- return size_t(pixelSize * width);
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(format, &sizeInfo);
+ return size_t((width + sizeInfo.blockWidth - 1) / sizeInfo.blockWidth * sizeInfo.blockSizeInBytes);
}
size_t calcNumRows(Format format, int height)
{
- return (size_t)height;
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(format, &sizeInfo);
+ return (size_t)(height + sizeInfo.blockHeight - 1) / sizeInfo.blockHeight;
}
Result VKDevice::createTextureResource(const ITextureResource::Desc& descIn, const ITextureResource::SubresourceData* initData, ITextureResource** outResource)
@@ -6516,6 +6513,8 @@ Result VKDevice::createTextureResource(const ITextureResource::Desc& descIn, con
uint8_t* dstData;
m_api.vkMapMemory(m_device, uploadBuffer.m_memory, 0, bufferSize, 0, (void**)&dstData);
+ uint8_t* dstDataStart;
+ dstDataStart = dstData;
size_t dstSubresourceOffset = 0;
for (int i = 0; i < arraySize; ++i)
@@ -6822,6 +6821,8 @@ Result VKDevice::createSamplerState(ISamplerState::Desc const& desc, ISamplerSta
samplerInfo.compareEnable = desc.reductionOp == TextureReductionOp::Comparison;
samplerInfo.compareOp = translateComparisonFunc(desc.comparisonFunc);
samplerInfo.mipmapMode = translateMipFilterMode(desc.mipFilter);
+ samplerInfo.minLod = Math::Max(0.0f, desc.minLOD);
+ samplerInfo.maxLod = Math::Clamp(desc.maxLOD, samplerInfo.minLod, VK_LOD_CLAMP_NONE);
VkSampler sampler;
SLANG_VK_RETURN_ON_FAIL(m_api.vkCreateSampler(m_device, &samplerInfo, nullptr, &sampler));
@@ -6840,7 +6841,7 @@ Result VKDevice::createTextureView(ITextureResource* texture, IResourceView::Des
VkImageViewCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
createInfo.flags = 0;
- createInfo.format = resourceImpl->m_vkformat;
+ createInfo.format = gfxIsTypelessFormat(texture->getDesc()->format) ? VulkanUtil::getVkFormat(desc.format) : resourceImpl->m_vkformat;
createInfo.image = resourceImpl->m_image;
createInfo.components = VkComponentMapping{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,VK_COMPONENT_SWIZZLE_B,VK_COMPONENT_SWIZZLE_A };
bool isArray = resourceImpl->getDesc()->arraySize != 0;
@@ -7013,7 +7014,9 @@ Result VKDevice::createInputLayout(const InputElementDesc* elements, UInt numEle
dstDesc.offset = uint32_t(srcDesc.offset);
- const size_t elementSize = gfxGetFormatSize(srcDesc.format);
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(srcDesc.format, &sizeInfo);
+ const size_t elementSize = sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock;
assert(elementSize > 0);
const size_t endElement = srcDesc.offset + elementSize;
diff --git a/tools/gfx/vulkan/vk-util.cpp b/tools/gfx/vulkan/vk-util.cpp
index 56664d9e4..3a40152a4 100644
--- a/tools/gfx/vulkan/vk-util.cpp
+++ b/tools/gfx/vulkan/vk-util.cpp
@@ -11,25 +11,102 @@ namespace gfx {
{
switch (format)
{
- case Format::RGBA_Float32: return VK_FORMAT_R32G32B32A32_SFLOAT;
- case Format::RGB_Float32: return VK_FORMAT_R32G32B32_SFLOAT;
- case Format::RG_Float32: return VK_FORMAT_R32G32_SFLOAT;
- case Format::R_Float32: return VK_FORMAT_R32_SFLOAT;
+ case Format::R32G32B32A32_TYPELESS: return VK_FORMAT_R32G32B32A32_SFLOAT;
+ case Format::R32G32B32_TYPELESS: return VK_FORMAT_R32G32B32_SFLOAT;
+ case Format::R32G32_TYPELESS: return VK_FORMAT_R32G32_SFLOAT;
+ case Format::R32_TYPELESS: return VK_FORMAT_R32_SFLOAT;
- case Format::RGBA_Float16: return VK_FORMAT_R16G16B16A16_SFLOAT;
- case Format::RG_Float16: return VK_FORMAT_R16G16_SFLOAT;
- case Format::R_Float16: return VK_FORMAT_R16_SFLOAT;
+ case Format::R16G16B16A16_TYPELESS: return VK_FORMAT_R16G16B16A16_SFLOAT;
+ case Format::R16G16_TYPELESS: return VK_FORMAT_R16G16_SFLOAT;
+ case Format::R16_TYPELESS: return VK_FORMAT_R16_SFLOAT;
- case Format::RGBA_Unorm_UInt8: return VK_FORMAT_R8G8B8A8_UNORM;
- case Format::BGRA_Unorm_UInt8: return VK_FORMAT_B8G8R8A8_UNORM;
- case Format::RGBA_Snorm_UInt16: return VK_FORMAT_R16G16B16A16_SNORM;
- case Format::RG_Snorm_UInt16: return VK_FORMAT_R16G16_SNORM;
- case Format::R_UInt32: return VK_FORMAT_R32_UINT;
+ case Format::R8G8B8A8_TYPELESS: return VK_FORMAT_R8G8B8A8_UNORM;
+ case Format::R8G8_TYPELESS: return VK_FORMAT_R8G8_UNORM;
+ case Format::R8_TYPELESS: return VK_FORMAT_R8_UNORM;
+ case Format::B8G8R8A8_TYPELESS: return VK_FORMAT_B8G8R8A8_UNORM;
- case Format::D_Float32: return VK_FORMAT_D32_SFLOAT;
- case Format::D_Unorm24_S8: return VK_FORMAT_D24_UNORM_S8_UINT;
+ case Format::R32G32B32A32_FLOAT: return VK_FORMAT_R32G32B32A32_SFLOAT;
+ case Format::R32G32B32_FLOAT: return VK_FORMAT_R32G32B32_SFLOAT;
+ case Format::R32G32_FLOAT: return VK_FORMAT_R32G32_SFLOAT;
+ case Format::R32_FLOAT: return VK_FORMAT_R32_SFLOAT;
- default: return VK_FORMAT_UNDEFINED;
+ case Format::R16G16B16A16_FLOAT: return VK_FORMAT_R16G16B16A16_SFLOAT;
+ case Format::R16G16_FLOAT: return VK_FORMAT_R16G16_SFLOAT;
+ case Format::R16_FLOAT: return VK_FORMAT_R16_SFLOAT;
+
+ case Format::R32G32B32A32_UINT: return VK_FORMAT_R32G32B32A32_UINT;
+ case Format::R32G32B32_UINT: return VK_FORMAT_R32G32B32_UINT;
+ case Format::R32G32_UINT: return VK_FORMAT_R32G32_UINT;
+ case Format::R32_UINT: return VK_FORMAT_R32_UINT;
+
+ case Format::R16G16B16A16_UINT: return VK_FORMAT_R16G16B16A16_UINT;
+ case Format::R16G16_UINT: return VK_FORMAT_R16G16_UINT;
+ case Format::R16_UINT: return VK_FORMAT_R16_UINT;
+
+ case Format::R8G8B8A8_UINT: return VK_FORMAT_R8G8B8A8_UINT;
+ case Format::R8G8_UINT: return VK_FORMAT_R8G8_UINT;
+ case Format::R8_UINT: return VK_FORMAT_R8_UINT;
+
+ case Format::R32G32B32A32_SINT: return VK_FORMAT_R32G32B32A32_SINT;
+ case Format::R32G32B32_SINT: return VK_FORMAT_R32G32B32_SINT;
+ case Format::R32G32_SINT: return VK_FORMAT_R32G32_SINT;
+ case Format::R32_SINT: return VK_FORMAT_R32_SINT;
+
+ case Format::R16G16B16A16_SINT: return VK_FORMAT_R16G16B16A16_SINT;
+ case Format::R16G16_SINT: return VK_FORMAT_R16G16_SINT;
+ case Format::R16_SINT: return VK_FORMAT_R16_SINT;
+
+ case Format::R8G8B8A8_SINT: return VK_FORMAT_R8G8B8A8_SINT;
+ case Format::R8G8_SINT: return VK_FORMAT_R8G8_SINT;
+ case Format::R8_SINT: return VK_FORMAT_R8_SINT;
+
+ case Format::R16G16B16A16_UNORM: return VK_FORMAT_R16G16B16A16_UNORM;
+ case Format::R16G16_UNORM: return VK_FORMAT_R16G16_UNORM;
+ case Format::R16_UNORM: return VK_FORMAT_R16_UNORM;
+
+ case Format::R8G8B8A8_UNORM: return VK_FORMAT_R8G8B8A8_UNORM;
+ case Format::R8G8B8A8_UNORM_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
+ case Format::R8G8_UNORM: return VK_FORMAT_R8G8_UNORM;
+ case Format::R8_UNORM: return VK_FORMAT_R8_UNORM;
+ case Format::B8G8R8A8_UNORM: return VK_FORMAT_B8G8R8A8_UNORM;
+
+ case Format::R16G16B16A16_SNORM: return VK_FORMAT_R16G16B16A16_SNORM;
+ case Format::R16G16_SNORM: return VK_FORMAT_R16G16_SNORM;
+ case Format::R16_SNORM: return VK_FORMAT_R16_SNORM;
+
+ case Format::R8G8B8A8_SNORM: return VK_FORMAT_R8G8B8A8_SNORM;
+ case Format::R8G8_SNORM: return VK_FORMAT_R8G8_SNORM;
+ case Format::R8_SNORM: return VK_FORMAT_R8_SNORM;
+
+ case Format::D32_FLOAT: return VK_FORMAT_D32_SFLOAT;
+ case Format::D16_UNORM: return VK_FORMAT_D16_UNORM;
+
+ case Format::B4G4R4A4_UNORM: return VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT;
+ case Format::B5G6R5_UNORM: return VK_FORMAT_R5G6B5_UNORM_PACK16;
+ case Format::B5G5R5A1_UNORM: return VK_FORMAT_A1R5G5B5_UNORM_PACK16;
+
+ case Format::R9G9B9E5_SHAREDEXP: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32;
+ case Format::R10G10B10A2_TYPELESS: return VK_FORMAT_A2B10G10R10_UINT_PACK32;
+ case Format::R10G10B10A2_UINT: return VK_FORMAT_A2B10G10R10_UINT_PACK32;
+ case Format::R10G10B10A2_UNORM: return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
+ case Format::R11G11B10_FLOAT: return VK_FORMAT_B10G11R11_UFLOAT_PACK32;
+
+ case Format::BC1_UNORM: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
+ case Format::BC1_UNORM_SRGB: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK;
+ case Format::BC2_UNORM: return VK_FORMAT_BC2_UNORM_BLOCK;
+ case Format::BC2_UNORM_SRGB: return VK_FORMAT_BC2_SRGB_BLOCK;
+ case Format::BC3_UNORM: return VK_FORMAT_BC3_UNORM_BLOCK;
+ case Format::BC3_UNORM_SRGB: return VK_FORMAT_BC3_SRGB_BLOCK;
+ case Format::BC4_UNORM: return VK_FORMAT_BC4_UNORM_BLOCK;
+ case Format::BC4_SNORM: return VK_FORMAT_BC4_SNORM_BLOCK;
+ case Format::BC5_UNORM: return VK_FORMAT_BC5_UNORM_BLOCK;
+ case Format::BC5_SNORM: return VK_FORMAT_BC5_SNORM_BLOCK;
+ case Format::BC6H_UF16: return VK_FORMAT_BC6H_UFLOAT_BLOCK;
+ case Format::BC6H_SF16: return VK_FORMAT_BC6H_SFLOAT_BLOCK;
+ case Format::BC7_UNORM: return VK_FORMAT_BC7_UNORM_BLOCK;
+ case Format::BC7_UNORM_SRGB: return VK_FORMAT_BC7_SRGB_BLOCK;
+
+ default: return VK_FORMAT_UNDEFINED;
}
}
@@ -256,10 +333,10 @@ Result AccelerationStructureBuildGeometryInfoBuilder::build(
vkGeomData.triangles.maxVertex = geomDesc.content.triangles.vertexCount - 1;
switch (geomDesc.content.triangles.indexFormat)
{
- case Format::R_UInt32:
+ case Format::R32_UINT:
vkGeomData.triangles.indexType = VK_INDEX_TYPE_UINT32;
break;
- case Format::R_UInt16:
+ case Format::R16_UINT:
vkGeomData.triangles.indexType = VK_INDEX_TYPE_UINT16;
break;
case Format::Unknown:
diff --git a/tools/platform/gui.cpp b/tools/platform/gui.cpp
index e4f269b95..1573a848b 100644
--- a/tools/platform/gui.cpp
+++ b/tools/platform/gui.cpp
@@ -102,9 +102,9 @@ GUI::GUI(
program = device->createProgram(programDesc);
#endif
InputElementDesc inputElements[] = {
- {"U", 0, Format::RG_Float32, offsetof(ImDrawVert, pos) },
- {"U", 1, Format::RG_Float32, offsetof(ImDrawVert, uv) },
- {"U", 2, Format::RGBA_Unorm_UInt8, offsetof(ImDrawVert, col) },
+ {"U", 0, Format::R32G32_FLOAT, offsetof(ImDrawVert, pos) },
+ {"U", 1, Format::R32G32_FLOAT, offsetof(ImDrawVert, uv) },
+ {"U", 2, Format::R8G8B8A8_UNORM, offsetof(ImDrawVert, col) },
};
auto inputLayout = device->createInputLayout(
&inputElements[0],
@@ -141,7 +141,7 @@ GUI::GUI(
{
gfx::ITextureResource::Desc desc = {};
desc.type = IResource::Type::Texture2D;
- desc.format = Format::RGBA_Unorm_UInt8;
+ desc.format = Format::R8G8B8A8_UNORM;
desc.arraySize = 0;
desc.size.width = width;
desc.size.height = height;
@@ -289,7 +289,7 @@ void GUI::endFrame(ITransientResourceHeap* transientHeap, IFramebuffer* framebuf
renderEncoder->setVertexBuffer(0, vertexBuffer, sizeof(ImDrawVert));
renderEncoder->setIndexBuffer(
- indexBuffer, sizeof(ImDrawIdx) == 2 ? Format::R_UInt16 : Format::R_UInt32);
+ indexBuffer, sizeof(ImDrawIdx) == 2 ? Format::R16_UINT : Format::R32_UINT);
renderEncoder->setPrimitiveTopology(PrimitiveTopology::TriangleList);
UInt vertexOffset = 0;
diff --git a/tools/platform/model.cpp b/tools/platform/model.cpp
index 57acf9ecd..a48d499b9 100644
--- a/tools/platform/model.cpp
+++ b/tools/platform/model.cpp
@@ -125,7 +125,7 @@ ComPtr<ITextureResource> loadTextureImage(
default:
return nullptr;
- case 4: format = Format::RGBA_Unorm_UInt8;
+ case 4: format = Format::R8G8B8A8_UNORM;
// TODO: handle other cases here if/when we stop forcing 4-component
// results when loading the image with stb_image.
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 7c65da5e7..3f26f6d9b 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -539,9 +539,9 @@ SlangResult RenderTestApp::initialize(
// fixed/known set of attributes.
//
const InputElementDesc inputElements[] = {
- { "A", 0, Format::RGB_Float32, offsetof(Vertex, position) },
- { "A", 1, Format::RGB_Float32, offsetof(Vertex, color) },
- { "A", 2, Format::RG_Float32, offsetof(Vertex, uv) },
+ { "A", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, position) },
+ { "A", 1, Format::R32G32B32_FLOAT, offsetof(Vertex, color) },
+ { "A", 2, Format::R32G32_FLOAT, offsetof(Vertex, uv) },
};
ComPtr<IInputLayout> inputLayout;
@@ -600,7 +600,7 @@ void RenderTestApp::_initializeRenderPass()
depthBufferDesc.size.height = gWindowHeight;
depthBufferDesc.size.depth = 1;
depthBufferDesc.numMipLevels = 1;
- depthBufferDesc.format = Format::D_Float32;
+ depthBufferDesc.format = Format::D32_FLOAT;
depthBufferDesc.defaultState = ResourceState::DepthWrite;
depthBufferDesc.allowedStates = ResourceState::DepthWrite;
@@ -613,14 +613,14 @@ void RenderTestApp::_initializeRenderPass()
colorBufferDesc.size.height = gWindowHeight;
colorBufferDesc.size.depth = 1;
colorBufferDesc.numMipLevels = 1;
- colorBufferDesc.format = Format::RGBA_Unorm_UInt8;
+ colorBufferDesc.format = Format::R8G8B8A8_UNORM;
colorBufferDesc.defaultState = ResourceState::RenderTarget;
colorBufferDesc.allowedStates = ResourceState::RenderTarget;
m_colorBuffer = m_device->createTextureResource(colorBufferDesc, nullptr);
gfx::IResourceView::Desc colorBufferViewDesc;
memset(&colorBufferViewDesc, 0, sizeof(colorBufferViewDesc));
- colorBufferViewDesc.format = gfx::Format::RGBA_Unorm_UInt8;
+ colorBufferViewDesc.format = gfx::Format::R8G8B8A8_UNORM;
colorBufferViewDesc.renderTarget.shape = gfx::IResource::Type::Texture2D;
colorBufferViewDesc.type = gfx::IResourceView::Type::RenderTarget;
ComPtr<gfx::IResourceView> rtv =
@@ -628,14 +628,14 @@ void RenderTestApp::_initializeRenderPass()
gfx::IResourceView::Desc depthBufferViewDesc;
memset(&depthBufferViewDesc, 0, sizeof(depthBufferViewDesc));
- depthBufferViewDesc.format = gfx::Format::D_Float32;
+ depthBufferViewDesc.format = gfx::Format::D32_FLOAT;
depthBufferViewDesc.renderTarget.shape = gfx::IResource::Type::Texture2D;
depthBufferViewDesc.type = gfx::IResourceView::Type::DepthStencil;
ComPtr<gfx::IResourceView> dsv =
m_device->createTextureView(depthBufferResource.get(), depthBufferViewDesc);
- IFramebufferLayout::AttachmentLayout colorAttachment = {gfx::Format::RGBA_Unorm_UInt8, 1};
- IFramebufferLayout::AttachmentLayout depthAttachment = {gfx::Format::D_Float32, 1};
+ IFramebufferLayout::AttachmentLayout colorAttachment = {gfx::Format::R8G8B8A8_UNORM, 1};
+ IFramebufferLayout::AttachmentLayout depthAttachment = {gfx::Format::D32_FLOAT, 1};
gfx::IFramebufferLayout::Desc framebufferLayoutDesc;
framebufferLayoutDesc.renderTargetCount = 1;
framebufferLayoutDesc.renderTargets = &colorAttachment;
@@ -703,7 +703,7 @@ void RenderTestApp::_initializeAccelerationStructure()
geomDesc.content.triangles.indexFormat = Format::Unknown;
geomDesc.content.triangles.vertexCount = kVertexCount;
geomDesc.content.triangles.vertexData = vertexBuffer->getDeviceAddress();
- geomDesc.content.triangles.vertexFormat = Format::RGB_Float32;
+ geomDesc.content.triangles.vertexFormat = Format::R32G32B32_FLOAT;
geomDesc.content.triangles.vertexStride = sizeof(Vertex);
geomDesc.content.triangles.transform3x4 = transformBuffer->getDeviceAddress();
accelerationStructureBuildInputs.geometryDescs = &geomDesc;
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 7e6d290c8..7aef0025f 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -19,7 +19,7 @@ namespace renderer_test
Format _getFormatFromName(const UnownedStringSlice& slice)
{
-#define SLANG_FORMAT_CASE(name, size) if (slice == #name) return Format::name; else
+#define SLANG_FORMAT_CASE(name, blockSizeInBytes, pixelsPerBlock) if (slice == #name) return Format::name; else
GFX_FORMAT(SLANG_FORMAT_CASE)
return Format::Unknown;
@@ -1091,19 +1091,19 @@ namespace renderer_test
void generateTextureData(TextureData& output, const InputTextureDesc& desc)
{
- const gfx::FormatInfo formatInfo = gfxGetFormatInfo(desc.format);
-
+ gfx::FormatInfo formatInfo;
+ gfxGetFormatInfo(desc.format, &formatInfo);
switch (desc.format)
{
- case Format::RGBA_Unorm_UInt8:
+ case Format::R8G8B8A8_UNORM:
{
generateTextureDataRGB8(output, desc);
break;
}
- case Format::R_Float16:
- case Format::RG_Float16:
- case Format::RGBA_Float16:
+ case Format::R16_FLOAT:
+ case Format::R16G16_FLOAT:
+ case Format::R16G16B16A16_FLOAT:
{
TextureData work;
generateTextureDataRGB8(work, desc);
@@ -1176,11 +1176,11 @@ namespace renderer_test
}
break;
}
- case Format::R_Float32:
- case Format::RG_Float32:
- case Format::RGB_Float32:
- case Format::RGBA_Float32:
- case Format::D_Float32:
+ case Format::R32_FLOAT:
+ case Format::R32G32_FLOAT:
+ case Format::R32G32B32_FLOAT:
+ case Format::R32G32B32A32_FLOAT:
+ case Format::D32_FLOAT:
{
TextureData work;
generateTextureDataRGB8(work, desc);
@@ -1285,7 +1285,7 @@ namespace renderer_test
if (arrLen == 0)
arrLen = 1;
- output.init(Format::RGBA_Unorm_UInt8);
+ output.init(Format::R8G8B8A8_UNORM);
//List<List<unsigned int>>& dataBuffer = output.dataBuffer;
int arraySize = arrLen;
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index fe835a7f1..78d545114 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -41,7 +41,7 @@ struct InputTextureDesc
int size = 4;
int mipMapCount = 0; ///< 0 means the maximum number of mips will be bound
- Format format = Format::RGBA_Unorm_UInt8;
+ Format format = Format::R8G8B8A8_UNORM;
InputTextureContent content = InputTextureContent::One;
};
@@ -111,7 +111,9 @@ struct TextureData
{
clearSlices();
- m_formatSize = uint8_t(gfxGetFormatSize(format));
+ FormatInfo formatSizeInfo;
+ gfxGetFormatInfo(format, &formatSizeInfo);
+ m_formatSize = uint8_t(formatSizeInfo.blockSizeInBytes / formatSizeInfo.pixelsPerBlock);
m_format = format;
}
diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp
index e12a538b3..bbc000594 100644
--- a/tools/render-test/shader-renderer-util.cpp
+++ b/tools/render-test/shader-renderer-util.cpp
@@ -29,8 +29,8 @@ using Slang::Result;
{
ITextureResource::Desc textureResourceDesc = {};
- // Default to RGBA_Unorm_UInt8
- const Format format = (inputDesc.format == Format::Unknown) ? Format::RGBA_Unorm_UInt8 : inputDesc.format;
+ // Default to R8G8B8A8_UNORM
+ const Format format = (inputDesc.format == Format::Unknown) ? Format::R8G8B8A8_UNORM : inputDesc.format;
textureResourceDesc.format = format;
textureResourceDesc.numMipLevels = texData.m_mipLevels;