mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
More profiling
This commit is contained in:
@@ -67,6 +67,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
*/
|
*/
|
||||||
public void Bind(GraphicsContext context)
|
public void Bind(GraphicsContext context)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
for(let (name, texture) in _textures)
|
for(let (name, texture) in _textures)
|
||||||
{
|
{
|
||||||
_effect.SetTexture(name, texture);
|
_effect.SetTexture(name, texture);
|
||||||
@@ -106,12 +108,25 @@ namespace GlitchyEngine.Renderer
|
|||||||
[Inline]
|
[Inline]
|
||||||
private void SetVariable<T>(String name, T value) where T : struct
|
private void SetVariable<T>(String name, T value) where T : struct
|
||||||
{
|
{
|
||||||
if(_variables.TryGetValue(name, let entry))
|
bool b = false;
|
||||||
|
(uint32 Offset, BufferVariable Variable) entry;
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("TryGetValue");
|
||||||
|
|
||||||
|
b = _variables.TryGetValue(name, out entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b)
|
||||||
{
|
{
|
||||||
entry.Variable.EnsureTypeMatch<T>();
|
entry.Variable.EnsureTypeMatch<T>();
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("RawPointer!");
|
||||||
|
|
||||||
RawPointer!<T>(entry.Offset) = value;
|
RawPointer!<T>(entry.Offset) = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Assert(false, scope $"The effect doesn't contain a variable named \"{name}\"");
|
Log.EngineLogger.Assert(false, scope $"The effect doesn't contain a variable named \"{name}\"");
|
||||||
|
|||||||
@@ -279,14 +279,21 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileRendererFunction!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
_queue.Sort(scope => SortMeshes);
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("Sort Meshes");
|
||||||
|
|
||||||
|
_queue.Sort(scope => SortMeshes);
|
||||||
|
}
|
||||||
// Deferred renderer:
|
// Deferred renderer:
|
||||||
|
|
||||||
// TODO: foreach light: draw shadow map
|
// TODO: foreach light: draw shadow map
|
||||||
|
|
||||||
// foreach camera:
|
// foreach camera:
|
||||||
// {
|
// {
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("Draw GBuffer");
|
||||||
|
|
||||||
_gBuffer.EnsureSize(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
_gBuffer.EnsureSize(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
||||||
_gBuffer.Clear();
|
_gBuffer.Clear();
|
||||||
RenderCommand.UnbindRenderTargets();
|
RenderCommand.UnbindRenderTargets();
|
||||||
@@ -296,21 +303,26 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
RenderCommand.SetBlendState(_gBufferBlend);
|
RenderCommand.SetBlendState(_gBufferBlend);
|
||||||
|
|
||||||
//RenderCommand.UnbindRenderTargets();
|
|
||||||
//RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
|
||||||
//RenderCommand.BindRenderTargets();
|
|
||||||
|
|
||||||
// TODO: Draw into GBuffer
|
|
||||||
for (SubmittedMesh entry in _queue)
|
for (SubmittedMesh entry in _queue)
|
||||||
{
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("Draw Mesh");
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("SetVariables");
|
||||||
|
|
||||||
entry.Material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
entry.Material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
||||||
entry.Material.SetVariable("Transform", entry.Transform);
|
entry.Material.SetVariable("Transform", entry.Transform);
|
||||||
|
}
|
||||||
|
|
||||||
entry.Material.Bind(_context);
|
entry.Material.Bind(_context);
|
||||||
|
|
||||||
entry.Mesh.Bind();
|
entry.Mesh.Bind();
|
||||||
RenderCommand.DrawIndexed(entry.Mesh);
|
RenderCommand.DrawIndexed(entry.Mesh);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("Draw Lights");
|
||||||
|
|
||||||
RenderCommand.UnbindRenderTargets();
|
RenderCommand.UnbindRenderTargets();
|
||||||
RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
||||||
@@ -336,6 +348,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
RenderCommand.DrawIndexed(s_quadGeometry);
|
RenderCommand.DrawIndexed(s_quadGeometry);
|
||||||
|
|
||||||
RenderCommand.UnbindTextures();
|
RenderCommand.UnbindTextures();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Draw lights to camera target
|
// TODO: Draw lights to camera target
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user