From e40a26be19acada42afb525f45381c25bf1fc024 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 3 Apr 2015 20:28:44 +0200 Subject: [PATCH] gsdx: add some helper to debug openGL renderer --- plugins/GSdx/GSShaderOGL.cpp | 3 +++ plugins/GSdx/res/glsl_source.h | 14 ++++++++++++++ plugins/GSdx/res/tfx.glsl | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp index 4451739dae..7fc5d397a5 100644 --- a/plugins/GSdx/GSShaderOGL.cpp +++ b/plugins/GSdx/GSShaderOGL.cpp @@ -104,7 +104,10 @@ void GSShaderOGL::PS(GLuint s, GLuint sub_count) { m_ps_sub_count = sub_count; +#ifndef _DEBUG + // In debug always sets the program. It allow to replace the program in apitrace easily. GLState::ps = s; +#endif GLState::dirty_prog = true; GLState::dirty_subroutine_ps = true; GLState::dirty_ressources = true; diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 5af90bbf49..fb37abca60 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -458,6 +458,8 @@ static const char* tfx_glsl = "#define FMT_16 2\n" "#define FMT_PAL 4 /* flag bit */\n" "\n" + "#define APITRACE_DEBUG 0\n" + "\n" "// Not sure we have same issue on opengl. Doesn't work anyway on ATI card\n" "// And I say this as an ATI user.\n" "#define ATI_SUCKS 0\n" @@ -1477,6 +1479,18 @@ static const char* tfx_glsl = "#endif\n" "\n" " vec4 c = ps_color();\n" + "#if (APITRACE_DEBUG & 1) == 1\n" + " c.r = 1.0f;\n" + "#endif\n" + "#if (APITRACE_DEBUG & 2) == 2\n" + " c.g = 1.0f;\n" + "#endif\n" + "#if (APITRACE_DEBUG & 4) == 4\n" + " c.b = 1.0f;\n" + "#endif\n" + "#if (APITRACE_DEBUG & 8) == 8\n" + " c.a = 0.5f;\n" + "#endif\n" "\n" " float alpha = c.a * 2.0;\n" "\n" diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index c4f3536f4a..c397ca733b 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -7,6 +7,8 @@ #define FMT_16 2 #define FMT_PAL 4 /* flag bit */ +#define APITRACE_DEBUG 0 + // Not sure we have same issue on opengl. Doesn't work anyway on ATI card // And I say this as an ATI user. #define ATI_SUCKS 0 @@ -1026,6 +1028,18 @@ void ps_main() #endif vec4 c = ps_color(); +#if (APITRACE_DEBUG & 1) == 1 + c.r = 1.0f; +#endif +#if (APITRACE_DEBUG & 2) == 2 + c.g = 1.0f; +#endif +#if (APITRACE_DEBUG & 4) == 4 + c.b = 1.0f; +#endif +#if (APITRACE_DEBUG & 8) == 8 + c.a = 0.5f; +#endif float alpha = c.a * 2.0;