diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index a3877ceb4e..8f383a620b 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -594,28 +594,6 @@ static void surface_evict_sysmem(struct wined3d_surface *surface) surface_invalidate_location(surface, SFLAG_INSYSMEM); } -/* Context activation is done by the caller. */ -static void surface_bind_and_dirtify(struct wined3d_surface *surface, - struct wined3d_context *context, BOOL srgb) -{ - DWORD active_sampler; - - /* 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 - * 0, this avoids messing around with the state manager's GL states. The - * current texture unit should always be a valid one. - * - * To be more specific, this is tricky because we can implicitly be - * 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. */ - active_sampler = context->rev_tex_unit_map[context->active_texture]; - - if (active_sampler != WINED3D_UNMAPPED_STAGE) - context_invalidate_state(context, STATE_SAMPLER(active_sampler)); - wined3d_texture_bind(surface->container, context, srgb); -} - static void surface_force_reload(struct wined3d_surface *surface) { surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED); @@ -628,13 +606,13 @@ static void surface_release_client_storage(struct wined3d_surface *surface) if (surface->container->texture_rgb.name) { - surface_bind_and_dirtify(surface, context, FALSE); + wined3d_texture_bind_and_dirtify(surface->container, context, FALSE); gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); } if (surface->container->texture_srgb.name) { - surface_bind_and_dirtify(surface, context, TRUE); + wined3d_texture_bind_and_dirtify(surface->container, context, TRUE); gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); } @@ -3746,7 +3724,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb) device_invalidate_state(device, STATE_FRAMEBUFFER); surface_prepare_texture(surface, context, srgb); - surface_bind_and_dirtify(surface, context, srgb); + wined3d_texture_bind_and_dirtify(surface->container, context, srgb); TRACE("Reading back offscreen render target %p.\n", surface); @@ -3778,7 +3756,7 @@ static void surface_prepare_texture_internal(struct wined3d_surface *surface, surface->flags |= SFLAG_CONVERTED; else surface->flags &= ~SFLAG_CONVERTED; - surface_bind_and_dirtify(surface, context, srgb); + wined3d_texture_bind_and_dirtify(surface->container, context, srgb); surface_allocate_surface(surface, context->gl_info, &format, srgb); surface->flags |= alloc_flag; } @@ -5087,7 +5065,7 @@ static void surface_load_sysmem(struct wined3d_surface *surface, /* TODO: Use already acquired context when possible. */ context = context_acquire(device, NULL); - surface_bind_and_dirtify(surface, context, !(surface->flags & SFLAG_INTEXTURE)); + wined3d_texture_bind_and_dirtify(surface->container, context, !(surface->flags & SFLAG_INTEXTURE)); surface_download_data(surface, gl_info); context_release(context); @@ -5214,7 +5192,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, context = context_acquire(device, NULL); surface_prepare_texture(surface, context, srgb); - surface_bind_and_dirtify(surface, context, srgb); + wined3d_texture_bind_and_dirtify(surface->container, context, srgb); if (surface->CKeyFlags & WINEDDSD_CKSRCBLT) { diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 9ce96c9642..52a2bf90a0 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -257,6 +257,28 @@ void wined3d_texture_bind(struct wined3d_texture *texture, } } +/* Context activation is done by the caller. */ +void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, + struct wined3d_context *context, BOOL srgb) +{ + DWORD active_sampler; + + /* 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 + * 0, this avoids messing around with the state manager's GL states. The + * current texture unit should always be a valid one. + * + * To be more specific, this is tricky because we can implicitly be + * 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. */ + active_sampler = context->rev_tex_unit_map[context->active_texture]; + if (active_sampler != WINED3D_UNMAPPED_STAGE) + context_invalidate_state(context, STATE_SAMPLER(active_sampler)); + + wined3d_texture_bind(texture, context, srgb); +} + /* Context activation is done by the caller. */ static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target, enum wined3d_texture_address d3d_wrap, GLenum param, BOOL cond_np2) diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 037e904689..efe0f38397 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -27,28 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); -/* Context activation is done by the caller. */ -static void volume_bind_and_dirtify(const struct wined3d_volume *volume, - struct wined3d_context *context, BOOL srgb) -{ - DWORD active_sampler; - - /* 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 0, this avoids messing around with the state manager's - * gl states. The current texture unit should always be a valid one. - * - * To be more specific, this is tricky because we can implicitly be 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. */ - active_sampler = context->rev_tex_unit_map[context->active_texture]; - - if (active_sampler != WINED3D_UNMAPPED_STAGE) - context_invalidate_state(context, STATE_SAMPLER(active_sampler)); - - wined3d_texture_bind(volume->container, context, srgb); -} - void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) { TRACE("volume %p, container %p.\n", volume, container); @@ -274,9 +252,9 @@ static void wined3d_volume_srgb_transfer(struct wined3d_volume *volume, if (!data.addr) return; - volume_bind_and_dirtify(volume, context, !dest_is_srgb); + wined3d_texture_bind_and_dirtify(volume->container, context, !dest_is_srgb); wined3d_volume_download_data(volume, context, &data); - volume_bind_and_dirtify(volume, context, dest_is_srgb); + wined3d_texture_bind_and_dirtify(volume->container, context, dest_is_srgb); wined3d_volume_upload_data(volume, context, &data); HeapFree(GetProcessHeap(), 0, data.addr); @@ -376,9 +354,9 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume, struct wined3d_bo_address data = {0, volume->resource.heap_memory}; if (volume->locations & WINED3D_LOCATION_TEXTURE_RGB) - volume_bind_and_dirtify(volume, context, FALSE); + wined3d_texture_bind_and_dirtify(volume->container, context, FALSE); else - volume_bind_and_dirtify(volume, context, TRUE); + wined3d_texture_bind_and_dirtify(volume->container, context, TRUE); volume->download_count++; wined3d_volume_download_data(volume, context, &data); @@ -406,9 +384,9 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume, struct wined3d_bo_address data = {volume->pbo, NULL}; if (volume->locations & WINED3D_LOCATION_TEXTURE_RGB) - volume_bind_and_dirtify(volume, context, FALSE); + wined3d_texture_bind_and_dirtify(volume->container, context, FALSE); else - volume_bind_and_dirtify(volume, context, TRUE); + wined3d_texture_bind_and_dirtify(volume->container, context, TRUE); wined3d_volume_download_data(volume, context, &data); } @@ -430,7 +408,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume, /* Context activation is done by the caller. */ void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) { - volume_bind_and_dirtify(volume, context, srgb_mode); + wined3d_texture_bind_and_dirtify(volume->container, context, srgb_mode); if (srgb_mode) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2a2b6c6f6c..31235f220d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2105,6 +2105,8 @@ void wined3d_texture_apply_state_changes(struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; void wined3d_texture_bind(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; +void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, + struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN; #define WINED3D_VFLAG_ALLOCATED 0x00000001