D3D: Set the geometry shader before every draw call.

And refactor the VertexManager draw call.
This commit is contained in:
Jules Blok 2014-12-17 03:05:23 +01:00
parent 7e8f96f0d3
commit 3d9dfad6a2
5 changed files with 22 additions and 39 deletions

View File

@ -350,6 +350,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
D3D::stateman->SetPixelShader(m_pshader);
D3D::stateman->SetVertexShader(m_vshader);
D3D::stateman->SetGeometryShader(nullptr);
D3D::stateman->SetInputLayout(m_InputLayout);
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

View File

@ -1084,6 +1084,7 @@ size_t PSTextureEncoder::Encode(u8* dst, unsigned int dstFormat,
#endif
{
D3D::stateman->SetVertexShader(m_vShader);
D3D::stateman->SetGeometryShader(nullptr);
D3D::stateman->PushBlendState(m_efbEncodeBlendState);
D3D::stateman->PushDepthState(m_efbEncodeDepthState);

View File

@ -1105,13 +1105,14 @@ void Renderer::ApplyState(bool bUseDstAlpha)
}
ID3D11Buffer* vertexConstants = VertexShaderCache::GetConstantBuffer();
ID3D11Buffer* pixelConstants = PixelShaderCache::GetConstantBuffer();
D3D::stateman->SetPixelConstants(pixelConstants, g_ActiveConfig.bEnablePixelLighting ? vertexConstants : nullptr);
D3D::stateman->SetPixelConstants(PixelShaderCache::GetConstantBuffer(), g_ActiveConfig.bEnablePixelLighting ? vertexConstants : nullptr);
D3D::stateman->SetVertexConstants(vertexConstants);
D3D::stateman->SetGeometryConstants(GeometryShaderCache::GetConstantBuffer());
D3D::stateman->SetPixelShader(PixelShaderCache::GetActiveShader());
D3D::stateman->SetVertexShader(VertexShaderCache::GetActiveShader());
D3D::stateman->SetGeometryShader(GeometryShaderCache::GetActiveShader());
}
void Renderer::RestoreState()

View File

@ -126,49 +126,28 @@ void VertexManager::Draw(u32 stride)
u32 baseVertex = m_vertexDrawOffset / stride;
u32 startIndex = m_indexDrawOffset / sizeof(u16);
if (current_primitive_type == PRIMITIVE_TRIANGLES)
switch (current_primitive_type)
{
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
D3D::stateman->SetGeometryConstants(GeometryShaderCache::GetConstantBuffer());
D3D::stateman->SetGeometryShader(GeometryShaderCache::GetActiveShader());
D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
INCSTAT(stats.thisFrame.numDrawCalls);
D3D::stateman->SetGeometryShader(nullptr);
}
else if (current_primitive_type == PRIMITIVE_LINES)
{
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
D3D::stateman->SetGeometryConstants(GeometryShaderCache::GetConstantBuffer());
D3D::stateman->SetGeometryShader(GeometryShaderCache::GetActiveShader());
D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
INCSTAT(stats.thisFrame.numDrawCalls);
D3D::stateman->SetGeometryShader(nullptr);
((DX11::Renderer*)g_renderer)->RestoreCull();
}
else //if (current_primitive_type == PRIMITIVE_POINTS)
{
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
case PRIMITIVE_POINTS:
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
D3D::stateman->SetGeometryConstants(GeometryShaderCache::GetConstantBuffer());
D3D::stateman->SetGeometryShader(GeometryShaderCache::GetActiveShader());
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
break;
case PRIMITIVE_LINES:
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
break;
case PRIMITIVE_TRIANGLES:
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
break;
}
D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
INCSTAT(stats.thisFrame.numDrawCalls);
D3D::stateman->SetGeometryShader(nullptr);
if (current_primitive_type != PRIMITIVE_TRIANGLES)
((DX11::Renderer*)g_renderer)->RestoreCull();
}
}
void VertexManager::vFlush(bool useDstAlpha)

View File

@ -282,6 +282,7 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
D3D::stateman->SetPixelShader(m_pShader);
D3D::stateman->SetVertexShader(m_vShader);
D3D::stateman->SetGeometryShader(nullptr);
D3D::stateman->PushBlendState(m_xfbEncodeBlendState);
D3D::stateman->PushDepthState(m_xfbEncodeDepthState);