From dbd7f36da8ec3ac1c2898aee346beecb86aac8a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Feb 2019 09:15:16 +1100 Subject: GPU: refactor clipped drawing from DRW into GPU Needed to fix T61196, supporting clipped back-buffer in the 3D view which is done outside the draw module. It was also inconvenient having DRW_shader_* versions of GPU_shader_* API calls. - Clipping distances are now supported as a shader configuration for builtin shaders. - Add shader config argument when accessing builtin shaders. - Move GPU_shader_create_from_arrays() from DRW to GPU. --- source/blender/draw/modes/edit_lattice_mode.c | 16 +- source/blender/draw/modes/edit_mesh_mode.c | 36 ++-- source/blender/draw/modes/object_mode.c | 207 ++++++++++----------- source/blender/draw/modes/overlay_mode.c | 18 +- source/blender/draw/modes/paint_vertex_mode.c | 18 +- source/blender/draw/modes/paint_weight_mode.c | 18 +- .../draw/modes/shaders/common_world_clip_lib.glsl | 25 --- 7 files changed, 155 insertions(+), 183 deletions(-) delete mode 100644 source/blender/draw/modes/shaders/common_world_clip_lib.glsl (limited to 'source/blender/draw/modes') diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 988a750f05f..4727049a0bc 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -30,9 +30,7 @@ #include "draw_common.h" -#include "draw_builtin_shader.h" - -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; extern char datatoc_common_globals_lib_glsl[]; extern char datatoc_edit_lattice_overlay_loosevert_vert_glsl[]; @@ -99,7 +97,7 @@ static struct { * init in EDIT_LATTICE_engine_init(); * free in EDIT_LATTICE_engine_free(); */ - EDIT_LATTICE_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + EDIT_LATTICE_Shaders sh_data[GPU_SHADER_CFG_LEN]; } e_data = {NULL}; /* Engine data */ @@ -139,20 +137,20 @@ static void EDIT_LATTICE_engine_init(void *vedata) */ const DRWContextState *draw_ctx = DRW_context_state_get(); - EDIT_LATTICE_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + EDIT_LATTICE_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; if (is_clip) { DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d); } - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; if (!sh_data->wire) { - sh_data->wire = DRW_shader_get_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR, draw_ctx->shader_slot); + sh_data->wire = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_SMOOTH_COLOR, draw_ctx->shader_cfg); } if (!sh_data->overlay_vert) { - sh_data->overlay_vert = DRW_shader_create_from_arrays({ + sh_data->overlay_vert = GPU_shader_create_from_arrays({ .vert = (const char *[]){ world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, @@ -177,7 +175,7 @@ static void EDIT_LATTICE_cache_init(void *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; - EDIT_LATTICE_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + EDIT_LATTICE_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; if (!stl->g_data) { /* Alloc transient pointers */ diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 368edb7d067..e5904aba192 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -43,7 +43,7 @@ #include "BLI_dynstr.h" #include "BLI_string_utils.h" -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; extern char datatoc_paint_weight_vert_glsl[]; extern char datatoc_paint_weight_frag_glsl[]; @@ -120,7 +120,7 @@ typedef struct EDIT_MESH_Shaders { /* *********** STATIC *********** */ static struct { - EDIT_MESH_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + EDIT_MESH_Shaders sh_data[GPU_SHADER_CFG_LEN]; /* temp buffer texture */ struct GPUTexture *occlude_wire_depth_tx; @@ -162,7 +162,7 @@ static void EDIT_MESH_engine_init(void *vedata) EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl; const DRWContextState *draw_ctx = DRW_context_state_get(); - EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; const float *viewport_size = DRW_viewport_size_get(); @@ -182,11 +182,11 @@ static void EDIT_MESH_engine_init(void *vedata) DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d); } - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; if (!sh_data->weight_face) { - sh_data->weight_face = DRW_shader_create_from_arrays({ + sh_data->weight_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_weight_vert_glsl, NULL}, .frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_paint_weight_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -199,40 +199,40 @@ static void EDIT_MESH_engine_init(void *vedata) geom_sh_code[0] = NULL; } const char *use_geom_def = use_geom_shader ? "#define USE_GEOM_SHADER\n" : ""; - sh_data->overlay_face = DRW_shader_create_from_arrays({ + sh_data->overlay_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define FACE\n", NULL}, }); - sh_data->overlay_edge = DRW_shader_create_from_arrays({ + sh_data->overlay_edge = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){lib, datatoc_edit_mesh_overlay_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, use_geom_def, "#define EDGE\n", NULL}, .geom = (use_geom_shader) ? geom_sh_code : NULL, }); - sh_data->overlay_edge_flat = DRW_shader_create_from_arrays({ + sh_data->overlay_edge_flat = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, use_geom_def, "#define EDGE\n", "#define FLAT\n", NULL}, .geom = (use_geom_shader) ? geom_sh_code : NULL, }); - sh_data->overlay_edge_deco = DRW_shader_create_from_arrays({ + sh_data->overlay_edge_deco = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, use_geom_def, "#define EDGE_DECORATION\n", "#define FLAT\n", NULL}, .geom = (use_geom_shader) ? geom_sh_code : NULL, }); - sh_data->overlay_vert = DRW_shader_create_from_arrays({ + sh_data->overlay_vert = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define VERT\n", NULL}, }); - sh_data->overlay_facedot = DRW_shader_create_from_arrays({ + sh_data->overlay_facedot = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define FACEDOT\n", NULL}, }); - sh_data->overlay_facefill = DRW_shader_create_from_arrays({ + sh_data->overlay_facefill = GPU_shader_create_from_arrays({ .vert = (const char *[]){lib, datatoc_edit_mesh_overlay_facefill_vert_glsl, NULL}, .frag = (const char *[]){lib, datatoc_edit_mesh_overlay_facefill_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -241,28 +241,28 @@ static void EDIT_MESH_engine_init(void *vedata) sh_data->overlay_mix = DRW_shader_create_fullscreen(datatoc_edit_mesh_overlay_mix_frag_glsl, NULL); - sh_data->normals_face = DRW_shader_create_from_arrays({ + sh_data->normals_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_geom_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define FACE_NORMALS\n", NULL}, }); - sh_data->normals_loop = DRW_shader_create_from_arrays({ + sh_data->normals_loop = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_geom_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define LOOP_NORMALS\n", NULL}, }); - sh_data->normals = DRW_shader_create_from_arrays({ + sh_data->normals = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_edit_normals_geom_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->depth = DRW_shader_create_3D_depth_only(draw_ctx->shader_slot); + sh_data->depth = DRW_shader_create_3D_depth_only(draw_ctx->shader_cfg); sh_data->ghost_clear_depth = DRW_shader_create_fullscreen(datatoc_gpu_shader_depth_only_frag_glsl, NULL); } @@ -278,7 +278,7 @@ static DRWPass *edit_mesh_create_overlay_pass( RegionView3D *rv3d = draw_ctx->rv3d; Scene *scene = draw_ctx->scene; ToolSettings *tsettings = scene->toolsettings; - EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool select_vert = (tsettings->selectmode & SCE_SELECT_VERTEX) != 0; const bool select_face = (tsettings->selectmode & SCE_SELECT_FACE) != 0; float winmat[4][4]; @@ -393,7 +393,7 @@ static void EDIT_MESH_cache_init(void *vedata) RegionView3D *rv3d = draw_ctx->rv3d; Scene *scene = draw_ctx->scene; ToolSettings *tsettings = scene->toolsettings; - EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + EDIT_MESH_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; static float zero = 0.0f; if (!stl->g_data) { diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index cf6c9e39028..95ff5982ee4 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -66,11 +66,10 @@ #include "draw_mode_engines.h" #include "draw_manager_text.h" #include "draw_common.h" -#include "draw_builtin_shader.h" #include "DEG_depsgraph_query.h" -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; extern char datatoc_object_outline_prepass_vert_glsl[]; extern char datatoc_object_outline_prepass_geom_glsl[]; extern char datatoc_object_outline_prepass_frag_glsl[]; @@ -317,7 +316,7 @@ static struct { struct GPUVertFormat *empty_image_format; struct GPUVertFormat *empty_image_wire_format; - OBJECT_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + OBJECT_Shaders sh_data[GPU_SHADER_CFG_LEN]; float camera_pos[3]; float grid_settings[5]; @@ -397,20 +396,20 @@ static void OBJECT_engine_init(void *vedata) /* Shaders */ const DRWContextState *draw_ctx = DRW_context_state_get(); - OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; if (!sh_data->outline_resolve) { /* Outline */ - sh_data->outline_prepass = DRW_shader_create_from_arrays({ + sh_data->outline_prepass = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL}, .frag = (const char *[]){datatoc_object_outline_prepass_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->outline_prepass_wire = DRW_shader_create_from_arrays({ + sh_data->outline_prepass_wire = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_object_outline_prepass_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_object_outline_prepass_geom_glsl, NULL}, .frag = (const char *[]){datatoc_object_outline_prepass_frag_glsl, NULL}, @@ -449,12 +448,12 @@ static void OBJECT_engine_init(void *vedata) "#define DEPTH_FRONT " STRINGIFY(OB_EMPTY_IMAGE_DEPTH_FRONT) "\n" "#define DEPTH_BACK " STRINGIFY(OB_EMPTY_IMAGE_DEPTH_BACK) "\n"); - sh_data->object_empty_image = DRW_shader_create_from_arrays({ + sh_data->object_empty_image = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_object_empty_image_vert_glsl, NULL}, .frag = (const char *[]){datatoc_object_empty_image_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, empty_image_defs, NULL}, }); - sh_data->object_empty_image_wire = DRW_shader_create_from_arrays({ + sh_data->object_empty_image_wire = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_object_empty_image_vert_glsl, NULL}, .frag = (const char *[]){datatoc_object_empty_image_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define USE_WIRE\n", empty_image_defs, NULL}, @@ -483,7 +482,7 @@ static void OBJECT_engine_init(void *vedata) datatoc_object_lightprobe_grid_vert_glsl, NULL, datatoc_gpu_shader_flat_id_frag_glsl, NULL); /* Loose Points */ - sh_data->loose_points = DRW_shader_create_from_arrays({ + sh_data->loose_points = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL}, .frag = (const char *[]){datatoc_object_loose_points_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -661,37 +660,37 @@ static void OBJECT_engine_free(void) } } -static DRWShadingGroup *shgroup_outline(DRWPass *pass, const int *ofs, GPUShader *sh, eDRW_ShaderSlot shader_slot) +static DRWShadingGroup *shgroup_outline(DRWPass *pass, const int *ofs, GPUShader *sh, eGPUShaderConfig shader_cfg) { DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); DRW_shgroup_uniform_int(grp, "baseId", ofs, 1); - if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } return grp; } /* currently same as 'shgroup_outline', new function to avoid confustion */ -static DRWShadingGroup *shgroup_wire(DRWPass *pass, const float col[4], GPUShader *sh, eDRW_ShaderSlot shader_slot) +static DRWShadingGroup *shgroup_wire(DRWPass *pass, const float col[4], GPUShader *sh, eGPUShaderConfig shader_cfg) { DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); DRW_shgroup_uniform_vec4(grp, "color", col, 1); - if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } return grp; } /* currently same as 'shgroup_outline', new function to avoid confustion */ -static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUShader *sh, eDRW_ShaderSlot shader_slot) +static DRWShadingGroup *shgroup_points(DRWPass *pass, const float col[4], GPUShader *sh, eGPUShaderConfig shader_cfg) { DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); DRW_shgroup_uniform_vec4(grp, "color", col, 1); DRW_shgroup_uniform_vec4(grp, "innerColor", G_draw.block.colorEditMeshMiddle, 1); - if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } return grp; @@ -914,7 +913,7 @@ static void image_calc_aspect(Image *ima, const int size[2], float r_image_aspec static void DRW_shgroup_empty_image( OBJECT_Shaders *sh_data, OBJECT_ShadingGroupList *sgl, - Object *ob, const float color[3], RegionView3D *rv3d, eDRW_ShaderSlot shader_slot) + Object *ob, const float color[3], RegionView3D *rv3d, eGPUShaderConfig shader_cfg) { /* TODO: 'StereoViews', see draw_empty_image. */ @@ -954,7 +953,7 @@ static void DRW_shgroup_empty_image( DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1); DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1); DRW_shgroup_uniform_vec4(grp, "objectColor", ob->col, 1); - if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } DRW_shgroup_call_add(grp, DRW_cache_image_plane_get(), ob->obmat); @@ -969,7 +968,7 @@ static void DRW_shgroup_empty_image( DRW_shgroup_uniform_float(grp, "size", &ob->empty_drawsize, 1); DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1); DRW_shgroup_uniform_vec3(grp, "color", color, 1); - if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } DRW_shgroup_call_add(grp, DRW_cache_image_plane_wire_get(), ob->obmat); @@ -984,7 +983,7 @@ static void OBJECT_cache_init(void *vedata) DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); OBJECT_PrivateData *g_data; const DRWContextState *draw_ctx = DRW_context_state_get(); - OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const float outline_width = UI_GetThemeValuef(TH_OUTLINE_WIDTH); const bool do_outline_expand = (U.pixelsize > 1.0) || (outline_width > 2.0f); @@ -1008,10 +1007,10 @@ static void OBJECT_cache_init(void *vedata) sh = sh_data->outline_prepass_wire; } - g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh, draw_ctx->shader_slot); - g_data->outlines_select_dupli = shgroup_outline(psl->outlines, &g_data->id_ofs_select_dupli, sh, draw_ctx->shader_slot); - g_data->outlines_transform = shgroup_outline(psl->outlines, &g_data->id_ofs_transform, sh, draw_ctx->shader_slot); - g_data->outlines_active = shgroup_outline(psl->outlines, &g_data->id_ofs_active, sh, draw_ctx->shader_slot); + g_data->outlines_select = shgroup_outline(psl->outlines, &g_data->id_ofs_select, sh, draw_ctx->shader_cfg); + g_data->outlines_select_dupli = shgroup_outline(psl->outlines, &g_data->id_ofs_select_dupli, sh, draw_ctx->shader_cfg); + g_data->outlines_transform = shgroup_outline(psl->outlines, &g_data->id_ofs_transform, sh, draw_ctx->shader_cfg); + g_data->outlines_active = shgroup_outline(psl->outlines, &g_data->id_ofs_active, sh, draw_ctx->shader_cfg); g_data->id_ofs_select = 0; g_data->id_ofs_select_dupli = 0; @@ -1169,129 +1168,129 @@ static void OBJECT_cache_init(void *vedata) /* Empties */ geom = DRW_cache_plain_axes_get(); - sgl->plain_axes = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->plain_axes = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_cube_get(); - sgl->cube = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->cube = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_circle_get(); - sgl->circle = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->circle = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_sphere_get(); - sgl->sphere = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->sphere = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_sphere_get(); sgl->sphere_solid = shgroup_instance_solid(sgl->non_meshes, geom); geom = DRW_cache_empty_cylinder_get(); - sgl->cylinder = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->cylinder = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_capsule_cap_get(); - sgl->capsule_cap = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->capsule_cap = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_capsule_body_get(); - sgl->capsule_body = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->capsule_body = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_cone_get(); - sgl->cone = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->cone = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_arrow_get(); - sgl->single_arrow = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->single_arrow = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_line_get(); - sgl->single_arrow_line = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->single_arrow_line = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_bone_arrows_get(); - sgl->empty_axes = shgroup_instance_empty_axes(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->empty_axes = shgroup_instance_empty_axes(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Force Field */ geom = DRW_cache_field_wind_get(); - sgl->field_wind = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_wind = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_field_force_get(); - sgl->field_force = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_force = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_field_vortex_get(); - sgl->field_vortex = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_vortex = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_screenspace_circle_get(); - sgl->field_curve_sta = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_curve_sta = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Grease Pencil */ geom = DRW_cache_gpencil_axes_get(); - sgl->gpencil_axes = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->gpencil_axes = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Speaker */ geom = DRW_cache_speaker_get(); - sgl->speaker = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->speaker = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Probe */ static float probeSize = 14.0f; geom = DRW_cache_lightprobe_cube_get(); - sgl->probe_cube = shgroup_instance_screenspace(sgl->non_meshes, geom, &probeSize, draw_ctx->shader_slot); + sgl->probe_cube = shgroup_instance_screenspace(sgl->non_meshes, geom, &probeSize, draw_ctx->shader_cfg); geom = DRW_cache_lightprobe_grid_get(); - sgl->probe_grid = shgroup_instance_screenspace(sgl->non_meshes, geom, &probeSize, draw_ctx->shader_slot); + sgl->probe_grid = shgroup_instance_screenspace(sgl->non_meshes, geom, &probeSize, draw_ctx->shader_cfg); static float probePlanarSize = 20.0f; geom = DRW_cache_lightprobe_planar_get(); - sgl->probe_planar = shgroup_instance_screenspace(sgl->non_meshes, geom, &probePlanarSize, draw_ctx->shader_slot); + sgl->probe_planar = shgroup_instance_screenspace(sgl->non_meshes, geom, &probePlanarSize, draw_ctx->shader_cfg); /* Camera */ geom = DRW_cache_camera_get(); - sgl->camera = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_camera_frame_get(); - sgl->camera_frame = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_frame = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_camera_tria_get(); - sgl->camera_tria = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_tria = shgroup_camera_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_plain_axes_get(); - sgl->camera_focus = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_focus = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_line_get(); - sgl->camera_clip = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); - sgl->camera_mist = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_clip = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); + sgl->camera_mist = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_line_endpoints_get(); - sgl->camera_clip_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); - sgl->camera_mist_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_clip_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); + sgl->camera_mist_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_quad_get(); - sgl->camera_stereo_plane = shgroup_instance_alpha(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_stereo_plane = shgroup_instance_alpha(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_cube_get(); - sgl->camera_stereo_volume = shgroup_instance_alpha(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_stereo_volume = shgroup_instance_alpha(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_empty_cube_get(); - sgl->camera_stereo_volume_wires = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->camera_stereo_volume_wires = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); BLI_listbase_clear(&sgl->camera_path); /* Texture Space */ geom = DRW_cache_empty_cube_get(); - sgl->texspace = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->texspace = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Wires (for loose edges) */ - sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR, draw_ctx->shader_slot); - sgl->wire = shgroup_wire(sgl->non_meshes, gb->colorWire, sh, draw_ctx->shader_slot); - sgl->wire_select = shgroup_wire(sgl->non_meshes, gb->colorSelect, sh, draw_ctx->shader_slot); - sgl->wire_transform = shgroup_wire(sgl->non_meshes, gb->colorTransform, sh, draw_ctx->shader_slot); - sgl->wire_active = shgroup_wire(sgl->non_meshes, gb->colorActive, sh, draw_ctx->shader_slot); + sh = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_UNIFORM_COLOR, draw_ctx->shader_cfg); + sgl->wire = shgroup_wire(sgl->non_meshes, gb->colorWire, sh, draw_ctx->shader_cfg); + sgl->wire_select = shgroup_wire(sgl->non_meshes, gb->colorSelect, sh, draw_ctx->shader_cfg); + sgl->wire_transform = shgroup_wire(sgl->non_meshes, gb->colorTransform, sh, draw_ctx->shader_cfg); + sgl->wire_active = shgroup_wire(sgl->non_meshes, gb->colorActive, sh, draw_ctx->shader_cfg); /* Wire (duplicator) */ - sgl->wire_dupli = shgroup_wire(sgl->non_meshes, gb->colorDupli, sh, draw_ctx->shader_slot); - sgl->wire_dupli_select = shgroup_wire(sgl->non_meshes, gb->colorDupliSelect, sh, draw_ctx->shader_slot); + sgl->wire_dupli = shgroup_wire(sgl->non_meshes, gb->colorDupli, sh, draw_ctx->shader_cfg); + sgl->wire_dupli_select = shgroup_wire(sgl->non_meshes, gb->colorDupliSelect, sh, draw_ctx->shader_cfg); /* Points (loose points) */ sh = sh_data->loose_points; - sgl->points = shgroup_points(sgl->non_meshes, gb->colorWire, sh, draw_ctx->shader_slot); - sgl->points_select = shgroup_points(sgl->non_meshes, gb->colorSelect, sh, draw_ctx->shader_slot); - sgl->points_transform = shgroup_points(sgl->non_meshes, gb->colorTransform, sh, draw_ctx->shader_slot); - sgl->points_active = shgroup_points(sgl->non_meshes, gb->colorActive, sh, draw_ctx->shader_slot); + sgl->points = shgroup_points(sgl->non_meshes, gb->colorWire, sh, draw_ctx->shader_cfg); + sgl->points_select = shgroup_points(sgl->non_meshes, gb->colorSelect, sh, draw_ctx->shader_cfg); + sgl->points_transform = shgroup_points(sgl->non_meshes, gb->colorTransform, sh, draw_ctx->shader_cfg); + sgl->points_active = shgroup_points(sgl->non_meshes, gb->colorActive, sh, draw_ctx->shader_cfg); /* Points (duplicator) */ - sgl->points_dupli = shgroup_points(sgl->non_meshes, gb->colorDupli, sh, draw_ctx->shader_slot); - sgl->points_dupli_select = shgroup_points(sgl->non_meshes, gb->colorDupliSelect, sh, draw_ctx->shader_slot); + sgl->points_dupli = shgroup_points(sgl->non_meshes, gb->colorDupli, sh, draw_ctx->shader_cfg); + sgl->points_dupli_select = shgroup_points(sgl->non_meshes, gb->colorDupliSelect, sh, draw_ctx->shader_cfg); 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); @@ -1309,50 +1308,50 @@ static void OBJECT_cache_init(void *vedata) /* start with buflimit because we don't want stipples */ geom = DRW_cache_single_line_get(); - sgl->lamp_buflimit = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_buflimit = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); - sgl->lamp_center = shgroup_dynpoints_uniform_color(sgl->non_meshes, gb->colorLampNoAlpha, &gb->sizeLampCenter, draw_ctx->shader_slot); + sgl->lamp_center = shgroup_dynpoints_uniform_color(sgl->non_meshes, gb->colorLampNoAlpha, &gb->sizeLampCenter, draw_ctx->shader_cfg); geom = DRW_cache_lamp_get(); - sgl->lamp_circle = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle, draw_ctx->shader_slot); + sgl->lamp_circle = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle, draw_ctx->shader_cfg); geom = DRW_cache_lamp_shadows_get(); - sgl->lamp_circle_shadow = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircleShadow, draw_ctx->shader_slot); + sgl->lamp_circle_shadow = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircleShadow, draw_ctx->shader_cfg); geom = DRW_cache_lamp_sunrays_get(); - sgl->lamp_sunrays = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle, draw_ctx->shader_slot); + sgl->lamp_sunrays = shgroup_instance_screenspace(sgl->non_meshes, geom, &gb->sizeLampCircle, draw_ctx->shader_cfg); - sgl->lamp_groundline = shgroup_groundlines_uniform_color(sgl->non_meshes, gb->colorLamp, draw_ctx->shader_slot); - sgl->lamp_groundpoint = shgroup_groundpoints_uniform_color(sgl->non_meshes, gb->colorLamp, draw_ctx->shader_slot); + sgl->lamp_groundline = shgroup_groundlines_uniform_color(sgl->non_meshes, gb->colorLamp, draw_ctx->shader_cfg); + sgl->lamp_groundpoint = shgroup_groundpoints_uniform_color(sgl->non_meshes, gb->colorLamp, draw_ctx->shader_cfg); geom = DRW_cache_screenspace_circle_get(); - sgl->lamp_area_sphere = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_area_sphere = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_area_square_get(); - sgl->lamp_area_square = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_area_square = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_area_disk_get(); - sgl->lamp_area_disk = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_area_disk = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_hemi_get(); - sgl->lamp_hemi = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_hemi = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_line_get(); - sgl->lamp_distance = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_distance = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_single_line_endpoints_get(); - sgl->lamp_buflimit_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_buflimit_points = shgroup_distance_lines_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_spot_get(); - sgl->lamp_spot_cone = shgroup_spot_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_cone = shgroup_spot_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_circle_get(); - sgl->lamp_spot_blend = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_blend = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_spot_square_get(); - sgl->lamp_spot_pyramid = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_pyramid = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); geom = DRW_cache_square_get(); - sgl->lamp_spot_blend_rect = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_blend_rect = shgroup_instance(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* -------- STIPPLES ------- */ @@ -1363,34 +1362,34 @@ static void OBJECT_cache_init(void *vedata) /* Force Field Curve Guide End (here because of stipple) */ /* TODO port to shader stipple */ geom = DRW_cache_screenspace_circle_get(); - sgl->field_curve_end = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_curve_end = shgroup_instance_screen_aligned(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Force Field Limits */ /* TODO port to shader stipple */ geom = DRW_cache_field_tube_limit_get(); - sgl->field_tube_limit = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_tube_limit = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* TODO port to shader stipple */ geom = DRW_cache_field_cone_limit_get(); - sgl->field_cone_limit = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_slot); + sgl->field_cone_limit = shgroup_instance_scaled(sgl->non_meshes, geom, draw_ctx->shader_cfg); /* Spot shapes */ state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND | DRW_STATE_CULL_FRONT; sgl->spot_shapes = psl->spot_shapes[i] = DRW_pass_create("Spot Shape Pass", state); geom = DRW_cache_lamp_spot_volume_get(); - sgl->lamp_spot_volume = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_volume = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_spot_square_volume_get(); - sgl->lamp_spot_volume_rect = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_volume_rect = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_cfg); geom = DRW_cache_lamp_spot_volume_get(); - sgl->lamp_spot_volume_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_volume_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_cfg); DRW_shgroup_state_disable(sgl->lamp_spot_volume_outside, DRW_STATE_CULL_FRONT); DRW_shgroup_state_enable(sgl->lamp_spot_volume_outside, DRW_STATE_CULL_BACK); geom = DRW_cache_lamp_spot_square_volume_get(); - sgl->lamp_spot_volume_rect_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_slot); + sgl->lamp_spot_volume_rect_outside = shgroup_instance_alpha(sgl->spot_shapes, geom, draw_ctx->shader_cfg); DRW_shgroup_state_disable(sgl->lamp_spot_volume_rect_outside, DRW_STATE_CULL_FRONT); DRW_shgroup_state_enable(sgl->lamp_spot_volume_rect_outside, DRW_STATE_CULL_BACK); } @@ -1406,8 +1405,8 @@ static void OBJECT_cache_init(void *vedata) outlineWidth = 1.0f * U.pixelsize; size = U.obcenter_dia * U.pixelsize + outlineWidth; - GPUShader *sh = DRW_shader_get_builtin_shader( - GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, draw_ctx->shader_slot); + GPUShader *sh = GPU_shader_get_builtin_shader_with_config( + GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, draw_ctx->shader_cfg); /* Active */ grp = DRW_shgroup_point_batch_create(sh, psl->ob_center); @@ -1415,7 +1414,7 @@ static void OBJECT_cache_init(void *vedata) DRW_shgroup_uniform_float(grp, "outlineWidth", &outlineWidth, 1); DRW_shgroup_uniform_vec4(grp, "color", gb->colorActive, 1); DRW_shgroup_uniform_vec4(grp, "outlineColor", gb->colorOutline, 1); - if (draw_ctx->shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (draw_ctx->shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d); } stl->g_data->center_active = grp; @@ -1423,7 +1422,7 @@ static void OBJECT_cache_init(void *vedata) /* Select */ grp = DRW_shgroup_point_batch_create(sh, psl->ob_center); DRW_shgroup_uniform_vec4(grp, "color", gb->colorSelect, 1); - if (draw_ctx->shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (draw_ctx->shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d); } stl->g_data->center_selected = grp; @@ -1431,7 +1430,7 @@ static void OBJECT_cache_init(void *vedata) /* Deselect */ grp = DRW_shgroup_point_batch_create(sh, psl->ob_center); DRW_shgroup_uniform_vec4(grp, "color", gb->colorDeselect, 1); - if (draw_ctx->shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (draw_ctx->shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d); } stl->g_data->center_deselected = grp; @@ -1439,7 +1438,7 @@ static void OBJECT_cache_init(void *vedata) /* Select (library) */ grp = DRW_shgroup_point_batch_create(sh, psl->ob_center); DRW_shgroup_uniform_vec4(grp, "color", gb->colorLibrarySelect, 1); - if (draw_ctx->shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (draw_ctx->shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d); } stl->g_data->center_selected_lib = grp; @@ -1447,7 +1446,7 @@ static void OBJECT_cache_init(void *vedata) /* Deselect (library) */ grp = DRW_shgroup_point_batch_create(sh, psl->ob_center); DRW_shgroup_uniform_vec4(grp, "color", gb->colorLibrary, 1); - if (draw_ctx->shader_slot == DRW_SHADER_SLOT_CLIPPED) { + if (draw_ctx->shader_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d); } stl->g_data->center_deselected_lib = grp; @@ -2120,7 +2119,7 @@ static void DRW_shgroup_empty_ex( static void DRW_shgroup_empty( OBJECT_Shaders *sh_data, OBJECT_ShadingGroupList *sgl, - Object *ob, ViewLayer *view_layer, RegionView3D *rv3d, eDRW_ShaderSlot shader_slot) + Object *ob, ViewLayer *view_layer, RegionView3D *rv3d, eGPUShaderConfig shader_cfg) { float *color; DRW_object_wire_theme_get(ob, view_layer, &color); @@ -2136,7 +2135,7 @@ static void DRW_shgroup_empty( DRW_shgroup_empty_ex(sgl, ob->obmat, &ob->empty_drawsize, ob->empty_drawtype, color); break; case OB_EMPTY_IMAGE: - DRW_shgroup_empty_image(sh_data, sgl, ob, color, rv3d, shader_slot); + DRW_shgroup_empty_image(sh_data, sgl, ob, color, rv3d, shader_cfg); break; } } @@ -2896,7 +2895,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) ModifierData *md = NULL; int theme_id = TH_UNDEFINED; const int ob_visibility = DRW_object_visibility_in_active_context(ob); - OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + OBJECT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; /* Handle particles first in case the emitter itself shouldn't be rendered. */ if (ob_visibility & OB_VISIBLE_PARTICLES) { @@ -3054,7 +3053,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - DRW_shgroup_empty(sh_data, sgl, ob, view_layer, rv3d, draw_ctx->shader_slot); + DRW_shgroup_empty(sh_data, sgl, ob, view_layer, rv3d, draw_ctx->shader_cfg); break; case OB_GPENCIL: if (hide_object_extra) { diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c index 243acc24fd3..dc022fbbcd7 100644 --- a/source/blender/draw/modes/overlay_mode.c +++ b/source/blender/draw/modes/overlay_mode.c @@ -71,10 +71,10 @@ typedef struct OVERLAY_Shaders { /* *********** STATIC *********** */ static struct { - OVERLAY_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + OVERLAY_Shaders sh_data[GPU_SHADER_CFG_LEN]; } e_data = {NULL}; -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; /* Shaders */ extern char datatoc_overlay_face_orientation_frag_glsl[]; @@ -92,7 +92,7 @@ static void overlay_engine_init(void *vedata) OVERLAY_StorageList *stl = data->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); - OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; if (is_clip) { @@ -105,12 +105,12 @@ static void overlay_engine_init(void *vedata) } stl->g_data->ghost_stencil_test = false; - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; if (!sh_data->face_orientation) { /* Face orientation */ - sh_data->face_orientation = DRW_shader_create_from_arrays({ + sh_data->face_orientation = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_orientation_vert_glsl, NULL}, .frag = (const char *[]){datatoc_overlay_face_orientation_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -118,18 +118,18 @@ static void overlay_engine_init(void *vedata) } if (!sh_data->face_wireframe) { - sh_data->select_wireframe = DRW_shader_create_from_arrays({ + sh_data->select_wireframe = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_wireframe_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_wireframe_geom_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_depth_only_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define SELECT_EDGES\n", NULL}, }); - sh_data->face_wireframe = DRW_shader_create_from_arrays({ + sh_data->face_wireframe = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_wireframe_vert_glsl, NULL}, .frag = (const char *[]){datatoc_overlay_face_wireframe_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->face_wireframe_sculpt = DRW_shader_create_from_arrays({ + sh_data->face_wireframe_sculpt = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_wireframe_vert_glsl, NULL}, .geom = (const char *[]){world_clip_lib_or_empty, datatoc_overlay_face_wireframe_geom_glsl, NULL}, .frag = (const char *[]){datatoc_overlay_face_wireframe_frag_glsl, NULL}, @@ -147,7 +147,7 @@ static void overlay_cache_init(void *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); RegionView3D *rv3d = draw_ctx->rv3d; - OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const DRWContextState *DCS = DRW_context_state_get(); diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index 95c9c4bf238..de59249af33 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -33,7 +33,7 @@ #include "DEG_depsgraph_query.h" -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; extern char datatoc_paint_vertex_vert_glsl[]; extern char datatoc_paint_vertex_frag_glsl[]; @@ -76,7 +76,7 @@ typedef struct PAINT_VERTEX_Shaders { /* *********** STATIC *********** */ static struct { - PAINT_VERTEX_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + PAINT_VERTEX_Shaders sh_data[GPU_SHADER_CFG_LEN]; } e_data = {{{NULL}}}; /* Engine data */ typedef struct PAINT_VERTEX_PrivateData { @@ -91,7 +91,7 @@ typedef struct PAINT_VERTEX_PrivateData { static void PAINT_VERTEX_engine_init(void *UNUSED(vedata)) { const DRWContextState *draw_ctx = DRW_context_state_get(); - PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; if (is_clip) { @@ -99,25 +99,25 @@ static void PAINT_VERTEX_engine_init(void *UNUSED(vedata)) } if (!sh_data->vcolor_face) { - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; - sh_data->vcolor_face = DRW_shader_create_from_arrays({ + sh_data->vcolor_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_paint_vertex_vert_glsl, NULL}, .frag = (const char *[]){datatoc_paint_vertex_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->wire_overlay = DRW_shader_create_from_arrays({ + sh_data->wire_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_wire_vert_glsl, NULL}, .frag = (const char *[]){datatoc_paint_wire_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define VERTEX_MODE\n", NULL}, }); - sh_data->face_overlay = DRW_shader_create_from_arrays({ + sh_data->face_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_paint_face_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->vert_overlay = DRW_shader_create_from_arrays({ + sh_data->vert_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_wire_vert_glsl, NULL}, .frag = (const char *[]){datatoc_paint_vert_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -132,7 +132,7 @@ static void PAINT_VERTEX_cache_init(void *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const View3D *v3d = draw_ctx->v3d; const RegionView3D *rv3d = draw_ctx->rv3d; - PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; if (!stl->g_data) { /* Alloc transient pointers */ diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index c8b8e088f37..ed457340ffc 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -32,7 +32,7 @@ #include "DEG_depsgraph_query.h" -extern char datatoc_common_world_clip_lib_glsl[]; +extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[]; extern char datatoc_paint_face_vert_glsl[]; extern char datatoc_paint_weight_vert_glsl[]; @@ -75,7 +75,7 @@ typedef struct PAINT_WEIGHT_Shaders { /* *********** STATIC *********** */ static struct { - PAINT_WEIGHT_Shaders sh_data[DRW_SHADER_SLOT_LEN]; + PAINT_WEIGHT_Shaders sh_data[GPU_SHADER_CFG_LEN]; int actdef; } e_data = {NULL}; /* Engine data */ @@ -92,7 +92,7 @@ typedef struct PAINT_WEIGHT_PrivateData { static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata)) { const DRWContextState *draw_ctx = DRW_context_state_get(); - PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; if (is_clip) { @@ -100,28 +100,28 @@ static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata)) } if (!sh_data->weight_face) { - const char *world_clip_lib_or_empty = is_clip ? datatoc_common_world_clip_lib_glsl : ""; + const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : ""; const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : ""; - sh_data->weight_face = DRW_shader_create_from_arrays({ + sh_data->weight_face = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_weight_vert_glsl, NULL}, .frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_paint_weight_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->wire_overlay = DRW_shader_create_from_arrays({ + sh_data->wire_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_wire_vert_glsl, NULL}, .frag = (const char *[]){datatoc_paint_wire_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, "#define WEIGHT_MODE\n", NULL}, }); - sh_data->face_overlay = DRW_shader_create_from_arrays({ + sh_data->face_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_paint_face_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, }); - sh_data->vert_overlay = DRW_shader_create_from_arrays({ + sh_data->vert_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_paint_wire_vert_glsl, NULL}, .frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_paint_vert_frag_glsl, NULL}, .defs = (const char *[]){world_clip_def_or_empty, NULL}, @@ -136,7 +136,7 @@ static void PAINT_WEIGHT_cache_init(void *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const View3D *v3d = draw_ctx->v3d; RegionView3D *rv3d = draw_ctx->rv3d; - PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; + PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_cfg]; if (!stl->g_data) { /* Alloc transient pointers */ diff --git a/source/blender/draw/modes/shaders/common_world_clip_lib.glsl b/source/blender/draw/modes/shaders/common_world_clip_lib.glsl deleted file mode 100644 index 6964b2a0c39..00000000000 --- a/source/blender/draw/modes/shaders/common_world_clip_lib.glsl +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef USE_WORLD_CLIP_PLANES -#if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_SHADER) -uniform vec4 WorldClipPlanes[6]; -void world_clip_planes_calc_clip_distance(vec3 wpos) -{ - gl_ClipDistance[0] = dot(WorldClipPlanes[0].xyz, wpos) + WorldClipPlanes[0].w; - gl_ClipDistance[1] = dot(WorldClipPlanes[1].xyz, wpos) + WorldClipPlanes[1].w; - gl_ClipDistance[2] = dot(WorldClipPlanes[2].xyz, wpos) + WorldClipPlanes[2].w; - gl_ClipDistance[3] = dot(WorldClipPlanes[3].xyz, wpos) + WorldClipPlanes[3].w; - gl_ClipDistance[4] = dot(WorldClipPlanes[4].xyz, wpos) + WorldClipPlanes[4].w; - gl_ClipDistance[5] = dot(WorldClipPlanes[5].xyz, wpos) + WorldClipPlanes[5].w; -} -#endif - -#define world_clip_planes_set_clip_distance(c) \ -{ \ - gl_ClipDistance[0] = (c)[0]; \ - gl_ClipDistance[1] = (c)[1]; \ - gl_ClipDistance[2] = (c)[2]; \ - gl_ClipDistance[3] = (c)[3]; \ - gl_ClipDistance[4] = (c)[4]; \ - gl_ClipDistance[5] = (c)[5]; \ -} - -#endif -- cgit v1.2.3