From: Marek Olšák Date: Wed, 11 Mar 2020 21:19:10 +0000 (-0400) Subject: vbo,gallium: make glBegin/End buffer size configurable by drivers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5cc3ab0ba0eed6e730eac869953c052f8b1e9ec2;p=mesa.git vbo,gallium: make glBegin/End buffer size configurable by drivers The default is 512 KB, but radeonsi wants 4 MB. Acked-by: Pierre-Eric Pelloux-Prayer Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 318bce1a0f0..d770a84c21a 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -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_*"); } diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 8301ecbc8f2..4743f0ffdff 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -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: diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 5b4598da103..d3fa08f91f2 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -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); diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 523c81996ad..407b5afe4e3 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -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, }; /** diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index a88f3c2722c..9023394824e 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -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; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 12884170c24..8977a50eaeb 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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; }; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index b26d3904b8f..85e249a377e 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -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); } diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index 0d056b35dc9..336765c9117 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -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; diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 71c8f340702..53269f18d3b 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -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; } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 035c1163612..93a74cc07ad 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -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); diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h index 1e37df881cd..9f169fd7675 100644 --- a/src/mesa/vbo/vbo_private.h +++ b/src/mesa/vbo/vbo_private.h @@ -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