mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fixed crash when resizing window
This commit is contained in:
@@ -426,6 +426,9 @@ namespace GlitchyEditor
|
|||||||
// Clear the swapchain-buffer
|
// Clear the swapchain-buffer
|
||||||
RenderCommand.Clear(null, .Color | .Depth, .(0.2f, 0.2f, 0.2f), 1.0f, 0);
|
RenderCommand.Clear(null, .Color | .Depth, .(0.2f, 0.2f, 0.2f), 1.0f, 0);
|
||||||
|
|
||||||
|
// Explicitly set the swap chain as render target, because we end a frame with it bound and the RTV might stop existing if we resized the swapchain between frames.
|
||||||
|
// TODO: maybe we need to be smarter about how we handle resizing in general: should the RenderTarget check during resize whether it is bound and update the GraphicsContext?!
|
||||||
|
RenderCommand.SetRenderTarget(null);
|
||||||
RenderCommand.SetBlendState(_alphaBlendState);
|
RenderCommand.SetBlendState(_alphaBlendState);
|
||||||
RenderCommand.SetDepthStencilState(_depthStencilState);
|
RenderCommand.SetDepthStencilState(_depthStencilState);
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
PlatformCreateTexture();
|
PlatformCreateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetDebugNames();
|
||||||
|
|
||||||
if(_description.DepthStencilFormat != .Unknown)
|
if(_description.DepthStencilFormat != .Unknown)
|
||||||
{
|
{
|
||||||
_depthStenilTarget = new DepthStencilTarget(_description.Width, _description.Height, _description.DepthStencilFormat);
|
_depthStenilTarget = new DepthStencilTarget(_description.Width, _description.Height, _description.DepthStencilFormat);
|
||||||
@@ -131,6 +133,18 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetDebugNames()
|
||||||
|
{
|
||||||
|
_nativeTexture.SetDebugName(Identifier);
|
||||||
|
_nativeResourceView.SetDebugName(scope $"{Identifier}: SRV");
|
||||||
|
_nativeRenderTargetView.SetDebugName(scope $"{Identifier}: RTV");
|
||||||
|
|
||||||
|
if (_depthStenilTarget != null)
|
||||||
|
{
|
||||||
|
_depthStenilTarget.nativeView.SetDebugName(scope $"{Identifier}: DSV");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override TextureViewBinding PlatformGetViewBinding()
|
protected override TextureViewBinding PlatformGetViewBinding()
|
||||||
{
|
{
|
||||||
return new .(_nativeResourceView, _samplerState?.nativeSamplerState);
|
return new .(_nativeResourceView, _samplerState?.nativeSamplerState);
|
||||||
@@ -255,6 +269,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
ID3D11Texture2D* texture = null;
|
ID3D11Texture2D* texture = null;
|
||||||
var result = NativeDevice.CreateTexture2D(ref desc, null, &texture);
|
var result = NativeDevice.CreateTexture2D(ref desc, null, &texture);
|
||||||
|
texture.SetDebugName(target.DebugName);
|
||||||
Log.EngineLogger.Assert(result.Succeeded, "Failed to create RenderTarget2D");
|
Log.EngineLogger.Assert(result.Succeeded, "Failed to create RenderTarget2D");
|
||||||
|
|
||||||
// TODO: calculate the max mip level
|
// TODO: calculate the max mip level
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
_backBuffer = new RenderTarget2D(desc);
|
_backBuffer = new RenderTarget2D(desc);
|
||||||
_backBuffer.Identifier = "Back buffer";
|
_backBuffer.Identifier = "Back buffer";
|
||||||
_backBuffer.SamplerState = SamplerStateManager.LinearClamp;
|
_backBuffer.SamplerState = SamplerStateManager.LinearClamp;
|
||||||
|
_backBuffer.ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
_backBufferViewport = GlitchyEngine.Renderer.Viewport(0, 0, _width, _height, 0.0f, 1.0f);
|
_backBufferViewport = GlitchyEngine.Renderer.Viewport(0, 0, _width, _height, 0.0f, 1.0f);
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ namespace GlitchyEngine.Renderer
|
|||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_description = description;
|
_description = description;
|
||||||
|
|
||||||
ApplyChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recreates the render target using the current description
|
/// Recreates the render target using the current description
|
||||||
|
|||||||
Reference in New Issue
Block a user