[PATCH 5/5] wined3d: Introduce a separate structure for OpenGL unordered access view information.
Henri Verbeet
hverbeet at codeweavers.com
Tue Nov 13 07:10:18 CST 2018
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/context.c | 21 ++++++++-------
dlls/wined3d/view.c | 61 ++++++++++++++++++++++--------------------
dlls/wined3d/wined3d_private.h | 15 +++++++++--
3 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 2e24c834277..4cd46c66c67 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3875,7 +3875,7 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_unordered_access_view *view;
+ struct wined3d_unordered_access_view_gl *view_gl;
const struct wined3d_format_gl *format_gl;
GLuint texture_name;
unsigned int i;
@@ -3886,7 +3886,7 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
{
- if (!(view = views[i]))
+ if (!views[i])
{
if (shader->reg_maps.uav_resource_info[i].type)
WARN("No unordered access view bound at index %u.\n", i);
@@ -3894,16 +3894,17 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
continue;
}
- if (view->gl_view.name)
+ view_gl = wined3d_unordered_access_view_gl(views[i]);
+ if (view_gl->gl_view.name)
{
- texture_name = view->gl_view.name;
+ texture_name = view_gl->gl_view.name;
level = 0;
}
- else if (view->resource->type != WINED3D_RTYPE_BUFFER)
+ else if (view_gl->v.resource->type != WINED3D_RTYPE_BUFFER)
{
- struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(texture_from_resource(view->resource));
+ struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(texture_from_resource(view_gl->v.resource));
texture_name = wined3d_texture_gl_get_texture_name(texture_gl, context, FALSE);
- level = view->desc.u.texture.level_idx;
+ level = view_gl->v.desc.u.texture.level_idx;
}
else
{
@@ -3912,12 +3913,12 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
continue;
}
- format_gl = wined3d_format_gl(view->format);
+ format_gl = wined3d_format_gl(view_gl->v.format);
GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE,
format_gl->internal));
- if (view->counter_bo)
- GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo));
+ if (view_gl->counter_bo)
+ GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view_gl->counter_bo));
}
checkGLcall("Bind unordered access views");
}
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index 5fff7e749e1..0cfadf7329b 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -968,26 +968,26 @@ ULONG CDECL wined3d_unordered_access_view_incref(struct wined3d_unordered_access
return refcount;
}
-static void wined3d_unordered_access_view_destroy_object(void *object)
+static void wined3d_unordered_access_view_gl_destroy_object(void *object)
{
- struct wined3d_unordered_access_view *view = object;
+ struct wined3d_unordered_access_view_gl *view_gl = object;
- if (view->gl_view.name || view->counter_bo)
+ if (view_gl->gl_view.name || view_gl->counter_bo)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- context = context_acquire(view->resource->device, NULL, 0);
+ context = context_acquire(view_gl->v.resource->device, NULL, 0);
gl_info = context->gl_info;
- 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));
+ if (view_gl->gl_view.name)
+ gl_info->gl_ops.gl.p_glDeleteTextures(1, &view_gl->gl_view.name);
+ if (view_gl->counter_bo)
+ GL_EXTCALL(glDeleteBuffers(1, &view_gl->counter_bo));
checkGLcall("delete resources");
context_release(context);
}
- heap_free(view);
+ heap_free(view_gl);
}
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
@@ -1004,7 +1004,8 @@ ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access
/* Call wined3d_object_destroyed() before releasing the resource,
* since releasing the resource may end up destroying the parent. */
view->parent_ops->wined3d_object_destroyed(view->parent);
- wined3d_cs_destroy_object(device->cs, wined3d_unordered_access_view_destroy_object, view);
+ wined3d_cs_destroy_object(device->cs, wined3d_unordered_access_view_gl_destroy_object,
+ wined3d_unordered_access_view_gl(view));
wined3d_resource_decref(resource);
}
@@ -1069,15 +1070,16 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
unsigned int value)
{
+ struct wined3d_unordered_access_view_gl *view_gl = wined3d_unordered_access_view_gl(view);
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- if (!view->counter_bo)
+ if (!view_gl->counter_bo)
return;
- context = context_acquire(view->resource->device, NULL, 0);
+ context = context_acquire(view_gl->v.resource->device, NULL, 0);
gl_info = context->gl_info;
- GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo));
+ GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view_gl->counter_bo));
GL_EXTCALL(glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(value), &value));
checkGLcall("set atomic counter");
context_release(context);
@@ -1086,16 +1088,17 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v
void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context)
{
+ struct wined3d_unordered_access_view_gl *view_gl = wined3d_unordered_access_view_gl(view);
struct wined3d_bo_address dst, src;
DWORD dst_location;
- if (!view->counter_bo)
+ if (!view_gl->counter_bo)
return;
dst_location = wined3d_buffer_get_memory(buffer, &dst, buffer->locations);
dst.addr += offset;
- src.buffer_object = view->counter_bo;
+ src.buffer_object = view_gl->counter_bo;
src.addr = NULL;
context_copy_bo_address(context, &dst, wined3d_buffer_gl(buffer)->buffer_type_hint,
@@ -1104,11 +1107,11 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_
wined3d_buffer_invalidate_location(buffer, ~dst_location);
}
-static void wined3d_unordered_access_view_cs_init(void *object)
+static void wined3d_unordered_access_view_gl_cs_init(void *object)
{
- struct wined3d_unordered_access_view *view = object;
- struct wined3d_resource *resource = view->resource;
- struct wined3d_view_desc *desc = &view->desc;
+ struct wined3d_unordered_access_view_gl *view_gl = object;
+ struct wined3d_resource *resource = view_gl->v.resource;
+ struct wined3d_view_desc *desc = &view_gl->v.desc;
const struct wined3d_gl_info *gl_info;
gl_info = &resource->device->adapter->gl_info;
@@ -1120,12 +1123,12 @@ static void wined3d_unordered_access_view_cs_init(void *object)
context = context_acquire(resource->device, NULL, 0);
gl_info = context->gl_info;
- create_buffer_view(&view->gl_view, context, desc, buffer, view->format);
+ create_buffer_view(&view_gl->gl_view, context, desc, buffer, view_gl->v.format);
if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND))
{
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(glGenBuffers(1, &view_gl->counter_bo));
+ GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view_gl->counter_bo));
GL_EXTCALL(glBufferData(GL_ATOMIC_COUNTER_BUFFER,
sizeof(initial_value), &initial_value, GL_STATIC_DRAW));
checkGLcall("create atomic counter buffer");
@@ -1144,8 +1147,8 @@ static void wined3d_unordered_access_view_cs_init(void *object)
if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count)
{
- create_texture_view(&view->gl_view, get_texture_view_target(gl_info, desc, texture_gl),
- desc, texture_gl, view->format);
+ create_texture_view(&view_gl->gl_view, get_texture_view_target(gl_info, desc, texture_gl),
+ desc, texture_gl, view_gl->v.format);
}
}
}
@@ -1164,8 +1167,6 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
wined3d_resource_incref(view->resource = resource);
- wined3d_cs_init_object(resource->device->cs, wined3d_unordered_access_view_cs_init, view);
-
return WINED3D_OK;
}
@@ -1173,7 +1174,7 @@ HRESULT CDECL wined3d_unordered_access_view_create(const struct wined3d_view_des
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_unordered_access_view **view)
{
- struct wined3d_unordered_access_view *object;
+ struct wined3d_unordered_access_view_gl *object;
HRESULT hr;
TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
@@ -1182,15 +1183,17 @@ HRESULT CDECL wined3d_unordered_access_view_create(const struct wined3d_view_des
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = wined3d_unordered_access_view_init(object, desc, resource, parent, parent_ops)))
+ if (FAILED(hr = wined3d_unordered_access_view_init(&object->v, desc, resource, parent, parent_ops)))
{
heap_free(object);
WARN("Failed to initialise view, hr %#x.\n", hr);
return hr;
}
+ wined3d_cs_init_object(resource->device->cs, wined3d_unordered_access_view_gl_cs_init, object);
+
TRACE("Created unordered access view %p.\n", object);
- *view = object;
+ *view = &object->v;
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b8b3d55d307..2d2f712d66d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3902,9 +3902,7 @@ struct wined3d_unordered_access_view
void *parent;
const struct wined3d_parent_ops *parent_ops;
- struct wined3d_gl_view gl_view;
const struct wined3d_format *format;
- GLuint counter_bo;
struct wined3d_view_desc desc;
};
@@ -3918,6 +3916,19 @@ void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
unsigned int value) DECLSPEC_HIDDEN;
+struct wined3d_unordered_access_view_gl
+{
+ struct wined3d_unordered_access_view v;
+ struct wined3d_gl_view gl_view;
+ GLuint counter_bo;
+};
+
+static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
+ struct wined3d_unordered_access_view *view)
+{
+ return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
+}
+
struct wined3d_swapchain_ops
{
void (*swapchain_present)(struct wined3d_swapchain *swapchain,
--
2.11.0
More information about the wine-devel
mailing list