diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-04-05 21:45:32 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-04-05 22:15:25 +0300 |
commit | fefc9c95e4818768ba08c665111d2e405ae72672 (patch) | |
tree | 3eaf8cdd0a7ead15111c618009c32c2480642a45 /source/blender/draw/intern/draw_manager.h | |
parent | 2219f28a68b69ba227270abadbcaa431601d42dc (diff) |
DRW: Opti: Replace bound tex/ubo tracking array by bitfields
release_texture_slots() and release_ubo_slots() were one hotspot when
drawing taking ~9% of total CPU counters for no reason.
This was because of the loops using GPU_max_textures that was overkill and
slow.
Replace those by a simple 64bit bitwise OR operation.
Diffstat (limited to 'source/blender/draw/intern/draw_manager.h')
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 45721951abf..03f6eef225e 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -313,6 +313,7 @@ typedef struct DRWDebugSphere { /* ------------- DRAW MANAGER ------------ */ +#define DST_MAX_SLOTS 64 /* Cannot be changed without modifying RST.bound_tex_slots */ #define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */ #define STENCIL_UNDEFINED 256 typedef struct DRWManager { @@ -394,12 +395,16 @@ typedef struct DRWManager { /** GPU Resource State: Memory storage between drawing. */ struct { - GPUTexture **bound_texs; - char *bound_tex_slots; - int bind_tex_inc; - GPUUniformBuffer **bound_ubos; - char *bound_ubo_slots; - int bind_ubo_inc; + /* High end GPUs supports up to 32 binds per shader stage. + * We only use textures during the vertex and fragment stage, + * so 2 * 32 slots is a nice limit. */ + GPUTexture *bound_texs[DST_MAX_SLOTS]; + uint64_t bound_tex_slots; + uint64_t bound_tex_slots_persist; + + GPUUniformBuffer *bound_ubos[DST_MAX_SLOTS]; + uint64_t bound_ubo_slots; + uint64_t bound_ubo_slots_persist; } RST; struct { |