From e46dffddb11f23fef52625ed2ab99d01d02cb919 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 2 Oct 2024 06:31:36 -0400 Subject: [PATCH] util/vbuf: rename/consolidate some bools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit now that the pipe caps are unified, this makes reading a bit easier Reviewed-by: Alyssa Rosenzweig Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_vbuf.c | 37 ++++++++++++----------------- src/gallium/auxiliary/util/u_vbuf.h | 8 +++---- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 40fa4337a16..46507327c45 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -306,20 +306,16 @@ void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps, } /* by default, all of these are supported */ - caps->velem_src_offset_unaligned = 1; - caps->buffer_stride_unaligned = 1; - caps->buffer_offset_unaligned = 1; - caps->attrib_component_unaligned = 1; + caps->attrib_4byte_unaligned = 1; + caps->attrib_element_unaligned = 1; /* pipe cap removes capabilities */ switch (screen->get_param(screen, PIPE_CAP_VERTEX_INPUT_ALIGNMENT)) { case PIPE_VERTEX_INPUT_ALIGNMENT_4BYTE: - caps->velem_src_offset_unaligned = 0; - caps->buffer_stride_unaligned = 0; - caps->buffer_offset_unaligned = 0; + caps->attrib_4byte_unaligned = 0; break; case PIPE_VERTEX_INPUT_ALIGNMENT_ELEMENT: - caps->attrib_component_unaligned = 0; + caps->attrib_element_unaligned = 0; break; default: break; @@ -350,10 +346,7 @@ void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps, if (caps->max_vertex_buffers < 16) caps->fallback_always = true; - if (!caps->buffer_offset_unaligned || - !caps->buffer_stride_unaligned || - !caps->attrib_component_unaligned || - !caps->velem_src_offset_unaligned) + if (!caps->attrib_4byte_unaligned || !caps->attrib_element_unaligned) caps->fallback_always = true; if (!caps->fallback_always && !caps->user_vertex_buffers) @@ -790,7 +783,7 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, te->output_format = output_format; te->output_offset = k->output_stride; unsigned adjustment = 0; - if (!mgr->caps.attrib_component_unaligned && + if (!mgr->caps.attrib_element_unaligned && te->output_offset % mgr->ve->component_size[i] != 0) { unsigned aligned = align(te->output_offset, mgr->ve->component_size[i]); adjustment = aligned - te->output_offset; @@ -806,7 +799,7 @@ u_vbuf_translate_begin(struct u_vbuf *mgr, for (type = 0; type < VB_NUM; type++) { if (key[type].nr_elements) { enum pipe_error err; - if (!mgr->caps.attrib_component_unaligned) + if (!mgr->caps.attrib_element_unaligned) key[type].output_stride = align(key[type].output_stride, min_alignment[type]); err = u_vbuf_translate_buffers(mgr, &key[type], info, draw, mask[type], mgr->fallback_vbs[type], @@ -928,9 +921,9 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, ve->component_size[i] = component_size; if (ve->ve[i].src_format != format || - (!mgr->caps.velem_src_offset_unaligned && + (!mgr->caps.attrib_4byte_unaligned && ve->ve[i].src_offset % 4 != 0) || - (!mgr->caps.attrib_component_unaligned && + (!mgr->caps.attrib_element_unaligned && ve->ve[i].src_offset % component_size != 0)) { ve->incompatible_elem_mask |= 1 << i; ve->incompatible_vb_mask_any |= vb_index_bit; @@ -947,8 +940,8 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, if (ve->ve[i].src_stride) { ve->nonzero_stride_vb_mask |= 1 << ve->ve[i].vertex_buffer_index; } - if ((!mgr->caps.buffer_stride_unaligned && ve->ve[i].src_stride % 4 != 0) || - (!mgr->caps.attrib_component_unaligned && ve->ve[i].src_stride % component_size != 0)) + if ((!mgr->caps.attrib_4byte_unaligned && ve->ve[i].src_stride % 4 != 0) || + (!mgr->caps.attrib_element_unaligned && ve->ve[i].src_stride % component_size != 0)) ve->incompatible_vb_mask |= vb_index_bit; } @@ -968,7 +961,7 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, ve->incompatible_vb_mask_all = ~ve->compatible_vb_mask_any & used_buffers; /* Align the formats and offsets to the size of DWORD if needed. */ - if (!mgr->caps.velem_src_offset_unaligned) { + if (!mgr->caps.attrib_4byte_unaligned) { for (i = 0; i < count; i++) { ve->native_format_size[i] = align(ve->native_format_size[i], 4); driver_attribs[i].src_offset = align(ve->ve[i].src_offset, 4); @@ -1064,7 +1057,7 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, enabled_vb_mask |= 1 << i; - if ((!mgr->caps.buffer_offset_unaligned && vb->buffer_offset % 4 != 0)) { + if ((!mgr->caps.attrib_4byte_unaligned && vb->buffer_offset % 4 != 0)) { incompatible_vb_mask |= 1 << i; real_vb->buffer_offset = vb->buffer_offset; pipe_vertex_buffer_unreference(real_vb); @@ -1072,7 +1065,7 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, continue; } - if (!mgr->caps.attrib_component_unaligned) { + if (!mgr->caps.attrib_element_unaligned) { if (vb->buffer_offset % 2 != 0) unaligned_vb_mask[0] |= BITFIELD_BIT(i); if (vb->buffer_offset % 4 != 0) @@ -1463,7 +1456,7 @@ void u_vbuf_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *inf unsigned fixed_restart_index = info->index_size ? util_prim_restart_index_from_size(info->index_size) : 0; uint32_t misaligned = 0; - if (!mgr->caps.attrib_component_unaligned) { + if (!mgr->caps.attrib_element_unaligned) { for (unsigned i = 0; i < ARRAY_SIZE(mgr->unaligned_vb_mask); i++) { misaligned |= mgr->ve->vb_align_mask[i] & mgr->unaligned_vb_mask[i]; } diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h index e3509a66df3..9809ee90b6d 100644 --- a/src/gallium/auxiliary/util/u_vbuf.h +++ b/src/gallium/auxiliary/util/u_vbuf.h @@ -47,10 +47,10 @@ struct u_vbuf_caps { /* Whether vertex fetches don't have to be 4-byte-aligned. */ /* TRUE if hardware supports it. */ - unsigned buffer_offset_unaligned:1; - unsigned buffer_stride_unaligned:1; - unsigned velem_src_offset_unaligned:1; - unsigned attrib_component_unaligned:1; + unsigned attrib_4byte_unaligned:1; + /* Whether vertex fetches don't have to be element-aligned. */ + /* TRUE if hardware supports it. */ + unsigned attrib_element_unaligned:1; /* Whether the driver supports user vertex buffers. */ unsigned user_vertex_buffers:1;