[Scummvm-git-logs] scummvm master -> bc4e7662cc23e2be6c45c54d216dd21bbb9fe5bb
lephilousophe
noreply at scummvm.org
Sun Apr 3 07:40:56 UTC 2022
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
89cfc283ab OPENGL: Use correct function to debug program linking
dda9a66f7a GRIM: Fix z-depth shader rendering on big-endian hosts
0bbd37828d GRIM: Compile dim ARB program only when enabled
352d42f52c GRIM: Don't access uniforms array items individually
bc4e7662cc SDL: Initialize OpenGLContext with the proper version
Commit: 89cfc283ab9f88810642d1568651afd9d9248150
https://github.com/scummvm/scummvm/commit/89cfc283ab9f88810642d1568651afd9d9248150
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-03T09:40:51+02:00
Commit Message:
OPENGL: Use correct function to debug program linking
Changed paths:
graphics/opengl/shader.cpp
diff --git a/graphics/opengl/shader.cpp b/graphics/opengl/shader.cpp
index 8fc9fcb791a..8572040336b 100644
--- a/graphics/opengl/shader.cpp
+++ b/graphics/opengl/shader.cpp
@@ -189,9 +189,9 @@ ShaderGL::ShaderGL(const Common::String &name, GLuint vertexShader, GLuint fragm
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &status);
if (status != GL_TRUE) {
GLint logSize;
- glGetShaderiv(shaderProgram, GL_INFO_LOG_LENGTH, &logSize);
+ glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &logSize);
GLchar *log = new GLchar[logSize];
- glGetShaderInfoLog(shaderProgram, logSize, nullptr, log);
+ glGetProgramInfoLog(shaderProgram, logSize, nullptr, log);
error("Could not link shader %s: %s", name.c_str(), log);
}
Commit: dda9a66f7a83e2247c14f635ad71bd65d67d4124
https://github.com/scummvm/scummvm/commit/dda9a66f7a83e2247c14f635ad71bd65d67d4124
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-03T09:40:51+02:00
Commit Message:
GRIM: Fix z-depth shader rendering on big-endian hosts
The value read is done in shader on a byte basis so we must set the
expected layout
Changed paths:
engines/grim/gfx_opengl_shaders.cpp
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index 944d5467e11..36141eb4482 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -1275,7 +1275,9 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
if (val == 0xf81f) {
val = 0;
}
- zbufPtr[i] = 0xffff - ((uint32)val) * 0x10000 / 100 / (0x10000 - val);
+ // This is later read as a LA pair when filling texture
+ // with L being used as the LSB in fragment shader
+ zbufPtr[i] = TO_LE_16(0xffff - ((uint32)val) * 0x10000 / 100 / (0x10000 - val));
}
}
}
Commit: 0bbd37828d399429fb1f6a50ae990335d6f839d2
https://github.com/scummvm/scummvm/commit/0bbd37828d399429fb1f6a50ae990335d6f839d2
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-03T09:40:51+02:00
Commit Message:
GRIM: Compile dim ARB program only when enabled
Changed paths:
engines/grim/gfx_opengl.cpp
diff --git a/engines/grim/gfx_opengl.cpp b/engines/grim/gfx_opengl.cpp
index 5d0e92d287b..5b65ff42cbc 100644
--- a/engines/grim/gfx_opengl.cpp
+++ b/engines/grim/gfx_opengl.cpp
@@ -167,11 +167,13 @@ void GfxOpenGL::initExtensions() {
warning("Error compiling depth fragment program:\n%s", glGetString(GL_PROGRAM_ERROR_STRING_ARB));
_useDepthShader = false;
}
+ }
-
+ if (_useDimShader) {
glGenProgramsARB(1, &_dimFragProgram);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, _dimFragProgram);
+ GLint errorPos;
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dimFragSrc), dimFragSrc);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
if (errorPos != -1) {
Commit: 352d42f52c2e69b8082aa1fb29b8d6c74e0d4076
https://github.com/scummvm/scummvm/commit/352d42f52c2e69b8082aa1fb29b8d6c74e0d4076
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-03T09:40:51+02:00
Commit Message:
GRIM: Don't access uniforms array items individually
Accessing an array item is only allowed for arrays of structures which
got removed because not supported on RPi.
Instead we build an array with all variables laid out sequentially and
set uniform once.
Changed paths:
engines/grim/gfx_opengl_shaders.cpp
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index 36141eb4482..32cd60337f9 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -826,27 +826,77 @@ void GfxOpenGLS::startActorDraw(const Actor *actor) {
_actorLightsProgram->setUniform("hasAmbient", _hasAmbientLight);
if (_lightsEnabled) {
+ // Allocate all variables in one chunk
+ static const unsigned int numUniforms = 4;
+ static const unsigned int uniformSize = _maxLights * 4;
+ float *lightsData = new float[numUniforms * uniformSize];
for (int i = 0; i < _maxLights; ++i) {
const GLSLight &l = _lights[i];
- Common::String uniform;
- uniform = Common::String::format("lightsPosition[%u]", i);
- _actorLightsProgram->setUniform(uniform.c_str(), viewMatrix * l._position);
+ // lightsPosition
+ Math::Vector4d tmp = viewMatrix * l._position;
+ lightsData[0 * uniformSize + 4 * i + 0] = tmp.x();
+ lightsData[0 * uniformSize + 4 * i + 1] = tmp.y();
+ lightsData[0 * uniformSize + 4 * i + 2] = tmp.z();
+ lightsData[0 * uniformSize + 4 * i + 3] = tmp.w();
+
+ // lightsDirection
Math::Vector4d direction = l._direction;
direction.w() = 0.0;
viewMatrix.transformVector(&direction);
direction.w() = l._direction.w();
- uniform = Common::String::format("lightsDirection[%u]", i);
- _actorLightsProgram->setUniform(uniform.c_str(), direction);
+ lightsData[1 * uniformSize + 4 * i + 0] = direction.x();
+ lightsData[1 * uniformSize + 4 * i + 1] = direction.y();
+ lightsData[1 * uniformSize + 4 * i + 2] = direction.z();
+ lightsData[1 * uniformSize + 4 * i + 3] = direction.w();
+
+ // lightsColor
+ lightsData[2 * uniformSize + 4 * i + 0] = l._color.x();
+ lightsData[2 * uniformSize + 4 * i + 1] = l._color.y();
+ lightsData[2 * uniformSize + 4 * i + 2] = l._color.z();
+ lightsData[2 * uniformSize + 4 * i + 3] = l._color.w();
+
+ // lightsParams
+ lightsData[3 * uniformSize + 4 * i + 0] = l._params.x();
+ lightsData[3 * uniformSize + 4 * i + 1] = l._params.y();
+ lightsData[3 * uniformSize + 4 * i + 2] = l._params.z();
+ lightsData[3 * uniformSize + 4 * i + 3] = l._params.w();
+ }
- uniform = Common::String::format("lightsColor[%u]", i);
- _actorLightsProgram->setUniform(uniform.c_str(), l._color);
+ Common::String uniform;
+ GLint uniformPos;
- uniform = Common::String::format("lightsParams[%u]", i);
- _actorLightsProgram->setUniform(uniform.c_str(), l._params);
+ uniform = Common::String::format("lightsPosition");
+ uniformPos = _actorLightsProgram->getUniformLocation(uniform.c_str());
+ if (uniformPos == -1) {
+ error("No uniform named '%s'", uniform.c_str());
}
+ glUniform4fv(uniformPos, _maxLights, &lightsData[0 * uniformSize]);
+
+ uniform = Common::String::format("lightsDirection");
+ uniformPos = _actorLightsProgram->getUniformLocation(uniform.c_str());
+ if (uniformPos == -1) {
+ error("No uniform named '%s'", uniform.c_str());
+ }
+ glUniform4fv(uniformPos, _maxLights, &lightsData[1 * uniformSize]);
+
+ uniform = Common::String::format("lightsColor");
+ uniformPos = _actorLightsProgram->getUniformLocation(uniform.c_str());
+ if (uniformPos == -1) {
+ error("No uniform named '%s'", uniform.c_str());
+ }
+ glUniform4fv(uniformPos, _maxLights, &lightsData[2 * uniformSize]);
+
+ uniform = Common::String::format("lightsParams");
+ uniformPos = _actorLightsProgram->getUniformLocation(uniform.c_str());
+ if (uniformPos == -1) {
+ error("No uniform named '%s'", uniform.c_str());
+ }
+ glUniform4fv(uniformPos, _maxLights, &lightsData[3 * uniformSize]);
+
+ delete[] lightsData;
}
}
Commit: bc4e7662cc23e2be6c45c54d216dd21bbb9fe5bb
https://github.com/scummvm/scummvm/commit/bc4e7662cc23e2be6c45c54d216dd21bbb9fe5bb
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-03T09:40:51+02:00
Commit Message:
SDL: Initialize OpenGLContext with the proper version
Changed paths:
backends/platform/sdl/sdl.cpp
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index f39ac65c247..1e7d06faca5 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -322,20 +322,46 @@ void OSystem_SDL::detectFramebufferSupport() {
// 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);
- if (window) {
- SDL_GLContext glContext = SDL_GL_CreateContext(window);
- if (glContext) {
- OpenGLContext.initialize(OpenGL::kOGLContextGL);
- _supportsFrameBuffer = OpenGLContext.framebufferObjectSupported;
- OpenGLContext.reset();
- SDL_GL_DeleteContext(glContext);
+ if (!window) {
+ return;
+ }
+
+ int glContextProfileMask, glContextMajor;
+ OpenGL::ContextOGLType glContextType;
+ if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &glContextProfileMask) != 0) {
+ SDL_DestroyWindow(window);
+ return;
+ }
+ if (glContextProfileMask == SDL_GL_CONTEXT_PROFILE_ES) {
+ if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &glContextMajor) != 0) {
+ SDL_DestroyWindow(window);
+ return;
}
+ if (glContextMajor == 2) {
+ glContextType = OpenGL::kOGLContextGLES2;
+ } else {
+ SDL_DestroyWindow(window);
+ return;
+ }
+ } else {
+ glContextType = OpenGL::kOGLContextGL;
+ }
+ SDL_GLContext glContext = SDL_GL_CreateContext(window);
+ if (!glContext) {
SDL_DestroyWindow(window);
+ return;
}
+
+ OpenGLContext.initialize(glContextType);
+ _supportsFrameBuffer = OpenGLContext.framebufferObjectSupported;
+ OpenGLContext.reset();
+ SDL_GL_DeleteContext(glContext);
+ SDL_DestroyWindow(window);
#else
SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=9000,9000"));
SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
SDL_putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center"));
+ // SDL 1.2 only supports OpenGL
OpenGLContext.initialize(OpenGL::kOGLContextGL);
_supportsFrameBuffer = OpenGLContext.framebufferObjectSupported;
OpenGLContext.reset();
More information about the Scummvm-git-logs
mailing list