mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #672 from delroth/vertex-loader
Vertex loader: reduce dependency on global state
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/TextureCacheBase.h"
|
||||
#include "VideoCommon/VertexLoader.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
@ -136,6 +136,7 @@ static const float LINE_PT_TEX_OFFSETS[8] = {
|
||||
|
||||
void VertexManager::Draw(UINT stride)
|
||||
{
|
||||
u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components;
|
||||
D3D::context->IASetVertexBuffers(0, 1, &m_vertex_buffers[m_current_vertex_buffer], &stride, &m_vertex_draw_offset);
|
||||
D3D::context->IASetIndexBuffer(m_index_buffers[m_current_index_buffer], DXGI_FORMAT_R16_UINT, 0);
|
||||
|
||||
@ -157,7 +158,7 @@ void VertexManager::Draw(UINT stride)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
texOffsetEnable[i] = bpmem.texcoords[i].s.line_offset;
|
||||
|
||||
if (m_lineShader.SetShader(g_nativeVertexFmt->m_components, lineWidth,
|
||||
if (m_lineShader.SetShader(components, lineWidth,
|
||||
texOffset, vpWidth, vpHeight, texOffsetEnable))
|
||||
{
|
||||
((DX11::Renderer*)g_renderer)->ApplyCullDisable(); // Disable culling for lines and points
|
||||
@ -181,7 +182,7 @@ void VertexManager::Draw(UINT stride)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
texOffsetEnable[i] = bpmem.texcoords[i].s.point_offset;
|
||||
|
||||
if (m_pointShader.SetShader(g_nativeVertexFmt->m_components, pointSize,
|
||||
if (m_pointShader.SetShader(components, pointSize,
|
||||
texOffset, vpWidth, vpHeight, texOffsetEnable))
|
||||
{
|
||||
((DX11::Renderer*)g_renderer)->ApplyCullDisable(); // Disable culling for lines and points
|
||||
@ -197,21 +198,21 @@ void VertexManager::Draw(UINT stride)
|
||||
|
||||
void VertexManager::vFlush(bool useDstAlpha)
|
||||
{
|
||||
u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components;
|
||||
if (!PixelShaderCache::SetShader(
|
||||
useDstAlpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE,
|
||||
g_nativeVertexFmt->m_components))
|
||||
useDstAlpha ? DSTALPHA_DUAL_SOURCE_BLEND : DSTALPHA_NONE, components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
return;
|
||||
}
|
||||
if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components))
|
||||
if (!VertexShaderCache::SetShader(components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
|
||||
return;
|
||||
}
|
||||
PrepareDrawBuffers();
|
||||
unsigned int stride = g_nativeVertexFmt->GetVertexStride();
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
unsigned int stride = VertexLoaderManager::GetCurrentVertexFormat()->GetVertexStride();
|
||||
VertexLoaderManager::GetCurrentVertexFormat()->SetupVertexPointers();
|
||||
g_renderer->ApplyState(useDstAlpha);
|
||||
|
||||
Draw(stride);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/PixelShaderManager.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/VertexLoader.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
@ -126,7 +126,7 @@ void VertexManager::Draw(u32 stride)
|
||||
|
||||
void VertexManager::vFlush(bool useDstAlpha)
|
||||
{
|
||||
GLVertexFormat *nativeVertexFmt = (GLVertexFormat*)g_nativeVertexFmt;
|
||||
GLVertexFormat *nativeVertexFmt = (GLVertexFormat*)VertexLoaderManager::GetCurrentVertexFormat();
|
||||
u32 stride = nativeVertexFmt->GetVertexStride();
|
||||
|
||||
if (m_last_vao != nativeVertexFmt->VAO) {
|
||||
@ -144,18 +144,18 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// the same pass as regular rendering.
|
||||
if (useDstAlpha && dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, g_nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, nativeVertexFmt->m_components);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE, nativeVertexFmt->m_components);
|
||||
}
|
||||
|
||||
// upload global constants
|
||||
ProgramShaderCache::UploadConstants();
|
||||
|
||||
// setup the pointers
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
nativeVertexFmt->SetupVertexPointers();
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
Draw(stride);
|
||||
@ -163,7 +163,7 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// run through vertex groups again to set alpha
|
||||
if (useDstAlpha && !dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS,g_nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, nativeVertexFmt->m_components);
|
||||
|
||||
// only update alpha
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
|
Reference in New Issue
Block a user