From eaf8fe3335b1c7e62275ac0fef202f51750ffba9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 19 Apr 2012 01:41:46 +0200 Subject: [PATCH] u_vbuf: take advantage of all new vertex fetch caps --- src/gallium/auxiliary/util/u_vbuf.c | 19 ++++++++++++------- src/gallium/auxiliary/util/u_vbuf.h | 6 ++++-- src/mesa/state_tracker/st_context.c | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index 3c6dc9a3ab1..a592a1214e2 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -144,11 +144,15 @@ void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps) screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER); - caps->fetch_dword_unaligned = + caps->buffer_offset_unaligned = !screen->get_param(screen, - PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY) && + PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY); + + caps->buffer_stride_unaligned = !screen->get_param(screen, - PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY) && + PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY); + + caps->velem_src_offset_unaligned = !screen->get_param(screen, PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY); @@ -653,14 +657,15 @@ u_vbuf_create_vertex_elements(struct u_vbuf *mgr, unsigned count, ve->incompatible_layout_elem[i] = ve->ve[i].src_format != format || - (!mgr->caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0); + (!mgr->caps.velem_src_offset_unaligned && + ve->ve[i].src_offset % 4 != 0); ve->incompatible_layout = ve->incompatible_layout || ve->incompatible_layout_elem[i]; } /* Align the formats to the size of DWORD if needed. */ - if (!mgr->caps.fetch_dword_unaligned) { + if (!mgr->caps.velem_src_offset_unaligned) { for (i = 0; i < count; i++) { ve->native_format_size[i] = align(ve->native_format_size[i], 4); } @@ -704,8 +709,8 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, unsigned count, continue; } - if (!mgr->caps.fetch_dword_unaligned && - (vb->stride % 4 != 0 || vb->buffer_offset % 4 != 0)) { + if ((!mgr->caps.buffer_offset_unaligned && vb->buffer_offset % 4 != 0) || + (!mgr->caps.buffer_stride_unaligned && vb->stride % 4 != 0)) { mgr->incompatible_vb[i] = TRUE; mgr->incompatible_vb_layout = TRUE; pipe_resource_reference(&real_vb->buffer, NULL); diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h index 161349970a1..59eb59a1190 100644 --- a/src/gallium/auxiliary/util/u_vbuf.h +++ b/src/gallium/auxiliary/util/u_vbuf.h @@ -49,9 +49,11 @@ struct u_vbuf_caps { unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */ unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */ - /* Whether vertex fetches don't have to be dword-aligned. */ + /* Whether vertex fetches don't have to be 4-byte-aligned. */ /* TRUE if hardware supports it. */ - unsigned fetch_dword_unaligned:1; + unsigned buffer_offset_unaligned:1; + unsigned buffer_stride_unaligned:1; + unsigned velem_src_offset_unaligned:1; /* Whether the driver supports user vertex buffers. */ unsigned user_vertex_buffers:1; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index b27f2f677b6..84aae814416 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -119,7 +119,9 @@ static void st_init_vbuf(struct st_context *st) u_vbuf_get_caps(st->pipe->screen, &caps); /* Create u_vbuf if there is anything unsupported. */ - if (!caps.fetch_dword_unaligned || + if (!caps.buffer_offset_unaligned || + !caps.buffer_stride_unaligned || + !caps.velem_src_offset_unaligned || !caps.format_fixed32 || !caps.format_float16 || !caps.format_float64 || -- 2.30.2