diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-09-10 04:47:03 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-09-10 04:47:03 +0000 |
| commit | 02742f2efe4d400dc3562730badb5ea13aaa0876 (patch) | |
| tree | fc41669e1583c22af650cff12746a9f3347bb50c /Graphics | |
| parent | Fixed merge conflicts (diff) | |
| download | DiligentCore-02742f2efe4d400dc3562730badb5ea13aaa0876.tar.gz DiligentCore-02742f2efe4d400dc3562730badb5ea13aaa0876.zip | |
Another set of minor updates to mesh shader implementation
Diffstat (limited to 'Graphics')
15 files changed, 33 insertions, 31 deletions
diff --git a/Graphics/GLSLTools/CMakeLists.txt b/Graphics/GLSLTools/CMakeLists.txt index 4cc1ecf9..e6977dc8 100644 --- a/Graphics/GLSLTools/CMakeLists.txt +++ b/Graphics/GLSLTools/CMakeLists.txt @@ -81,13 +81,6 @@ if(VULKAN_SUPPORTED) endif() endif() -if(NOT ${DILIGENT_NO_GLSLANG}) - target_include_directories(Diligent-GLSLTools - PRIVATE - ${spirv-tools_BINARY_DIR} - ../../ThirdParty/SPIRV-Tools) -endif() - set_common_target_properties(Diligent-GLSLTools) source_group("src" FILES ${SOURCE}) diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 76018d04..2ba5d90a 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -150,6 +150,7 @@ ShaderResourceDesc SPIRVShaderResourceAttribs::GetResourceDesc() const static spv::ExecutionModel ShaderTypeToExecutionModel(SHADER_TYPE ShaderType) { + static_assert(SHADER_TYPE_LAST == 0x080, "Please handle the new shader type in the switch below"); switch (ShaderType) { // clang-format off @@ -161,8 +162,7 @@ static spv::ExecutionModel ShaderTypeToExecutionModel(SHADER_TYPE ShaderType) case SHADER_TYPE_COMPUTE: return spv::ExecutionModelGLCompute; case SHADER_TYPE_AMPLIFICATION: return spv::ExecutionModelTaskNV; case SHADER_TYPE_MESH: return spv::ExecutionModelMeshNV; - // clang-format on - + // clang-format on default: UNEXPECTED("Unexpected shader type"); return spv::ExecutionModelVertex; diff --git a/Graphics/GLSLTools/src/SPIRVUtils.cpp b/Graphics/GLSLTools/src/SPIRVUtils.cpp index 5ae9d3a1..6543d4fb 100644 --- a/Graphics/GLSLTools/src/SPIRVUtils.cpp +++ b/Graphics/GLSLTools/src/SPIRVUtils.cpp @@ -69,6 +69,7 @@ void FinalizeGlslang() EShLanguage ShaderTypeToShLanguage(SHADER_TYPE ShaderType) { + static_assert(SHADER_TYPE_LAST == 0x080, "Please handle the new shader type in the switch below"); switch (ShaderType) { // clang-format off diff --git a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp index 7979cfbb..68a17d8c 100644 --- a/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp +++ b/Graphics/GraphicsAccessories/src/GraphicsAccessories.cpp @@ -474,7 +474,7 @@ const Char* GetBufferViewTypeLiteralName(BUFFER_VIEW_TYPE ViewType) const Char* GetShaderTypeLiteralName(SHADER_TYPE ShaderType) { - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_MESH, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x080, "Please handle the new shader type in the switch below"); switch (ShaderType) { // clang-format off diff --git a/Graphics/GraphicsEngine/include/ShaderBase.hpp b/Graphics/GraphicsEngine/include/ShaderBase.hpp index 17dec618..5b39da79 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBase.hpp @@ -54,7 +54,7 @@ inline Int32 GetShaderTypeIndex(SHADER_TYPE Type) Int32 ShaderIndex = PlatformMisc::GetLSB(Type); #ifdef DILIGENT_DEBUG - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_MESH, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x080, "Please update the switch below to handle the new shader type"); switch (Type) { // clang-format off diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 18e53478..272c2cd5 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -1089,7 +1089,7 @@ DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject) /// Uint32 TaskCount; /// Uint32 FirstTask; /// - /// \remarks For compatibility between Direct3D12 and Vulkan and with direct call (DrawMesh) use define the first element in the structure, + /// \remarks For compatibility between Direct3D12 and Vulkan and with direct call (DrawMesh) use the first element in the structure, /// for example: Direct3D12 {TaskCount, 1, 1}, Vulkan {TaskCount, 0}. /// /// \remarks If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 40ac9671..323a3fd1 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1743,10 +1743,10 @@ typedef struct VulkanDescriptorPoolSize VulkanDescriptorPoolSize; struct EngineVkCreateInfo DILIGENT_DERIVE(EngineCreateInfo) /// Id of the hardware adapter the engine should be initialized on. - Uint32 AdapterId DEFAULT_INITIALIZER(DEFAULT_ADAPTER_ID); + Uint32 AdapterId DEFAULT_INITIALIZER(DEFAULT_ADAPTER_ID); /// Enable Vulkan validation layers. - bool EnableValidation DEFAULT_INITIALIZER(false); + bool EnableValidation DEFAULT_INITIALIZER(false); /// Number of global Vulkan extensions Uint32 GlobalExtensionCount DEFAULT_INITIALIZER(0); diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 7fe2fbb6..9491168d 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -166,10 +166,10 @@ struct GraphicsPipelineDesc /// Geometry shader to be used with the pipeline. IShader* pGS DEFAULT_INITIALIZER(nullptr); - /// Amplification shader to be used with the pipeline + /// Amplification shader to be used with the pipeline. IShader* pAS DEFAULT_INITIALIZER(nullptr); - /// Mesh shader to be used with the pipeline + /// Mesh shader to be used with the pipeline. IShader* pMS DEFAULT_INITIALIZER(nullptr); //D3D12_STREAM_OUTPUT_DESC StreamOutput; diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index 7cffb0f1..d961b962 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -85,7 +85,7 @@ DILIGENT_TYPED_ENUM(SHADER_SOURCE_LANGUAGE, Uint32) /// Describes the shader compiler that will be used to compile the shader source code DILIGENT_TYPED_ENUM(SHADER_COMPILER, Uint32) { - /// Default compiler for specific language and API that is chosen as follows: + /// Default compiler for specific language and API that is selected as follows: /// - Direct3D11: legacy HLSL compiler (FXC) /// - Direct3D12: legacy HLSL compiler (FXC) /// - OpenGL(ES) GLSL: native compiler diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index a7d3c169..536a2df0 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -97,7 +97,7 @@ void DeviceContextD3D11Impl::SetPipelineState(IPipelineState* pPipelineState) COMMIT_SHADER(CS, ComputeShader); } - else + else if (Desc.PipelineType == PIPELINE_TYPE_GRAPHICS) { COMMIT_SHADER(VS, VertexShader); COMMIT_SHADER(PS, PixelShader); @@ -127,6 +127,10 @@ void DeviceContextD3D11Impl::SetPipelineState(IPipelineState* pPipelineState) m_pd3d11DeviceContext->IASetPrimitiveTopology(m_CommittedD3D11PrimTopology); } } + else + { + UNEXPECTED(GetPipelineTypeString(Desc.PipelineType), " pipelines '", Desc.Name, "' are not supported in OpenGL"); + } } // clang-format off diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp index 97d76fde..f0625c7b 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp @@ -65,7 +65,7 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pR } m_ShaderResourceLayoutHash = pCS->GetD3D11Resources()->GetHash(); } - else + else if (m_Desc.PipelineType == PIPELINE_TYPE_GRAPHICS) { #define INIT_SHADER(ShortName, ExpectedType) \ @@ -125,6 +125,10 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pR "Failed to create the Direct3D11 input layout"); } } + else + { + UNEXPECTED(GetPipelineTypeString(m_Desc.PipelineType), " pipelines are not supported by Direct3D11 backend"); + } m_pStaticResourceLayouts = ALLOCATE(GetRawAllocator(), "Raw memory for ShaderResourceLayoutD3D11", ShaderResourceLayoutD3D11, m_NumShaders); m_pStaticResourceCaches = ALLOCATE(GetRawAllocator(), "Raw memory for ShaderResourceCacheD3D11", ShaderResourceCacheD3D11, m_NumShaders); diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp index 3b6edc0e..0db57800 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderD3D11Impl.cpp @@ -41,8 +41,8 @@ static const ShaderVersion HLSLValidateShaderVersion(const ShaderVersion& Versio { ModelVer = MaxVersion; LOG_ERROR_MESSAGE("Shader model ", Uint32{Version.Major}, "_", Uint32{Version.Minor}, - " is not supported by this device. Maximum supported model: ", - MaxVersion.Major, "_", MaxVersion.Minor, ". Attempting to use ", MaxVersion.Major, "_", MaxVersion.Minor, '.'); + " is not supported by this device. Attempting to use the maximum supported model ", + Uint32{MaxVersion.Major}, "_", Uint32{MaxVersion.Minor}, '.'); } else { @@ -66,22 +66,22 @@ static const ShaderVersion GetD3D11ShaderModel(ID3D11Device* pd3d11Device, const case D3D_FEATURE_LEVEL_11_1: case D3D_FEATURE_LEVEL_11_0: return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ? - ShaderVersion(5, 0) : + ShaderVersion{5, 0} : HLSLValidateShaderVersion(HLSLVersion, {5, 0}); case D3D_FEATURE_LEVEL_10_1: return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ? - ShaderVersion(4, 1) : + ShaderVersion{4, 1} : HLSLValidateShaderVersion(HLSLVersion, {4, 1}); case D3D_FEATURE_LEVEL_10_0: return (HLSLVersion.Major == 0 && HLSLVersion.Minor == 0) ? - ShaderVersion(4, 0) : + ShaderVersion{4, 0} : HLSLValidateShaderVersion(HLSLVersion, {4, 0}); default: UNEXPECTED("Unexpected D3D feature level ", static_cast<Uint32>(d3dDeviceFeatureLevel)); - return ShaderVersion(4, 0); + return ShaderVersion{4, 0}; } } @@ -95,7 +95,7 @@ ShaderD3D11Impl::ShaderD3D11Impl(IReferenceCounters* pRefCounters, pRenderDeviceD3D11, ShaderCI.Desc }, - ShaderD3DBase{ShaderCI, GetD3D11ShaderModel(pRenderDeviceD3D11->GetD3D11Device(), ShaderCI.HLSLVersion), false} + ShaderD3DBase{ShaderCI, GetD3D11ShaderModel(pRenderDeviceD3D11->GetD3D11Device(), ShaderCI.HLSLVersion), nullptr} // clang-format on { auto* pDeviceD3D11 = pRenderDeviceD3D11->GetD3D11Device(); diff --git a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp index 743d7185..701128b8 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp @@ -42,7 +42,7 @@ namespace Diligent class FixedBlockMemoryAllocator; -/// Render pass implementation in OpenGL backend. +/// Framebuffer implementation in OpenGL backend. class FramebufferGLImpl final : public FramebufferBase<IFramebuffer, RenderDeviceGLImpl> { public: diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp index 13f2affe..65c948a4 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineLayout.cpp @@ -43,7 +43,7 @@ namespace Diligent static VkShaderStageFlagBits ShaderTypeToVkShaderStageFlagBit(SHADER_TYPE ShaderType) { - static_assert(SHADER_TYPE_LAST == SHADER_TYPE_MESH, "Please update the switch below to handle the new shader type"); + static_assert(SHADER_TYPE_LAST == 0x080, "Please update the switch below to handle the new shader type"); switch (ShaderType) { // clang-format off diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index b136487f..949086b8 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -345,11 +345,11 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* pRefCoun if (m_Desc.PipelineType == PIPELINE_TYPE_MESH) { - // Input assembly doesn't used during mesh pipeline creation, so topology may contain any value. - // Validation layers may generate warning if used point_list topology, so set another value. + // Input assembly is not used in the mesh pipeline, so topology may contain any value. + // Validation layers may generate a warning if point_list topology is used, so use MAX_ENUM value. InputAssemblyCI.topology = VK_PRIMITIVE_TOPOLOGY_MAX_ENUM; - // Vertex input state and tessellation state are ignored in mesh pipeline and shuld be null. + // Vertex input state and tessellation state are ignored in a mesh pipeline and should be null. PipelineCI.pVertexInputState = nullptr; PipelineCI.pTessellationState = nullptr; } |
