summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2019-03-01 09:27:54 +0100
committerMathias Fröhlich <[email protected]>2019-03-15 06:06:42 +0100
commit94b64eb46257ea3a81e7198527357438a6762932 (patch)
treed1b1b9b6d34d49487b5f176256ba8895c52935ac
parenta8183c1334e282f079d0387e1d8187fab57cf4fb (diff)
mesa: Use mapping tools in debug prints.
Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
-rw-r--r--src/mesa/main/draw.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index bfc4b9c9373..fa70463eaee 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -73,12 +73,6 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
struct gl_buffer_object *bo = binding->BufferObj;
const void *data = array->Ptr;
if (_mesa_is_bufferobj(bo)) {
- if (!bo->Mappings[MAP_INTERNAL].Pointer) {
- /* need to map now */
- bo->Mappings[MAP_INTERNAL].Pointer =
- ctx->Driver.MapBufferRange(ctx, 0, bo->Size,
- GL_MAP_READ_BIT, bo, MAP_INTERNAL);
- }
data = ADD_POINTERS(_mesa_vertex_attrib_address(array, binding),
bo->Mappings[MAP_INTERNAL].Pointer);
}
@@ -110,25 +104,6 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
}
-/**
- * Unmap the buffer object referenced by given array, if mapped.
- */
-static void
-unmap_array_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
- GLuint attrib)
-{
- const struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
- if (vao->Enabled & VERT_BIT(attrib)) {
- const struct gl_vertex_buffer_binding *binding =
- &vao->BufferBinding[array->BufferBindingIndex];
- struct gl_buffer_object *bo = binding->BufferObj;
- if (_mesa_is_bufferobj(bo) && _mesa_bufferobj_mapped(bo, MAP_INTERNAL)) {
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
- }
- }
-}
-
-
static inline int
sizeof_ib_type(GLenum type)
{
@@ -156,17 +131,14 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count,
GLint basevertex)
{
struct gl_vertex_array_object *vao = ctx->Array.VAO;
- const void *elemMap;
GLint i;
GLuint k;
- if (_mesa_is_bufferobj(vao->IndexBufferObj)) {
- elemMap = ctx->Driver.MapBufferRange(ctx, 0,
- vao->IndexBufferObj->Size,
- GL_MAP_READ_BIT,
- vao->IndexBufferObj, MAP_INTERNAL);
- elements = ADD_POINTERS(elements, elemMap);
- }
+ _mesa_vao_map(ctx, vao, GL_MAP_READ_BIT);
+
+ if (_mesa_is_bufferobj(vao->IndexBufferObj))
+ elements =
+ ADD_POINTERS(vao->IndexBufferObj->Mappings[MAP_INTERNAL].Pointer, elements);
for (i = 0; i < count; i++) {
GLuint j;
@@ -192,13 +164,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count,
}
}
- if (_mesa_is_bufferobj(vao->IndexBufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, vao->IndexBufferObj, MAP_INTERNAL);
- }
-
- for (k = 0; k < VERT_ATTRIB_MAX; k++) {
- unmap_array_buffer(ctx, vao, k);
- }
+ _mesa_vao_unmap(ctx, vao);
}
@@ -272,11 +238,13 @@ static void
print_draw_arrays(struct gl_context *ctx,
GLenum mode, GLint start, GLsizei count)
{
- const struct gl_vertex_array_object *vao = ctx->Array.VAO;
+ struct gl_vertex_array_object *vao = ctx->Array.VAO;
printf("_mesa_DrawArrays(mode 0x%x, start %d, count %d):\n",
mode, start, count);
+ _mesa_vao_map_arrays(ctx, vao, GL_MAP_READ_BIT);
+
GLbitfield mask = vao->Enabled;
while (mask) {
const gl_vert_attrib i = u_bit_scan(&mask);
@@ -293,9 +261,7 @@ print_draw_arrays(struct gl_context *ctx,
array->Ptr, bufObj->Name);
if (_mesa_is_bufferobj(bufObj)) {
- GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size,
- GL_MAP_READ_BIT, bufObj,
- MAP_INTERNAL);
+ GLubyte *p = bufObj->Mappings[MAP_INTERNAL].Pointer;
int offset = (int) (GLintptr)
_mesa_vertex_attrib_address(array, binding);
@@ -326,9 +292,10 @@ print_draw_arrays(struct gl_context *ctx,
printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]);
i++;
} while (i < n);
- ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
}
}
+
+ _mesa_vao_unmap_arrays(ctx, vao);
}