From: Henri Verbeet Subject: [PATCH 4/5] wined3d: Use wined3d_texture_get_sub_resource_target() in surface_load_fb_texture(). Message-Id: <1519283218-1353-4-git-send-email-hverbeet@codeweavers.com> Date: Thu, 22 Feb 2018 10:36:57 +0330 Signed-off-by: Henri Verbeet --- dlls/wined3d/surface.c | 7 +++++-- dlls/wined3d/texture.c | 11 ----------- dlls/wined3d/wined3d_private.h | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 699e8b3..d4da824 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1529,15 +1529,17 @@ error: * 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) { + unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface); struct wined3d_texture *texture = surface->container; struct wined3d_device *device = texture->resource.device; const struct wined3d_gl_info *gl_info; struct wined3d_context *context = old_ctx; struct wined3d_surface *restore_rt = NULL; + GLenum target; restore_rt = context_get_rt_surface(old_ctx); if (restore_rt != surface) - context = context_acquire(device, texture, surface_get_sub_resource_idx(surface)); + context = context_acquire(device, texture, sub_resource_idx); else restore_rt = NULL; @@ -1555,7 +1557,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(texture)); checkGLcall("glReadBuffer"); - gl_info->gl_ops.gl.p_glCopyTexSubImage2D(surface->texture_target, surface->texture_level, + target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); + gl_info->gl_ops.gl.p_glCopyTexSubImage2D(target, surface->texture_level, 0, 0, 0, 0, wined3d_texture_get_level_width(texture, surface->texture_level), wined3d_texture_get_level_height(texture, surface->texture_level)); checkGLcall("glCopyTexSubImage2D"); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 1e34299..ebaa3b9 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1394,7 +1394,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT texture->target = GL_TEXTURE_2D_MULTISAMPLE; else texture->target = GL_TEXTURE_2D; - texture->sub_resources[0].u.surface->texture_target = texture->target; if (((width & (width - 1)) || (height & (height - 1))) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]) @@ -2213,22 +2212,12 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 { for (j = 0; j < texture->layer_count; ++j) { - static const GLenum cube_targets[6] = - { - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, - }; struct wined3d_texture_sub_resource *sub_resource; unsigned int idx = j * texture->level_count + i; struct wined3d_surface *surface; surface = &surfaces[idx]; surface->container = texture; - surface->texture_target = desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP ? cube_targets[j] : texture->target; surface->texture_level = i; surface->texture_layer = j; list_init(&surface->renderbuffers); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b9647d2..b4d15c5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3310,7 +3310,6 @@ struct wined3d_surface { struct wined3d_texture *container; - GLenum texture_target; unsigned int texture_level; unsigned int texture_layer; -- 2.1.4