From 8813a0139dd89f475326cdb4ddb90b780c40d636 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 11 Mar 2024 16:28:00 -0700 Subject: [PATCH] expose GraphicsDevice.DebugMode --- src/Graphics/GraphicsDevice.cs | 2 ++ src/Graphics/Resources/GpuBuffer.cs | 14 +++++++++----- src/Graphics/Resources/Texture.cs | 14 +++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 86eb6c5..4287b6d 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -15,6 +15,7 @@ namespace MoonWorks.Graphics { public IntPtr Handle { get; } public Backend Backend { get; } + public bool DebugMode { get; } private uint windowFlags; public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags; @@ -61,6 +62,7 @@ namespace MoonWorks.Graphics Conversions.BoolToByte(debugMode) ); + DebugMode = debugMode; // TODO: check for CreateDevice fail // Check for replacement stock shaders diff --git a/src/Graphics/Resources/GpuBuffer.cs b/src/Graphics/Resources/GpuBuffer.cs index ad87e58..7a673cf 100644 --- a/src/Graphics/Resources/GpuBuffer.cs +++ b/src/Graphics/Resources/GpuBuffer.cs @@ -23,11 +23,15 @@ namespace MoonWorks.Graphics set { - Refresh.Refresh_SetGpuBufferName( - Device.Handle, - Handle, - value - ); + if (Device.DebugMode) + { + Refresh.Refresh_SetGpuBufferName( + Device.Handle, + Handle, + value + ); + } + name = value; } } diff --git a/src/Graphics/Resources/Texture.cs b/src/Graphics/Resources/Texture.cs index 9a26c39..7648808 100644 --- a/src/Graphics/Resources/Texture.cs +++ b/src/Graphics/Resources/Texture.cs @@ -27,11 +27,15 @@ namespace MoonWorks.Graphics set { - Refresh.Refresh_SetTextureName( - Device.Handle, - Handle, - value - ); + if (Device.DebugMode) + { + Refresh.Refresh_SetTextureName( + Device.Handle, + Handle, + value + ); + } + name = value; } }