Update swapchain from native method instead of recreating it when video changed (#3562)

Recreating it works fine on Intel GPU, no issues on validation but didnt work on other cards, there is a better way to do this from native without dangling around

Fixes https://github.com/Facepunch/sbox-issues/issues/9675
This commit is contained in:
Sam Pavlovic
2025-12-05 09:37:12 -03:00
committed by GitHub
parent 25b38e42e0
commit db6ca66000
2 changed files with 5 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ native static class WidgetUtil Native.WidgetUtil
static void PaintSetFont( QPainter painter, string fontName, int size, int weight, bool italic, bool heightInPixels );
static SwapChainHandle_t CreateSwapChain( QWidget target, RenderMultisampleType_t nMSAAAmount );
static bool UpdateSwapChainMSAA( SwapChainHandle_t swapChain, RenderMultisampleType_t nMSAAAmount );
static void SetWindowNoActivate( QWidget widget );

View File

@@ -207,18 +207,15 @@ public class SceneRenderingWidget : Frame
internal void HandleVideoChanged()
{
var oldSwapChain = SwapChain;
SwapChain = WidgetUtil.CreateSwapChain( _widget, RenderSettings.Instance.AntiAliasQuality.ToEngine() );
var msaaAmount = RenderSettings.Instance.AntiAliasQuality.ToEngine();
if ( SwapChain == default )
{
SwapChain = oldSwapChain;
SwapChain = WidgetUtil.CreateSwapChain( _widget, msaaAmount );
return;
}
if ( oldSwapChain != default )
{
EngineLoop.DisposeAtFrameEnd( new Sandbox.Utility.DisposeAction( () => g_pRenderDevice.DestroySwapChain( oldSwapChain ) ) );
}
WidgetUtil.UpdateSwapChainMSAA( SwapChain, msaaAmount );
}
internal static void RenderAll()