mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 15:30:14 +01:00
vbo: Use a bitmask to track the active arrays in vbo_exec*.
The use of a bitmask makes functions iterating only active
attributes less visible in profiles.
v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
parent
22e5d4a1ee
commit
bc4e0c4868
3 changed files with 75 additions and 66 deletions
|
|
@ -101,6 +101,7 @@ struct vbo_exec_context
|
||||||
GLuint max_vert; /**< Max number of vertices allowed in buffer */
|
GLuint max_vert; /**< Max number of vertices allowed in buffer */
|
||||||
struct vbo_exec_copied_vtx copied;
|
struct vbo_exec_copied_vtx copied;
|
||||||
|
|
||||||
|
GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
|
||||||
GLubyte attrsz[VBO_ATTRIB_MAX]; /**< nr. of attrib components (1..4) */
|
GLubyte attrsz[VBO_ATTRIB_MAX]; /**< nr. of attrib components (1..4) */
|
||||||
GLenum attrtype[VBO_ATTRIB_MAX]; /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */
|
GLenum attrtype[VBO_ATTRIB_MAX]; /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */
|
||||||
GLubyte active_sz[VBO_ATTRIB_MAX]; /**< attrib size (nr. 32-bit words) */
|
GLubyte active_sz[VBO_ATTRIB_MAX]; /**< attrib size (nr. 32-bit words) */
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include "main/api_arrayelt.h"
|
#include "main/api_arrayelt.h"
|
||||||
#include "main/api_validate.h"
|
#include "main/api_validate.h"
|
||||||
#include "main/dispatch.h"
|
#include "main/dispatch.h"
|
||||||
|
#include "util/bitscan.h"
|
||||||
|
|
||||||
#include "vbo_context.h"
|
#include "vbo_context.h"
|
||||||
#include "vbo_noop.h"
|
#include "vbo_noop.h"
|
||||||
|
|
@ -167,10 +168,11 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
|
||||||
{
|
{
|
||||||
struct gl_context *ctx = exec->ctx;
|
struct gl_context *ctx = exec->ctx;
|
||||||
struct vbo_context *vbo = vbo_context(ctx);
|
struct vbo_context *vbo = vbo_context(ctx);
|
||||||
GLuint i;
|
GLbitfield64 enabled = exec->vtx.enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
|
||||||
|
|
||||||
|
while (enabled) {
|
||||||
|
const int i = u_bit_scan64(&enabled);
|
||||||
|
|
||||||
for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
|
|
||||||
if (exec->vtx.attrsz[i]) {
|
|
||||||
/* Note: the exec->vtx.current[i] pointers point into the
|
/* Note: the exec->vtx.current[i] pointers point into the
|
||||||
* ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
|
* ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
|
||||||
*/
|
*/
|
||||||
|
|
@ -178,6 +180,8 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
|
||||||
fi_type tmp[8]; /* space for doubles */
|
fi_type tmp[8]; /* space for doubles */
|
||||||
int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
|
int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
|
||||||
|
|
||||||
|
assert(exec->vtx.attrsz[i]);
|
||||||
|
|
||||||
if (exec->vtx.attrtype[i] == GL_DOUBLE) {
|
if (exec->vtx.attrtype[i] == GL_DOUBLE) {
|
||||||
memset(tmp, 0, sizeof(tmp));
|
memset(tmp, 0, sizeof(tmp));
|
||||||
memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * sizeof(GLfloat));
|
memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * sizeof(GLfloat));
|
||||||
|
|
@ -216,7 +220,6 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
|
||||||
ctx->NewState |= _NEW_CURRENT_ATTRIB;
|
ctx->NewState |= _NEW_CURRENT_ATTRIB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Colormaterial -- this kindof sucks.
|
/* Colormaterial -- this kindof sucks.
|
||||||
*/
|
*/
|
||||||
|
|
@ -311,6 +314,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
|
||||||
exec->vtx.max_vert = vbo_compute_max_verts(exec);
|
exec->vtx.max_vert = vbo_compute_max_verts(exec);
|
||||||
exec->vtx.vert_count = 0;
|
exec->vtx.vert_count = 0;
|
||||||
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
|
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
|
||||||
|
exec->vtx.enabled |= BITFIELD64_BIT(attr);
|
||||||
|
|
||||||
if (unlikely(oldSize)) {
|
if (unlikely(oldSize)) {
|
||||||
/* Size changed, recalculate all the attrptr[] values
|
/* Size changed, recalculate all the attrptr[] values
|
||||||
|
|
@ -345,18 +349,19 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
|
||||||
if (unlikely(exec->vtx.copied.nr)) {
|
if (unlikely(exec->vtx.copied.nr)) {
|
||||||
fi_type *data = exec->vtx.copied.buffer;
|
fi_type *data = exec->vtx.copied.buffer;
|
||||||
fi_type *dest = exec->vtx.buffer_ptr;
|
fi_type *dest = exec->vtx.buffer_ptr;
|
||||||
GLuint j;
|
|
||||||
|
|
||||||
assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map);
|
assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map);
|
||||||
|
|
||||||
for (i = 0 ; i < exec->vtx.copied.nr ; i++) {
|
for (i = 0 ; i < exec->vtx.copied.nr ; i++) {
|
||||||
for (j = 0 ; j < VBO_ATTRIB_MAX ; j++) {
|
GLbitfield64 enabled = exec->vtx.enabled;
|
||||||
|
while (enabled) {
|
||||||
|
const int j = u_bit_scan64(&enabled);
|
||||||
GLuint sz = exec->vtx.attrsz[j];
|
GLuint sz = exec->vtx.attrsz[j];
|
||||||
|
|
||||||
if (sz) {
|
|
||||||
GLint old_offset = old_attrptr[j] - exec->vtx.vertex;
|
GLint old_offset = old_attrptr[j] - exec->vtx.vertex;
|
||||||
GLint new_offset = exec->vtx.attrptr[j] - exec->vtx.vertex;
|
GLint new_offset = exec->vtx.attrptr[j] - exec->vtx.vertex;
|
||||||
|
|
||||||
|
assert(sz);
|
||||||
|
|
||||||
if (j == attr) {
|
if (j == attr) {
|
||||||
if (oldSize) {
|
if (oldSize) {
|
||||||
fi_type tmp[4];
|
fi_type tmp[4];
|
||||||
|
|
@ -373,7 +378,6 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
|
||||||
COPY_SZ_4V(dest + new_offset, sz, data + old_offset);
|
COPY_SZ_4V(dest + new_offset, sz, data + old_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
data += old_vtx_size;
|
data += old_vtx_size;
|
||||||
dest += exec->vtx.vertex_size;
|
dest += exec->vtx.vertex_size;
|
||||||
|
|
@ -1145,6 +1149,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
|
||||||
vbo_exec_vtxfmt_init( exec );
|
vbo_exec_vtxfmt_init( exec );
|
||||||
_mesa_noop_vtxfmt_init(&exec->vtxfmt_noop);
|
_mesa_noop_vtxfmt_init(&exec->vtxfmt_noop);
|
||||||
|
|
||||||
|
exec->vtx.enabled = 0;
|
||||||
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
|
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
|
||||||
assert(i < ARRAY_SIZE(exec->vtx.attrsz));
|
assert(i < ARRAY_SIZE(exec->vtx.attrsz));
|
||||||
exec->vtx.attrsz[i] = 0;
|
exec->vtx.attrsz[i] = 0;
|
||||||
|
|
@ -1273,9 +1278,10 @@ void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags )
|
||||||
|
|
||||||
static void reset_attrfv( struct vbo_exec_context *exec )
|
static void reset_attrfv( struct vbo_exec_context *exec )
|
||||||
{
|
{
|
||||||
GLuint i;
|
while (exec->vtx.enabled) {
|
||||||
|
const int i = u_bit_scan64(&exec->vtx.enabled);
|
||||||
|
assert(exec->vtx.attrsz[i]);
|
||||||
|
|
||||||
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
|
|
||||||
exec->vtx.attrsz[i] = 0;
|
exec->vtx.attrsz[i] = 0;
|
||||||
exec->vtx.attrtype[i] = GL_FLOAT;
|
exec->vtx.attrtype[i] = GL_FLOAT;
|
||||||
exec->vtx.active_sz[i] = 0;
|
exec->vtx.active_sz[i] = 0;
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,8 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
|
||||||
exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
|
exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
|
||||||
exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
|
exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
|
||||||
exec->vtx.attrsz[0] = 0;
|
exec->vtx.attrsz[0] = 0;
|
||||||
|
exec->vtx.enabled &= (~BITFIELD64_BIT(VBO_ATTRIB_POS));
|
||||||
|
exec->vtx.enabled |= BITFIELD64_BIT(VBO_ATTRIB_GENERIC0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue