aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2018-11-17 07:13:11 +0100
committerMathias Fröhlich <[email protected]>2018-11-21 06:27:19 +0100
commit0a7020b4e60ef69e0e4b38aee31bfce385e594d8 (patch)
tree64e68add5e2e22579c6ef715707c1dd99c1ecde1 /src/mesa/vbo
parent2da7b0a2fbf0dbc5e89f19622cf3bbfa346ed0f1 (diff)
mesa: Factor out struct gl_vertex_format.
Factor out struct gl_vertex_format from array attributes. The data type is supposed to describe the type of a vertex element. At this current stage the data type is only used with the VAO, but actually is useful in various other places. Due to the bitfields being used, special care needs to be taken for the glGet code paths. v2: Change unsigned char -> GLubyte. Use struct assignment for struct gl_vertex_format. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo_context.c5
-rw-r--r--src/mesa/vbo/vbo_exec_api.c13
-rw-r--r--src/mesa/vbo/vbo_private.h10
-rw-r--r--src/mesa/vbo/vbo_save_api.c12
-rw-r--r--src/mesa/vbo/vbo_save_draw.c14
-rw-r--r--src/mesa/vbo/vbo_save_loopback.c2
6 files changed, 26 insertions, 30 deletions
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 364de2c507e..484625d9aca 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -58,11 +58,8 @@ init_array(struct gl_context *ctx, struct gl_array_attributes *attrib,
{
memset(attrib, 0, sizeof(*attrib));
- attrib->Size = size;
- attrib->Type = GL_FLOAT;
- attrib->Format = GL_RGBA;
+ vbo_set_vertex_format(&attrib->Format, size, GL_FLOAT);
attrib->Stride = 0;
- attrib->_ElementSize = size * sizeof(GLfloat);
attrib->Ptr = pointer;
}
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index e46922ef859..749a5ebe65a 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -195,7 +195,7 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
exec->vtx.attrtype[i]);
}
- if (exec->vtx.attrtype[i] != vbo->current[i].Type ||
+ if (exec->vtx.attrtype[i] != vbo->current[i].Format.Type ||
memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul);
@@ -205,14 +205,9 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
* directly.
*/
/* Size here is in components - not bytes */
- vbo->current[i].Size = exec->vtx.attrsz[i] / dmul;
- vbo->current[i]._ElementSize =
- vbo->current[i].Size * sizeof(GLfloat) * dmul;
- vbo->current[i].Type = exec->vtx.attrtype[i];
- vbo->current[i].Integer =
- vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]);
- vbo->current[i].Doubles =
- vbo_attrtype_to_double_flag(exec->vtx.attrtype[i]);
+ vbo_set_vertex_format(&vbo->current[i].Format,
+ exec->vtx.attrsz[i] / dmul,
+ exec->vtx.attrtype[i]);
/* This triggers rather too much recalculation of Mesa state
* that doesn't get used (eg light positions).
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 1fc2ab48fd1..6110a6cc0e8 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -115,6 +115,16 @@ vbo_attrtype_to_double_flag(GLenum format)
}
+static inline void
+vbo_set_vertex_format(struct gl_vertex_format* vertex_format,
+ GLubyte size, GLenum16 type)
+{
+ _mesa_set_vertex_format(vertex_format, size, type, GL_RGBA, GL_FALSE,
+ vbo_attrtype_to_integer_flag(type),
+ vbo_attrtype_to_double_flag(type));
+}
+
+
/**
* Return default component values for the given format.
* The return type is an array of fi_types, because that's how we declare
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 8dc03b9f773..fb8d68d5560 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -450,14 +450,14 @@ compare_vao(gl_vertex_processing_mode mode,
const struct gl_array_attributes *attrib = &vao->VertexAttrib[attr];
if (attrib->RelativeOffset + vao->BufferBinding[0].Offset != off)
return false;
- if (attrib->Type != tp)
+ if (attrib->Format.Type != tp)
return false;
- if (attrib->Size != size[vbo_attr])
+ if (attrib->Format.Size != size[vbo_attr])
return false;
- assert(attrib->Format == GL_RGBA);
- assert(attrib->Normalized == GL_FALSE);
- assert(attrib->Integer == vbo_attrtype_to_integer_flag(tp));
- assert(attrib->Doubles == vbo_attrtype_to_double_flag(tp));
+ assert(attrib->Format.Format == GL_RGBA);
+ assert(attrib->Format.Normalized == GL_FALSE);
+ assert(attrib->Format.Integer == vbo_attrtype_to_integer_flag(tp));
+ assert(attrib->Format.Doubles == vbo_attrtype_to_double_flag(tp));
assert(attrib->BufferBindingIndex == 0);
}
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index b3578cc27c3..b5807bb377c 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -52,8 +52,8 @@ copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
const int i = u_bit_scan(&mask);
const struct gl_array_attributes *attrib = &vao->VertexAttrib[i];
struct gl_array_attributes *currval = &vbo->current[shift + i];
- const GLubyte size = attrib->Size;
- const GLenum16 type = attrib->Type;
+ const GLubyte size = attrib->Format.Size;
+ const GLenum16 type = attrib->Format.Type;
fi_type tmp[8];
int dmul = 1;
@@ -66,17 +66,11 @@ copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
else
COPY_CLEAN_4V_TYPE_AS_UNION(tmp, size, *data, type);
- if (type != currval->Type ||
+ if (type != currval->Format.Type ||
memcmp(currval->Ptr, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
memcpy((fi_type*)currval->Ptr, tmp, 4 * sizeof(GLfloat) * dmul);
- currval->Size = size;
- currval->_ElementSize = size * sizeof(GLfloat) * dmul;
- currval->Type = type;
- currval->Integer = vbo_attrtype_to_integer_flag(type);
- currval->Doubles = vbo_attrtype_to_double_flag(type);
- currval->Normalized = GL_FALSE;
- currval->Format = GL_RGBA;
+ vbo_set_vertex_format(&currval->Format, size, type);
ctx->NewState |= state;
}
diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c
index 7e9296bae20..26a9f94facb 100644
--- a/src/mesa/vbo/vbo_save_loopback.c
+++ b/src/mesa/vbo/vbo_save_loopback.c
@@ -139,7 +139,7 @@ append_attr(GLuint *nr, struct loopback_attr la[], int i, int shift,
{
la[*nr].index = shift + i;
la[*nr].offset = vao->VertexAttrib[i].RelativeOffset;
- la[*nr].func = vert_attrfunc[vao->VertexAttrib[i].Size - 1];
+ la[*nr].func = vert_attrfunc[vao->VertexAttrib[i].Format.Size - 1];
(*nr)++;
}