mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Render EntityIDs (breaks post processing)
This commit is contained in:
@@ -5,6 +5,7 @@ using DirectX.D3D11;
|
||||
using GlitchyEngine.Platform.DX11;
|
||||
using DirectX.DXGI.DXGI1_2;
|
||||
using System;
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
using internal GlitchyEngine.Platform.DX11;
|
||||
|
||||
@@ -199,6 +200,16 @@ namespace GlitchyEngine.Renderer
|
||||
ReleaseEveryThing();
|
||||
}
|
||||
|
||||
internal ID3D11Texture2D* GetNativeTexture(int index)
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(index >= -1 && index < ColorTargetCount);
|
||||
|
||||
if (index == -1)
|
||||
return _nativeDepthTexture;
|
||||
|
||||
return _nativeTextures[index];
|
||||
}
|
||||
|
||||
private ID3D11Texture2D* PlatformCreateTexture(TargetDescription target)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
@@ -443,6 +454,18 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public override void CopyTo(RenderTargetGroup destination, int dstTarget, Int2 dstTopLeft, Int2 size, Int2 srcTopLeft, int srcTarget)
|
||||
{
|
||||
ID3D11Texture2D* dstTexture = destination.GetNativeTexture(dstTarget);
|
||||
ID3D11Texture2D* srcTexture = GetNativeTexture(srcTarget);
|
||||
|
||||
// TODO: Mips/Arrays
|
||||
|
||||
Box srcBox = .((.)srcTopLeft.X, (.)srcTopLeft.Y, 0, (.)(srcTopLeft.X + size.X), (.)(srcTopLeft.Y + size.Y), 1);
|
||||
|
||||
NativeContext.CopySubresourceRegion(dstTexture, 0, (.)dstTopLeft.X, (.)dstTopLeft.Y, 0, srcTexture, 0, &srcBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
private GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
private Effect _clearUintFx ~ _?.ReleaseRef();
|
||||
private BlendState _nonblendingState ~ _?.ReleaseRef();
|
||||
|
||||
public GraphicsContext Context
|
||||
{
|
||||
get => _context;
|
||||
@@ -26,6 +29,11 @@ namespace GlitchyEngine.Renderer
|
||||
public override void Init()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
_clearUintFx = new Effect("content/Shaders/ClearUInt.hlsl");
|
||||
BlendStateDescription desc =.Default;
|
||||
desc.RenderTarget[0].BlendEnable = false;
|
||||
_nonblendingState = new BlendState(desc);
|
||||
}
|
||||
|
||||
private mixin RtOrBackbuffer(RenderTarget2D renderTarget)
|
||||
@@ -69,12 +77,23 @@ namespace GlitchyEngine.Renderer
|
||||
case .Color(let color):
|
||||
NativeContext.ClearRenderTargetView(rtv, color);
|
||||
case .UInt(let value):
|
||||
/*#unwarn
|
||||
#unwarn
|
||||
NativeContext.OutputMerger.SetRenderTargets(1, &rtv, null);
|
||||
|
||||
using (BlendState lastBlendState = _currentBlendState..AddRef())
|
||||
{
|
||||
SetBlendState(_nonblendingState);
|
||||
|
||||
|
||||
BindRenderTargets();*/
|
||||
_clearUintFx.Variables["ClearValue"].SetData(value);
|
||||
_clearUintFx.Bind(_context);
|
||||
|
||||
FullscreenQuad.Draw();
|
||||
|
||||
SetBlendState(lastBlendState);
|
||||
}
|
||||
|
||||
// Rebind the old render targets
|
||||
BindRenderTargets();
|
||||
default:
|
||||
Runtime.NotImplemented();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user