mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Instrumentation
This commit is contained in:
@@ -21,6 +21,8 @@ namespace GlitchyEngine.Platform.DX11
|
||||
|
||||
internal static void Dx11Init()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
if(!IsDx11Initialized)
|
||||
{
|
||||
Log.EngineLogger.Trace("Creating D3D11 Device and Context...");
|
||||
@@ -31,21 +33,30 @@ namespace GlitchyEngine.Platform.DX11
|
||||
#endif
|
||||
|
||||
FeatureLevel[] levels = scope .(.Level_11_0);
|
||||
|
||||
|
||||
FeatureLevel deviceLevel = ?;
|
||||
var deviceResult = D3D11.CreateDevice(null, .Hardware, 0, deviceFlags, levels, &NativeDevice, &deviceLevel, &NativeContext);
|
||||
|
||||
HResult deviceResult;
|
||||
{
|
||||
Debug.Profiler.ProfileScope!("D3D11.CreateDevice");
|
||||
deviceResult = D3D11.CreateDevice(null, .Hardware, 0, deviceFlags, levels, &NativeDevice, &deviceLevel, &NativeContext);
|
||||
}
|
||||
|
||||
Log.EngineLogger.Assert(deviceResult.Succeeded, scope $"Failed to create D3D11 Device. Message({(int32)deviceResult}): {deviceResult}");
|
||||
|
||||
#if DEBUG
|
||||
if(NativeDevice.QueryInterface<ID3D11Debug>(out DebugDevice).Succeeded)
|
||||
{
|
||||
ID3D11InfoQueue* infoQueue;
|
||||
if(NativeDevice.QueryInterface<ID3D11InfoQueue>(out infoQueue).Succeeded)
|
||||
Debug.Profiler.ProfileScope!("Query for ID3D11Debug");
|
||||
if(NativeDevice.QueryInterface<ID3D11Debug>(out DebugDevice).Succeeded)
|
||||
{
|
||||
infoQueue.SetBreakOnSeverity(.Corruption, true);
|
||||
infoQueue.SetBreakOnSeverity(.Error, true);
|
||||
|
||||
infoQueue.Release();
|
||||
ID3D11InfoQueue* infoQueue;
|
||||
if(NativeDevice.QueryInterface<ID3D11InfoQueue>(out infoQueue).Succeeded)
|
||||
{
|
||||
infoQueue.SetBreakOnSeverity(.Corruption, true);
|
||||
infoQueue.SetBreakOnSeverity(.Error, true);
|
||||
|
||||
infoQueue.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -63,6 +74,8 @@ namespace GlitchyEngine.Platform.DX11
|
||||
|
||||
internal static void Dx11Release()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
NativeDevice.Release();
|
||||
NativeContext.Release();
|
||||
DebugDevice.ReportLiveDeviceObjects(.Detail);
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformCreateBlendState()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
BlendDescription nativeDesc = .Default;
|
||||
nativeDesc.IndependentBlendEnable = _desc.IndependentBlendEnable;
|
||||
nativeDesc.AlphaToCoverageEnable = _desc.AlphaToCoverageEnable;
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
private Result<void> InternalCreateBuffer(void* data, uint32 byteLength, uint32 dstByteOffset)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
nativeDescription = (.)_description;
|
||||
|
||||
uint8* byteData = (.)data;
|
||||
@@ -84,6 +86,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override Result<void> PlatformSetData(void* data, uint32 byteLength, uint32 dstByteOffset, GlitchyEngine.Renderer.MapType mapType)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
if(nativeBuffer == null)
|
||||
{
|
||||
// We can pass the data while creating the buffer, so we can return here.
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
internal void PlatformFetchNativeBuffers()
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
for(let buffer in _buffers)
|
||||
{
|
||||
nativeBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
internal this(ConstantBuffer constantBuffer, ID3D11ShaderReflectionVariable* variableReflection)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
_constantBuffer = constantBuffer;
|
||||
|
||||
HResult result = variableReflection.GetDescription(let variableDescription);
|
||||
@@ -51,6 +53,8 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
internal this(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Reflect(bufferReflection);
|
||||
|
||||
ConstructBuffer();
|
||||
@@ -60,6 +64,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
private void Reflect(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
HResult result = bufferReflection.GetDescription(let bufferDescription);
|
||||
Log.EngineLogger.Assert(result.Succeeded, scope $"Failed to get buffer description. Error({(int)result}): {result}");
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public this(GEDSSDesc description)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
_description = description;
|
||||
nativeDescription = (.)description;
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformCreate()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Texture2DDescription desc = .();
|
||||
desc.Format = (.)_format;
|
||||
desc.ArraySize = 1;
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
protected override void Compile(String vsPath, String vsEntry, String psPath, String psEntry)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
// Todo: macros
|
||||
VertexShader = new VertexShader(vsPath, vsEntry);
|
||||
PixelShader = new PixelShader(psPath, psEntry);
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformSetVertexBuffer(VertexBufferBinding binding, uint32 slot)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Log.EngineLogger.Assert(slot < nativeBuffers.Count, "The buffer slot has to be in the range from 0 to 31.");
|
||||
|
||||
VertexBuffer vertexBuffer = binding.Buffer;
|
||||
@@ -59,12 +61,16 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformSetVertexLayout(VertexLayout vertexLayout)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
nativeVertexLayout?.Release();
|
||||
nativeVertexLayout = vertexLayout?.nativeLayout..AddRef();
|
||||
}
|
||||
|
||||
protected override void PlatformSetIndexBuffer(IndexBuffer indexBuffer)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Log.EngineLogger.Assert(indexBuffer.nativeDescription.BindFlags.HasFlag(.IndexBuffer),
|
||||
scope $"Buffer ({indexBuffer.nativeBuffer.GetDebugName(.. scope .())}) must have IndexBuffer-flag set to be bound as an index buffer.");
|
||||
|
||||
@@ -79,6 +85,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Bind()
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
NativeContext.InputAssembler.SetVertexBuffers(0, nativeBuffers.Count, &nativeBuffers, &bufferStrides, &bufferOffsets);
|
||||
NativeContext.InputAssembler.SetInputLayout(_vertexLayout.nativeLayout);
|
||||
NativeContext.InputAssembler.SetPrimitiveTopology((.)_primitiveTopology);
|
||||
@@ -89,6 +97,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Unbind()
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
ID3D11Buffer*[nativeBuffers.Count] nullBuffers = .();
|
||||
uint32[nativeBuffers.Count] zeroStrides = .();
|
||||
uint32[nativeBuffers.Count] zeroOffsets = .();
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public this(Windows.HWnd windowHandle)
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
nativeWindowHandle = windowHandle;
|
||||
|
||||
_swapChain = new SwapChain(this);
|
||||
@@ -47,6 +49,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public ~this()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
delete _swapChain;
|
||||
|
||||
Dx11Release();
|
||||
@@ -54,6 +58,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
Dx11Init();
|
||||
|
||||
SwapChain.Init();
|
||||
@@ -177,6 +183,8 @@ namespace GlitchyEngine.Renderer
|
||||
*/
|
||||
private void BindShaderToStage<TShader>(TShader shader) where TShader : Shader
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
uint32 _firstTexture = D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT;
|
||||
uint32 _textureCount = 0;
|
||||
|
||||
@@ -212,7 +220,7 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
shader.Buffers.PlatformFetchNativeBuffers();
|
||||
|
||||
|
||||
switch(typeof(TShader))
|
||||
{
|
||||
// TODO: Add remaining shader stages
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "ps_5_0", DefaultCompileFlags, out nativeCode);
|
||||
|
||||
var result = NativeDevice.CreatePixelShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override this(GlitchyEngine.Renderer.RasterizerStateDescription description)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
_description = description;
|
||||
nativeDescription = (.)_description;
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
private void ReleaseAndNullify()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
ReleaseAndNullify!(_nativeTexture);
|
||||
ReleaseAndNullify!(_nativeResourceView);
|
||||
ReleaseAndNullify!(_nativeRenderTargetView);
|
||||
@@ -28,6 +30,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Resize(uint32 width, uint32 height)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
ReleaseAndNullify();
|
||||
|
||||
_description.Width = width;
|
||||
@@ -38,6 +42,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformApplyChanges()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
ReleaseAndNullify();
|
||||
|
||||
PlatformCreateTexture();
|
||||
@@ -62,6 +68,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
private void PlatformCreateTexture()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Texture2DDescription desc = .()
|
||||
{
|
||||
Width = _description.Width,
|
||||
@@ -87,6 +95,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
private void CreateViews()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
var result = NativeDevice.CreateShaderResourceView(_nativeTexture, null, &_nativeResourceView);
|
||||
Log.EngineLogger.Assert(result.Succeeded, "Failed to create resource view");
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
}
|
||||
|
||||
private mixin RtOrBackbuffer(RenderTarget2D renderTarget)
|
||||
@@ -34,11 +34,15 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Clear(RenderTarget2D renderTarget, ColorRGBA color)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
NativeContext.ClearRenderTargetView(RtOrBackbuffer!(renderTarget)._nativeRenderTargetView, color);
|
||||
}
|
||||
|
||||
public override void Clear(DepthStencilTarget target, ClearOptions clearOptions, float depth, uint8 stencil)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
@@ -59,16 +63,22 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void SetRenderTarget(RenderTarget2D renderTarget, int slot, bool setDepthBuffer)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
_context.SetRenderTarget(renderTarget, slot, setDepthBuffer);
|
||||
}
|
||||
|
||||
public override void SetDepthStencilTarget(DepthStencilTarget target)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
_context.SetDepthStencilTarget(target);
|
||||
}
|
||||
|
||||
public override void BindRenderTargets()
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
_context.BindRenderTargets();
|
||||
}
|
||||
|
||||
@@ -76,6 +86,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void SetRasterizerState(RasterizerState rasterizerState)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
SetReference!(_currentRasterizerState, rasterizerState);
|
||||
NativeContext.Rasterizer.SetState(_currentRasterizerState.nativeRasterizerState);
|
||||
}
|
||||
@@ -84,6 +96,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void SetBlendState(BlendState blendState, ColorRGBA blendFactor)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
SetReference!(_currentBlendState, blendState);
|
||||
NativeContext.OutputMerger.SetBlendState(_currentBlendState.nativeBlendState, blendFactor);
|
||||
}
|
||||
@@ -92,12 +106,16 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void SetDepthStencilState(DepthStencilState depthStencilState, uint8 stencilReference)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
SetReference!(_currentDepthStencilState, depthStencilState);
|
||||
NativeContext.OutputMerger.SetDepthStencilState(_currentDepthStencilState.nativeDepthStencilState, stencilReference);
|
||||
}
|
||||
|
||||
public override void DrawIndexed(GeometryBinding geometry)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
if(geometry.IsIndexed)
|
||||
_context.DrawIndexed(geometry.IndexCount, geometry.IndexByteOffset, 0);
|
||||
else
|
||||
@@ -106,11 +124,15 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void DrawIndexedInstanced(GeometryBinding geometry)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
NativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
|
||||
}
|
||||
|
||||
public override void SetViewport(Viewport viewport)
|
||||
{
|
||||
Debug.Profiler.ProfileRendererFunction!();
|
||||
|
||||
_context.SetViewport(viewport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PlatformCreateSamplerState()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
_desc.ToNative(var nativeDesc);
|
||||
|
||||
HResult result = NativeDevice.CreateSamplerState(ref nativeDesc, &nativeSamplerState);
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
internal static void PlattformCompileShaderFromSource(String code, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, out ID3DBlob* shaderBlob)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
ShaderMacro* nativeMacros = macros == null ? null : new:ScopedAlloc! ShaderMacro[macros.Count]*;
|
||||
|
||||
for(int i < macros?.Count ?? 0)
|
||||
@@ -51,6 +53,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected internal void Reflect(ID3DBlob* shaderCode)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
ID3D11ShaderReflection* reflection = null;
|
||||
var result = D3DCompiler.D3DReflect(shaderCode.GetBufferPointer(), shaderCode.GetBufferSize(), &reflection);
|
||||
if(result.Failed)
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public this(GraphicsContext context)
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
_context = context;
|
||||
|
||||
SetResolutionFromWindow();
|
||||
@@ -24,6 +26,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public ~this()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
nativeDxgiDevice?.Release();
|
||||
nativeSwapChain?.Release();
|
||||
}
|
||||
@@ -38,11 +42,15 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
ApplyChanges();
|
||||
}
|
||||
|
||||
public override void ApplyChanges()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
if(!_changed)
|
||||
return;
|
||||
|
||||
@@ -54,6 +62,8 @@ namespace GlitchyEngine.Renderer
|
||||
*/
|
||||
public void UpdateSwapchain()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
Log.EngineLogger.Trace($"Updating swap chain ({_width}, {_height})");
|
||||
|
||||
uint32 backBufferCount = 2;
|
||||
@@ -112,12 +122,16 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
internal void GetBackbuffer(out ID3D11Texture2D* texture)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
var result = nativeSwapChain.GetBuffer<ID3D11Texture2D>(0, out texture);
|
||||
Log.EngineLogger.Assert(result.Succeeded, "Failed to get backbuffer.");
|
||||
}
|
||||
|
||||
public override void Present()
|
||||
{
|
||||
Debug.Profiler.ProfileFunction!();
|
||||
|
||||
nativeSwapChain.Present(Application.Get().Window.IsVSync ? 1 : 0, .None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace GlitchyEngine.Renderer
|
||||
*/
|
||||
protected bool LoadResourcePlatform<T>(StringView path, ref T* texture) where T : ID3D11Resource
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
((ID3D11Resource*)texture)?.Release();
|
||||
nativeResourceView?.Release();
|
||||
|
||||
@@ -92,6 +94,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void LoadTexturePlatform()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
LoadResourcePlatform(_path, ref nativeTexture);
|
||||
|
||||
let resType = nativeTexture.GetResourceType();
|
||||
@@ -102,12 +106,16 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
PrepareTexturePlatform(desc, isRenderTarget);
|
||||
InternalCreateTexture(data, linePitch, 0);
|
||||
}
|
||||
|
||||
private void InternalCreateTexture(void* data, uint32 linePitch, uint32 slicePitch)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
SubresourceData resData = .(data, linePitch, slicePitch);
|
||||
|
||||
// If data is null, set subresourceData null
|
||||
@@ -122,6 +130,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void PrepareTexturePlatform(Texture2DDesc desc, bool isRenderTarget)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
nativeTexture?.Release();
|
||||
nativeTexture = null;
|
||||
nativeResourceView?.Release();
|
||||
@@ -137,6 +147,8 @@ namespace GlitchyEngine.Renderer
|
||||
protected override System.Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
|
||||
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
if(nativeTexture == null)
|
||||
{
|
||||
if(destX == 0 && destY == 0 && destWidth == nativeDesc.Width && destHeight == nativeDesc.Height)
|
||||
@@ -189,6 +201,8 @@ namespace GlitchyEngine.Renderer
|
||||
ResourceBox sourceBox = default, uint32 destX = 0, uint32 destY = 0,
|
||||
uint32 srcArraySlice = 0, uint32 srcMipSlice = 0, uint32 destArraySlice = 0, uint32 destMipSlice = 0)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Log.EngineLogger.AssertDebug(source != destination || srcArraySlice != destArraySlice
|
||||
|| srcMipSlice != destMipSlice, "Cannot copy from and to the same sub resource.");
|
||||
|
||||
@@ -215,6 +229,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void CopyTo(Texture2D destination)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
if(nativeTexture == null)
|
||||
return;
|
||||
|
||||
@@ -252,6 +268,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void LoadTexturePlatform()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
LoadResourcePlatform(_path, ref nativeTexture);
|
||||
|
||||
let resType = nativeTexture.GetResourceType();
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected override void CreateNativeLayout()
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
var nativeElements = scope InputElementDescription[_elements.Count];
|
||||
|
||||
ToNativeLayout(_elements, nativeElements);
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "vs_5_0", DefaultCompileFlags, out nativeCode);
|
||||
|
||||
var result = NativeDevice.CreateVertexShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
||||
|
||||
Reference in New Issue
Block a user