From 510e262676be0aaf511316190b1d526b352a8b56 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Mon, 17 Jan 2022 15:00:04 +0100 Subject: [PATCH] wined3d: Don't force going through a texture when downloading from renderbuffers. It can be unnecessary at best and unsupported at worst (e.g. no ARB_texture_multisample or MultisampleTextures setting disabled). --- dlls/wined3d/surface.c | 10 ++++++---- dlls/wined3d/texture.c | 11 +++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index dce1de3ac18..99338b91d5b 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -359,6 +359,9 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i uint8_t *offset; unsigned int i; + TRACE("texture %p, sub_resource_idx %u, context %p, src_location %s, dst_location %s.\n", + texture, sub_resource_idx, context, wined3d_debug_location(src_location), wined3d_debug_location(dst_location)); + /* dst_location was already prepared by the caller. */ wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, dst_location); offset = data.addr; @@ -382,10 +385,9 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i resource, sub_resource_idx, NULL, 0, src_location); } - /* Select the correct read buffer, and give some debug output. - * There is no need to keep track of the current read buffer or reset it, - * every part of the code that reads sets the read buffer as desired. - */ + /* Select the correct read buffer, and give some debug output. There is no + * need to keep track of the current read buffer or reset it, every part + * of the code that reads pixels sets the read buffer as desired. */ if (src_location != WINED3D_LOCATION_DRAWABLE || wined3d_resource_is_offscreen(resource)) { /* Mapping the primary render target which is not on a swapchain. diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 22f69cc0cc6..e5005cf99fa 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2974,18 +2974,17 @@ static BOOL wined3d_texture_gl_load_sysmem(struct wined3d_texture_gl *texture_gl sub_resource = &texture_gl->t.sub_resources[sub_resource_idx]; /* We cannot download data from multisample textures directly. */ - if (wined3d_texture_gl_is_multisample_location(texture_gl, WINED3D_LOCATION_TEXTURE_RGB)) - { + if (wined3d_texture_gl_is_multisample_location(texture_gl, WINED3D_LOCATION_TEXTURE_RGB) + || sub_resource->locations & WINED3D_LOCATION_RB_MULTISAMPLE) wined3d_texture_load_location(&texture_gl->t, sub_resource_idx, &context_gl->c, WINED3D_LOCATION_RB_RESOLVED); + + if (sub_resource->locations & WINED3D_LOCATION_RB_RESOLVED) + { texture2d_read_from_framebuffer(&texture_gl->t, sub_resource_idx, &context_gl->c, WINED3D_LOCATION_RB_RESOLVED, dst_location); return TRUE; } - if (sub_resource->locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED)) - wined3d_texture_load_location(&texture_gl->t, sub_resource_idx, &context_gl->c, WINED3D_LOCATION_TEXTURE_RGB); - - /* Download the sub-resource to system memory. */ if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) { unsigned int row_pitch, slice_pitch, level;