Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D-Canvas: Improve Render performance #246

Open
kimkulling opened this issue Oct 11, 2024 · 0 comments
Open

2D-Canvas: Improve Render performance #246

kimkulling opened this issue Oct 11, 2024 · 0 comments
Labels
Improvements Possible Improvements TechDept Tech-Depts in OSRE

Comments

@kimkulling
Copy link
Owner

Improved drawRect method implementation for unfilled rectangles

The new implementation for unfilled rectangles in the drawRect method offers better control and clarity:

Each edge of the rectangle is now drawn explicitly, improving precision.
The use of a constant thickness enhances maintainability.
However, there's a potential optimization opportunity:

Consider creating a single DrawCmd for the entire unfilled rectangle instead of four separate commands. This could improve performance, especially when drawing many unfilled rectangles. Here's a potential approach:

if (!filled) {
    DrawCmd *drawCmd = alloc();
    drawCmd->NumVertices = 8;  // 4 corners, each used twice
    drawCmd->Vertices = new RenderVert[drawCmd->NumVertices];
    // ... set up vertices for all four corners ...
    
    drawCmd->NumIndices = 8;  // 4 lines, 2 indices each
    drawCmd->Indices = new ui16[drawCmd->NumIndices];
    // ... set up indices to draw 4 lines ...
    
    drawCmd->PrimType = PrimitiveType::LineList;
    mDrawCmdArray.add(drawCmd);
}

This approach would reduce memory allocations and draw calls, potentially improving performance.

@kimkulling kimkulling added TechDept Tech-Depts in OSRE Improvements Possible Improvements labels Oct 11, 2024
@kimkulling kimkulling changed the title 2D-Canvas: IMprove Render performance 2D-Canvas: Improve Render performance Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvements Possible Improvements TechDept Tech-Depts in OSRE
Projects
None yet
Development

No branches or pull requests

1 participant