Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/surface.c | 25 ++++++++++++------------- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 87a233f..23f4d04 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7832,7 +7832,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl * flip in the blitter, we don't actually need that flip anyway. So we * use the surface's texture as scratch texture, and flip the source * rectangle instead. */ - surface_load_fb_texture(src_surface, FALSE, context); + texture2d_load_fb_texture(src_texture, src_sub_resource_idx, FALSE, context);
s = *src_rect; s.top = wined3d_texture_get_level_height(src_texture, src_level) - s.top; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 201a563..c2b1cd5 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1479,22 +1479,21 @@ error: * * Context activation is done by the caller. This function may temporarily * switch to a different context and restore the original one before return. */ -void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_context *old_ctx) +void texture2d_load_fb_texture(struct wined3d_texture *texture, + unsigned int sub_resource_idx, BOOL srgb, struct wined3d_context *context) { - unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface); - struct wined3d_texture *texture = surface->container; struct wined3d_device *device = texture->resource.device; + struct wined3d_texture *restore_texture; const struct wined3d_gl_info *gl_info; - struct wined3d_context *context = old_ctx; - struct wined3d_surface *restore_rt = NULL; - unsigned int level; + unsigned int restore_idx, level; GLenum target;
- restore_rt = context_get_rt_surface(old_ctx); - if (restore_rt != surface) + restore_texture = context->current_rt.texture; + restore_idx = context->current_rt.sub_resource_idx; + if (restore_texture != texture || restore_idx != sub_resource_idx) context = context_acquire(device, texture, sub_resource_idx); else - restore_rt = NULL; + restore_texture = NULL;
gl_info = context->gl_info; device_invalidate_state(device, STATE_FRAMEBUFFER); @@ -1502,7 +1501,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_texture_prepare_texture(texture, context, srgb); wined3d_texture_bind_and_dirtify(texture, context, srgb);
- TRACE("Reading back offscreen render target %p.\n", surface); + TRACE("Reading back offscreen render target %p, %u.\n", texture, sub_resource_idx);
if (wined3d_resource_is_offscreen(&texture->resource)) gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context)); @@ -1517,8 +1516,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_texture_get_level_height(texture, level)); checkGLcall("glCopyTexSubImage2D");
- if (restore_rt) - context_restore(context, restore_rt); + if (restore_texture) + context_restore(context, restore_texture->sub_resources[sub_resource_idx].u.surface); }
/* Does a direct frame buffer -> texture copy. Stretching is done with single @@ -2184,7 +2183,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re && wined3d_resource_is_offscreen(&texture->resource) && (sub_resource->locations & WINED3D_LOCATION_DRAWABLE)) { - surface_load_fb_texture(sub_resource->u.surface, srgb, context); + texture2d_load_fb_texture(texture, sub_resource_idx, srgb, context);
return TRUE; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 853f9e2..e3d669a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3236,6 +3236,8 @@ static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wi
BOOL texture2d_load_drawable(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context) DECLSPEC_HIDDEN; +void texture2d_load_fb_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx, + BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN; BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN; BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_resource_idx, @@ -3346,8 +3348,6 @@ static inline struct wined3d_texture_sub_resource *surface_get_sub_resource(stru HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const struct wined3d_box *dst_box, struct wined3d_surface *src_surface, const struct wined3d_box *src_box, DWORD flags, const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN; -void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, - struct wined3d_context *context) DECLSPEC_HIDDEN; void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, unsigned int src_pitch, const POINT *dst_point, BOOL srgb,
2018-03-09 0:31 GMT-06:00 Henri Verbeet hverbeet@codeweavers.com:
@@ -1517,8 +1516,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_texture_get_level_height(texture, level)); checkGLcall("glCopyTexSubImage2D");
- if (restore_rt)
context_restore(context, restore_rt);
- if (restore_texture)
context_restore(context, restore_texture->sub_resources[sub_resource_idx].u.surface);
I think this should use restore_idx. I can send a patch fixing it (i.e. based on top of this series, I've rebased my branch on top of it already) if that seems useful.
On 9 March 2018 at 18:24, Matteo Bruni matteo.mystral@gmail.com wrote:
2018-03-09 0:31 GMT-06:00 Henri Verbeet hverbeet@codeweavers.com:
@@ -1517,8 +1516,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct wined3d_texture_get_level_height(texture, level)); checkGLcall("glCopyTexSubImage2D");
- if (restore_rt)
context_restore(context, restore_rt);
- if (restore_texture)
context_restore(context, restore_texture->sub_resources[sub_resource_idx].u.surface);
I think this should use restore_idx.
Right, it should.
I can send a patch fixing it (i.e. based on top of this series, I've rebased my branch on top of it already) if that seems useful.
Sure.