and more boring moving and cleanup ...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1661 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-12-25 21:44:56 +00:00
parent 17a601958c
commit 358333b94b
13 changed files with 75 additions and 75 deletions

View File

@ -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"
/*

View File

@ -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
};
};
#endif // _INDEXGENERATOR_H

View File

@ -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);

View File

@ -471,6 +471,14 @@
RelativePath=".\Src\Fifo.h"
>
</File>
<File
RelativePath=".\Src\IndexGenerator.cpp"
>
</File>
<File
RelativePath=".\Src\IndexGenerator.h"
>
</File>
<File
RelativePath=".\Src\LookUpTables.cpp"
>

View File

@ -1257,14 +1257,6 @@
<Filter
Name="Render"
>
<File
RelativePath=".\Src\IndexGenerator.cpp"
>
</File>
<File
RelativePath=".\Src\IndexGenerator.h"
>
</File>
<File
RelativePath=".\Src\PixelShader.cpp"
>

View File

@ -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...

View File

@ -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();

View File

@ -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:

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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])

View File

@ -126,7 +126,4 @@ public:
static float GetPixelAspectRatio();
};
void LoadXFReg(u32 transferSize, u32 address, u32 *pData);
void LoadIndexedXF(u32 val, int array);
#endif