st/mesa: factor ucp-lowering logic into helper
[mesa.git] / src / mesa / tnl / t_split_copy.c
index 9df55c78558cbb8b8d0689bada23b40dcce8c0cc..cee50fc96059ff3b2f8290e53dbac1d472dfe080 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "main/glheader.h"
 #include "main/bufferobj.h"
-#include "util/imports.h"
+
 #include "main/glformats.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
@@ -146,13 +146,10 @@ check_flush(struct copy_context *copy)
  * Dump the parameters/info for a vbo->draw() call.
  */
 static void
-dump_draw_info(struct gl_context *ctx,
-               const struct tnl_vertex_array *arrays,
+dump_draw_info(const struct tnl_vertex_array *arrays,
                const struct _mesa_prim *prims,
                GLuint nr_prims,
-               const struct _mesa_index_buffer *ib,
-               GLuint min_index,
-               GLuint max_index)
+               const struct _mesa_index_buffer *ib)
 {
    GLuint i, j;
 
@@ -192,13 +189,10 @@ flush(struct copy_context *copy)
    copy->dstib.count = copy->dstelt_nr;
 
 #if 0
-   dump_draw_info(copy->ctx,
-                  copy->dstarray,
+   dump_draw_info(copy->dstarray,
                   copy->dstprim,
                   copy->dstprim_nr,
-                  &copy->dstib,
-                  0,
-                  copy->dstbuf_nr);
+                  &copy->dstib);
 #else
    (void) dump_draw_info;
 #endif
@@ -212,8 +206,7 @@ flush(struct copy_context *copy)
               0,
               copy->dstbuf_nr - 1,
               1,
-              0,
-              NULL, 0);
+              0);
 
    /* Reset all pointers:
     */
@@ -274,7 +267,7 @@ elt(struct copy_context *copy, GLuint elt_idx)
             GLuint k;
             GLfloat *f = (GLfloat *) srcptr;
             for (k = 0; k < srcarray->Size; k++) {
-               assert(!IS_INF_OR_NAN(f[k]));
+               assert(!util_is_inf_or_nan(f[k]));
                assert(f[k] <= 1.0e20 && f[k] >= -1.0e20);
             }
          }
@@ -455,7 +448,7 @@ replay_init(struct copy_context *copy)
          copy->varying[j].size = attrib->Format._ElementSize;
          copy->vertex_size += attrib->Format._ElementSize;
 
-         if (_mesa_is_bufferobj(vbo)) {
+         if (vbo) {
             if (!_mesa_bufferobj_mapped(vbo, MAP_INTERNAL)) {
                ctx->Driver.MapBufferRange(ctx, 0, vbo->Size, GL_MAP_READ_BIT, vbo,
                                           MAP_INTERNAL);
@@ -476,14 +469,16 @@ replay_init(struct copy_context *copy)
     * caller convert non-indexed prims to indexed.  Could alternately
     * do it internally.
     */
-   if (_mesa_is_bufferobj(copy->ib->obj) &&
-       !_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
-      ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
-                                 copy->ib->obj, MAP_INTERNAL);
+   if (copy->ib->obj) {
+      if (!_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
+         ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
+                                    copy->ib->obj, MAP_INTERNAL);
 
-   srcptr = (const GLubyte *)
-            ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
-                         copy->ib->ptr);
+      srcptr = (const GLubyte *)
+         ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
+                      copy->ib->ptr);
+   } else
+      srcptr = copy->ib->ptr;
 
    switch (copy->ib->index_size_shift) {
    case 0:
@@ -578,12 +573,12 @@ replay_finish(struct copy_context *copy)
    for (i = 0; i < copy->nr_varying; i++) {
       struct gl_buffer_object *vbo =
          copy->varying[i].array->BufferBinding->BufferObj;
-      if (_mesa_is_bufferobj(vbo) && _mesa_bufferobj_mapped(vbo, MAP_INTERNAL))
+      if (vbo && _mesa_bufferobj_mapped(vbo, MAP_INTERNAL))
          ctx->Driver.UnmapBuffer(ctx, vbo, MAP_INTERNAL);
    }
 
    /* Unmap index buffer */
-   if (_mesa_is_bufferobj(copy->ib->obj) &&
+   if (copy->ib->obj &&
        _mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL)) {
       ctx->Driver.UnmapBuffer(ctx, copy->ib->obj, MAP_INTERNAL);
    }