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

This reverts commit 34899ec13d5037c76d76293b7da47d5c9843a66d.

This causes issues on WIN32 which I'm unable to reproduce.
Resolving the error with textures failing to load can be done with
fewer changes.
This commit is contained in:
Campbell Barton 2023-10-23 10:59:57 +11:00
parent 19b112b11c
commit a65f806658

@ -542,27 +542,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);
@ -602,22 +599,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();
}