Switch to using an index for sprite tracking

Frees up two bytes in GPUCell. Doesn't require a minimum texture row
size. Makes a bunch of code faster. Index uses 31 bits which gives us
2,147,483,647 aka ~ 2 billion sprites.
This commit is contained in:
Kovid Goyal
2024-12-11 08:36:03 +05:30
parent 203a5f4e00
commit 0fb49f4139
12 changed files with 97 additions and 71 deletions

View File

@@ -338,6 +338,13 @@ extern GlobalState global_state;
else Py_DECREF(cret_); \
}
static inline void
sprite_index_to_pos(unsigned idx, unsigned xnum, unsigned ynum, unsigned *x, unsigned *y, unsigned *z) {
div_t r = div(idx & 0x7fffffff, ynum * xnum), r2 = div(r.rem, xnum);
*z = r.quot; *y = r2.quot; *x = r2.rem;
}
void gl_init(void);
void remove_vao(ssize_t vao_idx);
bool remove_os_window(id_type os_window_id);
@@ -379,7 +386,7 @@ void update_surface_size(int, int, uint32_t);
void free_texture(uint32_t*);
void free_framebuffer(uint32_t*);
void send_image_to_gpu(uint32_t*, const void*, int32_t, int32_t, bool, bool, bool, RepeatStrategy);
void send_sprite_to_gpu(FONTS_DATA_HANDLE fg, unsigned int, unsigned int, unsigned int, pixel*);
void send_sprite_to_gpu(FONTS_DATA_HANDLE fg, unsigned int, pixel*);
void blank_canvas(float, color_type);
void blank_os_window(OSWindow *);
void set_os_window_chrome(OSWindow *w);