(2024-04-12, 08:00)KOPRajs Wrote: It works better now (no performance issues), but there is still one minor issue which happens randomly and that I haven't found the reason for yet. Sometimes it renders black screen after the game has changed the resolution until you open the Video filter selection GUI (that fixes it).
I have found out what the issue was:
#8 - Black screen (or wrong scale) after source resolution has changed
After fixing the #5 by reloading the shader preset when the source resolution is changed, the new issue was revealed. When the preset is reloaded the MVPs of each shader pass are not being initialized (the
UpdateMVPs() is not being called). It relies on being called from
CShaderPresetGL :: PrepareParameters(), but it is only called if the viewport has changed. When the preset is loading for the first time the viewport is always considered changed. If the viewport hasn't been changed, the MVPs remain uninitialized (or not updated) which causes unpredictable shader scaling issues. Opening of any GUI window with the shader thumbnails fixes it, because the thumbnails trigger the viewport update. This issue mostly affects emulators which change output resolution (e.g. Beetle PSX) with multi pass shaders enabled (using Beetle PSX with the gbc-2x shader during the new game start is a good way to reproduce the issue). This can be solved by initializing of the MVP for every shader pass during the reload (after the texture has been created and
SetSizes() has been called, see:
https://github.com/KOPRajs/xbmc/blob/6a4...L.cpp#L335).
Both issues #5 and #8 should in theory affect video shaders in DirectX as well (I have only confirmed #5 in the 21.0 RC2 build, as I don't have Windows devel environment for testing).
I have added the fix to
6a48e83 (including the fix for DirectX, but it is not tested). I've also changed the way the shader preset update is triggered (the original version for reference:
https://github.com/KOPRajs/xbmc/commit/7...16c0bfa649). Instead of comparing the buffer size in
CRPBaseRenderer :: SetBuffer() it is now being done in the
CShaderPresetGL :: SetVideoSize() because it seems more consistent with how the rest of the code works and it allows to simplify the
CRPBaseRenderer :: Updateshaders(). Let me know if you liked the original version more. I'm also planning to rewrite the fix for #1 and #3 (
2057a1c), because after moving the code which actually belongs to rendering from
CShaderGL :: SetShaderParameters() to
CShaderGL :: Render() in
2a7b0a7, part of the original fix is not needed anymore (we can revert the calls to
videoShader->PrepareParameters() back to the loop in
CShaderPresetGL :: PrepareParameters() because it will not overwrite anything anymore). The new fix should be more consistent with the DirectX code, but it will require a rebase, so I'll create a new branch for it.