From 60690109f03630a0722cc8b0bba6d99700592785 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Apr 2021 13:32:13 -0700 Subject: [PATCH 1/5] GLES: Handle GLSL 1.30/1.40 better. Was causing errors for people using older GL. --- Common/GPU/OpenGL/thin3d_gl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 29e8283d53..0acb176dea 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -641,8 +641,12 @@ OpenGLContext::OpenGLContext() { } else if (gl_extensions.VersionGEThan(3, 0, 0)) { shaderLanguageDesc_.shaderLanguage = ShaderLanguage::GLSL_1xx; shaderLanguageDesc_.fragColor0 = "fragColor0"; + shaderLanguageDesc_.texture = "texture"; shaderLanguageDesc_.bitwiseOps = true; shaderLanguageDesc_.texelFetch = "texelFetch"; + shaderLanguageDesc_.varying_vs = "out"; + shaderLanguageDesc_.varying_fs = "in"; + shaderLanguageDesc_.attribute = "in"; } else { // This too... shaderLanguageDesc_.shaderLanguage = ShaderLanguage::GLSL_1xx; From 9a812f7f0baccb5b6c1d730e8b215e53a5578c2f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Apr 2021 13:41:41 -0700 Subject: [PATCH 2/5] Shaders: Set vert shaders to mediump by default. Seeing errors in logs about precision not agreeing. --- assets/shaders/4xhqglsl.vsh | 5 +++++ assets/shaders/5xBR.vsh | 6 ++++++ assets/shaders/aacolor.vsh | 5 +++++ assets/shaders/cartoon.vsh | 5 +++++ assets/shaders/fxaa.vsh | 5 +++++ assets/shaders/natural.vsh | 5 +++++ assets/shaders/naturalA.vsh | 25 +++++++++++++++---------- assets/shaders/upscale_spline36.vsh | 5 +++++ 8 files changed, 51 insertions(+), 10 deletions(-) diff --git a/assets/shaders/4xhqglsl.vsh b/assets/shaders/4xhqglsl.vsh index 128512e413..3ed7ccda8e 100644 --- a/assets/shaders/4xhqglsl.vsh +++ b/assets/shaders/4xhqglsl.vsh @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; uniform vec2 u_texelDelta; diff --git a/assets/shaders/5xBR.vsh b/assets/shaders/5xBR.vsh index b3649d47d0..01e85aab98 100644 --- a/assets/shaders/5xBR.vsh +++ b/assets/shaders/5xBR.vsh @@ -18,6 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; varying vec2 v_texcoord0; diff --git a/assets/shaders/aacolor.vsh b/assets/shaders/aacolor.vsh index 85fecb4640..97199877e0 100644 --- a/assets/shaders/aacolor.vsh +++ b/assets/shaders/aacolor.vsh @@ -1,6 +1,11 @@ // by guest(r) - guest.r@gmail.com // license: GNU-GPL +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; uniform vec2 u_texelDelta; diff --git a/assets/shaders/cartoon.vsh b/assets/shaders/cartoon.vsh index 13a5b0ae3c..701ce8f74f 100644 --- a/assets/shaders/cartoon.vsh +++ b/assets/shaders/cartoon.vsh @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; uniform vec2 u_texelDelta; diff --git a/assets/shaders/fxaa.vsh b/assets/shaders/fxaa.vsh index 49295bb532..0c93df96f0 100644 --- a/assets/shaders/fxaa.vsh +++ b/assets/shaders/fxaa.vsh @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; varying vec2 v_texcoord0; diff --git a/assets/shaders/natural.vsh b/assets/shaders/natural.vsh index 34402d93de..cebb5f7c43 100644 --- a/assets/shaders/natural.vsh +++ b/assets/shaders/natural.vsh @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + uniform vec2 u_texelDelta; attribute vec4 a_position; diff --git a/assets/shaders/naturalA.vsh b/assets/shaders/naturalA.vsh index ebad6e2724..8e52bc055f 100644 --- a/assets/shaders/naturalA.vsh +++ b/assets/shaders/naturalA.vsh @@ -1,10 +1,15 @@ -attribute vec4 a_position; -attribute vec2 a_texcoord0; - -varying vec2 v_texcoord0; - -void main() -{ - gl_Position=a_position; - v_texcoord0=a_texcoord0; -} +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +attribute vec4 a_position; +attribute vec2 a_texcoord0; + +varying vec2 v_texcoord0; + +void main() +{ + gl_Position=a_position; + v_texcoord0=a_texcoord0; +} diff --git a/assets/shaders/upscale_spline36.vsh b/assets/shaders/upscale_spline36.vsh index 4b47d816cb..77d2f36f15 100644 --- a/assets/shaders/upscale_spline36.vsh +++ b/assets/shaders/upscale_spline36.vsh @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + attribute vec4 a_position; attribute vec2 a_texcoord0; From c18236b5fa4fc334d005c1cd94b7b789525ee303 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Apr 2021 14:01:33 -0700 Subject: [PATCH 3/5] GPU: Avoid switch on uint. Vivante seems to get confused. --- GPU/Common/FragmentShaderGenerator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 2d8c52b594..3fc0e16ffc 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -589,8 +589,8 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " uint depalOffset = ((u_depal_mask_shift_off_fmt >> 16) & 0xFFU) << 4;\n"); WRITE(p, " uint depalFmt = (u_depal_mask_shift_off_fmt >> 24) & 0x3U;\n"); WRITE(p, " uvec4 col; uint index0; uint index1; uint index2; uint index3;\n"); - WRITE(p, " switch (depalFmt) {\n"); // We might want to include fmt in the shader ID if this is a performance issue. - WRITE(p, " case 0U:\n"); // 565 + WRITE(p, " switch (int(depalFmt)) {\n"); // We might want to include fmt in the shader ID if this is a performance issue. + WRITE(p, " case 0:\n"); // 565 WRITE(p, " col = uvec4(t.rgb * vec3(31.99, 63.99, 31.99), 0);\n"); WRITE(p, " index0 = (col.b << 11) | (col.g << 5) | (col.r);\n"); WRITE(p, " if (bilinear) {\n"); @@ -602,7 +602,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " index3 = (col.b << 11) | (col.g << 5) | (col.r);\n"); WRITE(p, " }\n"); WRITE(p, " break;\n"); - WRITE(p, " case 1U:\n"); // 5551 + WRITE(p, " case 1:\n"); // 5551 WRITE(p, " col = uvec4(t.rgba * vec4(31.99, 31.99, 31.99, 1.0));\n"); WRITE(p, " index0 = (col.a << 15) | (col.b << 10) | (col.g << 5) | (col.r);\n"); WRITE(p, " if (bilinear) {\n"); @@ -614,7 +614,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " index3 = (col.a << 15) | (col.b << 10) | (col.g << 5) | (col.r);\n"); WRITE(p, " }\n"); WRITE(p, " break;\n"); - WRITE(p, " case 2U:\n"); // 4444 + WRITE(p, " case 2:\n"); // 4444 WRITE(p, " col = uvec4(t.rgba * 15.99);\n"); WRITE(p, " index0 = (col.a << 12) | (col.b << 8) | (col.g << 4) | (col.r);\n"); WRITE(p, " if (bilinear) {\n"); @@ -626,7 +626,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " index3 = (col.a << 12) | (col.b << 8) | (col.g << 4) | (col.r);\n"); WRITE(p, " }\n"); WRITE(p, " break;\n"); - WRITE(p, " case 3U:\n"); // 8888 + WRITE(p, " case 3:\n"); // 8888 WRITE(p, " col = uvec4(t.rgba * 255.99);\n"); WRITE(p, " index0 = (col.a << 24) | (col.b << 16) | (col.g << 8) | (col.r);\n"); WRITE(p, " if (bilinear) {\n"); From 1b4f0e25b7ab474d173c147d059f752e46c8aa01 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Apr 2021 15:11:44 -0700 Subject: [PATCH 4/5] Reporting: Log more data about sceIoChStat(). --- Core/HLE/sceIo.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 16ee5c1891..7706c08620 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -949,11 +949,15 @@ static u32 sceIoGetstat(const char *filename, u32 addr) { } static u32 sceIoChstat(const char *filename, u32 iostatptr, u32 changebits) { + auto iostat = PSPPointer::Create(iostatptr); + if (!iostat.IsValid()) + return hleReportError(SCEIO, SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT, "bad address"); + ERROR_LOG_REPORT(SCEIO, "UNIMPL sceIoChstat(%s, %08x, %08x)", filename, iostatptr, changebits); if (changebits & SCE_CST_MODE) - ERROR_LOG(SCEIO, "sceIoChstat: change mode requested"); + ERROR_LOG_REPORT(SCEIO, "sceIoChstat: change mode to %03o requested", iostat->st_mode); if (changebits & SCE_CST_ATTR) - ERROR_LOG(SCEIO, "sceIoChstat: change attr requested"); + ERROR_LOG_REPORT(SCEIO, "sceIoChstat: change attr to %04x requested", iostat->st_attr); if (changebits & SCE_CST_SIZE) ERROR_LOG(SCEIO, "sceIoChstat: change size requested"); if (changebits & SCE_CST_CT) @@ -961,7 +965,7 @@ static u32 sceIoChstat(const char *filename, u32 iostatptr, u32 changebits) { if (changebits & SCE_CST_AT) ERROR_LOG(SCEIO, "sceIoChstat: change access time requested"); if (changebits & SCE_CST_MT) - ERROR_LOG(SCEIO, "sceIoChstat: change modification time requested"); + ERROR_LOG_REPORT(SCEIO, "sceIoChstat: change modification time to %04d-%02d-%02d requested", iostat->st_m_time.year, iostat->st_m_time.month, iostat->st_m_time.day); if (changebits & SCE_CST_PRVT) ERROR_LOG(SCEIO, "sceIoChstat: change private data requested"); return 0; From 3c09b5c01013247bcad526e01480a2b59db3ee3f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 10 Apr 2021 16:26:39 -0700 Subject: [PATCH 5/5] GLES: Always use fragColor0 on GL 3.0+. --- Common/GPU/OpenGL/GLQueueRunner.cpp | 2 +- GPU/Common/DepalettizeShaderCommon.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 487a335dd0..3f3dec4c4d 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -199,7 +199,7 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski // Dual source alpha glBindFragDataLocationIndexed(program->program, 0, 0, "fragColor0"); glBindFragDataLocationIndexed(program->program, 0, 1, "fragColor1"); - } else if (gl_extensions.VersionGEThan(3, 3, 0)) { + } else if (gl_extensions.VersionGEThan(3, 0, 0)) { glBindFragDataLocation(program->program, 0, "fragColor0"); } #elif !PPSSPP_PLATFORM(IOS) diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 11236f1f9a..11c598a7f0 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -292,7 +292,7 @@ void GenerateDepalShaderFloat(char *buffer, GEBufferFormat pixelFormat, ShaderLa WRITE(p, "precision mediump float;\n"); } else { WRITE(p, "#version %d\n", gl_extensions.GLSLVersion()); - if (gl_extensions.VersionGEThan(3, 3)) { + if (gl_extensions.VersionGEThan(3, 0, 0)) { WRITE(p, "#define gl_FragColor fragColor0\n"); WRITE(p, "out vec4 fragColor0;\n"); }