[Scummvm-git-logs] scummvm master -> 3f08b71d85d836356f76a38181fa8a01dc5d8306

lephilousophe noreply at scummvm.org
Sat Oct 22 14:51:30 UTC 2022


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
86ea6f581c BACKENDS: OPENGL: Fix cursor scaling with LibRetro
3f08b71d85 BACKENDS: OPENGL: With animated LibRetro shaders, always update screen


Commit: 86ea6f581cb4e86d58f0a5340b33a8653b913a90
    https://github.com/scummvm/scummvm/commit/86ea6f581cb4e86d58f0a5340b33a8653b913a90
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-22T16:51:08+02:00

Commit Message:
BACKENDS: OPENGL: Fix cursor scaling with LibRetro

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 196af99d233..e24491ee2be 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -656,14 +656,25 @@ void OpenGLGraphicsManager::updateScreen() {
 		Framebuffer *lastFramebuffer = Pipeline::getActivePipeline()->setFramebuffer(_gameScreenTarget);
 		_gameScreenTarget->enableBlend(Framebuffer::kBlendModeDisabled);
 		const GLTexture &gameScreenTexture = _gameScreen->getGLTexture();
-		Pipeline::getActivePipeline()->drawTexture(gameScreenTexture, 0, 0, gameScreenTexture.getLogicalWidth(), gameScreenTexture.getLogicalHeight());
+		const uint retroWidth = gameScreenTexture.getLogicalWidth(),
+		           retroHeight = gameScreenTexture.getLogicalHeight();
+		Pipeline::getActivePipeline()->drawTexture(gameScreenTexture, 0, 0, retroWidth, retroHeight);
 
 		// Draw the cursor if necessary.
+		// If overlay is visible we draw it later to have the cursor above overlay
 		if (needsCursor && !_overlayVisible) {
-			int gameScreenCursorX = (_cursorX - _gameDrawRect.left) * _gameScreen->getWidth() / _gameDrawRect.width() - _cursorHotspotX;
-			int gameScreenCursorY = (_cursorY - _gameDrawRect.top) * _gameScreen->getHeight() / _gameDrawRect.height() - _cursorHotspotY;
+			// Do all calculations in window coordinates
+			int gameScreenCursorX = _cursorX - _gameDrawRect.left - _cursorHotspotXScaled + _shakeOffsetScaled.x;
+			int gameScreenCursorY = _cursorY - _gameDrawRect.top - _cursorHotspotYScaled + _shakeOffsetScaled.y;
+			// Scale to come back to libretro input surface coordinates
+			gameScreenCursorX = gameScreenCursorX * retroWidth / _gameDrawRect.width();
+			gameScreenCursorY = gameScreenCursorY * retroHeight / _gameDrawRect.height();
+
+			int cursorWidth = _cursorWidthScaled * retroWidth / _gameDrawRect.width();
+			int cursorHeight = _cursorHeightScaled * retroHeight / _gameDrawRect.height();
+
 			_gameScreenTarget->enableBlend(Framebuffer::kBlendModePremultipliedTransparency);
-			Pipeline::getActivePipeline()->drawTexture(_cursor->getGLTexture(), gameScreenCursorX, gameScreenCursorY, _cursor->getWidth(), _cursor->getHeight());
+			Pipeline::getActivePipeline()->drawTexture(_cursor->getGLTexture(), gameScreenCursorX, gameScreenCursorY, cursorWidth, cursorHeight);
 			needsCursor = false;
 		}
 		Pipeline::getActivePipeline()->setFramebuffer(lastFramebuffer);


Commit: 3f08b71d85d836356f76a38181fa8a01dc5d8306
    https://github.com/scummvm/scummvm/commit/3f08b71d85d836356f76a38181fa8a01dc5d8306
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-22T16:51:08+02:00

Commit Message:
BACKENDS: OPENGL: With animated LibRetro shaders, always update screen

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/pipelines/libretro.cpp
    backends/graphics/opengl/pipelines/libretro.h


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index e24491ee2be..6efe0a43013 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -619,6 +619,9 @@ void OpenGLGraphicsManager::updateScreen() {
 	if (   !_forceRedraw
 		&& !_cursorNeedsRedraw
 	    && !_gameScreen->isDirty()
+#if !USE_FORCED_GLES
+	    && !(_libretroPipeline && _libretroPipeline->isAnimated())
+#endif
 	    && !(_overlayVisible && _overlay->isDirty())
 	    && !(_cursorVisible && _cursor && _cursor->isDirty())
 #ifdef USE_OSD
diff --git a/backends/graphics/opengl/pipelines/libretro.cpp b/backends/graphics/opengl/pipelines/libretro.cpp
index 2d3ee249d82..d2a76d53c3b 100644
--- a/backends/graphics/opengl/pipelines/libretro.cpp
+++ b/backends/graphics/opengl/pipelines/libretro.cpp
@@ -118,13 +118,15 @@ static const char *g_compatFragment =
 LibRetroPipeline::LibRetroPipeline()
 	: ShaderPipeline(ShaderMan.query(ShaderManager::kDefault)),
 	  _shaderPreset(nullptr), _applyProjectionChanges(false),
-	  _inputWidth(0), _inputHeight(0), _outputWidth(0), _outputHeight(0), _frameCount(0) {
+	  _inputWidth(0), _inputHeight(0), _outputWidth(0), _outputHeight(0),
+	  _isAnimated(false), _frameCount(0) {
 }
 
 LibRetroPipeline::LibRetroPipeline(const Common::FSNode &shaderPreset)
 	: ShaderPipeline(ShaderMan.query(ShaderManager::kDefault)),
 	  _shaderPreset(nullptr), _applyProjectionChanges(false),
-	  _inputWidth(0), _inputHeight(0), _outputWidth(0), _outputHeight(0), _frameCount(0) {
+	  _inputWidth(0), _inputHeight(0), _outputWidth(0), _outputHeight(0),
+	  _isAnimated(false), _frameCount(0) {
 	open(shaderPreset);
 }
 
@@ -295,6 +297,8 @@ bool LibRetroPipeline::loadPasses() {
 		}
 	}
 
+	_isAnimated = false;
+
 	// parameters are shared among all passes so we load them first and apply them to all shaders
 	UniformsMap uniformParams;
 	for (LibRetro::ShaderPreset::PassArray::const_iterator
@@ -394,6 +398,8 @@ bool LibRetroPipeline::loadPasses() {
 		const uint passId = _passes.size() - 1;
 
 		pass.hasFrameCount = shader->getUniformLocation("FrameCount") != -1;
+		// If pass has FrameCount uniform, preset is animated and must be redrawn on a regular basis
+		_isAnimated |= pass.hasFrameCount;
 
 		pass.buildTexCoords(passId, aliases);
 		pass.buildTexSamplers(passId, _textures, aliases);
diff --git a/backends/graphics/opengl/pipelines/libretro.h b/backends/graphics/opengl/pipelines/libretro.h
index 7a1f67a6e4f..9c238331cb6 100644
--- a/backends/graphics/opengl/pipelines/libretro.h
+++ b/backends/graphics/opengl/pipelines/libretro.h
@@ -62,6 +62,7 @@ public:
 	void close();
 
 	bool isInitialized() const { return _shaderPreset != nullptr; }
+	bool isAnimated() const { return _isAnimated; }
 
 	static bool isSupportedByContext() {
 		return OpenGLContext.shadersSupported
@@ -91,6 +92,8 @@ private:
 	uint _outputWidth;
 	uint _outputHeight;
 
+	/* Determines if preset depends on frameCount or from previous frames */
+	bool _isAnimated;
 	uint _frameCount;
 
 	struct Texture {




More information about the Scummvm-git-logs mailing list