summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2007-02-02 12:26:10 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2007-02-02 12:26:10 +0000
commitb59657ad965f9471574e914b861bb1d2a17d772e (patch)
tree99a4fe6dc933472516de91773da04034626a84b5 /src/mesa/drivers/dri/r300
parent325196f548f8e46aa8fcc7b030e81ba939e7f6b7 (diff)
parent2ddc8799a8e243cb10cd69ea9424f72b6c4de534 (diff)
Merge branch 'vbo-0.2'
Conflicts: src/mesa/main/texcompress_s3tc.c src/mesa/tnl/t_array_api.c
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c8
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h7
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c4
-rw-r--r--src/mesa/drivers/dri/r300/radeon_state.c2
-rw-r--r--src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c304
6 files changed, 100 insertions, 229 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 71402761ae..00489ba14e 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -44,7 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
@@ -292,7 +292,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext(ctx);
- _ac_CreateContext(ctx);
+ _vbo_CreateContext(ctx);
_tnl_CreateContext(ctx);
_swsetup_CreateContext(ctx);
_swsetup_Wakeup(ctx);
@@ -305,7 +305,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
/* Try and keep materials and vertices separate:
*/
- _tnl_isolate_materials(ctx, GL_TRUE);
+/* _tnl_isolate_materials(ctx, GL_TRUE); */
/* Configure swrast and TNL to match hardware characteristics:
*/
@@ -486,7 +486,7 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
_swsetup_DestroyContext(r300->radeon.glCtx);
_tnl_ProgramCacheDestroy(r300->radeon.glCtx);
_tnl_DestroyContext(r300->radeon.glCtx);
- _ac_DestroyContext(r300->radeon.glCtx);
+ _vbo_DestroyContext(r300->radeon.glCtx);
_swrast_DestroyContext(r300->radeon.glCtx);
if (r300->dma.current.buf) {
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index dd3ecbb235..02f8e9107d 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -48,7 +48,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_context.h"
#define USER_BUFFERS
-#define RADEON_VTXFMT_A
+/* KW: Disable this code. Driver should hook into vbo module
+ * directly, see i965 driver for example.
+ */
+/* #define RADEON_VTXFMT_A */
#define HW_VBOS
/* We don't handle 16 bits elts swapping yet */
@@ -754,7 +757,7 @@ struct radeon_vertex_buffer {
struct dt AttribPtr[VERT_ATTRIB_MAX];
- struct tnl_prim *Primitive;
+ const struct _mesa_prim *Primitive;
GLuint PrimitiveCount;
GLint LockFirst;
GLsizei LockCount;
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index 91305cb5a2..3d094b9db5 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -42,7 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "api_arrayelt.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_vp_build.h"
@@ -352,7 +352,7 @@ GLboolean r300_run_vb_render(GLcontext *ctx,
r300EmitState(rmesa);
for(i=0; i < VB->PrimitiveCount; i++){
- GLuint prim = VB->Primitive[i].mode;
+ GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
GLuint start = VB->Primitive[i].start;
GLuint length = VB->Primitive[i].count;
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 6a22ccad2f..e06999aa26 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -46,7 +46,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "api_arrayelt.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "texformat.h"
@@ -1885,7 +1885,7 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
- _ac_InvalidateState(ctx, new_state);
+ _vbo_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
_ae_invalidate_state(ctx, new_state);
diff --git a/src/mesa/drivers/dri/r300/radeon_state.c b/src/mesa/drivers/dri/r300/radeon_state.c
index 0ceaf7ebb7..ddadf83a00 100644
--- a/src/mesa/drivers/dri/r300/radeon_state.c
+++ b/src/mesa/drivers/dri/r300/radeon_state.c
@@ -41,7 +41,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "light.h"
#include "swrast/swrast.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "swrast_setup/swrast_setup.h"
diff --git a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
index 72c03c53ad..0625e5bc57 100644
--- a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
+++ b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c
@@ -46,6 +46,8 @@
#include "state.h"
#include "image.h"
+#include "vbo/vbo_context.h"
+
#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
rvb->AttribPtr[(a)].type = GL_FLOAT, \
rvb->AttribPtr[(a)].stride = vb->b->stride, \
@@ -129,15 +131,7 @@ static int setup_arrays(r300ContextPtr rmesa, GLint start)
CONV(i, VertexAttrib[i]);
for (i=0; i < VERT_ATTRIB_MAX; i++) {
- if (enabled & (1 << i)) {
- rmesa->state.VB.AttribPtr[i].data += rmesa->state.VB.AttribPtr[i].stride * start;
- } else {
- def.data = ctx->Current.Attrib[i];
- memcpy(&rmesa->state.VB.AttribPtr[i], &def, sizeof(struct dt));
- }
-
- /*if(rmesa->state.VB.AttribPtr[i].data == ctx->Current.Attrib[i])
- fprintf(stderr, "%d is default coord\n", i);*/
+ rmesa->state.VB.AttribPtr[i].data += rmesa->state.VB.AttribPtr[i].stride * start;
}
for(i=0; i < VERT_ATTRIB_MAX; i++){
@@ -177,177 +171,18 @@ static int setup_arrays(r300ContextPtr rmesa, GLint start)
void radeon_init_vtxfmt_a(r300ContextPtr rmesa);
-static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *c_indices )
-{
- GET_CURRENT_CONTEXT(ctx);
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- int elt_size;
- int i;
- unsigned int min = ~0, max = 0;
- struct tnl_prim prim;
- static void *ptr = NULL;
- struct r300_dma_region rvb;
- const GLvoid *indices = c_indices;
-
- if (count > 65535) {
- WARN_ONCE("Too many verts!\n");
- goto fallback;
- }
-
- if (ctx->Array.ElementArrayBufferObj->Name) {
- /* use indices in the buffer object */
- if (!ctx->Array.ElementArrayBufferObj->Data) {
- _mesa_warning(ctx, "DrawRangeElements with empty vertex elements buffer!");
- return;
- }
- /* actual address is the sum of pointers */
- indices = (GLvoid *)
- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, (const GLubyte *) c_indices);
- }
-
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
- return;
-
- FLUSH_CURRENT( ctx, 0 );
-
- memset(&rvb, 0, sizeof(rvb));
- switch (type) {
- case GL_UNSIGNED_BYTE:
- for (i=0; i < count; i++) {
- if(((unsigned char *)indices)[i] < min)
- min = ((unsigned char *)indices)[i];
- if(((unsigned char *)indices)[i] > max)
- max = ((unsigned char *)indices)[i];
- }
-
-#ifdef FORCE_32BITS_ELTS
- elt_size = 4;
-#else
- elt_size = 2;
-#endif
- r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
- rvb.aos_offset = GET_START(&rvb);
- ptr = rvb.address + rvb.start;
-
-#ifdef FORCE_32BITS_ELTS
- for (i=0; i < count; i++)
- ((unsigned int *)ptr)[i] = ((unsigned char *)indices)[i] - min;
-#else
- for (i=0; i < count; i++)
- ((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - min;
-#endif
- break;
-
- case GL_UNSIGNED_SHORT:
- for (i=0; i < count; i++) {
- if(((unsigned short int *)indices)[i] < min)
- min = ((unsigned short int *)indices)[i];
- if(((unsigned short int *)indices)[i] > max)
- max = ((unsigned short int *)indices)[i];
- }
-
-#ifdef FORCE_32BITS_ELTS
- elt_size = 4;
-#else
- elt_size = 2;
-#endif
-
- r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
- rvb.aos_offset = GET_START(&rvb);
- ptr = rvb.address + rvb.start;
-
-#ifdef FORCE_32BITS_ELTS
- for (i=0; i < count; i++)
- ((unsigned int *)ptr)[i] = ((unsigned short int *)indices)[i] - min;
-#else
- for (i=0; i < count; i++)
- ((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - min;
-#endif
- break;
-
- case GL_UNSIGNED_INT:
- for (i=0; i < count; i++) {
- if(((unsigned int *)indices)[i] < min)
- min = ((unsigned int *)indices)[i];
- if(((unsigned int *)indices)[i] > max)
- max = ((unsigned int *)indices)[i];
- }
-
-#ifdef FORCE_32BITS_ELTS
- elt_size = 4;
-#else
- if (max - min <= 65535)
- elt_size = 2;
- else
- elt_size = 4;
-#endif
- r300AllocDmaRegion(rmesa, &rvb, count * elt_size, elt_size);
- rvb.aos_offset = GET_START(&rvb);
- ptr = rvb.address + rvb.start;
-
-
- if (elt_size == 2)
- for (i=0; i < count; i++)
- ((unsigned short int *)ptr)[i] = ((unsigned int *)indices)[i] - min;
- else
- for (i=0; i < count; i++)
- ((unsigned int *)ptr)[i] = ((unsigned int *)indices)[i] - min;
- break;
-
- default:
- WARN_ONCE("Unknown elt type!\n");
- goto fallback;
- }
-
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- r300UpdateShaders(rmesa);
-
- if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) {
- r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- goto fallback;
- }
-
- rmesa->state.VB.Count = max - min + 1;
-
- r300UpdateShaderStates(rmesa);
-
- rmesa->state.VB.Primitive = &prim;
- rmesa->state.VB.PrimitiveCount = 1;
-
- prim.mode = mode | PRIM_BEGIN | PRIM_END;
- if (rmesa->state.VB.LockCount)
- prim.start = min - rmesa->state.VB.LockFirst;
- else
- prim.start = 0;
- prim.count = count;
-
- rmesa->state.VB.Elts = ptr;
- rmesa->state.VB.elt_size = elt_size;
-
- if (r300_run_vb_render(ctx, NULL)) {
- r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- goto fallback;
- }
-
- if(rvb.buf)
- radeon_mm_use(rmesa, rvb.buf->id);
-
- r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- return;
-
- fallback:
- _tnl_array_init(ctx);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
- CALL_DrawElements(GET_DISPATCH(), (mode, count, type, c_indices));
- radeon_init_vtxfmt_a(rmesa);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
-}
-static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei count, GLenum type, const GLvoid *c_indices)
+static void radeonDrawRangeElements(GLcontext *ctx,
+ GLenum mode,
+ GLuint min,
+ GLuint max,
+ GLsizei count,
+ GLenum type,
+ const GLvoid *c_indices)
{
- GET_CURRENT_CONTEXT(ctx);
+#if 1
+ return GL_FALSE;
+#else
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct tnl_prim prim;
int elt_size;
@@ -371,26 +206,23 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
indices += i * _mesa_sizeof_type(type);
count -= i;
}
- return ;
+ return GL_TRUE;
}
WARN_ONCE("Too many verts!\n");
- goto fallback;
+ return GL_FALSE;
}
if (ctx->Array.ElementArrayBufferObj->Name) {
/* use indices in the buffer object */
if (!ctx->Array.ElementArrayBufferObj->Data) {
_mesa_warning(ctx, "DrawRangeElements with empty vertex elements buffer!");
- return;
+ return GL_TRUE;
}
/* actual address is the sum of pointers */
indices = (GLvoid *)
ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, (const GLubyte *) c_indices);
}
- if (!_mesa_validate_DrawRangeElements( ctx, mode, min, max, count, type, indices ))
- return;
-
FLUSH_CURRENT( ctx, 0 );
#ifdef OPTIMIZE_ELTS
min = 0;
@@ -465,7 +297,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
default:
WARN_ONCE("Unknown elt type!\n");
- goto fallback;
+ return GL_FALSE;
}
/* XXX: setup_arrays before state update? */
@@ -477,7 +309,7 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
if (setup_arrays(rmesa, min) >= R300_FALLBACK_TCL) {
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- goto fallback;
+ return GL_FALSE;
}
rmesa->state.VB.Count = max - min + 1;
@@ -501,37 +333,34 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
if (r300_run_vb_render(ctx, NULL)) {
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- goto fallback;
+ return GL_FALSE;
}
if(rvb.buf)
radeon_mm_use(rmesa, rvb.buf->id);
r300ReleaseDmaRegion(rmesa, &rvb, __FUNCTION__);
- return ;
-
- fallback:
- _tnl_array_init(ctx);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
- CALL_DrawRangeElements(GET_DISPATCH(), (mode, min, max, count, type, c_indices));
- radeon_init_vtxfmt_a(rmesa);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
+ return GL_TRUE;
+#endif
}
-static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
+static GLboolean radeonDrawArrays( GLcontext *ctx,
+ GLenum mode, GLint start, GLsizei count )
{
+#if 1
+ return GL_FALSE;
+#else
GET_CURRENT_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct tnl_prim prim;
if (count > 65535) {
+ /* TODO: split into multiple draws.
+ */
WARN_ONCE("Too many verts!\n");
- goto fallback;
+ return GL_FALSE;
}
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
- return;
-
FLUSH_CURRENT( ctx, 0 );
if (ctx->NewState)
@@ -542,7 +371,7 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
r300UpdateShaders(rmesa);
if (setup_arrays(rmesa, start) >= R300_FALLBACK_TCL)
- goto fallback;
+ return GL_FALSE;
rmesa->state.VB.Count = count;
@@ -564,31 +393,70 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
rmesa->state.VB.elt_max = 0;
if (r300_run_vb_render(ctx, NULL))
- goto fallback;
+ return GL_FALSE;
- return ;
-
- fallback:
- _tnl_array_init(ctx);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
- CALL_DrawArrays(GET_DISPATCH(), (mode, start, count));
- radeon_init_vtxfmt_a(rmesa);
- _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
+ return GL_TRUE;
+#endif
}
+static void radeon_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct _mesa_prim *prim,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index)
+{
+ if (ib == NULL) {
+ for (i = 0; i < nr_prims; i++) {
+ if (!radeonDrawArrays(ctx,
+ prim->mode,
+ prim->start,
+ prim->count)) {
+ /* Fallback
+ */
+ _tnl_draw_prims(ctx,
+ arrays,
+ prim + i,
+ nr_prims - i,
+ ib,
+ min_index,
+ max_index);
+ return;
+ }
+ }
+ } else {
+ for (i = 0; i < nr_prims; i++) {
+ if (!radeonDrawRangeElements(ctx,
+ prim->mode,
+ min_index,
+ max_index,
+ prim->count,
+ ib->types,
+ ib->ptr)) {
+ /* Fallback
+ */
+ _tnl_draw_prims(ctx,
+ arrays,
+ prim + i,
+ nr_prims - i,
+ ib,
+ min_index,
+ max_index);
+ return;
+ }
+ }
+ }
+}
+
void radeon_init_vtxfmt_a(r300ContextPtr rmesa)
{
GLcontext *ctx;
- GLvertexformat *vfmt;
-
- ctx = rmesa->radeon.glCtx;
- vfmt = (GLvertexformat *)ctx->TnlModule.Current;
-
- vfmt->DrawElements = radeonDrawElements;
- vfmt->DrawArrays = radeonDrawArrays;
- vfmt->DrawRangeElements = radeonDrawRangeElements;
+ struct vbo_context *vbo = vbo_context(ctx);
+ vbo->draw_prims = radeon_draw_prims;
}
+
#endif
#ifdef HW_VBOS