1 /**************************************************************************
3 Copyright (C) 2004 Nicolai Haehnle.
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Nicolai Haehnle <prefect_@gmx.net>
40 #include "simple_list.h"
42 #include "api_arrayelt.h"
43 #include "swrast/swrast.h"
44 #include "swrast_setup/swrast_setup.h"
45 #include "array_cache/acache.h"
47 #include "tnl/t_vp_build.h"
49 #include "radeon_reg.h"
50 #include "radeon_macros.h"
51 #include "radeon_ioctl.h"
52 #include "radeon_state.h"
53 #include "r300_context.h"
54 #include "r300_ioctl.h"
55 #include "r300_state.h"
57 #include "r300_program.h"
59 #include "r300_maos.h"
60 #include "r300_emit.h"
62 extern int future_hw_tcl_on
;
64 /**********************************************************************
65 * Hardware rasterization
67 * When we fell back to software TCL, we still try to use the
68 * rasterization hardware for rendering.
69 **********************************************************************/
71 static int r300_get_primitive_type(r300ContextPtr rmesa
, GLcontext
*ctx
, int prim
)
75 switch (prim
& PRIM_MODE_MASK
) {
77 type
=R300_VAP_VF_CNTL__PRIM_POINTS
;
80 type
=R300_VAP_VF_CNTL__PRIM_LINES
;
83 type
=R300_VAP_VF_CNTL__PRIM_LINE_STRIP
;
86 type
=R300_VAP_VF_CNTL__PRIM_LINE_LOOP
;
89 type
=R300_VAP_VF_CNTL__PRIM_TRIANGLES
;
91 case GL_TRIANGLE_STRIP
:
92 type
=R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP
;
95 type
=R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN
;
98 type
=R300_VAP_VF_CNTL__PRIM_QUADS
;
101 type
=R300_VAP_VF_CNTL__PRIM_QUAD_STRIP
;
104 type
=R300_VAP_VF_CNTL__PRIM_POLYGON
;
107 fprintf(stderr
, "%s:%s Do not know how to handle primitive %02x - help me !\n",
108 __FILE__
, __FUNCTION__
,
109 prim
& PRIM_MODE_MASK
);
116 static int r300_get_num_verts(r300ContextPtr rmesa
,
122 char *name
="UNKNOWN";
124 switch (prim
& PRIM_MODE_MASK
) {
131 verts_off
= num_verts
% 2;
136 verts_off
= num_verts
;
141 verts_off
= num_verts
;
145 verts_off
= num_verts
% 3;
147 case GL_TRIANGLE_STRIP
:
150 verts_off
= num_verts
;
152 case GL_TRIANGLE_FAN
:
155 verts_off
= num_verts
;
159 verts_off
= num_verts
% 4;
164 verts_off
= num_verts
;
166 verts_off
= num_verts
% 2;
171 verts_off
= num_verts
;
174 fprintf(stderr
, "%s:%s Do not know how to handle primitive %02x - help me !\n",
175 __FILE__
, __FUNCTION__
,
176 prim
& PRIM_MODE_MASK
);
181 if (RADEON_DEBUG
& DEBUG_VERTS
) {
182 if (num_verts
- verts_off
== 0) {
183 WARN_ONCE("user error: Need more than %d vertices to draw primitive %s !\n", num_verts
, name
);
188 WARN_ONCE("user error: %d is not a valid number of vertices for primitive %s !\n", num_verts
, name
);
192 return num_verts
- verts_off
;
195 /* This function compiles GL context into state registers that
196 describe data routing inside of R300 pipeline.
198 In particular, it programs input_route, output_vtx_fmt, texture
199 unit configuration and gb_output_vtx_fmt
201 This function encompasses setup_AOS() from r300_lib.c
207 /* Immediate implementation - vertex data is sent via command stream */
209 static GLfloat default_vector
[4]={0.0, 0.0, 0.0, 1.0};
211 #define output_vector(v, i) { \
213 for(_i=0;_i<v->size;_i++){ \
215 efloat(VEC_ELT(v, GLfloat, VB->Elts[i])[_i]); \
217 efloat(VEC_ELT(v, GLfloat, i)[_i]); \
220 for(_i=v->size;_i<4;_i++){ \
221 efloat(default_vector[_i]); \
225 /* Immediate implementation - vertex data is sent via command stream */
227 static void r300_render_immediate_primitive(r300ContextPtr rmesa
,
233 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
234 struct vertex_buffer
*VB
= &tnl
->vb
;
235 GLuint i
, render_inputs
;
236 int k
, type
, num_verts
;
239 type
=r300_get_primitive_type(rmesa
, ctx
, prim
);
240 num_verts
=r300_get_num_verts(rmesa
, ctx
, end
-start
, prim
);
243 fprintf(stderr
,"ObjPtr: size=%d stride=%d\n",
244 VB
->ObjPtr
->size
, VB
->ObjPtr
->stride
);
245 fprintf(stderr
,"ColorPtr[0]: size=%d stride=%d\n",
246 VB
->ColorPtr
[0]->size
, VB
->ColorPtr
[0]->stride
);
247 fprintf(stderr
,"TexCoordPtr[0]: size=%d stride=%d\n",
248 VB
->TexCoordPtr
[0]->size
, VB
->TexCoordPtr
[0]->stride
);
251 if(type
<0 || num_verts
<= 0)return;
254 WARN_ONCE("FIXME: Don't know how to handle GL_ARB_vertex_buffer_object correctly\n");
257 /* A packet cannot have more than 16383 data words.. */
258 if((num_verts
*4*rmesa
->state
.aos_count
)>16380){
259 WARN_ONCE("Too many vertices to paint. Fix me !\n");
263 //fprintf(stderr, "aos_count=%d start=%d end=%d\n", rmesa->state.aos_count, start, end);
265 if(rmesa
->state
.aos_count
==0){
266 WARN_ONCE("Aeiee ! aos_count==0, while it shouldn't. Skipping rendering\n");
270 render_inputs
= rmesa
->state
.render_inputs
;
273 WARN_ONCE("Aeiee ! render_inputs==0. Skipping rendering.\n");
278 start_immediate_packet(num_verts
, type
, 4*rmesa
->state
.aos_count
);
280 for(i
=start
;i
<start
+num_verts
;i
++){
282 fprintf(stderr
, "* (%f %f %f %f) (%f %f %f %f)\n",
283 VEC_ELT(VB
->ObjPtr
, GLfloat
, i
)[0],
284 VEC_ELT(VB
->ObjPtr
, GLfloat
, i
)[1],
285 VEC_ELT(VB
->ObjPtr
, GLfloat
, i
)[2],
286 VEC_ELT(VB
->ObjPtr
, GLfloat
, i
)[3],
288 VEC_ELT(VB
->ColorPtr
[0], GLfloat
, i
)[0],
289 VEC_ELT(VB
->ColorPtr
[0], GLfloat
, i
)[1],
290 VEC_ELT(VB
->ColorPtr
[0], GLfloat
, i
)[2],
291 VEC_ELT(VB
->ColorPtr
[0], GLfloat
, i
)[3]
297 if(render_inputs
& _TNL_BIT_POS
)
298 output_vector(VB
->ObjPtr
, i
);
299 if(render_inputs
& _TNL_BIT_NORMAL
)
300 output_vector(VB
->NormalPtr
, i
);
302 /* color components */
303 if(render_inputs
& _TNL_BIT_COLOR0
)
304 output_vector(VB
->ColorPtr
[0], i
);
305 if(render_inputs
& _TNL_BIT_COLOR1
)
306 output_vector(VB
->SecondaryColorPtr
[0], i
);
308 /* if(render_inputs & _TNL_BIT_FOG) // Causes lock ups when immediate mode is on
309 output_vector(VB->FogCoordPtr, i);*/
311 /* texture coordinates */
312 for(k
=0;k
< ctx
->Const
.MaxTextureUnits
;k
++)
313 if(render_inputs
& (_TNL_BIT_TEX0
<<k
))
314 output_vector(VB
->TexCoordPtr
[k
], i
);
316 if(render_inputs
& _TNL_BIT_INDEX
)
317 output_vector(VB
->IndexPtr
[0], i
);
318 if(render_inputs
& _TNL_BIT_POINTSIZE
)
319 output_vector(VB
->PointSizePtr
, i
);
325 static GLboolean
r300_run_immediate_render(GLcontext
*ctx
,
326 struct tnl_pipeline_stage
*stage
)
328 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
329 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
330 struct vertex_buffer
*VB
= &tnl
->vb
;
335 /* Update texture state - needs to be done only when actually changed..
336 All the time for now.. */
339 if (RADEON_DEBUG
== DEBUG_PRIMS
)
340 fprintf(stderr
, "%s\n", __FUNCTION__
);
342 #if 1 /* we need this, somehow */
343 /* Flush state - make sure command buffer is nice and large */
345 /* Make sure we have enough space */
347 /* Count is very imprecize, but should be good upper bound */
348 r300EnsureCmdBufSpace(rmesa
, rmesa
->hw
.max_state_size
+ 4+2+30
349 +VB
->PrimitiveCount
*(1+8)+VB
->Count
*4*rmesa
->state
.texture
.tc_count
+4, __FUNCTION__
);
352 /* needed before starting 3d operation .. */
353 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
360 #if 0 /* looks like the Z offset issue got fixed */
361 rmesa
->hw
.vte
.cmd
[1] = R300_VPORT_X_SCALE_ENA
362 | R300_VPORT_X_OFFSET_ENA
363 | R300_VPORT_Y_SCALE_ENA
364 | R300_VPORT_Y_OFFSET_ENA
366 R300_STATECHANGE(rmesa
, vte
);
371 /* Magic register - note it is right after 20b0 */
374 if(rmesa
->state
.texture
.tc_count
>0){
380 r300EmitState(rmesa
);
382 /* Setup INPUT_ROUTE and INPUT_CNTL */
383 r300EmitArrays(ctx
, GL_TRUE
);
385 /* Why do we need this for immediate mode?? Vertex processor needs it to know proper regs */
386 // r300EmitLOAD_VBPNTR(rmesa, 0);
387 /* Okay, it seems I misunderstood something, EmitAOS does the same thing */
388 r300EmitAOS(rmesa
, rmesa
->state
.aos_count
, 0);
390 for(i
=0; i
< VB
->PrimitiveCount
; i
++){
391 GLuint prim
= VB
->Primitive
[i
].mode
;
392 GLuint start
= VB
->Primitive
[i
].start
;
393 GLuint length
= VB
->Primitive
[i
].count
;
395 r300_render_immediate_primitive(rmesa
, ctx
, start
, start
+ length
, prim
);
398 /* This sequence is required after any 3d drawing packet
399 I suspect it work arounds a bug (or deficiency) in hardware */
401 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
411 /* vertex buffer implementation */
413 static void inline fire_EB(PREFIX
unsigned long addr
, int vertex_count
, int type
, int elt_size
)
416 unsigned long addr_a
;
417 unsigned long t_addr
;
418 unsigned long magic_1
, magic_2
;
420 ctx
= rmesa
->radeon
.glCtx
;
422 assert(elt_size
== 2 || elt_size
== 4);
424 if(addr
& (elt_size
-1)){
425 WARN_ONCE("Badly aligned buffer\n");
431 magic_1
= (addr
% 32) / 4;
432 t_addr
= addr
& (~0x1d);
433 magic_2
= (vertex_count
+ 1 + (t_addr
& 0x2)) / 2 + magic_1
;
437 start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2
, 0);
439 e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (vertex_count
<<16) | type
| R300_VAP_VF_CNTL__INDEX_SIZE_32bit
);
441 e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (vertex_count
<<16) | type
);
444 start_packet3(RADEON_CP_PACKET3_INDX_BUFFER
, 2);
446 e32(R300_EB_UNK1
| (0 << 16) | R300_EB_UNK2
);
447 e32(addr
/*& 0xffffffe3*/);
449 e32(R300_EB_UNK1
| (magic_1
<< 16) | R300_EB_UNK2
);
454 e32(vertex_count
/*+ addr_a/4*/); /* Total number of dwords needed? */
456 e32(magic_2
); /* Total number of dwords needed? */
458 //cp_delay(PASS_PREFIX 1);
460 fprintf(stderr
, "magic_1 %d\n", magic_1
);
461 fprintf(stderr
, "t_addr %x\n", t_addr
);
462 fprintf(stderr
, "magic_2 %d\n", magic_2
);
466 (void)magic_2
, (void)magic_1
, (void)t_addr
;
472 start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2
, 0);
474 e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (vertex_count
<<16) | type
| R300_VAP_VF_CNTL__INDEX_SIZE_32bit
);
476 e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES
| (vertex_count
<<16) | type
);
479 start_packet3(RADEON_CP_PACKET3_INDX_BUFFER
, 2);
480 e32(R300_EB_UNK1
| (0 << 16) | R300_EB_UNK2
);
481 e32(addr
/*& 0xffffffe3*/);
484 e32(vertex_count
/*+ addr_a/4*/); /* Total number of dwords needed? */
486 e32((vertex_count
+1)/2 /*+ addr_a/4*/); /* Total number of dwords needed? */
488 //cp_delay(PASS_PREFIX 1);
492 static void r300_render_vb_primitive(r300ContextPtr rmesa
,
501 type
=r300_get_primitive_type(rmesa
, ctx
, prim
);
502 num_verts
=r300_get_num_verts(rmesa
, ctx
, end
-start
, prim
);
504 if(type
<0 || num_verts
<= 0)return;
506 if(rmesa
->state
.Elts
){
507 r300EmitAOS(rmesa
, rmesa
->state
.aos_count
, 0);
510 start_index32_packet(num_verts
, type
);
511 for(i
=0; i
< num_verts
; i
++)
512 e32(rmesa
->state
.Elts
[start
+i
]); /* start ? */
514 WARN_ONCE("Rendering with elt buffers\n");
516 start_index32_packet(num_verts
, type
);
517 e32(rmesa
->state
.Elts
[start
]);
521 if(num_verts
> 65535){ /* not implemented yet */
522 WARN_ONCE("Too many elts\n");
525 r300EmitElts(ctx
, rmesa
->state
.Elts
+start
, num_verts
, 4);
526 fire_EB(PASS_PREFIX
GET_START(&(rmesa
->state
.elt_dma
)), num_verts
, type
, 4);
529 r300EmitAOS(rmesa
, rmesa
->state
.aos_count
, start
);
530 fire_AOS(PASS_PREFIX num_verts
, type
);
534 static GLboolean
r300_run_vb_render(GLcontext
*ctx
,
535 struct tnl_pipeline_stage
*stage
)
537 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
538 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
539 struct vertex_buffer
*VB
= &tnl
->vb
;
543 if (RADEON_DEBUG
& DEBUG_PRIMS
)
544 fprintf(stderr
, "%s\n", __FUNCTION__
);
547 r300UpdateShaders(rmesa
);
549 r300ReleaseArrays(ctx
);
550 r300EmitArrays(ctx
, GL_FALSE
);
552 r300UpdateShaderStates(rmesa
);
553 // LOCK_HARDWARE(&(rmesa->radeon));
555 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
560 r300EmitState(rmesa
);
562 rmesa
->state
.Elts
= VB
->Elts
;
564 for(i
=0; i
< VB
->PrimitiveCount
; i
++){
565 GLuint prim
= VB
->Primitive
[i
].mode
;
566 GLuint start
= VB
->Primitive
[i
].start
;
567 GLuint length
= VB
->Primitive
[i
].count
;
569 r300_render_vb_primitive(rmesa
, ctx
, start
, start
+ length
, prim
);
572 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
581 // end_3d(PASS_PREFIX_VOID);
583 /* Flush state - we are done drawing.. */
584 // r300FlushCmdBufLocked(rmesa, __FUNCTION__);
585 // radeonWaitForIdleLocked(&(rmesa->radeon));
587 // UNLOCK_HARDWARE(&(rmesa->radeon));
591 #ifdef RADEON_VTXFMT_A
593 static void r300_render_vb_primitive_vtxfmt_a(r300ContextPtr rmesa
,
600 radeonScreenPtr rsp
=rmesa
->radeon
.radeonScreen
;
602 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
603 struct vertex_buffer
*VB
= &tnl
->vb
;
606 type
=r300_get_primitive_type(rmesa
, ctx
, prim
);
607 num_verts
=r300_get_num_verts(rmesa
, ctx
, end
-start
, prim
);
609 if(type
<0 || num_verts
<= 0)return;
611 if(rmesa
->state
.VB
.Elts
){
612 r300EmitAOS(rmesa
, rmesa
->state
.aos_count
, /*0*/start
);
614 start_index32_packet(num_verts
, type
);
615 for(i
=0; i
< num_verts
; i
++)
616 e32(((unsigned long *)rmesa
->state
.VB
.Elts
)[i
]/*rmesa->state.Elts[start+i]*/); /* start ? */
618 WARN_ONCE("Rendering with elt buffers\n");
620 //start_index32_packet(num_verts, type);
621 //e32(rmesa->state.Elts[start]);
625 if(num_verts
> 65535){ /* not implemented yet */
626 WARN_ONCE("Too many elts\n");
630 r300EmitElts(ctx
, rmesa
->state
.VB
.Elts
, num_verts
, rmesa
->state
.VB
.elt_size
);
631 fire_EB(PASS_PREFIX rmesa
->state
.elt_dma
.aos_offset
, num_verts
, type
, rmesa
->state
.VB
.elt_size
);
634 r300EmitAOS(rmesa
, rmesa
->state
.aos_count
, start
);
635 fire_AOS(PASS_PREFIX num_verts
, type
);
639 void dump_array(struct r300_dma_region
*rvb
, int count
)
641 int *out
= (int *)(rvb
->address
+ rvb
->start
);
644 for (i
=0; i
< count
; i
++) {
645 fprintf(stderr
, "{");
646 if (rvb
->aos_format
== AOS_FORMAT_FLOAT
)
647 for (ci
=0; ci
< rvb
->aos_size
; ci
++)
648 fprintf(stderr
, "%f ", ((float *)out
)[ci
]);
650 for (ci
=0; ci
< rvb
->aos_size
; ci
++)
651 fprintf(stderr
, "%d ", ((unsigned char *)out
)[ci
]);
652 fprintf(stderr
, "}");
654 out
+= rvb
->aos_stride
;
657 fprintf(stderr
, "\n");
660 void dump_dt(struct dt
*dt
, int count
)
665 fprintf(stderr
, "base at %p ", out
);
667 for (i
=0; i
< count
; i
++){
668 fprintf(stderr
, "{");
669 if (dt
->type
== GL_FLOAT
)
670 for (ci
=0; ci
< dt
->size
; ci
++)
671 fprintf(stderr
, "%f ", ((float *)out
)[ci
]);
673 for (ci
=0; ci
< dt
->size
; ci
++)
674 fprintf(stderr
, "%d ", ((unsigned char *)out
)[ci
]);
675 fprintf(stderr
, "}");
677 out
= (char *)out
+ dt
->stride
;
680 fprintf(stderr
, "\n");
683 /*static */GLboolean
r300_run_vb_render_vtxfmt_a(GLcontext
*ctx
,
684 struct tnl_pipeline_stage
*stage
)
686 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
687 //TNLcontext *tnl = TNL_CONTEXT(ctx);
688 struct radeon_vertex_buffer
*VB
= &rmesa
->state
.VB
; //&tnl->vb;
692 if (RADEON_DEBUG
& DEBUG_PRIMS
)
693 fprintf(stderr
, "%s\n", __FUNCTION__
);
695 if (rmesa
->state
.VB
.LockCount
== 0) {
696 r300ReleaseArrays(ctx
);
697 r300EmitArraysVtx(ctx
, GL_FALSE
);
699 r300UpdateShaderStates(rmesa
);
701 /* TODO: Figure out why do we need these. */
702 R300_STATECHANGE(rmesa
, vir
[0]);
703 R300_STATECHANGE(rmesa
, vir
[1]);
704 R300_STATECHANGE(rmesa
, vic
);
705 R300_STATECHANGE(rmesa
, vof
);
708 fprintf(stderr
, "dt:\n");
709 for(i
=0; i
< VERT_ATTRIB_MAX
; i
++){
710 fprintf(stderr
, "dt %d:", i
);
711 dump_dt(&rmesa
->state
.VB
.AttribPtr
[i
], VB
->Count
);
714 fprintf(stderr
, "before:\n");
715 for(i
=0; i
< rmesa
->state
.aos_count
; i
++){
716 fprintf(stderr
, "aos %d:", i
);
717 dump_array(&rmesa
->state
.aos
[i
], VB
->Count
);
721 r300ReleaseArrays(ctx
);
722 r300EmitArraysVtx(ctx
, GL_FALSE
);
724 fprintf(stderr
, "after:\n");
725 for(i
=0; i
< rmesa
->state
.aos_count
; i
++){
726 fprintf(stderr
, "aos %d:", i
);
727 dump_array(&rmesa
->state
.aos
[i
], VB
->Count
);
732 // LOCK_HARDWARE(&(rmesa->radeon));
734 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
740 reg_start(R300_VAP_PVS_WAITIDLE
,0);
743 r300EmitState(rmesa
);
745 for(i
=0; i
< VB
->PrimitiveCount
; i
++){
746 GLuint prim
= VB
->Primitive
[i
].mode
;
747 GLuint start
= VB
->Primitive
[i
].start
;
748 GLuint length
= VB
->Primitive
[i
].count
;
750 r300_render_vb_primitive_vtxfmt_a(rmesa
, ctx
, start
, start
+ length
, prim
);
753 reg_start(R300_RB3D_DSTCACHE_CTLSTAT
,0);
754 e32(0x0000000a/*0x2*/);
757 e32(0x00000003/*0x1*/);
762 // end_3d(PASS_PREFIX_VOID);
764 /* Flush state - we are done drawing.. */
765 // r300FlushCmdBufLocked(rmesa, __FUNCTION__);
766 // radeonWaitForIdleLocked(&(rmesa->radeon));
768 // UNLOCK_HARDWARE(&(rmesa->radeon));
773 #define FALLBACK_IF(expr) \
776 if (1 || RADEON_DEBUG & DEBUG_FALLBACKS) \
777 WARN_ONCE("fallback:%s\n", #expr); \
782 GLboolean
r300Fallback(GLcontext
*ctx
)
785 FALLBACK_IF(ctx
->RenderMode
!= GL_RENDER
); // We do not do SELECT or FEEDBACK (yet ?)
787 #if 0 /* These should work now.. */
788 FALLBACK_IF(ctx
->Color
.DitherFlag
);
789 FALLBACK_IF(ctx
->Color
.AlphaEnabled
); // GL_ALPHA_TEST
790 FALLBACK_IF(ctx
->Color
.BlendEnabled
); // GL_BLEND
791 FALLBACK_IF(ctx
->Polygon
.OffsetFill
); // GL_POLYGON_OFFSET_FILL
793 FALLBACK_IF(ctx
->Polygon
.OffsetPoint
); // GL_POLYGON_OFFSET_POINT
794 FALLBACK_IF(ctx
->Polygon
.OffsetLine
); // GL_POLYGON_OFFSET_LINE
795 //FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
797 //FALLBACK_IF(ctx->Fog.Enabled); // GL_FOG disable as swtcl doesnt seem to support this
798 //FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH disabling to get blender going
799 FALLBACK_IF(ctx
->Polygon
.StippleFlag
); // GL_POLYGON_STIPPLE
800 FALLBACK_IF(ctx
->Multisample
.Enabled
); // GL_MULTISAMPLE_ARB
803 FALLBACK_IF(ctx
->Line
.StippleFlag
);
805 /* HW doesnt appear to directly support these */
806 FALLBACK_IF(ctx
->Line
.SmoothFlag
); // GL_LINE_SMOOTH
807 FALLBACK_IF(ctx
->Point
.SmoothFlag
); // GL_POINT_SMOOTH
808 /* Rest could be done with vertex fragments */
809 if (ctx
->Extensions
.NV_point_sprite
|| ctx
->Extensions
.ARB_point_sprite
)
810 FALLBACK_IF(ctx
->Point
.PointSprite
); // GL_POINT_SPRITE_NV
816 * Called by the pipeline manager to render a batch of primitives.
817 * We can return true to pass on to the next stage (i.e. software
818 * rasterization) or false to indicate that the pipeline has finished
819 * after we render something.
821 static GLboolean
r300_run_render(GLcontext
*ctx
,
822 struct tnl_pipeline_stage
*stage
)
825 if (RADEON_DEBUG
& DEBUG_PRIMS
)
826 fprintf(stderr
, "%s\n", __FUNCTION__
);
828 if (r300Fallback(ctx
))
831 return r300_run_immediate_render(ctx
, stage
);
833 return r300_run_vb_render(ctx
, stage
);
837 const struct tnl_pipeline_stage _r300_render_stage
= {
843 r300_run_render
/* run */
846 static GLboolean
r300_run_tcl_render(GLcontext
*ctx
,
847 struct tnl_pipeline_stage
*stage
)
849 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
851 hw_tcl_on
=future_hw_tcl_on
;
853 if (RADEON_DEBUG
& DEBUG_PRIMS
)
854 fprintf(stderr
, "%s\n", __FUNCTION__
);
855 if(hw_tcl_on
== GL_FALSE
)
858 //r300UpdateShaders(rmesa);
859 //r300UpdateShaderStates(rmesa);
861 return r300_run_vb_render(ctx
, stage
);
864 static void r300_check_tcl_render(GLcontext
*ctx
, struct tnl_pipeline_stage
*stage
)
867 if (RADEON_DEBUG
& DEBUG_STATE
)
868 fprintf(stderr
, "%s\n", __FUNCTION__
);
870 /* We only support rendering in hardware for now */
871 if (ctx
->RenderMode
!= GL_RENDER
) {
872 //stage->active = GL_FALSE;
877 const struct tnl_pipeline_stage _r300_tcl_stage
= {
883 r300_run_tcl_render
/* run */