From ee5021d94d8abe6cc57d37c6c07027495275ca45 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 20 Nov 2024 18:28:47 +0100 Subject: [PATCH] Fix regression bugs from 471d5c2a9b033618c7df33fbd988aa3ce64eb0f0 --- .../DirectX/DX11/GPUContextDX11.cpp | 15 ++++++++------- .../GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp | 10 +++++----- .../GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp index 2950abcf8..029012fa8 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp @@ -23,18 +23,18 @@ ID3D11ShaderResourceView* EmptySRHandles[GPU_MAX_SR_BINDED] = {}; // Ensure to match the indirect commands arguments layout static_assert(sizeof(GPUDispatchIndirectArgs) == sizeof(uint32) * 3, "Wrong size of GPUDrawIndirectArgs."); static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountX) == sizeof(uint32) * 0, "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountX"); -static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountY) == sizeof(uint32) * 1,"Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountY"); +static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountY) == sizeof(uint32) * 1, "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountY"); static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountZ) == sizeof(uint32) * 2, "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountZ"); // static_assert(sizeof(GPUDrawIndirectArgs) == sizeof(D3D11_DRAW_INSTANCED_INDIRECT_ARGS), "Wrong size of GPUDrawIndirectArgs."); static_assert(OFFSET_OF(GPUDrawIndirectArgs, VerticesCount) == OFFSET_OF(D3D11_DRAW_INSTANCED_INDIRECT_ARGS, VertexCountPerInstance), "Wrong offset for GPUDrawIndirectArgs::VerticesCount"); -static_assert(OFFSET_OF(GPUDrawIndirectArgs, InstanceCount) == OFFSET_OF(D3D11_DRAW_INSTANCED_INDIRECT_ARGS, InstanceCount),"Wrong offset for GPUDrawIndirectArgs::InstanceCount"); +static_assert(OFFSET_OF(GPUDrawIndirectArgs, InstanceCount) == OFFSET_OF(D3D11_DRAW_INSTANCED_INDIRECT_ARGS, InstanceCount), "Wrong offset for GPUDrawIndirectArgs::InstanceCount"); static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartVertex) == OFFSET_OF(D3D11_DRAW_INSTANCED_INDIRECT_ARGS, StartVertexLocation), "Wrong offset for GPUDrawIndirectArgs::StartVertex"); static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartInstance) == OFFSET_OF(D3D11_DRAW_INSTANCED_INDIRECT_ARGS, StartInstanceLocation), "Wrong offset for GPUDrawIndirectArgs::StartInstance"); // static_assert(sizeof(GPUDrawIndexedIndirectArgs) == sizeof(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS), "Wrong size of GPUDrawIndexedIndirectArgs."); static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, IndicesCount) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, IndexCountPerInstance), "Wrong offset for GPUDrawIndexedIndirectArgs::IndicesCount"); -static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, InstanceCount) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, InstanceCount),"Wrong offset for GPUDrawIndexedIndirectArgs::InstanceCount"); +static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, InstanceCount) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, InstanceCount), "Wrong offset for GPUDrawIndexedIndirectArgs::InstanceCount"); static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartIndex) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, StartIndexLocation), "Wrong offset for GPUDrawIndexedIndirectArgs::StartIndex"); static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartVertex) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, BaseVertexLocation), "Wrong offset for GPUDrawIndexedIndirectArgs::StartVertex"); static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartInstance) == OFFSET_OF(D3D11_DRAW_INDEXED_INSTANCED_INDIRECT_ARGS, StartInstanceLocation), "Wrong offset for GPUDrawIndexedIndirectArgs::StartInstance"); @@ -564,6 +564,7 @@ void GPUContextDX11::SetState(GPUPipelineState* state) ASSERT(_currentState->IsValid()); blendState = _currentState->BlendState; rasterizerState = _device->RasterizerStates[_currentState->RasterizerStateIndex]; + //depthStencilState = _device->DepthStencilStates2[_currentState->DepthStencilStateIndex]; depthStencilState = _currentState->DepthStencilState; ASSERT(_currentState->VS != nullptr); vs = _currentState->VS; @@ -854,13 +855,13 @@ void GPUContextDX11::flushSRVs() { _srMaskDirtyGraphics = 0; FLUSH_STAGE(VS); - #if GPU_ALLOW_TESSELLATION_SHADERS +#if GPU_ALLOW_TESSELLATION_SHADERS FLUSH_STAGE(HS); FLUSH_STAGE(DS); - #endif - #if GPU_ALLOW_GEOMETRY_SHADERS +#endif +#if GPU_ALLOW_GEOMETRY_SHADERS FLUSH_STAGE(GS); - #endif +#endif FLUSH_STAGE(PS); } } diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp index 24257596b..c67904865 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp @@ -332,9 +332,9 @@ ID3D11DepthStencilState* GPUDeviceDX11::GetDepthStencilState(const void* descrip // Prepare description D3D11_DEPTH_STENCIL_DESC desc; - desc.DepthEnable = !!description.DepthEnable; - desc.DepthWriteMask = description.DepthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; - desc.DepthFunc = ToDX11(description.DepthFunc); + desc.DepthEnable = !!description.DepthEnable; + desc.DepthWriteMask = description.DepthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; + desc.DepthFunc = ToDX11(description.DepthFunc); desc.StencilEnable = !!description.StencilEnable; desc.StencilReadMask = description.StencilReadMask; desc.StencilWriteMask = description.StencilWriteMask; @@ -417,9 +417,9 @@ bool GPUDeviceDX11::Init() #if PLATFORM_WINDOWS // Detect RenderDoc usage (UUID {A7AA6116-9C8D-4BBA-9083-B4D816B71B78}) IUnknown* unknown = nullptr; - const GUID uuidRenderDoc = { 0xa7aa6116, 0x9c8d, 0x4bba, {0x90, 0x83, 0xb4, 0xd8, 0x16, 0xb7, 0x1b, 0x78}}; + const GUID uuidRenderDoc = { 0xa7aa6116, 0x9c8d, 0x4bba, { 0x90, 0x83, 0xb4, 0xd8, 0x16, 0xb7, 0x1b, 0x78 } }; HRESULT hr = _device->QueryInterface(uuidRenderDoc, (void**)&unknown); - if(SUCCEEDED(hr) && unknown) + if (SUCCEEDED(hr) && unknown) { IsDebugToolAttached = true; unknown->Release(); diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h index df4bbfabf..ffe1688f1 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h @@ -40,7 +40,7 @@ private: bool operator==(const DepthStencilMode& other) const { - return Platform::MemoryCompare(this, &other, sizeof(DepthStencilMode)); + return Platform::MemoryCompare(this, &other, sizeof(DepthStencilMode)) == 0; } friend uint32 GetHash(const DepthStencilMode& key)