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,11 +108,24 @@ 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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -279,63 +279,76 @@ 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:
|
||||||
// {
|
// {
|
||||||
_gBuffer.EnsureSize(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
|
||||||
_gBuffer.Clear();
|
|
||||||
RenderCommand.UnbindRenderTargets();
|
|
||||||
_gBuffer.Bind();
|
|
||||||
|
|
||||||
RenderCommand.SetViewport(0, 0, _sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
|
||||||
|
|
||||||
RenderCommand.SetBlendState(_gBufferBlend);
|
|
||||||
|
|
||||||
//RenderCommand.UnbindRenderTargets();
|
|
||||||
//RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
|
||||||
//RenderCommand.BindRenderTargets();
|
|
||||||
|
|
||||||
// TODO: Draw into GBuffer
|
|
||||||
for (SubmittedMesh entry in _queue)
|
|
||||||
{
|
{
|
||||||
entry.Material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
Debug.Profiler.ProfileRendererScope!("Draw GBuffer");
|
||||||
entry.Material.SetVariable("Transform", entry.Transform);
|
|
||||||
|
_gBuffer.EnsureSize(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
||||||
entry.Material.Bind(_context);
|
_gBuffer.Clear();
|
||||||
|
RenderCommand.UnbindRenderTargets();
|
||||||
entry.Mesh.Bind();
|
_gBuffer.Bind();
|
||||||
RenderCommand.DrawIndexed(entry.Mesh);
|
|
||||||
|
RenderCommand.SetViewport(0, 0, _sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height);
|
||||||
|
|
||||||
|
RenderCommand.SetBlendState(_gBufferBlend);
|
||||||
|
|
||||||
|
for (SubmittedMesh entry in _queue)
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("Draw Mesh");
|
||||||
|
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileRendererScope!("SetVariables");
|
||||||
|
|
||||||
|
entry.Material.SetVariable("ViewProjection", _sceneConstants.ViewProjection);
|
||||||
|
entry.Material.SetVariable("Transform", entry.Transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.Material.Bind(_context);
|
||||||
|
|
||||||
|
entry.Mesh.Bind();
|
||||||
|
RenderCommand.DrawIndexed(entry.Mesh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderCommand.UnbindRenderTargets();
|
{
|
||||||
RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
Debug.Profiler.ProfileRendererScope!("Draw Lights");
|
||||||
RenderCommand.BindRenderTargets();
|
|
||||||
|
RenderCommand.UnbindRenderTargets();
|
||||||
_gBuffer.Albedo.SamplerState = SamplerStateManager.PointClamp;
|
RenderCommand.SetRenderTarget(_sceneConstants.CameraTarget, 0, true);
|
||||||
|
RenderCommand.BindRenderTargets();
|
||||||
TestFullscreenEffect.SetTexture("GBuffer_Albedo", _gBuffer.Albedo);
|
|
||||||
TestFullscreenEffect.SetTexture("GBuffer_Normal", _gBuffer.Normal);
|
_gBuffer.Albedo.SamplerState = SamplerStateManager.PointClamp;
|
||||||
TestFullscreenEffect.SetTexture("GBuffer_Tangent", _gBuffer.Tangent);
|
|
||||||
TestFullscreenEffect.SetTexture("GBuffer_Position", _gBuffer.Position);
|
TestFullscreenEffect.SetTexture("GBuffer_Albedo", _gBuffer.Albedo);
|
||||||
TestFullscreenEffect.SetTexture("GBuffer_Material", _gBuffer.Material);
|
TestFullscreenEffect.SetTexture("GBuffer_Normal", _gBuffer.Normal);
|
||||||
|
TestFullscreenEffect.SetTexture("GBuffer_Tangent", _gBuffer.Tangent);
|
||||||
TestFullscreenEffect.Variables["LightColor"].SetData(Vector3(1, 1, 1));
|
TestFullscreenEffect.SetTexture("GBuffer_Position", _gBuffer.Position);
|
||||||
TestFullscreenEffect.Variables["Illuminance"].SetData(5.0f);
|
TestFullscreenEffect.SetTexture("GBuffer_Material", _gBuffer.Material);
|
||||||
TestFullscreenEffect.Variables["LightDir"].SetData(Vector3(0, 1, 0));
|
|
||||||
TestFullscreenEffect.Variables["CameraPos"].SetData(_sceneConstants.CameraPosition);
|
TestFullscreenEffect.Variables["LightColor"].SetData(Vector3(1, 1, 1));
|
||||||
TestFullscreenEffect.Variables["Scaling"].SetData(Vector2(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height) / Vector2(_gBuffer.Albedo.Width, _gBuffer.Albedo.Height));
|
TestFullscreenEffect.Variables["Illuminance"].SetData(5.0f);
|
||||||
|
TestFullscreenEffect.Variables["LightDir"].SetData(Vector3(0, 1, 0));
|
||||||
TestFullscreenEffect.Bind(_context);
|
TestFullscreenEffect.Variables["CameraPos"].SetData(_sceneConstants.CameraPosition);
|
||||||
|
TestFullscreenEffect.Variables["Scaling"].SetData(Vector2(_sceneConstants.CameraTarget.Width, _sceneConstants.CameraTarget.Height) / Vector2(_gBuffer.Albedo.Width, _gBuffer.Albedo.Height));
|
||||||
s_quadGeometry.Bind();
|
|
||||||
RenderCommand.DrawIndexed(s_quadGeometry);
|
TestFullscreenEffect.Bind(_context);
|
||||||
|
|
||||||
RenderCommand.UnbindTextures();
|
s_quadGeometry.Bind();
|
||||||
|
RenderCommand.DrawIndexed(s_quadGeometry);
|
||||||
|
|
||||||
|
RenderCommand.UnbindTextures();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Draw lights to camera target
|
// TODO: Draw lights to camera target
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user