Coder Social home page Coder Social logo

Comments (13)

scurest avatar scurest commented on August 11, 2024 1

I can repro the screen being fully black if I hack the snoise functions to always return 0.0. I suspect this is what's happening.

My guess is the GLSL mediump precision on the RPi is actually a float16. From a quick test, it looks like float16s don't have enough precision for the hash function to work (you ends up the fractional part of a number in the range where all fractional parts are 0). This would also explain why it doesn't happen on desktop, where everything is float32.

Can you see if this fixes it?

diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
index 901d17ab..1de49ab1 100644
--- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
+++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
@@ -1007,8 +1007,8 @@ public:
 			"uniform float uNoiseSeed;								\n"
 			"lowp float snoise()									\n"
 			"{														\n"
-			"  mediump vec2 coord = floor(gl_FragCoord.xy/uScreenScale);	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);			\n"
+			"  highp vec2 coord = floor(gl_FragCoord.xy/uScreenScale);	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);			\n"
 			// hash13 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * .1031);								\n"
 			"  p3 += dot(p3, p3.zyx + 31.32);						\n"
@@ -1063,13 +1063,13 @@ public:
 		if (config.generalEmulation.enableHiresNoiseDithering != 0)
 			// multiplier for higher res noise effect
 			m_part +=
-			"  lowp float mult = 1.0 + step(2.0, uScreenScale.x);	\n";
+			"  highp float mult = 1.0 + step(2.0, uScreenScale.x);	\n";
 		else
 			m_part +=
-			"  lowp float mult = 1.0;								\n";
+			"  highp float mult = 1.0;								\n";
 		m_part +=
-			"  mediump vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);				\n"
+			"  highp vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);				\n"
 			// hash33 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * vec3(.1031, .1030, .0973));				\n"
 			"  p3 += dot(p3, p3.yxz+33.33);								\n"
@@ -1081,14 +1081,14 @@ public:
 		if (config.generalEmulation.enableHiresNoiseDithering != 0)
 			// multiplier for higher res noise effect
 			m_part +=
-			"  lowp float mult = 1.0 + step(2.0, uScreenScale.x);	\n";
+			"  highp float mult = 1.0 + step(2.0, uScreenScale.x);	\n";
 		else
 			m_part +=
-			"  lowp float mult = 1.0;								\n";
+			"  highp float mult = 1.0;								\n";
 		m_part +=
 			"														\n"
-			"  mediump vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);			\n"
+			"  highp vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);			\n"
 			// hash13 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * .1031);								\n"
 			"  p3 += dot(p3, p3.zyx + 31.32);						\n"

from gliden64.

cmitu avatar cmitu commented on August 11, 2024 1

@scurest Thank you for the patch - after applying it now video output shows up, no longer a black screen.

from gliden64.

Jj0YzL5nvJ avatar Jj0YzL5nvJ commented on August 11, 2024

Try with:
export MESA_GLSL_CACHE_DISABLE=1

Or clear your shader cache.
rm -rf ${HOME}/.cache/mupen64plus ${HOME}/.cache/mesa_shader_cache

from gliden64.

cmitu avatar cmitu commented on August 11, 2024

No, ignoring/erasing the shader cache doesn't seem to help - I still get a black screen. For a couple of launches, before invalidating the cache, I got a video output. Then, for the subsequent launches, using MESA_GLSL_CACHE_DISABLE=1 and clearing the cache, I got the same black screen.

from gliden64.

Jj0YzL5nvJ avatar Jj0YzL5nvJ commented on August 11, 2024

Then seek for gliden64.log in the mupen64plus configuration folder.

from gliden64.

cmitu avatar cmitu commented on August 11, 2024

Thanks.
The gliden64.log file shows:

2024/05/08,04:09:38.981,opengl_Utils.cpp:60,WARNING, "Could not query EGL extensions on this device"
2024/05/08,04:09:38.981,opengl_Utils.cpp:60,WARNING, "Could not query EGL extensions on this device"

and previously also printed:

2024/05/07,19:27:00.746,glsl_ShaderStorage.cpp:191,ERROR, "Error while writing shader with key key=0x3811FE23FFFFF7FB"
2024/05/07,19:27:00.746,glsl_ShaderStorage.cpp:191,ERROR, "Error while writing shader with key key=0x3851D6A3FFAFFFFF"
2024/05/07,19:27:00.746,glsl_ShaderStorage.cpp:191,ERROR, "Error while writing shader with key key=0x38FFFFFFFFFDF6FB

I think the latter messages have been printed after I cleared the shader cache, the former are printed right now when I start and get a blank video output.

from gliden64.

cmitu avatar cmitu commented on August 11, 2024

@scurest thank you for the patch. Unfortunately it doesn't resolve the issue - still getting a black video. Here's a MESA shader cache dump taken from the start-up - https://gist.github.com/cmitu/57bd70c14e9f6914a96732f5844f1769.

from gliden64.

Jj0YzL5nvJ avatar Jj0YzL5nvJ commented on August 11, 2024

@scurest, can you see #2507 too? I'm available as a guinea pig.

from gliden64.

scurest avatar scurest commented on August 11, 2024

@cmitu Okay, thanks. I notice that if the shader has compilation errors it also produces a black screen. Compilation errors only get logged to gliden64.log in debug builds, ie. you need to pass -DCMAKE_BUILD_TYPE=Debug when you run cmake. Can you make sure you're using a debug build?

You can test whether logging of shader compilation errors is working with a patch like this

diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
index 901d17ab..e04c05bd 100644
--- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
+++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
@@ -1073,7 +1073,7 @@ public:
 			// hash33 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * vec3(.1031, .1030, .0973));				\n"
 			"  p3 += dot(p3, p3.yxz+33.33);								\n"
-			"  return fract((p3.xxy + p3.yxx)*p3.zyx);					\n"
+			"  return adsfhdsakjhfjlksahliurhsadsakjdfhl;				\n"
 			"}															\n"
 			"lowp float snoiseA()									\n"
 			"{														\n"

which will definitely trigger an error.

Also make sure to clear the shader cache before testing.

@Jj0YzL5nvJ I don't understand the connection to this issue.

from gliden64.

Jj0YzL5nvJ avatar Jj0YzL5nvJ commented on August 11, 2024

I don't understand the connection to this issue.

It's very likely a float precision issue as well. That hardware originally only had support for OpenGL 2.0, but later received support for OpenGL 3.3 in software.

It works with EnableInaccurateTextureCoordinates=True but fails with EnableInaccurateTextureCoordinates=False, and not generate errors, I suspect the driver might be truncating the precision of some shaders to maintain performance.

If it were possible to know exactly what the driver doesn't like, a special path/hack could be created for that hardware.

from gliden64.

cmitu avatar cmitu commented on August 11, 2024

Can you make sure you're using a debug build?

Thank you. I've switched to a Debug build and the behavior/logging is changed.

Running the emulator crashes outright because of an assert:

....
Input: Mupen64Plus SDL Input Plugin version 2.5.9 initialized.
RSP: RSP Fallback disabled !
Core Status: Selected state slot: 3
Core: Using video capture backend: dummy
Core: Game controller 0 (Standard controller) has a Memory pak plugged in
Core: Game controller 1 (Standard controller) has a Memory pak plugged in
Core: Game controller 2 (Standard controller) has a Memory pak plugged in
Core: Game controller 3 (Standard controller) has a Memory pak plugged in
Core: Using CIC type X102
Core: Setting video mode: 1280x1024

mupen64plus: /home/pi/RetroPie-Setup/tmp/build/mupen64plus/GLideN64/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp:514: graphics::CombinerProgram* glsl::CombinerProgramBuilder::buildCombinerProgram(Combiner&, Combiner&, const CombinerKey&): Assertion `Utils::checkProgramLinkStatus(program)' failed.

The gliden64.log log file contains the shader linking error - https://pastebin.com/9HV0SBqJ

from gliden64.

scurest avatar scurest commented on August 11, 2024

Please try

diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
index 901d17ab..5ef84042 100644
--- a/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
+++ b/src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilderCommon.cpp
@@ -1004,11 +1004,11 @@ public:
 	ShaderNoise(const opengl::GLInfo & _glinfo)
 	{
 		m_part =
-			"uniform float uNoiseSeed;								\n"
+			"uniform mediump float uNoiseSeed;						\n"
 			"lowp float snoise()									\n"
 			"{														\n"
-			"  mediump vec2 coord = floor(gl_FragCoord.xy/uScreenScale);	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);			\n"
+			"  highp vec2 coord = floor(gl_FragCoord.xy/uScreenScale);	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);			\n"
 			// hash13 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * .1031);								\n"
 			"  p3 += dot(p3, p3.zyx + 31.32);						\n"
@@ -1068,8 +1068,8 @@ public:
 			m_part +=
 			"  lowp float mult = 1.0;								\n";
 		m_part +=
-			"  mediump vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);				\n"
+			"  highp vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);				\n"
 			// hash33 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * vec3(.1031, .1030, .0973));				\n"
 			"  p3 += dot(p3, p3.yxz+33.33);								\n"
@@ -1087,8 +1087,8 @@ public:
 			"  lowp float mult = 1.0;								\n";
 		m_part +=
 			"														\n"
-			"  mediump vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
-			"  mediump vec3 p3 = vec3(uNoiseSeed, coord);			\n"
+			"  highp vec2 coord = floor(mult * (gl_FragCoord.xy/uScreenScale));	\n"
+			"  highp vec3 p3 = vec3(uNoiseSeed, coord);			\n"
 			// hash13 from https://www.shadertoy.com/view/4djSRW
 			"  p3 = fract(p3 * .1031);								\n"
 			"  p3 += dot(p3, p3.zyx + 31.32);						\n"

from gliden64.

Rosalie241 avatar Rosalie241 commented on August 11, 2024

@scurest could you PR that patch? it fixes rendering on my pinebook pro aswell with GLES.

from gliden64.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.