Revert "Fix crash when the animation player fails to create a texture"

This reverts commit 34899ec13d.
This commit is contained in:
Campbell Barton 2023-10-23 10:58:56 +11:00
parent 14247f9194
commit dcc6a9d73b
1 changed files with 45 additions and 60 deletions

View File

@ -571,27 +571,24 @@ static void draw_display_buffer(const PlayDisplayContext *display_ctx,
const rctf *canvas,
const bool draw_flip[2])
{
void *display_buffer;
/* Format needs to be created prior to any #immBindShader call.
* Do it here because OCIO binds its own shader. */
eGPUTextureFormat format;
eGPUDataFormat data;
bool glsl_used = false;
GPUVertFormat *imm_format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
uint texCoord = GPU_vertformat_attr_add(
imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
void *buffer_cache_handle = nullptr;
void *display_buffer = ocio_transform_ibuf(
display_buffer = ocio_transform_ibuf(
display_ctx, ibuf, &glsl_used, &format, &data, &buffer_cache_handle);
GPUTexture *texture = GPU_texture_create_2d(
"display_buf", ibuf->x, ibuf->y, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
/* NOTE: This may fail, especially for large images that exceed the GPU's texture size limit.
* Large images could be supported although this isn't so common for animation playback. */
if (texture != nullptr) {
GPUVertFormat *imm_format = immVertexFormat();
const uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
const uint texCoord = GPU_vertformat_attr_add(
imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_texture_update(texture, data, display_buffer);
GPU_texture_filter_mode(texture, false);
@ -631,22 +628,10 @@ static void draw_display_buffer(const PlayDisplayContext *display_ctx,
GPU_texture_unbind(texture);
GPU_texture_free(texture);
}
else {
/* Show a pink square, to show the texture failed to load. */
GPUVertFormat *imm_format = immVertexFormat();
const uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 0.0f, 1.0f);
immRectf(pos, canvas->xmin, canvas->ymin, canvas->xmax, canvas->ymax);
immUnbindProgram();
}
if (!glsl_used) {
if (texture != nullptr) {
immUnbindProgram();
}
}
else {
IMB_colormanagement_finish_glsl_draw();
}