mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 05:20:37 +02:00
vbo/dlist: reallocate the vertex buffer on vertex upgrade
upgrade_vertex copies save->copied.nr vertices to the vertex buffer,
so we need to make sure it has enough space to accomodate them.
This commit also drops the usage of COPY_CLEAN_4V_TYPE_AS_UNION in
this function because it always writes 4-components for all attributes,
but our buffer might be smaller. Instead, only write the needed
components.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5353
Fixes: cc57156dce ("vbo/dlist: rework vertex_store management")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12849>
This commit is contained in:
parent
beb7ed2b89
commit
4c0b8254a2
1 changed files with 27 additions and 12 deletions
|
|
@ -1114,6 +1114,7 @@ upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz)
|
|||
if (save->copied.nr) {
|
||||
assert(save->copied.buffer);
|
||||
const fi_type *data = save->copied.buffer;
|
||||
grow_vertex_storage(ctx, save->copied.nr);
|
||||
fi_type *dest = save->vertex_store->buffer_in_ram;
|
||||
|
||||
/* Need to note this and fix up at runtime (or loopback):
|
||||
|
|
@ -1129,20 +1130,34 @@ upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz)
|
|||
const int j = u_bit_scan64(&enabled);
|
||||
assert(save->attrsz[j]);
|
||||
if (j == attr) {
|
||||
if (oldsz) {
|
||||
COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data,
|
||||
save->attrtype[j]);
|
||||
data += oldsz;
|
||||
dest += newsz;
|
||||
int k;
|
||||
const fi_type *src = oldsz ? data : save->current[attr];
|
||||
int copy = oldsz ? oldsz : newsz;
|
||||
for (k = 0; k < copy; k++)
|
||||
dest[k] = src[k];
|
||||
for (; k < newsz; k++) {
|
||||
switch (save->attrtype[j]) {
|
||||
case GL_FLOAT:
|
||||
dest[k] = FLOAT_AS_UNION(k == 3);
|
||||
break;
|
||||
case GL_INT:
|
||||
dest[k] = INT_AS_UNION(k == 3);
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
dest[k] = UINT_AS_UNION(k == 3);
|
||||
break;
|
||||
default:
|
||||
dest[k] = FLOAT_AS_UNION(k == 3);
|
||||
assert(!"Unexpected type in upgrade_vertex");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
COPY_SZ_4V(dest, newsz, save->current[attr]);
|
||||
dest += newsz;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dest += newsz;
|
||||
data += oldsz;
|
||||
} else {
|
||||
GLint sz = save->attrsz[j];
|
||||
COPY_SZ_4V(dest, sz, data);
|
||||
for (int k = 0; k < sz; k++)
|
||||
dest[k] = data[k];
|
||||
data += sz;
|
||||
dest += sz;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue