mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: extend shader to lookup a single channel
This commit is contained in:
parent
eaa4fd41e2
commit
c445a14c46
|
@ -778,6 +778,7 @@ GLuint GSDeviceOGL::CompilePS(PSSelector sel)
|
|||
+ format("#define PS_TEX_FMT %d\n", sel.tex_fmt)
|
||||
+ format("#define PS_DFMT %d\n", sel.dfmt)
|
||||
+ format("#define PS_DEPTH_FMT %d\n", sel.depth_fmt)
|
||||
+ format("#define PS_CHANNEL_FETCH %d\n", sel.channel)
|
||||
+ format("#define PS_AEM %d\n", sel.aem)
|
||||
+ format("#define PS_TFX %d\n", sel.tfx)
|
||||
+ format("#define PS_TCC %d\n", sel.tcc)
|
||||
|
@ -920,21 +921,25 @@ void GSDeviceOGL::SelfShaderTest()
|
|||
PRINT_TEST("Fst/Tc/IIp");
|
||||
|
||||
// Test: tfx/tcc
|
||||
for (int channel = 0; channel < 5; channel++) {
|
||||
for (int tfx = 0; tfx < 5; tfx++) {
|
||||
for (int tcc = 0; tcc < 2; tcc++) {
|
||||
PSSelector sel;
|
||||
sel.atst = 1;
|
||||
sel.fst = 1;
|
||||
|
||||
sel.channel = channel;
|
||||
sel.tfx = tfx;
|
||||
sel.tcc = tcc;
|
||||
std::string file = format("Shader_Tfx_%d__Tcc_%d.glsl.asm", tfx, tcc);
|
||||
std::string file = format("Shader_Tfx_%d__Tcc_%d__Channel_%d.glsl.asm", tfx, tcc, channel);
|
||||
RUN_TEST;
|
||||
}
|
||||
}
|
||||
PRINT_TEST("Tfx/Tcc");
|
||||
}
|
||||
PRINT_TEST("Tfx/Tcc/Channel");
|
||||
|
||||
// Test: Texture Sampling
|
||||
for (int depth = 0; depth < 4; depth++) {
|
||||
for (int fmt = 0; fmt < 16; fmt++) {
|
||||
if ((fmt & 3) == 3) continue;
|
||||
|
||||
|
@ -948,19 +953,21 @@ void GSDeviceOGL::SelfShaderTest()
|
|||
sel.tcc = 1;
|
||||
sel.fst = 1;
|
||||
|
||||
sel.depth_fmt = depth;
|
||||
sel.ltf = ltf;
|
||||
sel.aem = aem;
|
||||
sel.tex_fmt = fmt;
|
||||
sel.wms = wms;
|
||||
sel.wmt = wmt;
|
||||
std::string file = format("Shader_Ltf_%d__Aem_%d__TFmt_%d__Wms_%d__Wmt_%d.glsl.asm",
|
||||
ltf, aem, fmt, wms, wmt);
|
||||
std::string file = format("Shader_Ltf_%d__Aem_%d__TFmt_%d__Wms_%d__Wmt_%d__DepthFmt_%d.glsl.asm",
|
||||
ltf, aem, fmt, wms, wmt, depth);
|
||||
RUN_TEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PRINT_TEST("Texture Sampling");
|
||||
|
||||
fprintf(stderr, "\nTotal %d\n", all);
|
||||
|
|
|
@ -284,10 +284,13 @@ class GSDeviceOGL final : public GSDevice
|
|||
uint32 hdr:1;
|
||||
uint32 colclip:1;
|
||||
|
||||
// Others ways to fetch the texture
|
||||
uint32 channel:3;
|
||||
|
||||
// Hack
|
||||
uint32 tcoffsethack:1;
|
||||
|
||||
uint32 _free2:19;
|
||||
uint32 _free2:16;
|
||||
};
|
||||
|
||||
uint64 key;
|
||||
|
|
|
@ -261,6 +261,34 @@ vec4 sample_depth(vec2 st)
|
|||
|
||||
return t;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Fetch a Single Channel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
vec4 fetch_red()
|
||||
{
|
||||
vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
return sample_p(rt.r) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_blue()
|
||||
{
|
||||
vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
return sample_p(rt.b) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_green()
|
||||
{
|
||||
vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
return sample_p(rt.g) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_alpha()
|
||||
{
|
||||
vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
return sample_p(rt.a) * 255.0f;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
vec4 sample_color(vec2 st)
|
||||
|
@ -422,7 +450,15 @@ vec4 ps_color()
|
|||
vec2 st = PSin.t_int.xy;
|
||||
#endif
|
||||
|
||||
#if (PS_DEPTH_FMT > 0)
|
||||
#if PS_CHANNEL_FETCH == 1
|
||||
vec4 T = fetch_red();
|
||||
#elif PS_CHANNEL_FETCH == 2
|
||||
vec4 T = fetch_green();
|
||||
#elif PS_CHANNEL_FETCH == 3
|
||||
vec4 T = fetch_blue();
|
||||
#elif PS_CHANNEL_FETCH == 4
|
||||
vec4 T = fetch_alpha();
|
||||
#elif PS_DEPTH_FMT > 0
|
||||
// Integral coordinate
|
||||
vec4 T = sample_depth(PSin.t_int.zw);
|
||||
#else
|
||||
|
|
|
@ -1105,6 +1105,34 @@ static const char* const tfx_fs_all_glsl =
|
|||
"\n"
|
||||
" return t;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//////////////////////////////////////////////////////////////////////\n"
|
||||
"// Fetch a Single Channel\n"
|
||||
"//////////////////////////////////////////////////////////////////////\n"
|
||||
"vec4 fetch_red()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" return sample_p(rt.r) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_blue()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" return sample_p(rt.b) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_green()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" return sample_p(rt.g) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_alpha()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RtSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" return sample_p(rt.a) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"//////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"vec4 sample_color(vec2 st)\n"
|
||||
|
@ -1266,7 +1294,15 @@ static const char* const tfx_fs_all_glsl =
|
|||
" vec2 st = PSin.t_int.xy;\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#if (PS_DEPTH_FMT > 0)\n"
|
||||
"#if PS_CHANNEL_FETCH == 1\n"
|
||||
" vec4 T = fetch_red();\n"
|
||||
"#elif PS_CHANNEL_FETCH == 2\n"
|
||||
" vec4 T = fetch_green();\n"
|
||||
"#elif PS_CHANNEL_FETCH == 3\n"
|
||||
" vec4 T = fetch_blue();\n"
|
||||
"#elif PS_CHANNEL_FETCH == 4\n"
|
||||
" vec4 T = fetch_alpha();\n"
|
||||
"#elif PS_DEPTH_FMT > 0\n"
|
||||
" // Integral coordinate\n"
|
||||
" vec4 T = sample_depth(PSin.t_int.zw);\n"
|
||||
"#else\n"
|
||||
|
|
Loading…
Reference in New Issue