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

mesa: import PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET handling

This should decrease overhead in st_update_array.
Reviewed-by: Pierre-Eric Pelloux-Prayer's avatarPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <!3766>
parent 27dada7c
......@@ -4150,6 +4150,9 @@ struct gl_constants
/** Wether or not glBitmap uses red textures rather than alpha */
bool BitmapUsesRed;
/** Whether the vertex buffer offset is a signed 32-bit integer. */
bool VertexBufferOffsetIsInt32;
/** GL_ARB_gl_spirv */
struct spirv_supported_capabilities SpirVCapabilities;
......
......@@ -199,6 +199,20 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
assert(!vao->SharedAndImmutable);
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
if (ctx->Const.VertexBufferOffsetIsInt32 && (int)offset < 0 &&
_mesa_is_bufferobj(vbo)) {
/* The offset will be interpreted as a signed int, so make sure
* the user supplied offset is not negative (driver limitation).
*/
_mesa_warning(ctx, "Received negative int32 vertex buffer offset. "
"(driver limitation)\n");
/* We can't disable this binding, so use a non-negative offset value
* instead.
*/
offset = 0;
}
if (binding->BufferObj != vbo ||
binding->Offset != offset ||
binding->Stride != stride) {
......
......@@ -390,21 +390,10 @@ st_setup_arrays(struct st_context *st,
if (_mesa_is_bufferobj(binding->BufferObj)) {
/* Set the binding */
struct st_buffer_object *stobj = st_buffer_object(binding->BufferObj);
vbuffer[bufidx].buffer.resource = stobj ? stobj->buffer : NULL;
vbuffer[bufidx].is_user_buffer = false;
vbuffer[bufidx].buffer_offset = _mesa_draw_binding_offset(binding);
if (st->has_signed_vertex_buffer_offset) {
/* 'buffer_offset' will be interpreted as an signed int, so make sure
* the user supplied offset is not negative (application bug).
*/
if ((int) vbuffer[bufidx].buffer_offset < 0) {
assert ((int) vbuffer[bufidx].buffer_offset >= 0);
/* Fallback if assert are disabled: we can't disable this attribute
* since other parts expects it (e.g: velements, vp_variant), so
* use a non-buggy offset value instead */
vbuffer[bufidx].buffer_offset = 0;
}
}
} else {
/* Set the binding */
const void *ptr = (const void *)_mesa_draw_binding_offset(binding);
......
......@@ -680,8 +680,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC);
st->needs_rgb_dst_alpha_override =
screen->get_param(screen, PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND);
st->has_signed_vertex_buffer_offset =
screen->get_param(screen, PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET);
st->lower_flatshade =
!screen->get_param(screen, PIPE_CAP_FLATSHADE);
st->lower_alpha_test =
......
......@@ -147,7 +147,6 @@ struct st_context
boolean has_indep_blend_func;
boolean needs_rgb_dst_alpha_override;
boolean can_bind_const_buffer_as_vertex;
boolean has_signed_vertex_buffer_offset;
boolean lower_flatshade;
boolean lower_alpha_test;
boolean lower_point_size;
......
......@@ -559,6 +559,9 @@ void st_init_limits(struct pipe_screen *screen,
temp = screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES);
if (temp > 0 && c->MaxCombinedShaderOutputResources > temp)
c->MaxCombinedShaderOutputResources = temp;
c->VertexBufferOffsetIsInt32 =
screen->get_param(screen, PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET);
}
......
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