From 358333b94b9344b2e5a8897f6e82da160a4c85a9 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Thu, 25 Dec 2008 21:44:56 +0000 Subject: [PATCH] and more boring moving and cleanup ... git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1661 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../VideoCommon}/Src/IndexGenerator.cpp | 1 - .../VideoCommon}/Src/IndexGenerator.h | 11 ++++- .../VideoCommon/Src/VertexLoaderManager.h | 6 +-- Source/Core/VideoCommon/VideoCommon.vcproj | 8 ++++ .../Plugin_VideoDX9/Plugin_VideoDX9.vcproj | 8 ---- .../Plugin_VideoDX9/Src/VertexManager.cpp | 46 +++++++++++-------- .../Plugin_VideoDX9/Src/VertexManager.h | 17 +------ .../Plugins/Plugin_VideoOGL/Src/BPStructs.cpp | 2 +- .../Src/PixelShaderManager.cpp | 26 +++++++---- .../Plugin_VideoOGL/Src/PixelShaderManager.h | 4 +- .../Plugin_VideoOGL/Src/VertexLoader.cpp | 16 ++----- .../Src/VertexLoader_Color.cpp | 2 +- .../Plugin_VideoOGL/Src/VertexShaderManager.h | 3 -- 13 files changed, 75 insertions(+), 75 deletions(-) rename Source/{Plugins/Plugin_VideoDX9 => Core/VideoCommon}/Src/IndexGenerator.cpp (99%) rename Source/{Plugins/Plugin_VideoDX9 => Core/VideoCommon}/Src/IndexGenerator.h (84%) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.cpp b/Source/Core/VideoCommon/Src/IndexGenerator.cpp similarity index 99% rename from Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.cpp rename to Source/Core/VideoCommon/Src/IndexGenerator.cpp index 2e07750e9b..01ff44a5c0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.cpp +++ b/Source/Core/VideoCommon/Src/IndexGenerator.cpp @@ -15,7 +15,6 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#include "stdafx.h" #include "IndexGenerator.h" /* diff --git a/Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.h b/Source/Core/VideoCommon/Src/IndexGenerator.h similarity index 84% rename from Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.h rename to Source/Core/VideoCommon/Src/IndexGenerator.h index 91ce0cf20a..44500358e0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/IndexGenerator.h +++ b/Source/Core/VideoCommon/Src/IndexGenerator.h @@ -15,13 +15,18 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#pragma once +// This is currently only used by the DX plugin, but it may make sense to +// use it in the GL plugin or a future DX10 plugin too. + +#ifndef _INDEXGENERATOR_H +#define _INDEXGENERATOR_H class IndexGenerator { unsigned short *ptr; int numPrims; int index; + public: void Start(unsigned short *startptr); void AddList(int numVerts); @@ -33,4 +38,6 @@ public: void AddQuads(int numVerts); int GetNumPrims() {return numPrims;} //returns numprimitives int GetNumVerts() {return index;} //returns numprimitives -}; \ No newline at end of file +}; + +#endif // _INDEXGENERATOR_H \ No newline at end of file diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.h b/Source/Core/VideoCommon/Src/VertexLoaderManager.h index 9982437b22..1061d85480 100644 --- a/Source/Core/VideoCommon/Src/VertexLoaderManager.h +++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.h @@ -22,13 +22,13 @@ namespace VertexLoaderManager { - void Init(); - void Shutdown(); + void Init(); + void Shutdown(); void MarkAllDirty(); int GetVertexSize(int vtx_attr_group); - void RunVertices(int vtx_attr_group, int primitive, int count); + void RunVertices(int vtx_attr_group, int primitive, int count); // For debugging void AppendListToString(std::string *dest); diff --git a/Source/Core/VideoCommon/VideoCommon.vcproj b/Source/Core/VideoCommon/VideoCommon.vcproj index f0bf1f691d..3261e68a5e 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcproj +++ b/Source/Core/VideoCommon/VideoCommon.vcproj @@ -471,6 +471,14 @@ RelativePath=".\Src\Fifo.h" > + + + + diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj index 79c00bdb3e..0366e740cc 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj @@ -1257,14 +1257,6 @@ - - - - diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index b5204337b8..23b0b97cce 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -37,6 +37,14 @@ using namespace D3D; namespace VertexManager { +enum Collection +{ + C_NOTHING=0, + C_TRIANGLES=1, + C_LINES=2, + C_POINTS=3 +}; + static IndexGenerator indexGen; static Collection collection; @@ -65,6 +73,23 @@ const D3DVERTEXELEMENT9 decl[] = D3DDECL_END() }; +const Collection collectionTypeLUT[8] = +{ + C_TRIANGLES,//quads + C_NOTHING, //nothing + C_TRIANGLES,//triangles + C_TRIANGLES,//strip + C_TRIANGLES,//fan + C_LINES, //lines + C_LINES, //linestrip + C_POINTS //guess :P +}; + + +D3DVertex *vbufferwrite; + +void CreateDeviceObjects(); +void DestroyDeviceObjects(); bool Init() { @@ -105,12 +130,11 @@ void DestroyDeviceObjects() vDecl = 0; } - void AddIndices(int _primitive, int _numVertices) { - switch(_primitive) { - case GX_DRAW_QUADS: indexGen.AddQuads(_numVertices); return; - case GX_DRAW_TRIANGLES: indexGen.AddList(_numVertices); return; + switch (_primitive) { + case GX_DRAW_QUADS: indexGen.AddQuads(_numVertices); return; + case GX_DRAW_TRIANGLES: indexGen.AddList(_numVertices); return; case GX_DRAW_TRIANGLE_STRIP: indexGen.AddStrip(_numVertices); return; case GX_DRAW_TRIANGLE_FAN: indexGen.AddFan(_numVertices); return; case GX_DRAW_LINE_STRIP: indexGen.AddLineStrip(_numVertices); return; @@ -119,20 +143,6 @@ void AddIndices(int _primitive, int _numVertices) } } -const Collection collectionTypeLUT[8] = -{ - C_TRIANGLES,//quads - C_NOTHING, //nothing - C_TRIANGLES,//triangles - C_TRIANGLES,//strip - C_TRIANGLES,//fan - C_LINES, //lines - C_LINES, //linestrip - C_POINTS //guess :P -}; - -D3DVertex *vbufferwrite; - void AddVertices(int _primitive, int _numVertices, const DecodedVArray *varray) { if (_numVertices <= 0) //This check is pretty stupid... diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.h b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.h index cd17fb4c89..a860130b94 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.h @@ -18,13 +18,13 @@ #pragma once -#include "CPStructs.h" +#include "CPMemory.h" #include "VertexLoader.h" #include "DecodedVArray.h" struct UV { - float u,v,w; + float u, v, w; }; struct D3DVertex { @@ -34,27 +34,14 @@ struct D3DVertex { UV uv[8]; }; -enum Collection -{ - C_NOTHING=0, - C_TRIANGLES=1, - C_LINES=2, - C_POINTS=3 -}; - namespace VertexManager { -extern const Collection collectionTypeLUT[8]; - bool Init(); void Shutdown(); void BeginFrame(); -void CreateDeviceObjects(); -void DestroyDeviceObjects(); - void AddVertices(int _primitive, int _numVertices, const DecodedVArray *varray); void Flush(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index 5635e909dd..73ce4d43e6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -363,7 +363,7 @@ void BPWritten(int addr, int changes, int newval) VertexManager::Flush(); ((u32*)&bpmem)[addr] = newval; PRIM_LOG("ztex bias=0x%x\n", bpmem.ztex1.bias); - PixelShaderMngr::SetZTetureBias(bpmem.ztex1.bias); + PixelShaderMngr::SetZTextureBias(bpmem.ztex1.bias); } break; case BPMEM_ZTEX2: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp index 09dab621eb..449cee8df3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp @@ -41,7 +41,9 @@ PIXELSHADERUID PixelShaderMngr::s_curuid; static int s_nMaxPixelInstructions; static int s_nColorsChanged[2]; // 0 - regular colors, 1 - k colors static int s_nIndTexMtxChanged = 0; -static bool s_bAlphaChanged, s_bZBiasChanged, s_bIndTexScaleChanged; +static bool s_bAlphaChanged; +static bool s_bZBiasChanged; +static bool s_bIndTexScaleChanged; static float lastRGBAfull[2][4][4]; static u8 s_nTexDimsChanged; static u32 lastAlpha = 0; @@ -54,9 +56,9 @@ static u32 lastZBias = 0; u32 s_texturemask = 0; static int maptocoord[8]; // indexed by texture map, holds the texcoord associated with the map -static u32 maptocoord_mask=0; +static u32 maptocoord_mask = 0; -static GLuint s_ColorMatrixProgram=0; +static GLuint s_ColorMatrixProgram = 0; void PixelShaderMngr::SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4) { glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f1, f2, f3, f4); @@ -216,8 +218,6 @@ bool PixelShaderMngr::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpro } } - //ERROR_LOG(pcompiledprog); - //ERROR_LOG(pstrprogram); glGenProgramsARB( 1, &ps.glprogid ); glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, ps.glprogid ); glProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pcompiledprog), pcompiledprog); @@ -348,9 +348,15 @@ void PixelShaderMngr::SetConstants() // xyz - static matrix //TODO w - dynamic matrix scale / 256...... somehow / 4 works better SetPSConstant4f(C_INDTEXMTX+2*i, - bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale, fscale * 256.0f); + bpmem.indmtx[i].col0.ma * fscale, + bpmem.indmtx[i].col1.mc * fscale, + bpmem.indmtx[i].col2.me * fscale, + fscale * 256.0f); SetPSConstant4f(C_INDTEXMTX+2*i+1, - bpmem.indmtx[i].col0.mb * fscale, bpmem.indmtx[i].col1.md * fscale, bpmem.indmtx[i].col2.mf * fscale, fscale * 256.0f); + bpmem.indmtx[i].col0.mb * fscale, + bpmem.indmtx[i].col1.md * fscale, + bpmem.indmtx[i].col2.mf * fscale, + fscale * 256.0f); PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n", i, 1024.0f*fscale, bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale, @@ -439,7 +445,7 @@ void PixelShaderMngr::SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, } } -void PixelShaderMngr::SetZTetureBias(u32 bias) +void PixelShaderMngr::SetZTextureBias(u32 bias) { if (lastZBias != bias) { s_bZBiasChanged = true; @@ -477,7 +483,7 @@ void PixelShaderMngr::SetTevIndirectChanged(int id) { } -void PixelShaderMngr::SetZTetureOpChanged() +void PixelShaderMngr::SetZTextureOpChanged() { s_bZBiasChanged = true; } @@ -546,7 +552,7 @@ void PixelShaderMngr::GetPixelShaderId(PIXELSHADERUID &uid) s_curuid.values[0] = (s_curuid.values[0] & ~0x0ff00000) | (projtexcoords << 20); // swap table for (int i = 0; i < 8; i += 2) - ((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf)<<4); + ((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4); uid.values[2] = s_texturemask; int hdr = 3; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h index 8207014ac1..0048326fd7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.h @@ -125,7 +125,7 @@ public: static void SetAlpha(const AlphaFunc& alpha); static void SetDestAlpha(const ConstantAlpha& alpha); static void SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt); - static void SetZTetureBias(u32 bias); + static void SetZTextureBias(u32 bias); static void SetIndTexScaleChanged(); static void SetIndMatrixChanged(int matrixidx); @@ -134,7 +134,7 @@ public: static void SetTevKSelChanged(int id); static void SetTevOrderChanged(int id); static void SetTevIndirectChanged(int id); - static void SetZTetureOpChanged(); + static void SetZTextureOpChanged(); static void SetTexturesUsed(u32 nonpow2tex); static void SetTexDimsChanged(int texmapid); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index c1a2193d82..34a953097d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -31,10 +31,8 @@ #include "Statistics.h" #include "VertexManager.h" #include "VertexLoaderManager.h" -#include "VertexShaderManager.h" -#include "VertexManager.h" #include "VertexLoader.h" -#include "BPStructs.h" +#include "BPMemory.h" #include "DataReader.h" #include "VertexLoader_Position.h" @@ -48,18 +46,18 @@ NativeVertexFormat *g_nativeVertexFmt; -//these don't need to be saved #ifndef _WIN32 #undef inline #define inline #endif -// Direct -// ============================================================================== +// Matrix components are first in GC format but later in PC format - we need to store it temporarily +// when decoding each vertex. static u8 s_curposmtx; static u8 s_curtexmtx[8]; static int s_texmtxwrite = 0; static int s_texmtxread = 0; + static int loop_counter; // Vertex loaders read these. Although the scale ones should be baked into the shader. @@ -514,8 +512,6 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count) VertexManager::EnableComponents(m_NativeFmt->m_components); // Load position and texcoord scale factors. - // TODO - figure out if we should leave these independent, or compile them into - // the vertexloaders. m_VtxAttr.PosFrac = g_VtxAttr[vtx_attr_group].g0.PosFrac; m_VtxAttr.texCoord[0].Frac = g_VtxAttr[vtx_attr_group].g0.Tex0Frac; m_VtxAttr.texCoord[1].Frac = g_VtxAttr[vtx_attr_group].g1.Tex1Frac; @@ -528,10 +524,9 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count) pVtxAttr = &m_VtxAttr; posScale = shiftLookup[m_VtxAttr.PosFrac]; - if (m_NativeFmt->m_components & VB_HAS_UVALL) { + if (m_NativeFmt->m_components & VB_HAS_UVALL) for (int i = 0; i < 8; i++) tcScale[i] = shiftLookup[m_VtxAttr.texCoord[i].Frac]; - } for (int i = 0; i < 2; i++) colElements[i] = m_VtxAttr.color[i].Elements; @@ -604,7 +599,6 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count) if (count - v < remainingVerts) remainingVerts = count - v; - // Clean tight loader loop. Todo - build the loop into the JIT code. #ifdef USE_JIT if (remainingVerts > 0) { loop_counter = remainingVerts; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp index 8000893ce1..5c56f4faee 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp @@ -117,7 +117,7 @@ void LOADERDECL Color_ReadDirect_24b_6666() _SetCol6666(val); } -// F|RES: i am not 100 percent show, but the colElements seems to be important for rendering only +// F|RES: i am not 100 percent sure, but the colElements seems to be important for rendering only // at least it fixes mario party 4 // // if (colElements[colIndex]) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.h index 883b403a0f..09d0548749 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.h @@ -126,7 +126,4 @@ public: static float GetPixelAspectRatio(); }; -void LoadXFReg(u32 transferSize, u32 address, u32 *pData); -void LoadIndexedXF(u32 val, int array); - #endif