diff options
author | marha <marha@users.sourceforge.net> | 2011-05-16 09:49:27 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-05-16 09:49:27 +0000 |
commit | ab5c2d2c78273ccdc7c9734bcba482a33fcf9652 (patch) | |
tree | d12aaeba9956621fe7429d94a7c90105fe306b42 /mesalib/src/gallium/auxiliary | |
parent | 421ecdd3ee6f691c63c4568944423d986f9f69db (diff) | |
parent | 08cbf3b50bfe713044f36b363c73768cd042f13c (diff) | |
download | vcxsrv-ab5c2d2c78273ccdc7c9734bcba482a33fcf9652.tar.gz vcxsrv-ab5c2d2c78273ccdc7c9734bcba482a33fcf9652.tar.bz2 vcxsrv-ab5c2d2c78273ccdc7c9734bcba482a33fcf9652.zip |
merge ^/branches/released .
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 16 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c | 62 |
2 files changed, 47 insertions, 31 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index 16a9eab6d..8f2ae2e17 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -413,22 +413,6 @@ unsigned ffs( unsigned u ) #define ffs __builtin_ffs
#endif
-#ifdef __MINGW32__
-#define ffs __builtin_ffs
-#endif
-
-
-/* Could also binary search for the highest bit.
- */
-static INLINE unsigned
-util_unsigned_logbase2(unsigned n)
-{
- unsigned log2 = 0;
- while (n >>= 1)
- ++log2;
- return log2;
-}
-
/**
* Return float bits.
diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c index 9306fcd5c..78e9df033 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf_mgr.c @@ -53,9 +53,11 @@ struct u_vbuf_mgr_elements { unsigned count;
struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
- /* If (velem[i].src_format != real_format[i]), the vertex buffer
+ unsigned src_format_size[PIPE_MAX_ATTRIBS];
+
+ /* If (velem[i].src_format != native_format[i]), the vertex buffer
* referenced by the vertex element cannot be used for rendering and
- * its vertex data must be translated to real_format[i]. */
+ * its vertex data must be translated to native_format[i]. */
enum pipe_format native_format[PIPE_MAX_ATTRIBS];
unsigned native_format_size[PIPE_MAX_ATTRIBS];
@@ -353,6 +355,8 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb, for (i = 0; i < count; i++) {
enum pipe_format format = ve->ve[i].src_format;
+ ve->src_format_size[i] = util_format_get_blocksize(format);
+
/* Choose a native format.
* For now we don't care about the alignment, that's going to
* be sorted out later. */
@@ -460,7 +464,6 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb, struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
unsigned i;
- mgr->b.max_index = ~0;
mgr->any_user_vbs = FALSE;
mgr->incompatible_vb_layout = FALSE;
@@ -483,23 +486,16 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb, pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
- if (u_vbuf_resource(vb->buffer)->user_ptr) {
- mgr->any_user_vbs = TRUE;
+ if (!vb->buffer) {
continue;
}
- pipe_resource_reference(&mgr->b.real_vertex_buffer[i], vb->buffer);
-
- /* The stride of zero means we will be fetching only the first
- * vertex, so don't care about max_index. */
- if (!vb->stride) {
+ if (u_vbuf_resource(vb->buffer)->user_ptr) {
+ mgr->any_user_vbs = TRUE;
continue;
}
- /* Update the maximum index. */
- mgr->b.max_index =
- MIN2(mgr->b.max_index,
- (vb->buffer->width0 - vb->buffer_offset) / vb->stride - 1);
+ pipe_resource_reference(&mgr->b.real_vertex_buffer[i], vb->buffer);
}
for (; i < mgr->b.nr_real_vertex_buffers; i++) {
@@ -519,7 +515,7 @@ static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr, unsigned instance_count,
boolean *upload_flushed)
{
- int i, nr = mgr->ve->count;
+ unsigned i, nr = mgr->ve->count;
unsigned count = max_index + 1 - min_index;
boolean uploaded[PIPE_MAX_ATTRIBS] = {0};
@@ -562,6 +558,40 @@ static void u_vbuf_upload_buffers(struct u_vbuf_mgr_priv *mgr, }
}
+static void u_vbuf_mgr_compute_max_index(struct u_vbuf_mgr_priv *mgr)
+{
+ unsigned i, nr = mgr->ve->count;
+
+ mgr->b.max_index = ~0;
+
+ for (i = 0; i < nr; i++) {
+ struct pipe_vertex_buffer *vb =
+ &mgr->b.vertex_buffer[mgr->ve->ve[i].vertex_buffer_index];
+ int unused;
+ unsigned max_index;
+
+ if (!vb->buffer ||
+ !vb->stride ||
+ u_vbuf_resource(vb->buffer)->user_ptr) {
+ continue;
+ }
+
+ /* How many bytes is unused after the last vertex.
+ * width0 may be "count*stride - unused" and we have to compensate
+ * for that when dividing by stride. */
+ unused = vb->stride -
+ (mgr->ve->ve[i].src_offset + mgr->ve->src_format_size[i]);
+ assert(unused >= 0);
+
+ /* Compute the maximum index for this vertex element. */
+ max_index =
+ (vb->buffer->width0 - vb->buffer_offset + (unsigned)unused) /
+ vb->stride - 1;
+
+ mgr->b.max_index = MIN2(mgr->b.max_index, max_index);
+ }
+}
+
void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
const struct pipe_draw_info *info,
boolean *buffers_updated,
@@ -571,6 +601,8 @@ void u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb, boolean bufs_updated = FALSE, upload_flushed = FALSE;
int min_index, max_index;
+ u_vbuf_mgr_compute_max_index(mgr);
+
min_index = info->min_index - info->index_bias;
if (info->max_index == ~0) {
max_index = mgr->b.max_index;
|