From 174ed69c1ba8cb8ca7ac39d41922bc203f78326f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 15 Jun 2021 15:31:17 +0200 Subject: DrawManager: Cache material offsets. When using multiple materials in a single mesh the most time is spend in counting the offsets of each material for the sorting. This patch moves the counting of the offsets to render mesh data and caches it as long as the geometry doesn't change. This patch doesn't include multithreading of this code. Reviewed By: mano-wii Differential Revision: https://developer.blender.org/D11612 --- source/blender/draw/intern/draw_cache_extract.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/draw/intern/draw_cache_extract.h') diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.h index 46234366251..2c4e4dfe76b 100644 --- a/source/blender/draw/intern/draw_cache_extract.h +++ b/source/blender/draw/intern/draw_cache_extract.h @@ -83,8 +83,9 @@ typedef enum eMRDataType { MR_DATA_LOOPTRI = 1 << 3, /** Force loop normals calculation. */ MR_DATA_TAN_LOOP_NOR = 1 << 4, + MR_DATA_MAT_OFFSETS = 1 << 5, } eMRDataType; -ENUM_OPERATORS(eMRDataType, MR_DATA_TAN_LOOP_NOR) +ENUM_OPERATORS(eMRDataType, MR_DATA_MAT_OFFSETS) #ifdef __cplusplus extern "C" { @@ -166,6 +167,12 @@ typedef struct MeshBufferExtractionCache { int *verts; int *edges; } loose_geom; + + struct { + int *tri; + int visible_tri_len; + } mat_offsets; + } MeshBufferExtractionCache; typedef enum DRWBatchFlag { -- cgit v1.2.3