Commit 11db4d4a authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use the texture dimension helpers in surface_load_texture().

parent 7c9ff854
...@@ -3044,8 +3044,7 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface, ...@@ -3044,8 +3044,7 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface,
static HRESULT surface_load_texture(struct wined3d_surface *surface, static HRESULT surface_load_texture(struct wined3d_surface *surface,
struct wined3d_context *context, BOOL srgb) struct wined3d_context *context, BOOL srgb)
{ {
unsigned int width, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch; unsigned int width, height, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch;
const RECT src_rect = {0, 0, surface->resource.width, surface->resource.height};
unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface); 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_texture *texture = surface->container;
...@@ -3056,6 +3055,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3056,6 +3055,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
struct wined3d_format format; struct wined3d_format format;
POINT dst_point = {0, 0}; POINT dst_point = {0, 0};
BYTE *mem = NULL; BYTE *mem = NULL;
RECT src_rect;
sub_resource = surface_get_sub_resource(surface); sub_resource = surface_get_sub_resource(surface);
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
...@@ -3067,6 +3067,10 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3067,6 +3067,10 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
return WINED3D_OK; return WINED3D_OK;
} }
width = wined3d_texture_get_level_width(texture, surface->texture_level);
height = wined3d_texture_get_level_height(texture, surface->texture_level);
SetRect(&src_rect, 0, 0, width, height);
if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_SRGB | WINED3D_LOCATION_TEXTURE_RGB) if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_SRGB | WINED3D_LOCATION_TEXTURE_RGB)
&& (texture->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB) && (texture->resource.format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB)
&& fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT, && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
...@@ -3092,10 +3096,9 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3092,10 +3096,9 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
DWORD src_location = sub_resource->locations & WINED3D_LOCATION_RB_RESOLVED ? DWORD src_location = sub_resource->locations & WINED3D_LOCATION_RB_RESOLVED ?
WINED3D_LOCATION_RB_RESOLVED : WINED3D_LOCATION_RB_MULTISAMPLE; WINED3D_LOCATION_RB_RESOLVED : WINED3D_LOCATION_RB_MULTISAMPLE;
DWORD dst_location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB; DWORD dst_location = srgb ? WINED3D_LOCATION_TEXTURE_SRGB : WINED3D_LOCATION_TEXTURE_RGB;
RECT rect = {0, 0, surface->resource.width, surface->resource.height};
surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, src_location, surface_blt_fbo(device, context, WINED3D_TEXF_POINT, surface, src_location,
&rect, surface, dst_location, &rect); &src_rect, surface, dst_location, &src_rect);
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -3134,8 +3137,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3134,8 +3137,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
wined3d_texture_bind_and_dirtify(texture, context, srgb); wined3d_texture_bind_and_dirtify(texture, context, srgb);
wined3d_texture_get_pitch(texture, surface->texture_level, &src_row_pitch, &src_slice_pitch); wined3d_texture_get_pitch(texture, surface->texture_level, &src_row_pitch, &src_slice_pitch);
width = surface->resource.width;
format = *texture->resource.format; format = *texture->resource.format;
if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE))) if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
format = *wined3d_get_format(gl_info, conversion->dst_format); format = *wined3d_get_format(gl_info, conversion->dst_format);
...@@ -3160,8 +3161,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3160,8 +3161,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
if (format.convert) if (format.convert)
{ {
/* This code is entered for texture formats which need a fixup. */ /* This code is entered for texture formats which need a fixup. */
UINT height = surface->resource.height;
format.byte_count = format.conv_byte_count; format.byte_count = format.conv_byte_count;
wined3d_format_calculate_pitch(&format, 1, width, height, &dst_row_pitch, &dst_slice_pitch); wined3d_format_calculate_pitch(&format, 1, width, height, &dst_row_pitch, &dst_slice_pitch);
...@@ -3180,7 +3179,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, ...@@ -3180,7 +3179,6 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
{ {
/* This code is only entered for color keying fixups */ /* This code is only entered for color keying fixups */
struct wined3d_palette *palette = NULL; struct wined3d_palette *palette = NULL;
UINT height = surface->resource.height;
wined3d_format_calculate_pitch(&format, device->surface_alignment, wined3d_format_calculate_pitch(&format, device->surface_alignment,
width, height, &dst_row_pitch, &dst_slice_pitch); width, height, &dst_row_pitch, &dst_slice_pitch);
......
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