Merge pull request #8283 from unknownbrackets/prescale

Fix some issues with the prescale UV speedhack
This commit is contained in:
Henrik Rydgård committed 2015-12-21 23:43:08 +01:00
commit 41372a0903
7 files changed
+45 -30

No files matched your search

+4 -5
View File
@@ -598,7 +598,6 @@ static void _BezierPatchLowQuality(u8 *&dest, u16 *&indices, int &count, int tes
v3.nrm = norm;
}
int total = patch.index * 3 * 3 * 4; // A patch has 3x3 tiles, and each tiles have 4 vertices.
int tile_index = tile_u + tile_v * 3;
int idx0 = total + tile_index * 4 + 0;
@@ -805,7 +804,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
u32 vertTypeWithIndex16 = (vertType & ~GE_VTYPE_IDX_MASK) | GE_VTYPE_IDX_16BIT;
UVScale prevUVScale;
if (g_Config.bPrescaleUV) {
if (g_Config.bPrescaleUV && (origVertType & GE_VTYPE_TC_MASK) != 0) {
// We scaled during Normalize already so let's turn it off when drawing.
prevUVScale = gstate_c.uv;
gstate_c.uv.uScale = 1.0f;
@@ -819,7 +818,7 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
DispatchFlush();
if (g_Config.bPrescaleUV) {
if (g_Config.bPrescaleUV && (origVertType & GE_VTYPE_TC_MASK) != 0) {
gstate_c.uv = prevUVScale;
}
}
@@ -901,7 +900,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
u32 vertTypeWithIndex16 = (vertType & ~GE_VTYPE_IDX_MASK) | GE_VTYPE_IDX_16BIT;
UVScale prevUVScale;
if (g_Config.bPrescaleUV) {
if (g_Config.bPrescaleUV && (origVertType & GE_VTYPE_TC_MASK) != 0) {
// We scaled during Normalize already so let's turn it off when drawing.
prevUVScale = gstate_c.uv;
gstate_c.uv.uScale = 1.0f;
@@ -915,7 +914,7 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
DispatchFlush();
if (g_Config.bPrescaleUV) {
if (g_Config.bPrescaleUV && (origVertType & GE_VTYPE_TC_MASK) != 0) {
gstate_c.uv = prevUVScale;
}
}
-1
View File
@@ -469,7 +469,6 @@ void ShaderManagerDX9::VSUpdateUniforms(int dirtyUniforms) {
// Not sure what GE_TEXMAP_UNKNOWN is, but seen in Riviera. Treating the same as GE_TEXMAP_TEXTURE_COORDS works.
case GE_TEXMAP_UNKNOWN:
if (g_Config.bPrescaleUV) {
// Shouldn't even get here as we won't use the uniform in the shader.
// We are here but are prescaling UV in the decoder? Let's do the same as in the other case
// except consider *Scale and *Off to be 1 and 0.
uvscaleoff[0] = widthFactor;
+2 -2
View File
@@ -134,7 +134,7 @@ void GenerateVertexShaderDX9(const ShaderID &id, char *buffer) {
}
#endif
}
if (doTexture && (!prescale || uvGenMode == GE_TEXMAP_ENVIRONMENT_MAP || uvGenMode == GE_TEXMAP_TEXTURE_MATRIX)) {
if (doTexture) {
WRITE(p, "float4 u_uvscaleoffset : register(c%i);\n", CONST_VS_UVSCALEOFFSET);
}
for (int i = 0; i < 4; i++) {
@@ -506,7 +506,7 @@ void GenerateVertexShaderDX9(const ShaderID &id, char *buffer) {
case GE_TEXMAP_UNKNOWN: // Not sure what this is, but Riviera uses it. Treating as coords works.
if (prescale) {
if (hasTexcoord) {
WRITE(p, " Out.v_texcoord = In.texcoord;\n");
WRITE(p, " Out.v_texcoord = In.texcoord * u_uvscaleoffset.xy;\n");
} else {
WRITE(p, " Out.v_texcoord = float2(0.0, 0.0);\n");
}
-6
View File
@@ -544,7 +544,6 @@ void LinkedShader::UpdateUniforms(u32 vertType) {
// Not sure what GE_TEXMAP_UNKNOWN is, but seen in Riviera. Treating the same as GE_TEXMAP_TEXTURE_COORDS works.
case GE_TEXMAP_UNKNOWN:
if (g_Config.bPrescaleUV) {
// Shouldn't even get here as we won't use the uniform in the shader.
// We are here but are prescaling UV in the decoder? Let's do the same as in the other case
// except consider *Scale and *Off to be 1 and 0.
uvscaleoff[0] = widthFactor;
@@ -795,11 +794,6 @@ bool ShaderManager::DebugAreShadersCompatibleForLinking(Shader *vs, Shader *fs)
}
Shader *ShaderManager::ApplyVertexShader(int prim, u32 vertType) {
// This doesn't work - we miss some events that really do need to dirty the prescale.
// like changing the texmapmode.
// if (g_Config.bPrescaleUV)
// globalDirty_ &= ~DIRTY_UVSCALEOFFSET;
if (globalDirty_) {
if (lastShader_)
lastShader_->dirtyUniforms |= globalDirty_;
+2 -2
View File
@@ -247,7 +247,7 @@ void GenerateVertexShader(const ShaderID &id, char *buffer) {
}
#endif
}
if (doTexture && (!prescale || uvGenMode == GE_TEXMAP_ENVIRONMENT_MAP || uvGenMode == GE_TEXMAP_TEXTURE_MATRIX)) {
if (doTexture) {
WRITE(p, "uniform vec4 u_uvscaleoffset;\n");
}
for (int i = 0; i < 4; i++) {
@@ -595,7 +595,7 @@ void GenerateVertexShader(const ShaderID &id, char *buffer) {
case GE_TEXMAP_UNKNOWN: // Not sure what this is, but Riviera uses it. Treating as coords works.
if (prescale) {
if (hasTexcoord) {
WRITE(p, " v_texcoord = texcoord;\n");
WRITE(p, " v_texcoord = texcoord * u_uvscaleoffset.xy;\n");
} else {
WRITE(p, " v_texcoord = vec2(0.0);\n");
}
+36 -12
View File
@@ -1181,10 +1181,18 @@ void DrawTriangleSlice(
Vec2<int> d01((int)v0.screenpos.x - (int)v1.screenpos.x, (int)v0.screenpos.y - (int)v1.screenpos.y);
Vec2<int> d02((int)v0.screenpos.x - (int)v2.screenpos.x, (int)v0.screenpos.y - (int)v2.screenpos.y);
Vec2<int> d12((int)v1.screenpos.x - (int)v2.screenpos.x, (int)v1.screenpos.y - (int)v2.screenpos.y);
float texScaleU = getFloat24(gstate.texscaleu);
float texScaleV = getFloat24(gstate.texscalev);
float texOffsetU = getFloat24(gstate.texoffsetu);
float texOffsetV = getFloat24(gstate.texoffsetv);
float texScaleU = gstate_c.uv.uScale;
float texScaleV = gstate_c.uv.vScale;
float texOffsetU = gstate_c.uv.uOff;
float texOffsetV = gstate_c.uv.vOff;
if (g_Config.bPrescaleUV) {
// Already applied during vertex decode.
texScaleU = 1.0f;
texScaleV = 1.0f;
texOffsetU = 0.0f;
texOffsetV = 0.0f;
}
int bias0 = IsRightSideOrFlatBottomLine(v0.screenpos.xy(), v1.screenpos.xy(), v2.screenpos.xy()) ? -1 : 0;
int bias1 = IsRightSideOrFlatBottomLine(v1.screenpos.xy(), v2.screenpos.xy(), v0.screenpos.xy()) ? -1 : 0;
@@ -1409,10 +1417,18 @@ void DrawPoint(const VertexData &v0)
// TODO: Is it really this simple?
ApplyTexturing(prim_color, s, t, maxTexLevel, magFilt, texptr, texbufwidthbits);
} else {
float texScaleU = getFloat24(gstate.texscaleu);
float texScaleV = getFloat24(gstate.texscalev);
float texOffsetU = getFloat24(gstate.texoffsetu);
float texOffsetV = getFloat24(gstate.texoffsetv);
float texScaleU = gstate_c.uv.uScale;
float texScaleV = gstate_c.uv.vScale;
float texOffsetU = gstate_c.uv.uOff;
float texOffsetV = gstate_c.uv.vOff;
if (g_Config.bPrescaleUV) {
// Already applied during vertex decode.
texScaleU = 1.0f;
texScaleV = 1.0f;
texOffsetU = 0.0f;
texOffsetV = 0.0f;
}
s = s * texScaleU + texOffsetU;
t = t * texScaleV + texOffsetV;
@@ -1492,10 +1508,18 @@ void DrawLine(const VertexData &v0, const VertexData &v1)
}
}
float texScaleU = getFloat24(gstate.texscaleu);
float texScaleV = getFloat24(gstate.texscalev);
float texOffsetU = getFloat24(gstate.texoffsetu);
float texOffsetV = getFloat24(gstate.texoffsetv);
float texScaleU = gstate_c.uv.uScale;
float texScaleV = gstate_c.uv.vScale;
float texOffsetU = gstate_c.uv.uOff;
float texOffsetV = gstate_c.uv.vOff;
if (g_Config.bPrescaleUV) {
// Already applied during vertex decode.
texScaleU = 1.0f;
texScaleV = 1.0f;
texOffsetU = 0.0f;
texOffsetV = 0.0f;
}
float x = a.x;
float y = a.y;
+1 -2
View File
@@ -309,8 +309,7 @@ void GameSettingsScreen::CreateViews() {
CheckBox *depthWrite = graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gr->T("Always Depth Write")));
depthWrite->SetDisabledPtr(&g_Config.bSoftwareRendering);
CheckBox *prescale = graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gr->T("Texture Coord Speedhack")));
prescale->SetDisabledPtr(&g_Config.bSoftwareRendering);
graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gr->T("Texture Coord Speedhack")));
static const char *bloomHackOptions[] = { "Off", "Safe", "Balanced", "Aggressive" };
PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects (reduces artifacts)"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), gr->GetName(), screenManager()));