EEVEE-Next: DoF: Avoid out of bound access in scatter vertex shader
As noted in the comment, it is very unlikely to happen. But since we can run into undefined behavior if it does better make the access safe.
This commit is contained in:
@@ -400,6 +400,7 @@ void DepthOfField::scatter_pass_sync()
|
||||
drw_pass.init();
|
||||
drw_pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD_FULL);
|
||||
drw_pass.shader_set(inst_.shaders.static_shader_get(DOF_SCATTER));
|
||||
drw_pass.bind_ubo("dof_buf", data_);
|
||||
drw_pass.push_constant("use_bokeh_lut", use_bokeh_lut_);
|
||||
drw_pass.bind_texture("bokeh_lut_tx", &bokeh_scatter_lut_tx_);
|
||||
drw_pass.bind_texture("occlusion_tx", &occlusion_tx_);
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
if (gl_InstanceID >= dof_buf.scatter_max_rect) {
|
||||
/* Very unlikely to happen but better avoid out of bound access. */
|
||||
gl_Position = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
ScatterRect rect = scatter_list_buf[gl_InstanceID];
|
||||
|
||||
interp_flat.color_and_coc1 = rect.color_and_coc[0];
|
||||
|
||||
@@ -212,6 +212,7 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter)
|
||||
.additional_info("eevee_shared", "draw_view")
|
||||
.sampler(0, ImageType::FLOAT_2D, "occlusion_tx")
|
||||
.sampler(1, ImageType::FLOAT_2D, "bokeh_lut_tx")
|
||||
.uniform_buf(6, "DepthOfFieldData", "dof_buf")
|
||||
.storage_buf(0, Qualifier::READ, "ScatterRect", "scatter_list_buf[]")
|
||||
.fragment_out(0, Type::VEC4, "out_color")
|
||||
.push_constant(Type::BOOL, "use_bokeh_lut")
|
||||
|
||||
Reference in New Issue
Block a user