Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/context_gl.c | 58 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 30 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index f7d4d9e8cb3..cec698d7a6b 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -5067,6 +5067,12 @@ void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *conte } }
+static const void *get_vertex_attrib_pointer(const struct wined3d_stream_info_element *element, + const struct wined3d_state *state) +{ + return element->data.addr + state->load_base_vertex_index * element->stride; +} + void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl, const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) { @@ -5110,7 +5116,7 @@ void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context /* The coords to supply depend completely on the fvf/vertex shader. */ format_gl = wined3d_format_gl(e->format); gl_info->gl_ops.gl.p_glTexCoordPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); + get_vertex_attrib_pointer(e, state)); gl_info->gl_ops.gl.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY); state->streams[e->stream_idx].buffer->bo_user.valid = true; } @@ -5154,6 +5160,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte const struct wined3d_stream_info_element *e; const struct wined3d_format_gl *format_gl; GLuint current_bo, bo; + const void *offset;
TRACE("context_gl %p, si %p, state %p.\n", context_gl, si, state);
@@ -5184,6 +5191,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte { e = &si->elements[WINED3D_FFP_POSITION]; format_gl = wined3d_format_gl(e->format); + offset = get_vertex_attrib_pointer(e, state);
bo = wined3d_bo_gl_id(e->data.buffer_object); if (current_bo != bo) @@ -5193,11 +5201,8 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte current_bo = bo; }
- TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n", - format_gl->vtx_format, format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - gl_info->gl_ops.gl.p_glVertexPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); + TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n", format_gl->vtx_format, format_gl->vtx_type, e->stride, offset); + gl_info->gl_ops.gl.p_glVertexPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride, offset); checkGLcall("glVertexPointer(...)"); gl_info->gl_ops.gl.p_glEnableClientState(GL_VERTEX_ARRAY); checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)"); @@ -5209,6 +5214,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte { e = &si->elements[WINED3D_FFP_NORMAL]; format_gl = wined3d_format_gl(e->format); + offset = get_vertex_attrib_pointer(e, state);
bo = wined3d_bo_gl_id(e->data.buffer_object); if (current_bo != bo) @@ -5218,10 +5224,8 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte current_bo = bo; }
- TRACE("glNormalPointer(%#x, %#x, %p);\n", format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - gl_info->gl_ops.gl.p_glNormalPointer(format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); + TRACE("glNormalPointer(%#x, %#x, %p);\n", format_gl->vtx_type, e->stride, offset); + gl_info->gl_ops.gl.p_glNormalPointer(format_gl->vtx_type, e->stride, offset); checkGLcall("glNormalPointer(...)"); gl_info->gl_ops.gl.p_glEnableClientState(GL_NORMAL_ARRAY); checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)"); @@ -5238,6 +5242,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte { e = &si->elements[WINED3D_FFP_DIFFUSE]; format_gl = wined3d_format_gl(e->format); + offset = get_vertex_attrib_pointer(e, state);
bo = wined3d_bo_gl_id(e->data.buffer_object); if (current_bo != bo) @@ -5248,10 +5253,8 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte }
TRACE("glColorPointer(%#x, %#x %#x, %p);\n", - format_gl->vtx_format, format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - gl_info->gl_ops.gl.p_glColorPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); + format_gl->vtx_format, format_gl->vtx_type, e->stride, offset); + gl_info->gl_ops.gl.p_glColorPointer(format_gl->vtx_format, format_gl->vtx_type, e->stride, offset); checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)"); gl_info->gl_ops.gl.p_glEnableClientState(GL_COLOR_ARRAY); checkGLcall("glEnableClientState(GL_COLOR_ARRAY)"); @@ -5269,6 +5272,7 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte TRACE("Setting specular colour.\n");
e = &si->elements[WINED3D_FFP_SPECULAR]; + offset = get_vertex_attrib_pointer(e, state);
if (gl_info->supported[EXT_SECONDARY_COLOR]) { @@ -5294,10 +5298,8 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts * 4 component secondary colors use it */ - TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format, type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - GL_EXTCALL(glSecondaryColorPointerEXT(format, type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride)); + TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format, type, e->stride, offset); + GL_EXTCALL(glSecondaryColorPointerEXT(format, type, e->stride, offset)); checkGLcall("glSecondaryColorPointerEXT(format, type, ...)"); } else @@ -5305,20 +5307,16 @@ static void wined3d_context_gl_load_vertex_data(struct wined3d_context_gl *conte switch (type) { case GL_UNSIGNED_BYTE: - TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride)); + TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e->stride, offset); + GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, e->stride, offset)); checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)"); break;
default: FIXME("Add 4 component specular colour pointers for type %#x.\n", type); /* Make sure that the right colour component is dropped. */ - TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride); - GL_EXTCALL(glSecondaryColorPointerEXT(3, type, e->stride, - e->data.addr + state->load_base_vertex_index * e->stride)); + TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type, e->stride, offset); + GL_EXTCALL(glSecondaryColorPointerEXT(3, type, e->stride, offset)); checkGLcall("glSecondaryColorPointerEXT(3, type, ...)"); } } @@ -5388,6 +5386,7 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c for (i = 0; i < MAX_ATTRIBS; ++i) { const struct wined3d_stream_info_element *element = &stream_info->elements[i]; + const void *offset = get_vertex_attrib_pointer(element, state); const struct wined3d_stream_state *stream; const struct wined3d_format_gl *format_gl;
@@ -5460,14 +5459,13 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c * won't be load converted attributes anyway. */ if (vs && vs->reg_maps.shader_version.major >= 4 && (format_flags & WINED3DFMT_FLAG_INTEGER)) { - GL_EXTCALL(glVertexAttribIPointer(i, format_gl->vtx_format, format_gl->vtx_type, - element->stride, element->data.addr + state->load_base_vertex_index * element->stride)); + GL_EXTCALL(glVertexAttribIPointer(i, format_gl->vtx_format, + format_gl->vtx_type, element->stride, offset)); } else { GL_EXTCALL(glVertexAttribPointer(i, format_gl->vtx_format, format_gl->vtx_type, - !!(format_flags & WINED3DFMT_FLAG_NORMALISED), element->stride, - element->data.addr + state->load_base_vertex_index * element->stride)); + !!(format_flags & WINED3DFMT_FLAG_NORMALISED), element->stride, offset)); }
if (!(context->numbered_array_mask & (1u << i)))
From: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/context_gl.c | 7 ++++++- dlls/wined3d/wined3d_private.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index cec698d7a6b..3868351a4b3 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2922,6 +2922,7 @@ bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizei list_init(&bo->b.users); bo->command_fence_id = 0; bo->b.memory_offset = 0; + bo->buffer_offset = 0; bo->b.map_ptr = NULL;
return true; @@ -5070,7 +5071,11 @@ void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *conte static const void *get_vertex_attrib_pointer(const struct wined3d_stream_info_element *element, const struct wined3d_state *state) { - return element->data.addr + state->load_base_vertex_index * element->stride; + const uint8_t *offset = element->data.addr + state->load_base_vertex_index * element->stride; + + if (element->data.buffer_object) + offset += wined3d_bo_gl(element->data.buffer_object)->buffer_offset; + return offset; }
void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 90824d83290..79b02c2448d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1606,6 +1606,7 @@ struct wined3d_bo_gl struct wined3d_bo b;
GLuint id; + GLsizeiptr buffer_offset; GLsizeiptr size; GLenum binding; GLenum usage;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/context_gl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 3868351a4b3..5767258973d 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -4909,10 +4909,12 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s if (parameters->indexed) { struct wined3d_buffer *index_buffer = state->index_buffer; - if (!index_buffer->buffer_object || !stream_info->all_vbo) + struct wined3d_bo *bo = index_buffer->buffer_object; + + if (!bo || !stream_info->all_vbo) idx_data = index_buffer->resource.heap_memory; else - idx_data = NULL; + idx_data = (void *)wined3d_bo_gl(bo)->buffer_offset; idx_data = (const BYTE *)idx_data + state->index_offset;
if (state->index_format == WINED3DFMT_R16_UINT)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 21b5ba1d032..adbaa50a349 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4651,6 +4651,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state const struct wined3d_gl_info *gl_info = context_gl->gl_info; struct wined3d_buffer *buffer; unsigned int offset, size, i; + struct wined3d_bo_gl *bo_gl;
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
@@ -4666,6 +4667,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state
buffer = state->stream_output[i].buffer; offset = state->stream_output[i].offset; + bo_gl = wined3d_bo_gl(buffer->buffer_object); if (offset == ~0u) { FIXME("Appending to stream output buffers not implemented.\n"); @@ -4673,7 +4675,7 @@ static void state_so(struct wined3d_context *context, const struct wined3d_state } size = buffer->resource.size - offset; GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, i, - wined3d_bo_gl(buffer->buffer_object)->id, offset, size)); + bo_gl->id, bo_gl->buffer_offset + offset, size)); buffer->bo_user.valid = true; } checkGLcall("bind transform feedback buffers");
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index adbaa50a349..e0dba8701bc 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4577,6 +4577,7 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state enum wined3d_shader_type shader_type; struct wined3d_buffer *buffer; unsigned int i, base, count; + struct wined3d_bo_gl *bo_gl;
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
@@ -4597,8 +4598,9 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state }
buffer = buffer_state->buffer; + bo_gl = wined3d_bo_gl(buffer->buffer_object); GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER, base + i, - wined3d_bo_gl(buffer->buffer_object)->id, buffer_state->offset, buffer_state->size)); + bo_gl->id, bo_gl->buffer_offset + buffer_state->offset, buffer_state->size)); buffer->bo_user.valid = true; } checkGLcall("bind constant buffers");
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/context_gl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 5767258973d..2751a4a2182 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3788,7 +3788,8 @@ static void wined3d_context_gl_bind_unordered_access_views(struct wined3d_contex format_gl->internal));
if (view_gl->counter_bo.id) - GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view_gl->counter_bo.id)); + GL_EXTCALL(glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, i, view_gl->counter_bo.id, + view_gl->counter_bo.buffer_offset, view_gl->counter_bo.size)); } checkGLcall("Bind unordered access views"); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com