vbo,gallium: make glBegin/End buffer size configurable by drivers
authorMarek Olšák <marek.olsak@amd.com>
Wed, 11 Mar 2020 21:19:10 +0000 (17:19 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sat, 21 Mar 2020 03:39:51 +0000 (03:39 +0000)
The default is 512 KB, but radeonsi wants 4 MB.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4154>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4154>

src/gallium/auxiliary/util/u_screen.c
src/gallium/docs/source/screen.rst
src/gallium/drivers/radeonsi/si_get.c
src/gallium/include/pipe/p_defines.h
src/mesa/main/context.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c
src/mesa/vbo/vbo_exec.h
src/mesa/vbo/vbo_exec_api.c
src/mesa/vbo/vbo_exec_draw.c
src/mesa/vbo/vbo_private.h

index 318bce1a0f07d1a03ac172c64ed987111d93ebfc..d770a84c21a91b5e8d416f37c1c1832aa529816a 100644 (file)
@@ -422,6 +422,9 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
    case PIPE_CAP_PSIZ_CLAMPED:
       return 0;
 
+   case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE:
+      return 512 * 1024;
+
    default:
       unreachable("bad PIPE_CAP_*");
    }
index 8301ecbc8f2ea552cf5ad902289ff0b339b037cb..4743f0ffdffe5e536fdcbae1ee9128daa73e934c 100644 (file)
@@ -572,6 +572,7 @@ The integer capabilities:
 * ``PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED``: Driver needs the nir_lower_viewport_transform pass to be enabled. This also means that the gl_Position value is modified and should be lowered for transform feedback, if needed. Defaults to false.
 * ``PIPE_CAP_PSIZ_CLAMPED``: Driver needs for the point size to be clamped. Additionally, the gl_PointSize has been modified and its value should be lowered for transform feedback, if needed. Defaults to false.
 * ``PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES``: pipe_draw_info::start can be non-zero with user indices.
+* ``PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE``: Buffer size used to upload vertices for glBegin/glEnd.
 
 .. _pipe_capf:
 
index 5b4598da10347945087328a094b6f99cc7ac4a13..d3fa08f91f2e4e24981eb6e42ead388bd19f862d 100644 (file)
@@ -203,6 +203,9 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                /* Optimal number for good TexSubImage performance on Polaris10. */
                return 64 * 1024 * 1024;
 
+       case PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE:
+               return 4096 * 1024;
+
        case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
        case PIPE_CAP_MAX_SHADER_BUFFER_SIZE:
                return MIN2(sscreen->info.max_alloc_size, INT_MAX);
index 523c81996adb6f41810a9351ae9bee86f56ec7e5..407b5afe4e3d7288bd44e98fd1702637640387a8 100644 (file)
@@ -919,6 +919,7 @@ enum pipe_cap
    PIPE_CAP_VIEWPORT_TRANSFORM_LOWERED,
    PIPE_CAP_PSIZ_CLAMPED,
    PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES,
+   PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE,
 };
 
 /**
index a88f3c2722cdc5b5035136135b07584bc8cef9be..9023394824e436fe893f972d564eff028e3e3fb8 100644 (file)
@@ -754,6 +754,8 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
    consts->ConservativeRasterDilateRange[0] = 0.0;
    consts->ConservativeRasterDilateRange[1] = 0.0;
    consts->ConservativeRasterDilateGranularity = 0.0;
+
+   consts->glBeginEndBufferSize = 512 * 1024;
 }
 
 
index 12884170c242ff34dae5dc2e0371425dde83c6a9..8977a50eaeb85a89cc2282fa3570df6d323b4b66 100644 (file)
@@ -4183,6 +4183,9 @@ struct gl_constants
    struct spirv_supported_extensions *SpirVExtensions;
 
    char *VendorOverride;
+
+   /** Buffer size used to upload vertices from glBegin/glEnd. */
+   unsigned glBeginEndBufferSize;
 };
 
 
index b26d3904b8ff08147511af8d0b15643fa2a83528..85e249a377e421320214ef63f7e56f9d7bf65809 100644 (file)
@@ -572,6 +572,9 @@ void st_init_limits(struct pipe_screen *screen,
 
    c->MultiDrawWithUserIndices =
       screen->get_param(screen, PIPE_CAP_DRAW_INFO_START_WITH_USER_INDICES);
+
+   c->glBeginEndBufferSize =
+      screen->get_param(screen, PIPE_CAP_GL_BEGIN_END_BUFFER_SIZE);
 }
 
 
index 0d056b35dc933c64ed22a47bdf39fb6ed7b0ea7e..336765c9117527fd8259f41180240e93f7a7d46f 100644 (file)
@@ -46,12 +46,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define VBO_MAX_PRIM 64
 
 
-/**
- * Size (in bytes) of the VBO to use for glBegin/glVertex/glEnd-style rendering.
- */
-#define VBO_VERT_BUFFER_SIZE (1024 * 512)
-
-
 struct vbo_exec_eval1_map {
    struct gl_1d_map *map;
    GLuint sz;
index 71c8f340702346c7aff7f5a2b1b41497c413ddf4..53269f18d3bebf9ffde96068321f2e3f0b4602ac 100644 (file)
@@ -1017,7 +1017,8 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects)
                                     &exec->vtx.bufferobj,
                                     ctx->Shared->NullBufferObj);
 
-      exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
+      exec->vtx.buffer_map =
+         _mesa_align_malloc(ctx->Const.glBeginEndBufferSize, 64);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }
 
index 035c11636123cb49e4d5e300b23659fa821c27dc..93a74cc07ad35c757e77aadf81e00188d34bfa03 100644 (file)
@@ -169,7 +169,7 @@ vbo_exec_vtx_unmap(struct vbo_exec_context *exec)
       exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
                                 exec->vtx.buffer_map) * sizeof(float);
 
-      assert(exec->vtx.buffer_used <= VBO_VERT_BUFFER_SIZE);
+      assert(exec->vtx.buffer_used <= exec->ctx->Const.glBeginEndBufferSize);
       assert(exec->vtx.buffer_ptr != NULL);
 
       ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
@@ -182,7 +182,7 @@ vbo_exec_vtx_unmap(struct vbo_exec_context *exec)
 static bool
 vbo_exec_buffer_has_space(struct vbo_exec_context *exec)
 {
-   return VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024;
+   return exec->ctx->Const.glBeginEndBufferSize > exec->vtx.buffer_used + 1024;
 }
 
 
@@ -223,7 +223,7 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
          exec->vtx.buffer_map = (fi_type *)
             ctx->Driver.MapBufferRange(ctx,
                                        exec->vtx.buffer_used,
-                                       VBO_VERT_BUFFER_SIZE
+                                       ctx->Const.glBeginEndBufferSize
                                        - exec->vtx.buffer_used,
                                        accessRange,
                                        exec->vtx.bufferobj,
@@ -240,7 +240,7 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
       exec->vtx.buffer_used = 0;
 
       if (ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB,
-                                 VBO_VERT_BUFFER_SIZE,
+                                 ctx->Const.glBeginEndBufferSize,
                                  NULL, usage,
                                  GL_MAP_WRITE_BIT |
                                  (ctx->Extensions.ARB_buffer_storage ?
@@ -253,7 +253,7 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
          /* buffer allocation worked, now map the buffer */
          exec->vtx.buffer_map =
             (fi_type *)ctx->Driver.MapBufferRange(ctx,
-                                                  0, VBO_VERT_BUFFER_SIZE,
+                                                  0, ctx->Const.glBeginEndBufferSize,
                                                   accessRange,
                                                   exec->vtx.bufferobj,
                                                   MAP_INTERNAL);
index 1e37df881cd8e965ec38b03328716e1713a52e22..9f169fd7675b59978dd73ee2af652e12f60ed6fd 100644 (file)
@@ -163,8 +163,9 @@ vbo_get_default_vals_as_union(GLenum format)
 static inline unsigned
 vbo_compute_max_verts(const struct vbo_exec_context *exec)
 {
-   unsigned n = (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) /
-      (exec->vtx.vertex_size * sizeof(GLfloat));
+   unsigned n = (exec->ctx->Const.glBeginEndBufferSize -
+                 exec->vtx.buffer_used) /
+                (exec->vtx.vertex_size * sizeof(GLfloat));
    if (n == 0)
       return 0;
    /* Subtract one so we're always sure to have room for an extra