From 77bc74c6379fc121802fdf790b130da5a490ba50 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 9 May 2019 19:11:13 +0430 Subject: [PATCH] wined3d: Pass a wined3d_context_gl structure to wined3d_texture_gl_bind_and_dirtify(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/cs.c | 4 +-- dlls/wined3d/surface.c | 8 +++--- dlls/wined3d/texture.c | 51 ++++++++++++++++++---------------- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index b2a2b1ad4ff..2fb361fb677 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2242,7 +2242,7 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void * wined3d_texture_get_pitch(src_texture, op->src_sub_resource_idx % src_texture->level_count, &row_pitch, &slice_pitch); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE); wined3d_texture_upload_data(dst_texture, op->dst_sub_resource_idx, context, dst_texture->resource.format, &op->src_box, wined3d_const_bo_address(&addr), row_pitch, slice_pitch, op->dst_box.left, op->dst_box.top, op->dst_box.front, FALSE); @@ -2340,7 +2340,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi wined3d_texture_prepare_texture(texture, context, FALSE); else wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), FALSE); wined3d_box_set(&src_box, 0, 0, box->right - box->left, box->bottom - box->top, 0, box->back - box->front); wined3d_texture_upload_data(texture, op->sub_resource_idx, context, texture->resource.format, &src_box, diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 7a20e2c6007..15d8078fa06 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -687,7 +687,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr TRACE("Using upload conversion.\n"); wined3d_texture_prepare_texture(dst_texture, context, FALSE); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), 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_const_bo_address(&src_data), src_row_pitch, src_slice_pitch, 0, 0, 0, FALSE); @@ -858,7 +858,7 @@ void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, device_invalidate_state(device, STATE_FRAMEBUFFER); wined3d_texture_prepare_texture(&texture_gl->t, context, srgb); - wined3d_texture_gl_bind_and_dirtify(texture_gl, context, srgb); + wined3d_texture_gl_bind_and_dirtify(texture_gl, wined3d_context_gl(context), srgb); TRACE("Reading back offscreen render target %p, %u.\n", texture_gl, sub_resource_idx); @@ -1445,7 +1445,7 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB)) { struct wined3d_bo_address data; - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), !(sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)); wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); @@ -1612,7 +1612,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re } wined3d_texture_prepare_texture(texture, context, srgb); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, srgb); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), srgb); wined3d_texture_get_pitch(texture, level, &src_row_pitch, &src_slice_pitch); format = texture->resource.format; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 80f72f5cfd8..8097bb23f74 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1050,7 +1050,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, /* Context activation is done by the caller. */ void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, - struct wined3d_context *context, BOOL srgb) + struct wined3d_context_gl *context_gl, BOOL srgb) { /* We don't need a specific texture unit, but after binding the texture * the current unit is dirty. Read the unit back instead of switching to @@ -1061,18 +1061,18 @@ void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, * called from sampler() in state.c. This means we can't touch anything * other than whatever happens to be the currently active texture, or we * would risk marking already applied sampler states dirty again. */ - if (context->active_texture < ARRAY_SIZE(context->rev_tex_unit_map)) + if (context_gl->c.active_texture < ARRAY_SIZE(context_gl->c.rev_tex_unit_map)) { - DWORD active_sampler = context->rev_tex_unit_map[context->active_texture]; + DWORD active_sampler = context_gl->c.rev_tex_unit_map[context_gl->c.active_texture]; if (active_sampler != WINED3D_UNMAPPED_STAGE) - context_invalidate_state(context, STATE_SAMPLER(active_sampler)); + context_invalidate_state(&context_gl->c, STATE_SAMPLER(active_sampler)); } /* FIXME: Ideally we'd only do this when touching a binding that's used by * a shader. */ - context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING); - context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); + context_invalidate_compute_state(&context_gl->c, STATE_COMPUTE_SHADER_RESOURCE_BINDING); + context_invalidate_state(&context_gl->c, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); - wined3d_texture_gl_bind(texture_gl, context, srgb); + wined3d_texture_gl_bind(texture_gl, &context_gl->c, srgb); } /* Context activation is done by the caller (state handler). */ @@ -1752,7 +1752,7 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win } format_gl = wined3d_format_gl(format); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, srgb); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), wined3d_context_gl(context), srgb); if (srgb) internal = format_gl->srgb_internal; @@ -2730,6 +2730,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_context *context, DWORD location) { struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; + struct wined3d_context_gl *context_gl = wined3d_context_gl(context); unsigned int row_pitch, slice_pitch; TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n", @@ -2749,7 +2750,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in data.addr += sub_resource->offset; wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), - context, location == WINED3D_LOCATION_TEXTURE_SRGB); + context_gl, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format, @@ -2760,7 +2761,7 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL}; struct wined3d_box src_box; - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); @@ -2781,9 +2782,9 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in data.addr += sub_resource->offset; if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, FALSE); else - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, TRUE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, TRUE); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); ++texture->download_count; @@ -2802,9 +2803,9 @@ static BOOL texture1d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_bo_address data = {sub_resource->buffer_object, NULL}; if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, FALSE); else - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, TRUE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, TRUE); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); } @@ -3107,6 +3108,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in struct wined3d_context *context, BOOL dest_is_srgb) { struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; + struct wined3d_context_gl *context_gl = wined3d_context_gl(context); unsigned int row_pitch, slice_pitch; struct wined3d_bo_address data; struct wined3d_box src_box; @@ -3124,9 +3126,9 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, !dest_is_srgb); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, !dest_is_srgb); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, dest_is_srgb); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, dest_is_srgb); wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format, &src_box, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE); @@ -3138,6 +3140,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_context *context, DWORD location) { struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; + struct wined3d_context_gl *context_gl = wined3d_context_gl(context); unsigned int row_pitch, slice_pitch; if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location)) @@ -3154,7 +3157,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in data.addr += sub_resource->offset; wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), - context, location == WINED3D_LOCATION_TEXTURE_SRGB); + context_gl, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format, @@ -3166,7 +3169,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_box src_box; wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), - context, location == WINED3D_LOCATION_TEXTURE_SRGB); + context_gl, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format, @@ -3194,9 +3197,9 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in data.addr += sub_resource->offset; if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, FALSE); else - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, TRUE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, TRUE); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); ++texture->download_count; @@ -3215,9 +3218,9 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in struct wined3d_bo_address data = {sub_resource->buffer_object, NULL}; if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, FALSE); else - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context, TRUE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(texture), context_gl, TRUE); wined3d_texture_download_data(texture, sub_resource_idx, context, &data); } @@ -3800,7 +3803,7 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un wined3d_texture_prepare_texture(dst_texture, context, FALSE); else 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), context, FALSE); + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(dst_texture), wined3d_context_gl(context), FALSE); src_level = src_sub_resource_idx % src_texture->level_count; wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &data, @@ -3828,7 +3831,7 @@ void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, dst_location); wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &data, dst_location); - wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(src_texture), context, + wined3d_texture_gl_bind_and_dirtify(wined3d_texture_gl(src_texture), wined3d_context_gl(context), !(src_texture->sub_resources[src_sub_resource_idx].locations & WINED3D_LOCATION_TEXTURE_RGB)); wined3d_texture_download_data(src_texture, src_sub_resource_idx, context, &data); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index d04f861f0c4..3b004a8882b 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -906,7 +906,7 @@ void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view * } else { - wined3d_texture_gl_bind_and_dirtify(texture_gl, context, srgb); + wined3d_texture_gl_bind_and_dirtify(texture_gl, wined3d_context_gl(context), srgb); gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level); gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, max_level); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 333178a80d0..26b0894b2e1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3602,7 +3602,7 @@ void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, - struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; + struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN; void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl, struct wined3d_context *context, unsigned int level, const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;