GPU: Fix assert when using light gizmo.

Blender was reporting that the GPU_TEXTURE_USAGE_HOST_READ wasn't set.
This is used to indicate that the textures needs to be read back to
CPU. Textures that don't need to be read back can be optimized by the
GPU backend.

Found during investigation of #104282.
This commit is contained in:
Jeroen Bakker 2023-02-09 08:36:27 +01:00
parent 1883e782cb
commit 8b35db914e
1 changed files with 7 additions and 2 deletions

View File

@ -155,8 +155,13 @@ static void gpu_viewport_textures_create(GPUViewport *viewport)
/* Can be shared with GPUOffscreen. */
if (viewport->depth_tx == NULL) {
viewport->depth_tx = GPU_texture_create_2d_ex(
"dtxl_depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, usage, NULL);
/* Depth texture can be read back by gizmos #view3d_depths_create .*/
viewport->depth_tx = GPU_texture_create_2d_ex("dtxl_depth",
UNPACK2(size),
1,
GPU_DEPTH24_STENCIL8,
usage | GPU_TEXTURE_USAGE_HOST_READ,
NULL);
if (GPU_clear_viewport_workaround()) {
static int depth_clear = 0;
GPU_texture_clear(viewport->depth_tx, GPU_DATA_UINT_24_8, &depth_clear);