mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Instrumentation
This commit is contained in:
@@ -3,7 +3,7 @@ Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", DirectXTK = "*", F
|
|||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "GlitchyEngine"
|
Name = "GlitchyEngine"
|
||||||
ProcessorMacros = ["GE_GRAPHICS_DX11", "GE_PROFILE", "GE_SHADER_MATRIX_MISMATCH_IS_ERROR", "GE_SHADER_VAR_TYPE_MISMATCH_IS_ERROR", "GE_SHADER_UNUSED_VARIABLE_IS_WARNING", "GE_WINDOWS"]
|
ProcessorMacros = ["GE_GRAPHICS_DX11", "GE_SHADER_MATRIX_MISMATCH_IS_ERROR", "GE_SHADER_VAR_TYPE_MISMATCH_IS_ERROR", "GE_SHADER_UNUSED_VARIABLE_IS_WARNING", "GE_WINDOWS"]
|
||||||
|
|
||||||
[Configs.Paranoid.Win32]
|
[Configs.Paranoid.Win32]
|
||||||
PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
|
PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
|
||||||
@@ -14,8 +14,14 @@ PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"]
|
|||||||
[Configs.Release.Win32]
|
[Configs.Release.Win32]
|
||||||
PreprocessorMacros = ["RELEASE", "GE_WINDOWS"]
|
PreprocessorMacros = ["RELEASE", "GE_WINDOWS"]
|
||||||
|
|
||||||
|
[Configs.Release.Win64]
|
||||||
|
PreprocessorMacros = ["RELEASE", "GE_PROFILE"]
|
||||||
|
|
||||||
[Configs.Test.Win32]
|
[Configs.Test.Win32]
|
||||||
PreprocessorMacros = ["TEST", "GE_WINDOWS"]
|
PreprocessorMacros = ["TEST", "GE_WINDOWS"]
|
||||||
|
|
||||||
[Configs.Test.Win64]
|
[Configs.Test.Win64]
|
||||||
PreprocessorMacros = ["TEST", "GE_WINDOWS"]
|
PreprocessorMacros = ["TEST", "GE_WINDOWS"]
|
||||||
|
|
||||||
|
[Configs.Debug.Win64]
|
||||||
|
PreprocessorMacros = ["DEBUG", "GE_PROFILE", "GE_PROFILE_RENDERER", "GE_PROFILE_RESOURCES"]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using GlitchyEngine.Events;
|
using GlitchyEngine.Events;
|
||||||
using GlitchyEngine.ImGui;
|
using GlitchyEngine.ImGui;
|
||||||
using GlitchyEngine.Renderer;
|
using GlitchyEngine.Renderer;
|
||||||
|
using GlitchyEngine.Debug;
|
||||||
|
|
||||||
namespace GlitchyEngine
|
namespace GlitchyEngine
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
|
Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.Assert(s_Instance == null, "Tried to create a second application.");
|
Log.EngineLogger.Assert(s_Instance == null, "Tried to create a second application.");
|
||||||
s_Instance = this;
|
s_Instance = this;
|
||||||
|
|
||||||
@@ -57,6 +60,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Profiler.ProfileFunction!();
|
||||||
|
|
||||||
delete _layerStack;
|
delete _layerStack;
|
||||||
SamplerStateManager.Uninit();
|
SamplerStateManager.Uninit();
|
||||||
Renderer.Deinit();
|
Renderer.Deinit();
|
||||||
@@ -65,6 +70,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void OnEvent(Event e)
|
public void OnEvent(Event e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(!_running)
|
if(!_running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -90,8 +97,12 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
while(_running)
|
while(_running)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileScope!("Loop");
|
||||||
|
|
||||||
if(allowFrame)
|
if(allowFrame)
|
||||||
{
|
{
|
||||||
_gameTime.NewFrame();
|
_gameTime.NewFrame();
|
||||||
@@ -110,6 +121,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
if(allowFrame && !_isMinimized)
|
if(allowFrame && !_isMinimized)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileScope!("Update Layers");
|
||||||
|
|
||||||
for(Layer layer in _layerStack)
|
for(Layer layer in _layerStack)
|
||||||
layer.Update(_gameTime);
|
layer.Update(_gameTime);
|
||||||
}
|
}
|
||||||
@@ -125,9 +138,21 @@ namespace GlitchyEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushLayer(Layer ownLayer) => _layerStack.PushLayer(ownLayer);
|
public void PushLayer(Layer ownLayer)
|
||||||
|
{
|
||||||
|
Profiler.ProfileFunction!();
|
||||||
|
|
||||||
public void PushOverlay(Layer ownOverlay) => _layerStack.PushOverlay(ownOverlay);
|
_layerStack.PushLayer(ownLayer);
|
||||||
|
ownLayer.OnAttach();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PushOverlay(Layer ownOverlay)
|
||||||
|
{
|
||||||
|
Profiler.ProfileFunction!();
|
||||||
|
|
||||||
|
_layerStack.PushOverlay(ownOverlay);
|
||||||
|
ownOverlay.OnAttach();
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnWindowClose(WindowCloseEvent e)
|
public bool OnWindowClose(WindowCloseEvent e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,40 @@ namespace GlitchyEngine.Debug
|
|||||||
{
|
{
|
||||||
scope:mixin PerformanceTimer(scopeName)
|
scope:mixin PerformanceTimer(scopeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extension
|
||||||
|
|
||||||
|
#if !GE_PROFILE_RENDERER
|
||||||
|
[SkipCall]
|
||||||
|
#endif
|
||||||
|
public static mixin ProfileRendererFunction()
|
||||||
|
{
|
||||||
|
scope:mixin PerformanceTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !GE_PROFILE_RENDERER
|
||||||
|
[SkipCall]
|
||||||
|
#endif
|
||||||
|
public static mixin ProfileRendererScope(char8* scopeName)
|
||||||
|
{
|
||||||
|
scope:mixin PerformanceTimer(scopeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !GE_PROFILE_RESOURCES
|
||||||
|
[SkipCall]
|
||||||
|
#endif
|
||||||
|
public static mixin ProfileResourceFunction()
|
||||||
|
{
|
||||||
|
scope:mixin PerformanceTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !GE_PROFILE_RESOURCES
|
||||||
|
[SkipCall]
|
||||||
|
#endif
|
||||||
|
public static mixin ProfileResourceScope(char8* scopeName)
|
||||||
|
{
|
||||||
|
scope:mixin PerformanceTimer(scopeName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PerformanceTimer
|
class PerformanceTimer
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public override void OnAttach()
|
public override void OnAttach()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
//ImGuiImplWin32.EnableDpiAwareness();
|
//ImGuiImplWin32.EnableDpiAwareness();
|
||||||
Log.EngineLogger.Trace("Initializing ImGui...");
|
Log.EngineLogger.Trace("Initializing ImGui...");
|
||||||
|
|
||||||
@@ -56,6 +58,8 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public override void OnDetach()
|
public override void OnDetach()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
ImGuiImplDX11.Shutdown();
|
ImGuiImplDX11.Shutdown();
|
||||||
ImGuiImplWin32.Shutdown();
|
ImGuiImplWin32.Shutdown();
|
||||||
ImGui.DestroyContext();
|
ImGui.DestroyContext();
|
||||||
@@ -184,6 +188,8 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public void Begin()
|
public void Begin()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
// Todo:
|
// Todo:
|
||||||
//var v = DirectX.ImmediateContext;
|
//var v = DirectX.ImmediateContext;
|
||||||
//v.OutputMerger.SetRenderTargets(1, &DirectX.BackBufferTarget, null);
|
//v.OutputMerger.SetRenderTargets(1, &DirectX.BackBufferTarget, null);
|
||||||
@@ -198,11 +204,16 @@ namespace GlitchyEngine.ImGui
|
|||||||
bool showDemo = true;
|
bool showDemo = true;
|
||||||
public void ImGuiRender()
|
public void ImGuiRender()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Begin();
|
Begin();
|
||||||
|
|
||||||
var event = scope ImGuiRenderEvent();
|
{
|
||||||
Application.Get().OnEvent(event);
|
Debug.Profiler.ProfileScope!("ImGuiRenderEvent");
|
||||||
|
|
||||||
|
var event = scope ImGuiRenderEvent();
|
||||||
|
Application.Get().OnEvent(event);
|
||||||
|
}
|
||||||
//ImGui.ShowDemoWindow(&showDemo);
|
//ImGui.ShowDemoWindow(&showDemo);
|
||||||
|
|
||||||
End();
|
End();
|
||||||
@@ -210,6 +221,8 @@ namespace GlitchyEngine.ImGui
|
|||||||
|
|
||||||
public void End()
|
public void End()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
ImGui.IO* io = ImGui.GetIO();
|
ImGui.IO* io = ImGui.GetIO();
|
||||||
|
|
||||||
let window = Application.Get().Window;
|
let window = Application.Get().Window;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace GlitchyEngine
|
|||||||
public void PushLayer(Layer ownLayer)
|
public void PushLayer(Layer ownLayer)
|
||||||
{
|
{
|
||||||
_layers.Insert(_insertIndex++, ownLayer);
|
_layers.Insert(_insertIndex++, ownLayer);
|
||||||
ownLayer.OnAttach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +39,6 @@ namespace GlitchyEngine
|
|||||||
public void PushOverlay(Layer ownOverlay)
|
public void PushOverlay(Layer ownOverlay)
|
||||||
{
|
{
|
||||||
_layers.Add(ownOverlay);
|
_layers.Add(ownOverlay);
|
||||||
ownOverlay.OnAttach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public this(float aspectRatio, bool rotation = false)
|
public this(float aspectRatio, bool rotation = false)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_aspectRatio = aspectRatio;
|
_aspectRatio = aspectRatio;
|
||||||
_rotation = rotation;
|
_rotation = rotation;
|
||||||
|
|
||||||
@@ -35,6 +37,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(Application.Get().Window.IsActive)
|
if(Application.Get().Window.IsActive)
|
||||||
{
|
{
|
||||||
Vector3 movement = .();
|
Vector3 movement = .();
|
||||||
@@ -82,6 +86,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void OnEvent(Event e)
|
public void OnEvent(Event e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
EventDispatcher dispatcher = EventDispatcher(e);
|
EventDispatcher dispatcher = EventDispatcher(e);
|
||||||
dispatcher.Dispatch<MouseScrolledEvent>(scope => OnMouseScrolled);
|
dispatcher.Dispatch<MouseScrolledEvent>(scope => OnMouseScrolled);
|
||||||
dispatcher.Dispatch<WindowResizeEvent>(scope => OnWindowResized);
|
dispatcher.Dispatch<WindowResizeEvent>(scope => OnWindowResized);
|
||||||
@@ -89,6 +95,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
private bool OnMouseScrolled(MouseScrolledEvent e)
|
private bool OnMouseScrolled(MouseScrolledEvent e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_zoomLevel -= e.YOffset * 0.25f;
|
_zoomLevel -= e.YOffset * 0.25f;
|
||||||
|
|
||||||
_zoomLevel = Math.Max(_zoomLevel, 0.25f);
|
_zoomLevel = Math.Max(_zoomLevel, 0.25f);
|
||||||
@@ -100,6 +108,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
private bool OnWindowResized(WindowResizeEvent e)
|
private bool OnWindowResized(WindowResizeEvent e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_aspectRatio = (float)e.Width / (float)e.Height;
|
_aspectRatio = (float)e.Width / (float)e.Height;
|
||||||
|
|
||||||
UpdateCamera();
|
UpdateCamera();
|
||||||
@@ -109,6 +119,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
private void UpdateCamera()
|
private void UpdateCamera()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_camera.Left = -_aspectRatio * _zoomLevel;
|
_camera.Left = -_aspectRatio * _zoomLevel;
|
||||||
_camera.Right = _aspectRatio * _zoomLevel;
|
_camera.Right = _aspectRatio * _zoomLevel;
|
||||||
_camera.Top = _zoomLevel;
|
_camera.Top = _zoomLevel;
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public this(float aspectRatio)
|
public this(float aspectRatio)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_aspectRatio = aspectRatio;
|
_aspectRatio = aspectRatio;
|
||||||
|
|
||||||
_camera = new PerspectiveCamera();
|
_camera = new PerspectiveCamera();
|
||||||
@@ -94,6 +96,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void Update(GameTime gameTime)
|
public void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(Application.Get().Window.IsActive)
|
if(Application.Get().Window.IsActive)
|
||||||
{
|
{
|
||||||
Vector3 movement = .();
|
Vector3 movement = .();
|
||||||
@@ -150,12 +154,16 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public void OnEvent(Event e)
|
public void OnEvent(Event e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
EventDispatcher dispatcher = EventDispatcher(e);
|
EventDispatcher dispatcher = EventDispatcher(e);
|
||||||
dispatcher.Dispatch<WindowResizeEvent>(scope => OnWindowResized);
|
dispatcher.Dispatch<WindowResizeEvent>(scope => OnWindowResized);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnWindowResized(WindowResizeEvent e)
|
private bool OnWindowResized(WindowResizeEvent e)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_aspectRatio = (float)e.Width / (float)e.Height;
|
_aspectRatio = (float)e.Width / (float)e.Height;
|
||||||
|
|
||||||
UpdateCamera();
|
UpdateCamera();
|
||||||
@@ -165,6 +173,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
private void UpdateCamera()
|
private void UpdateCamera()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_camera.AspectRatio = _aspectRatio;
|
_camera.AspectRatio = _aspectRatio;
|
||||||
_camera.FovY = _fovY;
|
_camera.FovY = _fovY;
|
||||||
_camera.Rotation = _cameraRotation;
|
_camera.Rotation = _cameraRotation;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace GlitchyEngine.Platform.DX11
|
|||||||
|
|
||||||
internal static void Dx11Init()
|
internal static void Dx11Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(!IsDx11Initialized)
|
if(!IsDx11Initialized)
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Trace("Creating D3D11 Device and Context...");
|
Log.EngineLogger.Trace("Creating D3D11 Device and Context...");
|
||||||
@@ -33,19 +35,28 @@ namespace GlitchyEngine.Platform.DX11
|
|||||||
FeatureLevel[] levels = scope .(.Level_11_0);
|
FeatureLevel[] levels = scope .(.Level_11_0);
|
||||||
|
|
||||||
FeatureLevel deviceLevel = ?;
|
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}");
|
Log.EngineLogger.Assert(deviceResult.Succeeded, scope $"Failed to create D3D11 Device. Message({(int32)deviceResult}): {deviceResult}");
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if(NativeDevice.QueryInterface<ID3D11Debug>(out DebugDevice).Succeeded)
|
|
||||||
{
|
{
|
||||||
ID3D11InfoQueue* infoQueue;
|
Debug.Profiler.ProfileScope!("Query for ID3D11Debug");
|
||||||
if(NativeDevice.QueryInterface<ID3D11InfoQueue>(out infoQueue).Succeeded)
|
if(NativeDevice.QueryInterface<ID3D11Debug>(out DebugDevice).Succeeded)
|
||||||
{
|
{
|
||||||
infoQueue.SetBreakOnSeverity(.Corruption, true);
|
ID3D11InfoQueue* infoQueue;
|
||||||
infoQueue.SetBreakOnSeverity(.Error, true);
|
if(NativeDevice.QueryInterface<ID3D11InfoQueue>(out infoQueue).Succeeded)
|
||||||
|
{
|
||||||
|
infoQueue.SetBreakOnSeverity(.Corruption, true);
|
||||||
|
infoQueue.SetBreakOnSeverity(.Error, true);
|
||||||
|
|
||||||
infoQueue.Release();
|
infoQueue.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -63,6 +74,8 @@ namespace GlitchyEngine.Platform.DX11
|
|||||||
|
|
||||||
internal static void Dx11Release()
|
internal static void Dx11Release()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
NativeDevice.Release();
|
NativeDevice.Release();
|
||||||
NativeContext.Release();
|
NativeContext.Release();
|
||||||
DebugDevice.ReportLiveDeviceObjects(.Detail);
|
DebugDevice.ReportLiveDeviceObjects(.Detail);
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformCreateBlendState()
|
protected override void PlatformCreateBlendState()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
BlendDescription nativeDesc = .Default;
|
BlendDescription nativeDesc = .Default;
|
||||||
nativeDesc.IndependentBlendEnable = _desc.IndependentBlendEnable;
|
nativeDesc.IndependentBlendEnable = _desc.IndependentBlendEnable;
|
||||||
nativeDesc.AlphaToCoverageEnable = _desc.AlphaToCoverageEnable;
|
nativeDesc.AlphaToCoverageEnable = _desc.AlphaToCoverageEnable;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private Result<void> InternalCreateBuffer(void* data, uint32 byteLength, uint32 dstByteOffset)
|
private Result<void> InternalCreateBuffer(void* data, uint32 byteLength, uint32 dstByteOffset)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
nativeDescription = (.)_description;
|
nativeDescription = (.)_description;
|
||||||
|
|
||||||
uint8* byteData = (.)data;
|
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)
|
protected override Result<void> PlatformSetData(void* data, uint32 byteLength, uint32 dstByteOffset, GlitchyEngine.Renderer.MapType mapType)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(nativeBuffer == null)
|
if(nativeBuffer == null)
|
||||||
{
|
{
|
||||||
// We can pass the data while creating the buffer, so we can return here.
|
// We can pass the data while creating the buffer, so we can return here.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
internal void PlatformFetchNativeBuffers()
|
internal void PlatformFetchNativeBuffers()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
for(let buffer in _buffers)
|
for(let buffer in _buffers)
|
||||||
{
|
{
|
||||||
nativeBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
|
nativeBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
internal this(ConstantBuffer constantBuffer, ID3D11ShaderReflectionVariable* variableReflection)
|
internal this(ConstantBuffer constantBuffer, ID3D11ShaderReflectionVariable* variableReflection)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_constantBuffer = constantBuffer;
|
_constantBuffer = constantBuffer;
|
||||||
|
|
||||||
HResult result = variableReflection.GetDescription(let variableDescription);
|
HResult result = variableReflection.GetDescription(let variableDescription);
|
||||||
@@ -51,6 +53,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
internal this(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
internal this(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Reflect(bufferReflection);
|
Reflect(bufferReflection);
|
||||||
|
|
||||||
ConstructBuffer();
|
ConstructBuffer();
|
||||||
@@ -60,6 +64,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void Reflect(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
private void Reflect(ID3D11ShaderReflectionConstantBuffer* bufferReflection)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
HResult result = bufferReflection.GetDescription(let bufferDescription);
|
HResult result = bufferReflection.GetDescription(let bufferDescription);
|
||||||
Log.EngineLogger.Assert(result.Succeeded, scope $"Failed to get buffer description. Error({(int)result}): {result}");
|
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)
|
public this(GEDSSDesc description)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_description = description;
|
_description = description;
|
||||||
nativeDescription = (.)description;
|
nativeDescription = (.)description;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformCreate()
|
protected override void PlatformCreate()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Texture2DDescription desc = .();
|
Texture2DDescription desc = .();
|
||||||
desc.Format = (.)_format;
|
desc.Format = (.)_format;
|
||||||
desc.ArraySize = 1;
|
desc.ArraySize = 1;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
protected override void Compile(String vsPath, String vsEntry, String psPath, String psEntry)
|
protected override void Compile(String vsPath, String vsEntry, String psPath, String psEntry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// Todo: macros
|
// Todo: macros
|
||||||
VertexShader = new VertexShader(vsPath, vsEntry);
|
VertexShader = new VertexShader(vsPath, vsEntry);
|
||||||
PixelShader = new PixelShader(psPath, psEntry);
|
PixelShader = new PixelShader(psPath, psEntry);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformSetVertexBuffer(VertexBufferBinding binding, uint32 slot)
|
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.");
|
Log.EngineLogger.Assert(slot < nativeBuffers.Count, "The buffer slot has to be in the range from 0 to 31.");
|
||||||
|
|
||||||
VertexBuffer vertexBuffer = binding.Buffer;
|
VertexBuffer vertexBuffer = binding.Buffer;
|
||||||
@@ -59,12 +61,16 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformSetVertexLayout(VertexLayout vertexLayout)
|
protected override void PlatformSetVertexLayout(VertexLayout vertexLayout)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
nativeVertexLayout?.Release();
|
nativeVertexLayout?.Release();
|
||||||
nativeVertexLayout = vertexLayout?.nativeLayout..AddRef();
|
nativeVertexLayout = vertexLayout?.nativeLayout..AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PlatformSetIndexBuffer(IndexBuffer indexBuffer)
|
protected override void PlatformSetIndexBuffer(IndexBuffer indexBuffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.Assert(indexBuffer.nativeDescription.BindFlags.HasFlag(.IndexBuffer),
|
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.");
|
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()
|
public override void Bind()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
NativeContext.InputAssembler.SetVertexBuffers(0, nativeBuffers.Count, &nativeBuffers, &bufferStrides, &bufferOffsets);
|
NativeContext.InputAssembler.SetVertexBuffers(0, nativeBuffers.Count, &nativeBuffers, &bufferStrides, &bufferOffsets);
|
||||||
NativeContext.InputAssembler.SetInputLayout(_vertexLayout.nativeLayout);
|
NativeContext.InputAssembler.SetInputLayout(_vertexLayout.nativeLayout);
|
||||||
NativeContext.InputAssembler.SetPrimitiveTopology((.)_primitiveTopology);
|
NativeContext.InputAssembler.SetPrimitiveTopology((.)_primitiveTopology);
|
||||||
@@ -89,6 +97,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Unbind()
|
public override void Unbind()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
ID3D11Buffer*[nativeBuffers.Count] nullBuffers = .();
|
ID3D11Buffer*[nativeBuffers.Count] nullBuffers = .();
|
||||||
uint32[nativeBuffers.Count] zeroStrides = .();
|
uint32[nativeBuffers.Count] zeroStrides = .();
|
||||||
uint32[nativeBuffers.Count] zeroOffsets = .();
|
uint32[nativeBuffers.Count] zeroOffsets = .();
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(Windows.HWnd windowHandle)
|
public this(Windows.HWnd windowHandle)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
nativeWindowHandle = windowHandle;
|
nativeWindowHandle = windowHandle;
|
||||||
|
|
||||||
_swapChain = new SwapChain(this);
|
_swapChain = new SwapChain(this);
|
||||||
@@ -47,6 +49,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
delete _swapChain;
|
delete _swapChain;
|
||||||
|
|
||||||
Dx11Release();
|
Dx11Release();
|
||||||
@@ -54,6 +58,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Dx11Init();
|
Dx11Init();
|
||||||
|
|
||||||
SwapChain.Init();
|
SwapChain.Init();
|
||||||
@@ -177,6 +183,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
private void BindShaderToStage<TShader>(TShader shader) where TShader : Shader
|
private void BindShaderToStage<TShader>(TShader shader) where TShader : Shader
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
uint32 _firstTexture = D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT;
|
uint32 _firstTexture = D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT;
|
||||||
uint32 _textureCount = 0;
|
uint32 _textureCount = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
|
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);
|
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "ps_5_0", DefaultCompileFlags, out nativeCode);
|
||||||
|
|
||||||
var result = NativeDevice.CreatePixelShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
var result = NativeDevice.CreatePixelShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override this(GlitchyEngine.Renderer.RasterizerStateDescription description)
|
public override this(GlitchyEngine.Renderer.RasterizerStateDescription description)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_description = description;
|
_description = description;
|
||||||
nativeDescription = (.)_description;
|
nativeDescription = (.)_description;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void ReleaseAndNullify()
|
private void ReleaseAndNullify()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ReleaseAndNullify!(_nativeTexture);
|
ReleaseAndNullify!(_nativeTexture);
|
||||||
ReleaseAndNullify!(_nativeResourceView);
|
ReleaseAndNullify!(_nativeResourceView);
|
||||||
ReleaseAndNullify!(_nativeRenderTargetView);
|
ReleaseAndNullify!(_nativeRenderTargetView);
|
||||||
@@ -28,6 +30,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Resize(uint32 width, uint32 height)
|
public override void Resize(uint32 width, uint32 height)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ReleaseAndNullify();
|
ReleaseAndNullify();
|
||||||
|
|
||||||
_description.Width = width;
|
_description.Width = width;
|
||||||
@@ -38,6 +42,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformApplyChanges()
|
protected override void PlatformApplyChanges()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ReleaseAndNullify();
|
ReleaseAndNullify();
|
||||||
|
|
||||||
PlatformCreateTexture();
|
PlatformCreateTexture();
|
||||||
@@ -62,6 +68,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void PlatformCreateTexture()
|
private void PlatformCreateTexture()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Texture2DDescription desc = .()
|
Texture2DDescription desc = .()
|
||||||
{
|
{
|
||||||
Width = _description.Width,
|
Width = _description.Width,
|
||||||
@@ -87,6 +95,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void CreateViews()
|
private void CreateViews()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
var result = NativeDevice.CreateShaderResourceView(_nativeTexture, null, &_nativeResourceView);
|
var result = NativeDevice.CreateShaderResourceView(_nativeTexture, null, &_nativeResourceView);
|
||||||
Log.EngineLogger.Assert(result.Succeeded, "Failed to create resource view");
|
Log.EngineLogger.Assert(result.Succeeded, "Failed to create resource view");
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
}
|
}
|
||||||
|
|
||||||
private mixin RtOrBackbuffer(RenderTarget2D renderTarget)
|
private mixin RtOrBackbuffer(RenderTarget2D renderTarget)
|
||||||
@@ -34,11 +34,15 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Clear(RenderTarget2D renderTarget, ColorRGBA color)
|
public override void Clear(RenderTarget2D renderTarget, ColorRGBA color)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
NativeContext.ClearRenderTargetView(RtOrBackbuffer!(renderTarget)._nativeRenderTargetView, color);
|
NativeContext.ClearRenderTargetView(RtOrBackbuffer!(renderTarget)._nativeRenderTargetView, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Clear(DepthStencilTarget target, ClearOptions clearOptions, float depth, uint8 stencil)
|
public override void Clear(DepthStencilTarget target, ClearOptions clearOptions, float depth, uint8 stencil)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(target == null)
|
if(target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -59,16 +63,22 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void SetRenderTarget(RenderTarget2D renderTarget, int slot, bool setDepthBuffer)
|
public override void SetRenderTarget(RenderTarget2D renderTarget, int slot, bool setDepthBuffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_context.SetRenderTarget(renderTarget, slot, setDepthBuffer);
|
_context.SetRenderTarget(renderTarget, slot, setDepthBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetDepthStencilTarget(DepthStencilTarget target)
|
public override void SetDepthStencilTarget(DepthStencilTarget target)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_context.SetDepthStencilTarget(target);
|
_context.SetDepthStencilTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void BindRenderTargets()
|
public override void BindRenderTargets()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_context.BindRenderTargets();
|
_context.BindRenderTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +86,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void SetRasterizerState(RasterizerState rasterizerState)
|
public override void SetRasterizerState(RasterizerState rasterizerState)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
SetReference!(_currentRasterizerState, rasterizerState);
|
SetReference!(_currentRasterizerState, rasterizerState);
|
||||||
NativeContext.Rasterizer.SetState(_currentRasterizerState.nativeRasterizerState);
|
NativeContext.Rasterizer.SetState(_currentRasterizerState.nativeRasterizerState);
|
||||||
}
|
}
|
||||||
@@ -84,6 +96,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void SetBlendState(BlendState blendState, ColorRGBA blendFactor)
|
public override void SetBlendState(BlendState blendState, ColorRGBA blendFactor)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
SetReference!(_currentBlendState, blendState);
|
SetReference!(_currentBlendState, blendState);
|
||||||
NativeContext.OutputMerger.SetBlendState(_currentBlendState.nativeBlendState, blendFactor);
|
NativeContext.OutputMerger.SetBlendState(_currentBlendState.nativeBlendState, blendFactor);
|
||||||
}
|
}
|
||||||
@@ -92,12 +106,16 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void SetDepthStencilState(DepthStencilState depthStencilState, uint8 stencilReference)
|
public override void SetDepthStencilState(DepthStencilState depthStencilState, uint8 stencilReference)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
SetReference!(_currentDepthStencilState, depthStencilState);
|
SetReference!(_currentDepthStencilState, depthStencilState);
|
||||||
NativeContext.OutputMerger.SetDepthStencilState(_currentDepthStencilState.nativeDepthStencilState, stencilReference);
|
NativeContext.OutputMerger.SetDepthStencilState(_currentDepthStencilState.nativeDepthStencilState, stencilReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawIndexed(GeometryBinding geometry)
|
public override void DrawIndexed(GeometryBinding geometry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(geometry.IsIndexed)
|
if(geometry.IsIndexed)
|
||||||
_context.DrawIndexed(geometry.IndexCount, geometry.IndexByteOffset, 0);
|
_context.DrawIndexed(geometry.IndexCount, geometry.IndexByteOffset, 0);
|
||||||
else
|
else
|
||||||
@@ -106,11 +124,15 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void DrawIndexedInstanced(GeometryBinding geometry)
|
public override void DrawIndexedInstanced(GeometryBinding geometry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
NativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
|
NativeContext.DrawIndexedInstanced(geometry.IndexCount, geometry.InstanceCount, geometry.IndexByteOffset, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetViewport(Viewport viewport)
|
public override void SetViewport(Viewport viewport)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_context.SetViewport(viewport);
|
_context.SetViewport(viewport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PlatformCreateSamplerState()
|
protected override void PlatformCreateSamplerState()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_desc.ToNative(var nativeDesc);
|
_desc.ToNative(var nativeDesc);
|
||||||
|
|
||||||
HResult result = NativeDevice.CreateSamplerState(ref nativeDesc, &nativeSamplerState);
|
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)
|
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]*;
|
ShaderMacro* nativeMacros = macros == null ? null : new:ScopedAlloc! ShaderMacro[macros.Count]*;
|
||||||
|
|
||||||
for(int i < macros?.Count ?? 0)
|
for(int i < macros?.Count ?? 0)
|
||||||
@@ -51,6 +53,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected internal void Reflect(ID3DBlob* shaderCode)
|
protected internal void Reflect(ID3DBlob* shaderCode)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ID3D11ShaderReflection* reflection = null;
|
ID3D11ShaderReflection* reflection = null;
|
||||||
var result = D3DCompiler.D3DReflect(shaderCode.GetBufferPointer(), shaderCode.GetBufferSize(), &reflection);
|
var result = D3DCompiler.D3DReflect(shaderCode.GetBufferPointer(), shaderCode.GetBufferSize(), &reflection);
|
||||||
if(result.Failed)
|
if(result.Failed)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(GraphicsContext context)
|
public this(GraphicsContext context)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
||||||
SetResolutionFromWindow();
|
SetResolutionFromWindow();
|
||||||
@@ -24,6 +26,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
nativeDxgiDevice?.Release();
|
nativeDxgiDevice?.Release();
|
||||||
nativeSwapChain?.Release();
|
nativeSwapChain?.Release();
|
||||||
}
|
}
|
||||||
@@ -38,11 +42,15 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
ApplyChanges();
|
ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyChanges()
|
public override void ApplyChanges()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(!_changed)
|
if(!_changed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -54,6 +62,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public void UpdateSwapchain()
|
public void UpdateSwapchain()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.Trace($"Updating swap chain ({_width}, {_height})");
|
Log.EngineLogger.Trace($"Updating swap chain ({_width}, {_height})");
|
||||||
|
|
||||||
uint32 backBufferCount = 2;
|
uint32 backBufferCount = 2;
|
||||||
@@ -112,12 +122,16 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
internal void GetBackbuffer(out ID3D11Texture2D* texture)
|
internal void GetBackbuffer(out ID3D11Texture2D* texture)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
var result = nativeSwapChain.GetBuffer<ID3D11Texture2D>(0, out texture);
|
var result = nativeSwapChain.GetBuffer<ID3D11Texture2D>(0, out texture);
|
||||||
Log.EngineLogger.Assert(result.Succeeded, "Failed to get backbuffer.");
|
Log.EngineLogger.Assert(result.Succeeded, "Failed to get backbuffer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Present()
|
public override void Present()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
nativeSwapChain.Present(Application.Get().Window.IsVSync ? 1 : 0, .None);
|
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
|
protected bool LoadResourcePlatform<T>(StringView path, ref T* texture) where T : ID3D11Resource
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
((ID3D11Resource*)texture)?.Release();
|
((ID3D11Resource*)texture)?.Release();
|
||||||
nativeResourceView?.Release();
|
nativeResourceView?.Release();
|
||||||
|
|
||||||
@@ -92,6 +94,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void LoadTexturePlatform()
|
protected override void LoadTexturePlatform()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
LoadResourcePlatform(_path, ref nativeTexture);
|
LoadResourcePlatform(_path, ref nativeTexture);
|
||||||
|
|
||||||
let resType = nativeTexture.GetResourceType();
|
let resType = nativeTexture.GetResourceType();
|
||||||
@@ -102,12 +106,16 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch)
|
protected override void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
PrepareTexturePlatform(desc, isRenderTarget);
|
PrepareTexturePlatform(desc, isRenderTarget);
|
||||||
InternalCreateTexture(data, linePitch, 0);
|
InternalCreateTexture(data, linePitch, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InternalCreateTexture(void* data, uint32 linePitch, uint32 slicePitch)
|
private void InternalCreateTexture(void* data, uint32 linePitch, uint32 slicePitch)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
SubresourceData resData = .(data, linePitch, slicePitch);
|
SubresourceData resData = .(data, linePitch, slicePitch);
|
||||||
|
|
||||||
// If data is null, set subresourceData null
|
// If data is null, set subresourceData null
|
||||||
@@ -122,6 +130,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void PrepareTexturePlatform(Texture2DDesc desc, bool isRenderTarget)
|
protected override void PrepareTexturePlatform(Texture2DDesc desc, bool isRenderTarget)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
nativeTexture?.Release();
|
nativeTexture?.Release();
|
||||||
nativeTexture = null;
|
nativeTexture = null;
|
||||||
nativeResourceView?.Release();
|
nativeResourceView?.Release();
|
||||||
@@ -137,6 +147,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
protected override System.Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
|
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)
|
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(nativeTexture == null)
|
if(nativeTexture == null)
|
||||||
{
|
{
|
||||||
if(destX == 0 && destY == 0 && destWidth == nativeDesc.Width && destHeight == nativeDesc.Height)
|
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,
|
ResourceBox sourceBox = default, uint32 destX = 0, uint32 destY = 0,
|
||||||
uint32 srcArraySlice = 0, uint32 srcMipSlice = 0, uint32 destArraySlice = 0, uint32 destMipSlice = 0)
|
uint32 srcArraySlice = 0, uint32 srcMipSlice = 0, uint32 destArraySlice = 0, uint32 destMipSlice = 0)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.AssertDebug(source != destination || srcArraySlice != destArraySlice
|
Log.EngineLogger.AssertDebug(source != destination || srcArraySlice != destArraySlice
|
||||||
|| srcMipSlice != destMipSlice, "Cannot copy from and to the same sub resource.");
|
|| srcMipSlice != destMipSlice, "Cannot copy from and to the same sub resource.");
|
||||||
|
|
||||||
@@ -215,6 +229,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void CopyTo(Texture2D destination)
|
public override void CopyTo(Texture2D destination)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(nativeTexture == null)
|
if(nativeTexture == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -252,6 +268,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void LoadTexturePlatform()
|
protected override void LoadTexturePlatform()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
LoadResourcePlatform(_path, ref nativeTexture);
|
LoadResourcePlatform(_path, ref nativeTexture);
|
||||||
|
|
||||||
let resType = nativeTexture.GetResourceType();
|
let resType = nativeTexture.GetResourceType();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void CreateNativeLayout()
|
protected override void CreateNativeLayout()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
var nativeElements = scope InputElementDescription[_elements.Count];
|
var nativeElements = scope InputElementDescription[_elements.Count];
|
||||||
|
|
||||||
ToNativeLayout(_elements, nativeElements);
|
ToNativeLayout(_elements, nativeElements);
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public override void CompileFromSource(String code, String entryPoint, ShaderDefine[] macros = null)
|
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);
|
Shader.PlattformCompileShaderFromSource(code, macros, entryPoint, "vs_5_0", DefaultCompileFlags, out nativeCode);
|
||||||
|
|
||||||
var result = NativeDevice.CreateVertexShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
var result = NativeDevice.CreateVertexShader(nativeCode.GetBufferPointer(), nativeCode.GetBufferSize(), null, &nativeShader);
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public override static void NewFrame()
|
public override static void NewFrame()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Swap!(CurrentState, LastState);
|
Swap!(CurrentState, LastState);
|
||||||
|
|
||||||
// Get current keyboard state
|
// Get current keyboard state
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public override this(WindowDescription desc)
|
public override this(WindowDescription desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_minMaxInfo.MaximumTrackingSize.x = int32.MaxValue;
|
_minMaxInfo.MaximumTrackingSize.x = int32.MaxValue;
|
||||||
_minMaxInfo.MaximumTrackingSize.y = int32.MaxValue;
|
_minMaxInfo.MaximumTrackingSize.y = int32.MaxValue;
|
||||||
|
|
||||||
@@ -174,6 +176,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(!DestroyWindow(_windowHandle))
|
if(!DestroyWindow(_windowHandle))
|
||||||
{
|
{
|
||||||
HResult res = (.)GetLastError();
|
HResult res = (.)GetLastError();
|
||||||
@@ -188,6 +192,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
private void Init(WindowDescription desc)
|
private void Init(WindowDescription desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.Trace($"Creating window \"{desc.Title}\" ({desc.Width}, {desc.Height})...");
|
Log.EngineLogger.Trace($"Creating window \"{desc.Title}\" ({desc.Width}, {desc.Height})...");
|
||||||
|
|
||||||
_instanceHandle = (.)GetModuleHandleW(null);
|
_instanceHandle = (.)GetModuleHandleW(null);
|
||||||
@@ -497,6 +503,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Message message = .();
|
Message message = .();
|
||||||
while (PeekMessageW(&message, 0, 0, 0, .Remove))
|
while (PeekMessageW(&message, 0, 0, 0, .Remove))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using GlitchLog;
|
using GlitchLog;
|
||||||
|
using GlitchyEngine.Debug;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace GlitchyEngine
|
namespace GlitchyEngine
|
||||||
@@ -11,6 +12,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public static int Main(String[] args)
|
public static int Main(String[] args)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.BeginProfiling();
|
||||||
|
|
||||||
Log.EngineLogger.Info("Initializing Application...");
|
Log.EngineLogger.Info("Initializing Application...");
|
||||||
|
|
||||||
Stopwatch initWatch = scope Stopwatch();
|
Stopwatch initWatch = scope Stopwatch();
|
||||||
@@ -30,6 +33,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
Log.EngineLogger.Info("Application uninitialized.");
|
Log.EngineLogger.Info("Application uninitialized.");
|
||||||
|
|
||||||
|
Debug.Profiler.EndProfiling();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,11 +80,18 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(BlendStateDescription desc)
|
public this(BlendStateDescription desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_desc = desc;
|
_desc = desc;
|
||||||
|
|
||||||
PlatformCreateBlendState();
|
PlatformCreateBlendState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
}
|
||||||
|
|
||||||
protected extern void PlatformCreateBlendState();
|
protected extern void PlatformCreateBlendState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// Todo: append allocate as soon as it's fixed
|
// Todo: append allocate as soon as it's fixed
|
||||||
let buffers = new List<BufferEntry>();
|
let buffers = new List<BufferEntry>();
|
||||||
let strToBuf = new Dictionary<String, BufferEntry*>();
|
let strToBuf = new Dictionary<String, BufferEntry*>();
|
||||||
@@ -25,6 +27,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
_idxToBuf = idxToBuf;
|
_idxToBuf = idxToBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
}
|
||||||
|
|
||||||
mixin DeleteBufferEntries(List<BufferEntry> entries)
|
mixin DeleteBufferEntries(List<BufferEntry> entries)
|
||||||
{
|
{
|
||||||
if(entries == null)
|
if(entries == null)
|
||||||
@@ -54,6 +61,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public BufferEntry* TryGetBufferEntry(String name)
|
public BufferEntry* TryGetBufferEntry(String name)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(_strToBuf.TryGetValue(name, let buffer))
|
if(_strToBuf.TryGetValue(name, let buffer))
|
||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
@@ -64,6 +73,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public BufferEntry* TryGetBufferEntry(int index)
|
public BufferEntry* TryGetBufferEntry(int index)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(_idxToBuf.TryGetValue(index, let buffer))
|
if(_idxToBuf.TryGetValue(index, let buffer))
|
||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
@@ -80,6 +91,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public bool TryReplaceBuffer(int idx, Buffer buffer)
|
public bool TryReplaceBuffer(int idx, Buffer buffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(_idxToBuf.TryGetValue(idx, let bufferEntry))
|
if(_idxToBuf.TryGetValue(idx, let bufferEntry))
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Assert(idx == bufferEntry.Index);
|
Log.EngineLogger.Assert(idx == bufferEntry.Index);
|
||||||
@@ -105,6 +118,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public bool TryReplaceBuffer(String name, Buffer buffer)
|
public bool TryReplaceBuffer(String name, Buffer buffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(_strToBuf.TryGetValue(name, let bufferEntry))
|
if(_strToBuf.TryGetValue(name, let bufferEntry))
|
||||||
{
|
{
|
||||||
Log.EngineLogger.AssertDebug(name == bufferEntry.Name);
|
Log.EngineLogger.AssertDebug(name == bufferEntry.Name);
|
||||||
@@ -129,6 +144,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public void Add(BufferEntry entry)
|
public void Add(BufferEntry entry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
BufferEntry copy = (new String(entry.Name), entry.Index, entry.Buffer..AddRef());
|
BufferEntry copy = (new String(entry.Name), entry.Index, entry.Buffer..AddRef());
|
||||||
|
|
||||||
_buffers.Add(copy);
|
_buffers.Add(copy);
|
||||||
@@ -146,6 +163,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
int GetIndexOfBuffer(Buffer buffer)
|
int GetIndexOfBuffer(Buffer buffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
for(int i < _buffers.Count)
|
for(int i < _buffers.Count)
|
||||||
{
|
{
|
||||||
// Only check for reference equality.
|
// Only check for reference equality.
|
||||||
@@ -165,6 +184,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
String GetNameOfBuffer(Buffer buffer)
|
String GetNameOfBuffer(Buffer buffer)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
for(int i < _buffers.Count)
|
for(int i < _buffers.Count)
|
||||||
{
|
{
|
||||||
// Only check for reference equality.
|
// Only check for reference equality.
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public void Add(Effect effect, String effectName = null)
|
public void Add(Effect effect, String effectName = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
if(effectName == null)
|
if(effectName == null)
|
||||||
@@ -51,6 +53,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public Effect Load(String filepath, String effectName = null)
|
public Effect Load(String filepath, String effectName = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
String name = effectName;
|
String name = effectName;
|
||||||
|
|
||||||
if(name == null)
|
if(name == null)
|
||||||
@@ -80,6 +84,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public Effect Get(String effectName)
|
public Effect Get(String effectName)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.AssertDebug(Exists(effectName), "Effect not found!");
|
Log.EngineLogger.AssertDebug(Exists(effectName), "Effect not found!");
|
||||||
|
|
||||||
return _effects.GetValue(effectName).Get()..AddRef();
|
return _effects.GetValue(effectName).Get()..AddRef();
|
||||||
@@ -137,6 +143,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(String filename, String vsEntry, String psEntry, String shaderName = null)
|
public this(String filename, String vsEntry, String psEntry, String shaderName = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
CompileFromFile(filename, vsEntry, psEntry);
|
CompileFromFile(filename, vsEntry, psEntry);
|
||||||
|
|
||||||
if(shaderName == null)
|
if(shaderName == null)
|
||||||
@@ -152,6 +160,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(String filename, String shaderName = null)
|
public this(String filename, String shaderName = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
String fileContent = scope String();
|
String fileContent = scope String();
|
||||||
String vsName = scope String();
|
String vsName = scope String();
|
||||||
String psName = scope String();
|
String psName = scope String();
|
||||||
@@ -175,6 +185,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(String shaderName, String vsPath, String vsEntry, String psPath, String psEntry)
|
public this(String shaderName, String vsPath, String vsEntry, String psPath, String psEntry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Compile(vsPath, vsEntry, psPath, psEntry);
|
Compile(vsPath, vsEntry, psPath, psEntry);
|
||||||
|
|
||||||
_name = new String(shaderName);
|
_name = new String(shaderName);
|
||||||
@@ -182,6 +194,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
for(let entry in _textures)
|
for(let entry in _textures)
|
||||||
{
|
{
|
||||||
entry.value.Texture?.ReleaseRef();
|
entry.value.Texture?.ReleaseRef();
|
||||||
@@ -190,6 +204,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public void SetTexture(String name, Texture texture)
|
public void SetTexture(String name, Texture texture)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
ref TextureEntry entry = ref _textures[name];
|
ref TextureEntry entry = ref _textures[name];
|
||||||
|
|
||||||
entry.Texture?.ReleaseRef();
|
entry.Texture?.ReleaseRef();
|
||||||
@@ -199,6 +215,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void ApplyTextures()
|
private void ApplyTextures()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
for(let (name, entry) in _textures)
|
for(let (name, entry) in _textures)
|
||||||
{
|
{
|
||||||
entry.VsSlot?.Texture?.ReleaseRef();
|
entry.VsSlot?.Texture?.ReleaseRef();
|
||||||
@@ -213,6 +231,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void ApplyChanges()
|
private void ApplyChanges()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
for(let buffer in _bufferCollection)
|
for(let buffer in _bufferCollection)
|
||||||
{
|
{
|
||||||
if(let cbuffer = buffer.Buffer as ConstantBuffer)
|
if(let cbuffer = buffer.Buffer as ConstantBuffer)
|
||||||
@@ -224,6 +244,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public void Bind(GraphicsContext context)
|
public void Bind(GraphicsContext context)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
ApplyTextures();
|
ApplyTextures();
|
||||||
ApplyChanges();
|
ApplyChanges();
|
||||||
|
|
||||||
@@ -235,6 +257,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void CompileFromFile(String filename, String vsEntry, String psEntry)
|
private void CompileFromFile(String filename, String vsEntry, String psEntry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
let vs = Shader.FromFile!<VertexShader>(filename, vsEntry);
|
let vs = Shader.FromFile!<VertexShader>(filename, vsEntry);
|
||||||
VertexShader = vs;
|
VertexShader = vs;
|
||||||
vs.ReleaseRef();
|
vs.ReleaseRef();
|
||||||
@@ -245,6 +269,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void Compile(String fileContent, String vsEntry, String psEntry)
|
private void Compile(String fileContent, String vsEntry, String psEntry)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// TODO: vsEntry and psEntry could be empty (which is a valid case.)
|
// TODO: vsEntry and psEntry could be empty (which is a valid case.)
|
||||||
let vs = new VertexShader(fileContent, vsEntry);
|
let vs = new VertexShader(fileContent, vsEntry);
|
||||||
VertexShader = vs;
|
VertexShader = vs;
|
||||||
@@ -265,6 +291,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
private static void ProcessFile(String filename, String fileContent, String vsName, String psName)
|
private static void ProcessFile(String filename, String fileContent, String vsName, String psName)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
File.ReadAllText(filename, fileContent, true);
|
File.ReadAllText(filename, fileContent, true);
|
||||||
// append line ending just in case the file doesn't end with one.
|
// append line ending just in case the file doesn't end with one.
|
||||||
fileContent.Append('\n');
|
fileContent.Append('\n');
|
||||||
@@ -324,6 +352,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void MergeResources()
|
private void MergeResources()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
MergeConstantBuffers();
|
MergeConstantBuffers();
|
||||||
MergeBufferVariables();
|
MergeBufferVariables();
|
||||||
MergeTextures();
|
MergeTextures();
|
||||||
@@ -331,6 +361,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void MergeConstantBuffers()
|
private void MergeConstantBuffers()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_bufferCollection = new BufferCollection();
|
_bufferCollection = new BufferCollection();
|
||||||
|
|
||||||
HashSet<String> bufferNames = scope HashSet<String>();
|
HashSet<String> bufferNames = scope HashSet<String>();
|
||||||
@@ -374,6 +406,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void MergeBufferVariables()
|
private void MergeBufferVariables()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_variables = new BufferVariableCollection(false);
|
_variables = new BufferVariableCollection(false);
|
||||||
|
|
||||||
for(let buffer in _bufferCollection)
|
for(let buffer in _bufferCollection)
|
||||||
@@ -390,6 +424,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private void AddShaderBuffers(Shader shader, HashSet<String> bufferNames)
|
private void AddShaderBuffers(Shader shader, HashSet<String> bufferNames)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
if(shader != null)
|
if(shader != null)
|
||||||
{
|
{
|
||||||
for(let buffer in shader.Buffers)
|
for(let buffer in shader.Buffers)
|
||||||
@@ -402,6 +438,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
/// Merges the texture slots of all shaders into one dictionary.
|
/// Merges the texture slots of all shaders into one dictionary.
|
||||||
private void MergeTextures()
|
private void MergeTextures()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
delete _textures;
|
delete _textures;
|
||||||
_textures = new .();
|
_textures = new .();
|
||||||
|
|
||||||
@@ -414,6 +452,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
private void EnumerateShaderTextures<T>(T shader) where T : Shader
|
private void EnumerateShaderTextures<T>(T shader) where T : Shader
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
//for(var (name, index, texture) in shader.Resources)
|
//for(var (name, index, texture) in shader.Resources)
|
||||||
for(var shaderEntry in ref shader.Textures)
|
for(var shaderEntry in ref shader.Textures)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,11 +80,15 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void UpdateProjection()
|
protected override void UpdateProjection()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_projection = Matrix.OrthographicProjectionOffCenter(_left, _right, _top, _bottom, _nearPlane, _farPlane);
|
_projection = Matrix.OrthographicProjectionOffCenter(_left, _right, _top, _bottom, _nearPlane, _farPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateTransform()
|
protected override void UpdateTransform()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_transform = Matrix.Translation(_position) * Matrix.RotationZ(_rotation.Z) * Matrix.RotationY(_rotation.Y) * Matrix.RotationX(_rotation.X);
|
_transform = Matrix.Translation(_position) * Matrix.RotationZ(_rotation.Z) * Matrix.RotationY(_rotation.Y) * Matrix.RotationX(_rotation.X);
|
||||||
_view = _transform.Invert();
|
_view = _transform.Invert();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void UpdateProjection()
|
protected override void UpdateProjection()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(_projectionType == .Limited || _projectionType == .LimitedReversed)
|
if(_projectionType == .Limited || _projectionType == .LimitedReversed)
|
||||||
Log.EngineLogger.AssertDebug(_nearPlane < _farPlane, "The near plane must be smaller than the far plane.");
|
Log.EngineLogger.AssertDebug(_nearPlane < _farPlane, "The near plane must be smaller than the far plane.");
|
||||||
|
|
||||||
@@ -98,6 +100,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
protected override void UpdateTransform()
|
protected override void UpdateTransform()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_transform = Matrix.Translation(_position) * Matrix.RotationZ(_rotation.Z) * Matrix.RotationY(_rotation.Y) * Matrix.RotationX(_rotation.X);
|
_transform = Matrix.Translation(_position) * Matrix.RotationZ(_rotation.Z) * Matrix.RotationY(_rotation.Y) * Matrix.RotationX(_rotation.X);
|
||||||
_view = _transform.Invert();
|
_view = _transform.Invert();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
[Inline]
|
[Inline]
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_rendererAPI.Init();
|
_rendererAPI.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(RenderTarget2DDescription description)
|
public this(RenderTarget2DDescription description)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_description = description;
|
_description = description;
|
||||||
|
|
||||||
ApplyChanges();
|
ApplyChanges();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Init(GraphicsContext context, EffectLibrary effectLibrary)
|
public static void Init(GraphicsContext context, EffectLibrary effectLibrary)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_context = context..AddRef();
|
_context = context..AddRef();
|
||||||
/*
|
/*
|
||||||
_sceneConstants = new Buffer<SceneConstants>(.(0, .Constant, .Dynamic, .Write));
|
_sceneConstants = new Buffer<SceneConstants>(.(0, .Constant, .Dynamic, .Write));
|
||||||
@@ -46,11 +48,15 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Deinit()
|
public static void Deinit()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
Renderer2D.Deinit();
|
Renderer2D.Deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitLineRenderer(EffectLibrary effectLibrary)
|
static void InitLineRenderer(EffectLibrary effectLibrary)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
LineEffect = effectLibrary.Load("content\\Shaders\\lineShader.hlsl");
|
LineEffect = effectLibrary.Load("content\\Shaders\\lineShader.hlsl");
|
||||||
|
|
||||||
LineGeometry = new GeometryBinding();
|
LineGeometry = new GeometryBinding();
|
||||||
@@ -75,6 +81,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void BeginScene(EcsWorld world, Entity cameraEntity)
|
public static void BeginScene(EcsWorld world, Entity cameraEntity)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
var camera = world.GetComponent<CameraComponent>(cameraEntity);
|
var camera = world.GetComponent<CameraComponent>(cameraEntity);
|
||||||
var transform = world.GetComponent<TransformComponent>(cameraEntity);
|
var transform = world.GetComponent<TransformComponent>(cameraEntity);
|
||||||
|
|
||||||
@@ -87,15 +95,22 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void BeginScene(Camera camera)
|
public static void BeginScene(Camera camera)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_sceneConstants.ViewProjection = camera.ViewProjection;
|
_sceneConstants.ViewProjection = camera.ViewProjection;
|
||||||
//_sceneConstants.Data.ViewProjection = camera.ViewProjection;
|
//_sceneConstants.Data.ViewProjection = camera.ViewProjection;
|
||||||
//_sceneConstants.Update();
|
//_sceneConstants.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EndScene(){}
|
public static void EndScene()
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
}
|
||||||
|
|
||||||
public static void Submit(GeometryBinding geometry, Effect effect, Matrix transform = .Identity)
|
public static void Submit(GeometryBinding geometry, Effect effect, Matrix transform = .Identity)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
//effect.PixelShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
//effect.PixelShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
||||||
//effect.VertexShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
//effect.VertexShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
||||||
|
|
||||||
@@ -116,6 +131,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Submit(GeometryBinding geometry, Material material, Matrix transform = .Identity)
|
public static void Submit(GeometryBinding geometry, Material material, Matrix transform = .Identity)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
||||||
material.SetVariable("Transform", transform);
|
material.SetVariable("Transform", transform);
|
||||||
|
|
||||||
@@ -175,6 +192,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public static void DrawLine(Vector4 start, Vector4 end, Color color, Matrix transform)
|
public static void DrawLine(Vector4 start, Vector4 end, Color color, Matrix transform)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
LineVertices.SetData(Vector4[2](start, end), 0, .WriteDiscard);
|
LineVertices.SetData(Vector4[2](start, end), 0, .WriteDiscard);
|
||||||
LineEffect.Variables["ViewProjection"].SetData(_sceneConstants.ViewProjection * transform);
|
LineEffect.Variables["ViewProjection"].SetData(_sceneConstants.ViewProjection * transform);
|
||||||
LineEffect.Variables["Color"].SetData(color);
|
LineEffect.Variables["Color"].SetData(color);
|
||||||
|
|||||||
@@ -135,12 +135,16 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void InitEffect()
|
private static void InitEffect()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
s_batchEffect = new Effect("content\\Shaders\\spritebatch.hlsl");
|
s_batchEffect = new Effect("content\\Shaders\\spritebatch.hlsl");
|
||||||
s_circleBatchEffect = new Effect("content\\Shaders\\circlebatch.hlsl");
|
s_circleBatchEffect = new Effect("content\\Shaders\\circlebatch.hlsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitGeometry()
|
private static void InitGeometry()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
s_quadGeometry = new GeometryBinding();
|
s_quadGeometry = new GeometryBinding();
|
||||||
s_quadGeometry.SetPrimitiveTopology(.TriangleList);
|
s_quadGeometry.SetPrimitiveTopology(.TriangleList);
|
||||||
|
|
||||||
@@ -171,6 +175,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void InitInstancingGeometry()
|
private static void InitInstancingGeometry()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
{
|
{
|
||||||
s_instanceBuffer = new VertexBuffer(typeof(BatchVertex), 1024, .Dynamic, .Write);
|
s_instanceBuffer = new VertexBuffer(typeof(BatchVertex), 1024, .Dynamic, .Write);
|
||||||
s_instanceBuffer.SetData(0);
|
s_instanceBuffer.SetData(0);
|
||||||
@@ -242,6 +248,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void InitWhitetexture()
|
private static void InitWhitetexture()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
// Create a texture with a single white pixel
|
// Create a texture with a single white pixel
|
||||||
Texture2DDesc tex2Ddesc = .{
|
Texture2DDesc tex2Ddesc = .{
|
||||||
Format = .R8G8B8A8_UNorm,
|
Format = .R8G8B8A8_UNorm,
|
||||||
@@ -266,6 +274,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
InitEffect();
|
InitEffect();
|
||||||
InitGeometry();
|
InitGeometry();
|
||||||
InitInstancingGeometry();
|
InitInstancingGeometry();
|
||||||
@@ -280,6 +290,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Deinit()
|
public static void Deinit()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
|
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
|
||||||
#endif
|
#endif
|
||||||
@@ -313,6 +324,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void BeginScene(OrthographicCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
|
public static void BeginScene(OrthographicCamera camera, DrawOrder drawOrder = .SortByTexture, Effect effect = null, Effect circleEffect = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
|
Log.EngineLogger.AssertDebug(s_initialized, "Renderer2D was not initialized.");
|
||||||
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
Log.EngineLogger.AssertDebug(!s_sceneRunning, "You have to call EndScene before you can make another call to BeginScene.");
|
||||||
@@ -352,6 +364,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void EndScene()
|
public static void EndScene()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
@@ -364,6 +377,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Flush()
|
public static void Flush()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
@@ -388,6 +402,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void FlushInstances()
|
private static void FlushInstances()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(s_setInstances == 0)
|
if(s_setInstances == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -403,6 +419,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void FlushCircleInstances()
|
private static void FlushCircleInstances()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(s_setInstances == 0)
|
if(s_setInstances == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -446,6 +464,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void SortInstances()
|
private static void SortInstances()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
switch(s_drawOrder)
|
switch(s_drawOrder)
|
||||||
{
|
{
|
||||||
case .SortByTexture:
|
case .SortByTexture:
|
||||||
@@ -465,6 +485,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void DrawDeferred()
|
private static void DrawDeferred()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(s_instanceQueue.IsEmpty && s_circleInstanceQueue.IsEmpty)
|
if(s_instanceQueue.IsEmpty && s_circleInstanceQueue.IsEmpty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -476,6 +498,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void DrawDeferredQuads()
|
private static void DrawDeferredQuads()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(s_instanceQueue.IsEmpty)
|
if(s_instanceQueue.IsEmpty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -512,6 +536,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
private static void DrawDeferredCircles()
|
private static void DrawDeferredCircles()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(s_circleInstanceQueue.IsEmpty)
|
if(s_circleInstanceQueue.IsEmpty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -583,6 +609,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
@@ -599,6 +627,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void DrawQuad(Matrix transform, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
public static void DrawQuad(Matrix transform, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
@@ -636,6 +666,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
public static void DrawCircle(Vector3 position, Vector2 size, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, Vector4 uvTransform = .(0, 0, 1, 1))
|
public static void DrawCircle(Vector3 position, Vector2 size, Texture2D texture, ColorRGBA color = .White, float innerRadius = 1.0f, Vector4 uvTransform = .(0, 0, 1, 1))
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
Log.EngineLogger.AssertDebug(s_sceneRunning, "Missing call of BeginScene.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public void Clear(RenderTarget2D renderTarget, ClearOptions options, ColorRGBA color, float depth, uint8 stencil)
|
public void Clear(RenderTarget2D renderTarget, ClearOptions options, ColorRGBA color, float depth, uint8 stencil)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
var actualRt = (renderTarget ?? GraphicsContext.Get().SwapChain.BackBuffer);
|
var actualRt = (renderTarget ?? GraphicsContext.Get().SwapChain.BackBuffer);
|
||||||
|
|
||||||
if(options.HasFlag(.Color))
|
if(options.HasFlag(.Color))
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_samplers = new .();
|
_samplers = new .();
|
||||||
|
|
||||||
// Init point samplers
|
// Init point samplers
|
||||||
@@ -230,6 +232,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public static void Uninit()
|
public static void Uninit()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
PointClamp.ReleaseRef();
|
PointClamp.ReleaseRef();
|
||||||
PointWrap.ReleaseRef();
|
PointWrap.ReleaseRef();
|
||||||
LinearClamp.ReleaseRef();
|
LinearClamp.ReleaseRef();
|
||||||
@@ -249,6 +253,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public static SamplerState GetSampler(SamplerStateDescription desc)
|
public static SamplerState GetSampler(SamplerStateDescription desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Log.EngineLogger.AssertDebug(_samplers != null, "SamplerStateManager was not initialized.");
|
Log.EngineLogger.AssertDebug(_samplers != null, "SamplerStateManager was not initialized.");
|
||||||
|
|
||||||
if(_samplers.TryGetValue(desc, let sampler))
|
if(_samplers.TryGetValue(desc, let sampler))
|
||||||
@@ -299,6 +305,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public this(SamplerStateDescription desc)
|
public this(SamplerStateDescription desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
_desc = desc;
|
_desc = desc;
|
||||||
|
|
||||||
PlatformCreateSamplerState();
|
PlatformCreateSamplerState();
|
||||||
@@ -306,6 +314,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
SamplerStateManager.[Friend]Remove(this);
|
SamplerStateManager.[Friend]Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(String source, String entryPoint, ShaderDefine[] macros = null)
|
public this(String source, String entryPoint, ShaderDefine[] macros = null)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// Todo: append as soon as it's fixed.
|
// Todo: append as soon as it's fixed.
|
||||||
//let buffers = new BufferCollection();
|
//let buffers = new BufferCollection();
|
||||||
_buffers = new BufferCollection();
|
_buffers = new BufferCollection();
|
||||||
@@ -42,11 +44,13 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mixin FromFile<T>(String fileName, String entryPoint, ShaderDefine[] macros = null) where T : Shader
|
public static mixin FromFile<T>(String fileName, String entryPoint, ShaderDefine[] macros = null) where T : Shader
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
String fileContent = new String();
|
String fileContent = new String();
|
||||||
|
|
||||||
File.ReadAllText(fileName, fileContent, true);
|
File.ReadAllText(fileName, fileContent, true);
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
public this(String fontPath, uint32 fontSize, bool hasColor = true, char32 firstChar = '\0', uint32 charCount = 128, int32 faceIndex = 0)
|
public this(String fontPath, uint32 fontSize, bool hasColor = true, char32 firstChar = '\0', uint32 charCount = 128, int32 faceIndex = 0)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// Make sure the fontrenderer is initialized (Font only cares about freetype)
|
// Make sure the fontrenderer is initialized (Font only cares about freetype)
|
||||||
FontRenderer.Init();
|
FontRenderer.Init();
|
||||||
|
|
||||||
@@ -125,11 +127,19 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
_faceIndex = faceIndex;
|
_faceIndex = faceIndex;
|
||||||
_hasColor = hasColor;
|
_hasColor = hasColor;
|
||||||
|
|
||||||
var res = FreeType.New_Face(FontRenderer.s_Library, fontPath, faceIndex, &_face);
|
{
|
||||||
Log.EngineLogger.Assert(res.Success, scope $"New_Face failed({(int)res}): {res}");
|
Debug.Profiler.ProfileResourceScope!("Freetype.New_Face");
|
||||||
|
|
||||||
res = FreeType.Set_Pixel_Sizes(_face, 0, _fontSize);
|
FT_Error res = FreeType.New_Face(FontRenderer.s_Library, fontPath, faceIndex, &_face);
|
||||||
Log.EngineLogger.Assert(res.Success, scope $"Set_Pixel_Sizes failed({(int)res}): {res}");
|
Log.EngineLogger.Assert(res.Success, scope $"New_Face failed({(int)res}): {res}");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("Freetype.Set_Pixel_Sizes");
|
||||||
|
|
||||||
|
FT_Error res = FreeType.Set_Pixel_Sizes(_face, 0, _fontSize);
|
||||||
|
Log.EngineLogger.Assert(res.Success, scope $"Set_Pixel_Sizes failed({(int)res}): {res}");
|
||||||
|
}
|
||||||
|
|
||||||
double unitsPerEm = F26Dot6ToDouble(_face.units_per_EM);
|
double unitsPerEm = F26Dot6ToDouble(_face.units_per_EM);
|
||||||
_geometryScaler = _fontSize / unitsPerEm;
|
_geometryScaler = _fontSize / unitsPerEm;
|
||||||
@@ -147,6 +157,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
// HarfBuzz
|
// HarfBuzz
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("hb_ft_font_create_referenced");
|
||||||
|
|
||||||
_harfBuzzFont = hb_ft_font_create_referenced(_face);
|
_harfBuzzFont = hb_ft_font_create_referenced(_face);
|
||||||
hb_font_set_scale(_harfBuzzFont, (.)fontSize * 64, (.)fontSize * 64);
|
hb_font_set_scale(_harfBuzzFont, (.)fontSize * 64, (.)fontSize * 64);
|
||||||
}
|
}
|
||||||
@@ -156,6 +168,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
public void LoadGlyphs(char32 firstChar, uint32 charCount)
|
public void LoadGlyphs(char32 firstChar, uint32 charCount)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ExtendRange(firstChar, firstChar + charCount);
|
ExtendRange(firstChar, firstChar + charCount);
|
||||||
|
|
||||||
UpdateAtlas();
|
UpdateAtlas();
|
||||||
@@ -163,6 +177,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
public void LoadGlyphs(uint32 firstGlyph, uint32 charCount)
|
public void LoadGlyphs(uint32 firstGlyph, uint32 charCount)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
ExtendRange(firstGlyph, firstGlyph + charCount);
|
ExtendRange(firstGlyph, firstGlyph + charCount);
|
||||||
|
|
||||||
UpdateAtlas();
|
UpdateAtlas();
|
||||||
@@ -237,6 +253,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
void ExtendRange(char32 firstChar, char32 rangeEnd)
|
void ExtendRange(char32 firstChar, char32 rangeEnd)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
|
|
||||||
for(char32 char = firstChar; char < rangeEnd; char++)
|
for(char32 char = firstChar; char < rangeEnd; char++)
|
||||||
@@ -266,6 +284,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
void ExtendRange(uint32 firstGlyph, uint32 rangeEnd)
|
void ExtendRange(uint32 firstGlyph, uint32 rangeEnd)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
|
|
||||||
for(uint32 glyphId = firstGlyph; glyphId < rangeEnd; glyphId++)
|
for(uint32 glyphId = firstGlyph; glyphId < rangeEnd; glyphId++)
|
||||||
@@ -317,6 +337,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
Int3 PrepareAtlas()
|
Int3 PrepareAtlas()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
const uint32 maxRes = 16384; // D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|
const uint32 maxRes = 16384; // D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
|
||||||
const uint32 maxArray = 2048; // D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION
|
const uint32 maxArray = 2048; // D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION
|
||||||
|
|
||||||
@@ -398,11 +420,15 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
void DrawAtlas()
|
void DrawAtlas()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Int3 oldAtlasSize = _atlasSize;
|
Int3 oldAtlasSize = _atlasSize;
|
||||||
_atlasSize = PrepareAtlas();
|
_atlasSize = PrepareAtlas();
|
||||||
|
|
||||||
if(_atlasSize != oldAtlasSize)
|
if(_atlasSize != oldAtlasSize)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("Recreate Atlas");
|
||||||
|
|
||||||
var oldAtlas = _atlas;
|
var oldAtlas = _atlas;
|
||||||
|
|
||||||
Texture2DDesc desc;
|
Texture2DDesc desc;
|
||||||
@@ -444,20 +470,31 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
bool Calculate(ref GlyphDescriptor desc)
|
bool Calculate(ref GlyphDescriptor desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// prepare shape
|
// prepare shape
|
||||||
|
|
||||||
double advance = 0;
|
double advance = 0;
|
||||||
|
|
||||||
Shape shape;
|
Shape shape;
|
||||||
if(!msdfgen.LoadGlyph(out shape, ref _face, desc.GlyphIndex, out advance) || !shape.Validate())
|
|
||||||
{
|
{
|
||||||
return false;
|
Debug.Profiler.ProfileResourceScope!("msdfgen.LoadGlyph");
|
||||||
|
|
||||||
|
if(!msdfgen.LoadGlyph(out shape, ref _face, desc.GlyphIndex, out advance) || !shape.Validate())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.Advance = (float)(advance * _geometryScaler);
|
desc.Advance = (float)(advance * _geometryScaler);
|
||||||
|
|
||||||
//shape.OrientContours();
|
//shape.OrientContours();
|
||||||
msdfgen.ResolveShapeGeometry(shape);
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("msdfgen.ResolveShapeGeometry");
|
||||||
|
|
||||||
|
msdfgen.ResolveShapeGeometry(shape);
|
||||||
|
}
|
||||||
|
|
||||||
shape.Normalize();
|
shape.Normalize();
|
||||||
|
|
||||||
@@ -616,12 +653,19 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
void GenerateMSDF(GlyphDescriptor desc)
|
void GenerateMSDF(GlyphDescriptor desc)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// prepare shape
|
// prepare shape
|
||||||
|
|
||||||
double advance = 0;
|
double advance = 0;
|
||||||
|
|
||||||
Shape shape;
|
Shape shape;
|
||||||
msdfgen.LoadGlyph(out shape, ref _face, desc.GlyphIndex, out advance);
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("msdfgen.LoadGlyph");
|
||||||
|
|
||||||
|
msdfgen.LoadGlyph(out shape, ref _face, desc.GlyphIndex, out advance);
|
||||||
|
}
|
||||||
|
|
||||||
msdfgen.ResolveShapeGeometry(shape);
|
msdfgen.ResolveShapeGeometry(shape);
|
||||||
|
|
||||||
@@ -646,6 +690,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
using(Bitmap<ColorRGB, const 1> bitmap = .((.)bufferX, (.)bufferY))
|
using(Bitmap<ColorRGB, const 1> bitmap = .((.)bufferX, (.)bufferY))
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileResourceScope!("GenerateMSDF");
|
||||||
|
|
||||||
MSDFGeneratorConfig config = .();
|
MSDFGeneratorConfig config = .();
|
||||||
|
|
||||||
msdfgen.GenerateMSDF(*(Bitmap<float, const 3>*)&bitmap, shape, projection, _range, config);
|
msdfgen.GenerateMSDF(*(Bitmap<float, const 3>*)&bitmap, shape, projection, _range, config);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
internal static void Init()
|
internal static void Init()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(s_isInitialized)
|
if(s_isInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -32,6 +34,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
internal static void Deinit()
|
internal static void Deinit()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
_msdfEffect.ReleaseRef();
|
_msdfEffect.ReleaseRef();
|
||||||
|
|
||||||
DeinitFreetype();
|
DeinitFreetype();
|
||||||
@@ -41,6 +45,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
private static void InitFreetype()
|
private static void InitFreetype()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
if(s_Library == null)
|
if(s_Library == null)
|
||||||
{
|
{
|
||||||
var res = FreeType.Init_FreeType(&s_Library);
|
var res = FreeType.Init_FreeType(&s_Library);
|
||||||
@@ -50,6 +56,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
private static void DeinitFreetype()
|
private static void DeinitFreetype()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
FreeType.Done_FreeType(s_Library);
|
FreeType.Done_FreeType(s_Library);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +125,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
public static PreparedText PrepareText(Font font, String text, float fontSize, Color fontColor = .White, Color bitmapColor = .White, float lineSpaceScale = 1.0f, TextDirection direction = .LeftToRight)
|
public static PreparedText PrepareText(Font font, String text, float fontSize, Color fontColor = .White, Color bitmapColor = .White, float lineSpaceScale = 1.0f, TextDirection direction = .LeftToRight)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(text.IsWhiteSpace)
|
if(text.IsWhiteSpace)
|
||||||
return .Empty;
|
return .Empty;
|
||||||
|
|
||||||
@@ -152,6 +162,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
void FlushShapeBuffer()
|
void FlushShapeBuffer()
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
float fontScale = (float)fontSize / currentFont._fontSize;
|
float fontScale = (float)fontSize / currentFont._fontSize;
|
||||||
|
|
||||||
hb_buffer_clear_contents(buf);
|
hb_buffer_clear_contents(buf);
|
||||||
@@ -294,6 +306,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
public static void DrawText(PreparedText text, float x, float y)
|
public static void DrawText(PreparedText text, float x, float y)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
text.AddRef();
|
text.AddRef();
|
||||||
defer text.ReleaseRef();
|
defer text.ReleaseRef();
|
||||||
|
|
||||||
@@ -396,6 +410,8 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
*/
|
*/
|
||||||
public static void DrawText(Font font, String text, float x, float y, float fontSize, Color fontColor = .White, Color bitmapColor = .White, float lineGapOffset = 0)
|
public static void DrawText(Font font, String text, float x, float y, float fontSize, Color fontColor = .White, Color bitmapColor = .White, float lineGapOffset = 0)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
if(text.IsWhiteSpace)
|
if(text.IsWhiteSpace)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user