Skip to content

Commit 5ac4f15

Browse files
[Rendering] Cleanup and even more ImGui fixes;
1 parent 8555a3a commit 5ac4f15

File tree

7 files changed

+9
-25
lines changed

7 files changed

+9
-25
lines changed

Engine/Staple.Core/Rendering/Graphics.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public static class Graphics
1515
/// <param name="vertex">The vertex buffer</param>
1616
/// <param name="index">The index buffer</param>
1717
/// <param name="startVertex">The starting vertex</param>
18-
/// <param name="vertexCount">The amount of vertexes to draw</param>
1918
/// <param name="startIndex">The start index</param>
2019
/// <param name="indexCount">The amount of indices to draw</param>
2120
/// <param name="material">The material to use</param>
@@ -25,7 +24,7 @@ public static class Graphics
2524
/// <param name="viewID">The bgfx view ID to render to</param>
2625
/// <param name="materialSetupCallback">A callback to setup the material. If it's not set, the default behaviour will be used</param>
2726
public static void RenderGeometry(VertexBuffer vertex, IndexBuffer index,
28-
int startVertex, int vertexCount, int startIndex, int indexCount, Material material,
27+
int startVertex, int startIndex, int indexCount, Material material,
2928
Vector3 position, Matrix4x4 transform, MeshTopology topology, MaterialLighting lighting, ushort viewID,
3029
Action materialSetupCallback = null)
3130
{
@@ -35,7 +34,6 @@ public static void RenderGeometry(VertexBuffer vertex, IndexBuffer index,
3534
index.Disposed ||
3635
startVertex < 0 ||
3736
startIndex < 0 ||
38-
vertexCount <= 0 ||
3937
indexCount <= 0 ||
4038
material == null ||
4139
material.IsValid == false)
@@ -53,9 +51,7 @@ public static void RenderGeometry(VertexBuffer vertex, IndexBuffer index,
5351
vertexBuffer = vertex,
5452
startVertex = startVertex,
5553
startIndex = startIndex,
56-
vertexCount = vertexCount,
5754
indexCount = indexCount,
58-
vertexLayout = vertex.layout,
5955
world = transform,
6056
};
6157

Engine/Staple.Core/Rendering/Mesh/Mesh+Internal.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,6 @@ internal bool SetActive(ref RenderState state, int submeshIndex = 0)
877877

878878
if(submeshes.Count == 0)
879879
{
880-
state.vertexCount = VertexCount;
881880
state.indexCount = indices.Length;
882881
}
883882
else if(submeshIndex >= 0 && submeshIndex < submeshes.Count)
@@ -886,7 +885,6 @@ internal bool SetActive(ref RenderState state, int submeshIndex = 0)
886885

887886
state.startVertex = submesh.startVertex;
888887
state.startIndex = submesh.startIndex;
889-
state.vertexCount = submesh.vertexCount;
890888
state.indexCount = submesh.indexCount;
891889
}
892890
else

Engine/Staple.Core/Rendering/Mesh/MeshCombineSystem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ void SetupMaterial()
360360
indexBuffer = mesh.indexBuffer,
361361
vertexBuffer = mesh.vertexBuffer,
362362
indexCount = mesh.IndexCount,
363-
vertexCount = mesh.VertexCount,
364-
vertexLayout = mesh.vertexBuffer.layout,
365363
world = item.transform.Matrix,
366364
};
367365

Engine/Staple.Core/Rendering/Mesh/MeshRenderSystem.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ public static void RenderMesh(Mesh mesh, Vector3 position, Quaternion rotation,
8181
cull = material.CullingMode,
8282
indexBuffer = mesh.indexBuffer,
8383
vertexBuffer = mesh.vertexBuffer,
84-
vertexLayout = mesh.vertexBuffer.layout,
8584
indexCount = mesh.IndexCount,
86-
vertexCount = mesh.VertexCount,
8785
world = matrix,
8886
};
8987

@@ -384,7 +382,6 @@ public void Submit(ushort viewID)
384382

385383
renderState.vertexBuffer = content.mesh.vertexBuffer;
386384
renderState.indexBuffer = content.mesh.indexBuffer;
387-
renderState.vertexLayout = content.mesh.vertexBuffer.layout;
388385
renderState.primitiveType = content.mesh.MeshTopology;
389386
renderState.world = content.transform.Matrix;
390387

Engine/Staple.Core/Rendering/RenderSystem/Backend/Impls/SDLGPU/SDLGPURendererBackend.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ public void Render(IRenderPass pass, RenderState state)
513513
if(pass is not SDLGPURenderPass renderPass ||
514514
state.program is not SDLGPUShaderProgram shader ||
515515
shader.Type != ShaderType.VertexFragment ||
516-
state.vertexLayout is not SDLGPUVertexLayout vertexLayout ||
517516
state.vertexBuffer is not SDLGPUVertexBuffer vertex ||
517+
vertex.layout is not SDLGPUVertexLayout vertexLayout ||
518518
state.indexBuffer is not SDLGPUIndexBuffer index)
519519
{
520520
return;

Engine/Staple.Core/Rendering/RenderSystem/Backend/RenderState.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Numerics;
43

54
namespace Staple.Internal;
@@ -15,10 +14,8 @@ internal struct RenderState
1514
public VertexBuffer vertexBuffer;
1615
public IndexBuffer indexBuffer;
1716
public InstanceBuffer instanceBuffer;
18-
public VertexLayout vertexLayout;
1917
public int startVertex;
2018
public int startIndex;
21-
public int vertexCount;
2219
public int indexCount;
2320
public RenderTarget renderTarget;
2421
public BlendMode sourceBlend;
@@ -39,7 +36,7 @@ internal readonly int StateKey
3936
hashCode.Add(wireframe);
4037
hashCode.Add(enableDepth);
4138
hashCode.Add(depthWrite);
42-
hashCode.Add(vertexLayout);
39+
hashCode.Add(vertexBuffer?.layout);
4340
hashCode.Add(renderTarget);
4441
hashCode.Add(sourceBlend);
4542
hashCode.Add(destinationBlend);

Engine/Staple.Editor/ImGuiProxy.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,22 +635,20 @@ private void Render(ImDrawDataPtr drawData)
635635
scissor = new(x, (int)(Math.Min(clipRect.Z, 65535.0f) - x), y, (int)(Math.Min(clipRect.W, 65535.0f) - y)),
636636
indexBuffer = indexBuffer,
637637
vertexBuffer = vertexBuffer,
638-
vertexLayout = layout,
639-
startVertex = currentVertex,
640-
vertexCount = numVertices,
641-
startIndex = currentIndex,
642-
indexCount = numIndices,
638+
startVertex = currentVertex + (int)drawCmd.VtxOffset,
639+
startIndex = currentIndex + (int)drawCmd.IdxOffset,
640+
indexCount = (int)drawCmd.ElemCount,
643641
program = program,
644642
textures = textures,
645643
world = Matrix4x4.Identity,
646644
};
647645

648646
RenderSystem.Submit(pass, state, (int)drawCmd.ElemCount / 3, 1);
649647
}
650-
651-
currentVertex += numVertices;
652-
currentIndex += numIndices;
653648
}
649+
650+
currentVertex += numVertices;
651+
currentIndex += numIndices;
654652
}
655653

656654
pass.Finish();

0 commit comments

Comments
 (0)