mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
D3D: Fix bugs in the shader cache, fixes crashes on x64. added some debugging stuff (only active in debug builds). assorted code cleanup.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4145 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -26,19 +26,18 @@ QUAD simulator
|
||||
021231 243453
|
||||
*/
|
||||
|
||||
|
||||
void IndexGenerator::Start(unsigned short *startptr)
|
||||
{
|
||||
ptr=startptr;
|
||||
index=0;
|
||||
numPrims=0;
|
||||
ptr = startptr;
|
||||
index = 0;
|
||||
numPrims = 0;
|
||||
}
|
||||
|
||||
void IndexGenerator::AddList(int numVerts)
|
||||
{
|
||||
int numTris = numVerts/3;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris; i++)
|
||||
int numTris = numVerts / 3;
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*ptr++ = index+i*3;
|
||||
*ptr++ = index+i*3+1;
|
||||
@ -50,10 +49,10 @@ void IndexGenerator::AddList(int numVerts)
|
||||
|
||||
void IndexGenerator::AddStrip(int numVerts)
|
||||
{
|
||||
int numTris = numVerts-2;
|
||||
if (numTris<=0) return;
|
||||
int numTris = numVerts - 2;
|
||||
if (numTris <= 0) return;
|
||||
bool wind = false;
|
||||
for (int i=0; i<numTris; i++)
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*ptr++ = index+i;
|
||||
*ptr++ = index+i+(wind?2:1);
|
||||
@ -66,9 +65,9 @@ void IndexGenerator::AddStrip(int numVerts)
|
||||
|
||||
void IndexGenerator::AddLineList(int numVerts)
|
||||
{
|
||||
int numLines= numVerts/2;
|
||||
if (numLines<=0) return;
|
||||
for (int i=0; i<numLines; i++)
|
||||
int numLines= numVerts / 2;
|
||||
if (numLines <= 0) return;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*ptr++ = index+i*2;
|
||||
*ptr++ = index+i*2+1;
|
||||
@ -79,9 +78,9 @@ void IndexGenerator::AddLineList(int numVerts)
|
||||
|
||||
void IndexGenerator::AddLineStrip(int numVerts)
|
||||
{
|
||||
int numLines = numVerts-1;
|
||||
if (numLines<=0) return;
|
||||
for (int i=0; i<numLines; i++)
|
||||
int numLines = numVerts - 1;
|
||||
if (numLines <= 0) return;
|
||||
for (int i = 0; i < numLines; i++)
|
||||
{
|
||||
*ptr++ = index+i;
|
||||
*ptr++ = index+i+1;
|
||||
@ -93,9 +92,9 @@ void IndexGenerator::AddLineStrip(int numVerts)
|
||||
|
||||
void IndexGenerator::AddFan(int numVerts)
|
||||
{
|
||||
int numTris = numVerts-2;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris; i++)
|
||||
int numTris = numVerts - 2;
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris; i++)
|
||||
{
|
||||
*ptr++ = index;
|
||||
*ptr++ = index+i+1;
|
||||
@ -108,15 +107,15 @@ void IndexGenerator::AddFan(int numVerts)
|
||||
void IndexGenerator::AddQuads(int numVerts)
|
||||
{
|
||||
int numTris = (numVerts/4)*2;
|
||||
if (numTris<=0) return;
|
||||
for (int i=0; i<numTris/2; i++)
|
||||
if (numTris <= 0) return;
|
||||
for (int i = 0; i < numTris / 2; i++)
|
||||
{
|
||||
*ptr++=index+i*4;
|
||||
*ptr++=index+i*4+1;
|
||||
*ptr++=index+i*4+3;
|
||||
*ptr++=index+i*4+1;
|
||||
*ptr++=index+i*4+2;
|
||||
*ptr++=index+i*4+3;
|
||||
*ptr++ = index+i*4;
|
||||
*ptr++ = index+i*4+1;
|
||||
*ptr++ = index+i*4+3;
|
||||
*ptr++ = index+i*4+1;
|
||||
*ptr++ = index+i*4+2;
|
||||
*ptr++ = index+i*4+3;
|
||||
}
|
||||
index += numVerts;
|
||||
numPrims += numTris;
|
||||
|
@ -23,10 +23,6 @@
|
||||
|
||||
class IndexGenerator
|
||||
{
|
||||
unsigned short *ptr;
|
||||
int numPrims;
|
||||
int index;
|
||||
|
||||
public:
|
||||
void Start(unsigned short *startptr);
|
||||
void AddList(int numVerts);
|
||||
@ -38,6 +34,10 @@ public:
|
||||
void AddQuads(int numVerts);
|
||||
int GetNumPrims() {return numPrims;} //returns numprimitives
|
||||
int GetNumVerts() {return index;} //returns numprimitives
|
||||
private:
|
||||
unsigned short *ptr;
|
||||
int numPrims;
|
||||
int index;
|
||||
};
|
||||
|
||||
#endif // _INDEXGENERATOR_H
|
@ -398,7 +398,7 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||
for (int i = 0; i < numStages; ++i)
|
||||
{
|
||||
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
|
||||
nIndirectStagesUsed |= 1<<bpmem.tevind[i].bt;
|
||||
nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,13 +410,14 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||
else
|
||||
WRITE(p, "uniform samplerRECT ");
|
||||
bool bfirst = true;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (texture_mask & (1<<i))
|
||||
{
|
||||
WRITE(p, "%s samp%d : register(s%d)", bfirst?"":",", i, i);
|
||||
bfirst = false;
|
||||
}
|
||||
|
||||
}
|
||||
WRITE(p, ";\n");
|
||||
}
|
||||
|
||||
|
@ -92,44 +92,17 @@ const char *GenerateVertexShader(u32 components, bool D3D)
|
||||
|
||||
char *p = text;
|
||||
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
|
||||
WRITE(p, "typedef struct {\n"
|
||||
" float4 T0, T1, T2;\n"
|
||||
" float4 N0, N1, N2;\n"
|
||||
"} s_"I_POSNORMALMATRIX";\n\n"
|
||||
"typedef struct {\n"
|
||||
" float4 t;\n"
|
||||
"} FLT4;\n"
|
||||
"typedef struct {\n"
|
||||
" FLT4 T[24];\n"
|
||||
"} s_"I_TEXMATRICES";\n\n"
|
||||
"typedef struct {\n"
|
||||
" FLT4 T[64];\n"
|
||||
"} s_"I_TRANSFORMMATRICES";\n\n"
|
||||
"typedef struct {\n"
|
||||
" FLT4 T[32];\n"
|
||||
"} s_"I_NORMALMATRICES";\n\n"
|
||||
"typedef struct {\n"
|
||||
" FLT4 T[64];\n"
|
||||
"} s_"I_POSTTRANSFORMMATRICES";\n\n"
|
||||
"typedef struct {\n"
|
||||
" float4 col;\n"
|
||||
" float4 cosatt;\n"
|
||||
" float4 distatt;\n"
|
||||
" float4 pos;\n"
|
||||
" float4 dir;\n"
|
||||
"} Light;\n\n"
|
||||
"typedef struct {\n"
|
||||
" Light lights[8];\n"
|
||||
"} s_"I_LIGHTS";\n\n"
|
||||
"typedef struct {\n"
|
||||
" float4 C0, C1, C2, C3;\n"
|
||||
"} s_"I_MATERIALS";\n\n"
|
||||
"typedef struct {\n"
|
||||
" float4 T0,T1,T2,T3;\n"
|
||||
"} s_"I_PROJECTION";\n"
|
||||
"typedef struct {\n"
|
||||
" float4 params;\n" // a, b, c, b_shift
|
||||
"} s_"I_FOGPARAMS";\n\n");
|
||||
WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_"I_POSNORMALMATRIX";\n"
|
||||
"typedef struct { float4 t; } FLT4;\n"
|
||||
"typedef struct { FLT4 T[24]; } s_"I_TEXMATRICES";\n"
|
||||
"typedef struct { FLT4 T[64]; } s_"I_TRANSFORMMATRICES";\n"
|
||||
"typedef struct { FLT4 T[32]; } s_"I_NORMALMATRICES";\n"
|
||||
"typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n"
|
||||
"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n"
|
||||
"typedef struct { Light lights[8]; } s_"I_LIGHTS";\n"
|
||||
"typedef struct { float4 C0,C1,C2,C3; } s_"I_MATERIALS";\n"
|
||||
"typedef struct { float4 T0,T1,T2,T3; } s_"I_PROJECTION";\n"
|
||||
"typedef struct { float4 params; } s_"I_FOGPARAMS";\n"); // a, b, c, b_shift
|
||||
|
||||
WRITE(p, "struct VS_OUTPUT {\n");
|
||||
WRITE(p, " float4 pos : POSITION;\n");
|
||||
@ -143,13 +116,10 @@ const char *GenerateVertexShader(u32 components, bool D3D)
|
||||
// clip position is in w of first 4 texcoords
|
||||
for (int i = 0; i < xfregs.numTexGens; ++i)
|
||||
WRITE(p, " float%d tex%d : TEXCOORD%d;\n", i<4?4:3, i, i);
|
||||
}
|
||||
|
||||
}
|
||||
WRITE(p, "};\n");
|
||||
WRITE(p, "\n");
|
||||
|
||||
// uniforms
|
||||
|
||||
// bool bTexMtx = ((components & VB_HAS_TEXMTXIDXALL)<<VB_HAS_UVTEXMTXSHIFT)!=0; unused TODO: keep?
|
||||
|
||||
WRITE(p, "uniform s_"I_TRANSFORMMATRICES" "I_TRANSFORMMATRICES" : register(c%d);\n", C_TRANSFORMMATRICES);
|
||||
@ -201,8 +171,8 @@ const char *GenerateVertexShader(u32 components, bool D3D)
|
||||
if (components & VB_HAS_POSMTXIDX) {
|
||||
if (D3D)
|
||||
{
|
||||
WRITE(p,"int4 indices = D3DCOLORtoUBYTE4(blend_indices);\n"
|
||||
"int posmtx = indices.x;\n");
|
||||
WRITE(p, "int4 indices = D3DCOLORtoUBYTE4(blend_indices);\n"
|
||||
"int posmtx = indices.x;\n");
|
||||
}
|
||||
WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos),1);\n");
|
||||
|
||||
|
Reference in New Issue
Block a user