wined3d: Pass a texture and sub-resource index to surface_load_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-07 10:56:41 +03:30 committed by Alexandre Julliard
parent 42a9563e43
commit 92008ec4cf
3 changed files with 17 additions and 20 deletions

View File

@ -2153,13 +2153,11 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
return TRUE;
}
BOOL surface_load_texture(struct wined3d_surface *surface,
BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL srgb)
{
unsigned int width, height, level, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch;
unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface);
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture *texture = surface->container;
struct wined3d_device *device = texture->resource.device;
const struct wined3d_color_key_conversion *conversion;
struct wined3d_texture_sub_resource *sub_resource;
@ -2171,13 +2169,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
BOOL depth;
depth = texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL;
sub_resource = surface_get_sub_resource(surface);
sub_resource = &texture->sub_resources[sub_resource_idx];
if (!depth && wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& wined3d_resource_is_offscreen(&texture->resource)
&& (sub_resource->locations & WINED3D_LOCATION_DRAWABLE))
{
surface_load_fb_texture(surface, srgb, context);
surface_load_fb_texture(sub_resource->u.surface, srgb, context);
return TRUE;
}
@ -2194,11 +2192,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
&texture->resource, WINED3D_LOCATION_TEXTURE_SRGB))
{
if (srgb)
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_RGB,
&src_rect, surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect);
surface_blt_fbo(device, context, WINED3D_TEXF_POINT,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect);
else
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_SRGB,
&src_rect, surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect);
surface_blt_fbo(device, context, WINED3D_TEXF_POINT,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect);
return TRUE;
}
@ -2212,8 +2212,8 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if (fbo_blitter_supported(WINED3D_BLIT_OP_COLOR_BLIT, gl_info,
&texture->resource, src_location, &texture->resource, dst_location))
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, src_location,
&src_rect, surface, dst_location, &src_rect);
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, sub_resource->u.surface,
src_location, &src_rect, sub_resource->u.surface, dst_location, &src_rect);
return TRUE;
}
@ -2225,7 +2225,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | texture->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_RGB)
{
FIXME_(d3d_perf)("Downloading RGB surface %p to reload it as sRGB.\n", surface);
FIXME_(d3d_perf)("Downloading RGB texture %p, %u to reload it as sRGB.\n", texture, sub_resource_idx);
wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
}
}
@ -2234,7 +2234,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_SRGB | texture->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_SRGB)
{
FIXME_(d3d_perf)("Downloading sRGB surface %p to reload it as RGB.\n", surface);
FIXME_(d3d_perf)("Downloading sRGB texture %p, %u to reload it as RGB.\n", texture, sub_resource_idx);
wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
}
}
@ -2259,7 +2259,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
* getting called. */
if ((format.conv_byte_count || conversion) && texture->sub_resources[sub_resource_idx].buffer_object)
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
TRACE("Removing the pbo attached to texture %p, %u.\n", texture, sub_resource_idx);
wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
wined3d_texture_set_map_binding(texture, WINED3D_LOCATION_SYSMEM);

View File

@ -1792,12 +1792,9 @@ static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int
static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location)
{
struct wined3d_surface *surface;
TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
texture, sub_resource_idx, context, wined3d_debug_location(location));
surface = texture->sub_resources[sub_resource_idx].u.surface;
switch (location)
{
case WINED3D_LOCATION_USER_MEMORY:
@ -1814,7 +1811,7 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in
case WINED3D_LOCATION_TEXTURE_RGB:
case WINED3D_LOCATION_TEXTURE_SRGB:
return surface_load_texture(surface, context,
return texture2d_load_texture(texture, sub_resource_idx, context,
location == WINED3D_LOCATION_TEXTURE_SRGB);
default:

View File

@ -3240,6 +3240,8 @@ BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int s
struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN;
BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN;
BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN;
@ -3346,8 +3348,6 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst
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;
BOOL surface_load_texture(struct wined3d_surface *surface,
struct wined3d_context *context, BOOL srgb) 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,