wined3d: Allow reusing current GL context without a current RT.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57411
This commit is contained in:
Matteo Bruni 2024-01-08 12:24:18 +01:00 committed by Alexandre Julliard
parent 5b4237d2be
commit 8923eb51ea
Notes: Alexandre Julliard 2024-11-19 23:23:06 +01:00
Approved-by: Jan Sikorski (@jsikorski)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6806
4 changed files with 13 additions and 11 deletions

View file

@ -54,7 +54,7 @@ void wined3d_context_cleanup(struct wined3d_context *context)
* A to avoid breaking caller code. */ * A to avoid breaking caller code. */
void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx) void context_restore(struct wined3d_context *context, struct wined3d_texture *texture, unsigned int sub_resource_idx)
{ {
if (context->current_rt.texture != texture || context->current_rt.sub_resource_idx != sub_resource_idx) if (texture && (context->current_rt.texture != texture || context->current_rt.sub_resource_idx != sub_resource_idx))
{ {
context_release(context); context_release(context);
context = context_acquire(texture->resource.device, texture, sub_resource_idx); context = context_acquire(texture->resource.device, texture, sub_resource_idx);

View file

@ -4356,7 +4356,6 @@ struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *
if (!texture) if (!texture)
{ {
if (current_context if (current_context
&& current_context->c.current_rt.texture
&& current_context->c.device == device) && current_context->c.device == device)
{ {
texture = current_context->c.current_rt.texture; texture = current_context->c.current_rt.texture;

View file

@ -352,6 +352,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
unsigned int row_pitch, slice_pitch; unsigned int row_pitch, slice_pitch;
unsigned int width, height, level; unsigned int width, height, level;
struct wined3d_bo_address data; struct wined3d_bo_address data;
bool restore_context = false;
unsigned int restore_idx; unsigned int restore_idx;
BYTE *row, *top, *bottom; BYTE *row, *top, *bottom;
BOOL src_is_upside_down; BOOL src_is_upside_down;
@ -369,9 +370,10 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
restore_texture = context->current_rt.texture; restore_texture = context->current_rt.texture;
restore_idx = context->current_rt.sub_resource_idx; restore_idx = context->current_rt.sub_resource_idx;
if (!wined3d_resource_is_offscreen(resource) && (restore_texture != texture || restore_idx != sub_resource_idx)) if (!wined3d_resource_is_offscreen(resource) && (restore_texture != texture || restore_idx != sub_resource_idx))
{
context = context_acquire(device, texture, sub_resource_idx); context = context_acquire(device, texture, sub_resource_idx);
else restore_context = true;
restore_texture = NULL; }
context_gl = wined3d_context_gl(context); context_gl = wined3d_context_gl(context);
gl_info = context_gl->gl_info; gl_info = context_gl->gl_info;
@ -473,7 +475,7 @@ error:
checkGLcall("glBindBuffer"); checkGLcall("glBindBuffer");
} }
if (restore_texture) if (restore_context)
context_restore(context, restore_texture, restore_idx); context_restore(context, restore_texture, restore_idx);
} }

View file

@ -340,12 +340,12 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location,
const RECT *dst_rect, const struct wined3d_format *resolve_format) const RECT *dst_rect, const struct wined3d_format *resolve_format)
{ {
struct wined3d_texture *required_texture, *restore_texture = NULL, *dst_save_texture = dst_texture; struct wined3d_texture *required_texture, *restore_texture, *dst_save_texture = dst_texture;
unsigned int restore_idx, dst_save_sub_resource_idx = dst_sub_resource_idx; unsigned int restore_idx, dst_save_sub_resource_idx = dst_sub_resource_idx;
bool resolve, scaled_resolve, restore_context = false;
struct wined3d_texture *src_staging_texture = NULL; struct wined3d_texture *src_staging_texture = NULL;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_context_gl *context_gl; struct wined3d_context_gl *context_gl;
bool resolve, scaled_resolve;
GLenum gl_filter; GLenum gl_filter;
GLenum buffer; GLenum buffer;
RECT s, d; RECT s, d;
@ -490,16 +490,17 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
restore_texture = context->current_rt.texture; restore_texture = context->current_rt.texture;
restore_idx = context->current_rt.sub_resource_idx; restore_idx = context->current_rt.sub_resource_idx;
if (restore_texture != required_texture) if (restore_texture != required_texture)
{
context = context_acquire(device, required_texture, 0); context = context_acquire(device, required_texture, 0);
else restore_context = true;
restore_texture = NULL; }
context_gl = wined3d_context_gl(context); context_gl = wined3d_context_gl(context);
if (!context_gl->valid) if (!context_gl->valid)
{ {
context_release(context); context_release(context);
WARN("Invalid context, skipping blit.\n"); WARN("Invalid context, skipping blit.\n");
restore_texture = NULL; restore_context = false;
goto done; goto done;
} }
@ -565,7 +566,7 @@ done:
if (src_staging_texture) if (src_staging_texture)
wined3d_texture_decref(src_staging_texture); wined3d_texture_decref(src_staging_texture);
if (restore_texture) if (restore_context)
context_restore(context, restore_texture, restore_idx); context_restore(context, restore_texture, restore_idx);
} }