wined3d: Pass a wined3d_context_gl structure to wined3d_texture_prepare_texture().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-06-12 15:59:32 +04:30 committed by Alexandre Julliard
parent e3d28cd45d
commit ed9a6a2d67
5 changed files with 41 additions and 35 deletions

View File

@ -2228,7 +2228,8 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void *
&& update_h == wined3d_texture_get_level_height(dst_texture, level) && update_h == wined3d_texture_get_level_height(dst_texture, level)
&& update_d == wined3d_texture_get_level_depth(dst_texture, level)) && update_d == wined3d_texture_get_level_depth(dst_texture, level))
{ {
wined3d_texture_prepare_texture(dst_texture, context, FALSE); wined3d_texture_prepare_location(dst_texture, op->dst_sub_resource_idx,
context, WINED3D_LOCATION_TEXTURE_RGB);
} }
else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx, else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx,
context, WINED3D_LOCATION_TEXTURE_RGB)) context, WINED3D_LOCATION_TEXTURE_RGB))
@ -2337,7 +2338,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
/* Only load the sub-resource for partial updates. */ /* Only load the sub-resource for partial updates. */
if (!box->left && !box->top && !box->front if (!box->left && !box->top && !box->front
&& box->right == width && box->bottom == height && box->back == depth) && box->right == width && box->bottom == height && box->back == depth)
wined3d_texture_prepare_texture(texture, context, FALSE); wined3d_texture_prepare_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
else else
wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);

View File

@ -693,7 +693,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
TRACE("Using upload conversion.\n"); TRACE("Using upload conversion.\n");
wined3d_texture_prepare_texture(dst_texture, context, FALSE); wined3d_texture_prepare_location(dst_texture, 0, context, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE); wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE);
wined3d_texture_upload_data(dst_texture, 0, context, src_format, &src_box, wined3d_texture_upload_data(dst_texture, 0, context, src_format, &src_box,
wined3d_const_bo_address(&src_data), src_row_pitch, src_slice_pitch, 0, 0, 0, FALSE); wined3d_const_bo_address(&src_data), src_row_pitch, src_slice_pitch, 0, 0, 0, FALSE);
@ -868,7 +868,7 @@ void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl,
gl_info = context->gl_info; gl_info = context->gl_info;
device_invalidate_state(device, STATE_FRAMEBUFFER); device_invalidate_state(device, STATE_FRAMEBUFFER);
wined3d_texture_prepare_texture(&texture_gl->t, context, srgb); wined3d_texture_gl_prepare_texture(texture_gl, context_gl, srgb);
wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb); wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
TRACE("Reading back offscreen render target %p, %u.\n", texture_gl, sub_resource_idx); TRACE("Reading back offscreen render target %p, %u.\n", texture_gl, sub_resource_idx);
@ -1529,6 +1529,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
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;
struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(texture);
struct wined3d_context_gl *context_gl = wined3d_context_gl(context); struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = texture->resource.device; struct wined3d_device *device = texture->resource.device;
@ -1547,7 +1548,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
&& wined3d_resource_is_offscreen(&texture->resource) && wined3d_resource_is_offscreen(&texture->resource)
&& (sub_resource->locations & WINED3D_LOCATION_DRAWABLE)) && (sub_resource->locations & WINED3D_LOCATION_DRAWABLE))
{ {
texture2d_load_fb_texture(wined3d_texture_gl(texture), sub_resource_idx, srgb, context); texture2d_load_fb_texture(texture_gl, sub_resource_idx, srgb, context);
return TRUE; return TRUE;
} }
@ -1621,8 +1622,8 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
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_prepare_texture(texture, context, srgb); wined3d_texture_gl_prepare_texture(texture_gl, context_gl, srgb);
wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), srgb); wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
wined3d_texture_get_pitch(texture, level, &src_row_pitch, &src_slice_pitch); wined3d_texture_get_pitch(texture, level, &src_row_pitch, &src_slice_pitch);
format = texture->resource.format; format = texture->resource.format;

View File

@ -1715,52 +1715,53 @@ static void wined3d_texture_force_reload(struct wined3d_texture *texture)
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
struct wined3d_context_gl *context_gl, BOOL srgb)
{ {
DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED; DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED;
const struct wined3d_d3d_info *d3d_info = context->d3d_info; const struct wined3d_d3d_info *d3d_info = context_gl->c.d3d_info;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_resource *resource = &texture->resource; struct wined3d_resource *resource = &texture_gl->t.resource;
const struct wined3d_device *device = resource->device; const struct wined3d_device *device = resource->device;
const struct wined3d_format *format = resource->format; const struct wined3d_format *format = resource->format;
const struct wined3d_color_key_conversion *conversion; const struct wined3d_color_key_conversion *conversion;
const struct wined3d_format_gl *format_gl; const struct wined3d_format_gl *format_gl;
GLenum internal; GLenum internal;
TRACE("texture %p, context %p, format %s.\n", texture, context, debug_d3dformat(format->id)); TRACE("texture_gl %p, context_gl %p, format %s.\n", texture_gl, context_gl, debug_d3dformat(format->id));
if (!d3d_info->shader_color_key if (!d3d_info->shader_color_key
&& !(texture->async.flags & WINED3D_TEXTURE_ASYNC_COLOR_KEY) && !(texture_gl->t.async.flags & WINED3D_TEXTURE_ASYNC_COLOR_KEY)
!= !(texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT)) != !(texture_gl->t.async.color_key_flags & WINED3D_CKEY_SRC_BLT))
{ {
wined3d_texture_force_reload(texture); wined3d_texture_force_reload(&texture_gl->t);
if (texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT) if (texture_gl->t.async.color_key_flags & WINED3D_CKEY_SRC_BLT)
texture->async.flags |= WINED3D_TEXTURE_ASYNC_COLOR_KEY; texture_gl->t.async.flags |= WINED3D_TEXTURE_ASYNC_COLOR_KEY;
} }
if (texture->flags & alloc_flag) if (texture_gl->t.flags & alloc_flag)
return; return;
if (resource->format_flags & WINED3DFMT_FLAG_DECOMPRESS) if (resource->format_flags & WINED3DFMT_FLAG_DECOMPRESS)
{ {
TRACE("WINED3DFMT_FLAG_DECOMPRESS set.\n"); TRACE("WINED3DFMT_FLAG_DECOMPRESS set.\n");
texture->flags |= WINED3D_TEXTURE_CONVERTED; texture_gl->t.flags |= WINED3D_TEXTURE_CONVERTED;
format = wined3d_resource_get_decompress_format(resource); format = wined3d_resource_get_decompress_format(resource);
} }
else if (format->conv_byte_count) else if (format->conv_byte_count)
{ {
texture->flags |= WINED3D_TEXTURE_CONVERTED; texture_gl->t.flags |= WINED3D_TEXTURE_CONVERTED;
} }
else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE))) else if ((conversion = wined3d_format_get_color_key_conversion(&texture_gl->t, TRUE)))
{ {
texture->flags |= WINED3D_TEXTURE_CONVERTED; texture_gl->t.flags |= WINED3D_TEXTURE_CONVERTED;
format = wined3d_get_format(device->adapter, conversion->dst_format, resource->bind_flags); format = wined3d_get_format(device->adapter, conversion->dst_format, resource->bind_flags);
TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id)); TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
} }
format_gl = wined3d_format_gl(format); format_gl = wined3d_format_gl(format);
wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), srgb); wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
if (srgb) if (srgb)
internal = format_gl->srgb_internal; internal = format_gl->srgb_internal;
@ -1774,11 +1775,11 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
TRACE("internal %#x, format %#x, type %#x.\n", internal, format_gl->format, format_gl->type); TRACE("internal %#x, format %#x, type %#x.\n", internal, format_gl->format, format_gl->type);
if (wined3d_texture_use_immutable_storage(texture, gl_info)) if (wined3d_texture_use_immutable_storage(&texture_gl->t, gl_info))
wined3d_texture_gl_allocate_immutable_storage(wined3d_texture_gl(texture), internal, gl_info); wined3d_texture_gl_allocate_immutable_storage(texture_gl, internal, gl_info);
else else
wined3d_texture_gl_allocate_mutable_storage(wined3d_texture_gl(texture), internal, format_gl, gl_info); wined3d_texture_gl_allocate_mutable_storage(texture_gl, internal, format_gl, gl_info);
texture->flags |= alloc_flag; texture_gl->t.flags |= alloc_flag;
} }
static void wined3d_texture_gl_prepare_rb(struct wined3d_texture_gl *texture_gl, static void wined3d_texture_gl_prepare_rb(struct wined3d_texture_gl *texture_gl,
@ -1822,6 +1823,9 @@ static void wined3d_texture_gl_prepare_rb(struct wined3d_texture_gl *texture_gl,
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location) struct wined3d_context *context, DWORD location)
{ {
struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(texture);
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
switch (location) switch (location)
{ {
case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_SYSMEM:
@ -1842,11 +1846,11 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
return TRUE; return TRUE;
case WINED3D_LOCATION_TEXTURE_RGB: case WINED3D_LOCATION_TEXTURE_RGB:
wined3d_texture_prepare_texture(texture, context, FALSE); wined3d_texture_gl_prepare_texture(texture_gl, context_gl, FALSE);
return TRUE; return TRUE;
case WINED3D_LOCATION_TEXTURE_SRGB: case WINED3D_LOCATION_TEXTURE_SRGB:
wined3d_texture_prepare_texture(texture, context, TRUE); wined3d_texture_gl_prepare_texture(texture_gl, context_gl, TRUE);
return TRUE; return TRUE;
case WINED3D_LOCATION_DRAWABLE: case WINED3D_LOCATION_DRAWABLE:
@ -1855,11 +1859,11 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
return TRUE; return TRUE;
case WINED3D_LOCATION_RB_MULTISAMPLE: case WINED3D_LOCATION_RB_MULTISAMPLE:
wined3d_texture_gl_prepare_rb(wined3d_texture_gl(texture), context->gl_info, TRUE); wined3d_texture_gl_prepare_rb(texture_gl, context->gl_info, TRUE);
return TRUE; return TRUE;
case WINED3D_LOCATION_RB_RESOLVED: case WINED3D_LOCATION_RB_RESOLVED:
wined3d_texture_gl_prepare_rb(wined3d_texture_gl(texture), context->gl_info, FALSE); wined3d_texture_gl_prepare_rb(texture_gl, context->gl_info, FALSE);
return TRUE; return TRUE;
default: default:
@ -3844,7 +3848,7 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un
if (update_w == wined3d_texture_get_level_width(dst_texture, dst_level) if (update_w == wined3d_texture_get_level_width(dst_texture, dst_level)
&& update_h == wined3d_texture_get_level_height(dst_texture, dst_level) && update_h == wined3d_texture_get_level_height(dst_texture, dst_level)
&& update_d == wined3d_texture_get_level_depth(dst_texture, dst_level)) && update_d == wined3d_texture_get_level_depth(dst_texture, dst_level))
wined3d_texture_prepare_texture(dst_texture, context, FALSE); wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
else else
wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE); wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE);

View File

@ -190,7 +190,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
return; return;
} }
wined3d_texture_prepare_texture(&texture_gl->t, context, FALSE); wined3d_texture_gl_prepare_texture(texture_gl, context_gl, FALSE);
texture_name = wined3d_texture_gl_get_texture_name(texture_gl, context, FALSE); texture_name = wined3d_texture_gl_get_texture_name(texture_gl, context, FALSE);
level_idx = desc->u.texture.level_idx; level_idx = desc->u.texture.level_idx;

View File

@ -3550,8 +3550,6 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_texture(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN; void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
@ -3625,6 +3623,8 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl, void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
struct wined3d_context *context, unsigned int level, struct wined3d_context *context, unsigned int level,
const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN; const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;