Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ elseif(PLATFORM_ANDROID)
elseif(PLATFORM_LINUX)
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Linux platform")
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Linux platform")
set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on Linux platform via Dawn")
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on Linux platform")
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_LINUX=1)
elseif(PLATFORM_MACOS)
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on macOS platform")
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on macOS platform")
set(WEBGPU_SUPPORTED TRUE CACHE INTERNAL "WebGPU is supported on macOS platform via Dawn")
set(ARCHIVER_SUPPORTED TRUE CACHE INTERNAL "Archiver is supported on macOS platform")
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_MACOS=1 PLATFORM_APPLE=1)
elseif(PLATFORM_IOS)
Expand Down
16 changes: 9 additions & 7 deletions Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ class TexFormatToVkFormatMapper
m_FmtToVkFmtMap[TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS] = VK_FORMAT_D32_SFLOAT_S8_UINT;
m_FmtToVkFmtMap[TEX_FORMAT_X32_TYPELESS_G8X24_UINT] = VK_FORMAT_UNDEFINED;

m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_TYPELESS] = VK_FORMAT_A2R10G10B10_UNORM_PACK32;
m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_UNORM] = VK_FORMAT_A2R10G10B10_UNORM_PACK32;
m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_UINT] = VK_FORMAT_A2R10G10B10_UINT_PACK32;
// RGB10A2 stores R in the low bits (DXGI_FORMAT_R10G10B10A2, GL_RGB10_A2), which is A2B10G10R10 in Vulkan.
// It is also the format of the SPIR-V Rgb10A2/Rgb10a2ui image formats and the one with guaranteed storage support.
m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_TYPELESS] = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_UNORM] = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
m_FmtToVkFmtMap[TEX_FORMAT_RGB10A2_UINT] = VK_FORMAT_A2B10G10R10_UINT_PACK32;
m_FmtToVkFmtMap[TEX_FORMAT_R11G11B10_FLOAT] = VK_FORMAT_B10G11R11_UFLOAT_PACK32;

m_FmtToVkFmtMap[TEX_FORMAT_RGBA8_TYPELESS] = VK_FORMAT_R8G8B8A8_UNORM;
Expand Down Expand Up @@ -263,18 +265,18 @@ class VkFormatToTexFormatMapper
m_VkFmtToTexFmtMap[VK_FORMAT_A8B8G8R8_SINT_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A8B8G8R8_SRGB_PACK32] = TEX_FORMAT_UNKNOWN;

m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_UNORM_PACK32] = TEX_FORMAT_RGB10A2_UNORM;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_UNORM_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_SNORM_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_USCALED_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_SSCALED_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_UINT_PACK32] = TEX_FORMAT_RGB10A2_UINT;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_UINT_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2R10G10B10_SINT_PACK32] = TEX_FORMAT_UNKNOWN;

m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_UNORM_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_UNORM_PACK32] = TEX_FORMAT_RGB10A2_UNORM;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_SNORM_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_USCALED_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_SSCALED_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_UINT_PACK32] = TEX_FORMAT_UNKNOWN;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_UINT_PACK32] = TEX_FORMAT_RGB10A2_UINT;
m_VkFmtToTexFmtMap[VK_FORMAT_A2B10G10R10_SINT_PACK32] = TEX_FORMAT_UNKNOWN;

m_VkFmtToTexFmtMap[VK_FORMAT_R16_UNORM] = TEX_FORMAT_R16_UNORM;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineWebGPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ PUBLIC
target_link_libraries(Diligent-GraphicsEngineWebGPU-shared
PRIVATE
Diligent-BuildSettings
Diligent-GraphicsEngineWebGPU-static
PUBLIC
Diligent-GraphicsEngineWebGPUInterface
)

target_link_whole_archive(Diligent-GraphicsEngineWebGPU-shared Diligent-GraphicsEngineWebGPU-static)

if(PLATFORM_WIN32)
# Do not add 'lib' prefix when building with MinGW
set_target_properties(Diligent-GraphicsEngineWebGPU-shared PROPERTIES PREFIX "")
Expand Down
2 changes: 2 additions & 0 deletions Graphics/GraphicsEngineWebGPU/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#pragma once

#include <algorithm>
#include <cstring>
#include <string>

#include <webgpu/webgpu.h>
Expand Down
1 change: 1 addition & 0 deletions Graphics/ShaderTools/include/WGSLShaderResources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// | |
// | Uniform Buffers | Storage Buffers | Textures | Storage Textures | Samplers | Ext Textures | Spec Constants | Resource Names |

#include <cstdint>
#include <memory>
#include <string>

Expand Down
1 change: 1 addition & 0 deletions Graphics/ShaderTools/include/WGSLUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#pragma once

#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
Expand Down
4 changes: 4 additions & 0 deletions Graphics/ShaderTools/src/WGSLShaderResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
*/

#include "WGSLShaderResources.hpp"

#include <algorithm>
#include <cstring>

#include "Align.hpp"
#include "StringPool.hpp"
#include "WGSLUtils.hpp"
Expand Down
1 change: 1 addition & 0 deletions Graphics/ShaderTools/src/WGSLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include <algorithm>
#include <cstring>
#include <limits>
#include <unordered_set>

Expand Down
63 changes: 63 additions & 0 deletions Tests/DiligentCoreAPITest/src/ClearRenderTargetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,67 @@ TEST(ClearRenderTargetTest, LoadOpClear2)
TestClearWithLoadOp({0.375f, 0.75, 0.125, 1.0f}, 2);
}

// TEX_FORMAT_RGB10A2_UNORM has the layout of DXGI_FORMAT_R10G10B10A2_UNORM and GL_RGB10_A2: red in the low 10 bits
// and alpha in the high 2 bits. Every backend must store a red clear with this layout.
TEST(ClearRenderTargetTest, RGB10A2BitLayout)
{
GPUTestingEnvironment* pEnv = GPUTestingEnvironment::GetInstance();
IRenderDevice* pDevice = pEnv->GetDevice();
IDeviceContext* pContext = pEnv->GetDeviceContext();

if ((pDevice->GetTextureFormatInfoExt(TEX_FORMAT_RGB10A2_UNORM).BindFlags & BIND_RENDER_TARGET) == 0)
{
GTEST_SKIP() << "RGB10A2 render targets are not supported by this device";
}

GPUTestingEnvironment::ScopedReset EnvironmentAutoReset;

TextureDesc TexDesc;
TexDesc.Name = "ClearRenderTargetTest.RGB10A2BitLayout";
TexDesc.Type = RESOURCE_DIM_TEX_2D;
TexDesc.Width = 4;
TexDesc.Height = 4;
TexDesc.Format = TEX_FORMAT_RGB10A2_UNORM;
TexDesc.BindFlags = BIND_RENDER_TARGET;
RefCntAutoPtr<ITexture> pTex;
pDevice->CreateTexture(TexDesc, nullptr, &pTex);
ASSERT_NE(pTex, nullptr);

TexDesc.Name = "ClearRenderTargetTest.RGB10A2BitLayout staging";
TexDesc.Usage = USAGE_STAGING;
TexDesc.BindFlags = BIND_NONE;
TexDesc.CPUAccessFlags = CPU_ACCESS_READ;
RefCntAutoPtr<ITexture> pStagingTex;
pDevice->CreateTexture(TexDesc, nullptr, &pStagingTex);
ASSERT_NE(pStagingTex, nullptr);

ITextureView* pRTVs[] = {pTex->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET)};
pContext->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
constexpr float Red[] = {1, 0, 0, 1};
pContext->ClearRenderTarget(pRTVs[0], Red, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
pContext->SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE);

pContext->CopyTexture(CopyTextureAttribs{pTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION, pStagingTex, RESOURCE_STATE_TRANSITION_MODE_TRANSITION});
pContext->WaitForIdle();

// Some Intel D3D11 drivers return null with DO_NOT_WAIT even after WaitForIdle().
const MAP_FLAGS MapFlags = pDevice->GetDeviceInfo().Type == RENDER_DEVICE_TYPE_D3D11 ? MAP_FLAG_NONE : MAP_FLAG_DO_NOT_WAIT;
MappedTextureSubresource MappedData;
pContext->MapTextureSubresource(pStagingTex, 0, 0, MAP_READ, MapFlags, nullptr, MappedData);
ASSERT_NE(MappedData.pData, nullptr);

constexpr Uint32 RedTexel = (3u << 30) | 0x3FFu;
for (Uint32 Row = 0; Row < TexDesc.Height; ++Row)
{
const Uint8* pRow = static_cast<const Uint8*>(MappedData.pData) + Row * MappedData.Stride;
for (Uint32 Col = 0; Col < TexDesc.Width; ++Col)
{
Uint32 Texel = 0;
memcpy(&Texel, pRow + Col * sizeof(Texel), sizeof(Texel));
EXPECT_EQ(Texel, RedTexel) << "Texel (" << Col << ", " << Row << "): expected red in bits 0-9 and alpha in bits 30-31";
}
}
pContext->UnmapTextureSubresource(pStagingTex, 0, 0);
}

} // namespace
26 changes: 15 additions & 11 deletions ThirdParty/dawn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ endif()
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "" FORCE)
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "" FORCE)
set(TINT_BUILD_IR_BINARY OFF CACHE BOOL "" FORCE)
if (PLATFORM_WEB)
set(TINT_BUILD_HLSL_WRITER OFF CACHE BOOL "" FORCE)
else()
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "" FORCE)
endif()

set(TINT_BUILD_HLSL_WRITER OFF CACHE BOOL "" FORCE)
set(TINT_BUILD_GLSL_WRITER OFF CACHE BOOL "" FORCE)
set(TINT_BUILD_MSL_WRITER OFF CACHE BOOL "" FORCE)
set(TINT_BUILD_SPV_WRITER OFF CACHE BOOL "" FORCE)
Expand All @@ -59,16 +54,25 @@ set(DAWN_USE_WAYLAND OFF CACHE BOOL "" FORCE)

set(DAWN_ENABLE_VULKAN OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_D3D11 OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_D3D12 OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_DESKTOP_GL OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_OPENGLES OFF CACHE BOOL "" FORCE)
if (PLATFORM_WEB)
set(DAWN_ENABLE_D3D12 OFF CACHE BOOL "" FORCE)
else()
set(DAWN_ENABLE_D3D12 ON CACHE BOOL "" FORCE)
set(DAWN_ENABLE_METAL OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_NULL OFF CACHE BOOL "" FORCE)
if (PLATFORM_WIN32)
set(DAWN_ENABLE_D3D12 ON CACHE BOOL "" FORCE)
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "" FORCE)
elseif(PLATFORM_MACOS)
set(DAWN_ENABLE_METAL ON CACHE BOOL "" FORCE)
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "" FORCE)
elseif(PLATFORM_LINUX)
# Use the null device for serialization. Dawn Native references Tint bindings that are only
# defined when a backend writer is built, so enable the HLSL writer as on Windows.
set(DAWN_ENABLE_NULL ON CACHE BOOL "" FORCE)
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "" FORCE)
endif()

set(DAWN_USE_GLFW OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_NULL OFF CACHE BOOL "" FORCE)
set(DAWN_USE_WINDOWS_UI OFF CACHE BOOL "" FORCE)
set(DAWN_ENABLE_SPIRV_VALIDATION OFF CACHE BOOL "" FORCE)

Expand Down
Loading