From fefc9c95e4818768ba08c665111d2e405ae72672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 5 Apr 2019 20:45:32 +0200 Subject: 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. --- source/blender/draw/intern/draw_manager.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/draw/intern/draw_manager.h') 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 { -- cgit v1.2.3