diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 2bdfff7c1b0..79ee68c177a 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -133,7 +133,9 @@ 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->bo.binding, buffer_gl->bo.id); + const struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(buffer_gl->b.buffer_object); + + wined3d_context_gl_bind_bo(context_gl, bo_gl->binding, bo_gl->id); } static GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info, uint32_t bind_flags) @@ -225,7 +227,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf return FALSE; } - list_add_head(&buffer_gl->bo.b.users, &buffer_gl->b.bo_user.entry); + list_add_head(&bo->b.users, &buffer_gl->b.bo_user.entry); buffer_gl->b.buffer_object = &bo->b; buffer_invalidate_bo_range(&buffer_gl->b, 0, 0); @@ -1333,6 +1335,7 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); + struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(buffer->buffer_object); struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer); const struct wined3d_gl_info *gl_info = context_gl->gl_info; const struct wined3d_range *range; @@ -1345,10 +1348,10 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc while (range_count--) { range = &ranges[range_count]; - GL_EXTCALL(glBufferSubData(buffer_gl->bo.binding, + GL_EXTCALL(glBufferSubData(bo_gl->binding, range->offset, range->size, (BYTE *)data + range->offset - data_offset)); } - wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo); + wined3d_context_gl_reference_bo(context_gl, bo_gl); checkGLcall("buffer upload"); } @@ -1357,6 +1360,7 @@ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, str void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); + struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(buffer->buffer_object); struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer); const struct wined3d_gl_info *gl_info = context_gl->gl_info; const struct wined3d_range *range; @@ -1369,7 +1373,7 @@ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, str while (range_count--) { range = &ranges[range_count]; - GL_EXTCALL(glGetBufferSubData(buffer_gl->bo.binding, + GL_EXTCALL(glGetBufferSubData(bo_gl->binding, range->offset, range->size, (BYTE *)data + range->offset - data_offset)); } checkGLcall("buffer download"); diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index d63b928ca70..210d8e0b925 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -4335,12 +4335,12 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state if (parameters->indirect) { const struct wined3d_indirect_dispatch_parameters *indirect = ¶meters->u.indirect; - struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(indirect->buffer); + struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(indirect->buffer->buffer_object); - GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer_gl->bo.id)); + GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, bo_gl->id)); GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset)); GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0)); - wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo); + wined3d_context_gl_reference_bo(context_gl, bo_gl); } else { @@ -4721,8 +4721,8 @@ static void draw_primitive_immediate_mode(struct wined3d_context_gl *context_gl, static void wined3d_context_gl_draw_indirect(struct wined3d_context_gl *context_gl, const struct wined3d_state *state, const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size) { + struct wined3d_bo_gl *bo_gl = wined3d_bo_gl(parameters->buffer->buffer_object); GLenum gl_primitive_type = gl_primitive_type_from_d3d(state->primitive_type); - struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(parameters->buffer); const struct wined3d_gl_info *gl_info = context_gl->gl_info; const void *offset; @@ -4732,7 +4732,7 @@ static void wined3d_context_gl_draw_indirect(struct wined3d_context_gl *context_ return; } - GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_gl->bo.id)); + GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, bo_gl->id)); offset = (void *)(GLintptr)parameters->offset; if (idx_size) @@ -4748,7 +4748,7 @@ static void wined3d_context_gl_draw_indirect(struct wined3d_context_gl *context_ } GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0)); - wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo); + wined3d_context_gl_reference_bo(context_gl, bo_gl); checkGLcall("draw indirect"); } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 5e41f681c75..21b5ba1d032 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4465,7 +4465,7 @@ 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; - struct wined3d_buffer_gl *buffer_gl; + struct wined3d_buffer *buffer; if (!state->index_buffer || !stream_info->all_vbo) { @@ -4473,9 +4473,16 @@ static void indexbuffer(struct wined3d_context *context, const struct wined3d_st return; } - buffer_gl = wined3d_buffer_gl(state->index_buffer); - GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer_gl->bo.id)); - buffer_gl->b.bo_user.valid = true; + buffer = state->index_buffer; + if (buffer->buffer_object) + { + GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, wined3d_bo_gl(buffer->buffer_object)->id)); + buffer->bo_user.valid = true; + } + else + { + GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); + } } static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info) @@ -4568,7 +4575,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; enum wined3d_shader_type shader_type; - struct wined3d_buffer_gl *buffer_gl; + struct wined3d_buffer *buffer; unsigned int i, base, count; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); @@ -4589,10 +4596,10 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state continue; } - buffer_gl = wined3d_buffer_gl(buffer_state->buffer); - GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i, buffer_gl->bo.id, - buffer_state->offset, buffer_state->size)); - buffer_gl->b.bo_user.valid = true; + buffer = buffer_state->buffer; + GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i, + wined3d_bo_gl(buffer->buffer_object)->id, buffer_state->offset, buffer_state->size)); + buffer->bo_user.valid = true; } checkGLcall("bind constant buffers"); } @@ -4642,7 +4649,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - struct wined3d_buffer_gl *buffer_gl; + struct wined3d_buffer *buffer; unsigned int offset, size, i; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); @@ -4657,16 +4664,17 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state continue; } - buffer_gl = wined3d_buffer_gl(state->stream_output[i].buffer); + buffer = state->stream_output[i].buffer; offset = state->stream_output[i].offset; if (offset == ~0u) { FIXME("Appending to stream output buffers not implemented.\n"); offset = 0; } - size = buffer_gl->b.resource.size - offset; - GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, buffer_gl->bo.id, offset, size)); - buffer_gl->b.bo_user.valid = true; + size = buffer->resource.size - offset; + GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, + wined3d_bo_gl(buffer->buffer_object)->id, offset, size)); + buffer->bo_user.valid = true; } checkGLcall("bind transform feedback buffers"); } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 8746d9168c2..cbcfed4a21e 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -245,10 +245,11 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target } static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_context_gl *context_gl, - struct wined3d_buffer_gl *buffer_gl, const struct wined3d_format_gl *view_format_gl, + struct wined3d_buffer *buffer, const struct wined3d_format_gl *view_format_gl, unsigned int offset, unsigned int size) { const struct wined3d_gl_info *gl_info = context_gl->gl_info; + const struct wined3d_bo_gl *bo_gl; if (!gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) { @@ -263,7 +264,8 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c return; } - wined3d_buffer_load_location(&buffer_gl->b, &context_gl->c, WINED3D_LOCATION_BUFFER); + wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER); + bo_gl = wined3d_bo_gl(buffer->buffer_object); view->target = GL_TEXTURE_BUFFER; if (!view->name) @@ -272,13 +274,13 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c wined3d_context_gl_bind_texture(context_gl, GL_TEXTURE_BUFFER, view->name); if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE]) { - GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal, buffer_gl->bo.id, offset, size)); + GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal, bo_gl->id, offset, size)); } else { - if (offset || size != buffer_gl->b.resource.size) + 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, buffer_gl->bo.id)); + GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format_gl->internal, bo_gl->id)); } checkGLcall("Create buffer texture"); @@ -309,8 +311,7 @@ static void create_buffer_view(struct wined3d_gl_view *view, struct wined3d_cont unsigned int offset, size; get_buffer_view_range(buffer, desc, view_format, &offset, &size); - create_buffer_texture(view, wined3d_context_gl(context), - wined3d_buffer_gl(buffer), wined3d_format_gl(view_format), offset, size); + create_buffer_texture(view, wined3d_context_gl(context), buffer, wined3d_format_gl(view_format), offset, size); } static void wined3d_view_invalidate_location(struct wined3d_resource *resource, @@ -976,7 +977,7 @@ static void wined3d_shader_resource_view_gl_cs_init(void *object) context = context_acquire(resource->device, NULL, 0); create_buffer_view(&view_gl->gl_view, context, desc, buffer, view_format); view_gl->bo_user.valid = true; - list_add_head(&wined3d_buffer_gl(buffer)->bo.b.users, &view_gl->bo_user.entry); + list_add_head(&buffer->buffer_object->users, &view_gl->bo_user.entry); context_release(context); } else @@ -1480,8 +1481,9 @@ void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view { const struct wined3d_gl_info *gl_info = context_gl->gl_info; const struct wined3d_format_gl *format_gl; - struct wined3d_buffer_gl *buffer_gl; struct wined3d_resource *resource; + struct wined3d_buffer *buffer; + struct wined3d_bo_gl *bo_gl; unsigned int offset, size; resource = view_gl->v.resource; @@ -1587,15 +1589,16 @@ void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view return; } - buffer_gl = wined3d_buffer_gl(buffer_from_resource(resource)); - wined3d_buffer_load_location(&buffer_gl->b, &context_gl->c, WINED3D_LOCATION_BUFFER); + buffer = buffer_from_resource(resource); + wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER); wined3d_unordered_access_view_invalidate_location(&view_gl->v, ~WINED3D_LOCATION_BUFFER); - get_buffer_view_range(&buffer_gl->b, &view_gl->v.desc, &format_gl->f, &offset, &size); - wined3d_context_gl_bind_bo(context_gl, buffer_gl->bo.binding, buffer_gl->bo.id); - GL_EXTCALL(glClearBufferSubData(buffer_gl->bo.binding, format_gl->internal, + 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, offset, size, format_gl->format, format_gl->type, clear_value)); - wined3d_context_gl_reference_bo(context_gl, &buffer_gl->bo); + wined3d_context_gl_reference_bo(context_gl, bo_gl); checkGLcall("clear unordered access view"); } @@ -1662,7 +1665,7 @@ static void wined3d_unordered_access_view_gl_cs_init(void *object) context_gl = wined3d_context_gl(context_acquire(resource->device, NULL, 0)); create_buffer_view(&view_gl->gl_view, &context_gl->c, desc, buffer, view_gl->v.format); view_gl->bo_user.valid = true; - list_add_head(&wined3d_buffer_gl(buffer)->bo.b.users, &view_gl->bo_user.entry); + list_add_head(&buffer->buffer_object->users, &view_gl->bo_user.entry); if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND)) { struct wined3d_bo_gl *bo = &view_gl->counter_bo;