summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2016-04-09 02:36:19 +0200
committerdegasus <wickmarkus@web.de>2016-04-09 12:25:00 +0200
commit10e4f7e7bf214ad2c02470a722065875ccc1eee9 (patch)
treec2c0532e3f0b667c86b5daa37b0ce4c77b316e77 /Source/Core
parent94098a50c2a6c6eb76ed27b5ea9e5f9b69a459bc (diff)
PixelShaderGen: Move constant multiplication to constant generation.
No need to do this within the shader per pixel if it can be done once.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp6
-rw-r--r--Source/Core/VideoCommon/PixelShaderManager.cpp13
2 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 5ae79e0733..70f033c3a3 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -467,7 +467,7 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
{
out.Write("uv%d.xy", i);
}
- out.Write(" * " I_TEXDIMS"[%d].zw * 128.0);\n", i);
+ out.Write(" * " I_TEXDIMS"[%d].zw);\n", i);
// TODO: S24 overflows here?
}
}
@@ -501,7 +501,7 @@ static T GeneratePixelShader(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
out.Write("\ttempcoord = int2(0, 0);\n");
out.Write("\tint3 iindtex%d = ", i);
- SampleTexture<T>(out, "(float2(tempcoord)/128.0)", "abg", texmap, ApiType);
+ SampleTexture<T>(out, "float2(tempcoord)", "abg", texmap, ApiType);
}
}
@@ -836,7 +836,7 @@ static void WriteStage(T& out, pixel_shader_uid_data* uid_data, int n, API_TYPE
uid_data->SetTevindrefTexmap(i, texmap);
out.Write("\ttextemp = ");
- SampleTexture<T>(out, "(float2(tevcoord.xy)/128.0)", texswap, texmap, ApiType);
+ SampleTexture<T>(out, "(tevcoord.xy)", texswap, texmap, ApiType);
}
else
{
diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp
index 3fd0cfe0c8..2734f64827 100644
--- a/Source/Core/VideoCommon/PixelShaderManager.cpp
+++ b/Source/Core/VideoCommon/PixelShaderManager.cpp
@@ -137,13 +137,16 @@ void PixelShaderManager::SetDestAlpha()
void PixelShaderManager::SetTexDims(int texmapid, u32 width, u32 height)
{
+ float rwidth = 1.0f / (width * 128.0f);
+ float rheight = 1.0f / (height * 128.0f);
+
// TODO: move this check out to callee. There we could just call this function on texture changes
// or better, use textureSize() in glsl
- if (constants.texdims[texmapid][0] != 1.0f/width || constants.texdims[texmapid][1] != 1.0f/height)
+ if (constants.texdims[texmapid][0] != rwidth || constants.texdims[texmapid][1] != rheight)
dirty = true;
- constants.texdims[texmapid][0] = 1.0f/width;
- constants.texdims[texmapid][1] = 1.0f/height;
+ constants.texdims[texmapid][0] = rwidth;
+ constants.texdims[texmapid][1] = rheight;
}
void PixelShaderManager::SetZTextureBias()
@@ -238,8 +241,8 @@ void PixelShaderManager::SetZTextureTypeChanged()
void PixelShaderManager::SetTexCoordChanged(u8 texmapid)
{
TCoordInfo& tc = bpmem.texcoords[texmapid];
- constants.texdims[texmapid][2] = (float)(tc.s.scale_minus_1 + 1);
- constants.texdims[texmapid][3] = (float)(tc.t.scale_minus_1 + 1);
+ constants.texdims[texmapid][2] = (float)(tc.s.scale_minus_1 + 1) * 128.0f;
+ constants.texdims[texmapid][3] = (float)(tc.t.scale_minus_1 + 1) * 128.0f;
dirty = true;
}