Commit: 0df21e2504eeba504c201b4842415885ad5e8c91
Author: Clément Foucault
Date:   Wed Feb 28 01:16:23 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB0df21e2504eeba504c201b4842415885ad5e8c91

DRW: Refactor & Split draw_manager.c into multiple files.

Refactor include:
- Removal of DRWInterface. (was useless)
- Split DRWCallHeader into a new struct DRWCallState that will be reused in the 
future.
- Use BLI_link_utils for APPEND/PREPEND.
- Creation of the new DRWManager struct type. This will enable us to create 
more than one manager in the future.
- Removal of some dead code.

===================================================================

M       source/blender/draw/CMakeLists.txt
M       source/blender/draw/intern/DRW_render.h
M       source/blender/draw/intern/draw_manager.c
A       source/blender/draw/intern/draw_manager.h
A       source/blender/draw/intern/draw_manager_data.c
A       source/blender/draw/intern/draw_manager_exec.c
A       source/blender/draw/intern/draw_manager_framebuffer.c
M       source/blender/draw/intern/draw_manager_profiling.c
A       source/blender/draw/intern/draw_manager_shader.c
A       source/blender/draw/intern/draw_manager_texture.c

===================================================================

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 51b3db695c2..ba2aa0448fd 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -64,7 +64,12 @@ set(SRC
        intern/draw_common.c
        intern/draw_instance_data.c
        intern/draw_manager.c
+       intern/draw_manager_data.c
+       intern/draw_manager_exec.c
+       intern/draw_manager_framebuffer.c
+       intern/draw_manager_shader.c
        intern/draw_manager_text.c
+       intern/draw_manager_texture.c
        intern/draw_manager_profiling.c
        intern/draw_view.c
        modes/edit_armature_mode.c
@@ -108,6 +113,7 @@ set(SRC
        intern/draw_cache_impl.h
        intern/draw_common.h
        intern/draw_instance_data.h
+       intern/draw_manager.h
        intern/draw_manager_text.h
        intern/draw_manager_profiling.h
        intern/draw_view.h
diff --git a/source/blender/draw/intern/DRW_render.h 
b/source/blender/draw/intern/DRW_render.h
index 203fb80c0a0..2a119651ffd 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -288,7 +288,7 @@ typedef enum {
        DRW_STATE_CULL_BACK     = (1 << 6),
        DRW_STATE_CULL_FRONT    = (1 << 7),
        DRW_STATE_WIRE          = (1 << 8),
-       DRW_STATE_WIRE_LARGE    = (1 << 9),
+//     DRW_STATE_WIRE_LARGE    = (1 << 9), /* Removed from ogl in 3.0 */
        DRW_STATE_POINT         = (1 << 10),
        DRW_STATE_STIPPLE_2     = (1 << 11),
        DRW_STATE_STIPPLE_3     = (1 << 12),
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index baa76518270..7e0536c0d25 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -29,2140 +29,68 @@
 #include "BLI_mempool.h"
 #include "BLI_rect.h"
 #include "BLI_string.h"
-#include "BLI_string_utils.h"
 #include "BLI_threads.h"
 
-#include "BIF_glutil.h"
-
-#include "BKE_curve.h"
-#include "BKE_global.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h"
-#include "BKE_pbvh.h"
-#include "BKE_paint.h"
-#include "BKE_workspace.h"
-
-#include "BLT_translation.h"
-#include "BLF_api.h"
-
-#include "DRW_engine.h"
-#include "DRW_render.h"
-
-#include "DNA_camera_types.h"
-#include "DNA_curve_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_meta_types.h"
-
-#include "ED_space_api.h"
-#include "ED_screen.h"
-
-#include "intern/gpu_codegen.h"
-#include "GPU_batch.h"
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-#include "GPU_framebuffer.h"
-#include "GPU_immediate.h"
-#include "GPU_lamp.h"
-#include "GPU_material.h"
-#include "GPU_shader.h"
-#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
-#include "GPU_viewport.h"
-#include "GPU_matrix.h"
-
-#include "IMB_colormanagement.h"
-
-#include "RE_engine.h"
-#include "RE_pipeline.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-#include "wm_window.h"
-
-#include "draw_manager_text.h"
-#include "draw_manager_profiling.h"
-
-/* only for callbacks */
-#include "draw_cache_impl.h"
-
-#include "draw_instance_data.h"
-
-#include "draw_mode_engines.h"
-#include "engines/clay/clay_engine.h"
-#include "engines/eevee/eevee_engine.h"
-#include "engines/basic/basic_engine.h"
-#include "engines/external/external_engine.h"
-
-#include "../../../intern/gawain/gawain/gwn_context.h"
-
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
-
-/* -------------------------------------------------------------------- */
-/** \name Local Features
- * \{ */
-
-#define USE_PROFILE
-
-#ifdef USE_PROFILE
-#  include "PIL_time.h"
-
-#  define PROFILE_TIMER_FALLOFF 0.1
-
-#  define PROFILE_START(time_start) \
-       double time_start = PIL_check_seconds_timer();
-
-#  define PROFILE_END_ACCUM(time_accum, time_start) { \
-       time_accum += (PIL_check_seconds_timer() - time_start) * 1e3; \
-} ((void)0)
-
-/* exp average */
-#  define PROFILE_END_UPDATE(time_update, time_start) { \
-       double _time_delta = (PIL_check_seconds_timer() - time_start) * 1e3; \
-       time_update = (time_update * (1.0 - PROFILE_TIMER_FALLOFF)) + \
-                     (_time_delta * PROFILE_TIMER_FALLOFF); \
-} ((void)0)
-
-#else  /* USE_PROFILE */
-
-#  define PROFILE_START(time_start) ((void)0)
-#  define PROFILE_END_ACCUM(time_accum, time_start) ((void)0)
-#  define PROFILE_END_UPDATE(time_update, time_start) ((void)0)
-
-#endif  /* USE_PROFILE */
-
-
-/* Use draw manager to call GPU_select, see: DRW_draw_select_loop */
-#define USE_GPU_SELECT
-
-#ifdef USE_GPU_SELECT
-#  include "ED_view3d.h"
-#  include "ED_armature.h"
-#  include "GPU_select.h"
-#endif
-
-/** \} */
-
-
-#define MAX_ATTRIB_NAME 32
-#define MAX_ATTRIB_COUNT 6 /* Can be adjusted for more */
-#define MAX_PASS_NAME 32
-#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
-
-extern char datatoc_gpu_shader_2D_vert_glsl[];
-extern char datatoc_gpu_shader_3D_vert_glsl[];
-extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
-
-/* Prototypes. */
-static void drw_engines_enable_external(void);
-
-/* Structures */
-typedef enum {
-       DRW_UNIFORM_BOOL,
-       DRW_UNIFORM_SHORT_TO_INT,
-       DRW_UNIFORM_SHORT_TO_FLOAT,
-       DRW_UNIFORM_INT,
-       DRW_UNIFORM_FLOAT,
-       DRW_UNIFORM_TEXTURE,
-       DRW_UNIFORM_BUFFER,
-       DRW_UNIFORM_BLOCK
-} DRWUniformType;
-
-#define MAX_UNIFORM_DATA_SIZE 16
-
-struct DRWUniform {
-       struct DRWUniform *next;
-       const void *value;
-       int location;
-       char type; /* DRWUniformType */
-       char length; /* cannot be more than 16 */
-       char arraysize; /* cannot be more than 16 too */
-};
-
-struct DRWInterface {
-       DRWUniform *uniforms;   /* DRWUniform, single-linked list */
-       /* Dynamic batch */
-#ifdef USE_GPU_SELECT
-       struct DRWInstanceData *inst_selectid;
-       /* Override for single object instances. */
-       int override_selectid;
-#endif
-       Gwn_VertBuf *instance_vbo;
-       unsigned int instance_count;
-#ifndef NDEBUG
-       char attribs_count;
-#endif
-       /* matrices locations */
-       int model;
-       int modelinverse;
-       int modelview;
-       int modelviewinverse;
-       int modelviewprojection;
-       int normalview;
-       int normalworld;
-       int orcotexfac;
-       int eye;
-       /* Matrices needed */
-       uint16_t matflag;
-};
-
-struct DRWPass {
-       /* Single linked list with last member to append */
-       DRWShadingGroup *shgroups;
-       DRWShadingGroup *shgroups_last;
-
-       DRWState state;
-       char name[MAX_PASS_NAME];
-};
-
-typedef struct DRWCallHeader {
-       void *prev;
-#ifdef USE_GPU_SELECT
-       int select_id;
-#endif
-       unsigned char type, state;
-       uint16_t matflag;
-       /* Culling: Using Bounding Sphere for now for faster culling.
-        * Not ideal for planes. */
-       struct {
-               float loc[3], rad; /* Bypassed if radius is < 0.0. */
-       } bsphere;
-       /* Matrices */
-       float model[4][4];
-       float modelinverse[4][4];
-       float modelview[4][4];
-       float modelviewinverse[4][4];
-       float modelviewprojection[4][4];
-       float normalview[3][3];
-       float normalworld[3][3]; /* Not view dependant */
-       float orcotexfac[2][3]; /* Not view dependant */
-       float eyevec[3];
-} DRWCallHeader;
-
-typedef struct DRWCall {
-       DRWCallHeader head;
-
-       Gwn_Batch *geometry;
-} DRWCall;
-
-typedef struct DRWCallGenerate {
-       DRWCallHeader head;
-
-       DRWCallGenerateFn *geometry_fn;
-       void *user_data;
-} DRWCallGenerate;
-
-/* Used by DRWCall.flag */
-enum {
-       DRW_CALL_SINGLE,                 /* A single batch */
-       DRW_CALL_GENERATE,               /* Uses a callback to draw with any 
number of batches. */
-};
-
-/* Used by DRWCall.state */
-enum {
-       DRW_CALL_CULLED                 = (1 << 0),
-       DRW_CALL_NEGSCALE               = (1 << 1),
-};
-
-/* Used by DRWCall.flag */
-enum {
-       DRW_CALL_MODELINVERSE           = (1 << 0),
-       DRW_CALL_MODELVIEW              = (1 << 1),
-       DRW_CALL_MODELVIEWINVERSE       = (1 << 2),
-       DRW_CALL_MODELVIEWPROJECTION    = (1 << 3),
-       DRW_CALL_NORMALVIEW             = (1 << 4),
-       DRW_CALL_NORMALWORLD            = (1 << 5),
-       DRW_CALL_ORCOTEXFAC             = (1 << 6),
-       DRW_CALL_EYEVEC                 = (1 << 7),
-       /* 8 bit flag! */
-};
-
-struct DRWShadingGroup {
-       struct DRWShadingGroup *next;
-#ifdef USE_GPU_SELECT
-       /* backlink to pass we're in */
-       DRWPass *pass_parent;
-#endif
-       GPUShader *shader;               /* Shader to bind */
-       DRWInterface interface;          /* Uniforms pointers */
-       DRWState state_extra;            /* State changes for this batch only 
(or'd with the pass's state) */
-       DRWState state_extra_disable;    /* State changes for this batch only 
(and'd with the pass's state) */
-       unsigned int stencil_mask;       /* Stencil mask to use for stencil 
test / write operations */
-       int type;
-
-       /* Watch this! Can be nasty for debugging. */
-       union {
-               struct { /* DRW_SHG_NORMAL */
-                       void *calls;                 /* DRWCall or 
DRWCallDynamic depending of type */
-                       void *calls_first;           /* To be able to traverse 
the list in the order of addition */
-               };
-               struct { /* DRW_SHG_***_BATCH */
-                       Gwn_Batch *batch_geom;     /* Result of call batching */
-               };
-               struct { /* DRW_SHG_INSTANCE[_EXTERNAL] */
-                       Gwn_Batch *instance_geom;  /* Geometry to instance */
-                       Gwn_Batch *instancing_geom;/* Instances attributes */
-                       float instance_orcofac[2][3]; /* TODO find a better 
place. */
-               };
-       };
-};
-
-/* Used by DRWShadingGroup.type */
-enum {
-       DRW_SHG_NORMAL,
-       DRW_SHG_POINT_BATCH,
-       DRW_SHG_LINE_BATCH,
-       DRW_SHG_TRIANGLE_BATCH,
-       DRW_SHG_INSTANCE,
-       DRW_SHG_INSTANCE_EXTERNAL,
-};
-
-/** Render State: No persistent data between draw calls. */
-static struct DRWGlobalState {
-       /* Cache generation */
-       ViewportMemoryPool *vmempool;
-       DRWUniform *last_uniform;
-       DRWCall *last_call;
-       DRWCallGenerate *last_callgenerate;
-       DRWShadingGroup *last_shgroup;
-       DRWInstanceDataList *idatalist;
-       DRWInstanceData *common_instance_data[MAX_INSTANCE_DATA_SIZE];
-
-       /* Rendering state */
-       GPUShader *shader;
-
-       /* Managed by `DRW_state_set`, `DRW_state_reset` */
-       DRWState state;
-       unsigned int stencil_mask;
-
-       /* Per viewport */
-       GPUViewport *viewport;
-       struct GPUFrameBuffer *default_framebuffer;
-       float size[2];
-       float screenvecs[2][3];
-       float pixsize;
-
-       GLenum backface, frontface;
-
-       /* Clip planes */
-       int num_clip_planes;
-       float clip_planes_eq[MAX_CLIP_PLANES][4];
-
-       struct {
-               unsigned int is_select : 1;
-               unsigned int is_depth : 1;
-               unsigned int is_image_render : 1;
-               unsigned int i

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to