Don't convert texcoords to float either.

This commit is contained in:
Henrik Rydgard committed 2013-02-06 20:30:10 +01:00
1 parent 377c94b125
commit aaf00e047b
4 files changed
+64 -32

No files matched your search

+5
View File
@@ -270,6 +270,11 @@ void LinkedShader::updateUniforms() {
uvscaleoff[1] /= gstate_c.curTextureHeight;
uvscaleoff[2] /= gstate_c.curTextureWidth;
uvscaleoff[3] /= gstate_c.curTextureHeight;
} else {
uvscaleoff[0] *= 2.0f;
uvscaleoff[1] *= 2.0f;
uvscaleoff[2] *= 2.0f;
uvscaleoff[3] *= 2.0f;
}
glUniform4fv(u_uvscaleoffset, 1, uvscaleoff);
}
+1
View File
@@ -319,6 +319,7 @@ static const GlTypeInfo GLComp[] = {
{GL_UNSIGNED_SHORT, 2, GL_TRUE},// DEC_U16_2,
{GL_UNSIGNED_SHORT, 3, GL_TRUE},// DEC_U16_3,
{GL_UNSIGNED_SHORT, 4, GL_TRUE},// DEC_U16_4,
{GL_UNSIGNED_BYTE, 2, GL_FALSE},// DEC_U8A_2,
{GL_UNSIGNED_SHORT, 2, GL_FALSE},// DEC_U16A_2,
};
+22 -13
View File
@@ -77,6 +77,7 @@ int DecFmtSize(u8 fmt) {
case DEC_U16_2: return 4;
case DEC_U16_3: return 8;
case DEC_U16_4: return 8;
case DEC_U8A_2: return 4;
case DEC_U16A_2: return 4;
default:
return 0;
@@ -143,18 +144,18 @@ void VertexDecoder::Step_WeightsFloat() const
void VertexDecoder::Step_TcU8() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
u8 *uv = (u8*)(decoded_ + decFmt.uvoff);
const u8 *uvdata = (const u8*)(ptr_ + tcoff);
for (int j = 0; j < 2; j++)
uv[j] = (float)uvdata[j] / 128.0f;
uv[0] = uvdata[0];
uv[1] = uvdata[1];
}
void VertexDecoder::Step_TcU16() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
u16 *uv = (u16 *)(decoded_ + decFmt.uvoff);
const u16 *uvdata = (const u16*)(ptr_ + tcoff);
uv[0] = (float)uvdata[0] / 32768.0f;
uv[1] = (float)uvdata[1] / 32768.0f;
uv[0] = uvdata[0];
uv[1] = uvdata[1];
}
void VertexDecoder::Step_TcU16Through() const
@@ -169,15 +170,16 @@ void VertexDecoder::Step_TcFloat() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const float *uvdata = (const float*)(ptr_ + tcoff);
memcpy(uv, uvdata, sizeof(float) * 2);
uv[0] = uvdata[0] * 0.5f;
uv[1] = uvdata[1] * 0.5f;
}
void VertexDecoder::Step_TcFloatThrough() const
{
float *uv = (float *)(decoded_ + decFmt.uvoff);
const float *uvdata = (const float*)(ptr_ + tcoff);
uv[0] = uvdata[0];
uv[1] = uvdata[1];
uv[0] = uvdata[0] * 0.5f;
uv[1] = uvdata[1] * 0.5f;
}
void VertexDecoder::Step_Color565() const
@@ -588,11 +590,18 @@ void VertexDecoder::SetVertexType(u32 fmt) {
steps_[numSteps_++] = throughmode ? tcstep_through[tc] : tcstep[tc];
// All UV except through mode decode to DEC_FLOAT2 currently.
if (throughmode && (tc == (GE_VTYPE_TC_16BIT >> GE_VTYPE_TC_SHIFT)))
decFmt.uvfmt = DEC_U16A_2;
else
switch (tc) {
case GE_VTYPE_TC_8BIT >> GE_VTYPE_TC_SHIFT:
decFmt.uvfmt = throughmode ? DEC_U8A_2 : DEC_U8_2;
break;
case GE_VTYPE_TC_16BIT >> GE_VTYPE_TC_SHIFT:
decFmt.uvfmt = throughmode ? DEC_U16A_2 : DEC_U16_2;
break;
case GE_VTYPE_TC_FLOAT >> GE_VTYPE_TC_SHIFT:
decFmt.uvfmt = DEC_FLOAT_2;
break;
}
decFmt.uvoff = decOff;
decOff += DecFmtSize(decFmt.uvfmt);
}
+36 -19
View File
@@ -42,6 +42,7 @@ enum {
DEC_U16_2,
DEC_U16_3,
DEC_U16_4,
DEC_U8A_2,
DEC_U16A_2,
};
@@ -196,14 +197,14 @@ public:
{
const s16 *p = (s16 *)(data_ + decFmt_.posoff);
for (int i = 0; i < 3; i++)
pos[i] = p[i] / 32767.0f;
pos[i] = p[i] * (1.f / 32768.f);
}
break;
case DEC_S8_3:
{
const s8 *p = (s8 *)(data_ + decFmt_.posoff);
for (int i = 0; i < 3; i++)
pos[i] = p[i] / 127.0f;
pos[i] = p[i] * (1.f / 128.f);
}
break;
default:
@@ -221,14 +222,14 @@ public:
{
const s16 *p = (s16 *)(data_ + decFmt_.nrmoff);
for (int i = 0; i < 3; i++)
nrm[i] = p[i] / 32767.0f;
nrm[i] = p[i] * (1.f / 32768.f);
}
break;
case DEC_S8_3:
{
const s8 *p = (s8 *)(data_ + decFmt_.nrmoff);
for (int i = 0; i < 3; i++)
nrm[i] = p[i] / 127.0f;
nrm[i] = p[i] * (1.f / 128.0f);
}
break;
default:
@@ -238,9 +239,25 @@ public:
}
void ReadUV(float uv[2]) {
const u8 *b = (const u8 *)(data_ + decFmt_.uvoff);
const u16 *s = (const u16 *)(data_ + decFmt_.uvoff);
const float *f = (const float *)(data_ + decFmt_.uvoff);
switch (decFmt_.uvfmt) {
case DEC_U8_2:
uv[0] = b[0] * (1.f / 128.f);
uv[1] = b[1] * (1.f / 128.f);
break;
case DEC_U16_2:
uv[0] = s[0] * (1.f / 32768.f);
uv[1] = s[1] * (1.f / 32768.f);
break;
case DEC_FLOAT_2:
memcpy(uv, data_ + decFmt_.uvoff, 8); break;
uv[0] = f[0] * 2.0f;
uv[1] = f[1] * 2.0f;
break;
case DEC_U16A_2:
{
const u16 *p = (const u16 *)(data_ + decFmt_.uvoff);
@@ -260,7 +277,7 @@ public:
{
const u8 *p = (const u8 *)(data_ + decFmt_.c0off);
for (int i = 0; i < 4; i++)
color[i] = p[i] / 255.0f;
color[i] = p[i] * (1.f / 255.f);
}
break;
case DEC_FLOAT_4:
@@ -277,7 +294,7 @@ public:
{
const u8 *p = (const u8 *)(data_ + decFmt_.c1off);
for (int i = 0; i < 3; i++)
color[i] = p[i] / 255.0f;
color[i] = p[i] * (1.f / 255.f);
}
break;
case DEC_FLOAT_4:
@@ -300,14 +317,14 @@ public:
for (int i = 0; i <= decFmt_.w0fmt - DEC_FLOAT_1; i++)
weights[i] = f[i] * 2.0;
break;
case DEC_U8_1: weights[0] = p[0] / 128.f; break;
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = p[i] / 128.f; break;
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i] = p[i] / 128.f; break;
case DEC_U8_4: for (int i = 0; i < 4; i++) weights[i] = p[i] / 128.f; break;
case DEC_U16_1: weights[0] = s[0] / 32768.f; break;
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i] = s[i] / 32768.f; break;
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i] = s[i] / 32768.f; break;
case DEC_U16_4: for (int i = 0; i < 4; i++) weights[i] = s[i] / 32768.f; break;
case DEC_U8_1: weights[0] = p[0] * (1.f / 128.f); break;
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = p[i] * (1.f / 128.f); break;
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i] = p[i] * (1.f / 128.f); break;
case DEC_U8_4: for (int i = 0; i < 4; i++) weights[i] = p[i] * (1.f / 128.f); break;
case DEC_U16_1: weights[0] = s[0] * (1.f / 32768.f); break;
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i] = s[i] * (1.f / 32768.f); break;
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i] = s[i] * (1.f / 32768.f); break;
case DEC_U16_4: for (int i = 0; i < 4; i++) weights[i] = s[i] * (1.f / 32768.f); break;
default:
ERROR_LOG(G3D, "Reader: Unsupported W0 Format");
break;
@@ -327,10 +344,10 @@ public:
for (int i = 0; i <= decFmt_.w1fmt - DEC_FLOAT_1; i++)
weights[i+4] = f[i] * 2.0;
break;
case DEC_U16_1: weights[4] = s[0] / 32768.f; break;
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i+4] = s[i] / 32768.f; break;
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i+4] = s[i] / 32768.f; break;
case DEC_U16_4: for (int i = 0; i < 4; i++) weights[i+4] = s[i] / 32768.f; break;
case DEC_U16_1: weights[4] = s[0] * (1.f / 32768.f); break;
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i+4] = s[i] * (1.f / 32768.f); break;
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i+4] = s[i] * (1.f / 32768.f); break;
case DEC_U16_4: for (int i = 0; i < 4; i++) weights[i+4] = s[i] * (1.f / 32768.f); break;
default:
ERROR_LOG(G3D, "Reader: Unsupported W1 Format");
break;