Render more than ~5300 images #1467
Conversation
| sampler, | ||
| }); | ||
| ctx.fill_rect(&Rect::new(0.0, 0.0, 10.0, 10.0)); | ||
| } No newline at end of file |
|
|
||
| // Convert a flat texel index to 2D texture coordinates for the encoded paints texture. | ||
| fn encoded_paint_coord(flat_idx: u32) -> vec2<u32> { | ||
| let w = textureDimensions(encoded_paints_texture).x; |
There was a problem hiding this comment.
I’d be interested in exploring passing the texture dimensions as a uniform later. I’m curious how it performs across different machines.
There was a problem hiding this comment.
Ohhh great idea. This would mimic what we do for alphas_tex_width_bits. Implemented in 050add1
| // Convert a flat texel index to 2D texture coordinates for the encoded paints texture. | ||
| fn encoded_paint_coord(flat_idx: u32) -> vec2<u32> { | ||
| let w = textureDimensions(encoded_paints_texture).x; | ||
| return vec2<u32>(flat_idx % w, flat_idx / w); |
There was a problem hiding this comment.
If we can rely on max_texture_dimension_2d always being a power of two, we can use bitwise operations. We use the same pattern for alphas_texture.
There was a problem hiding this comment.
Great idea! Thank you! Implemented in 050add1
| } | ||
|
|
||
| /// Configuration for the GPU renderer. | ||
| #[repr(C)] |
There was a problem hiding this comment.
I think if we set this to align(16), bytemuck will automatically complain in case there is not enough padding, which could be useful in case we change it again in the future
| _padding0: u32, | ||
| _padding1: u32, | ||
| _padding2: u32, |
There was a problem hiding this comment.
Can we not use an array<3> here?
There was a problem hiding this comment.
That's not possible. Apparently for downleveling uniforms to WebGL2, arrays require a stride of 16 bytes. See the table in this section .
array<S> requires alignment roundUp(16, AlignOf(S)).
edit: How wild that it requires so much memory. A big pain point for uniforms!
Fixes #1468
There is a bug in the shader code - we only check the first row of the encoded paints texture. On my machine, that gives me ~5400 images before I start drawing empty rectangles.
This PR modifies our
textureLoadcalls to consider more than the first row of texels.On my machine, I used the following test to verify the fix.