Commit 92008ec4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent 42a9563e
...@@ -2153,13 +2153,11 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture, ...@@ -2153,13 +2153,11 @@ BOOL texture2d_load_drawable(struct wined3d_texture *texture,
return TRUE; 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) 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 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; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture *texture = surface->container;
struct wined3d_device *device = texture->resource.device; struct wined3d_device *device = texture->resource.device;
const struct wined3d_color_key_conversion *conversion; const struct wined3d_color_key_conversion *conversion;
struct wined3d_texture_sub_resource *sub_resource; struct wined3d_texture_sub_resource *sub_resource;
...@@ -2171,13 +2169,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface, ...@@ -2171,13 +2169,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
BOOL depth; BOOL depth;
depth = texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL; 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 if (!depth && wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& wined3d_resource_is_offscreen(&texture->resource) && wined3d_resource_is_offscreen(&texture->resource)
&& (sub_resource->locations & WINED3D_LOCATION_DRAWABLE)) && (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; return TRUE;
} }
...@@ -2194,11 +2192,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface, ...@@ -2194,11 +2192,13 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
&texture->resource, WINED3D_LOCATION_TEXTURE_SRGB)) &texture->resource, WINED3D_LOCATION_TEXTURE_SRGB))
{ {
if (srgb) if (srgb)
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_RGB, surface_blt_fbo(device, context, WINED3D_TEXF_POINT,
&src_rect, surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect); sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect);
else else
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, WINED3D_LOCATION_TEXTURE_SRGB, surface_blt_fbo(device, context, WINED3D_TEXF_POINT,
&src_rect, surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect); sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_SRGB, &src_rect,
sub_resource->u.surface, WINED3D_LOCATION_TEXTURE_RGB, &src_rect);
return TRUE; return TRUE;
} }
...@@ -2212,8 +2212,8 @@ BOOL surface_load_texture(struct wined3d_surface *surface, ...@@ -2212,8 +2212,8 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if (fbo_blitter_supported(WINED3D_BLIT_OP_COLOR_BLIT, gl_info, if (fbo_blitter_supported(WINED3D_BLIT_OP_COLOR_BLIT, gl_info,
&texture->resource, src_location, &texture->resource, dst_location)) &texture->resource, src_location, &texture->resource, dst_location))
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, src_location, surface_blt_fbo(device, context, WINED3D_TEXF_POINT, sub_resource->u.surface,
&src_rect, surface, dst_location, &src_rect); src_location, &src_rect, sub_resource->u.surface, dst_location, &src_rect);
return TRUE; return TRUE;
} }
...@@ -2225,7 +2225,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface, ...@@ -2225,7 +2225,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | texture->resource.map_binding)) if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | texture->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_RGB) == 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); 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, ...@@ -2234,7 +2234,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_SRGB | texture->resource.map_binding)) if ((sub_resource->locations & (WINED3D_LOCATION_TEXTURE_SRGB | texture->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_SRGB) == 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); 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, ...@@ -2259,7 +2259,7 @@ BOOL surface_load_texture(struct wined3d_surface *surface,
* getting called. */ * getting called. */
if ((format.conv_byte_count || conversion) && texture->sub_resources[sub_resource_idx].buffer_object) 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_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM);
wined3d_texture_set_map_binding(texture, WINED3D_LOCATION_SYSMEM); wined3d_texture_set_map_binding(texture, WINED3D_LOCATION_SYSMEM);
......
...@@ -1792,12 +1792,9 @@ static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int ...@@ -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, static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location) struct wined3d_context *context, DWORD location)
{ {
struct wined3d_surface *surface;
TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n", TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
texture, sub_resource_idx, context, wined3d_debug_location(location)); texture, sub_resource_idx, context, wined3d_debug_location(location));
surface = texture->sub_resources[sub_resource_idx].u.surface;
switch (location) switch (location)
{ {
case WINED3D_LOCATION_USER_MEMORY: case WINED3D_LOCATION_USER_MEMORY:
...@@ -1814,7 +1811,7 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in ...@@ -1814,7 +1811,7 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in
case WINED3D_LOCATION_TEXTURE_RGB: case WINED3D_LOCATION_TEXTURE_RGB:
case WINED3D_LOCATION_TEXTURE_SRGB: 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); location == WINED3D_LOCATION_TEXTURE_SRGB);
default: default:
......
...@@ -3240,6 +3240,8 @@ BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int s ...@@ -3240,6 +3240,8 @@ BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int s
struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN; struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN;
BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD dst_location) DECLSPEC_HIDDEN; 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, void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN; 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 ...@@ -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; 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, void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
struct wined3d_context *context) DECLSPEC_HIDDEN; 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, 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, 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, unsigned int src_pitch, const POINT *dst_point, BOOL srgb,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment