diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp index d21b576eef..237e7020c5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp @@ -23,6 +23,7 @@ #include +#include "ImageWrite.h" #include "Common.h" #include "Render.h" #include "VertexShader.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index 7d6cce7a0d..b0f1583613 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -118,7 +118,7 @@ VertexLoader g_VertexLoaders[8]; VertexLoader::VertexLoader() { - m_numPipelineStates = 0; + m_numPipelineStages = 0; m_VertexSize = 0; m_AttrDirty = 1; VertexLoader_Normal::Init(); @@ -275,7 +275,8 @@ void VertexLoader::ProcessFormat() if (!m_AttrDirty) { - if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 && (m_VtxDesc.Hex1&1)==(VertexManager::GetVtxDesc().Hex1&1)) + // Check if local cached desc (in this VL) matches global desc + if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 && (m_VtxDesc.Hex1 & 1)==(VertexManager::GetVtxDesc().Hex1 & 1)) return; // same } else @@ -287,14 +288,14 @@ void VertexLoader::ProcessFormat() // Reset pipeline m_VBStridePad = 0; m_VBVertexStride = 0; - m_numPipelineStates = 0; + m_numPipelineStages = 0; m_components = 0; - // m_VBVertexStride for texmtx and posmtx is computed later when writing + // m_VBVertexStride for texmtx and posmtx is computed later when writing. // Position Matrix Index if (m_VtxDesc.PosMatIdx) { - m_PipelineStates[m_numPipelineStates++] = PosMtx_ReadDirect_UByte; + m_PipelineStages[m_numPipelineStages++] = PosMtx_ReadDirect_UByte; m_components |= VB_HAS_POSMTXIDX; } @@ -565,7 +566,8 @@ void VertexLoader::PrepareRun() void VertexLoader::SetupColor(int num, int mode, int format, int elements) { // if COL0 not present, then embed COL1 into COL0 - if (num == 1 && !(m_components & VB_HAS_COL0) ) num = 0; + if (num == 1 && !(m_components & VB_HAS_COL0)) + num = 0; m_components |= VB_HAS_COL0 << num; switch (mode) @@ -659,7 +661,7 @@ void VertexLoader::SetupTexCoord(int num, int mode, int format, int elements, in void VertexLoader::WriteCall(void (LOADERDECL *func)(void *)) { - m_PipelineStates[m_numPipelineStates++] = func; + m_PipelineStages[m_numPipelineStages++] = func; } void VertexLoader::RunVertices(int primitive, int count) @@ -759,8 +761,8 @@ void VertexLoader::RunVertices(int primitive, int count) tcIndex = 0; colIndex = 0; s_texmtxwrite = s_texmtxread = 0; - for (int i = 0; i < m_numPipelineStates; i++) - m_PipelineStates[i](&m_VtxAttr); + for (int i = 0; i < m_numPipelineStages; i++) + m_PipelineStages[i](&m_VtxAttr); VertexManager::s_pCurBufferPointer += m_VBStridePad; PRIM_LOG("\n"); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h index 6e2ca14931..3c9e906d36 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.h @@ -18,8 +18,6 @@ #ifndef _VERTEXLOADER_H #define _VERTEXLOADER_H -#include - #define SHADER_POSMTX_ATTRIB 1 #define SHADER_NORM1_ATTRIB 6 #define SHADER_NORM2_ATTRIB 7 @@ -67,6 +65,7 @@ enum { // There are 8 of these. Most games only use the first, and just reconfigure it all the time // as needed, unfortunately. +// TODO - clarify the role of this class. It seems to have taken on some irrelevant stuff. class VertexLoader { public: @@ -77,26 +76,25 @@ public: NRM_THREE = 3 }; - private: - TPipelineFunction m_PipelineStates[32]; - int m_numPipelineStates; - int m_VertexSize; // number of bytes of a raw vertex - int m_counter; - int m_VBVertexStride, m_VBStridePad; // stride of a vertex to send to the GPU + TPipelineFunction m_PipelineStages[32]; + int m_numPipelineStages; - u32 m_components; // VB_HAS_X + int m_VertexSize; // number of bytes of a raw GC vertex + int m_VBVertexStride; // PC-side vertex stride + int m_VBStridePad; + u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present. + + // Raw VAttr UVAT_group0 m_group0; UVAT_group1 m_group1; UVAT_group2 m_group2; - - vector m_vtexmap; // tex index map - TVtxAttr m_VtxAttr; //Decoded into easy format + TVtxAttr m_VtxAttr; // Decoded into easy format u8* m_compiledCode; - //common for all loaders + // Common for all loaders (? then why is it here?) TVtxDesc m_VtxDesc; void SetupColor(int num, int _iMode, int _iFormat, int _iElements); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index 5dc13fd79a..3a21dc7f39 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -1,5 +1,7 @@ #include "Globals.h" +#include + #include "MemoryUtil.h" #include "Profiler.h" #include "Render.h" @@ -369,4 +371,4 @@ void VertexManager::EnableComponents(u32 components) s_prevcomponents = components; } -} \ No newline at end of file +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.h index c801066107..0a3ed4fb40 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.h @@ -21,6 +21,9 @@ #include "CPMemory.h" + +// TODO - clarify the role of this class. + // Methods to manage and cache the global state of vertex streams and flushing streams // Also handles processing the CP registers class VertexManager diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp index 9b905a7680..606ed46b8b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp @@ -25,6 +25,7 @@ #include +#include "ImageWrite.h" #include "Render.h" #include "VertexShader.h" #include "VertexShaderManager.h" @@ -111,7 +112,7 @@ VERTEXSHADER* VertexShaderMngr::GetShader(u32 components) char *code = GenerateVertexShader(components, Renderer::GetZBufferTarget() != 0); #if defined(_DEBUG) || defined(DEBUGFAST) - if( g_Config.iLog & CONF_SAVESHADERS && code ) { + if (g_Config.iLog & CONF_SAVESHADERS && code) { static int counter = 0; char szTemp[MAX_PATH]; sprintf(szTemp, "%s/vs_%04i.txt", g_Config.texDumpPath, counter++);