summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-07-18 18:47:08 +1000
committerMarek Olšák <maraeo@gmail.com>2010-07-18 18:11:29 +0200
commit4eaf591d1504f61e131f77f01711d27a75d02e90 (patch)
treec6e634f652b0418734a1afc3b45d97d0c9f18bed /src/gallium
parent14e362c79aedd9b463c74ef2e56ad96101ceb2af (diff)
downloadexternal_mesa3d-4eaf591d1504f61e131f77f01711d27a75d02e90.zip
external_mesa3d-4eaf591d1504f61e131f77f01711d27a75d02e90.tar.gz
external_mesa3d-4eaf591d1504f61e131f77f01711d27a75d02e90.tar.bz2
r300g: u_upload optimisation
fix vb/ib uploads
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/r300/r300_flush.c4
-rw-r--r--src/gallium/drivers/r300/r300_render.c8
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c8
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.h2
4 files changed, 15 insertions, 7 deletions
diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c
index 9e5bfeb..ae7b575 100644
--- a/src/gallium/drivers/r300/r300_flush.c
+++ b/src/gallium/drivers/r300/r300_flush.c
@@ -25,6 +25,7 @@
#include "draw/draw_private.h"
#include "util/u_simple_list.h"
+#include "util/u_upload_mgr.h"
#include "r300_context.h"
#include "r300_cs.h"
@@ -39,6 +40,9 @@ static void r300_flush(struct pipe_context* pipe,
struct r300_atom *atom;
struct r300_fence **rfence = (struct r300_fence**)fence;
+ u_upload_flush(r300->upload_vb);
+ u_upload_flush(r300->upload_ib);
+
/* We probably need to flush Draw, but we may have been called from
* within Draw. This feels kludgy, but it might be the best thing.
*
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index e29ebea..bae0213 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -497,6 +497,7 @@ static void r300_draw_range_elements(struct pipe_context* pipe,
unsigned short_count;
int buffer_offset = 0, index_offset = 0; /* for index bias emulation */
boolean translate = FALSE;
+ unsigned new_offset;
if (r300->skip_rendering) {
return;
@@ -526,18 +527,17 @@ static void r300_draw_range_elements(struct pipe_context* pipe,
&start, count);
r300_update_derived_state(r300);
- r300_upload_index_buffer(r300, &indexBuffer, indexSize, start, count);
+ r300_upload_index_buffer(r300, &indexBuffer, indexSize, start, count, &new_offset);
+ start = new_offset;
/* 15 dwords for emit_draw_elements */
r300_prepare_for_rendering(r300,
PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS | PREP_INDEXED,
indexBuffer, 15, buffer_offset, indexBias, NULL);
- u_upload_flush(r300->upload_vb);
- u_upload_flush(r300->upload_ib);
if (alt_num_verts || count <= 65535) {
r300_emit_draw_elements(r300, indexBuffer, indexSize,
- minIndex, maxIndex, mode, start, count);
+ minIndex, maxIndex, mode, start, count);
} else {
do {
short_count = MIN2(count, 65534);
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index bb5d4fa..b19b5b5 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -62,7 +62,8 @@ int r300_upload_index_buffer(struct r300_context *r300,
struct pipe_resource **index_buffer,
unsigned index_size,
unsigned start,
- unsigned count)
+ unsigned count,
+ unsigned *out_offset)
{
struct pipe_resource *upload_buffer = NULL;
unsigned index_offset = start * index_size;
@@ -79,7 +80,10 @@ int r300_upload_index_buffer(struct r300_context *r300,
goto done;
}
*index_buffer = upload_buffer;
- }
+ *out_offset = index_offset / index_size;
+ } else
+ *out_offset = start;
+
done:
// if (upload_buffer)
// pipe_resource_reference(&upload_buffer, NULL);
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
index fdd5d87..cafa9f9 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.h
+++ b/src/gallium/drivers/r300/r300_screen_buffer.h
@@ -68,7 +68,7 @@ int r300_upload_index_buffer(struct r300_context *r300,
struct pipe_resource **index_buffer,
unsigned index_size,
unsigned start,
- unsigned count);
+ unsigned count, unsigned *out_offset);
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ);