summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAapo Tahkola <aet@rasterburn.org>2005-05-11 17:28:13 +0000
committerAapo Tahkola <aet@rasterburn.org>2005-05-11 17:28:13 +0000
commit4e68f4c1faa67c072fefe040271edf2c3a334eb7 (patch)
tree33e5442bec96e453f0dd1cb9263562fcc4b7c3aa /src
parent1e5772f0ba7300e19d1980c0e30e358e71c5c685 (diff)
VBOs.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c53
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.c25
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c22
-rw-r--r--src/mesa/drivers/dri/r300/r300_shader.c9
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c22
-rw-r--r--src/mesa/drivers/dri/r300/r300_texprog.c5
8 files changed, 114 insertions, 26 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 3d5ec76b1a..a1dff1177d 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -140,6 +140,55 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = {
0,
};
+void r300BufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid *data, GLenum usage, struct gl_buffer_object *obj)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ drm_radeon_mem_alloc_t alloc;
+ int offset, ret;
+
+ alloc.region = RADEON_MEM_REGION_GART;
+ alloc.alignment = 4;
+ alloc.size = size;
+ alloc.region_offset = &offset;
+
+ ret = drmCommandWriteRead( rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc));
+ if(ret){
+ WARN_ONCE("Ran out of GART memory!\n");
+ _mesa_buffer_data(ctx, target, size, data, usage, obj);
+ return ;
+ }
+ obj->Data = ((char *)rmesa->radeon.radeonScreen->gartTextures.map) + offset;
+ memcpy(obj->Data, data, size);
+ obj->Size = size;
+ obj->Usage = usage;
+#if 0
+ fprintf(stderr, "allocated %d bytes at %p, offset=%d\n", size, obj->Data, offset);
+#endif
+}
+
+void r300DeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ if(r300IsGartMemory(rmesa, obj->Data, obj->Size)){
+ drm_radeon_mem_free_t memfree;
+ int ret;
+
+ memfree.region = RADEON_MEM_REGION_GART;
+ memfree.region_offset = (char *)obj->Data - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+
+ ret = drmCommandWrite(rmesa->radeon.radeonScreen->driScreen->fd,
+ DRM_RADEON_FREE, &memfree, sizeof(memfree));
+
+ if(ret){
+ WARN_ONCE("Failed to free GART memroy!\n");
+ }
+ obj->Data = NULL;
+ }
+ _mesa_delete_buffer_object(ctx, obj);
+}
+
/* Create the device specific rendering context.
*/
GLboolean r300CreateContext(const __GLcontextModes * glVisual,
@@ -177,6 +226,10 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
r300InitStateFuncs(&functions);
r300InitTextureFuncs(&functions);
r300InitShaderFuncs(&functions);
+ if(hw_tcl_on){
+ functions.BufferData = r300BufferData;
+ functions.DeleteBuffer = r300DeleteBuffer;
+ }
if (!radeonInitContext(&r300->radeon, &functions,
glVisual, driContextPriv, sharedContextPrivate)) {
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index fa6dbbf8af..16cf3b9f2c 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -568,7 +568,7 @@ struct r300_vertex_shader_state {
extern int hw_tcl_on;
-#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : &ctx->_TnlProgram)
+#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : ctx->_TnlProgram)
//#define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && (OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit)))) : \
// (r300->state.render_inputs & (_TNL_BIT_TEX0<<(unit))))
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index 7113deb71c..56e7b3e2af 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -582,7 +582,7 @@ GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa, const GLvoid * pointer)
int offset =
(char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
- fprintf(stderr, "offset=%08x\n", offset);
+ //fprintf(stderr, "offset=%08x\n", offset);
if (offset < 0 || offset > rmesa->radeon.radeonScreen->gartTextures.size)
return ~0;
diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c
index 5bbd5986d4..938978d68a 100644
--- a/src/mesa/drivers/dri/r300/r300_maos.c
+++ b/src/mesa/drivers/dri/r300/r300_maos.c
@@ -173,6 +173,20 @@ static void emit_vector(GLcontext * ctx,
fprintf(stderr, "%s count %d size %d stride %d\n",
__FUNCTION__, count, size, stride);
+ if(r300IsGartMemory(rmesa, data, size*stride)){
+ rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
+ rvb->start = data - rvb->address;
+ rvb->aos_offset = r300GartOffsetFromVirtual(rmesa, data);
+
+ if(stride == 0)
+ rvb->aos_stride = 0;
+ else
+ rvb->aos_stride = stride / 4;
+
+ rvb->aos_size = size;
+ return;
+ }
+
/* Gets triggered when playing with future_hw_tcl_on ...*/
//assert(!rvb->buf);
@@ -188,7 +202,7 @@ static void emit_vector(GLcontext * ctx,
rvb->aos_stride = size;
rvb->aos_size = size;
}
-
+
/* Emit the data
*/
switch (size) {
@@ -219,6 +233,13 @@ void r300EmitElts(GLcontext * ctx, GLuint *elts, unsigned long n_elts)
unsigned short int *out;
int i;
+ if(r300IsGartMemory(rmesa, elts, n_elts*sizeof(unsigned short int))){
+ rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
+ rvb->start = (char *)elts - rvb->address;
+ rvb->aos_offset = rmesa->radeon.radeonScreen->gart_texture_offset + rvb->start;
+ return ;
+ }
+
r300AllocDmaRegion(rmesa, rvb, n_elts*sizeof(unsigned short int), 2);
out = (unsigned short int *)(rvb->address + rvb->start);
@@ -242,7 +263,6 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
GLuint aa_vap_reg = 0; /* VAP register assignment */
GLuint i;
GLuint inputs = 0;
- GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->InputsRead;
#define CONFIGURE_AOS(r, f, v, sz, cn) { \
@@ -272,6 +292,7 @@ void r300EmitArrays(GLcontext * ctx, GLboolean immd)
}
if (hw_tcl_on) {
+ GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->InputsRead;
struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
if (InputsRead & (1<<VERT_ATTRIB_POS)) {
inputs |= _TNL_BIT_POS;
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index 4a827ace76..ac9d155026 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -545,7 +545,7 @@ static GLboolean r300_run_vb_render(GLcontext *ctx,
fprintf(stderr, "%s\n", __FUNCTION__);
- r300ReleaseArrays(ctx);
+ r300ReleaseArrays(ctx);
r300EmitArrays(ctx, GL_FALSE);
//dump_inputs(ctx, rmesa->state.render_inputs);
@@ -557,6 +557,9 @@ static GLboolean r300_run_vb_render(GLcontext *ctx,
reg_start(0x4f18,0);
e32(0x00000003);
r300EmitState(rmesa);
+
+ if(hw_tcl_on) /* FIXME */
+ r300FlushCmdBuf(rmesa, __FUNCTION__);
rmesa->state.Elts = VB->Elts;
@@ -748,6 +751,8 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx,
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
+ struct r300_vertex_program *vp;
+
hw_tcl_on=future_hw_tcl_on;
if (RADEON_DEBUG & DEBUG_PRIMS)
@@ -756,13 +761,16 @@ static GLboolean r300_run_tcl_render(GLcontext *ctx,
return GL_TRUE;
if(ctx->VertexProgram._Enabled == GL_FALSE){
_tnl_UpdateFixedFunctionProgram(ctx);
- r300ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, &ctx->_TnlProgram);
- r300_setup_textures(ctx);
- r300_setup_rs_unit(ctx);
-
- r300SetupVertexShader(rmesa);
- r300SetupPixelShader(rmesa);
}
+ vp = CURRENT_VERTEX_SHADER(ctx);
+ if(vp->translated == GL_FALSE)
+ translate_vertex_shader(vp);
+
+ r300_setup_textures(ctx);
+ r300_setup_rs_unit(ctx);
+
+ r300SetupVertexShader(rmesa);
+ r300SetupPixelShader(rmesa);
return r300_run_vb_render(ctx, stage);
}
diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
index c3c89e0215..c1f5914aad 100644
--- a/src/mesa/drivers/dri/r300/r300_shader.c
+++ b/src/mesa/drivers/dri/r300/r300_shader.c
@@ -21,11 +21,6 @@ static void r300BindProgram(GLcontext *ctx, GLenum target, struct program *prog)
}
}
-/* Mesa doesnt seem to have prototype for this */
-struct program *
-_mesa_init_ati_fragment_shader( GLcontext *ctx, struct ati_fragment_shader *prog,
- GLenum target, GLuint id);
-
static struct program *r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
{
struct r300_vertex_program *vp;
@@ -72,8 +67,8 @@ void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
switch(target) {
case GL_VERTEX_PROGRAM_ARB:
- vp->translated=GL_FALSE;
- translate_vertex_shader(vp);
+ /*vp->translated=GL_FALSE;
+ translate_vertex_shader(vp);*/
//debug_vp(ctx, vp);
break;
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 64b8da1f5c..804e6e666e 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1371,7 +1371,10 @@ void r300_setup_textures(GLcontext *ctx)
r300ContextPtr r300 = R300_CONTEXT(ctx);
int max_texture_unit=-1; /* -1 translates into no setup costs for fields */
struct gl_texture_unit *texUnit;
- GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
R300_STATECHANGE(r300, txe);
R300_STATECHANGE(r300, tex.filter);
@@ -1465,7 +1468,10 @@ void r300_setup_rs_unit(GLcontext *ctx)
0x00,
0x00
};
- GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
/* This needs to be rewritten - it is a hack at best */
@@ -2126,12 +2132,14 @@ void r300ResetHwState(r300ContextPtr r300)
r300UpdateTextureState(ctx);
// r300_setup_routing(ctx, GL_TRUE);
- r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */
- r300_setup_textures(ctx);
- r300_setup_rs_unit(ctx);
+ if(hw_tcl_on == GL_FALSE){
+ r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */
+ r300_setup_textures(ctx);
+ r300_setup_rs_unit(ctx);
- r300SetupVertexShader(r300);
- r300SetupPixelShader(r300);
+ r300SetupVertexShader(r300);
+ r300SetupPixelShader(r300);
+ }
r300_set_blend_state(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_texprog.c b/src/mesa/drivers/dri/r300/r300_texprog.c
index f90c4bacb8..4f92d9094b 100644
--- a/src/mesa/drivers/dri/r300/r300_texprog.c
+++ b/src/mesa/drivers/dri/r300/r300_texprog.c
@@ -223,7 +223,10 @@ void r300GenerateTextureFragmentShader(r300ContextPtr r300)
struct r300_pixel_shader_program *p = &ps->program;
GLcontext *ctx = r300->radeon.glCtx;
int i, tc_reg;
- GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
p->tex.length = 0;
p->alu.length = 0;