diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2014-12-18 19:43:12 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2014-12-18 19:43:12 -0600 |
| commit | 02f22152bedc292101d15fb89856fa89b861bfde (patch) | |
| tree | 76e963ec8fb61c74c672f95cc6a4a2713211501a /Source/Core/VideoBackends/D3D/VertexManager.cpp | |
| parent | c7b809d46b466cabac296d1891f3f5e96cf499a0 (diff) | |
| parent | e7e8a4f1cb3d1c7801c18f4d3ff5cae797d5f5b3 (diff) | |
Merge pull request #1706 from Armada651/line-width
VideoCommon: Merge LineGeometryShader into GeometryShaderGen.
Diffstat (limited to 'Source/Core/VideoBackends/D3D/VertexManager.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/VertexManager.cpp | 93 |
1 files changed, 19 insertions, 74 deletions
diff --git a/Source/Core/VideoBackends/D3D/VertexManager.cpp b/Source/Core/VideoBackends/D3D/VertexManager.cpp index abc7f18e33..5a15ca2a0b 100644 --- a/Source/Core/VideoBackends/D3D/VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D/VertexManager.cpp @@ -12,7 +12,6 @@ #include "VideoBackends/D3D/VertexShaderCache.h" #include "VideoCommon/BoundingBox.h" -#include "VideoCommon/BPMemory.h" #include "VideoCommon/Debugger.h" #include "VideoCommon/IndexGenerator.h" #include "VideoCommon/MainBase.h" @@ -49,16 +48,10 @@ void VertexManager::CreateDeviceObjects() m_currentBuffer = 0; m_bufferCursor = MAX_BUFFER_SIZE; - - m_lineShader.Init(); - m_pointShader.Init(); } void VertexManager::DestroyDeviceObjects() { - m_pointShader.Shutdown(); - m_lineShader.Shutdown(); - for (int i = 0; i < MAX_BUFFER_COUNT; i++) { SAFE_RELEASE(m_buffers[i]); @@ -122,10 +115,6 @@ void VertexManager::PrepareDrawBuffers(u32 stride) ADDSTAT(stats.thisFrame.bytesIndexStreamed, indexBufferSize); } -static const float LINE_PT_TEX_OFFSETS[8] = { - 0.f, 0.0625f, 0.125f, 0.25f, 0.5f, 1.f, 1.f, 1.f -}; - void VertexManager::Draw(u32 stride) { u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components; @@ -137,69 +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(VertexShaderCache::GetConstantBuffer()); - D3D::stateman->SetGeometryShader(g_ActiveConfig.iStereoMode > 0 ? GeometryShaderCache::GetActiveShader() : nullptr); - - D3D::stateman->Apply(); - D3D::context->DrawIndexed(indices, startIndex, baseVertex); - - INCSTAT(stats.thisFrame.numDrawCalls); - - D3D::stateman->SetGeometryShader(nullptr); - } - else if (current_primitive_type == PRIMITIVE_LINES) - { - float lineWidth = float(bpmem.lineptwidth.linesize) / 6.f; - float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.lineoff]; - float vpWidth = 2.0f * xfmem.viewport.wd; - float vpHeight = -2.0f * xfmem.viewport.ht; - - bool texOffsetEnable[8]; - - for (int i = 0; i < 8; ++i) - texOffsetEnable[i] = bpmem.texcoords[i].s.line_offset; - - if (m_lineShader.SetShader(components, lineWidth, - texOffset, vpWidth, vpHeight, texOffsetEnable)) - { + case PRIMITIVE_POINTS: + D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); + ((DX11::Renderer*)g_renderer)->ApplyCullDisable(); + break; + case PRIMITIVE_LINES: D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST); - - D3D::stateman->Apply(); - D3D::context->DrawIndexed(indices, startIndex, baseVertex); - - INCSTAT(stats.thisFrame.numDrawCalls); - - D3D::stateman->SetGeometryShader(nullptr); - } + ((DX11::Renderer*)g_renderer)->ApplyCullDisable(); + break; + case PRIMITIVE_TRIANGLES: + D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + break; } - else //if (current_primitive_type == PRIMITIVE_POINTS) - { - float pointSize = float(bpmem.lineptwidth.pointsize) / 6.f; - float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.pointoff]; - float vpWidth = 2.0f * xfmem.viewport.wd; - float vpHeight = -2.0f * xfmem.viewport.ht; - bool texOffsetEnable[8]; + D3D::stateman->Apply(); + D3D::context->DrawIndexed(indices, startIndex, baseVertex); - for (int i = 0; i < 8; ++i) - texOffsetEnable[i] = bpmem.texcoords[i].s.point_offset; + INCSTAT(stats.thisFrame.numDrawCalls); - if (m_pointShader.SetShader(components, pointSize, - texOffset, vpWidth, vpHeight, texOffsetEnable)) - { - D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); - - 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) @@ -219,13 +167,10 @@ void VertexManager::vFlush(bool useDstAlpha) return; } - if (g_ActiveConfig.iStereoMode > 0) + if (!GeometryShaderCache::SetShader(current_primitive_type)) { - if (!GeometryShaderCache::SetShader(components)) - { - GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); }); - return; - } + GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); }); + return; } if (g_ActiveConfig.backend_info.bSupportsBBox && BoundingBox::active) |
