gsdx-ogl: use normalized index coordinate for palette texture

In palette mode, 90% of texture accesses are done in 8 bits.
So let's keep this path as light as possible. It reduces GPU load.
This commit is contained in:
Gregory Hainaut 2015-08-14 17:53:41 +02:00
parent 42c08e6123
commit 78dd957717
2 changed files with 22 additions and 14 deletions

View File

@ -80,9 +80,9 @@ vec4 sample_c(vec2 uv)
return texture(TextureSampler, uv);
}
vec4 sample_p(uint idx)
vec4 sample_p(float idx)
{
return texelFetch(PaletteSampler, ivec2(idx, 0u), 0);
return texture(PaletteSampler, vec2(idx, 0.0f));
}
vec4 wrapuv(vec4 uv)
@ -149,7 +149,7 @@ mat4 sample_4c(vec4 uv)
return c;
}
uvec4 sample_4_index(vec4 uv)
vec4 sample_4_index(vec4 uv)
{
vec4 c;
@ -169,18 +169,22 @@ uvec4 sample_4_index(vec4 uv)
#if PS_IFMT == 1
// 4HH
return i >> 4u;
return vec4(i >> 4u) / 255.0f;
#elif PS_IFMT == 2
// 4HL
return i & 0xFu;
return vec4(i & 0xFu) / 255.0f;
#else
// Most of texture will hit this code so keep normalized float value
// 8 bits
return i;
return c;
#endif
}
mat4 sample_4p(uvec4 u)
mat4 sample_4p(vec4 u)
{
mat4 c;

View File

@ -939,9 +939,9 @@ static const char* tfx_fs_all_glsl =
" return texture(TextureSampler, uv);\n"
"}\n"
"\n"
"vec4 sample_p(uint idx)\n"
"vec4 sample_p(float idx)\n"
"{\n"
" return texelFetch(PaletteSampler, ivec2(idx, 0u), 0);\n"
" return texture(PaletteSampler, vec2(idx, 0.0f));\n"
"}\n"
"\n"
"vec4 wrapuv(vec4 uv)\n"
@ -1008,7 +1008,7 @@ static const char* tfx_fs_all_glsl =
" return c;\n"
"}\n"
"\n"
"uvec4 sample_4_index(vec4 uv)\n"
"vec4 sample_4_index(vec4 uv)\n"
"{\n"
" vec4 c;\n"
"\n"
@ -1028,18 +1028,22 @@ static const char* tfx_fs_all_glsl =
"\n"
"#if PS_IFMT == 1\n"
" // 4HH\n"
" return i >> 4u;\n"
" return vec4(i >> 4u) / 255.0f;\n"
"\n"
"#elif PS_IFMT == 2\n"
" // 4HL\n"
" return i & 0xFu;\n"
" return vec4(i & 0xFu) / 255.0f;\n"
"\n"
"#else\n"
" // Most of texture will hit this code so keep normalized float value\n"
"\n"
" // 8 bits\n"
" return i;\n"
" return c;\n"
"#endif\n"
"\n"
"}\n"
"\n"
"mat4 sample_4p(uvec4 u)\n"
"mat4 sample_4p(vec4 u)\n"
"{\n"
" mat4 c;\n"
"\n"