Skip to content

Batching is not working #4849

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

Closed
Flyboy1010 opened this issue Mar 21, 2025 · 2 comments
Closed

Batching is not working #4849

Flyboy1010 opened this issue Mar 21, 2025 · 2 comments

Comments

@Flyboy1010
Copy link

Issue description

I am using the Raylib bindings for Zig to render a tilemap by calling rl.drawTextureRec inside a loop. All tiles use the same texture, and the rendering happens within rl.beginTextureMode and rl.endTextureMode to allow for post-processing effects later.

However, when I inspect the rendering in RenderDoc, I notice that each tile results in a separate draw call instead of batching into a single one. Since I'm using a single texture, I expected Raylib to batch the draw calls automatically. I'm unsure why this is happening.

Environment

Version: 3.3.0 Core Profile Context 25.3.1.250220
GLSL: 4.60
GPU: AMD rx 7900 GRE

Issue Screenshot

The render doc screenshot with 1 draw call per tile

Image

It is rebinding the same texture over and over again

Image

Code Example

// loading the texture
...
const target = try rl.loadRenderTexture(target_width, target_height);
defer rl.unloadRenderTexture(target);

const tileset = try rl.loadTexture("res/sprites/tileset.png");
defer rl.unloadTexture(tileset);
...

// rendering code
...
rl.beginTextureMode(target);
rl.clearBackground(.{ .r = 40, .g = 40, .b = 46, .a = 255 });
for (...) {
  rl.drawTextureRec(
      tileset, 
      ...
  );
}
rl.endTextureMode();
...
@raysan5
Copy link
Owner

raysan5 commented Mar 21, 2025

@Flyboy1010 Wow! Thanks for detecting it! I'm reviewing it at the moment...

raysan5 added a commit that referenced this issue Mar 21, 2025
I'm sorry... I did not detect this change was breaking batching... :(
@raysan5
Copy link
Owner

raysan5 commented Mar 21, 2025

@Flyboy1010 Issue is fixed. The issue was due to a change I merged a while ago, sorry for the inconvenience...

@raysan5 raysan5 closed this as completed Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants