• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revision703c09861e7fd5c05eb27d40c29864fcf57d2959 (tree)
Time2018-05-14 02:45:14
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[Qt][OpenGL][GL3][GLES] Modify shaders to use float texture and high precision pixels if enabled.

Change Summary

Incremental Difference

--- a/source/src/qt/gui/gl3/qt_glutil_gl3_0.cpp
+++ b/source/src/qt/gui/gl3/qt_glutil_gl3_0.cpp
@@ -308,7 +308,7 @@ void GLDraw_3_0::initPackedGLObject(GLScreenPack **p,
308308 QString s;
309309 GLScreenPack *pp;
310310 if(p != NULL) {
311- pp = new GLScreenPack(_width, _height, p_wid);
311+ pp = new GLScreenPack(_width, _height, _name, p_wid);
312312 *p = pp;
313313 if(pp != NULL) {
314314 pp->initialize(_width, _height, vertex_shader, fragment_shader);
@@ -319,6 +319,11 @@ void GLDraw_3_0::initPackedGLObject(GLScreenPack **p,
319319 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "Fragment: %s ", fragment_shader.toLocal8Bit().constData());
320320 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "%s", s.toLocal8Bit().constData());
321321 }
322+ s = pp->getGLLog();
323+ if(s.size() > 0) {
324+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "%s", s.toLocal8Bit().constData());
325+ pp->clearGLLog();
326+ }
322327 }
323328 }
324329 }
--- a/source/src/qt/gui/gles2/chromakey_fragment_shader.glsl
+++ b/source/src/qt/gui/gles2/chromakey_fragment_shader.glsl
@@ -1,13 +1,15 @@
1+precision mediump float;
2+
13 varying mediump vec2 v_texcoord;
2-uniform mediump vec4 color;
3-uniform mediump vec3 chromakey;
4+uniform vec4 color;
5+uniform vec3 chromakey;
46 uniform bool do_chromakey;
57 uniform bool swap_byteorder;
68 uniform sampler2D a_texture;
79 void main ()
810 {
9- mediump vec4 pixel_r_1;
10- mediump vec4 pixel;
11+ vec4 pixel_r_1;
12+ vec4 pixel;
1113
1214 pixel_r_1 = texture2D(a_texture, v_texcoord);
1315
--- a/source/src/qt/gui/gles2/chromakey_fragment_shader2.glsl
+++ b/source/src/qt/gui/gles2/chromakey_fragment_shader2.glsl
@@ -1,13 +1,15 @@
1-varying mediump vec2 v_texcoord;
2-uniform mediump vec4 color;
3-uniform mediump vec3 chromakey;
1+precision mediump float;
2+
3+varying vec2 v_texcoord;
4+uniform vec4 color;
5+uniform vec3 chromakey;
46 uniform bool do_chromakey;
57 uniform bool swap_byteorder;
68 uniform sampler2D a_texture;
79 void main ()
810 {
9- mediump vec4 pixel_r_1;
10- mediump vec4 pixel;
11+ vec4 pixel_r_1;
12+ vec4 pixel;
1113
1214 pixel_r_1 = texture2D(a_texture, v_texcoord);
1315
--- a/source/src/qt/gui/gles2/ntsc_pass1.glsl
+++ b/source/src/qt/gui/gles2/ntsc_pass1.glsl
@@ -1,7 +1,11 @@
11 // NTSC Shader - written by Hans-Kristian Arntzen
22 // License: GPLv3
33 // pulled from git://github.com/libretro/common-shaders.git on 01/30/2014
4+#ifdef HAS_FRAGMENT_HIGH_PRECISION
5+precision highp float;
6+#else
47 precision mediump float;
8+#endif
59
610 varying mediump vec2 v_texcoord;
711
@@ -135,7 +139,9 @@ void main() {
135139 // -> y = 0 to +3.6
136140 // Cb = 0 to +1.7
137141 // Cr = 0 to +1.7
142+#ifndef HAS_FLOAT_TEXTURE
138143 ycbcr = ycbcr * vec3(0.277778 ,0.588235, 0.588235);
144+#endif
139145 // Normalise
140146 vec4 outvar = vec4(ycbcr, 1.0);
141147 gl_FragColor = outvar;
--- a/source/src/qt/gui/gles2/ntsc_pass2.glsl
+++ b/source/src/qt/gui/gles2/ntsc_pass2.glsl
@@ -2,11 +2,14 @@
22 // License: GPLv3
33 // pulled from git://github.com/libretro/common-shaders.git on 01/30/2014
44
5+#ifdef HAS_FRAGMENT_HIGH_PRECISION
6+precision highp float;
7+#else
58 precision mediump float;
6-uniform bool swap_byteorder;
7-
9+#endif
810 varying mediump vec2 v_texcoord;
911
12+uniform bool swap_byteorder;
1013 uniform sampler2D a_texture;
1114 uniform vec4 source_size;
1215 uniform vec4 target_size;
@@ -16,7 +19,11 @@ uniform float luma_filter[24 + 1];
1619 uniform float chroma_filter[24 + 1];
1720
1821 #define GAMMA_CORRECTION //comment to disable gamma correction, usually because higan's gamma correction is enabled or you have another shader already doing it
19-#define CRT_GAMMA 3.5
22+#ifndef HAS_FLOAT_TEXTURE
23+#define CRT_GAMMA 3.3
24+#else
25+#define CRT_GAMMA 2.5
26+#endif
2027 #define DISPLAY_GAMMA 2.1
2128
2229
@@ -103,28 +110,34 @@ void main() {
103110 for(int ii = 1; ii < TAPS; ii++) {
104111 pix_p = texture2D(a_texture, addr_p).xyz;
105112 pix_n = texture2D(a_texture, addr_n).xyz;
113+#ifndef HAS_FLOAT_TEXTURE
106114 pix_p = pix_p * vec3(3.6, 1.7, 1.7);
107115 pix_n = pix_n * vec3(3.6, 1.7, 1.7);
116+#endif
108117 pix_p = (pix_n + pix_p) * vec3(luma_filter[ii], chroma_filter[ii], chroma_filter[ii]);
109118 signal = signal + pix_p;
110119 addr_p = addr_p - delta;
111120 addr_n = addr_n + delta;
112121 }
113122 #endif
114- vec3 _tmpvar = texture2D(a_texture, fixCoord).xyz;
123+ vec3 texvar = texture2D(a_texture, fixCoord).xyz;
115124 // yMax = (0.299+0.587+0.114) * (+-1.0) * (BRIGHTNESS + ARTIFACTING + ARTIFACTING) * (+-1.0)
116125 // CbMax = (-0.168736 -0.331264 + 0.5) * (+-1.0) * (FRINGING + 2*SATURATION) * (+-1.0)
117126 // CrMax = (0.5 - 0.418688 - 0.081312) * (+-1.0) * (FRINGING + 2*SATURATION) * (+-1.0)
118127 // -> y = 0 to +3.6
119128 // Cb = 0 to +1.7
120129 // Cr = 0 to +1.7
121- _tmpvar = _tmpvar * vec3(3.6, 1.7, 1.7);
122- vec3 texvar = _tmpvar;
130+#ifndef HAS_FLOAT_TEXTURE
131+ texvar = texvar * vec3(3.6, 1.7, 1.7);
132+#endif
123133 signal += texvar * vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
124134 // END "ntsc-pass2-decode.inc" //
125135
126136 vec3 rgb = ycbcr2rgb(signal);
137+#ifndef HAS_FLOAT_TEXTURE
127138 rgb = rgb * vec3(0.67, 1.0, 1.0);
139+#endif
140+
128141 #ifdef GAMMA_CORRECTION
129142 vec3 gamma = vec3(CRT_GAMMA / DISPLAY_GAMMA);
130143 rgb = pow(abs(rgb), gamma.rgb);
--- a/source/src/qt/gui/gles2/qt_glutil_gles_2.cpp
+++ b/source/src/qt/gui/gles2/qt_glutil_gles_2.cpp
@@ -189,7 +189,7 @@ void GLDraw_ES_2::initPackedGLObject(GLScreenPack **p,
189189 QString s;
190190 GLScreenPack *pp;
191191 if(p != NULL) {
192- pp = new GLScreenPack(_width, _height, p_wid);
192+ pp = new GLScreenPack(_width, _height, _name, p_wid);
193193 *p = pp;
194194 if(pp != NULL) {
195195 pp->initialize(_width, _height, vertex_shader, fragment_shader);
@@ -200,6 +200,11 @@ void GLDraw_ES_2::initPackedGLObject(GLScreenPack **p,
200200 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "Fragment: %s ", fragment_shader.toLocal8Bit().constData());
201201 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "%s", s.toLocal8Bit().constData());
202202 }
203+ s = pp->getGLLog();
204+ if(s.size() > 0) {
205+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GL_SHADER, "%s", s.toLocal8Bit().constData());
206+ pp->clearGLLog();
207+ }
203208 }
204209 }
205210 }
Show on old repository browser