diff --git a/CMakeLists.txt b/CMakeLists.txt index f2143496ed..4776215820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1167,6 +1167,7 @@ set(GPU_D3D11 GPU/D3D11/FramebufferManagerD3D11.h GPU/D3D11/GPU_D3D11.cpp GPU/D3D11/GPU_D3D11.h + GPU/D3D11/StencilBufferD3D11.cpp GPU/D3D11/ShaderManagerD3D11.cpp GPU/D3D11/ShaderManagerD3D11.h GPU/D3D11/StateMappingD3D11.cpp diff --git a/GPU/D3D11/D3D11Util.cpp b/GPU/D3D11/D3D11Util.cpp index ca7e98be32..9a9f48b181 100644 --- a/GPU/D3D11/D3D11Util.cpp +++ b/GPU/D3D11/D3D11Util.cpp @@ -59,6 +59,10 @@ void StockObjectsD3D11::Create(ID3D11Device *device) { depth_desc.StencilWriteMask = 0xFF; depth_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; depth_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_REPLACE; + depth_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; + depth_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_REPLACE; + depth_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE; + depth_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_REPLACE; depth_desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; depth_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; device->CreateDepthStencilState(&depth_desc, &depthDisabledStencilWrite); diff --git a/GPU/D3D11/FramebufferManagerD3D11.cpp b/GPU/D3D11/FramebufferManagerD3D11.cpp index 2cb9ed711b..79f26e1b25 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.cpp +++ b/GPU/D3D11/FramebufferManagerD3D11.cpp @@ -119,6 +119,7 @@ FramebufferManagerD3D11::FramebufferManagerD3D11(Draw::DrawContext *draw) } FramebufferManagerD3D11::~FramebufferManagerD3D11() { + // Drawing cleanup if (pFramebufferVertexShader_) { pFramebufferVertexShader_->Release(); pFramebufferVertexShader_ = nullptr; @@ -131,10 +132,18 @@ FramebufferManagerD3D11::~FramebufferManagerD3D11() { if (drawPixelsTex_) { drawPixelsTex_->Release(); } + + // FBO cleanup for (auto it = tempFBOs_.begin(), end = tempFBOs_.end(); it != end; ++it) { delete it->second.fbo; } delete[] convBuf; + + // Stencil cleanup + for (int i = 0; i < 256; i++) { + if (stencilMaskStates_[i]) + stencilMaskStates_[i]->Release(); + } if (stencilUploadPS_) { stencilUploadPS_->Release(); } diff --git a/GPU/D3D11/FramebufferManagerD3D11.h b/GPU/D3D11/FramebufferManagerD3D11.h index f057f99b1a..a9cf0b91df 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.h +++ b/GPU/D3D11/FramebufferManagerD3D11.h @@ -120,6 +120,7 @@ private: ID3D11PixelShader *stencilUploadPS_; ID3D11VertexShader *stencilUploadVS_; ID3D11InputLayout *stencilUploadInputLayout_; + ID3D11DepthStencilState *stencilMaskStates_[256]{}; bool stencilUploadFailed_; TextureCacheD3D11 *textureCacheD3D11_; diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index fe54b64039..df1c60baba 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -1157,7 +1157,7 @@ void TextureCacheD3D11::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture & pixelData = (u32 *)map.pData; // We always end up at 8888. Other parts assume this. - assert(dstFmt == D3DFMT_A8R8G8B8); + assert(dstFmt == DXGI_FORMAT_R8G8B8A8_UNORM); bpp = sizeof(u32); decPitch = w * bpp; diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 5563f36453..c57058cec8 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -903,7 +903,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc) { return nullptr; } if (desc.uniformDesc) { - pipeline->dynamicUniformSize = desc.uniformDesc->uniformBufferSize; + pipeline->dynamicUniformSize = (int)desc.uniformDesc->uniformBufferSize; } return pipeline;