summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/VertexManager.cpp
diff options
context:
space:
mode:
authorDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-12-11 23:38:35 +0100
committerDolphin Bot <dolphin-emu-bot@users.noreply.github.com>2014-12-11 23:38:35 +0100
commit971a95aecef1c4fc3e5aa8799a296d2734526cfc (patch)
tree0b1d3a4f8bdd82f276f490c08c4854dedd553fa9 /Source/Core/VideoBackends/D3D/VertexManager.cpp
parentfe6723066355788a8877f484a8711524a80430e7 (diff)
parente90604c5ed4e78780cb56bf969cc80eec57c0199 (diff)
Merge pull request #1503 from kayru/d3d_optimization_cache
D3D: Filter redundant API calls by caching state in StateManager
Diffstat (limited to 'Source/Core/VideoBackends/D3D/VertexManager.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/VertexManager.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/Source/Core/VideoBackends/D3D/VertexManager.cpp b/Source/Core/VideoBackends/D3D/VertexManager.cpp
index 9e1b5ea17f..7ab4f950bc 100644
--- a/Source/Core/VideoBackends/D3D/VertexManager.cpp
+++ b/Source/Core/VideoBackends/D3D/VertexManager.cpp
@@ -4,6 +4,7 @@
#include "VideoBackends/D3D/BoundingBox.h"
#include "VideoBackends/D3D/D3DBase.h"
+#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3D/PixelShaderCache.h"
#include "VideoBackends/D3D/Render.h"
#include "VideoBackends/D3D/VertexManager.h"
@@ -129,17 +130,19 @@ void VertexManager::Draw(u32 stride)
u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components;
u32 indices = IndexGenerator::GetIndexLen();
- u32 zero = 0;
- D3D::context->IASetVertexBuffers(0, 1, &m_buffers[m_currentBuffer], &stride, &zero);
- D3D::context->IASetIndexBuffer(m_buffers[m_currentBuffer], DXGI_FORMAT_R16_UINT, 0);
+ D3D::stateman->SetVertexBuffer(m_buffers[m_currentBuffer], stride, 0);
+ D3D::stateman->SetIndexBuffer(m_buffers[m_currentBuffer]);
u32 baseVertex = m_vertexDrawOffset / stride;
u32 startIndex = m_indexDrawOffset / sizeof(u16);
if (current_primitive_type == PRIMITIVE_TRIANGLES)
{
- D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+
+ D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
+
INCSTAT(stats.thisFrame.numDrawCalls);
}
else if (current_primitive_type == PRIMITIVE_LINES)
@@ -157,13 +160,14 @@ void VertexManager::Draw(u32 stride)
if (m_lineShader.SetShader(components, lineWidth,
texOffset, vpWidth, vpHeight, texOffsetEnable))
{
- ((DX11::Renderer*)g_renderer)->ApplyCullDisable(); // Disable culling for lines and points
- D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
+ D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
+
+ D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
+
INCSTAT(stats.thisFrame.numDrawCalls);
- D3D::context->GSSetShader(nullptr, nullptr, 0);
- ((DX11::Renderer*)g_renderer)->RestoreCull();
+ D3D::stateman->SetGeometryShader(nullptr);
}
}
else //if (current_primitive_type == PRIMITIVE_POINTS)
@@ -181,13 +185,14 @@ void VertexManager::Draw(u32 stride)
if (m_pointShader.SetShader(components, pointSize,
texOffset, vpWidth, vpHeight, texOffsetEnable))
{
- ((DX11::Renderer*)g_renderer)->ApplyCullDisable(); // Disable culling for lines and points
- D3D::context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
+ D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
+
+ D3D::stateman->Apply();
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
+
INCSTAT(stats.thisFrame.numDrawCalls);
- D3D::context->GSSetShader(nullptr, nullptr, 0);
- ((DX11::Renderer*)g_renderer)->RestoreCull();
+ D3D::stateman->SetGeometryShader(nullptr);
}
}
}