From 996bfb53528aeaaba532413bf1848a0ebc3b03f0 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 13 Dec 2019 10:03:15 -0800 Subject: Unit tests: capturing debug output; fixed minor issue with viewport in Vk backend. --- Graphics/GLSLTools/src/SPIRVUtils.cpp | 5 ++++- Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp | 12 ++++++------ Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp | 12 ++++++------ Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp | 12 ++++++------ Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 3 +++ Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 6 ++++++ 6 files changed, 31 insertions(+), 19 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GLSLTools/src/SPIRVUtils.cpp b/Graphics/GLSLTools/src/SPIRVUtils.cpp index 56e9b2b5..42eb2c87 100644 --- a/Graphics/GLSLTools/src/SPIRVUtils.cpp +++ b/Graphics/GLSLTools/src/SPIRVUtils.cpp @@ -489,7 +489,10 @@ std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob Shader.setStringsWithLengthsAndNames(ShaderStrings, ShaderStringLenghts, Names, 1); IncluderImpl Includer(Attribs.pShaderSourceStreamFactory); - auto SPIRV = CompileShaderInternal(Shader, messages, &Includer, SourceCode, SourceCodeLen, ppCompilerOutput); + + auto SPIRV = CompileShaderInternal(Shader, messages, &Includer, SourceCode, SourceCodeLen, ppCompilerOutput); + if (SPIRV.empty()) + return SPIRV; // SPIR-V bytecode generated from HLSL must be legalized to // turn it into a valid vulkan SPIR-V shader diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index 6ffb2731..161ab79c 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -99,12 +99,12 @@ void EngineFactoryD3D11Impl::CreateDeviceAndContextsD3D11(const EngineD3D11Creat IRenderDevice** ppDevice, IDeviceContext** ppContexts) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(ppDevice && ppContexts, "Null pointer provided"); if (!ppDevice || !ppContexts) return; @@ -205,12 +205,12 @@ void EngineFactoryD3D11Impl::AttachToD3D11Device(void* pd IRenderDevice** ppDevice, IDeviceContext** ppContexts) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(ppDevice && ppContexts, "Null pointer provided"); if (!ppDevice || !ppContexts) return; diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 545da3d3..0526f672 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -107,12 +107,12 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat IRenderDevice** ppDevice, IDeviceContext** ppContexts) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(ppDevice && ppContexts, "Null pointer provided"); if (!ppDevice || !ppContexts) return; @@ -314,12 +314,12 @@ void EngineFactoryD3D12Impl::AttachToD3D12Device(void* pd IRenderDevice** ppDevice, IDeviceContext** ppContexts) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(pd3d12NativeDevice && ppCommandQueues && ppDevice && ppContexts, "Null pointer provided"); if (!pd3d12NativeDevice || !ppCommandQueues || !ppDevice || !ppContexts) return; diff --git a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp index c5544ce3..14fbd670 100644 --- a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp @@ -109,12 +109,12 @@ void EngineFactoryOpenGLImpl::CreateDeviceAndSwapChainGL(const EngineGLCreateInf const SwapChainDesc& SCDesc, ISwapChain** ppSwapChain) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(ppDevice && ppImmediateContext && ppSwapChain, "Null pointer provided"); if (!ppDevice || !ppImmediateContext || !ppSwapChain) return; @@ -189,12 +189,12 @@ void EngineFactoryOpenGLImpl::AttachToActiveGLContext(const EngineGLCreateInfo& IRenderDevice** ppDevice, IDeviceContext** ppImmediateContext) { - if (EngineCI.APIVersion != DILIGENT_API_VERSION) - LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); - if (EngineCI.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineCI.DebugMessageCallback); + if (EngineCI.APIVersion != DILIGENT_API_VERSION) + LOG_ERROR_AND_THROW("Diligent Engine runtime (", EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); + VERIFY(ppDevice && ppImmediateContext, "Null pointer provided"); if (!ppDevice || !ppImmediateContext) return; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 86a4bce1..135b5844 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -994,6 +994,9 @@ void DeviceContextVkImpl::SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffse void DeviceContextVkImpl::CommitViewports() { + if (m_NumViewports == 0) + return; + VkViewport VkViewports[MaxViewports]; // Do not waste time initializing array to zero for (Uint32 vp = 0; vp < m_NumViewports; ++vp) { diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index 0debf7eb..18be491e 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -87,6 +87,9 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E IRenderDevice** ppDevice, IDeviceContext** ppContexts) { + if (_EngineCI.DebugMessageCallback != nullptr) + SetDebugMessageCallback(_EngineCI.DebugMessageCallback); + if (_EngineCI.APIVersion != DILIGENT_API_VERSION) LOG_ERROR_AND_THROW("Diligent Engine runtime (", _EngineCI.APIVersion, ") is not compatible with the client API version (", DILIGENT_API_VERSION, ")"); @@ -245,6 +248,9 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptr