diff options
author | Marek Olšák <[email protected]> | 2020-02-13 15:29:22 -0500 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2020-03-04 19:54:42 -0500 |
commit | e92a4f817d1f7a5094066e2a47a246fd5ccf94d6 (patch) | |
tree | 75136b9e37577a469d885f7283ccbd62f041be03 | |
parent | 87085c673d593e6332ca2f3fb6737b77f7087f66 (diff) |
mesa: replace some index_size multiplications and divisions with shifts
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4052>
-rw-r--r-- | src/mesa/main/draw.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_draw_feedback.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_minmax_index.c | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index bcf4384a3a9..dc8fe1e5da8 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -1208,7 +1208,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode, for (i = 0; i < primcount; i++) { min_index_ptr = MIN2(min_index_ptr, (uintptr_t) indices[i]); max_index_ptr = MAX2(max_index_ptr, (uintptr_t) indices[i] + - ib.index_size * count[i]); + (count[i] << ib.index_size_shift)); } /* Check if we can handle this thing as a bunch of index offsets from the @@ -1217,10 +1217,10 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode, * Check that the difference between each prim's indexes is a multiple of * the index/element size. */ - if (ib.index_size != 1) { + if (ib.index_size_shift) { for (i = 0; i < primcount; i++) { - if ((((uintptr_t) indices[i] - min_index_ptr) % ib.index_size) != - 0) { + if ((((uintptr_t) indices[i] - min_index_ptr) & + ((1 << ib.index_size_shift) - 1)) != 0) { fallback = GL_TRUE; break; } @@ -1239,7 +1239,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode, ALLOC_PRIMS(prim, primcount, "glMultiDrawElements"); - ib.count = (max_index_ptr - min_index_ptr) / ib.index_size; + ib.count = (max_index_ptr - min_index_ptr) >> ib.index_size_shift; ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = (void *) min_index_ptr; @@ -1248,7 +1248,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode, prim[i].end = 1; prim[i].mode = mode; prim[i].start = - ((uintptr_t) indices[i] - min_index_ptr) / ib.index_size; + ((uintptr_t) indices[i] - min_index_ptr) >> ib.index_size_shift; prim[i].count = count[i]; prim[i].draw_id = i; if (basevertex != NULL) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index b370e552e79..6459b2553c2 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -217,7 +217,7 @@ st_draw_vbo(struct gl_context *ctx, if (!info.index.resource) return; - start = pointer_to_offset(ib->ptr) / info.index_size; + start = pointer_to_offset(ib->ptr) >> ib->index_size_shift; } else { /* indices are in user space memory */ info.has_user_indices = true; @@ -299,7 +299,7 @@ st_indirect_draw_vbo(struct gl_context *ctx, info.index_size = ib->index_size; info.index.resource = st_buffer_object(bufobj)->buffer; - info.start = pointer_to_offset(ib->ptr) / info.index_size; + info.start = pointer_to_offset(ib->ptr) >> ib->index_size_shift; /* Primitive restart is not handled by the VBO module in this case. */ setup_primitive_restart(ctx, &info); diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 14c809c8a09..4e6b67992f3 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -196,7 +196,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, if (bufobj && bufobj->Name) { struct st_buffer_object *stobj = st_buffer_object(bufobj); - start = pointer_to_offset(ib->ptr) / index_size; + start = pointer_to_offset(ib->ptr) >> ib->index_size_shift; mapped_indices = pipe_buffer_map(pipe, stobj->buffer, PIPE_TRANSFER_READ, &ib_transfer); } @@ -204,7 +204,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, mapped_indices = ib->ptr; } - info.index_size = ib->index_size; + info.index_size = index_size; info.min_index = min_index; info.max_index = max_index; info.has_user_indices = true; diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index d1298dcdc3a..8cb5f3c0aeb 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -247,9 +247,9 @@ vbo_get_minmax_index(struct gl_context *ctx, GLuint i; GLintptr offset = 0; - indices = (char *) ib->ptr + prim->start * ib->index_size; + indices = (char *) ib->ptr + (prim->start << ib->index_size_shift); if (_mesa_is_bufferobj(ib->obj)) { - GLsizeiptr size = MIN2(count * ib->index_size, ib->obj->Size); + GLsizeiptr size = MIN2(count << ib->index_size_shift, ib->obj->Size); if (vbo_get_minmax_cached(ib->obj, ib->index_size, (GLintptr) indices, count, min_index, max_index)) |