Cleanup: DRW: Move WorldClipPlanes to builtin uniform

This commit is contained in:
Clément Foucault 2019-05-26 20:36:24 +02:00
parent ba75e93c88
commit 577d3498b4
16 changed files with 72 additions and 79 deletions

View File

@ -94,7 +94,6 @@ static void basic_cache_init(void *vedata)
const DRWContextState *draw_ctx = DRW_context_state_get();
BASIC_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
const RegionView3D *rv3d = draw_ctx->rv3d;
if (!stl->g_data) {
/* Alloc transient pointers */
@ -106,7 +105,7 @@ static void basic_cache_init(void *vedata)
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
stl->g_data->depth_shgrp = DRW_shgroup_create(sh_data->depth, psl->depth_pass);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp, rv3d);
DRW_shgroup_state_enable(stl->g_data->depth_shgrp, DRW_STATE_CLIP_PLANES);
}
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull",
@ -114,7 +113,7 @@ static void basic_cache_init(void *vedata)
DRW_STATE_CULL_BACK);
stl->g_data->depth_shgrp_cull = DRW_shgroup_create(sh_data->depth, psl->depth_pass_cull);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp_cull, rv3d);
DRW_shgroup_state_enable(stl->g_data->depth_shgrp_cull, DRW_STATE_CLIP_PLANES);
}
}
}

View File

@ -212,7 +212,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
material->object_id = engine_object_data->object_id;
DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, draw_ctx->rv3d);
DRW_shgroup_state_enable(material->shgrp_object_outline, DRW_STATE_CLIP_PLANES);
}
BLI_ghash_insert(wpd->material_transp_hash, POINTER_FROM_UINT(hash), material);
}

View File

@ -316,7 +316,6 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd,
}
if (WORLD_CLIPPING_ENABLED(wpd)) {
DRW_shgroup_uniform_vec4(grp, "WorldClipPlanes", wpd->world_clip_planes[0], 6);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
}

View File

@ -306,13 +306,6 @@ void DRW_globals_free(void)
}
}
void DRW_shgroup_world_clip_planes_from_rv3d(DRWShadingGroup *shgrp, const RegionView3D *rv3d)
{
int world_clip_planes_len = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
DRW_shgroup_uniform_vec4(shgrp, "WorldClipPlanes", rv3d->clip[0], world_clip_planes_len);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
struct DRWCallBuffer *buffer_dynlines_flat_color(DRWPass *pass, eGPUShaderConfig sh_cfg)
{
GPUShader *sh = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_FLAT_COLOR, sh_cfg);
@ -325,7 +318,7 @@ struct DRWCallBuffer *buffer_dynlines_flat_color(DRWPass *pass, eGPUShaderConfig
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer(grp, g_formats.pos_color, GPU_PRIM_LINES);
}
@ -349,7 +342,7 @@ struct DRWCallBuffer *buffer_dynlines_dashed_uniform_color(DRWPass *pass,
DRW_shgroup_uniform_float(grp, "dash_factor", &dash_factor, 1);
DRW_shgroup_uniform_int_copy(grp, "colors_len", 0); /* "simple" mode */
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_LINES);
}
@ -372,7 +365,7 @@ struct DRWCallBuffer *buffer_groundlines_uniform_color(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
DRW_shgroup_uniform_vec4(grp, "color", color, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_POINTS);
}
@ -388,7 +381,7 @@ struct DRWCallBuffer *buffer_groundpoints_uniform_color(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
DRW_shgroup_uniform_vec4(grp, "color", color, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_POINTS);
}
@ -412,7 +405,7 @@ struct DRWCallBuffer *buffer_instance_screenspace(DRWPass *pass,
DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_screenspace, geom);
}
@ -467,7 +460,7 @@ struct DRWCallBuffer *buffer_instance_screen_aligned(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_screen_aligned, geom);
}
@ -488,7 +481,7 @@ struct DRWCallBuffer *buffer_instance_scaled(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_scaled, geom);
}
@ -510,7 +503,7 @@ struct DRWCallBuffer *buffer_instance(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
DRW_shgroup_state_disable(grp, DRW_STATE_BLEND);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
}
@ -551,7 +544,7 @@ struct DRWCallBuffer *buffer_instance_empty_axes(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->empty_axes_sh, pass);
DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
}
@ -591,7 +584,7 @@ struct DRWCallBuffer *buffer_camera_instance(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_camera, geom);
}
@ -615,7 +608,7 @@ struct DRWCallBuffer *buffer_distance_lines_instance(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
DRW_shgroup_uniform_float(grp, "size", &point_size, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_distance_lines, geom);
}
@ -640,7 +633,7 @@ struct DRWCallBuffer *buffer_spot_instance(DRWPass *pass,
DRW_shgroup_uniform_bool(grp, "drawBack", &False, 1);
DRW_shgroup_uniform_bool(grp, "drawSilhouette", &True, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_spot, geom);
}
@ -666,7 +659,7 @@ struct DRWCallBuffer *buffer_instance_bone_axes(DRWPass *pass, eGPUShaderConfig
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_axes, pass);
DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_color, DRW_cache_bone_arrows_get());
@ -696,7 +689,7 @@ struct DRWCallBuffer *buffer_instance_bone_envelope_outline(DRWPass *pass, eGPUS
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_envelope_outline, pass);
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone_envelope_outline, DRW_cache_bone_envelope_outline_get());
@ -725,7 +718,7 @@ struct DRWCallBuffer *buffer_instance_bone_envelope_distance(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_envelope_distance, pass);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone_envelope_distance, DRW_cache_bone_envelope_solid_get());
@ -761,7 +754,7 @@ struct DRWCallBuffer *buffer_instance_bone_envelope_solid(DRWPass *pass,
DRW_shgroup_state_enable(grp, DRW_STATE_CULL_BACK);
DRW_shgroup_uniform_float_copy(grp, "alpha", transp ? 0.6f : 1.0f);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone_envelope, DRW_cache_bone_envelope_solid_get());
@ -789,7 +782,7 @@ struct DRWCallBuffer *buffer_instance_mball_handles(DRWPass *pass, eGPUShaderCon
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->mball_handles, pass);
DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_mball_handles, DRW_cache_screenspace_circle_get());
@ -826,7 +819,7 @@ struct DRWCallBuffer *buffer_instance_bone_shape_outline(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->shape_outline, pass);
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_bone_outline, geom);
}
@ -859,7 +852,7 @@ struct DRWCallBuffer *buffer_instance_bone_shape_solid(DRWPass *pass,
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->shape_solid, pass);
DRW_shgroup_uniform_float_copy(grp, "alpha", transp ? 0.6f : 1.0f);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_bone, geom);
}
@ -889,7 +882,7 @@ struct DRWCallBuffer *buffer_instance_bone_sphere_solid(DRWPass *pass,
/* More transparent than the shape to be less distractive. */
DRW_shgroup_uniform_float_copy(grp, "alpha", transp ? 0.4f : 1.0f);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone, DRW_cache_bone_point_get());
@ -917,7 +910,7 @@ struct DRWCallBuffer *buffer_instance_bone_sphere_outline(DRWPass *pass, eGPUSha
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_sphere_outline, pass);
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone_outline, DRW_cache_bone_point_wire_outline_get());
@ -950,7 +943,7 @@ struct DRWCallBuffer *buffer_instance_bone_stick(DRWPass *pass, eGPUShaderConfig
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_float_copy(grp, "stickSize", 5.0f * U.pixelsize);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return DRW_shgroup_call_buffer_instance(
grp, g_formats.instance_bone_stick, DRW_cache_bone_stick_get());

View File

@ -123,9 +123,6 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
void DRW_globals_update(void);
void DRW_globals_free(void);
void DRW_shgroup_world_clip_planes_from_rv3d(struct DRWShadingGroup *shgrp,
const RegionView3D *rv3d);
/* TODO(fclem) ideally, most of the DRWCallBuffer functions shouldn't create a shgroup. */
struct DRWCallBuffer *buffer_dynlines_flat_color(struct DRWPass *pass, eGPUShaderConfig sh_cfg);
struct DRWCallBuffer *buffer_dynlines_dashed_uniform_color(struct DRWPass *pass,

View File

@ -2542,7 +2542,7 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
/** See #DRW_shgroup_world_clip_planes_from_rv3d. */
static void draw_world_clip_planes_from_rv3d(GPUBatch *batch, const float world_clip_planes[6][4])
{
GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes[0]);
GPU_batch_uniform_4fv_array(batch, "clipPlanes", 6, world_clip_planes[0]);
}
/**

View File

@ -876,6 +876,9 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, storage->wininv, 16, 1);
}
drw_shgroup_builtin_uniform(
shgroup, GPU_UNIFORM_CLIPPLANES, DST.view_storage_cpy.clipplanes, 4, 6);
/* Not supported. */
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV) == -1);
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW) == -1);

View File

@ -168,7 +168,7 @@ static void EDIT_CURVE_wire_shgrp_create(EDIT_CURVE_Shaders *sh_data,
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->wire_sh, pass);
DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
*wire_shgrp = grp;
@ -176,7 +176,7 @@ static void EDIT_CURVE_wire_shgrp_create(EDIT_CURVE_Shaders *sh_data,
DRW_shgroup_uniform_vec4(grp, "color", G_draw.block.colorWireEdit, 1);
DRW_shgroup_uniform_float_copy(grp, "normalSize", v3d->overlay.normals_length);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
*wire_normals_shgrp = grp;
}
@ -229,7 +229,7 @@ static void EDIT_CURVE_cache_init(void *vedata)
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_bool(grp, "showCurveHandles", &stl->g_data->show_handles, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
stl->g_data->overlay_edge_shgrp = grp;
@ -238,7 +238,7 @@ static void EDIT_CURVE_cache_init(void *vedata)
grp = DRW_shgroup_create(sh_data->overlay_vert_sh, psl->overlay_vert_pass);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
stl->g_data->overlay_vert_shgrp = grp;
}

View File

@ -184,7 +184,7 @@ static void EDIT_LATTICE_cache_init(void *vedata)
DRW_STATE_DEPTH_LESS_EQUAL);
stl->g_data->wire_shgrp = DRW_shgroup_create(sh_data->wire, psl->wire_pass);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->wire_shgrp, rv3d);
DRW_shgroup_state_enable(stl->g_data->wire_shgrp, DRW_STATE_CLIP_PLANES);
}
psl->vert_pass = DRW_pass_create("Lattice Verts",
@ -192,7 +192,7 @@ static void EDIT_LATTICE_cache_init(void *vedata)
stl->g_data->vert_shgrp = DRW_shgroup_create(sh_data->overlay_vert, psl->vert_pass);
DRW_shgroup_uniform_block(stl->g_data->vert_shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->vert_shgrp, rv3d);
DRW_shgroup_state_enable(stl->g_data->vert_shgrp, DRW_STATE_CLIP_PLANES);
}
}
}

View File

@ -368,7 +368,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha,
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
/* Cage geom needs to be offseted to avoid Z-fighting. */
@ -379,7 +379,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha,
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
/* Edges */
@ -393,7 +393,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha,
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
DRW_shgroup_uniform_bool_copy(grp, "selectEdges", do_edges || select_edge);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
/* Verts */
@ -404,7 +404,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha,
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
}
if (select_face) {
@ -412,7 +412,7 @@ static void edit_mesh_create_overlay_passes(float face_alpha,
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
}
}
@ -493,7 +493,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_texture(g_data->fweights_shgrp, "colorramp", G_draw.weight_ramp);
DRW_shgroup_uniform_block(g_data->fweights_shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->fweights_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->fweights_shgrp, DRW_STATE_CLIP_PLANES);
}
}
@ -504,7 +504,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_STATE_CULL_BACK);
g_data->depth_shgrp_hidden_wire = DRW_shgroup_create(sh_data->depth, psl->depth_hidden_wire);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->depth_shgrp_hidden_wire, rv3d);
DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire, DRW_STATE_CLIP_PLANES);
}
psl->depth_hidden_wire_in_front = DRW_pass_create(
@ -513,7 +513,7 @@ static void EDIT_MESH_cache_init(void *vedata)
g_data->depth_shgrp_hidden_wire_in_front = DRW_shgroup_create(sh_data->depth,
psl->depth_hidden_wire_in_front);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->depth_shgrp_hidden_wire_in_front, rv3d);
DRW_shgroup_state_enable(g_data->depth_shgrp_hidden_wire_in_front, DRW_STATE_CLIP_PLANES);
}
}
@ -527,21 +527,21 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_float(g_data->fnormals_shgrp, "normalSize", &size_normal, 1);
DRW_shgroup_uniform_vec4(g_data->fnormals_shgrp, "color", G_draw.block.colorNormal, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->fnormals_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->fnormals_shgrp, DRW_STATE_CLIP_PLANES);
}
g_data->vnormals_shgrp = DRW_shgroup_create(sh_data->normals, psl->normals);
DRW_shgroup_uniform_float(g_data->vnormals_shgrp, "normalSize", &size_normal, 1);
DRW_shgroup_uniform_vec4(g_data->vnormals_shgrp, "color", G_draw.block.colorVNormal, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->vnormals_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->vnormals_shgrp, DRW_STATE_CLIP_PLANES);
}
g_data->lnormals_shgrp = DRW_shgroup_create(sh_data->normals_loop, psl->normals);
DRW_shgroup_uniform_float(g_data->lnormals_shgrp, "normalSize", &size_normal, 1);
DRW_shgroup_uniform_vec4(g_data->lnormals_shgrp, "color", G_draw.block.colorLNormal, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->lnormals_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->lnormals_shgrp, DRW_STATE_CLIP_PLANES);
}
}
@ -554,7 +554,7 @@ static void EDIT_MESH_cache_init(void *vedata)
is_vertex_color ? sh_data->mesh_analysis_vertex : sh_data->mesh_analysis_face,
psl->mesh_analysis_pass);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->mesh_analysis_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->mesh_analysis_shgrp, DRW_STATE_CLIP_PLANES);
}
}
/* For in front option */
@ -597,7 +597,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
shgrp = g_data->facefill_occluded_cage_shgrp = DRW_shgroup_create(
@ -605,7 +605,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_ivec4(shgrp, "dataMask", g_data->data_mask, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
}
else {

View File

@ -708,7 +708,7 @@ static DRWShadingGroup *shgroup_outline(DRWPass *pass,
DRW_shgroup_uniform_int(grp, "baseId", ofs, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return grp;
}
@ -723,7 +723,7 @@ static DRWShadingGroup *shgroup_wire(DRWPass *pass,
DRW_shgroup_uniform_vec4(grp, "color", col, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return grp;
}
@ -739,7 +739,7 @@ static DRWShadingGroup *shgroup_points(DRWPass *pass,
DRW_shgroup_uniform_vec4(grp, "innerColor", G_draw.block.colorEditMeshMiddle, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
return grp;
}
@ -1016,7 +1016,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_vec2(grp, "offset", ob->ima_ofs, 1);
DRW_shgroup_uniform_vec3(grp, "color", color, 1);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
DRW_shgroup_call(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
}
@ -1036,7 +1036,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
DRW_shgroup_uniform_vec4(grp, "objectColor", ob->color, 1);
DRW_shgroup_uniform_bool_copy(grp, "useAlphaTest", !use_alpha_blend);
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
DRW_shgroup_call(grp, DRW_cache_image_plane_get(), ob->obmat);
}
@ -1404,7 +1404,7 @@ static void OBJECT_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(grp, "color", gb->colorLightNoAlpha, 1);
DRW_shgroup_uniform_float(grp, "size", &gb->sizeLightCenter, 1);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
sgl->light_center = buffer_dynpoints_uniform_color(grp);
@ -1492,7 +1492,7 @@ static void OBJECT_cache_init(void *vedata)
DRWShadingGroup *grp_transp = DRW_shgroup_create(sh, sgl->transp_shapes);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp_transp, DRW_context_state_get()->rv3d);
DRW_shgroup_state_enable(grp_transp, DRW_STATE_CLIP_PLANES);
}
DRWShadingGroup *grp_cull_back = DRW_shgroup_create_sub(grp_transp);
@ -1544,7 +1544,7 @@ static void OBJECT_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(grp, "color", gb->colorActive, 1);
DRW_shgroup_uniform_vec4(grp, "outlineColor", gb->colorOutline, 1);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, draw_ctx->rv3d);
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
}
/* TODO find better name. */
stl->g_data->center_active = buffer_dynpoints_uniform_color(grp);

View File

@ -210,7 +210,7 @@ static void overlay_cache_init(void *vedata)
g_data->face_orientation_shgrp = DRW_shgroup_create(sh_data->face_orientation,
psl->face_orientation_pass);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->face_orientation_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->face_orientation_shgrp, DRW_STATE_CLIP_PLANES);
}
}
@ -246,7 +246,7 @@ static void overlay_cache_init(void *vedata)
g_data->face_wires_shgrp, "viewportSizeInv", DRW_viewport_invert_size_get(), 1);
}
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(g_data->face_wires_shgrp, rv3d);
DRW_shgroup_state_enable(g_data->face_wires_shgrp, DRW_STATE_CLIP_PLANES);
}
g_data->wire_step_param = stl->g_data->overlay.wireframe_threshold - 254.0f / 255.0f;

View File

@ -248,7 +248,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(shgrp, "color", color, 1);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, draw_ctx->rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->image_faces = pass;
stl->g_data->shgroup_fallback = shgrp;
@ -308,7 +308,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, draw_ctx->rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->wire_select_overlay = pass;
stl->g_data->lwire_select_shgrp = shgrp;
@ -323,7 +323,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(shgrp, "color", col, 1);
if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, draw_ctx->rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->face_select_overlay = pass;
stl->g_data->face_select_shgrp = shgrp;

View File

@ -203,7 +203,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRW_shgroup_uniform_float_copy(
shgrp, "white_factor", 1.0f - v3d->overlay.vertex_paint_mode_opacity);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->by_mode[VERTEX_MODE].color_faces = pass;
stl->g_data->by_mode[VERTEX_MODE].color_shgrp = shgrp;
@ -220,7 +220,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRW_shgroup_uniform_texture(shgrp, "colorramp", G_draw.weight_ramp);
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->by_mode[WEIGHT_MODE].color_faces = pass;
stl->g_data->by_mode[WEIGHT_MODE].color_shgrp = shgrp;
@ -233,7 +233,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->by_mode[i].wire_overlay, pass);
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
stl->g_data->by_mode[i].lwire_shgrp = shgrp;
}
@ -248,7 +248,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->by_mode[i].wire_select_overlay, pass);
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
stl->g_data->by_mode[i].lwire_select_shgrp = shgrp;
}
@ -263,7 +263,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->face_select_overlay, pass);
DRW_shgroup_uniform_vec4(shgrp, "color", col, 1);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->face_select_overlay = pass;
stl->g_data->face_select_shgrp = shgrp;
@ -276,7 +276,7 @@ static void PAINT_VERTEX_cache_init(void *vedata)
DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->vert_select_overlay, pass);
DRW_shgroup_uniform_block(shgrp, "globalsBlock", G_draw.block_ubo);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(shgrp, rv3d);
DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
}
psl->vert_select_overlay = pass;
stl->g_data->vert_select_shgrp = shgrp;

View File

@ -44,8 +44,9 @@ typedef enum {
GPU_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */
GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
GPU_UNIFORM_CLIPPLANES, /* vec4 WorldClipPlanes[] */
GPU_UNIFORM_COLOR, /* vec4 color */
GPU_UNIFORM_CALLID, /* int callId */

View File

@ -62,6 +62,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u)
[GPU_UNIFORM_NORMAL] = "NormalMatrix",
[GPU_UNIFORM_ORCO] = "OrcoTexCoFactors",
[GPU_UNIFORM_CLIPPLANES] = "WorldClipPlanes",
[GPU_UNIFORM_COLOR] = "color",
[GPU_UNIFORM_CALLID] = "callId",