[Mesa-dev] [RFC PATCH 03/65] mesa: add support for unsigned 64-bit vertex attributes
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri May 19 16:52:08 UTC 2017
This adds support in the VBO and array code to handle unsigned
64-bit vertex attributes as specified by ARB_bindless_texture.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/mapi/glapi/gen/apiexec.py | 3 +++
src/mesa/main/api_loopback.c | 4 ++++
src/mesa/main/varray.c | 18 ++++++++++++++++++
src/mesa/vbo/vbo_attrib_tmp.h | 19 +++++++++++++++++++
src/mesa/vbo/vbo_context.h | 2 ++
src/mesa/vbo/vbo_exec_api.c | 12 +++++++++---
6 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py
index e5e1b7d78c..61eda4b0f9 100644
--- a/src/mapi/glapi/gen/apiexec.py
+++ b/src/mapi/glapi/gen/apiexec.py
@@ -291,4 +291,7 @@ functions = {
"ProgramUniform2ui64vARB": exec_info(core=31),
"ProgramUniform3ui64vARB": exec_info(core=31),
"ProgramUniform4ui64vARB": exec_info(core=31),
+
+ # GL_ARB_bindless_texture
+ "GetVertexAttribLui64vARB": exec_info(core=31),
}
diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index 36e5194b93..b552d17d6a 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -89,6 +89,8 @@
#define ATTRIB3_D(index,x,y,z) CALL_VertexAttribL3d(GET_DISPATCH(), (index,x,y,z))
#define ATTRIB4_D(index,x,y,z,w) CALL_VertexAttribL4d(GET_DISPATCH(), (index,x,y,z,w))
+#define ATTRIB1_UI64(index, x) CALL_VertexAttribL1ui64ARB(GET_DISPATCH(), (index, x))
+
void GLAPIENTRY
_mesa_Color3b( GLbyte red, GLbyte green, GLbyte blue )
{
@@ -1531,11 +1533,13 @@ _mesa_VertexAttribL1dv(GLuint index, const GLdouble *v)
void GLAPIENTRY
_mesa_VertexAttribL1ui64ARB(GLuint index, GLuint64EXT x)
{
+ ATTRIB1_UI64(index, x);
}
void GLAPIENTRY
_mesa_VertexAttribL1ui64vARB(GLuint index, const GLuint64EXT *v)
{
+ ATTRIB1_UI64(index, v[0]);
}
void GLAPIENTRY
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index fcb53d3986..2100cd1b9e 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1356,6 +1356,24 @@ _mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
void GLAPIENTRY
_mesa_GetVertexAttribLui64vARB(GLuint index, GLenum pname, GLuint64EXT *params)
{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ const GLuint64 *v =
+ (const GLuint64 *)get_current_attrib(ctx, index,
+ "glGetVertexAttribLui64vARB");
+ if (v != NULL) {
+ params[0] = v[0];
+ params[1] = v[1];
+ params[2] = v[2];
+ params[3] = v[3];
+ }
+ }
+ else {
+ params[0] = (GLuint64) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
+ "glGetVertexAttribLui64vARB");
+ }
}
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index 08b441aafb..8328445b2b 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -41,6 +41,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3))
#define ATTRD( A, N, V0, V1, V2, V3 ) \
ATTR_UNION(A, N, GL_DOUBLE, double, V0, V1, V2, V3)
+#define ATTRUI64( A, N, V0, V1, V2, V3 ) \
+ ATTR_UNION(A, N, GL_UNSIGNED_INT64_ARB, uint64_t, V0, V1, V2, V3)
/* float */
@@ -246,6 +248,9 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
#define ATTR3D( A, X, Y, Z ) ATTRD( A, 3, X, Y, Z, 1 )
#define ATTR4D( A, X, Y, Z, W ) ATTRD( A, 4, X, Y, Z, W )
+#define ATTR1UIV64( A, V ) ATTRUI64( A, 1, (V)[0], 0, 0, 0 )
+#define ATTR1UI64( A, X ) ATTRUI64( A, 1, X, 0, 0, 0 )
+
static void GLAPIENTRY
TAG(Vertex2f)(GLfloat x, GLfloat y)
@@ -1305,11 +1310,25 @@ TAG(VertexAttribL4dv)(GLuint index, const GLdouble * v)
static void GLAPIENTRY
TAG(VertexAttribL1ui64ARB)(GLuint index, GLuint64EXT x)
{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR1UI64(0, x);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR1UI64(VBO_ATTRIB_GENERIC0 + index, x);
+ else
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
TAG(VertexAttribL1ui64vARB)(GLuint index, const GLuint64EXT *v)
{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR1UIV64(0, v);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR1UIV64(VBO_ATTRIB_GENERIC0 + index, v);
+ else
+ ERROR(GL_INVALID_VALUE);
}
#undef ATTR1FV
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index 5cf399ffcd..a54258455f 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -156,6 +156,7 @@ vbo_attrtype_to_integer_flag(GLenum format)
return GL_FALSE;
case GL_INT:
case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_INT64_ARB:
return GL_TRUE;
default:
assert(0);
@@ -170,6 +171,7 @@ vbo_attrtype_to_double_flag(GLenum format)
case GL_FLOAT:
case GL_INT:
case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_INT64_ARB:
return GL_FALSE;
case GL_DOUBLE:
return GL_TRUE;
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 4db4eef3b6..019f986f0b 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -176,11 +176,16 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
*/
GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
fi_type tmp[8]; /* space for doubles */
- int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
+ int dmul = 1;
+
+ if (exec->vtx.attrtype[i] == GL_DOUBLE ||
+ exec->vtx.attrtype[i] == GL_UNSIGNED_INT64_ARB)
+ dmul = 2;
assert(exec->vtx.attrsz[i]);
- if (exec->vtx.attrtype[i] == GL_DOUBLE) {
+ if (exec->vtx.attrtype[i] == GL_DOUBLE ||
+ exec->vtx.attrtype[i] == GL_UNSIGNED_INT64_ARB) {
memset(tmp, 0, sizeof(tmp));
memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * sizeof(GLfloat));
} else {
@@ -241,7 +246,8 @@ vbo_exec_copy_from_current(struct vbo_exec_context *exec)
GLint i;
for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
- if (exec->vtx.attrtype[i] == GL_DOUBLE) {
+ if (exec->vtx.attrtype[i] == GL_DOUBLE ||
+ exec->vtx.attrtype[i] == GL_UNSIGNED_INT64_ARB) {
memcpy(exec->vtx.attrptr[i], vbo->currval[i].Ptr,
exec->vtx.attrsz[i] * sizeof(GLfloat));
} else {
--
2.13.0
More information about the mesa-dev
mailing list