Commit 5a29cc87 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Introduce wined3d_texture_validate_location().

parent 97f4034e
......@@ -7878,6 +7878,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_
struct wined3d_surface *dst_surface, const RECT *dst_rect_in,
const struct wined3d_color_key *color_key)
{
unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
struct wined3d_texture *src_texture = src_surface->container;
struct wined3d_texture *dst_texture = dst_surface->container;
struct wined3d_context *context;
......@@ -7935,7 +7936,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, enum wined3d_blit_
context_release(context);
surface_validate_location(dst_surface, dst_texture->resource.draw_binding);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_texture->resource.draw_binding);
surface_invalidate_location(dst_surface, ~dst_texture->resource.draw_binding);
}
......
......@@ -401,7 +401,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
if (rt)
{
surface_validate_location(rt, rtv->resource->draw_binding);
wined3d_texture_validate_location(rt->container, rtv->sub_resource_idx, rtv->resource->draw_binding);
surface_invalidate_location(rt, ~rtv->resource->draw_binding);
}
}
......@@ -4117,7 +4117,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
context_release(context);
surface_validate_location(surface, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
surface_invalidate_location(surface, ~WINED3D_LOCATION_TEXTURE_RGB);
}
......
......@@ -458,7 +458,8 @@ static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct
swapchain->back_buffers[i - 1]->texture_rgb = swapchain->back_buffers[i]->texture_rgb;
surface_prev->rb_multisample = surface->rb_multisample;
surface_validate_location(surface_prev, sub_resource->locations & supported_locations);
wined3d_texture_validate_location(swapchain->back_buffers[i - 1], 0,
sub_resource->locations & supported_locations);
surface_invalidate_location(surface_prev, ~(sub_resource->locations & supported_locations));
surface_prev = surface;
......@@ -467,7 +468,7 @@ static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct
swapchain->back_buffers[i - 1]->texture_rgb = tex0;
surface_prev->rb_multisample = rb0;
surface_validate_location(surface_prev, locations0 & supported_locations);
wined3d_texture_validate_location(swapchain->back_buffers[i - 1], 0, locations0 & supported_locations);
surface_invalidate_location(surface_prev, ~(locations0 & supported_locations));
device_invalidate_state(swapchain->device, STATE_FRAMEBUFFER);
......@@ -482,7 +483,6 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
const struct wined3d_gl_info *gl_info;
struct wined3d_texture *logo_texture;
struct wined3d_context *context;
struct wined3d_surface *front;
BOOL render_to_fbo;
context = context_acquire(swapchain->device, back_buffer);
......@@ -599,10 +599,8 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
}
}
front = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0));
surface_validate_location(front, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(front, ~WINED3D_LOCATION_DRAWABLE);
wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(swapchain->front_buffer->sub_resources[0].u.surface, ~WINED3D_LOCATION_DRAWABLE);
/* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
* and INTEXTURE copies can keep their old content if they have any defined content.
* If the swapeffect is COPY, the content remains the same.
......@@ -827,7 +825,6 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
{
const struct wined3d_adapter *adapter = device->adapter;
struct wined3d_resource_desc texture_desc;
struct wined3d_surface *front_buffer;
BOOL displaymode_set = FALSE;
RECT client_rect;
HWND window;
......@@ -911,11 +908,10 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
}
wined3d_texture_set_swapchain(swapchain->front_buffer, swapchain);
front_buffer = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0));
if (!(device->wined3d->flags & WINED3D_NO3D))
{
surface_validate_location(front_buffer, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(front_buffer, ~WINED3D_LOCATION_DRAWABLE);
wined3d_texture_validate_location(swapchain->front_buffer, 0, WINED3D_LOCATION_DRAWABLE);
surface_invalidate_location(swapchain->front_buffer->sub_resources[0].u.surface, ~WINED3D_LOCATION_DRAWABLE);
}
/* MSDN says we're only allowed a single fullscreen swapchain per device,
......
......@@ -69,6 +69,20 @@ GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
return GL_BACK;
}
void wined3d_texture_validate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
TRACE("texture %p, sub_resource_idx %u, location %s.\n",
texture, sub_resource_idx, wined3d_debug_location(location));
sub_resource = &texture->sub_resources[sub_resource_idx];
sub_resource->locations |= location;
TRACE("New locations flags are %s.\n", wined3d_debug_location(sub_resource->locations));
}
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
......@@ -857,7 +871,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
if (sub_resource->resource->map_binding == WINED3D_LOCATION_BUFFER && !wined3d_texture_use_pbo(texture, gl_info))
sub_resource->resource->map_binding = surface->dib.DIBsection ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
surface_validate_location(surface, valid_location);
wined3d_texture_validate_location(texture, 0, valid_location);
return WINED3D_OK;
}
......@@ -1000,7 +1014,7 @@ static HRESULT wined3d_texture_upload_data(struct wined3d_texture *texture,
struct wined3d_resource *sub_resource = texture->sub_resources[i].resource;
texture->texture_ops->texture_sub_resource_upload_data(sub_resource, context, &data[i]);
texture->texture_ops->texture_sub_resource_validate_location(sub_resource, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_TEXTURE_RGB);
texture->texture_ops->texture_sub_resource_invalidate_location(sub_resource, ~WINED3D_LOCATION_TEXTURE_RGB);
}
......@@ -1022,13 +1036,6 @@ static void texture2d_sub_resource_invalidate_location(struct wined3d_resource *
surface_invalidate_location(surface, location);
}
static void texture2d_sub_resource_validate_location(struct wined3d_resource *sub_resource, DWORD location)
{
struct wined3d_surface *surface = surface_from_resource(sub_resource);
surface_validate_location(surface, location);
}
static void texture2d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data)
{
......@@ -1141,7 +1148,6 @@ static const struct wined3d_texture_ops texture2d_ops =
{
texture2d_sub_resource_load,
texture2d_sub_resource_invalidate_location,
texture2d_sub_resource_validate_location,
texture2d_sub_resource_upload_data,
texture2d_load_location,
texture2d_prepare_location,
......@@ -1253,7 +1259,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
wined3d_debug_location(sub_resource->map_binding));
if ((ret = texture->texture_ops->texture_prepare_location(texture,
sub_resource_idx, context, sub_resource->map_binding)))
texture->texture_ops->texture_sub_resource_validate_location(sub_resource, sub_resource->map_binding);
wined3d_texture_validate_location(texture, sub_resource_idx, sub_resource->map_binding);
}
else
{
......@@ -1656,13 +1662,6 @@ static void texture3d_sub_resource_invalidate_location(struct wined3d_resource *
wined3d_volume_invalidate_location(volume, location);
}
static void texture3d_sub_resource_validate_location(struct wined3d_resource *sub_resource, DWORD location)
{
struct wined3d_volume *volume = volume_from_resource(sub_resource);
wined3d_volume_validate_location(volume, location);
}
static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data)
{
......@@ -1736,7 +1735,6 @@ static const struct wined3d_texture_ops texture3d_ops =
{
texture3d_sub_resource_load,
texture3d_sub_resource_invalidate_location,
texture3d_sub_resource_validate_location,
texture3d_sub_resource_upload_data,
texture3d_load_location,
texture3d_prepare_location,
......
......@@ -130,18 +130,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
HeapFree(GetProcessHeap(), 0, converted_mem);
}
void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
TRACE("Volume %p, setting %s.\n", volume, wined3d_debug_location(location));
sub_resource = &volume->container->sub_resources[volume->texture_level];
sub_resource->locations |= location;
TRACE("new location flags are %s.\n", wined3d_debug_location(sub_resource->locations));
}
void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location)
{
struct wined3d_texture_sub_resource *sub_resource;
......@@ -260,10 +248,11 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location)
{
DWORD required_access = volume_access_from_location(location);
unsigned int sub_resource_idx = volume->texture_level;
struct wined3d_texture *texture = volume->container;
struct wined3d_texture_sub_resource *sub_resource;
sub_resource = &texture->sub_resources[volume->texture_level];
sub_resource = &texture->sub_resources[sub_resource_idx];
TRACE("Volume %p, loading %s, have %s.\n", volume, wined3d_debug_location(location),
wined3d_debug_location(sub_resource->locations));
......@@ -371,7 +360,7 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
}
done:
wined3d_volume_validate_location(volume, location);
wined3d_texture_validate_location(texture, sub_resource_idx, location);
if (location != WINED3D_LOCATION_SYSMEM && wined3d_volume_can_evict(volume))
wined3d_volume_evict_sysmem(volume);
......@@ -397,10 +386,11 @@ void wined3d_volume_cleanup(struct wined3d_volume *volume)
static void volume_unload(struct wined3d_resource *resource)
{
struct wined3d_volume *volume = volume_from_resource(resource);
struct wined3d_device *device = volume->resource.device;
struct wined3d_texture *texture = volume->container;
struct wined3d_device *device = texture->resource.device;
struct wined3d_context *context;
if (volume->resource.pool == WINED3D_POOL_DEFAULT)
if (texture->resource.pool == WINED3D_POOL_DEFAULT)
ERR("Unloading DEFAULT pool volume.\n");
TRACE("texture %p.\n", resource);
......@@ -413,7 +403,7 @@ static void volume_unload(struct wined3d_resource *resource)
else
{
ERR("Out of memory when unloading volume %p.\n", volume);
wined3d_volume_validate_location(volume, WINED3D_LOCATION_DISCARDED);
wined3d_texture_validate_location(texture, volume->texture_level, WINED3D_LOCATION_DISCARDED);
wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_DISCARDED);
}
context_release(context);
......
......@@ -2369,7 +2369,6 @@ struct wined3d_texture_ops
void (*texture_sub_resource_load)(struct wined3d_resource *sub_resource,
struct wined3d_context *context, BOOL srgb);
void (*texture_sub_resource_invalidate_location)(struct wined3d_resource *sub_resource, DWORD location);
void (*texture_sub_resource_validate_location)(struct wined3d_resource *sub_resource, DWORD location);
void (*texture_sub_resource_upload_data)(struct wined3d_resource *sub_resource,
const struct wined3d_context *context, const struct wined3d_sub_resource_data *data);
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
......@@ -2496,6 +2495,8 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void wined3d_texture_validate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
#define WINED3D_LOCATION_DISCARDED 0x00000001
#define WINED3D_LOCATION_SYSMEM 0x00000002
......@@ -2533,7 +2534,6 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
BOOL wined3d_volume_prepare_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN;
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,
const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
......@@ -2662,7 +2662,6 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target,
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point,
BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
......
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