i915g: Unifdef VBUF_MAP_BUFFER.
authorEmma Anholt <emma@anholt.net>
Wed, 16 Jun 2021 04:52:04 +0000 (21:52 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Sep 2021 18:36:10 +0000 (18:36 +0000)
You do want to stream the vertices out to the WC mapping, as the code has
been doing, rather than writing into malloc and doing a memcpy later and
wasting cache space.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13052>

src/gallium/drivers/i915/i915_prim_vbuf.c

index 4f34753..fb19226 100644 (file)
@@ -50,8 +50,6 @@
 #include "i915_reg.h"
 #include "i915_state.h"
 
-#define VBUF_MAP_BUFFER
-
 /**
  * Primitive renderer for i915.
  */
@@ -82,12 +80,6 @@ struct i915_vbuf_render {
    void *vbo_ptr;
    size_t vbo_max_used;
    size_t vbo_max_index; /**< index offset to be added to all indices */
-
-#ifndef VBUF_MAP_BUFFER
-   size_t map_used_start;
-   size_t map_used_end;
-   size_t map_size;
-#endif
 };
 
 /**
@@ -196,14 +188,6 @@ i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
    i915_render->vbo_sw_offset = 0;
    i915_render->vbo_index = 0;
 
-#ifndef VBUF_MAP_BUFFER
-   if (i915_render->vbo_size > i915_render->map_size) {
-      i915_render->map_size = i915_render->vbo_size;
-      FREE(i915_render->vbo_ptr);
-      i915_render->vbo_ptr = MALLOC(i915_render->map_size);
-   }
-#endif
-
    i915_render->vbo =
       iws->buffer_create(iws, i915_render->vbo_size, I915_NEW_VERTEX);
    i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, true);
@@ -264,11 +248,7 @@ i915_vbuf_render_map_vertices(struct vbuf_render *render)
    if (i915->vbo_flushed)
       debug_printf("%s bad vbo flush occurred stalling on hw\n", __FUNCTION__);
 
-#ifdef VBUF_MAP_BUFFER
    return (unsigned char *)i915_render->vbo_ptr + i915_render->vbo_sw_offset;
-#else
-   return (unsigned char *)i915_render->vbo_ptr;
-#endif
 }
 
 static void
@@ -276,24 +256,10 @@ i915_vbuf_render_unmap_vertices(struct vbuf_render *render, ushort min_index,
                                 ushort max_index)
 {
    struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
-   struct i915_context *i915 = i915_render->i915;
-   struct i915_winsys *iws = i915->iws;
 
    i915_render->vbo_max_index = max_index;
    i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used,
                                     i915_render->vertex_size * (max_index + 1));
-#ifdef VBUF_MAP_BUFFER
-   (void)iws;
-#else
-   i915_render->map_used_start = i915_render->vertex_size * min_index;
-   i915_render->map_used_end = i915_render->vertex_size * (max_index + 1);
-   iws->buffer_write(
-      iws, i915_render->vbo,
-      i915_render->map_used_start + i915_render->vbo_sw_offset,
-      i915_render->map_used_end - i915_render->map_used_start,
-      (unsigned char *)i915_render->vbo_ptr + i915_render->map_used_start);
-
-#endif
 }
 
 /**
@@ -705,12 +671,6 @@ i915_vbuf_render_create(struct i915_context *i915)
    i915_render->base.release_vertices = i915_vbuf_render_release_vertices;
    i915_render->base.destroy = i915_vbuf_render_destroy;
 
-#ifndef VBUF_MAP_BUFFER
-   i915_render->map_size = 0;
-   i915_render->map_used_start = 0;
-   i915_render->map_used_end = 0;
-#endif
-
    i915_render->vbo = NULL;
    i915_render->vbo_ptr = NULL;
    i915_render->vbo_size = 0;