diff options
author | Jason Fielder <jason_apple> | 2022-04-27 14:00:36 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-27 14:00:51 +0300 |
commit | db622b5a0bea32cb3a78c0a4c7d4372a9178d27e (patch) | |
tree | b00c3b497d694929ef3d342fb0973ee9a27bc3e0 /source/blender/draw/engines/overlay | |
parent | cdd4354c81f6f9ae3bc72b7abd5dbcfd74fa548e (diff) |
Metal: GLSL Compatibility - Hosting default uniform values.
There are a number of shaders, most notably grid_frag.glsl, which rely on default assignments to uniform values within shaders. This is not currently supported by the shader uniform push model implemented for the Metal backend, wherein uniform updates are pushed as a singular block of data. Any default assignment would become over-written.
As such, adding assignments of these default values in the high-level, to ensure the correct value is written for all APIs. This likely impacts Vulkan push-constants as well.
Authored by Apple: Michael Parkin-White
Ref T96261
Reviewed By: fclem
Maniphest Tasks: T96261
Differential Revision: https://developer.blender.org/D14555
Diffstat (limited to 'source/blender/draw/engines/overlay')
4 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.c index e0671eac156..4d65cbc04ff 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.c @@ -179,10 +179,9 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) /* Verts */ state |= DRW_STATE_WRITE_DEPTH; DRW_PASS_CREATE(psl->edit_mesh_verts_ps[i], state | pd->clipping_state); + int vert_mask[4] = {0xFF, 0xFF, 0xFF, 0xFF}; if (select_vert) { - int vert_mask[4] = {0xFF, 0xFF, 0xFF, 0xFF}; - sh = OVERLAY_shader_edit_mesh_vert(); grp = pd->edit_mesh_verts_grp[i] = DRW_shgroup_create(sh, psl->edit_mesh_verts_ps[i]); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); @@ -201,6 +200,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity); DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex); + DRW_shgroup_uniform_ivec4_copy(grp, "dataMask", vert_mask); DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH); } else { diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c index ed6db459696..2d74bd53528 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.c @@ -226,6 +226,9 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) GPUShader *sh; struct GPUBatch *geom = DRW_cache_grid_get(); + const float line_zero = 0; + const float grid_steps_default[8] = {0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0}; + if (pd->space_type == SPACE_IMAGE) { float mat[4][4]; @@ -254,6 +257,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "gridSize", shd->grid_size, 1); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); + DRW_shgroup_uniform_float(grp, "gridSteps", grid_steps_default, 8); if (shd->zneg_flag & SHOW_AXIS_Z) { DRW_shgroup_call(grp, geom, NULL); } @@ -264,6 +268,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "planeAxes", shd->grid_axes, 1); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); + DRW_shgroup_uniform_float_copy(grp, "lineKernel", line_zero); DRW_shgroup_uniform_float(grp, "gridSteps", shd->grid_steps, ARRAY_SIZE(shd->grid_steps)); if (shd->grid_flag) { DRW_shgroup_call(grp, geom, NULL); @@ -274,6 +279,8 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "planeAxes", shd->zplane_axes, 1); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); + DRW_shgroup_uniform_float_copy(grp, "lineKernel", line_zero); + DRW_shgroup_uniform_float(grp, "gridSteps", grid_steps_default, 8); if (shd->zpos_flag & SHOW_AXIS_Z) { DRW_shgroup_call(grp, geom, NULL); } diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c index 8010319e3fa..47d9d19cad2 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.c +++ b/source/blender/draw/engines/overlay/overlay_outline.c @@ -132,6 +132,7 @@ void OVERLAY_outline_cache_init(OVERLAY_Data *vedata) pd->outlines_gpencil_grp = grp = DRW_shgroup_create(sh_gpencil, psl->outlines_prepass_ps); DRW_shgroup_uniform_bool_copy(grp, "isTransform", (G.moving & G_TRANSFORM_OBJ) != 0); + DRW_shgroup_uniform_float_copy(grp, "strokeIndexOffset", 0.0); } /* outlines_prepass_ps is still needed for selection of probes. */ diff --git a/source/blender/draw/engines/overlay/shaders/grid_frag.glsl b/source/blender/draw/engines/overlay/shaders/grid_frag.glsl index 4a9b8d15528..f1fcc3ad8fa 100644 --- a/source/blender/draw/engines/overlay/shaders/grid_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/grid_frag.glsl @@ -18,7 +18,7 @@ uniform int gridFlag; uniform float zoomFactor; #define STEPS_LEN 8 /* Match: #SI_GRID_STEPS_LEN */ -uniform float gridSteps[STEPS_LEN] = float[](0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0); +uniform float gridSteps[STEPS_LEN]; #define AXIS_X (1 << 0) #define AXIS_Y (1 << 1) |