Fix T91981: Crash when using operators that needs scene depth

There was a double lock in the object depth drawing function.
Also the texture read was not reading the texture with the right
format. Now it needs a conversion.

Fix T91981 Particle Edit make Blender Crash
Fix T92006 Light spot interactively point can't use
This commit is contained in:
Clément Foucault 2021-10-12 14:43:41 +02:00
parent 6535779c92
commit 45f167237f
Notes: blender-bot 2023-02-14 07:30:31 +01:00
Referenced by issue #92134, checksum of builds are incorrect
Referenced by issue #92069, Draw curve over surface does not work
Referenced by issue #92006, Lighti spot interactively point can't use
Referenced by issue #91981, Particle Edit make Blender Crash
2 changed files with 7 additions and 3 deletions

View File

@ -2801,7 +2801,6 @@ void DRW_draw_depth_object(
GPU_framebuffer_restore();
GPU_framebuffer_free(depth_fb);
DRW_opengl_context_disable();
}
/** \} */

View File

@ -2297,8 +2297,13 @@ static ViewDepths *view3d_depths_create(ARegion *region)
{
GPUViewport *viewport = WM_draw_region_get_viewport(region);
GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport);
d->depths = GPU_texture_read(depth_tx, GPU_DATA_FLOAT, 0);
uint32_t *int_depths = GPU_texture_read(depth_tx, GPU_DATA_UINT_24_8, 0);
d->depths = (float *)int_depths;
/* Convert in-place. */
int pixel_count = GPU_texture_width(depth_tx) * GPU_texture_height(depth_tx);
for (int i = 0; i < pixel_count; i++) {
d->depths[i] = (int_depths[i] >> 8u) / (float)0xFFFFFF;
}
/* Assumed to be this as they are never changed. */
d->depth_range[0] = 0.0;
d->depth_range[1] = 1.0;