Commit d163ef08 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Do not load UAV locations when clearing if not necessary.

Don't load the buffer location if we are clearing the whole buffer, and never load the texture location (for Vulkan; GL already did this). Only prepare them instead.
parent 9373cd5e
......@@ -103,7 +103,7 @@ static BOOL buffer_is_fully_dirty(const struct wined3d_buffer *buffer)
&& !buffer->maps->offset && buffer->maps->size == buffer->resource.size;
}
static void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, DWORD location)
void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location)
{
TRACE("buffer %p, location %s.\n", buffer, wined3d_debug_location(location));
......
......@@ -1657,11 +1657,15 @@ void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view
}
buffer = buffer_from_resource(resource);
wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER);
get_buffer_view_range(buffer, &view_gl->v.desc, &format_gl->f, &offset, &size);
if (!offset && size == buffer->resource.size)
wined3d_buffer_prepare_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER);
else
wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER);
wined3d_unordered_access_view_invalidate_location(&view_gl->v, ~WINED3D_LOCATION_BUFFER);
bo_gl = wined3d_bo_gl(buffer->buffer_object);
get_buffer_view_range(buffer, &view_gl->v.desc, &format_gl->f, &offset, &size);
wined3d_context_gl_bind_bo(context_gl, bo_gl->binding, bo_gl->id);
GL_EXTCALL(glClearBufferSubData(bo_gl->binding, format_gl->internal,
bo_gl->b.buffer_offset + offset, size, format_gl->format, format_gl->type, clear_value));
......@@ -1979,8 +1983,6 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
struct wined3d_range range;
VkMemoryBarrier vk_barrier;
VkPipeline vk_pipeline;
DWORD uav_location;
unsigned int level;
bool is_array;
device_vk = wined3d_device_vk(device);
......@@ -2048,8 +2050,8 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
if (resource->type == WINED3D_RTYPE_BUFFER)
{
struct wined3d_buffer *buffer = buffer_from_resource(resource);
unsigned int offset, size;
uav_location = WINED3D_LOCATION_BUFFER;
layout = state->buffer_layout;
vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
......@@ -2058,19 +2060,53 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
else
constants.extent.width = view_desc->u.buffer.count;
constants.extent.height = 1;
get_buffer_view_range(buffer, view_desc, view_format, &offset, &size);
if (!offset && size == buffer->resource.size)
wined3d_buffer_prepare_location(buffer, &context_vk->c, WINED3D_LOCATION_BUFFER);
else
wined3d_buffer_load_location(buffer, &context_vk->c, WINED3D_LOCATION_BUFFER);
wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_BUFFER);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER);
}
else
{
unsigned int layer_count, level_count, base_level, base_layer, i, j;
texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(resource));
uav_location = WINED3D_LOCATION_TEXTURE_RGB;
layout = state->image_layout;
vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
level = view_desc->u.texture.level_idx;
constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, level);
constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, level);
level_count = view_desc->u.texture.level_count;
base_level = view_desc->u.texture.level_idx;
if (resource->type == WINED3D_RTYPE_TEXTURE_3D)
{
layer_count = 1;
base_layer = 0;
}
else
{
layer_count = view_desc->u.texture.layer_count;
base_layer = view_desc->u.texture.layer_idx;
}
constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, base_level);
constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, base_level);
group_count.z = (view_desc->u.texture.layer_count + group_count.z - 1) / group_count.z;
for (i = 0; i < layer_count; ++i)
{
for (j = 0; j < level_count; ++j)
{
unsigned int sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j;
wined3d_texture_prepare_location(&texture_vk->t, sub_resource_idx,
&context_vk->c, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
}
}
}
group_count.x = (constants.extent.width + group_count.x - 1) / group_count.x;
......@@ -2108,9 +2144,6 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
return;
}
wined3d_view_load_location(resource, view_desc, &context_vk->c, uav_location);
wined3d_unordered_access_view_invalidate_location(&view_vk->v, ~uav_location);
if (resource->type == WINED3D_RTYPE_BUFFER)
{
if (format_id == view_format->id)
......
......@@ -4566,6 +4566,7 @@ BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN;
void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context,
const struct upload_bo *upload_bo, unsigned int offset, unsigned int size) DECLSPEC_HIDDEN;
void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location) DECLSPEC_HIDDEN;
HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
......
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