wined3d: Pass a texture and sub-resource index to surface_load_fb_texture().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-03-09 10:01:51 +03:30 committed by Alexandre Julliard
parent 661791cb7e
commit 2179e99120
3 changed files with 15 additions and 16 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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,