Fix issue with vertex shader IDs. Write the 4th component of packed vectors.

The latter makes sure we leave no holes in the CPU writebuffer.
This commit is contained in:
Henrik Rydgard
2013-01-22 22:27:03 +01:00
parent e04f5156ee
commit dbdd461a53
3 changed files with 24 additions and 6 deletions

View File

@@ -34,6 +34,8 @@
#define WRITE p+=sprintf
// #define DEBUG_SHADER
// GL_NV_shader_framebuffer_fetch looks interesting....
// Here we must take all the bits of the gstate that determine what the fragment shader will
@@ -72,6 +74,8 @@ void ComputeFragmentShaderID(FragmentShaderID *id)
void GenerateFragmentShader(char *buffer)
{
char *p = buffer;
#if defined(GLSL_ES_1_0)
WRITE(p, "precision mediump float;\n");
#elif !defined(FORCE_OPENGL_2_0)
@@ -186,8 +190,16 @@ void GenerateFragmentShader(char *buffer)
WRITE(p, " v = mix(vec4(u_fogcolor, v.a), v, fogCoef);\n");
// WRITE(p, " v.x = v_depth;\n");
}
}
#ifdef DEBUG_SHADER
if (doTexture) {
WRITE(p, " v = texture2D(tex, v_texcoord);\n");
} else {
WRITE(p, " v = vec4(1,0,1,1);\n");
}
#endif
WRITE(p, " gl_FragColor = v;\n");
WRITE(p, "}\n");
}

View File

@@ -50,11 +50,11 @@ void PrintDecodedVertex(VertexReader &vtx) {
printf("P: %f %f %f\n", pos[0], pos[1], pos[2]);
}
const int tcsize[4] = {0,2,4,8}, tcalign[4] = {0,1,2,4};
const int colsize[8] = {0,0,0,0,2,2,2,4}, colalign[8] = {0,0,0,0,2,2,2,4};
const int nrmsize[4] = {0,3,6,12}, nrmalign[4] = {0,1,2,4};
const int possize[4] = {0,3,6,12}, posalign[4] = {0,1,2,4};
const int wtsize[4] = {0,1,2,4}, wtalign[4] = {0,1,2,4};
const u8 tcsize[4] = {0,2,4,8}, tcalign[4] = {0,1,2,4};
const u8 colsize[8] = {0,0,0,0,2,2,2,4}, colalign[8] = {0,0,0,0,2,2,2,4};
const u8 nrmsize[4] = {0,3,6,12}, nrmalign[4] = {0,1,2,4};
const u8 possize[4] = {0,3,6,12}, posalign[4] = {0,1,2,4};
const u8 wtsize[4] = {0,1,2,4}, wtalign[4] = {0,1,2,4};
inline int align(int n, int align) {
return (n + (align - 1)) & ~(align - 1);
@@ -283,6 +283,7 @@ void VertexDecoder::Step_NormalS8() const
const s8 *sv = (const s8*)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
normal[j] = sv[j] ^ xorval;
normal[3] = 0;
}
void VertexDecoder::Step_NormalS16() const
@@ -294,6 +295,7 @@ void VertexDecoder::Step_NormalS16() const
const s16 *sv = (const s16*)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
normal[j] = sv[j] ^ xorval ;
normal[3] = 0;
}
void VertexDecoder::Step_NormalFloat() const
@@ -361,6 +363,7 @@ void VertexDecoder::Step_PosS8() const
const s8 *sv = (const s8*)(ptr_ + posoff);
for (int j = 0; j < 3; j++)
v[j] = sv[j];
v[3] = 0;
}
void VertexDecoder::Step_PosS16() const
@@ -369,6 +372,7 @@ void VertexDecoder::Step_PosS16() const
const s16 *sv = (const s16*)(ptr_ + posoff);
for (int j = 0; j < 3; j++)
v[j] = sv[j];
v[3] = 0;
}
void VertexDecoder::Step_PosFloat() const
@@ -386,6 +390,7 @@ void VertexDecoder::Step_PosS8Through() const
v[0] = sv[0];
v[1] = sv[1];
v[2] = sv[2];
v[3] = 0;
}
void VertexDecoder::Step_PosS16Through() const
@@ -395,6 +400,7 @@ void VertexDecoder::Step_PosS16Through() const
v[0] = sv[0];
v[1] = sv[1];
v[2] = sv[2];
v[3] = 0;
}
void VertexDecoder::Step_PosFloatThrough() const

View File

@@ -82,7 +82,7 @@ void ComputeVertexShaderID(VertexShaderID *id, int prim)
// Okay, d[1] coming up. ==============
id->d[1] |= (gstate.lightingEnable & 1) << 19;
if (gstate.lightingEnable & 1) {
if ((gstate.lightingEnable & 1) || gstate.getUVGenMode() == 2) {
// Light bits
for (int i = 0; i < 4; i++) {
id->d[1] |= (gstate.ltype[i] & 3) << (i * 4);