wined3d: Move the "buffer_object" field from struct wined3d_buffer_gl to struct wined3d_buffer.

We'll want to use this for Vulkan buffers as well.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2019-09-23 14:54:17 +03:30 committed by Alexandre Julliard
parent c2f0ae50b4
commit 179c8cc86f
6 changed files with 26 additions and 29 deletions

View File

@ -4675,7 +4675,7 @@ static void wined3d_buffer_gl_destroy_object(void *object)
struct wined3d_buffer_gl *buffer_gl = object;
struct wined3d_context *context;
if (buffer_gl->buffer_object)
if (buffer_gl->b.buffer_object)
{
context = context_acquire(buffer_gl->b.resource.device, NULL, 0);
wined3d_buffer_gl_destroy_buffer_object(buffer_gl, wined3d_context_gl(context));

View File

@ -135,7 +135,7 @@ void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD loc
/* Context activation is done by the caller. */
static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct wined3d_context_gl *context_gl)
{
wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->buffer_object);
wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->b.buffer_object);
}
/* Context activation is done by the caller. */
@ -144,8 +144,9 @@ void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl
{
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
struct wined3d_resource *resource = &buffer_gl->b.resource;
GLuint bo;
if (!buffer_gl->buffer_object)
if (!buffer_gl->b.buffer_object)
return;
/* The stream source state handler might have read the memory of the
@ -182,9 +183,10 @@ void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl
}
}
GL_EXTCALL(glDeleteBuffers(1, &buffer_gl->buffer_object));
bo = buffer_gl->b.buffer_object;
GL_EXTCALL(glDeleteBuffers(1, &bo));
checkGLcall("glDeleteBuffers");
buffer_gl->buffer_object = 0;
buffer_gl->b.buffer_object = 0;
if (buffer_gl->b.fence)
{
@ -201,6 +203,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
GLenum gl_usage = GL_STATIC_DRAW;
GLenum error;
GLuint bo;
TRACE("Creating an OpenGL buffer object for wined3d buffer %p with usage %s.\n",
buffer_gl, debug_d3dusage(buffer_gl->b.resource.usage));
@ -218,9 +221,10 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf
* to be verified to check if the rhw and color values are in the correct
* format. */
GL_EXTCALL(glGenBuffers(1, &buffer_gl->buffer_object));
GL_EXTCALL(glGenBuffers(1, &bo));
buffer_gl->b.buffer_object = bo;
error = gl_info->gl_ops.gl.p_glGetError();
if (!buffer_gl->buffer_object || error != GL_NO_ERROR)
if (!buffer_gl->b.buffer_object || error != GL_NO_ERROR)
{
ERR("Failed to create a BO with error %s (%#x).\n", debug_glerror(error), error);
goto fail;
@ -678,7 +682,7 @@ DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
if (locations & WINED3D_LOCATION_BUFFER)
{
data->buffer_object = wined3d_buffer_gl(buffer)->buffer_object;
data->buffer_object = buffer->buffer_object;
data->addr = NULL;
return WINED3D_LOCATION_BUFFER;
}
@ -701,7 +705,7 @@ static void buffer_unload(struct wined3d_resource *resource)
TRACE("buffer %p.\n", buffer);
if (wined3d_buffer_gl(buffer)->buffer_object)
if (buffer->buffer_object)
{
struct wined3d_context *context;
@ -969,7 +973,7 @@ static HRESULT wined3d_buffer_gl_map(struct wined3d_buffer_gl *buffer_gl,
count = ++buffer_gl->b.resource.map_count;
if (buffer_gl->buffer_object)
if (buffer_gl->b.buffer_object)
{
unsigned int dirty_offset = offset, dirty_size = size;
@ -1466,7 +1470,7 @@ static BOOL wined3d_buffer_gl_prepare_location(struct wined3d_buffer *buffer,
return wined3d_resource_prepare_sysmem(&buffer->resource);
case WINED3D_LOCATION_BUFFER:
if (buffer_gl->buffer_object)
if (buffer->buffer_object)
return TRUE;
if (!(buffer->flags & WINED3D_BUFFER_USE_BO))

View File

@ -4339,7 +4339,7 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state
const struct wined3d_indirect_dispatch_parameters *indirect = &parameters->u.indirect;
struct wined3d_buffer *buffer = indirect->buffer;
GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, wined3d_buffer_gl(buffer)->buffer_object));
GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer->buffer_object));
GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset));
GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0));
}
@ -4732,7 +4732,7 @@ static void wined3d_context_gl_draw_indirect(struct wined3d_context_gl *context_
return;
}
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, wined3d_buffer_gl(buffer)->buffer_object));
GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer->buffer_object));
offset = (void *)(GLintptr)parameters->offset;
if (idx_size)
@ -4898,7 +4898,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (parameters->indexed)
{
struct wined3d_buffer *index_buffer = state->index_buffer;
if (!wined3d_buffer_gl(index_buffer)->buffer_object || !stream_info->all_vbo)
if (!index_buffer->buffer_object || !stream_info->all_vbo)
{
idx_data = index_buffer->resource.heap_memory;
}

View File

@ -4292,16 +4292,12 @@ static void indexbuffer(struct wined3d_context *context, const struct wined3d_st
{
const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
const struct wined3d_stream_info *stream_info = &context->stream_info;
const struct wined3d_buffer *ib = state->index_buffer;
if (!state->index_buffer || !stream_info->all_vbo)
{
if (!ib || !stream_info->all_vbo)
GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
}
else
{
struct wined3d_buffer_gl *ib = wined3d_buffer_gl(state->index_buffer);
GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ib->buffer_object));
}
}
static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
@ -4400,8 +4396,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
for (i = 0; i < count; ++i)
{
buffer = state->cb[shader_type][i];
GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i,
buffer ? wined3d_buffer_gl(buffer)->buffer_object : 0));
GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER, base + i, buffer ? buffer->buffer_object : 0));
}
checkGLcall("bind constant buffers");
}
@ -4473,8 +4468,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
offset = 0;
}
size = buffer->resource.size - offset;
GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i,
wined3d_buffer_gl(buffer)->buffer_object, offset, size));
GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, buffer->buffer_object, offset, size));
}
checkGLcall("bind transform feedback buffers");
}

View File

@ -275,14 +275,13 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
{
GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal,
wined3d_buffer_gl(buffer)->buffer_object, offset, size));
buffer->buffer_object, offset, size));
}
else
{
if (offset || size != buffer->resource.size)
FIXME("OpenGL implementation does not support ARB_texture_buffer_range.\n");
GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format_gl->internal,
wined3d_buffer_gl(buffer)->buffer_object));
GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format_gl->internal, buffer->buffer_object));
}
checkGLcall("Create buffer texture");
@ -1033,7 +1032,7 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
wined3d_unordered_access_view_invalidate_location(view, ~WINED3D_LOCATION_BUFFER);
get_buffer_view_range(&buffer_gl->b, &view->desc, &format->f, &offset, &size);
wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->buffer_object);
wined3d_context_gl_bind_bo(context_gl, buffer_gl->buffer_type_hint, buffer_gl->b.buffer_object);
GL_EXTCALL(glClearBufferSubData(buffer_gl->buffer_type_hint, format->internal,
offset, size, format->format, format->type, clear_value));
checkGLcall("clear unordered access view");

View File

@ -4176,6 +4176,7 @@ struct wined3d_buffer
DWORD flags;
DWORD locations;
void *map_ptr;
uintptr_t buffer_object;
struct wined3d_map_range *maps;
SIZE_T maps_size, modified_areas;
@ -4216,7 +4217,6 @@ struct wined3d_buffer_gl
{
struct wined3d_buffer b;
GLuint buffer_object;
GLenum buffer_object_usage;
GLenum buffer_type_hint;
};