Module: wine Branch: master Commit: 6256956a4188c2d291dd6c9d236cce904a3374b9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6256956a4188c2d291dd6c9d23...
Author: Józef Kucia jkucia@codeweavers.com Date: Fri Mar 3 01:30:32 2017 +0100
wined3d: Implement UAV counters.
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
---
dlls/wined3d/context.c | 3 +++ dlls/wined3d/view.c | 46 ++++++++++++++++++++++++++---------------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 10a7222..784307c 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3476,6 +3476,9 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE, view->format->glInternal)); + + if (view->counter_bo) + GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo)); } checkGLcall("Bind unordered access views"); } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index d0d90b2..ff31de2 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -206,19 +206,15 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target context_release(context); }
-static void create_buffer_texture(struct wined3d_gl_view *view, +static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_context *context, struct wined3d_buffer *buffer, const struct wined3d_format *view_format, unsigned int offset, unsigned int size) { - const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; + const struct wined3d_gl_info *gl_info = context->gl_info;
- context = context_acquire(buffer->resource.device, NULL, 0); - gl_info = context->gl_info; if (!gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) { FIXME("OpenGL implementation does not support buffer textures.\n"); - context_release(context); return; }
@@ -226,7 +222,6 @@ static void create_buffer_texture(struct wined3d_gl_view *view, { FIXME("Buffer offset %u is not %u byte aligned.\n", offset, gl_info->limits.texture_buffer_offset_alignment); - context_release(context); return; }
@@ -251,11 +246,9 @@ static void create_buffer_texture(struct wined3d_gl_view *view,
context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING); context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); - - context_release(context); }
-static void create_buffer_view(struct wined3d_gl_view *view, +static void create_buffer_view(struct wined3d_gl_view *view, struct wined3d_context *context, const struct wined3d_view_desc *desc, struct wined3d_buffer *buffer, const struct wined3d_format *view_format) { @@ -272,7 +265,7 @@ static void create_buffer_view(struct wined3d_gl_view *view, size = desc->u.buffer.count * view_format->byte_count; }
- create_buffer_texture(view, buffer, view_format, offset, size); + create_buffer_texture(view, context, buffer, view_format, offset, size); }
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view) @@ -563,8 +556,11 @@ static void wined3d_shader_resource_view_cs_init(void *object) if (resource->type == WINED3D_RTYPE_BUFFER) { struct wined3d_buffer *buffer = buffer_from_resource(resource); + struct wined3d_context *context;
- create_buffer_view(&view->gl_view, desc, buffer, view_format); + context = context_acquire(resource->device, NULL, 0); + create_buffer_view(&view->gl_view, context, desc, buffer, view_format); + context_release(context); } else { @@ -675,15 +671,18 @@ static void wined3d_unordered_access_view_destroy_object(void *object) { struct wined3d_unordered_access_view *view = object;
- if (view->gl_view.name) + if (view->gl_view.name || view->counter_bo) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context;
context = context_acquire(view->resource->device, NULL, 0); gl_info = context->gl_info; - gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->gl_view.name); - checkGLcall("glDeleteTextures"); + if (view->gl_view.name) + gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->gl_view.name); + if (view->counter_bo) + GL_EXTCALL(glDeleteBuffers(1, &view->counter_bo)); + checkGLcall("delete resources"); context_release(context); }
@@ -751,8 +750,21 @@ static void wined3d_unordered_access_view_cs_init(void *object) if (resource->type == WINED3D_RTYPE_BUFFER) { struct wined3d_buffer *buffer = buffer_from_resource(resource); + struct wined3d_context *context;
- create_buffer_view(&view->gl_view, desc, buffer, view->format); + context = context_acquire(resource->device, NULL, 0); + gl_info = context->gl_info; + create_buffer_view(&view->gl_view, context, desc, buffer, view->format); + if (desc->flags & WINED3D_VIEW_BUFFER_COUNTER) + { + static const GLuint initial_value = 0; + GL_EXTCALL(glGenBuffers(1, &view->counter_bo)); + GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo)); + GL_EXTCALL(glBufferData(GL_ATOMIC_COUNTER_BUFFER, + sizeof(initial_value), &initial_value, GL_STATIC_DRAW)); + checkGLcall("create atomic counter buffer"); + } + context_release(context); } else { @@ -784,7 +796,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces return E_INVALIDARG; view->desc = *desc;
- if (desc->flags & (WINED3D_VIEW_BUFFER_APPEND | WINED3D_VIEW_BUFFER_COUNTER)) + if (desc->flags & WINED3D_VIEW_BUFFER_APPEND) FIXME("Unhandled view flags %#x.\n", desc->flags);
wined3d_resource_incref(view->resource = resource); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 101fe90..d329f11 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3410,6 +3410,7 @@ struct wined3d_unordered_access_view struct wined3d_view_desc desc;
struct wined3d_gl_view gl_view; + GLuint counter_bo; };
void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,