2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
33 * \author Keith Whitwell <keith@tungstengraphics.com>
34 * \author Nicolai Haehnle <prefect_@gmx.net>
37 #ifndef __R300_CONTEXT_H__
38 #define __R300_CONTEXT_H__
40 #include "tnl/t_vertex.h"
42 #include "radeon_drm.h"
45 #include "radeon_bo.h"
47 #include "main/macros.h"
48 #include "main/mtypes.h"
49 #include "main/colormac.h"
52 typedef struct r300_context r300ContextRec
;
53 typedef struct r300_context
*r300ContextPtr
;
55 #include "radeon_lock.h"
58 /* From http://gcc. gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
59 I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
60 with other compilers ... GLUE!
62 #define WARN_ONCE(a, ...) { \
63 static int warn##__LINE__=1; \
65 fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \
66 fprintf(stderr, "File %s function %s line %d\n", \
67 __FILE__, __FUNCTION__, __LINE__); \
68 fprintf(stderr, a, ## __VA_ARGS__);\
69 fprintf(stderr, "***************************************************************************\n"); \
74 #include "r300_vertprog.h"
75 #include "r500_fragprog.h"
78 * This function takes a float and packs it into a uint32_t
80 static INLINE
uint32_t r300PackFloat32(float fl
)
91 /* This is probably wrong for some values, I need to test this
92 * some more. Range checking would be a good idea also..
94 * But it works for most things. I'll fix it later if someone
95 * else with a better clue doesn't
97 static INLINE
uint32_t r300PackFloat24(float f
)
101 uint32_t float24
= 0;
106 mantissa
= frexpf(f
, &exponent
);
110 float24
|= (1 << 23);
111 mantissa
= mantissa
* -1.0;
113 /* Handle exponent, bias of 63 */
115 float24
|= (exponent
<< 16);
116 /* Kill 7 LSB of mantissa */
117 float24
|= (r300PackFloat32(mantissa
) & 0x7FFFFF) >> 7;
122 /************ DMA BUFFERS **************/
125 /* Texture related */
126 typedef struct r300_tex_obj r300TexObj
, *r300TexObjPtr
;
127 typedef struct _r300_texture_image r300_texture_image
;
130 struct _r300_texture_image
{
131 struct gl_texture_image base
;
134 * If mt != 0, the image is stored in hardware format in the
135 * given mipmap tree. In this case, base.Data may point into the
136 * mapping of the buffer object that contains the mipmap tree.
138 * If mt == 0, the image is stored in normal memory pointed to
141 struct _r300_mipmap_tree
*mt
;
142 struct radeon_bo
*bo
;
144 int mtlevel
; /** if mt != 0, this is the image's level in the mipmap tree */
145 int mtface
; /** if mt != 0, this is the image's face in the mipmap tree */
148 static INLINE r300_texture_image
*get_r300_texture_image(struct gl_texture_image
*image
)
150 return (r300_texture_image
*)image
;
154 /* Texture object in locally shared texture space.
156 struct r300_tex_obj
{
157 struct gl_texture_object base
;
158 struct _r300_mipmap_tree
*mt
;
161 * This is true if we've verified that the mipmap tree above is complete
166 GLboolean image_override
; /* Image overridden by GLX_EXT_tfp */
167 GLuint override_offset
;
169 /* hardware register values */
170 /* Note that R200 has 8 registers per texture and R300 only 7 */
174 GLuint size
; /* npot only */
176 GLuint pp_border_color
;
177 /* end hardware registers */
179 GLuint tile_bits
; /* hw texture tile bits used on this texture */
180 struct radeon_bo
*bo
;
183 static INLINE r300TexObj
* r300_tex_obj(struct gl_texture_object
*texObj
)
185 return (r300TexObj
*)texObj
;
188 /* The blit width for texture uploads
190 #define R300_BLIT_WIDTH_BYTES 1024
191 #define R300_MAX_TEXTURE_UNITS 8
193 struct r300_texture_state
{
194 int tc_count
; /* number of incoming texture coordinates from VAP */
198 #define R300_VPT_CMD_0 0
199 #define R300_VPT_XSCALE 1
200 #define R300_VPT_XOFFSET 2
201 #define R300_VPT_YSCALE 3
202 #define R300_VPT_YOFFSET 4
203 #define R300_VPT_ZSCALE 5
204 #define R300_VPT_ZOFFSET 6
205 #define R300_VPT_CMDSIZE 7
207 #define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */
208 #define R300_VIR_CNTL_0 1
209 #define R300_VIR_CNTL_1 2
210 #define R300_VIR_CNTL_2 3
211 #define R300_VIR_CNTL_3 4
212 #define R300_VIR_CNTL_4 5
213 #define R300_VIR_CNTL_5 6
214 #define R300_VIR_CNTL_6 7
215 #define R300_VIR_CNTL_7 8
216 #define R300_VIR_CMDSIZE 9
218 #define R300_VIC_CMD_0 0
219 #define R300_VIC_CNTL_0 1
220 #define R300_VIC_CNTL_1 2
221 #define R300_VIC_CMDSIZE 3
223 #define R300_VOF_CMD_0 0
224 #define R300_VOF_CNTL_0 1
225 #define R300_VOF_CNTL_1 2
226 #define R300_VOF_CMDSIZE 3
228 #define R300_PVS_CMD_0 0
229 #define R300_PVS_CNTL_1 1
230 #define R300_PVS_CNTL_2 2
231 #define R300_PVS_CNTL_3 3
232 #define R300_PVS_CMDSIZE 4
234 #define R300_GB_MISC_CMD_0 0
235 #define R300_GB_MISC_MSPOS_0 1
236 #define R300_GB_MISC_MSPOS_1 2
237 #define R300_GB_MISC_TILE_CONFIG 3
238 #define R300_GB_MISC_SELECT 4
239 #define R300_GB_MISC_AA_CONFIG 5
240 #define R300_GB_MISC_CMDSIZE 6
242 #define R300_TXE_CMD_0 0
243 #define R300_TXE_ENABLE 1
244 #define R300_TXE_CMDSIZE 2
246 #define R300_PS_CMD_0 0
247 #define R300_PS_POINTSIZE 1
248 #define R300_PS_CMDSIZE 2
250 #define R300_ZBS_CMD_0 0
251 #define R300_ZBS_T_FACTOR 1
252 #define R300_ZBS_T_CONSTANT 2
253 #define R300_ZBS_W_FACTOR 3
254 #define R300_ZBS_W_CONSTANT 4
255 #define R300_ZBS_CMDSIZE 5
257 #define R300_CUL_CMD_0 0
258 #define R300_CUL_CULL 1
259 #define R300_CUL_CMDSIZE 2
261 #define R300_RC_CMD_0 0
262 #define R300_RC_CNTL_0 1
263 #define R300_RC_CNTL_1 2
264 #define R300_RC_CMDSIZE 3
266 #define R300_RI_CMD_0 0
267 #define R300_RI_INTERP_0 1
268 #define R300_RI_INTERP_1 2
269 #define R300_RI_INTERP_2 3
270 #define R300_RI_INTERP_3 4
271 #define R300_RI_INTERP_4 5
272 #define R300_RI_INTERP_5 6
273 #define R300_RI_INTERP_6 7
274 #define R300_RI_INTERP_7 8
275 #define R300_RI_CMDSIZE 9
277 #define R500_RI_CMDSIZE 17
279 #define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
280 #define R300_RR_INST_0 1
281 #define R300_RR_INST_1 2
282 #define R300_RR_INST_2 3
283 #define R300_RR_INST_3 4
284 #define R300_RR_INST_4 5
285 #define R300_RR_INST_5 6
286 #define R300_RR_INST_6 7
287 #define R300_RR_INST_7 8
288 #define R300_RR_CMDSIZE 9
290 #define R300_FP_CMD_0 0
291 #define R300_FP_CNTL0 1
292 #define R300_FP_CNTL1 2
293 #define R300_FP_CNTL2 3
294 #define R300_FP_CMD_1 4
295 #define R300_FP_NODE0 5
296 #define R300_FP_NODE1 6
297 #define R300_FP_NODE2 7
298 #define R300_FP_NODE3 8
299 #define R300_FP_CMDSIZE 9
301 #define R500_FP_CMD_0 0
302 #define R500_FP_CNTL 1
303 #define R500_FP_PIXSIZE 2
304 #define R500_FP_CMD_1 3
305 #define R500_FP_CODE_ADDR 4
306 #define R500_FP_CODE_RANGE 5
307 #define R500_FP_CODE_OFFSET 6
308 #define R500_FP_CMD_2 7
309 #define R500_FP_FC_CNTL 8
310 #define R500_FP_CMDSIZE 9
312 #define R300_FPT_CMD_0 0
313 #define R300_FPT_INSTR_0 1
314 #define R300_FPT_CMDSIZE 65
316 #define R300_FPI_CMD_0 0
317 #define R300_FPI_INSTR_0 1
318 #define R300_FPI_CMDSIZE 65
319 /* R500 has space for 512 instructions - 6 dwords per instruction */
320 #define R500_FPI_CMDSIZE (512*6+1)
322 #define R300_FPP_CMD_0 0
323 #define R300_FPP_PARAM_0 1
324 #define R300_FPP_CMDSIZE (32*4+1)
325 /* R500 has spcae for 256 constants - 4 dwords per constant */
326 #define R500_FPP_CMDSIZE (256*4+1)
328 #define R300_FOGS_CMD_0 0
329 #define R300_FOGS_STATE 1
330 #define R300_FOGS_CMDSIZE 2
332 #define R300_FOGC_CMD_0 0
333 #define R300_FOGC_R 1
334 #define R300_FOGC_G 2
335 #define R300_FOGC_B 3
336 #define R300_FOGC_CMDSIZE 4
338 #define R300_FOGP_CMD_0 0
339 #define R300_FOGP_SCALE 1
340 #define R300_FOGP_START 2
341 #define R300_FOGP_CMDSIZE 3
343 #define R300_AT_CMD_0 0
344 #define R300_AT_ALPHA_TEST 1
345 #define R300_AT_UNKNOWN 2
346 #define R300_AT_CMDSIZE 3
348 #define R300_BLD_CMD_0 0
349 #define R300_BLD_CBLEND 1
350 #define R300_BLD_ABLEND 2
351 #define R300_BLD_CMDSIZE 3
353 #define R300_CMK_CMD_0 0
354 #define R300_CMK_COLORMASK 1
355 #define R300_CMK_CMDSIZE 2
357 #define R300_CB_CMD_0 0
358 #define R300_CB_OFFSET 1
359 #define R300_CB_CMD_1 2
360 #define R300_CB_PITCH 3
361 #define R300_CB_CMDSIZE 4
363 #define R300_ZS_CMD_0 0
364 #define R300_ZS_CNTL_0 1
365 #define R300_ZS_CNTL_1 2
366 #define R300_ZS_CNTL_2 3
367 #define R300_ZS_CMDSIZE 4
369 #define R300_ZB_CMD_0 0
370 #define R300_ZB_OFFSET 1
371 #define R300_ZB_PITCH 2
372 #define R300_ZB_CMDSIZE 3
374 #define R300_VAP_CNTL_FLUSH 0
375 #define R300_VAP_CNTL_FLUSH_1 1
376 #define R300_VAP_CNTL_CMD 2
377 #define R300_VAP_CNTL_INSTR 3
378 #define R300_VAP_CNTL_SIZE 4
380 #define R300_VPI_CMD_0 0
381 #define R300_VPI_INSTR_0 1
382 #define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */
384 #define R300_VPP_CMD_0 0
385 #define R300_VPP_PARAM_0 1
386 #define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */
388 #define R300_VPUCP_CMD_0 0
389 #define R300_VPUCP_X 1
390 #define R300_VPUCP_Y 2
391 #define R300_VPUCP_Z 3
392 #define R300_VPUCP_W 4
393 #define R300_VPUCP_CMDSIZE 5 /* 256 4-component parameters */
395 #define R300_VPS_CMD_0 0
396 #define R300_VPS_ZERO_0 1
397 #define R300_VPS_ZERO_1 2
398 #define R300_VPS_POINTSIZE 3
399 #define R300_VPS_ZERO_3 4
400 #define R300_VPS_CMDSIZE 5
402 /* the layout is common for all fields inside tex */
403 #define R300_TEX_CMD_0 0
404 #define R300_TEX_VALUE_0 1
405 /* We don't really use this, instead specify mtu+1 dynamically
406 #define R300_TEX_CMDSIZE (MAX_TEXTURE_UNITS+1)
410 * Cache for hardware register state.
412 struct r300_hw_state
{
413 struct radeon_state_atom atomlist
;
417 int max_state_size
; /* in dwords */
419 struct radeon_state_atom vpt
; /* viewport (1D98) */
420 struct radeon_state_atom vap_cntl
;
421 struct radeon_state_atom vap_index_offset
; /* 0x208c r5xx only */
422 struct radeon_state_atom vof
; /* VAP output format register 0x2090 */
423 struct radeon_state_atom vte
; /* (20B0) */
424 struct radeon_state_atom vap_vf_max_vtx_indx
; /* Maximum Vertex Indx Clamp (2134) */
425 struct radeon_state_atom vap_cntl_status
;
426 struct radeon_state_atom vir
[2]; /* vap input route (2150/21E0) */
427 struct radeon_state_atom vic
; /* vap input control (2180) */
428 struct radeon_state_atom vap_psc_sgn_norm_cntl
; /* Programmable Stream Control Signed Normalize Control (21DC) */
429 struct radeon_state_atom vap_clip_cntl
;
430 struct radeon_state_atom vap_clip
;
431 struct radeon_state_atom vap_pvs_vtx_timeout_reg
; /* Vertex timeout register (2288) */
432 struct radeon_state_atom pvs
; /* pvs_cntl (22D0) */
433 struct radeon_state_atom gb_enable
; /* (4008) */
434 struct radeon_state_atom gb_misc
; /* Multisampling position shifts ? (4010) */
435 struct radeon_state_atom ga_point_s0
; /* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) (4200) */
436 struct radeon_state_atom ga_triangle_stipple
; /* (4214) */
437 struct radeon_state_atom ps
; /* pointsize (421C) */
438 struct radeon_state_atom ga_point_minmax
; /* (4230) */
439 struct radeon_state_atom lcntl
; /* line control */
440 struct radeon_state_atom ga_line_stipple
; /* (4260) */
441 struct radeon_state_atom shade
;
442 struct radeon_state_atom polygon_mode
;
443 struct radeon_state_atom fogp
; /* fog parameters (4294) */
444 struct radeon_state_atom ga_soft_reset
; /* (429C) */
445 struct radeon_state_atom zbias_cntl
;
446 struct radeon_state_atom zbs
; /* zbias (42A4) */
447 struct radeon_state_atom occlusion_cntl
;
448 struct radeon_state_atom cul
; /* cull cntl (42B8) */
449 struct radeon_state_atom su_depth_scale
; /* (42C0) */
450 struct radeon_state_atom rc
; /* rs control (4300) */
451 struct radeon_state_atom ri
; /* rs interpolators (4310) */
452 struct radeon_state_atom rr
; /* rs route (4330) */
453 struct radeon_state_atom sc_hyperz
; /* (43A4) */
454 struct radeon_state_atom sc_screendoor
; /* (43E8) */
455 struct radeon_state_atom fp
; /* fragment program cntl + nodes (4600) */
456 struct radeon_state_atom fpt
; /* texi - (4620) */
457 struct radeon_state_atom us_out_fmt
; /* (46A4) */
458 struct radeon_state_atom r500fp
; /* r500 fp instructions */
459 struct radeon_state_atom r500fp_const
; /* r500 fp constants */
460 struct radeon_state_atom fpi
[4]; /* fp instructions (46C0/47C0/48C0/49C0) */
461 struct radeon_state_atom fogs
; /* fog state (4BC0) */
462 struct radeon_state_atom fogc
; /* fog color (4BC8) */
463 struct radeon_state_atom at
; /* alpha test (4BD4) */
464 struct radeon_state_atom fg_depth_src
; /* (4BD8) */
465 struct radeon_state_atom fpp
; /* 0x4C00 and following */
466 struct radeon_state_atom rb3d_cctl
; /* (4E00) */
467 struct radeon_state_atom bld
; /* blending (4E04) */
468 struct radeon_state_atom cmk
; /* colormask (4E0C) */
469 struct radeon_state_atom blend_color
; /* constant blend color */
470 struct radeon_state_atom rop
; /* ropcntl */
471 struct radeon_state_atom cb
; /* colorbuffer (4E28) */
472 struct radeon_state_atom rb3d_dither_ctl
; /* (4E50) */
473 struct radeon_state_atom rb3d_aaresolve_ctl
; /* (4E88) */
474 struct radeon_state_atom rb3d_discard_src_pixel_lte_threshold
; /* (4E88) I saw it only written on RV350 hardware.. */
475 struct radeon_state_atom zs
; /* zstencil control (4F00) */
476 struct radeon_state_atom zstencil_format
;
477 struct radeon_state_atom zb
; /* z buffer (4F20) */
478 struct radeon_state_atom zb_depthclearvalue
; /* (4F28) */
479 struct radeon_state_atom unk4F30
; /* (4F30) */
480 struct radeon_state_atom zb_hiz_offset
; /* (4F44) */
481 struct radeon_state_atom zb_hiz_pitch
; /* (4F54) */
483 struct radeon_state_atom vpi
; /* vp instructions */
484 struct radeon_state_atom vpp
; /* vp parameters */
485 struct radeon_state_atom vps
; /* vertex point size (?) */
486 struct radeon_state_atom vpucp
[6]; /* vp user clip plane - 6 */
487 /* 8 texture units */
488 /* the state is grouped by function and not by
489 texture unit. This makes single unit updates
490 really awkward - we are much better off
491 updating the whole thing at once */
493 struct radeon_state_atom filter
;
494 struct radeon_state_atom filter_1
;
495 struct radeon_state_atom size
;
496 struct radeon_state_atom format
;
497 struct radeon_state_atom pitch
;
498 struct radeon_state_atom offset
;
499 struct radeon_state_atom chroma_key
;
500 struct radeon_state_atom border_color
;
502 struct radeon_state_atom txe
; /* tex enable (4104) */
504 r300TexObj
*textures
[R300_MAX_TEXTURE_UNITS
];
508 * This structure holds the command buffer while it is being constructed.
510 * The first batch of commands in the buffer is always the state that needs
511 * to be re-emitted when the context is lost. This batch can be skipped
515 struct radeon_cs_manager
*csm
;
516 struct radeon_cs
*cs
;
517 int size
; /** # of dwords total */
518 unsigned int flushing
:1; /** whether we're currently in FlushCmdBufLocked */
525 /* Vertex shader state */
527 /* Perhaps more if we store programs in vmem? */
528 /* drm_r300_cmd_header_t->vpu->count is unsigned char */
529 #define VSF_MAX_FRAGMENT_LENGTH (255*4)
531 /* Can be tested with colormat currently. */
532 #define VSF_MAX_FRAGMENT_TEMPS (14)
534 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
535 #define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
537 struct r300_vertex_shader_fragment
{
540 GLuint d
[VSF_MAX_FRAGMENT_LENGTH
];
541 float f
[VSF_MAX_FRAGMENT_LENGTH
];
542 GLuint i
[VSF_MAX_FRAGMENT_LENGTH
];
546 struct r300_vertex_shader_state
{
547 struct r300_vertex_shader_fragment program
;
550 extern int hw_tcl_on
;
552 #define COLOR_IS_RGBA
553 #define TAG(x) r300##x
554 #include "tnl_dd/t_dd_vertex.h"
557 //#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Current)
558 #define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->selected_vp)
560 /* Should but doesnt work */
561 //#define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->curr_vp)
563 /* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
564 * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
567 struct r300_vertex_program_key
{
569 GLuint OutputsWritten
;
573 struct r300_vertex_program
{
574 struct r300_vertex_program
*next
;
575 struct r300_vertex_program_key key
;
578 struct r300_vertex_shader_fragment program
;
581 int num_temporaries
; /* Number of temp vars used by program */
583 int inputs
[VERT_ATTRIB_MAX
];
584 int outputs
[VERT_RESULT_MAX
];
590 struct r300_vertex_program_cont
{
591 struct gl_vertex_program mesa_program
; /* Must be first */
592 struct r300_vertex_shader_fragment params
;
593 struct r300_vertex_program
*progs
;
596 #define PFS_MAX_ALU_INST 64
597 #define PFS_MAX_TEX_INST 64
598 #define PFS_MAX_TEX_INDIRECT 4
599 #define PFS_NUM_TEMP_REGS 32
600 #define PFS_NUM_CONST_REGS 16
602 struct r300_pfs_compile_state
;
606 * Stores state that influences the compilation of a fragment program.
608 struct r300_fragment_program_external_state
{
611 * If the sampler is used as a shadow sampler,
616 * depending on the depth texture mode.
618 GLuint depth_texture_mode
: 2;
621 * If the sampler is used as a shadow sampler,
622 * this field is (texture_compare_func - GL_NEVER).
623 * [e.g. if compare function is GL_LEQUAL, this field is 3]
625 * Otherwise, this field is 0.
627 GLuint texture_compare_func
: 3;
632 struct r300_fragment_program_node
{
633 int tex_offset
; /**< first tex instruction */
634 int tex_end
; /**< last tex instruction, relative to tex_offset */
635 int alu_offset
; /**< first ALU instruction */
636 int alu_end
; /**< last ALU instruction, relative to alu_offset */
641 * Stores an R300 fragment program in its compiled-to-hardware form.
643 struct r300_fragment_program_code
{
645 int length
; /**< total # of texture instructions used */
646 GLuint inst
[PFS_MAX_TEX_INST
];
650 int length
; /**< total # of ALU instructions used */
656 } inst
[PFS_MAX_ALU_INST
];
659 struct r300_fragment_program_node node
[4];
661 int first_node_has_tex
;
664 * Remember which program register a given hardware constant
667 struct prog_src_register constant
[PFS_NUM_CONST_REGS
];
674 * Store everything about a fragment program that is needed
675 * to render with that program.
677 struct r300_fragment_program
{
678 struct gl_fragment_program mesa_program
;
680 GLboolean translated
;
683 struct r300_fragment_program_external_state state
;
684 struct r300_fragment_program_code code
;
686 GLboolean WritesDepth
;
690 struct r500_pfs_compile_state
;
692 struct r500_fragment_program_external_state
{
695 * If the sampler is used as a shadow sampler,
700 * depending on the depth texture mode.
702 GLuint depth_texture_mode
: 2;
705 * If the sampler is used as a shadow sampler,
706 * this field is (texture_compare_func - GL_NEVER).
707 * [e.g. if compare function is GL_LEQUAL, this field is 3]
709 * Otherwise, this field is 0.
711 GLuint texture_compare_func
: 3;
715 struct r500_fragment_program_code
{
729 * Remember which program register a given hardware constant
732 struct prog_src_register constant
[PFS_NUM_CONST_REGS
];
738 struct r500_fragment_program
{
739 struct gl_fragment_program mesa_program
;
742 GLboolean translated
;
745 struct r500_fragment_program_external_state state
;
746 struct r500_fragment_program_code code
;
748 GLboolean writes_depth
;
753 #define R300_MAX_AOS_ARRAYS 16
760 struct radeon_bo
*bo
; /** Buffer object where vertex data is stored */
761 int offset
; /** Offset into buffer object, in bytes */
762 int components
; /** Number of components per vertex */
763 int stride
; /** Stride in dwords (may be 0 for repeating) */
764 int count
; /** Number of vertices */
768 struct r300_texture_state texture
;
769 int sw_tcl_inputs
[VERT_ATTRIB_MAX
];
770 struct r300_vertex_shader_state vertex_shader
;
771 struct r300_aos aos
[R300_MAX_AOS_ARRAYS
];
774 struct radeon_bo
*elt_dma_bo
; /** Buffer object that contains element indices */
775 int elt_dma_offset
; /** Offset into this buffer object, in bytes */
777 DECLARE_RENDERINPUTS(render_inputs_bitset
); /* actual render inputs that R300 was configured for.
778 They are the same as tnl->render_inputs for fixed pipeline */
782 #define R300_FALLBACK_NONE 0
783 #define R300_FALLBACK_TCL 1
784 #define R300_FALLBACK_RAST 2
788 struct r300_swtcl_info
{
792 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
793 * installed in the Mesa state vector.
798 * Attributes instructing the Mesa TCL pipeline where / how to put vertex
799 * data in the hardware buffer.
801 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
804 * Number of elements of \c ::vertex_attrs that are actually used.
806 GLuint vertex_attr_count
;
809 * Cached pointer to the buffer where Mesa will store vertex data.
813 /* Fallback rasterization functions
816 GLenum render_primitive
;
820 * Offset of the 4UB color data within a hardware (swtcl) vertex.
825 * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
829 struct radeon_bo
*bo
;
830 void (*flush
) (r300ContextPtr
);
835 * \brief R300 context structure.
837 struct r300_context
{
838 struct radeon_context radeon
; /* parent class, must be first */
840 struct r300_hw_state hw
;
841 struct r300_cmdbuf cmdbuf
;
842 struct r300_state state
;
843 struct gl_vertex_program
*curr_vp
;
844 struct r300_vertex_program
*selected_vp
;
851 float initialMaxAnisotropy
;
853 GLvector4f dummy_attrib
[_TNL_ATTRIB_MAX
];
854 GLvector4f
*temp_attrib
[_TNL_ATTRIB_MAX
];
856 GLboolean disable_lowimpact_fallback
;
858 DECLARE_RENDERINPUTS(tnl_index_bitset
); /* index of bits for last tnl_install_attrs */
859 struct r300_swtcl_info swtcl
;
862 struct r300_buffer_object
{
863 struct gl_buffer_object mesa_obj
;
867 #define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
869 extern void r300DestroyContext(__DRIcontextPrivate
* driContextPriv
);
870 extern GLboolean
r300CreateContext(const __GLcontextModes
* glVisual
,
871 __DRIcontextPrivate
* driContextPriv
,
872 void *sharedContextPrivate
);
874 extern void r300SelectVertexShader(r300ContextPtr r300
);
875 extern void r300InitShaderFuncs(struct dd_function_table
*functions
);
876 extern int r300VertexProgUpdateParams(GLcontext
* ctx
,
877 struct r300_vertex_program_cont
*vp
,
880 #define RADEON_D_CAPTURE 0
881 #define RADEON_D_PLAYBACK 1
882 #define RADEON_D_PLAYBACK_RAW 2
885 #endif /* __R300_CONTEXT_H__ */