[Scummvm-git-logs] scummvm master -> 76eda43fb5d1ca87d47b8029f913d2e775fb81da
lephilousophe
noreply at scummvm.org
Sun Apr 17 10:34:42 UTC 2022
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
41638a09d1 AMIGAOS: Let user select the OpenGL implementation
7061b4109e AMIGAOS: Remove outdated ifdefs
c9b4949746 AMIGAOS: Improve shader compatibility
76eda43fb5 AMIGAOS: Install shaders files as well
Commit: 41638a09d119e43ec45fb788a0881f6d7fe72d0a
https://github.com/scummvm/scummvm/commit/41638a09d119e43ec45fb788a0881f6d7fe72d0a
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-17T12:34:38+02:00
Commit Message:
AMIGAOS: Let user select the OpenGL implementation
Changed paths:
backends/platform/sdl/amigaos/amigaos.cpp
backends/platform/sdl/amigaos/amigaos.h
diff --git a/backends/platform/sdl/amigaos/amigaos.cpp b/backends/platform/sdl/amigaos/amigaos.cpp
index 04f89798d25..a64d11b165c 100644
--- a/backends/platform/sdl/amigaos/amigaos.cpp
+++ b/backends/platform/sdl/amigaos/amigaos.cpp
@@ -47,4 +47,58 @@ bool OSystem_AmigaOS::hasFeature(Feature f) {
return OSystem_SDL::hasFeature(f);
}
+
+void OSystem_AmigaOS::initBackend() {
+ // AmigaOS4 SDL provides two OpenGL implementations (OpenGL 1.3 with miniGL and OpenGL ES with OGLES2)
+ // This is chosen by setting the profile mask attribute before the first window creation but after init
+ int force = 0;
+ if (ConfMan.hasKey("opengl_implementation")) {
+ Common::String implem = ConfMan.get("opengl_implementation");
+ if (implem == "gl") {
+ force = 1;;
+ } else if (implem == "gles2") {
+ force = 2;
+ }
+ }
+
+ // If not forcing, try OGLES2 first
+ if (!force || force == 2) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+ if (SDL_GL_LoadLibrary(NULL) < 0) {
+ if (force) {
+ warning("OpenGL implementation chosen is unsupported, falling back");
+ force = 0;
+ }
+ // SDL doesn't seem to be clean when loading fail
+ SDL_GL_UnloadLibrary();
+ SDL_GL_ResetAttributes();
+ } else {
+ // Loading succeeded, don't try anything more
+ force = 2;
+ }
+ }
+ // If not forcing, next try miniGL
+ if (!force || force == 1) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
+ if (SDL_GL_LoadLibrary(NULL) < 0) {
+ if (force) {
+ warning("OpenGL implementation chosen is unsupported, falling back");
+ force = 0;
+ }
+ // SDL doesn't seem to be clean when loading fail
+ SDL_GL_UnloadLibrary();
+ SDL_GL_ResetAttributes();
+ } else {
+ // Loading succeeded, don't try anything more
+ force = 1;
+ }
+ }
+
+ OSystem_SDL::initBackend();
+}
+
#endif
diff --git a/backends/platform/sdl/amigaos/amigaos.h b/backends/platform/sdl/amigaos/amigaos.h
index 20892bfcb5a..32cb85f8d30 100644
--- a/backends/platform/sdl/amigaos/amigaos.h
+++ b/backends/platform/sdl/amigaos/amigaos.h
@@ -32,6 +32,7 @@ public:
bool hasFeature(Feature f) override;
void init() override;
+ void initBackend() override;
};
#endif
Commit: 7061b4109e64ba4e34ef3b9c0bb97c06d34c608b
https://github.com/scummvm/scummvm/commit/7061b4109e64ba4e34ef3b9c0bb97c06d34c608b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-17T12:34:38+02:00
Commit Message:
AMIGAOS: Remove outdated ifdefs
We now link with OpenGL dynamically so symbols are provided by GLAD.
If it's not supported pointer will be null.
OGLES2 should support these functions so they must be removed
Changed paths:
backends/graphics3d/opengl/framebuffer.cpp
backends/graphics3d/opengl/framebuffer.h
backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
backends/platform/sdl/sdl.cpp
diff --git a/backends/graphics3d/opengl/framebuffer.cpp b/backends/graphics3d/opengl/framebuffer.cpp
index ea23a64e235..f757a661f9a 100644
--- a/backends/graphics3d/opengl/framebuffer.cpp
+++ b/backends/graphics3d/opengl/framebuffer.cpp
@@ -22,7 +22,7 @@
#include "common/textconsole.h"
#include "common/util.h"
-#if (defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)) && !defined(AMIGAOS) && !defined(__MORPHOS__)
+#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
#include "backends/graphics3d/opengl/framebuffer.h"
@@ -124,7 +124,7 @@ void FrameBuffer::detach() {
glViewport(_prevStateViewport[0], _prevStateViewport[1], _prevStateViewport[2], _prevStateViewport[3]);
}
-#if !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
+#if !USE_FORCED_GLES2
MultiSampleFrameBuffer::MultiSampleFrameBuffer(uint width, uint height, int samples)
: FrameBuffer(width,height) {
if (!OpenGLContext.framebufferObjectMultisampleSupported) {
@@ -186,7 +186,7 @@ void MultiSampleFrameBuffer::detach() {
glViewport(_prevStateViewport[0], _prevStateViewport[1], _prevStateViewport[2], _prevStateViewport[3]);
}
-#endif // !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
+#endif // !USE_FORCED_GLES2
} // End of namespace OpenGL
diff --git a/backends/graphics3d/opengl/framebuffer.h b/backends/graphics3d/opengl/framebuffer.h
index 84189a8d4b7..976e59c8b09 100644
--- a/backends/graphics3d/opengl/framebuffer.h
+++ b/backends/graphics3d/opengl/framebuffer.h
@@ -34,17 +34,10 @@ class FrameBuffer : public TextureGL {
public:
FrameBuffer(uint width, uint height);
FrameBuffer(GLuint texture_name, uint width, uint height, uint texture_width, uint texture_height);
-#if defined(AMIGAOS) || defined(__MORPHOS__)
- virtual ~FrameBuffer() {}
-
- void attach() {}
- void detach() {}
-#else
virtual ~FrameBuffer();
virtual void attach();
virtual void detach();
-#endif
protected:
GLuint getFrameBufferName() const { return _frameBuffer; }
@@ -56,7 +49,7 @@ private:
GLint _prevStateViewport[4];
};
-#if !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
+#if !USE_FORCED_GLES2
class MultiSampleFrameBuffer : public FrameBuffer {
public:
MultiSampleFrameBuffer(uint width, uint height, int samples);
diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
index aef35b94f70..fa827e0d709 100644
--- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
+++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
@@ -356,13 +356,11 @@ void OpenGLSdlGraphics3dManager::createOrUpdateScreen() {
_screenChangeCount++;
-#if !defined(__amigaos4__) && !defined(__MORPHOS__)
if (renderToFrameBuffer) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
_frameBuffer = createFramebuffer(_engineRequestedWidth, _engineRequestedHeight);
_frameBuffer->attach();
}
-#endif
}
Math::Rect2d OpenGLSdlGraphics3dManager::computeGameRect(bool renderToFrameBuffer, uint gameWidth, uint gameHeight,
@@ -579,7 +577,6 @@ void OpenGLSdlGraphics3dManager::drawOverlay() {
_surfaceRenderer->restorePreviousState();
}
-#if !defined(__amigaos4__) && !defined(__MORPHOS__)
OpenGL::FrameBuffer *OpenGLSdlGraphics3dManager::createFramebuffer(uint width, uint height) {
#if !USE_FORCED_GLES2
if (_antialiasing && OpenGLContext.framebufferObjectMultisampleSupported) {
@@ -590,7 +587,6 @@ OpenGL::FrameBuffer *OpenGLSdlGraphics3dManager::createFramebuffer(uint width, u
return new OpenGL::FrameBuffer(width, height);
}
}
-#endif
void OpenGLSdlGraphics3dManager::updateScreen() {
if (_frameBuffer) {
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 8f01465d373..d5b6b453240 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -328,7 +328,7 @@ void OSystem_SDL::detectOpenGLFeaturesSupport() {
_oglType = OpenGL::kOGLContextGLES2;
_supportsFrameBuffer = true;
_supportsShaders = true;
-#elif !defined(AMIGAOS) && !defined(__MORPHOS__)
+#else
// Spawn a 32x32 window off-screen with a GL context to test if framebuffers are supported
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Window *window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 32, 32, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
Commit: c9b4949746ef86eb1d35ba39efaa2f63f37b596b
https://github.com/scummvm/scummvm/commit/c9b4949746ef86eb1d35ba39efaa2f63f37b596b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-17T12:34:38+02:00
Commit Message:
AMIGAOS: Improve shader compatibility
OGLES2 doesn't support uniform booleans so we use macros to make it use
integers in this case. For other platforms, this change should be a
noop.
OGLES2 doesn't like float suffix for constants, remove it as well.
Changed paths:
backends/graphics3d/opengl/surfacerenderer.cpp
engines/grim/shaders/emi_actor.fragment
engines/grim/shaders/emi_actor.vertex
engines/grim/shaders/emi_actorlights.fragment
engines/grim/shaders/emi_actorlights.vertex
engines/grim/shaders/emi_sprite.fragment
engines/grim/shaders/emi_sprite.vertex
engines/grim/shaders/grim_actor.fragment
engines/grim/shaders/grim_actor.vertex
engines/grim/shaders/grim_actorlights.fragment
engines/grim/shaders/grim_actorlights.vertex
engines/grim/shaders/grim_smush.fragment
engines/myst3/shaders/myst3_box.fragment
engines/myst3/shaders/myst3_box.vertex
engines/playground3d/shaders/playground3d_cube.fragment
engines/playground3d/shaders/playground3d_cube.vertex
engines/stark/shaders/stark_actor.fragment
engines/stark/shaders/stark_actor.vertex
engines/stark/shaders/stark_prop.fragment
engines/stark/shaders/stark_prop.vertex
engines/stark/shaders/stark_surface.vertex
engines/wintermute/base/gfx/opengl/shaders/wme_line.vertex
engines/wintermute/base/gfx/opengl/shaders/wme_sprite.fragment
graphics/opengl/shader.cpp
diff --git a/backends/graphics3d/opengl/surfacerenderer.cpp b/backends/graphics3d/opengl/surfacerenderer.cpp
index 6e6ac1c8207..4fa46c50324 100644
--- a/backends/graphics3d/opengl/surfacerenderer.cpp
+++ b/backends/graphics3d/opengl/surfacerenderer.cpp
@@ -178,14 +178,23 @@ static const char *boxVertex =
"uniform vec2 offsetXY;\n"
"uniform vec2 sizeWH;\n"
"uniform vec2 texcrop;\n"
+// OGLES2 on AmigaOS doesn't support uniform booleans
+#if defined(AMIGAOS)
+ "uniform mediump int flipY;\n"
+#else
"uniform bool flipY;\n"
+#endif
"varying vec2 Texcoord;\n"
"void main() {\n"
"Texcoord = texcoord * texcrop;\n"
"vec2 pos = offsetXY + position * sizeWH;\n"
"pos.x = pos.x * 2.0 - 1.0;\n"
"pos.y = pos.y * 2.0 - 1.0;\n"
+#if defined(AMIGAOS)
+ "if (flipY != 0)\n"
+#else
"if (flipY)\n"
+#endif
"pos.y *= -1.0;\n"
"gl_Position = vec4(pos, 0.0, 1.0);\n"
"}\n";
diff --git a/engines/grim/shaders/emi_actor.fragment b/engines/grim/shaders/emi_actor.fragment
index 7616331a0ef..fff000875db 100644
--- a/engines/grim/shaders/emi_actor.fragment
+++ b/engines/grim/shaders/emi_actor.fragment
@@ -2,7 +2,7 @@ in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
-uniform bool textured;
+uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
@@ -11,7 +11,7 @@ OUTPUT
void main()
{
outColor = Color;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
diff --git a/engines/grim/shaders/emi_actor.vertex b/engines/grim/shaders/emi_actor.vertex
index 23bc72a6387..857a4a12ea1 100644
--- a/engines/grim/shaders/emi_actor.vertex
+++ b/engines/grim/shaders/emi_actor.vertex
@@ -9,12 +9,12 @@ uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
-uniform bool textured;
-uniform bool useVertexAlpha;
+uniform UBOOL textured;
+uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
struct shadow_info {
- bool _active;
+ UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
@@ -32,7 +32,7 @@ void main()
pos = modelMatrix * pos;
// See http://en.wikipedia.org/wiki/Line-plane_intersection
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
@@ -49,15 +49,15 @@ void main()
gl_Position = projectedPos;
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
- if (!useVertexAlpha)
+ if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
diff --git a/engines/grim/shaders/emi_actorlights.fragment b/engines/grim/shaders/emi_actorlights.fragment
index 7616331a0ef..fff000875db 100644
--- a/engines/grim/shaders/emi_actorlights.fragment
+++ b/engines/grim/shaders/emi_actorlights.fragment
@@ -2,7 +2,7 @@ in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
-uniform bool textured;
+uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
@@ -11,7 +11,7 @@ OUTPUT
void main()
{
outColor = Color;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
diff --git a/engines/grim/shaders/emi_actorlights.vertex b/engines/grim/shaders/emi_actorlights.vertex
index 0b358c1eab1..22a9dc41e29 100644
--- a/engines/grim/shaders/emi_actorlights.vertex
+++ b/engines/grim/shaders/emi_actorlights.vertex
@@ -9,10 +9,10 @@ uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
-uniform bool textured;
-uniform bool useVertexAlpha;
+uniform UBOOL textured;
+uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
-uniform bool hasAmbient;
+uniform UBOOL hasAmbient;
const int maxLights = 8;
uniform vec4 lightsPosition[maxLights];
@@ -21,7 +21,7 @@ uniform vec4 lightsColor[maxLights];
uniform vec4 lightsParams[maxLights];
struct shadow_info {
- bool _active;
+ UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
@@ -39,7 +39,7 @@ void main()
pos = modelMatrix * pos;
// See http://en.wikipedia.org/wiki/Line-plane_intersection
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
@@ -56,15 +56,15 @@ void main()
gl_Position = projectedPos;
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
- if (!useVertexAlpha)
+ if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
@@ -109,7 +109,7 @@ void main()
light += lightsColor[i].xyz * intensity;
}
- if (!hasAmbient)
+ if (!UBOOL_TEST(hasAmbient))
light += vec3(0.5, 0.5, 0.5);
light /= max(1.0, max(max(light.x, light.y), light.z));
Color *= vec4(light, 1.0);
diff --git a/engines/grim/shaders/emi_sprite.fragment b/engines/grim/shaders/emi_sprite.fragment
index 7616331a0ef..fff000875db 100644
--- a/engines/grim/shaders/emi_sprite.fragment
+++ b/engines/grim/shaders/emi_sprite.fragment
@@ -2,7 +2,7 @@ in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
-uniform bool textured;
+uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
@@ -11,7 +11,7 @@ OUTPUT
void main()
{
outColor = Color;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
diff --git a/engines/grim/shaders/emi_sprite.vertex b/engines/grim/shaders/emi_sprite.vertex
index 1bf6003c86e..08d813727e6 100644
--- a/engines/grim/shaders/emi_sprite.vertex
+++ b/engines/grim/shaders/emi_sprite.vertex
@@ -9,12 +9,12 @@ uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
-uniform bool textured;
-uniform bool useVertexAlpha;
+uniform UBOOL textured;
+uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
struct shadow_info {
- bool _active;
+ UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
@@ -43,15 +43,15 @@ void main()
gl_Position = projectedPos;
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
- if (!useVertexAlpha)
+ if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
diff --git a/engines/grim/shaders/grim_actor.fragment b/engines/grim/shaders/grim_actor.fragment
index a19c9dc5296..1be9ee2fbff 100644
--- a/engines/grim/shaders/grim_actor.fragment
+++ b/engines/grim/shaders/grim_actor.fragment
@@ -3,8 +3,8 @@ in vec4 Color;
uniform sampler2D tex;
uniform sampler2D texZBuf;
-uniform bool textured;
-uniform bool hasZBuffer;
+uniform UBOOL textured;
+uniform UBOOL hasZBuffer;
uniform vec2 texcropZBuf;
uniform vec2 screenSize;
uniform float alphaRef;
@@ -35,10 +35,10 @@ void checkZBuffer()
void main()
{
- if (hasZBuffer)
+ if (UBOOL_TEST(hasZBuffer))
checkZBuffer();
outColor = Color;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
diff --git a/engines/grim/shaders/grim_actor.vertex b/engines/grim/shaders/grim_actor.vertex
index 9ae08ba008a..da963f1eef1 100644
--- a/engines/grim/shaders/grim_actor.vertex
+++ b/engines/grim/shaders/grim_actor.vertex
@@ -11,12 +11,12 @@ uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
-uniform bool textured;
-uniform bool lightsEnabled;
+uniform UBOOL textured;
+uniform UBOOL lightsEnabled;
uniform highp vec2 texScale;
struct shadow_info {
- bool _active;
+ UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
@@ -33,7 +33,7 @@ void main()
vec4 pos = modelMatrix * extraMatrix * vec4(position, 1.0);
// See http://en.wikipedia.org/wiki/Line-plane_intersection
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
@@ -44,13 +44,13 @@ void main()
vec4 positionView = viewMatrix * pos;
gl_Position = projMatrix * positionView;
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Texcoord = vec2(0.0, 1.0) + (texcoord / texScale);
} else {
Texcoord = vec2(0.0, 0.0);
diff --git a/engines/grim/shaders/grim_actorlights.fragment b/engines/grim/shaders/grim_actorlights.fragment
index a19c9dc5296..1be9ee2fbff 100644
--- a/engines/grim/shaders/grim_actorlights.fragment
+++ b/engines/grim/shaders/grim_actorlights.fragment
@@ -3,8 +3,8 @@ in vec4 Color;
uniform sampler2D tex;
uniform sampler2D texZBuf;
-uniform bool textured;
-uniform bool hasZBuffer;
+uniform UBOOL textured;
+uniform UBOOL hasZBuffer;
uniform vec2 texcropZBuf;
uniform vec2 screenSize;
uniform float alphaRef;
@@ -35,10 +35,10 @@ void checkZBuffer()
void main()
{
- if (hasZBuffer)
+ if (UBOOL_TEST(hasZBuffer))
checkZBuffer();
outColor = Color;
- if (textured) {
+ if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
diff --git a/engines/grim/shaders/grim_actorlights.vertex b/engines/grim/shaders/grim_actorlights.vertex
index 5aa36a7170c..d6bf95f62a7 100644
--- a/engines/grim/shaders/grim_actorlights.vertex
+++ b/engines/grim/shaders/grim_actorlights.vertex
@@ -11,8 +11,8 @@ uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
-uniform bool textured;
-uniform bool lightsEnabled;
+uniform UBOOL textured;
+uniform UBOOL lightsEnabled;
uniform highp vec2 texScale;
const int maxLights = 8;
@@ -22,7 +22,7 @@ uniform vec4 lightsColor[maxLights];
uniform vec4 lightsParams[maxLights];
struct shadow_info {
- bool _active;
+ UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
@@ -39,7 +39,7 @@ void main()
vec4 pos = modelMatrix * extraMatrix * vec4(position, 1.0);
// See http://en.wikipedia.org/wiki/Line-plane_intersection
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
@@ -50,13 +50,13 @@ void main()
vec4 positionView = viewMatrix * pos;
gl_Position = projMatrix * positionView;
- if (shadow._active) {
+ if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Texcoord = vec2(0.0, 1.0) + (texcoord / texScale);
} else {
Texcoord = vec2(0.0, 0.0);
diff --git a/engines/grim/shaders/grim_smush.fragment b/engines/grim/shaders/grim_smush.fragment
index 43ce93e2a1f..e55e9bf8b4b 100644
--- a/engines/grim/shaders/grim_smush.fragment
+++ b/engines/grim/shaders/grim_smush.fragment
@@ -3,13 +3,13 @@ in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
-uniform bool swap;
-uniform bool swizzle;
+uniform UBOOL swap;
+uniform UBOOL swizzle;
void main()
{
vec4 color = texture(tex, Texcoord);
- if (swap) color.rgba = color.abgr;
- if (swizzle) color.rgba = color.bgra;
+ if (UBOOL_TEST(swap)) color.rgba = color.abgr;
+ if (UBOOL_TEST(swizzle)) color.rgba = color.bgra;
outColor = vec4(color.rgb, 1.0);
}
diff --git a/engines/myst3/shaders/myst3_box.fragment b/engines/myst3/shaders/myst3_box.fragment
index 9098e7e3b64..694626fee84 100644
--- a/engines/myst3/shaders/myst3_box.fragment
+++ b/engines/myst3/shaders/myst3_box.fragment
@@ -2,13 +2,13 @@ in vec2 Texcoord;
OUTPUT
-uniform bool textured;
+uniform UBOOL textured;
uniform vec4 color;
uniform sampler2D tex;
void main()
{
outColor = color;
- if (textured)
+ if (UBOOL_TEST(textured))
outColor = outColor * texture(tex, Texcoord);
}
diff --git a/engines/myst3/shaders/myst3_box.vertex b/engines/myst3/shaders/myst3_box.vertex
index b4b6261e357..8d1a5c364fd 100644
--- a/engines/myst3/shaders/myst3_box.vertex
+++ b/engines/myst3/shaders/myst3_box.vertex
@@ -5,7 +5,7 @@ uniform vec2 texOffsetXY;
uniform vec2 texSizeWH;
uniform vec2 verOffsetXY;
uniform vec2 verSizeWH;
-uniform bool flipY;
+uniform UBOOL flipY;
out vec2 Texcoord;
@@ -18,7 +18,7 @@ void main()
pos.x = pos.x * 2.0 - 1.0;
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
- if (flipY) {
+ if (UBOOL_TEST(flipY)) {
pos.y *= -1.0;
}
diff --git a/engines/playground3d/shaders/playground3d_cube.fragment b/engines/playground3d/shaders/playground3d_cube.fragment
index d6917e6b253..74f52fc0f65 100644
--- a/engines/playground3d/shaders/playground3d_cube.fragment
+++ b/engines/playground3d/shaders/playground3d_cube.fragment
@@ -3,12 +3,12 @@ in vec3 Color;
OUTPUT
-uniform bool textured;
+uniform UBOOL textured;
uniform sampler2D tex;
void main() {
outColor = vec4(Color, 1.0);
- if (textured) {
+ if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
}
diff --git a/engines/playground3d/shaders/playground3d_cube.vertex b/engines/playground3d/shaders/playground3d_cube.vertex
index 05f4126c82f..21968aca7f7 100644
--- a/engines/playground3d/shaders/playground3d_cube.vertex
+++ b/engines/playground3d/shaders/playground3d_cube.vertex
@@ -7,7 +7,7 @@ uniform mat4 mvpMatrix;
uniform mat4 projMatrix;
uniform mat4 modelMatrix;
uniform mat4 rotateMatrix;
-uniform bool textured;
+uniform UBOOL textured;
uniform vec3 modelPos;
out vec2 Texcoord;
@@ -19,7 +19,7 @@ void main() {
vec4 pos = rotateMatrix * vec4(position, 1.0);
gl_Position = mvpMatrix * (pos + vec4(modelPos, 1.0));
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Color = vec3(1.0);
} else {
Color = color;
diff --git a/engines/stark/shaders/stark_actor.fragment b/engines/stark/shaders/stark_actor.fragment
index a08c78d9ef3..425e7a974ee 100644
--- a/engines/stark/shaders/stark_actor.fragment
+++ b/engines/stark/shaders/stark_actor.fragment
@@ -3,13 +3,13 @@ in vec3 Color;
OUTPUT
-uniform bool textured;
+uniform UBOOL textured;
uniform sampler2D tex;
void main() {
outColor = vec4(Color, 1.0);
- if (textured) {
+ if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
}
diff --git a/engines/stark/shaders/stark_actor.vertex b/engines/stark/shaders/stark_actor.vertex
index dbfd0893dc9..ff5ae48fc0f 100644
--- a/engines/stark/shaders/stark_actor.vertex
+++ b/engines/stark/shaders/stark_actor.vertex
@@ -31,7 +31,7 @@ uniform vec3 bonePosition[maxBones];
uniform Light lights[maxLights];
uniform vec3 ambientColor;
uniform vec3 color;
-uniform bool textured;
+uniform UBOOL textured;
vec4 eyePosition;
vec3 eyeNormal;
@@ -94,7 +94,7 @@ void main()
gl_Position = projectionMatrix * eyePosition;
// Set the initial vertex color
- if (textured) {
+ if (UBOOL_TEST(textured)) {
Color = vec3(1.0);
} else {
Color = color;
diff --git a/engines/stark/shaders/stark_prop.fragment b/engines/stark/shaders/stark_prop.fragment
index 2ba2a37630e..c2799568b32 100644
--- a/engines/stark/shaders/stark_prop.fragment
+++ b/engines/stark/shaders/stark_prop.fragment
@@ -3,14 +3,14 @@ in vec3 Color;
OUTPUT
-uniform bool textured;
+uniform UBOOL textured;
uniform vec3 color;
uniform sampler2D tex;
void main() {
outColor = vec4(Color, 1.0);
- if (textured) {
+ if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
} else {
outColor *= vec4(color, 1.0);
diff --git a/engines/stark/shaders/stark_prop.vertex b/engines/stark/shaders/stark_prop.vertex
index 8ea49401aad..edd39b4e569 100644
--- a/engines/stark/shaders/stark_prop.vertex
+++ b/engines/stark/shaders/stark_prop.vertex
@@ -21,7 +21,7 @@ const int maxLights = 10;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat3 normalMatrix;
-uniform bool doubleSided;
+uniform UBOOL doubleSided;
uniform vec3 ambientColor;
uniform Light lights[maxLights];
@@ -62,7 +62,7 @@ vec3 spotLight(vec3 position, vec3 color, float falloffNear, float falloffFar, v
}
void main() {
- if (doubleSided) {
+ if (UBOOL_TEST(doubleSided)) {
Texcoord = vec2(texcoord.x, 1.0 - texcoord.y);
} else {
Texcoord = vec2(1.0 - texcoord.x, 1.0 - texcoord.y);
diff --git a/engines/stark/shaders/stark_surface.vertex b/engines/stark/shaders/stark_surface.vertex
index d80b022bb2c..415c77fc295 100644
--- a/engines/stark/shaders/stark_surface.vertex
+++ b/engines/stark/shaders/stark_surface.vertex
@@ -4,7 +4,7 @@ in vec2 texcoord;
uniform vec2 verOffsetXY;
uniform vec2 verSizeWH;
uniform vec2 viewport;
-uniform bool snapToGrid;
+uniform UBOOL snapToGrid;
out vec2 Texcoord;
@@ -14,7 +14,7 @@ void main() {
// Coordinates are [0.0; 1.0], transform to [-1.0; 1.0]
vec2 pos = verOffsetXY + position * verSizeWH;
- if (snapToGrid) {
+ if (UBOOL_TEST(snapToGrid)) {
// Align vertex coordinates to the native pixel grid
// This ensures text does not get garbled by nearest neighbors scaling
pos.x = floor(pos.x * viewport.x + 0.5) / viewport.x;
diff --git a/engines/wintermute/base/gfx/opengl/shaders/wme_line.vertex b/engines/wintermute/base/gfx/opengl/shaders/wme_line.vertex
index 615ed164278..a2096ae4d8b 100644
--- a/engines/wintermute/base/gfx/opengl/shaders/wme_line.vertex
+++ b/engines/wintermute/base/gfx/opengl/shaders/wme_line.vertex
@@ -6,6 +6,6 @@ uniform vec4 color;
out vec4 Color;
void main() {
- gl_Position = projMatrix * vec4(position, 0.0f, 1.0);
+ gl_Position = projMatrix * vec4(position, 0.0, 1.0);
Color = color;
}
diff --git a/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.fragment b/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.fragment
index 90a67cc5e13..5f602beebab 100644
--- a/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.fragment
+++ b/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.fragment
@@ -3,7 +3,7 @@ in vec4 Color;
uniform sampler2D tex;
uniform float alphaRef;
-uniform bool alphaTest;
+uniform UBOOL alphaTest;
OUTPUT
@@ -11,7 +11,7 @@ void main() {
vec4 texColor = texture(tex, Texcoord);
outColor = Color * texColor;
- if (alphaTest && outColor.a < alphaRef) {
+ if (UBOOL_TEST(alphaTest) && outColor.a < alphaRef) {
discard;
}
}
diff --git a/graphics/opengl/shader.cpp b/graphics/opengl/shader.cpp
index 22955c1e03d..1a407e41b34 100644
--- a/graphics/opengl/shader.cpp
+++ b/graphics/opengl/shader.cpp
@@ -64,6 +64,18 @@ static const char *compatFragment =
"#define OUTPUT out vec4 outColor;\n"
"#endif\n";
+// OGLES2 on AmigaOS doesn't support uniform booleans, let's introduce some shim
+#if defined(AMIGAOS)
+static const char *compatUniformBool =
+ "#define UBOOL mediump int\n"
+ "#define UBOOL_TEST(v) (v != 0)\n";
+#else
+static const char *compatUniformBool =
+ "#define UBOOL bool\n"
+ "#define UBOOL_TEST(v) v\n";
+#endif
+
+
static const GLchar *readFile(const Common::String &filename) {
Common::File file;
Common::String shaderDir;
@@ -127,11 +139,12 @@ static GLuint createCompatShader(const char *shaderSource, GLenum shaderType, co
const GLchar *shaderSources[] = {
versionSource,
compatSource,
+ compatUniformBool,
shaderSource
};
GLuint shader = glCreateShader(shaderType);
- glShaderSource(shader, 3, shaderSources, NULL);
+ glShaderSource(shader, 4, shaderSources, NULL);
glCompileShader(shader);
GLint status;
Commit: 76eda43fb5d1ca87d47b8029f913d2e775fb81da
https://github.com/scummvm/scummvm/commit/76eda43fb5d1ca87d47b8029f913d2e775fb81da
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-17T12:34:38+02:00
Commit Message:
AMIGAOS: Install shaders files as well
We make use of them when runiing in GLES2
Changed paths:
backends/platform/sdl/amigaos/amigaos.mk
diff --git a/backends/platform/sdl/amigaos/amigaos.mk b/backends/platform/sdl/amigaos/amigaos.mk
index c32dccbfeb2..08bbb6f4393 100644
--- a/backends/platform/sdl/amigaos/amigaos.mk
+++ b/backends/platform/sdl/amigaos/amigaos.mk
@@ -40,6 +40,10 @@ endif
ifdef DIST_FILES_THEMES
makedir all $(AMIGAOSPATH)/themes
cp $(DIST_FILES_THEMES) $(AMIGAOSPATH)/themes
+endif
+ifneq ($(DIST_FILES_SHADERS),)
+ makedir all $(AMIGAOSPATH)/shaders
+ cp $(DIST_FILES_SHADERS) $(AMIGAOSPATH)/shaders
endif
# Strip and copy engine plugins.
ifdef DYNAMIC_MODULES
More information about the Scummvm-git-logs
mailing list