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,
r300InitStateFuncs(&functions);
r300InitTextureFuncs(&functions);
r300InitShaderFuncs(&functions);
+ if(hw_tcl_on){
+ functions.BufferData = r300BufferData;
+ functions.DeleteBuffer = r300DeleteBuffer;
+ }
if (!radeonInitContext(&r300->radeon, &functions,
glVisual, driContextPriv, sharedContextPrivate)) {
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))))
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;
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);
rvb->aos_stride = size;
rvb->aos_size = size;
}
-
+
/* Emit the data
*/
switch (size) {
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);
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) { \
}
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;
fprintf(stderr, "%s\n", __FUNCTION__);
- r300ReleaseArrays(ctx);
+ r300ReleaseArrays(ctx);
r300EmitArrays(ctx, GL_FALSE);
//dump_inputs(ctx, rmesa->state.render_inputs);
reg_start(0x4f18,0);
e32(0x00000003);
r300EmitState(rmesa);
+
+ if(hw_tcl_on) /* FIXME */
+ r300FlushCmdBuf(rmesa, __FUNCTION__);
rmesa->state.Elts = VB->Elts;
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)
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);
}
}
}
-/* 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;
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;
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);
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 */
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);
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;