Cleanp: use single global for draw manager
authorCampbell Barton <ideasman42@gmail.com>
Tue, 22 Jan 2019 01:09:27 +0000 (12:09 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 22 Jan 2019 01:09:27 +0000 (12:09 +1100)
Add 'G_draw' for all draw manager globals,
avoids adding extern to each file.

Connection between `ts` and `globals_ubo` wasn't obvious,
now called `G_draw.block` & `G_draw.block_ubo`.

21 files changed:
source/blender/draw/engines/eevee/eevee_engine.c
source/blender/draw/engines/eevee/eevee_lightprobes.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/eevee/eevee_shaders.c
source/blender/draw/intern/draw_anim_viz.c
source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/intern/draw_manager.c
source/blender/draw/modes/edit_armature_mode.c
source/blender/draw/modes/edit_curve_mode.c
source/blender/draw/modes/edit_lattice_mode.c
source/blender/draw/modes/edit_mesh_mode.c
source/blender/draw/modes/edit_metaball_mode.c
source/blender/draw/modes/edit_text_mode.c
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/overlay_mode.c
source/blender/draw/modes/paint_texture_mode.c
source/blender/draw/modes/paint_vertex_mode.c
source/blender/draw/modes/paint_weight_mode.c
source/blender/draw/modes/particle_mode.c
source/blender/draw/modes/pose_mode.c

index 23db700..47010fe 100644 (file)
@@ -44,7 +44,6 @@
 
 #define EEVEE_ENGINE "BLENDER_EEVEE"
 
-extern GlobalsUboStorage ts;
 
 /* *********** FUNCTIONS *********** */
 
index 52bc4b9..a9e51b8 100644 (file)
@@ -65,7 +65,6 @@ static struct {
        struct GPUVertFormat *format_probe_display_planar;
 } e_data = {NULL}; /* Engine data */
 
-extern GlobalsUboStorage ts;
 
 /* *********** FUNCTIONS *********** */
 
@@ -316,7 +315,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
                Scene *scene = draw_ctx->scene;
                World *wo = scene->world;
 
-               float *col = ts.colorBackground;
+               const float *col = G_draw.block.colorBackground;
 
                /* LookDev */
                EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, wo, pinfo);
index 0099023..43762bd 100644 (file)
@@ -108,7 +108,6 @@ extern char datatoc_volumetric_lib_glsl[];
 extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
 
 extern Material defmaterial;
-extern GlobalsUboStorage ts;
 
 /* *********** FUNCTIONS *********** */
 
@@ -961,7 +960,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
                Scene *scene = draw_ctx->scene;
                World *wo = scene->world;
 
-               float *col = ts.colorBackground;
+               const float *col = G_draw.block.colorBackground;
 
                /* LookDev */
                EEVEE_lookdev_cache_init(vedata, &grp, psl->background_pass, wo, NULL);
index 29b30e7..b0b849b 100644 (file)
@@ -97,7 +97,6 @@ extern char datatoc_effect_velocity_resolve_frag_glsl[];
 /* Temporal Sampling */
 extern char datatoc_effect_temporal_aa_glsl[];
 
-extern GlobalsUboStorage ts;
 
 /* *********** FUNCTIONS *********** */
 
index 871358f..60dfea7 100644 (file)
@@ -64,8 +64,6 @@
 
 #include "draw_mode_engines.h"
 
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-
 /* ********************************* Lists ************************************** */
 /* All lists are per viewport specific datas.
  * They are all free when viewport changes engines
@@ -230,7 +228,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
                DRW_shgroup_uniform_bool_copy(shgrp, "selected", sel);
                DRW_shgroup_uniform_bool_copy(shgrp, "useCustomColor", use_custom_col);
                DRW_shgroup_uniform_vec2(shgrp, "viewportSize", DRW_viewport_size_get(), 1);
-               DRW_shgroup_uniform_block(shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
                if (use_custom_col) {
                        DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
                }
@@ -247,7 +245,7 @@ static void MPATH_cache_motion_path(MPATH_PassList *psl,
        DRW_shgroup_uniform_bool_copy(shgrp, "selected", sel);
        DRW_shgroup_uniform_bool_copy(shgrp, "showKeyFrames", show_keyframes);
        DRW_shgroup_uniform_bool_copy(shgrp, "useCustomColor", use_custom_col);
-       DRW_shgroup_uniform_block(shgrp, "globalsBlock", globals_ubo);
+       DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
        if (use_custom_col) {
                DRW_shgroup_uniform_vec3(shgrp, "customColor", mpath->color, 1);
        }
index 6145da7..83ea2cc 100644 (file)
        ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f)
 
 /* Colors & Constant */
-GlobalsUboStorage ts;
-struct GPUUniformBuffer *globals_ubo = NULL;
-struct GPUTexture *globals_ramp = NULL;
-struct GPUTexture *globals_weight_ramp = NULL;
+struct DRW_Global G_draw = {0};
 
 static bool weight_ramp_custom = false;
 static ColorBand weight_ramp_copy;
@@ -56,119 +53,121 @@ static struct GPUTexture *DRW_create_weight_colorramp_texture(void);
 
 void DRW_globals_update(void)
 {
-       UI_GetThemeColor4fv(TH_WIRE, ts.colorWire);
-       UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit);
-       UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive);
-       UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect);
-       UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect);
-       UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary);
-       UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform);
-       UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
-       UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
-       UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera);
-       UI_GetThemeColor4fv(TH_EMPTY, ts.colorEmpty);
-       UI_GetThemeColor4fv(TH_VERTEX, ts.colorVertex);
-       UI_GetThemeColor4fv(TH_VERTEX_SELECT, ts.colorVertexSelect);
-       UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, ts.colorVertexUnreferenced);
-       UI_COLOR_RGBA_FROM_U8(0xB0, 0x00, 0xB0, 0xFF, ts.colorVertexMissingData);
-       UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, ts.colorEditMeshActive);
-       UI_GetThemeColor4fv(TH_EDGE_SELECT, ts.colorEdgeSelect);
-
-       UI_GetThemeColor4fv(TH_EDGE_SEAM, ts.colorEdgeSeam);
-       UI_GetThemeColor4fv(TH_EDGE_SHARP, ts.colorEdgeSharp);
-       UI_GetThemeColor4fv(TH_EDGE_CREASE, ts.colorEdgeCrease);
-       UI_GetThemeColor4fv(TH_EDGE_BEVEL, ts.colorEdgeBWeight);
-       UI_GetThemeColor4fv(TH_EDGE_FACESEL, ts.colorEdgeFaceSelect);
-       UI_GetThemeColor4fv(TH_FACE, ts.colorFace);
-       UI_GetThemeColor4fv(TH_FACE_SELECT, ts.colorFaceSelect);
-       UI_GetThemeColor4fv(TH_NORMAL, ts.colorNormal);
-       UI_GetThemeColor4fv(TH_VNORMAL, ts.colorVNormal);
-       UI_GetThemeColor4fv(TH_LNORMAL, ts.colorLNormal);
-       UI_GetThemeColor4fv(TH_FACE_DOT, ts.colorFaceDot);
-       UI_GetThemeColor4fv(TH_BACK, ts.colorBackground);
+       GlobalsUboStorage *gb = &G_draw.block;
+
+       UI_GetThemeColor4fv(TH_WIRE, gb->colorWire);
+       UI_GetThemeColor4fv(TH_WIRE_EDIT, gb->colorWireEdit);
+       UI_GetThemeColor4fv(TH_ACTIVE, gb->colorActive);
+       UI_GetThemeColor4fv(TH_SELECT, gb->colorSelect);
+       UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, gb->colorLibrarySelect);
+       UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, gb->colorLibrary);
+       UI_GetThemeColor4fv(TH_TRANSFORM, gb->colorTransform);
+       UI_GetThemeColor4fv(TH_LAMP, gb->colorLamp);
+       UI_GetThemeColor4fv(TH_SPEAKER, gb->colorSpeaker);
+       UI_GetThemeColor4fv(TH_CAMERA, gb->colorCamera);
+       UI_GetThemeColor4fv(TH_EMPTY, gb->colorEmpty);
+       UI_GetThemeColor4fv(TH_VERTEX, gb->colorVertex);
+       UI_GetThemeColor4fv(TH_VERTEX_SELECT, gb->colorVertexSelect);
+       UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, gb->colorVertexUnreferenced);
+       UI_COLOR_RGBA_FROM_U8(0xB0, 0x00, 0xB0, 0xFF, gb->colorVertexMissingData);
+       UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, gb->colorEditMeshActive);
+       UI_GetThemeColor4fv(TH_EDGE_SELECT, gb->colorEdgeSelect);
+
+       UI_GetThemeColor4fv(TH_EDGE_SEAM, gb->colorEdgeSeam);
+       UI_GetThemeColor4fv(TH_EDGE_SHARP, gb->colorEdgeSharp);
+       UI_GetThemeColor4fv(TH_EDGE_CREASE, gb->colorEdgeCrease);
+       UI_GetThemeColor4fv(TH_EDGE_BEVEL, gb->colorEdgeBWeight);
+       UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->colorEdgeFaceSelect);
+       UI_GetThemeColor4fv(TH_FACE, gb->colorFace);
+       UI_GetThemeColor4fv(TH_FACE_SELECT, gb->colorFaceSelect);
+       UI_GetThemeColor4fv(TH_NORMAL, gb->colorNormal);
+       UI_GetThemeColor4fv(TH_VNORMAL, gb->colorVNormal);
+       UI_GetThemeColor4fv(TH_LNORMAL, gb->colorLNormal);
+       UI_GetThemeColor4fv(TH_FACE_DOT, gb->colorFaceDot);
+       UI_GetThemeColor4fv(TH_BACK, gb->colorBackground);
 
        /* Custom median color to slightly affect the edit mesh colors. */
-       interp_v4_v4v4(ts.colorEditMeshMiddle, ts.colorVertexSelect, ts.colorWireEdit, 0.35f);
-       copy_v3_fl(ts.colorEditMeshMiddle, dot_v3v3(ts.colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */
+       interp_v4_v4v4(gb->colorEditMeshMiddle, gb->colorVertexSelect, gb->colorWireEdit, 0.35f);
+       copy_v3_fl(gb->colorEditMeshMiddle, dot_v3v3(gb->colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */
 
-       interp_v4_v4v4(ts.colorDupliSelect, ts.colorBackground, ts.colorSelect, 0.5f);
+       interp_v4_v4v4(gb->colorDupliSelect, gb->colorBackground, gb->colorSelect, 0.5f);
        /* Was 50% in 2.7x since the background was lighter making it easier to tell the color from black,
         * with a darker background we need a more faded color. */
-       interp_v4_v4v4(ts.colorDupli, ts.colorBackground, ts.colorWire, 0.3f);
+       interp_v4_v4v4(gb->colorDupli, gb->colorBackground, gb->colorWire, 0.3f);
 
 #ifdef WITH_FREESTYLE
-       UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, ts.colorEdgeFreestyle);
-       UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, ts.colorFaceFreestyle);
+       UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, gb->colorEdgeFreestyle);
+       UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, gb->colorFaceFreestyle);
 #else
-       zero_v4(ts.colorEdgeFreestyle);
-       zero_v4(ts.colorFaceFreestyle);
+       zero_v4(gb->colorEdgeFreestyle);
+       zero_v4(gb->colorFaceFreestyle);
 #endif
 
        /* Curve */
-       UI_GetThemeColor4fv(TH_HANDLE_FREE, ts.colorHandleFree);
-       UI_GetThemeColor4fv(TH_HANDLE_AUTO, ts.colorHandleAuto);
-       UI_GetThemeColor4fv(TH_HANDLE_VECT, ts.colorHandleVect);
-       UI_GetThemeColor4fv(TH_HANDLE_ALIGN, ts.colorHandleAlign);
-       UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, ts.colorHandleAutoclamp);
-       UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, ts.colorHandleSelFree);
-       UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, ts.colorHandleSelAuto);
-       UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, ts.colorHandleSelVect);
-       UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, ts.colorHandleSelAlign);
-       UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, ts.colorHandleSelAutoclamp);
-       UI_GetThemeColor4fv(TH_NURB_ULINE, ts.colorNurbUline);
-       UI_GetThemeColor4fv(TH_NURB_VLINE, ts.colorNurbVline);
-       UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, ts.colorNurbSelUline);
-       UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, ts.colorNurbSelVline);
-       UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, ts.colorActiveSpline);
-
-       UI_GetThemeColor4fv(TH_BONE_POSE, ts.colorBonePose);
-
-       UI_GetThemeColor4fv(TH_CFRAME, ts.colorCurrentFrame);
+       UI_GetThemeColor4fv(TH_HANDLE_FREE, gb->colorHandleFree);
+       UI_GetThemeColor4fv(TH_HANDLE_AUTO, gb->colorHandleAuto);
+       UI_GetThemeColor4fv(TH_HANDLE_VECT, gb->colorHandleVect);
+       UI_GetThemeColor4fv(TH_HANDLE_ALIGN, gb->colorHandleAlign);
+       UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, gb->colorHandleAutoclamp);
+       UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, gb->colorHandleSelFree);
+       UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, gb->colorHandleSelAuto);
+       UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, gb->colorHandleSelVect);
+       UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, gb->colorHandleSelAlign);
+       UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, gb->colorHandleSelAutoclamp);
+       UI_GetThemeColor4fv(TH_NURB_ULINE, gb->colorNurbUline);
+       UI_GetThemeColor4fv(TH_NURB_VLINE, gb->colorNurbVline);
+       UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, gb->colorNurbSelUline);
+       UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, gb->colorNurbSelVline);
+       UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb->colorActiveSpline);
+
+       UI_GetThemeColor4fv(TH_BONE_POSE, gb->colorBonePose);
+
+       UI_GetThemeColor4fv(TH_CFRAME, gb->colorCurrentFrame);
 
        /* Grid */
-       UI_GetThemeColorShade4fv(TH_GRID, 10, ts.colorGrid);
+       UI_GetThemeColorShade4fv(TH_GRID, 10, gb->colorGrid);
        /* emphasise division lines lighter instead of darker, if background is darker than grid */
        UI_GetThemeColorShade4fv(
                TH_GRID,
-               (ts.colorGrid[0] + ts.colorGrid[1] + ts.colorGrid[2] + 0.12f >
-                ts.colorBackground[0] + ts.colorBackground[1] + ts.colorBackground[2]) ?
-               20 : -10, ts.colorGridEmphasise);
+               (gb->colorGrid[0] + gb->colorGrid[1] + gb->colorGrid[2] + 0.12f >
+                gb->colorBackground[0] + gb->colorBackground[1] + gb->colorBackground[2]) ?
+               20 : -10, gb->colorGridEmphasise);
        /* Grid Axis */
-       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, ts.colorGridAxisX);
-       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, ts.colorGridAxisY);
-       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, ts.colorGridAxisZ);
+       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, gb->colorGridAxisX);
+       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, gb->colorGridAxisY);
+       UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, gb->colorGridAxisZ);
 
-       UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, ts.colorDeselect);
-       UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, ts.colorOutline);
-       UI_GetThemeColorShadeAlpha4fv(TH_LAMP, 0, 255, ts.colorLampNoAlpha);
+       UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, gb->colorDeselect);
+       UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->colorOutline);
+       UI_GetThemeColorShadeAlpha4fv(TH_LAMP, 0, 255, gb->colorLampNoAlpha);
 
-       ts.sizeLampCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
-       ts.sizeLampCircle = U.pixelsize * 9.0f;
-       ts.sizeLampCircleShadow = ts.sizeLampCircle + U.pixelsize * 3.0f;
+       gb->sizeLampCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
+       gb->sizeLampCircle = U.pixelsize * 9.0f;
+       gb->sizeLampCircleShadow = gb->sizeLampCircle + U.pixelsize * 3.0f;
 
        /* M_SQRT2 to be at least the same size of the old square */
-       ts.sizeVertex = U.pixelsize * (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f));
-       ts.sizeFaceDot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE);
-       ts.sizeEdge = U.pixelsize * (1.0f / 2.0f); /* TODO Theme */
-       ts.sizeEdgeFix = U.pixelsize * (0.5f + 2.0f * (2.0f * (ts.sizeEdge * (float)M_SQRT1_2)));
+       gb->sizeVertex = U.pixelsize * (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f));
+       gb->sizeFaceDot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE);
+       gb->sizeEdge = U.pixelsize * (1.0f / 2.0f); /* TODO Theme */
+       gb->sizeEdgeFix = U.pixelsize * (0.5f + 2.0f * (2.0f * (gb->sizeEdge * (float)M_SQRT1_2)));
 
        /* Color management. */
        if (DRW_state_is_image_render()) {
-               float *color = ts.UBO_FIRST_COLOR;
+               float *color = gb->UBO_FIRST_COLOR;
                do {
                        /* TODO more accurate transform. */
                        srgb_to_linearrgb_v4(color, color);
                        color += 4;
-               } while (color != ts.UBO_LAST_COLOR);
+               } while (color != gb->UBO_LAST_COLOR);
        }
 
-       if (globals_ubo == NULL) {
-               globals_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), &ts);
+       if (G_draw.block_ubo == NULL) {
+               G_draw.block_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), gb);
        }
 
-       DRW_uniformbuffer_update(globals_ubo, &ts);
+       DRW_uniformbuffer_update(G_draw.block_ubo, gb);
 
-       if (!globals_ramp) {
+       if (!G_draw.ramp) {
                ColorBand ramp = {0};
                float *colors;
                int col_size;
@@ -186,7 +185,7 @@ void DRW_globals_update(void)
 
                BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
 
-               globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
+               G_draw.ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
 
                MEM_freeN(colors);
        }
@@ -197,14 +196,14 @@ void DRW_globals_update(void)
        if (weight_ramp_custom != user_weight_ramp ||
            (user_weight_ramp && memcmp(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand)) != 0))
        {
-               DRW_TEXTURE_FREE_SAFE(globals_weight_ramp);
+               DRW_TEXTURE_FREE_SAFE(G_draw.weight_ramp);
        }
 
-       if (globals_weight_ramp == NULL) {
+       if (G_draw.weight_ramp == NULL) {
                weight_ramp_custom = user_weight_ramp;
                memcpy(&weight_ramp_copy, &U.coba_weight, sizeof(ColorBand));
 
-               globals_weight_ramp = DRW_create_weight_colorramp_texture();
+               G_draw.weight_ramp = DRW_create_weight_colorramp_texture();
        }
 }
 
@@ -914,27 +913,27 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color
 
        if (r_color != NULL) {
                if (UNLIKELY(ob->base_flag & BASE_FROM_SET)) {
-                       *r_color = ts.colorDupli;
+                       *r_color = G_draw.block.colorDupli;
                }
                else if (UNLIKELY(ob->base_flag & BASE_FROM_DUPLI)) {
                        switch (theme_id) {
                                case TH_ACTIVE:
-                               case TH_SELECT:       *r_color = ts.colorDupliSelect; break;
-                               case TH_TRANSFORM:    *r_color = ts.colorTransform; break;
-                               default:              *r_color = ts.colorDupli; break;
+                               case TH_SELECT:       *r_color = G_draw.block.colorDupliSelect; break;
+                               case TH_TRANSFORM:    *r_color = G_draw.block.colorTransform; break;
+                               default:              *r_color = G_draw.block.colorDupli; break;
                        }
                }
                else {
                        switch (theme_id) {
-                               case TH_WIRE_EDIT:    *r_color = ts.colorWireEdit; break;
-                               case TH_ACTIVE:       *r_color = ts.colorActive; break;
-                               case TH_SELECT:       *r_color = ts.colorSelect; break;
-                               case TH_TRANSFORM:    *r_color = ts.colorTransform; break;
-                               case TH_SPEAKER:      *r_color = ts.colorSpeaker; break;
-                               case TH_CAMERA:       *r_color = ts.colorCamera; break;
-                               case TH_EMPTY:        *r_color = ts.colorEmpty; break;
-                               case TH_LAMP:         *r_color = ts.colorLamp; break;
-                               default:              *r_color = ts.colorWire; break;
+                               case TH_WIRE_EDIT:    *r_color = G_draw.block.colorWireEdit; break;
+                               case TH_ACTIVE:       *r_color = G_draw.block.colorActive; break;
+                               case TH_SELECT:       *r_color = G_draw.block.colorSelect; break;
+                               case TH_TRANSFORM:    *r_color = G_draw.block.colorTransform; break;
+                               case TH_SPEAKER:      *r_color = G_draw.block.colorSpeaker; break;
+                               case TH_CAMERA:       *r_color = G_draw.block.colorCamera; break;
+                               case TH_EMPTY:        *r_color = G_draw.block.colorEmpty; break;
+                               case TH_LAMP:         *r_color = G_draw.block.colorLamp; break;
+                               default:              *r_color = G_draw.block.colorWire; break;
                        }
                }
        }
index 01cc4a0..fa2dac9 100644 (file)
@@ -204,4 +204,18 @@ void DRW_hair_free(void);
 bool DRW_pose_mode_armature(
     struct Object *ob, struct Object *active_ob);
 
+/* draw_common.c */
+struct DRW_Global {
+       /** If needed, contains all global/Theme colors
+        * Add needed theme colors / values to DRW_globals_update() and update UBO
+        * Not needed for constant color. */
+       GlobalsUboStorage block;
+       /** Define "globalsBlock" uniform for 'block'.  */
+       struct GPUUniformBuffer *block_ubo;
+
+       struct GPUTexture *ramp;
+       struct GPUTexture *weight_ramp;
+};
+extern struct DRW_Global G_draw;
+
 #endif /* __DRAW_COMMON_H__ */
index 871c42a..057daf2 100644 (file)
@@ -2591,9 +2591,6 @@ void DRW_engines_register(void)
 }
 
 extern struct GPUVertFormat *g_pos_format; /* draw_shgroup.c */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GPUTexture *globals_ramp; /* draw_common.c */
-extern struct GPUTexture *globals_weight_ramp; /* draw_common.c */
 void DRW_engines_free(void)
 {
        DRW_opengl_context_enable();
@@ -2616,10 +2613,10 @@ void DRW_engines_free(void)
                }
        }
 
-       DRW_UBO_FREE_SAFE(globals_ubo);
+       DRW_UBO_FREE_SAFE(G_draw.block_ubo);
        DRW_UBO_FREE_SAFE(view_ubo);
-       DRW_TEXTURE_FREE_SAFE(globals_ramp);
-       DRW_TEXTURE_FREE_SAFE(globals_weight_ramp);
+       DRW_TEXTURE_FREE_SAFE(G_draw.ramp);
+       DRW_TEXTURE_FREE_SAFE(G_draw.weight_ramp);
        MEM_SAFE_FREE(g_pos_format);
 
        MEM_SAFE_FREE(DST.RST.bound_texs);
index 02f2089..403702b 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "draw_mode_engines.h"
 
-extern GlobalsUboStorage ts;
+
 
 /* *********** LISTS *********** */
 typedef struct EDIT_ARMATURE_PassList {
index b3cb2cb..a9f42e0 100644 (file)
@@ -42,8 +42,6 @@
 /* If needed, contains all global/Theme colors
  * Add needed theme colors / values to DRW_globals_update() and update UBO
  * Not needed for constant color. */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
 
 extern char datatoc_common_globals_lib_glsl[];
 extern char datatoc_edit_curve_overlay_loosevert_vert_glsl[];
@@ -159,12 +157,12 @@ static void EDIT_CURVE_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WIRE);
 
                grp = DRW_shgroup_create(e_data.wire_sh, psl->wire_pass);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorWireEdit, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
                stl->g_data->wire_shgrp = grp;
 
 
                grp = DRW_shgroup_create(e_data.wire_normals_sh, psl->wire_pass);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorWireEdit, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
                DRW_shgroup_uniform_float_copy(grp, "normalSize", v3d->overlay.normals_length);
                stl->g_data->wire_normals_shgrp = grp;
 
@@ -173,7 +171,7 @@ static void EDIT_CURVE_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND);
 
                grp = DRW_shgroup_create(e_data.overlay_edge_sh, psl->overlay_edge_pass);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
                DRW_shgroup_uniform_bool(grp, "showCurveHandles", &stl->g_data->show_handles, 1);
                stl->g_data->overlay_edge_shgrp = grp;
@@ -184,7 +182,7 @@ static void EDIT_CURVE_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_POINT);
 
                grp = DRW_shgroup_create(e_data.overlay_vert_sh, psl->overlay_vert_pass);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                stl->g_data->overlay_vert_shgrp = grp;
        }
 }
index 1d4d4cd..4bfdf24 100644 (file)
 
 #include "draw_mode_engines.h"
 
-/* If needed, contains all global/Theme colors
- * Add needed theme colors / values to DRW_globals_update() and update UBO
- * Not needed for constant color. */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 extern char datatoc_common_globals_lib_glsl[];
 extern char datatoc_edit_lattice_overlay_loosevert_vert_glsl[];
 extern char datatoc_edit_lattice_overlay_frag_glsl[];
@@ -180,7 +174,7 @@ static void EDIT_LATTICE_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_POINT);
                stl->g_data->vert_shgrp = DRW_shgroup_create(e_data.overlay_vert_sh, psl->vert_pass);
 
-               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 }
 
index c31cd62..3f3316e 100644 (file)
 #include "BLI_dynstr.h"
 #include "BLI_string_utils.h"
 
-
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
-extern struct GPUTexture *globals_weight_ramp; /* draw_common.c */
-
 extern char datatoc_common_world_clip_lib_glsl[];
 
 extern char datatoc_paint_weight_vert_glsl[];
@@ -378,7 +372,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
 
        if ((tsettings->selectmode & SCE_SELECT_VERTEX) != 0) {
                *r_lverts_shgrp = DRW_shgroup_create(sh_data->overlay_lvert, pass);
-               DRW_shgroup_uniform_block(*r_lverts_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(*r_lverts_shgrp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_vec2(*r_lverts_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
                DRW_shgroup_uniform_float(*r_lverts_shgrp, "edgeScale", edge_width_scale, 1);
                DRW_shgroup_state_enable(*r_lverts_shgrp, DRW_STATE_WRITE_DEPTH);
@@ -388,7 +382,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
                }
 
                *r_verts_shgrp = DRW_shgroup_create(sh_data->overlay_vert, pass);
-               DRW_shgroup_uniform_block(*r_verts_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(*r_verts_shgrp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_vec2(*r_verts_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
                DRW_shgroup_uniform_float(*r_verts_shgrp, "edgeScale", edge_width_scale, 1);
                DRW_shgroup_state_enable(*r_verts_shgrp, DRW_STATE_WRITE_DEPTH);
@@ -400,7 +394,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
 
        if ((tsettings->selectmode & SCE_SELECT_FACE) != 0) {
                *r_facedot_shgrp = DRW_shgroup_create(sh_data->overlay_facedot, pass);
-               DRW_shgroup_uniform_block(*r_facedot_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(*r_facedot_shgrp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_float(*r_facedot_shgrp, "edgeScale", edge_width_scale, 1);
                DRW_shgroup_state_enable(*r_facedot_shgrp, DRW_STATE_WRITE_DEPTH);
                if (rv3d->rflag & RV3D_CLIPPING) {
@@ -409,7 +403,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
        }
 
        *r_face_shgrp = DRW_shgroup_create(tri_sh, pass);
-       DRW_shgroup_uniform_block(*r_face_shgrp, "globalsBlock", globals_ubo);
+       DRW_shgroup_uniform_block(*r_face_shgrp, "globalsBlock", G_draw.block_ubo);
        DRW_shgroup_uniform_vec2(*r_face_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
        DRW_shgroup_uniform_float(*r_face_shgrp, "faceAlphaMod", face_alpha, 1);
        DRW_shgroup_uniform_float(*r_face_shgrp, "edgeScale", edge_width_scale, 1);
@@ -431,7 +425,7 @@ static DRWPass *edit_mesh_create_overlay_pass(
        DRW_shgroup_state_enable(*r_face_cage_shgrp, DRW_STATE_OFFSET_NEGATIVE);
 
        *r_ledges_shgrp = DRW_shgroup_create(ledge_sh, pass);
-       DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", globals_ubo);
+       DRW_shgroup_uniform_block(*r_ledges_shgrp, "globalsBlock", G_draw.block_ubo);
        DRW_shgroup_uniform_vec2(*r_ledges_shgrp, "viewportSize", DRW_viewport_size_get(), 1);
        DRW_shgroup_uniform_float(*r_ledges_shgrp, "edgeScale", edge_width_scale, 1);
        DRW_shgroup_uniform_ivec4(*r_ledges_shgrp, "dataMask", data_mask, 1);
@@ -522,8 +516,8 @@ static void EDIT_MESH_cache_init(void *vedata)
 
                static float alpha = 1.0f;
                DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "opacity", &alpha, 1);
-               DRW_shgroup_uniform_texture(stl->g_data->fweights_shgrp, "colorramp", globals_weight_ramp);
-               DRW_shgroup_uniform_block(stl->g_data->fweights_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_texture(stl->g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp);
+               DRW_shgroup_uniform_block(stl->g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo);
                if (rv3d->rflag & RV3D_CLIPPING) {
                        DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->fweights_shgrp, rv3d);
                }
@@ -556,21 +550,21 @@ static void EDIT_MESH_cache_init(void *vedata)
 
                stl->g_data->fnormals_shgrp = DRW_shgroup_create(sh_data->normals_face, psl->normals);
                DRW_shgroup_uniform_float(stl->g_data->fnormals_shgrp, "normalSize", &size_normal, 1);
-               DRW_shgroup_uniform_vec4(stl->g_data->fnormals_shgrp, "color", ts.colorNormal, 1);
+               DRW_shgroup_uniform_vec4(stl->g_data->fnormals_shgrp, "color", G_draw.block.colorNormal, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
                        DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->fnormals_shgrp, rv3d);
                }
 
                stl->g_data->vnormals_shgrp = DRW_shgroup_create(sh_data->normals, psl->normals);
                DRW_shgroup_uniform_float(stl->g_data->vnormals_shgrp, "normalSize", &size_normal, 1);
-               DRW_shgroup_uniform_vec4(stl->g_data->vnormals_shgrp, "color", ts.colorVNormal, 1);
+               DRW_shgroup_uniform_vec4(stl->g_data->vnormals_shgrp, "color", G_draw.block.colorVNormal, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
                        DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->vnormals_shgrp, rv3d);
                }
 
                stl->g_data->lnormals_shgrp = DRW_shgroup_create(sh_data->normals_loop, psl->normals);
                DRW_shgroup_uniform_float(stl->g_data->lnormals_shgrp, "normalSize", &size_normal, 1);
-               DRW_shgroup_uniform_vec4(stl->g_data->lnormals_shgrp, "color", ts.colorLNormal, 1);
+               DRW_shgroup_uniform_vec4(stl->g_data->lnormals_shgrp, "color", G_draw.block.colorLNormal, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
                        DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->lnormals_shgrp, rv3d);
                }
@@ -605,7 +599,7 @@ static void EDIT_MESH_cache_init(void *vedata)
                        "Front Face Color",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND);
                stl->g_data->facefill_occluded_shgrp = DRW_shgroup_create(sh_data->overlay_facefill, psl->facefill_occlude);
-               DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_ivec4(stl->g_data->facefill_occluded_shgrp, "dataMask", stl->g_data->data_mask, 1);
                if (rv3d->rflag & RV3D_CLIPPING) {
                        DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->facefill_occluded_shgrp, rv3d);
index 912c30c..4901b0f 100644 (file)
 
 #include "draw_mode_engines.h"
 
-/* If needed, contains all global/Theme colors
- * Add needed theme colors / values to DRW_globals_update() and update UBO
- * Not needed for constant color. */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 /* *********** LISTS *********** */
 /* All lists are per viewport specific datas.
  * They are all free when viewport changes engines
index 40cbd87..de63ec8 100644 (file)
 
 #include "draw_mode_engines.h"
 
-/* If needed, contains all global/Theme colors
- * Add needed theme colors / values to DRW_globals_update() and update UBO
- * Not needed for constant color. */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 /* *********** LISTS *********** */
 /* All lists are per viewport specific datas.
  * They are all free when viewport changes engines
@@ -190,8 +184,8 @@ static void EDIT_TEXT_cache_init(void *vedata)
                psl->text_box_pass = DRW_pass_create(
                        "Font Text Boxes",
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH);
-               stl->g_data->box_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, ts.colorWire);
-               stl->g_data->box_active_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, ts.colorActive);
+               stl->g_data->box_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorWire);
+               stl->g_data->box_active_shgrp = shgroup_dynlines_dashed_uniform_color(psl->text_box_pass, G_draw.block.colorActive);
        }
 }
 
index 8644e02..e991661 100644 (file)
 
 #include "DEG_depsgraph_query.h"
 
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GPUTexture *globals_ramp; /* draw_common.c */
-extern GlobalsUboStorage ts;
-
 extern char datatoc_object_outline_prepass_vert_glsl[];
 extern char datatoc_object_outline_prepass_geom_glsl[];
 extern char datatoc_object_outline_prepass_frag_glsl[];
@@ -679,7 +675,7 @@ static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUSha
 {
        DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
        DRW_shgroup_uniform_vec4(grp, "color", col, 1);
-       DRW_shgroup_uniform_vec4(grp, "innerColor", ts.colorEditMeshMiddle, 1);
+       DRW_shgroup_uniform_vec4(grp, "innerColor", G_draw.block.colorEditMeshMiddle, 1);
 
        return grp;
 }
@@ -957,6 +953,7 @@ static void DRW_shgroup_empty_image(
 
 static void OBJECT_cache_init(void *vedata)
 {
+       const GlobalsUboStorage *gb = &G_draw.block;
        OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
        OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
        DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
@@ -1033,7 +1030,7 @@ static void OBJECT_cache_init(void *vedata)
                DRW_shgroup_uniform_texture_ref(grp, "outlineId", &e_data.outlines_id_tx);
                DRW_shgroup_uniform_texture_ref(grp, "outlineDepth", &e_data.outlines_depth_tx);
                DRW_shgroup_uniform_texture_ref(grp, "sceneDepth", &dtxl->depth);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_float_copy(grp, "alphaOcclu", alphaOcclu);
                DRW_shgroup_uniform_int(grp, "idOffsets", &stl->g_data->id_ofs_active, 4);
                DRW_shgroup_call_add(grp, quad, NULL);
@@ -1089,21 +1086,21 @@ static void OBJECT_cache_init(void *vedata)
                DRW_shgroup_uniform_float_copy(grp, "lineKernel", grid_line_size);
                DRW_shgroup_uniform_float_copy(grp, "meshSize", e_data.grid_mesh_size);
                DRW_shgroup_uniform_float(grp, "gridOneOverLogSubdiv", &e_data.grid_settings[4], 1);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
                DRW_shgroup_call_add(grp, geom, mat);
 
                grp = DRW_shgroup_create(e_data.grid_sh, psl->grid);
                DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.grid_flag, 1);
                DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.grid_axes, 1);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
                DRW_shgroup_call_add(grp, geom, mat);
 
                grp = DRW_shgroup_create(e_data.grid_sh, psl->grid);
                DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.zpos_flag, 1);
                DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.zplane_axes, 1);
-               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
                DRW_shgroup_call_add(grp, geom, mat);
        }
@@ -1252,23 +1249,23 @@ static void OBJECT_cache_init(void *vedata)
 
                /* Wires (for loose edges) */
                sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
-               sgl->wire = shgroup_wire(sgl->non_meshes, ts.colorWire, sh);
-               sgl->wire_select = shgroup_wire(sgl->non_meshes, ts.colorSelect, sh);
-               sgl->wire_transform = shgroup_wire(sgl->non_meshes, ts.colorTransform, sh);
-               sgl->wire_active = shgroup_wire(sgl->non_meshes, ts.colorActive, sh);
+               sgl->wire = shgroup_wire(sgl->non_meshes, gb->colorWire, sh);
+               sgl->wire_select = shgroup_wire(sgl->non_meshes, gb->colorSelect, sh);
+               sgl->wire_transform = shgroup_wire(sgl->non_meshes, gb->colorTransform, sh);
+               sgl->wire_active = shgroup_wire(sgl->non_meshes, gb->colorActive, sh);
                /* Wire (duplicator) */
-               sgl->wire_dupli = shgroup_wire(sgl->non_meshes, ts.colorDupli, sh);
-               sgl->wire_dupli_select = shgroup_wire(sgl->non_meshes, ts.colorDupliSelect, sh);
+               sgl->wire_dupli = shgroup_wire(sgl->non_meshes, gb->colorDupli, sh);
+               sgl->wire_dupli_select = shgroup_wire(sgl->non_meshes, gb->colorDupliSelect, sh);
 
                /* Points (loose points) */
                sh = e_data.loose_points_sh;
-               sgl->points = shgroup_points(sgl->non_meshes, ts.colorWire, sh);
-               sgl->points_select = shgroup_points(sgl->non_meshes, ts.colorSelect, sh);
-               sgl->points_transform = shgroup_points(sgl->non_meshes, ts.colorTransform, sh);
-               sgl->points_active = shgroup_points(sgl->non_meshes, ts.colorActive, sh);
+               sgl->points = shgroup_points(sgl->non_meshes, gb->colorWire, sh);
+               sgl->points_select = shgroup_points(sgl->non_meshes, gb->colorSelect, sh);
+               sgl->points_transform = shgroup_points(sgl->non_meshes, gb->colorTransform, sh);
+               sgl->points_active = shgroup_points(sgl->non_meshes, gb->colorActive, sh);
                /* Points (duplicator) */
-               sgl->points_dupli = shgroup_points(sgl->non_meshes, ts.colorDupli, sh);
-               sgl->points_dupli_select = shgroup_points(sgl->non_meshes, ts.colorDupliSelect, sh);
+               sgl->points_dupli = shgroup_points(sgl->non_meshes, gb->colorDupli, sh);
+               sgl->points_dupli_select = shgroup_points(sgl->non_meshes, gb->colorDupliSelect, sh);
                DRW_shgroup_state_disable(sgl->points, DRW_STATE_BLEND);
                DRW_shgroup_state_disable(sgl->points_select, DRW_STATE_BLEND);
                DRW_shgroup_state_disable(sgl->points_transform, DRW_STATE_BLEND);
@@ -1288,18 +1285,18 @@ static void OBJECT_cache_init(void *vedata)
                geom = DRW_cache_single_line_get();
                sgl->lamp_buflimit = shgroup_distance_lines_instance(sgl->non_meshes, geom);
 
-               sgl->lamp_center = shgroup_dynpoints_uniform_color(sgl->non_meshes, ts.colorLampNoAlpha, &ts.sizeLampCenter);
+               sgl->lamp_center = shgroup_dynpoints_uniform_color(sgl->non_meshes, gb->colorLampNoAlpha, &gb->sizeLampCenter);
 
                geom = DRW_cache_lamp_get();
-               sgl->lamp_circle = shgroup_instance_screenspace(sgl->non_meshes, geom, &ts.sizeLampCircle);
+               sgl->lamp_circle = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle);
                geom = DRW_cache_lamp_shadows_get();
-               sgl->lamp_circle_shadow = shgroup_instance_screenspace(sgl->non_meshes, geom, &ts.sizeLampCircleShadow);
+               sgl->lamp_circle_shadow = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircleShadow);
 
                geom = DRW_cache_lamp_sunrays_get();
-               sgl->lamp_sunrays = shgroup_instance_screenspace(sgl->non_meshes, geom, &ts.sizeLampCircle);
+               sgl->lamp_sunrays = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle);
 
-               sgl->lamp_groundline = shgroup_groundlines_uniform_color(sgl->non_meshes, ts.colorLamp);
-               sgl->lamp_groundpoint = shgroup_groundpoints_uniform_color(sgl->non_meshes, ts.colorLamp);
+               sgl->lamp_groundline = shgroup_groundlines_uniform_color(sgl->non_meshes, gb->colorLamp);
+               sgl->lamp_groundpoint = shgroup_groundpoints_uniform_color(sgl->non_meshes, gb->colorLamp);
 
                geom = DRW_cache_screenspace_circle_get();
                sgl->lamp_area_sphere = shgroup_instance_screen_aligned(sgl->non_meshes, geom);
@@ -1334,8 +1331,8 @@ static void OBJECT_cache_init(void *vedata)
                /* -------- STIPPLES ------- */
 
                /* Relationship Lines */
-               sgl->relationship_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, ts.colorWire);
-               sgl->constraint_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, ts.colorGridAxisZ);
+               sgl->relationship_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorWire);
+               sgl->constraint_lines = shgroup_dynlines_dashed_uniform_color(sgl->non_meshes, gb->colorGridAxisZ);
 
                /* Force Field Curve Guide End (here because of stipple) */
                /* TODO port to shader stipple */
@@ -1389,28 +1386,28 @@ static void OBJECT_cache_init(void *vedata)
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
                DRW_shgroup_uniform_float(grp, "size", &size, 1);
                DRW_shgroup_uniform_float(grp, "outlineWidth", &outlineWidth, 1);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorActive, 1);
-               DRW_shgroup_uniform_vec4(grp, "outlineColor", ts.colorOutline, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", gb->colorActive, 1);
+               DRW_shgroup_uniform_vec4(grp, "outlineColor", gb->colorOutline, 1);
                stl->g_data->center_active = grp;
 
                /* Select */
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorSelect, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", gb->colorSelect, 1);
                stl->g_data->center_selected = grp;
 
                /* Deselect */
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorDeselect, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", gb->colorDeselect, 1);
                stl->g_data->center_deselected = grp;
 
                /* Select (library) */
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorLibrarySelect, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", gb->colorLibrarySelect, 1);
                stl->g_data->center_selected_lib = grp;
 
                /* Deselect (library) */
                grp = DRW_shgroup_point_batch_create(sh, psl->ob_center);
-               DRW_shgroup_uniform_vec4(grp, "color", ts.colorLibrary, 1);
+               DRW_shgroup_uniform_vec4(grp, "color", gb->colorLibrary, 1);
                stl->g_data->center_deselected_lib = grp;
        }
 
@@ -2797,14 +2794,14 @@ static void OBJECT_cache_populate_particles(Object *ob,
                                        DRW_shgroup_uniform_vec3(shgrp, "outlineColor", ma ? &ma->specr : def_sec_col, 1);
                                        DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
                                        DRW_shgroup_uniform_float(shgrp, "size", &part->draw_size, 1);
-                                       DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
+                                       DRW_shgroup_uniform_texture(shgrp, "ramp", G_draw.ramp);
                                        DRW_shgroup_call_add(shgrp, geom, mat);
                                        break;
                                case PART_DRAW_CROSS:
                                        shgrp = DRW_shgroup_instance_create(
                                                e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS),
                                                e_data.particle_format);
-                                       DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
+                                       DRW_shgroup_uniform_texture(shgrp, "ramp", G_draw.ramp);
                                        DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
                                        DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
                                        break;
@@ -2812,7 +2809,7 @@ static void OBJECT_cache_populate_particles(Object *ob,
                                        shgrp = DRW_shgroup_instance_create(
                                                e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC),
                                                e_data.particle_format);
-                                       DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
+                                       DRW_shgroup_uniform_texture(shgrp, "ramp", G_draw.ramp);
                                        DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
                                        DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[1], 1);
                                        break;
index 41f31d0..d84c219 100644 (file)
@@ -91,8 +91,6 @@ extern char datatoc_overlay_face_wireframe_geom_glsl[];
 extern char datatoc_overlay_face_wireframe_frag_glsl[];
 extern char datatoc_gpu_shader_depth_only_frag_glsl[];
 
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 static int OVERLAY_sh_data_index_from_rv3d(const RegionView3D *rv3d)
 {
        if (rv3d->rflag & RV3D_CLIPPING) {
@@ -293,40 +291,40 @@ static void overlay_cache_populate(void *vedata, Object *ob)
                        const float *rim_col = NULL;
                        const float *wire_col = NULL;
                        if (UNLIKELY(ob->base_flag & BASE_FROM_SET)) {
-                               rim_col = ts.colorDupli;
-                               wire_col = ts.colorDupli;
+                               rim_col = G_draw.block.colorDupli;
+                               wire_col = G_draw.block.colorDupli;
                        }
                        else if (UNLIKELY(ob->base_flag & BASE_FROM_DUPLI)) {
                                if (ob->base_flag & BASE_SELECTED) {
                                        if (G.moving & G_TRANSFORM_OBJ) {
-                                               rim_col = ts.colorTransform;
+                                               rim_col = G_draw.block.colorTransform;
                                        }
                                        else {
-                                               rim_col = ts.colorDupliSelect;
+                                               rim_col = G_draw.block.colorDupliSelect;
                                        }
                                }
                                else {
-                                       rim_col = ts.colorDupli;
+                                       rim_col = G_draw.block.colorDupli;
                                }
-                               wire_col = ts.colorDupli;
+                               wire_col = G_draw.block.colorDupli;
                        }
                        else if ((ob->base_flag & BASE_SELECTED) &&
                                 (!is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage))
                        {
                                if (G.moving & G_TRANSFORM_OBJ) {
-                                       rim_col = ts.colorTransform;
+                                       rim_col = G_draw.block.colorTransform;
                                }
                                else if (ob == draw_ctx->obact) {
-                                       rim_col = ts.colorActive;
+                                       rim_col = G_draw.block.colorActive;
                                }
                                else {
-                                       rim_col = ts.colorSelect;
+                                       rim_col = G_draw.block.colorSelect;
                                }
-                               wire_col = ts.colorWire;
+                               wire_col = G_draw.block.colorWire;
                        }
                        else {
-                               rim_col = ts.colorWire;
-                               wire_col = ts.colorWire;
+                               rim_col = G_draw.block.colorWire;
+                               wire_col = G_draw.block.colorWire;
                        }
                        BLI_assert(rim_col && wire_col);
 
index 757b43b..726b620 100644 (file)
@@ -51,12 +51,6 @@ extern char datatoc_paint_face_vert_glsl[];
 
 extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
 
-/* If needed, contains all global/Theme colors
- * Add needed theme colors / values to DRW_globals_update() and update UBO
- * Not needed for constant color. */
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 /* *********** LISTS *********** */
 /* All lists are per viewport specific datas.
  * They are all free when viewport changes engines
@@ -209,7 +203,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
                                                DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
                                                DRW_shgroup_uniform_texture(grp, "image", tex);
                                                DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
-                                               DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+                                               DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                                                DRW_shgroup_uniform_bool_copy(grp, "nearestInterp", interp == SHD_INTERP_CLOSEST);
                                                stl->g_data->shgroup_image_array[i] = grp;
                                        }
@@ -227,7 +221,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
                                        DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
                                        DRW_shgroup_uniform_texture(grp, "image", tex);
                                        DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
-                                       DRW_shgroup_uniform_block(grp, "globalsBlock", globals_ubo);
+                                       DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
                                        DRW_shgroup_uniform_bool_copy(grp, "nearestInterp", imapaint->interp == IMAGEPAINT_INTERP_CLOSEST);
                                        stl->g_data->shgroup_image_array[0] = grp;
                                }
@@ -245,7 +239,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
 
                stl->g_data->lwire_shgrp = DRW_shgroup_create(e_data.wire_overlay_shader, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 
        {
index db3cd46..658631e 100644 (file)
@@ -38,9 +38,6 @@
 
 #include "DEG_depsgraph_query.h"
 
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
 extern char datatoc_paint_vertex_vert_glsl[];
 extern char datatoc_paint_vertex_frag_glsl[];
 extern char datatoc_paint_wire_vert_glsl[];
@@ -141,7 +138,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
 
                stl->g_data->lwire_shgrp = DRW_shgroup_create(e_data.wire_overlay_shader, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 
        {
@@ -161,7 +158,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
 
                stl->g_data->vert_shgrp = DRW_shgroup_create(e_data.vert_overlay_shader, psl->vert_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 }
 
index 0d6b2ed..87e832e 100644 (file)
 
 #include "DEG_depsgraph_query.h"
 
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-extern struct GlobalsUboStorage ts; /* draw_common.c */
-
-extern struct GPUTexture *globals_weight_ramp; /* draw_common.c */
-
 extern char datatoc_paint_face_vert_glsl[];
 extern char datatoc_paint_weight_vert_glsl[];
 extern char datatoc_paint_weight_frag_glsl[];
@@ -142,8 +137,8 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
                DRW_shgroup_uniform_bool_copy(stl->g_data->fweights_shgrp, "drawContours", (v3d->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0);
 
                DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "opacity", &v3d->overlay.weight_paint_mode_opacity, 1);
-               DRW_shgroup_uniform_texture(stl->g_data->fweights_shgrp, "colorramp", globals_weight_ramp);
-               DRW_shgroup_uniform_block(stl->g_data->fweights_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_texture(stl->g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp);
+               DRW_shgroup_uniform_block(stl->g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 
        {
@@ -152,7 +147,7 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
 
                stl->g_data->lwire_shgrp = DRW_shgroup_create(e_data.wire_overlay_shader, psl->wire_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->lwire_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 
        {
@@ -172,7 +167,7 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
                        DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_OFFSET_NEGATIVE);
 
                stl->g_data->vert_shgrp = DRW_shgroup_create(e_data.vert_overlay_shader, psl->vert_overlay);
-               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", globals_ubo);
+               DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", G_draw.block_ubo);
        }
 }
 
index 758218f..e861e02 100644 (file)
@@ -50,8 +50,6 @@ extern char datatoc_particle_strand_vert_glsl[];
 extern char datatoc_particle_strand_frag_glsl[];
 extern char datatoc_common_globals_lib_glsl[];
 
-extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
-
 /* *********** LISTS *********** */
 
 typedef struct PARTICLE_PassList {
@@ -147,9 +145,9 @@ static void particle_cache_init(void *vedata)
        stl->g_data->inner_points_group = DRW_shgroup_create(e_data.points_shader, psl->psys_edit_pass);
        stl->g_data->tip_points_group = DRW_shgroup_create(e_data.points_shader, psl->psys_edit_pass);
 
-       DRW_shgroup_uniform_block(stl->g_data->strands_group, "globalsBlock", globals_ubo);
-       DRW_shgroup_uniform_block(stl->g_data->inner_points_group, "globalsBlock", globals_ubo);
-       DRW_shgroup_uniform_block(stl->g_data->tip_points_group, "globalsBlock", globals_ubo);
+       DRW_shgroup_uniform_block(stl->g_data->strands_group, "globalsBlock", G_draw.block_ubo);
+       DRW_shgroup_uniform_block(stl->g_data->inner_points_group, "globalsBlock", G_draw.block_ubo);
+       DRW_shgroup_uniform_block(stl->g_data->tip_points_group, "globalsBlock", G_draw.block_ubo);
 }
 
 static void particle_edit_cache_populate(void *vedata,
index 6ee6f59..e092367 100644 (file)
@@ -37,7 +37,6 @@
 
 #include "draw_mode_engines.h"
 
-extern GlobalsUboStorage ts;
 
 /* *********** LISTS *********** */
 /* All lists are per viewport specific datas.