From 569fb5a399cdb1cb39fb10d8db1fd78ab56f6c9e Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 5 Nov 2020 17:31:31 -0800 Subject: A number of minor updates/fixes --- .../include/RenderDeviceVkImpl.hpp | 23 ++++++++++------------ .../include/ShaderResourceLayoutVk.hpp | 4 ++-- .../interface/ShaderBindingTableVk.h | 4 ++++ .../src/PipelineStateVkImpl.cpp | 4 ++-- .../src/RenderDeviceVkImpl.cpp | 9 ++++++++- .../src/ShaderResourceLayoutVk.cpp | 14 ++++++------- .../src/VulkanTypeConversions.cpp | 8 ++++---- 7 files changed, 37 insertions(+), 29 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp index 556e3aa5..bd95d81b 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp @@ -197,22 +197,17 @@ public: IDXCompiler* GetDxCompiler() const { return m_pDxCompiler.get(); } - Uint32 GetShaderGroupHandleSize() const + struct Properties { - return GetPhysicalDevice().GetExtProperties().RayTracing.shaderGroupHandleSize; - } - Uint32 GetMaxShaderRecordStride() const - { - return GetPhysicalDevice().GetExtProperties().RayTracing.maxShaderGroupStride; - } - Uint32 GetShaderGroupBaseAlignment() const - { - return GetPhysicalDevice().GetExtProperties().RayTracing.shaderGroupBaseAlignment; - } + const Uint32 ShaderGroupHandleSize = 0; + const Uint32 MaxShaderRecordStride = 0; + const Uint32 ShaderGroupBaseAlignment = 0; + const Uint32 MaxDrawMeshTasksCount = 0; + }; - Uint32 GetMaxDrawMeshTasksCount() const + const Properties& GetProperties() const { - return GetPhysicalDevice().GetExtProperties().MeshShader.maxDrawMeshTasksCount; + return m_Properties; } private: @@ -249,6 +244,8 @@ private: VulkanDynamicMemoryManager m_DynamicMemoryManager; std::unique_ptr m_pDxCompiler; + + Properties m_Properties; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp index bee3de1f..44a377fd 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.hpp @@ -198,7 +198,7 @@ public: /* 16 */ const char* const Name; /* 24 */ const ShaderResourceLayoutVk& ParentResLayout; -#ifdef DILIGENT_DEBUG +#ifdef DILIGENT_DEVELOPMENT /* 32 */ const Uint32 BufferStaticSize; /* 36 */ const Uint32 BufferStride; #endif @@ -229,7 +229,7 @@ public: Type {_Type }, ResourceDim {_ResourceDim }, IsMS {_IsMS ? Uint8{1} : Uint8{0}}, -#ifdef DILIGENT_DEBUG +#ifdef DILIGENT_DEVELOPMENT BufferStaticSize {_BufferStaticSize}, BufferStride {_BufferStride }, #endif diff --git a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h index ee4ea3c8..10970156 100644 --- a/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h +++ b/Graphics/GraphicsEngineVulkan/interface/ShaderBindingTableVk.h @@ -46,6 +46,8 @@ static const INTERFACE_ID IID_ShaderBindingTableVk = IShaderBindingTableInclusiveMethods; \ IShaderBindingTableVkMethods ShaderBindingTableVk +#if DILIGENT_CPP_INTERFACE // Empty structs are not allwed in C + // clang-format off /// Exposes Vulkan-specific functionality of a Shader binding table object. DILIGENT_BEGIN_INTERFACE(IShaderBindingTableVk, IShaderBindingTable) @@ -54,6 +56,8 @@ DILIGENT_BEGIN_INTERFACE(IShaderBindingTableVk, IShaderBindingTable) DILIGENT_END_INTERFACE // clang-format on +#endif + #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h" #if DILIGENT_C_INTERFACE diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index a9dcc5cb..6bfd4eeb 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -758,8 +758,8 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* { try { - const auto& LogicalDevice = GetDevice()->GetLogicalDevice(); - const auto ShaderGroupHandleSize = pDeviceVk->GetShaderGroupHandleSize(); + const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); + const auto ShaderGroupHandleSize = pDeviceVk->GetProperties().ShaderGroupHandleSize; std::vector vkShaderStages; std::vector ShaderModules; diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 4d2c01e3..addf3440 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -159,7 +159,14 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters* EngineCI.DynamicHeapSize, ~Uint64{0} }, - m_pDxCompiler{CreateDXCompiler(DXCompilerTarget::Vulkan, EngineCI.pDxCompilerPath)} + m_pDxCompiler{CreateDXCompiler(DXCompilerTarget::Vulkan, EngineCI.pDxCompilerPath)}, + m_Properties + { + m_PhysicalDevice->GetExtProperties().RayTracing.shaderGroupHandleSize, + m_PhysicalDevice->GetExtProperties().RayTracing.maxShaderGroupStride, + m_PhysicalDevice->GetExtProperties().RayTracing.shaderGroupBaseAlignment, + m_PhysicalDevice->GetExtProperties().MeshShader.maxDrawMeshTasksCount + } // clang-format on { static_assert(sizeof(VulkanDescriptorPoolSize) == sizeof(Uint32) * 11, "Please add new descriptors to m_DescriptorSetAllocator and m_DynamicDescriptorPool constructors"); diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index 7763b480..ba8d567a 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -827,12 +827,12 @@ void ShaderResourceLayoutVk::VkResource::CacheUniformBuffer(IDeviceObject* #ifdef DILIGENT_DEVELOPMENT VerifyConstantBufferBinding(*this, GetVariableType(), ArrayInd, pBuffer, pBufferVk.RawPtr(), DstRes.pObject.RawPtr(), ParentResLayout.GetShaderName()); - if (pBufferVk->GetDesc().uiSizeInBytes != BufferStaticSize) + if (pBufferVk->GetDesc().uiSizeInBytes < BufferStaticSize) { std::stringstream ss; - ss << "binding buffer '" << pBufferVk->GetDesc().Name << "' size (" << pBufferVk->GetDesc().uiSizeInBytes - << ") doesn't match buffer size in shader (" << BufferStaticSize << ")"; - LOG_INFO_MESSAGE(ss.str()); + ss << "The size of buffer '" << pBufferVk->GetDesc().Name << "' (" << pBufferVk->GetDesc().uiSizeInBytes + << ") is not large enough for what the shader expects (" << BufferStaticSize << ")"; + LOG_ERROR_MESSAGE(ss.str()); } #endif @@ -890,9 +890,9 @@ void ShaderResourceLayoutVk::VkResource::CacheStorageBuffer(IDeviceObject* if (ViewDesc.ByteWidth < BufferStaticSize || (ViewDesc.ByteWidth - BufferStaticSize) % BufferStride != 0) { - LOG_INFO_MESSAGE("binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '", - Name, "' in shader '", ParentResLayout.GetShaderName(), "': size mismatch, in shader buffer has static size (", - BufferStaticSize, ") and array stride (", BufferStride, "), but actual size is (", ViewDesc.ByteWidth, ")."); + LOG_ERROR_MESSAGE("Error binding buffer view '", ViewDesc.Name, "' of buffer '", BuffDesc.Name, "' to shader variable '", + Name, "' in shader '", ParentResLayout.GetShaderName(), "': static buffer size in the shader (", + BufferStaticSize, ") and array element stride (", BufferStride, ") are incompatible with the actual buffer size (", ViewDesc.ByteWidth, ")."); } } } diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index 53719439..edfa7625 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -1634,18 +1634,18 @@ VkBuildAccelerationStructureFlagsKHR BuildASFlagsToVkBuildAccelerationStructureF VkGeometryFlagsKHR GeometryFlagsToVkGeometryFlags(RAYTRACING_GEOMETRY_FLAGS Flags) { - static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION, + static_assert(RAYTRACING_GEOMETRY_FLAGS_LAST == RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION, "Please update the switch below to handle the new ray tracing geometry flag"); VkGeometryFlagsKHR Result = 0; - while (Flags != RAYTRACING_GEOMETRY_NONE) + while (Flags != RAYTRACING_GEOMETRY_FLAG_NONE) { auto FlagBit = static_cast(1 << PlatformMisc::GetLSB(Uint32{Flags})); switch (FlagBit) { // clang-format off - case RAYTRACING_GEOMETRY_OPAQUE: Result |= VK_GEOMETRY_OPAQUE_BIT_KHR; break; - case RAYTRACING_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR; break; + case RAYTRACING_GEOMETRY_FLAG_OPAQUE: Result |= VK_GEOMETRY_OPAQUE_BIT_KHR; break; + case RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION: Result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR; break; // clang-format on default: UNEXPECTED("unknown geometry flag"); } -- cgit v1.2.3