This should decrease overhead in st_update_array.
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3766>
/** 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;
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) {
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);
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 =
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;
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);
}