wined3d: Add support for initial UAV counters values.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-08-04 19:53:50 +02:00 committed by Alexandre Julliard
parent be3baca9a6
commit e7f1559a8d
8 changed files with 52 additions and 37 deletions

View File

@ -661,27 +661,21 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnord
wined3d_mutex_lock();
for (i = 0; i < unordered_access_view_start_slot; ++i)
{
wined3d_device_set_unordered_access_view(device->wined3d_device, i, NULL);
wined3d_device_set_unordered_access_view(device->wined3d_device, i, NULL, ~0u);
}
for (i = 0; i < unordered_access_view_count; ++i)
{
struct d3d11_unordered_access_view *view
= unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_views[i]);
if (initial_counts && view && view->desc.ViewDimension == D3D11_UAV_DIMENSION_BUFFER
&& (view->desc.u.Buffer.Flags & (D3D11_BUFFER_UAV_FLAG_APPEND | D3D11_BUFFER_UAV_FLAG_COUNTER))
&& initial_counts[i] != ~(UINT)0)
FIXME("Ignoring initial count %u for slot %u.\n",
initial_counts[i], unordered_access_view_start_slot + i);
wined3d_device_set_unordered_access_view(device->wined3d_device,
unordered_access_view_start_slot + i,
view ? view->wined3d_view : NULL);
view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u);
}
for (; unordered_access_view_start_slot + i < D3D11_PS_CS_UAV_REGISTER_COUNT; ++i)
{
wined3d_device_set_unordered_access_view(device->wined3d_device,
unordered_access_view_start_slot + i, NULL);
unordered_access_view_start_slot + i, NULL, ~0u);
}
wined3d_mutex_unlock();
}
@ -1333,13 +1327,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(
{
struct d3d11_unordered_access_view *view = unsafe_impl_from_ID3D11UnorderedAccessView(views[i]);
if (initial_counts && view && view->desc.ViewDimension == D3D11_UAV_DIMENSION_BUFFER
&& (view->desc.u.Buffer.Flags & (D3D11_BUFFER_UAV_FLAG_APPEND | D3D11_BUFFER_UAV_FLAG_COUNTER))
&& initial_counts[i] != ~(UINT)0)
FIXME("Ignoring initial count %u for slot %u.\n", initial_counts[i], start_slot + i);
wined3d_device_set_cs_uav(device->wined3d_device, start_slot + i,
view ? view->wined3d_view : NULL);
view ? view->wined3d_view : NULL, initial_counts ? initial_counts[i] : ~0u);
}
wined3d_mutex_unlock();
}
@ -2481,8 +2470,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon
wined3d_device_set_depth_stencil_view(device->wined3d_device, NULL);
for (i = 0; i < D3D11_PS_CS_UAV_REGISTER_COUNT; ++i)
{
wined3d_device_set_unordered_access_view(device->wined3d_device, i, NULL);
wined3d_device_set_cs_uav(device->wined3d_device, i, NULL);
wined3d_device_set_unordered_access_view(device->wined3d_device, i, NULL, ~0u);
wined3d_device_set_cs_uav(device->wined3d_device, i, NULL, ~0u);
}
ID3D11DeviceContext_OMSetDepthStencilState(iface, NULL, 0);
ID3D11DeviceContext_OMSetBlendState(iface, NULL, blend_factor, D3D11_DEFAULT_SAMPLE_MASK);

View File

@ -17971,7 +17971,7 @@ static void test_uav_counters(void)
data = 8;
ID3D11DeviceContext_CSSetUnorderedAccessViews(context, 0, 1, &uav, &data);
data = read_uav_counter(context, staging_buffer, uav);
todo_wine ok(data == 8, "Got unexpected value %u.\n", data);
ok(data == 8, "Got unexpected value %u.\n", data);
ID3D11DeviceContext_CSSetShader(context, cs_producer, NULL, 0);
data = 0;
@ -18019,20 +18019,20 @@ static void test_uav_counters(void)
data = 8;
ID3D11DeviceContext_CSSetUnorderedAccessViews(context, 0, 1, &uav, &data);
data = read_uav_counter(context, staging_buffer, uav);
todo_wine ok(data == 8, "Got unexpected value %u.\n", data);
ok(data == 8, "Got unexpected value %u.\n", data);
/* consume */
ID3D11DeviceContext_Dispatch(context, 1, 1, 1);
data = read_uav_counter(context, staging_buffer, uav);
todo_wine ok(data == 4, "Got unexpected value %u.\n", data);
ok(data == 4, "Got unexpected value %u.\n", data);
ID3D11DeviceContext_Dispatch(context, 1, 1, 1);
data = read_uav_counter(context, staging_buffer, uav);
todo_wine ok(!data, "Got unexpected value %u.\n", data);
ok(!data, "Got unexpected value %u.\n", data);
get_buffer_readback(buffer2, &rb);
for (i = 0; i < 8; ++i)
{
data = get_readback_color(&rb, i, 0);
todo_wine ok(data == 0xdeadbeef, "Got data %u at %u.\n", data, i);
ok(data == 0xdeadbeef, "Got data %u at %u.\n", data, i);
}
release_resource_readback(&rb);

View File

@ -244,6 +244,7 @@ struct wined3d_cs_set_unordered_access_view
enum wined3d_pipeline pipeline;
unsigned int view_idx;
struct wined3d_unordered_access_view *view;
unsigned int initial_count;
};
struct wined3d_cs_set_sampler
@ -1293,10 +1294,13 @@ static void wined3d_cs_exec_set_unordered_access_view(struct wined3d_cs *cs, con
InterlockedDecrement(&prev->resource->bind_count);
device_invalidate_state(cs->device, STATE_UNORDERED_ACCESS_VIEW_BINDING(op->pipeline));
if (op->initial_count != ~0u)
wined3d_unordered_access_view_set_counter(op->view, op->initial_count);
}
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
unsigned int view_idx, struct wined3d_unordered_access_view *view)
unsigned int view_idx, struct wined3d_unordered_access_view *view, unsigned int initial_count)
{
struct wined3d_cs_set_unordered_access_view *op;
@ -1305,6 +1309,7 @@ void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined
op->pipeline = pipeline;
op->view_idx = view_idx;
op->view = view;
op->initial_count = initial_count;
cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT);
}

View File

@ -2950,7 +2950,8 @@ struct wined3d_sampler * CDECL wined3d_device_get_cs_sampler(const struct wined3
}
static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_device *device,
enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav)
enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav,
unsigned int initial_count)
{
struct wined3d_unordered_access_view *prev;
@ -2961,14 +2962,14 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev
}
prev = device->update_state->unordered_access_view[pipeline][idx];
if (uav == prev)
if (uav == prev && initial_count == ~0u)
return;
if (uav)
wined3d_unordered_access_view_incref(uav);
device->update_state->unordered_access_view[pipeline][idx] = uav;
if (!device->recording)
wined3d_cs_emit_set_unordered_access_view(device->cs, pipeline, idx, uav);
wined3d_cs_emit_set_unordered_access_view(device->cs, pipeline, idx, uav, initial_count);
if (prev)
wined3d_unordered_access_view_decref(prev);
}
@ -2986,11 +2987,11 @@ static struct wined3d_unordered_access_view *wined3d_device_get_pipeline_unorder
}
void CDECL wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx,
struct wined3d_unordered_access_view *uav)
struct wined3d_unordered_access_view *uav, unsigned int initial_count)
{
TRACE("device %p, idx %u, uav %p.\n", device, idx, uav);
TRACE("device %p, idx %u, uav %p, initial_count %#x.\n", device, idx, uav, initial_count);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_COMPUTE, idx, uav);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_COMPUTE, idx, uav, initial_count);
}
struct wined3d_unordered_access_view * CDECL wined3d_device_get_cs_uav(const struct wined3d_device *device,
@ -3002,11 +3003,11 @@ struct wined3d_unordered_access_view * CDECL wined3d_device_get_cs_uav(const str
}
void CDECL wined3d_device_set_unordered_access_view(struct wined3d_device *device,
unsigned int idx, struct wined3d_unordered_access_view *uav)
unsigned int idx, struct wined3d_unordered_access_view *uav, unsigned int initial_count)
{
TRACE("device %p, idx %u, uav %p.\n", device, idx, uav);
TRACE("device %p, idx %u, uav %p, initial_count %#x.\n", device, idx, uav, initial_count);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_GRAPHICS, idx, uav);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_GRAPHICS, idx, uav, initial_count);
}
struct wined3d_unordered_access_view * CDECL wined3d_device_get_unordered_access_view(

View File

@ -898,6 +898,23 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
checkGLcall("clear unordered access view");
}
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
unsigned int value)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
if (!view->counter_bo)
return;
context = context_acquire(view->resource->device, NULL, 0);
gl_info = context->gl_info;
GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo));
GL_EXTCALL(glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(value), &value));
checkGLcall("set atomic counter");
context_release(context);
}
void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context)
{

View File

@ -130,7 +130,7 @@
@ cdecl wined3d_device_set_cs_cb(ptr long ptr)
@ cdecl wined3d_device_set_cs_resource_view(ptr long ptr)
@ cdecl wined3d_device_set_cs_sampler(ptr long ptr)
@ cdecl wined3d_device_set_cs_uav(ptr long ptr)
@ cdecl wined3d_device_set_cs_uav(ptr long ptr long)
@ cdecl wined3d_device_set_cursor_position(ptr long long long)
@ cdecl wined3d_device_set_cursor_properties(ptr long long ptr long)
@ cdecl wined3d_device_set_depth_stencil_view(ptr ptr)
@ -175,7 +175,7 @@
@ cdecl wined3d_device_set_texture(ptr long ptr)
@ cdecl wined3d_device_set_texture_stage_state(ptr long long long)
@ cdecl wined3d_device_set_transform(ptr long ptr)
@ cdecl wined3d_device_set_unordered_access_view(ptr long ptr)
@ cdecl wined3d_device_set_unordered_access_view(ptr long ptr long)
@ cdecl wined3d_device_set_vertex_declaration(ptr ptr)
@ cdecl wined3d_device_set_vertex_shader(ptr ptr)
@ cdecl wined3d_device_set_viewport(ptr ptr)

View File

@ -3481,7 +3481,8 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
unsigned int view_idx, struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
unsigned int view_idx, struct wined3d_unordered_access_view *view,
unsigned int initial_count) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;
@ -3654,6 +3655,8 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_
struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
DWORD location) DECLSPEC_HIDDEN;
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
unsigned int value) DECLSPEC_HIDDEN;
struct wined3d_swapchain_ops
{

View File

@ -2349,7 +2349,7 @@ void __cdecl wined3d_device_set_cs_resource_view(struct wined3d_device *device,
void __cdecl wined3d_device_set_cs_sampler(struct wined3d_device *device,
unsigned int idx, struct wined3d_sampler *sampler);
void __cdecl wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx,
struct wined3d_unordered_access_view *uav);
struct wined3d_unordered_access_view *uav, unsigned int initial_count);
void __cdecl wined3d_device_set_cursor_position(struct wined3d_device *device,
int x_screen_space, int y_screen_space, DWORD flags);
HRESULT __cdecl wined3d_device_set_cursor_properties(struct wined3d_device *device,
@ -2420,7 +2420,7 @@ void __cdecl wined3d_device_set_texture_stage_state(struct wined3d_device *devic
void __cdecl wined3d_device_set_transform(struct wined3d_device *device,
enum wined3d_transform_state state, const struct wined3d_matrix *matrix);
void __cdecl wined3d_device_set_unordered_access_view(struct wined3d_device *device,
unsigned int idx, struct wined3d_unordered_access_view *uav);
unsigned int idx, struct wined3d_unordered_access_view *uav, unsigned int initial_count);
void __cdecl wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration *declaration);
void __cdecl wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader);