[Scummvm-git-logs] scummvm master -> ed3e83a26d95584a6fb06904628a898914993e75
lephilousophe
noreply at scummvm.org
Sat Apr 16 12:55:28 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ed3e83a26d GRIM: Don't prevent Z-buffer update when bitmap has changed
Commit: ed3e83a26d95584a6fb06904628a898914993e75
https://github.com/scummvm/scummvm/commit/ed3e83a26d95584a6fb06904628a898914993e75
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-04-16T14:54:53+02:00
Commit Message:
GRIM: Don't prevent Z-buffer update when bitmap has changed
The previous chack was essentialy based on data pointer being different
between successive updates.
Sometimes the memory allocator reuses the same memory space for two
different bitmaps and the z-buffer isn't updated.
Changed paths:
engines/grim/gfx_opengl_shaders.cpp
engines/grim/gfx_opengl_shaders.h
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index 32cd60337f9..898a2c7438d 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -1470,7 +1470,8 @@ void GfxOpenGLS::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer)
} else {
// Only draw the manual zbuffer when enabled
if (bitmap->getActiveImage() - 1 < bitmap->getNumImages()) {
- drawDepthBitmap(dx, dy, bitmap->getWidth(), bitmap->getHeight(), (char *)const_cast<void *>(bitmap->getData(bitmap->getActiveImage() - 1).getPixels()));
+ drawDepthBitmap(bitmap->getId(), dx, dy, bitmap->getWidth(), bitmap->getHeight(),
+ (char *)const_cast<void *>(bitmap->getData(bitmap->getActiveImage() - 1).getPixels()));
} else {
warning("zbuffer image has index out of bounds! %d/%d", bitmap->getActiveImage(), bitmap->getNumImages());
}
@@ -1478,15 +1479,26 @@ void GfxOpenGLS::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer)
}
}
-void GfxOpenGLS::drawDepthBitmap(int x, int y, int w, int h, char *data) {
+void GfxOpenGLS::drawDepthBitmap(int bitmapId, int x, int y, int w, int h, char *data) {
+ static int prevId = -1;
static int prevX = -1, prevY = -1;
+ static int prevW = -1, prevH = -1;
static char *prevData = nullptr;
- if (prevX == x && prevY == y && data == prevData)
+ // Sometimes the data pointer is reused by the allocator between bitmaps
+ // Use the bitmap ID to ensure we don't prevent an expected update
+ if (bitmapId == prevId &&
+ prevX == x && prevY == y &&
+ prevW == w && prevH == h &&
+ data == prevData) {
return;
+ }
+ prevId = bitmapId;
prevX = x;
prevY = y;
+ prevW = w;
+ prevH = h;
prevData = data;
glActiveTexture(GL_TEXTURE1);
diff --git a/engines/grim/gfx_opengl_shaders.h b/engines/grim/gfx_opengl_shaders.h
index 6af404726be..78cd862b8dd 100644
--- a/engines/grim/gfx_opengl_shaders.h
+++ b/engines/grim/gfx_opengl_shaders.h
@@ -245,7 +245,7 @@ private:
void setupQuadEBO();
void setupZBuffer();
- void drawDepthBitmap(int x, int y, int w, int h, char *data);
+ void drawDepthBitmap(int bitmapId, int x, int y, int w, int h, char *data);
float _fov;
float _nclip;
More information about the Scummvm-git-logs
mailing list