diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index e2d990e87c..b51eaf57f0 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -1276,6 +1276,27 @@ void Renderer::RestoreState() D3D::stateman->PopRasterizerState(); } +void Renderer::ApplyCullDisable() +{ + D3D11_RASTERIZER_DESC rastDesc = gx_state.rastdc; + rastDesc.CullMode = D3D11_CULL_NONE; + + ID3D11RasterizerState* raststate; + HRESULT hr = D3D::device->CreateRasterizerState(&rastDesc, &raststate); + if (FAILED(hr)) PanicAlert("Failed to create culling-disabled rasterizer state at %s %d\n", __FILE__, __LINE__); + D3D::SetDebugObjectName((ID3D11DeviceChild*)raststate, "rasterizer state (culling disabled) used to emulate the GX pipeline"); + + D3D::stateman->PushRasterizerState(raststate); + SAFE_RELEASE(raststate); + + D3D::stateman->Apply(); +} + +void Renderer::RestoreCull() +{ + D3D::stateman->PopRasterizerState(); +} + void Renderer::SetGenerationMode() { // rastdc.FrontCounterClockwise must be false for this to work diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.h b/Source/Plugins/Plugin_VideoDX11/Src/Render.h index 44631736fc..2394e87efe 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.h @@ -28,6 +28,9 @@ public: void ApplyState(bool bUseDstAlpha); void RestoreState(); + void ApplyCullDisable(); + void RestoreCull(); + void RenderText(const char* pstr, int left, int top, u32 color); u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp index 67171e4b49..c6fada7d20 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp @@ -26,6 +26,7 @@ #include "MainBase.h" #include "PixelShaderManager.h" #include "RenderBase.h" +#include "Render.h" #include "Statistics.h" #include "TextureCacheBase.h" #include "VertexShaderManager.h" @@ -147,6 +148,9 @@ void VertexManager::Draw(UINT stride) D3D::context->DrawIndexed(IndexGenerator::GetTriangleindexLen(), m_triangleDrawIndex, 0); INCSTAT(stats.thisFrame.numIndexedDrawCalls); } + // Disable culling for lines and points + if (IndexGenerator::GetNumLines() > 0 || IndexGenerator::GetNumPoints() > 0) + ((DX11::Renderer*)g_renderer)->ApplyCullDisable(); if (IndexGenerator::GetNumLines() > 0) { float lineWidth = float(bpmem.lineptwidth.linesize) / 6.f; @@ -175,6 +179,8 @@ void VertexManager::Draw(UINT stride) D3D::context->GSSetShader(NULL, NULL, 0); } } + if (IndexGenerator::GetNumLines() > 0 || IndexGenerator::GetNumPoints() > 0) + ((DX11::Renderer*)g_renderer)->RestoreCull(); } void VertexManager::vFlush()