Commit 5cc3ab0b authored by Marek Olšák's avatar Marek Olšák Committed by Marge Bot

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's avatarPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tested-by: Marge Bot <!4154>
Part-of: <!4154>
parent 11d3aa5e
Pipeline #122503 failed with stages
in 17 minutes and 56 seconds
......@@ -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_*");
}
......
......@@ -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:
......
......@@ -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);
......
......@@ -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,
};
/**
......
......@@ -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;
}
......
......@@ -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;
};
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment