r200_context.h revision 273e52f86fa41564f573c8e84d013f995e01a8f0
1/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */ 2/* 3Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. 4 5The Weather Channel (TM) funded Tungsten Graphics to develop the 6initial release of the Radeon 8500 driver under the XFree86 license. 7This notice must be preserved. 8 9Permission is hereby granted, free of charge, to any person obtaining 10a copy of this software and associated documentation files (the 11"Software"), to deal in the Software without restriction, including 12without limitation the rights to use, copy, modify, merge, publish, 13distribute, sublicense, and/or sell copies of the Software, and to 14permit persons to whom the Software is furnished to do so, subject to 15the following conditions: 16 17The above copyright notice and this permission notice (including the 18next paragraph) shall be included in all copies or substantial 19portions of the Software. 20 21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 25LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 29**************************************************************************/ 30 31/* 32 * Authors: 33 * Keith Whitwell <keith@tungstengraphics.com> 34 */ 35 36#ifndef __R200_CONTEXT_H__ 37#define __R200_CONTEXT_H__ 38 39#ifdef GLX_DIRECT_RENDERING 40 41#include <inttypes.h> 42#include "dri_util.h" 43#include "radeon_common.h" 44#include "texmem.h" 45 46#include "macros.h" 47#include "mtypes.h" 48#include "colormac.h" 49#include "r200_reg.h" 50 51#define ENABLE_HW_3D_TEXTURE 0 /* XXX this is temporary! */ 52 53struct r200_context; 54typedef struct r200_context r200ContextRec; 55typedef struct r200_context *r200ContextPtr; 56 57#include "r200_lock.h" 58#include "r200_screen.h" 59#include "mm.h" 60 61/* Flags for software fallback cases */ 62/* See correponding strings in r200_swtcl.c */ 63#define R200_FALLBACK_TEXTURE 0x1 64#define R200_FALLBACK_DRAW_BUFFER 0x2 65#define R200_FALLBACK_STENCIL 0x4 66#define R200_FALLBACK_RENDER_MODE 0x8 67#define R200_FALLBACK_BLEND_EQ 0x10 68#define R200_FALLBACK_BLEND_FUNC 0x20 69#define R200_FALLBACK_DISABLE 0x40 70#define R200_FALLBACK_BORDER_MODE 0x80 71 72/* The blit width for texture uploads 73 */ 74#define BLIT_WIDTH_BYTES 1024 75 76/* Use the templated vertex format: 77 */ 78#define COLOR_IS_RGBA 79#define TAG(x) r200##x 80#include "tnl_dd/t_dd_vertex.h" 81#undef TAG 82 83typedef void (*r200_tri_func)( r200ContextPtr, 84 r200Vertex *, 85 r200Vertex *, 86 r200Vertex * ); 87 88typedef void (*r200_line_func)( r200ContextPtr, 89 r200Vertex *, 90 r200Vertex * ); 91 92typedef void (*r200_point_func)( r200ContextPtr, 93 r200Vertex * ); 94 95 96struct r200_colorbuffer_state { 97 GLuint clear; 98 GLint drawOffset, drawPitch; 99 int roundEnable; 100}; 101 102 103struct r200_depthbuffer_state { 104 GLfloat scale; 105}; 106 107struct r200_pixel_state { 108 GLint readOffset, readPitch; 109}; 110 111struct r200_scissor_state { 112 XF86DRIClipRectRec rect; 113 GLboolean enabled; 114 115 GLuint numClipRects; /* Cliprects active */ 116 GLuint numAllocedClipRects; /* Cliprects available */ 117 XF86DRIClipRectPtr pClipRects; 118}; 119 120struct r200_stencilbuffer_state { 121 GLboolean hwBuffer; 122 GLuint clear; /* rb3d_stencilrefmask value */ 123}; 124 125struct r200_stipple_state { 126 GLuint mask[32]; 127}; 128 129 130 131#define TEX_0 0x1 132#define TEX_1 0x2 133#define TEX_ALL 0x3 134 135typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr; 136 137/* Texture object in locally shared texture space. 138 */ 139struct r200_tex_obj { 140 driTextureObject base; 141 142 GLuint bufAddr; /* Offset to start of locally 143 shared texture block */ 144 145 GLuint dirty_state; /* Flags (1 per texunit) for 146 whether or not this texobj 147 has dirty hardware state 148 (pp_*) that needs to be 149 brought into the 150 texunit. */ 151 152 drmRadeonTexImage image[6][RADEON_MAX_TEXTURE_LEVELS]; 153 /* Six, for the cube faces */ 154 155 GLuint pp_txfilter; /* hardware register values */ 156 GLuint pp_txformat; 157 GLuint pp_txformat_x; 158 GLuint pp_txoffset; /* Image location in texmem. 159 All cube faces follow. */ 160 GLuint pp_txsize; /* npot only */ 161 GLuint pp_txpitch; /* npot only */ 162 GLuint pp_border_color; 163 GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */ 164 165 GLboolean border_fallback; 166}; 167 168 169struct r200_texture_env_state { 170 r200TexObjPtr texobj; 171 GLenum format; 172 GLenum envMode; 173}; 174 175#define R200_MAX_TEXTURE_UNITS 3 176 177struct r200_texture_state { 178 struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS]; 179}; 180 181 182struct r200_state_atom { 183 struct r200_state_atom *next, *prev; 184 const char *name; /* for debug */ 185 int cmd_size; /* size in bytes */ 186 GLuint idx; 187 int *cmd; /* one or more cmd's */ 188 int *lastcmd; /* one or more cmd's */ 189 GLboolean (*check)( GLcontext *, int ); /* is this state active? */ 190}; 191 192 193 194/* Trying to keep these relatively short as the variables are becoming 195 * extravagently long. Drop the driver name prefix off the front of 196 * everything - I think we know which driver we're in by now, and keep the 197 * prefix to 3 letters unless absolutely impossible. 198 */ 199 200#define CTX_CMD_0 0 201#define CTX_PP_MISC 1 202#define CTX_PP_FOG_COLOR 2 203#define CTX_RE_SOLID_COLOR 3 204#define CTX_RB3D_BLENDCNTL 4 205#define CTX_RB3D_DEPTHOFFSET 5 206#define CTX_RB3D_DEPTHPITCH 6 207#define CTX_RB3D_ZSTENCILCNTL 7 208#define CTX_CMD_1 8 209#define CTX_PP_CNTL 9 210#define CTX_RB3D_CNTL 10 211#define CTX_RB3D_COLOROFFSET 11 212#define CTX_CMD_2 12 /* why */ 213#define CTX_RB3D_COLORPITCH 13 /* why */ 214#define CTX_STATE_SIZE 14 215 216#define SET_CMD_0 0 217#define SET_SE_CNTL 1 218#define SET_RE_CNTL 2 /* replace se_coord_fmt */ 219#define SET_STATE_SIZE 3 220 221#define VTE_CMD_0 0 222#define VTE_SE_VTE_CNTL 1 223#define VTE_STATE_SIZE 2 224 225#define LIN_CMD_0 0 226#define LIN_RE_LINE_PATTERN 1 227#define LIN_RE_LINE_STATE 2 228#define LIN_CMD_1 3 229#define LIN_SE_LINE_WIDTH 4 230#define LIN_STATE_SIZE 5 231 232#define MSK_CMD_0 0 233#define MSK_RB3D_STENCILREFMASK 1 234#define MSK_RB3D_ROPCNTL 2 235#define MSK_RB3D_PLANEMASK 3 236#define MSK_STATE_SIZE 4 237 238#define VPT_CMD_0 0 239#define VPT_SE_VPORT_XSCALE 1 240#define VPT_SE_VPORT_XOFFSET 2 241#define VPT_SE_VPORT_YSCALE 3 242#define VPT_SE_VPORT_YOFFSET 4 243#define VPT_SE_VPORT_ZSCALE 5 244#define VPT_SE_VPORT_ZOFFSET 6 245#define VPT_STATE_SIZE 7 246 247#define ZBS_CMD_0 0 248#define ZBS_SE_ZBIAS_FACTOR 1 249#define ZBS_SE_ZBIAS_CONSTANT 2 250#define ZBS_STATE_SIZE 3 251 252#define MSC_CMD_0 0 253#define MSC_RE_MISC 1 254#define MSC_STATE_SIZE 2 255 256#define TAM_CMD_0 0 257#define TAM_DEBUG3 1 258#define TAM_STATE_SIZE 2 259 260#define TEX_CMD_0 0 261#define TEX_PP_TXFILTER 1 /*2c00*/ 262#define TEX_PP_TXFORMAT 2 /*2c04*/ 263#define TEX_PP_TXFORMAT_X 3 /*2c08*/ 264#define TEX_PP_TXSIZE 4 /*2c0c*/ 265#define TEX_PP_TXPITCH 5 /*2c10*/ 266#define TEX_PP_BORDER_COLOR 6 /*2c14*/ 267#define TEX_CMD_1 7 268#define TEX_PP_TXOFFSET 8 /*2d00 */ 269#define TEX_STATE_SIZE 9 270 271#define CUBE_CMD_0 0 /* 1 register follows */ 272#define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */ 273#define CUBE_CMD_1 2 /* 5 registers follow */ 274#define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */ 275#define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */ 276#define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */ 277#define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */ 278#define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */ 279#define CUBE_STATE_SIZE 8 280 281#define PIX_CMD_0 0 282#define PIX_PP_TXCBLEND 1 283#define PIX_PP_TXCBLEND2 2 284#define PIX_PP_TXABLEND 3 285#define PIX_PP_TXABLEND2 4 286#define PIX_STATE_SIZE 5 287 288#define TF_CMD_0 0 289#define TF_TFACTOR_0 1 290#define TF_TFACTOR_1 2 291#define TF_TFACTOR_2 3 292#define TF_TFACTOR_3 4 293#define TF_TFACTOR_4 5 294#define TF_TFACTOR_5 6 295#define TF_STATE_SIZE 7 296 297#define TCL_CMD_0 0 298#define TCL_LIGHT_MODEL_CTL_0 1 299#define TCL_LIGHT_MODEL_CTL_1 2 300#define TCL_PER_LIGHT_CTL_0 3 301#define TCL_PER_LIGHT_CTL_1 4 302#define TCL_PER_LIGHT_CTL_2 5 303#define TCL_PER_LIGHT_CTL_3 6 304#define TCL_CMD_1 7 305#define TCL_UCP_VERT_BLEND_CTL 8 306#define TCL_STATE_SIZE 9 307 308#define MSL_CMD_0 0 309#define MSL_MATRIX_SELECT_0 1 310#define MSL_MATRIX_SELECT_1 2 311#define MSL_MATRIX_SELECT_2 3 312#define MSL_MATRIX_SELECT_3 4 313#define MSL_MATRIX_SELECT_4 5 314#define MSL_STATE_SIZE 6 315 316#define TCG_CMD_0 0 317#define TCG_TEX_PROC_CTL_2 1 318#define TCG_TEX_PROC_CTL_3 2 319#define TCG_TEX_PROC_CTL_0 3 320#define TCG_TEX_PROC_CTL_1 4 321#define TCG_TEX_CYL_WRAP_CTL 5 322#define TCG_STATE_SIZE 6 323 324#define MTL_CMD_0 0 325#define MTL_EMMISSIVE_RED 1 326#define MTL_EMMISSIVE_GREEN 2 327#define MTL_EMMISSIVE_BLUE 3 328#define MTL_EMMISSIVE_ALPHA 4 329#define MTL_AMBIENT_RED 5 330#define MTL_AMBIENT_GREEN 6 331#define MTL_AMBIENT_BLUE 7 332#define MTL_AMBIENT_ALPHA 8 333#define MTL_DIFFUSE_RED 9 334#define MTL_DIFFUSE_GREEN 10 335#define MTL_DIFFUSE_BLUE 11 336#define MTL_DIFFUSE_ALPHA 12 337#define MTL_SPECULAR_RED 13 338#define MTL_SPECULAR_GREEN 14 339#define MTL_SPECULAR_BLUE 15 340#define MTL_SPECULAR_ALPHA 16 341#define MTL_CMD_1 17 342#define MTL_SHININESS 18 343#define MTL_STATE_SIZE 19 344 345#define VAP_CMD_0 0 346#define VAP_SE_VAP_CNTL 1 347#define VAP_STATE_SIZE 2 348 349/* Replaces a lot of packet info from radeon 350 */ 351#define VTX_CMD_0 0 352#define VTX_VTXFMT_0 1 353#define VTX_VTXFMT_1 2 354#define VTX_TCL_OUTPUT_VTXFMT_0 3 355#define VTX_TCL_OUTPUT_VTXFMT_1 4 356#define VTX_CMD_1 5 357#define VTX_TCL_OUTPUT_COMPSEL 6 358#define VTX_CMD_2 7 359#define VTX_STATE_CNTL 8 360#define VTX_STATE_SIZE 9 361 362 363#define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\ 364 R200_VTX_COLOR_MASK) 365 366#define MAT_CMD_0 0 367#define MAT_ELT_0 1 368#define MAT_STATE_SIZE 17 369 370#define GRD_CMD_0 0 371#define GRD_VERT_GUARD_CLIP_ADJ 1 372#define GRD_VERT_GUARD_DISCARD_ADJ 2 373#define GRD_HORZ_GUARD_CLIP_ADJ 3 374#define GRD_HORZ_GUARD_DISCARD_ADJ 4 375#define GRD_STATE_SIZE 5 376 377/* position changes frequently when lighting in modelpos - separate 378 * out to new state item? 379 */ 380#define LIT_CMD_0 0 381#define LIT_AMBIENT_RED 1 382#define LIT_AMBIENT_GREEN 2 383#define LIT_AMBIENT_BLUE 3 384#define LIT_AMBIENT_ALPHA 4 385#define LIT_DIFFUSE_RED 5 386#define LIT_DIFFUSE_GREEN 6 387#define LIT_DIFFUSE_BLUE 7 388#define LIT_DIFFUSE_ALPHA 8 389#define LIT_SPECULAR_RED 9 390#define LIT_SPECULAR_GREEN 10 391#define LIT_SPECULAR_BLUE 11 392#define LIT_SPECULAR_ALPHA 12 393#define LIT_POSITION_X 13 394#define LIT_POSITION_Y 14 395#define LIT_POSITION_Z 15 396#define LIT_POSITION_W 16 397#define LIT_DIRECTION_X 17 398#define LIT_DIRECTION_Y 18 399#define LIT_DIRECTION_Z 19 400#define LIT_DIRECTION_W 20 401#define LIT_ATTEN_CONST 21 402#define LIT_ATTEN_LINEAR 22 403#define LIT_ATTEN_QUADRATIC 23 404#define LIT_ATTEN_XXX 24 405#define LIT_CMD_1 25 406#define LIT_SPOT_DCD 26 407#define LIT_SPOT_DCM 27 408#define LIT_SPOT_EXPONENT 28 409#define LIT_SPOT_CUTOFF 29 410#define LIT_SPECULAR_THRESH 30 411#define LIT_RANGE_CUTOFF 31 /* ? */ 412#define LIT_RANGE_ATTEN 32 /* ? */ 413#define LIT_STATE_SIZE 33 414 415/* Fog 416 */ 417#define FOG_CMD_0 0 418#define FOG_R 1 419#define FOG_C 2 420#define FOG_D 3 421#define FOG_PAD 4 422#define FOG_STATE_SIZE 5 423 424/* UCP 425 */ 426#define UCP_CMD_0 0 427#define UCP_X 1 428#define UCP_Y 2 429#define UCP_Z 3 430#define UCP_W 4 431#define UCP_STATE_SIZE 5 432 433/* GLT - Global ambient 434 */ 435#define GLT_CMD_0 0 436#define GLT_RED 1 437#define GLT_GREEN 2 438#define GLT_BLUE 3 439#define GLT_ALPHA 4 440#define GLT_STATE_SIZE 5 441 442/* EYE 443 */ 444#define EYE_CMD_0 0 445#define EYE_X 1 446#define EYE_Y 2 447#define EYE_Z 3 448#define EYE_RESCALE_FACTOR 4 449#define EYE_STATE_SIZE 5 450 451/* CST - constant state 452 */ 453#define CST_CMD_0 0 454#define CST_PP_CNTL_X 1 455#define CST_CMD_1 2 456#define CST_RB3D_DEPTHXY_OFFSET 3 457#define CST_CMD_2 4 458#define CST_RE_AUX_SCISSOR_CNTL 5 459#define CST_CMD_3 6 460#define CST_RE_SCISSOR_TL_0 7 461#define CST_RE_SCISSOR_BR_0 8 462#define CST_CMD_4 9 463#define CST_SE_VAP_CNTL_STATUS 10 464#define CST_CMD_5 11 465#define CST_RE_POINTSIZE 12 466#define CST_CMD_6 13 467#define CST_SE_TCL_INPUT_VTX_0 14 468#define CST_SE_TCL_INPUT_VTX_1 15 469#define CST_SE_TCL_INPUT_VTX_2 16 470#define CST_SE_TCL_INPUT_VTX_3 17 471#define CST_STATE_SIZE 18 472 473 474 475 476struct r200_hw_state { 477 /* All state should be on one of these lists: 478 */ 479 struct r200_state_atom dirty; /* dirty list head placeholder */ 480 struct r200_state_atom clean; /* clean list head placeholder */ 481 482 /* Hardware state, stored as cmdbuf commands: 483 * -- Need to doublebuffer for 484 * - reviving state after loss of context 485 * - eliding noop statechange loops? (except line stipple count) 486 */ 487 struct r200_state_atom ctx; 488 struct r200_state_atom set; 489 struct r200_state_atom vte; 490 struct r200_state_atom lin; 491 struct r200_state_atom msk; 492 struct r200_state_atom vpt; 493 struct r200_state_atom vap; 494 struct r200_state_atom vtx; 495 struct r200_state_atom tcl; 496 struct r200_state_atom msl; 497 struct r200_state_atom tcg; 498 struct r200_state_atom msc; 499 struct r200_state_atom cst; 500 struct r200_state_atom tam; 501 struct r200_state_atom tf; 502 struct r200_state_atom tex[2]; 503 struct r200_state_atom cube[2]; 504 struct r200_state_atom zbs; 505 struct r200_state_atom mtl[2]; 506 struct r200_state_atom mat[5]; 507 struct r200_state_atom lit[8]; /* includes vec, scl commands */ 508 struct r200_state_atom ucp[6]; 509 struct r200_state_atom pix[6]; /* pixshader stages */ 510 struct r200_state_atom eye; /* eye pos */ 511 struct r200_state_atom grd; /* guard band clipping */ 512 struct r200_state_atom fog; 513 struct r200_state_atom glt; 514}; 515 516struct r200_state { 517 /* Derived state for internal purposes: 518 */ 519 struct r200_colorbuffer_state color; 520 struct r200_depthbuffer_state depth; 521 struct r200_pixel_state pixel; 522 struct r200_scissor_state scissor; 523 struct r200_stencilbuffer_state stencil; 524 struct r200_stipple_state stipple; 525 struct r200_texture_state texture; 526}; 527 528/* Need refcounting on dma buffers: 529 */ 530struct r200_dma_buffer { 531 int refcount; /* the number of retained regions in buf */ 532 drmBufPtr buf; 533}; 534 535#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \ 536 (rvb)->address - rmesa->dma.buf0_address + \ 537 (rvb)->start) 538 539/* A retained region, eg vertices for indexed vertices. 540 */ 541struct r200_dma_region { 542 struct r200_dma_buffer *buf; 543 char *address; /* == buf->address */ 544 int start, end, ptr; /* offsets from start of buf */ 545 int aos_start; 546 int aos_stride; 547 int aos_size; 548}; 549 550 551struct r200_dma { 552 /* Active dma region. Allocations for vertices and retained 553 * regions come from here. Also used for emitting random vertices, 554 * these may be flushed by calling flush_current(); 555 */ 556 struct r200_dma_region current; 557 558 void (*flush)( r200ContextPtr ); 559 560 char *buf0_address; /* start of buf[0], for index calcs */ 561 GLuint nr_released_bufs; /* flush after so many buffers released */ 562}; 563 564struct r200_dri_mirror { 565 __DRIcontextPrivate *context; /* DRI context */ 566 __DRIscreenPrivate *screen; /* DRI screen */ 567 __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */ 568 569 drmContext hwContext; 570 drmLock *hwLock; 571 int fd; 572 int drmMinor; 573}; 574 575 576#define R200_CMD_BUF_SZ (8*1024) 577 578struct r200_store { 579 GLuint statenr; 580 GLuint primnr; 581 char cmd_buf[R200_CMD_BUF_SZ]; 582 int cmd_used; 583 int elts_start; 584}; 585 586 587/* r200_tcl.c 588 */ 589struct r200_tcl_info { 590 GLuint vertex_format; 591 GLint last_offset; 592 GLuint hw_primitive; 593 594 struct r200_dma_region *aos_components[8]; 595 GLuint nr_aos_components; 596 597 GLuint *Elts; 598 599 struct r200_dma_region indexed_verts; 600 struct r200_dma_region obj; 601 struct r200_dma_region rgba; 602 struct r200_dma_region spec; 603 struct r200_dma_region fog; 604 struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS]; 605 struct r200_dma_region norm; 606}; 607 608 609/* r200_swtcl.c 610 */ 611struct r200_swtcl_info { 612 GLuint SetupIndex; 613 GLuint SetupNewInputs; 614 GLuint RenderIndex; 615 GLuint vertex_size; 616 GLuint vertex_stride_shift; 617 GLuint vertex_format; 618 GLubyte *verts; 619 620 /* Fallback rasterization functions 621 */ 622 r200_point_func draw_point; 623 r200_line_func draw_line; 624 r200_tri_func draw_tri; 625 626 GLuint hw_primitive; 627 GLenum render_primitive; 628 GLuint numverts; 629 630 struct r200_dma_region indexed_verts; 631}; 632 633 634struct r200_ioctl { 635 GLuint vertex_offset; 636 GLuint vertex_size; 637}; 638 639 640 641#define R200_MAX_PRIMS 64 642 643 644/* Want to keep a cache of these around. Each is parameterized by 645 * only a single value which has only a small range. Only expect a 646 * few, so just rescan the list each time? 647 */ 648struct dynfn { 649 struct dynfn *next, *prev; 650 int key[2]; 651 char *code; 652}; 653 654struct dfn_lists { 655 struct dynfn Vertex2f; 656 struct dynfn Vertex2fv; 657 struct dynfn Vertex3f; 658 struct dynfn Vertex3fv; 659 struct dynfn Color4ub; 660 struct dynfn Color4ubv; 661 struct dynfn Color3ub; 662 struct dynfn Color3ubv; 663 struct dynfn Color4f; 664 struct dynfn Color4fv; 665 struct dynfn Color3f; 666 struct dynfn Color3fv; 667 struct dynfn SecondaryColor3ubEXT; 668 struct dynfn SecondaryColor3ubvEXT; 669 struct dynfn SecondaryColor3fEXT; 670 struct dynfn SecondaryColor3fvEXT; 671 struct dynfn Normal3f; 672 struct dynfn Normal3fv; 673 struct dynfn TexCoord2f; 674 struct dynfn TexCoord2fv; 675 struct dynfn TexCoord1f; 676 struct dynfn TexCoord1fv; 677 struct dynfn MultiTexCoord2fARB; 678 struct dynfn MultiTexCoord2fvARB; 679 struct dynfn MultiTexCoord1fARB; 680 struct dynfn MultiTexCoord1fvARB; 681}; 682 683struct dfn_generators { 684 struct dynfn *(*Vertex2f)( GLcontext *, const int * ); 685 struct dynfn *(*Vertex2fv)( GLcontext *, const int * ); 686 struct dynfn *(*Vertex3f)( GLcontext *, const int * ); 687 struct dynfn *(*Vertex3fv)( GLcontext *, const int * ); 688 struct dynfn *(*Color4ub)( GLcontext *, const int * ); 689 struct dynfn *(*Color4ubv)( GLcontext *, const int * ); 690 struct dynfn *(*Color3ub)( GLcontext *, const int * ); 691 struct dynfn *(*Color3ubv)( GLcontext *, const int * ); 692 struct dynfn *(*Color4f)( GLcontext *, const int * ); 693 struct dynfn *(*Color4fv)( GLcontext *, const int * ); 694 struct dynfn *(*Color3f)( GLcontext *, const int * ); 695 struct dynfn *(*Color3fv)( GLcontext *, const int * ); 696 struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, const int * ); 697 struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, const int * ); 698 struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, const int * ); 699 struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * ); 700 struct dynfn *(*Normal3f)( GLcontext *, const int * ); 701 struct dynfn *(*Normal3fv)( GLcontext *, const int * ); 702 struct dynfn *(*TexCoord2f)( GLcontext *, const int * ); 703 struct dynfn *(*TexCoord2fv)( GLcontext *, const int * ); 704 struct dynfn *(*TexCoord1f)( GLcontext *, const int * ); 705 struct dynfn *(*TexCoord1fv)( GLcontext *, const int * ); 706 struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * ); 707 struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * ); 708 struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * ); 709 struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, const int * ); 710}; 711 712 713 714struct r200_prim { 715 GLuint start; 716 GLuint end; 717 GLuint prim; 718}; 719 720struct r200_vbinfo { 721 GLint counter, initial_counter; 722 GLint *dmaptr; 723 void (*notify)( void ); 724 GLint vertex_size; 725 726 /* A maximum total of 15 elements per vertex: 3 floats for position, 3 727 * floats for normal, 4 floats for color, 4 bytes for secondary color, 728 * 2 floats for each texture unit (4 floats total). 729 * 730 * As soon as the 3rd TMU is supported or cube maps (or 3D textures) are 731 * supported, this value will grow. 732 * 733 * The position data is never actually stored here, so 3 elements could be 734 * trimmed out of the buffer. 735 */ 736 union { float f; int i; r200_color_t color; } vertex[15]; 737 738 GLfloat *normalptr; 739 GLfloat *floatcolorptr; 740 r200_color_t *colorptr; 741 GLfloat *floatspecptr; 742 r200_color_t *specptr; 743 GLfloat *texcoordptr[2]; 744 745 746 GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */ 747 GLuint primflags; 748 GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */ 749 GLboolean installed; 750 GLboolean fell_back; 751 GLboolean recheck; 752 GLint nrverts; 753 GLuint vtxfmt_0, vtxfmt_1; 754 755 GLuint installed_vertex_format; 756 GLuint installed_color_3f_sz; 757 758 struct r200_prim primlist[R200_MAX_PRIMS]; 759 int nrprims; 760 761 struct dfn_lists dfn_cache; 762 struct dfn_generators codegen; 763 GLvertexformat vtxfmt; 764}; 765 766 767 768 769struct r200_context { 770 GLcontext *glCtx; /* Mesa context */ 771 772 /* Driver and hardware state management 773 */ 774 struct r200_hw_state hw; 775 struct r200_state state; 776 777 /* Texture object bookkeeping 778 */ 779 unsigned nr_heaps; 780 driTexHeap * texture_heaps[ R200_NR_TEX_HEAPS ]; 781 driTextureObject swapped; 782 int texture_depth; 783 784 785 /* Rasterization and vertex state: 786 */ 787 GLuint TclFallback; 788 GLuint Fallback; 789 GLuint NewGLState; 790 791 792 /* Temporaries for translating away float colors: 793 */ 794 struct gl_client_array UbyteColor; 795 struct gl_client_array UbyteSecondaryColor; 796 797 /* Vertex buffers 798 */ 799 struct r200_ioctl ioctl; 800 struct r200_dma dma; 801 struct r200_store store; 802 803 /* Page flipping 804 */ 805 GLuint doPageFlip; 806 807 /* Busy waiting 808 */ 809 GLuint do_usleeps; 810 GLuint do_irqs; 811 GLuint irqsEmitted; 812 drmRadeonIrqWait iw; 813 814 /* Clientdata textures; 815 */ 816 GLuint prefer_gart_client_texturing; 817 818 /* Drawable, cliprect and scissor information 819 */ 820 GLuint numClipRects; /* Cliprects for the draw buffer */ 821 XF86DRIClipRectPtr pClipRects; 822 unsigned int lastStamp; 823 GLboolean lost_context; 824 r200ScreenPtr r200Screen; /* Screen private DRI data */ 825 RADEONSAREAPrivPtr sarea; /* Private SAREA data */ 826 827 /* TCL stuff 828 */ 829 GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS]; 830 GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS]; 831 GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS]; 832 GLuint TexMatEnabled; 833 GLuint TexMatCompSel; 834 GLuint TexGenEnabled; 835 GLuint TexGenInputs; 836 GLuint TexGenCompSel; 837 GLmatrix tmpmat; 838 839 /* VBI / buffer swap 840 */ 841 GLuint vbl_seq; 842 GLuint vblank_flags; 843 844 uint64_t swap_ust; 845 uint64_t swap_missed_ust; 846 847 GLuint swap_count; 848 GLuint swap_missed_count; 849 850 PFNGLXGETUSTPROC get_ust; 851 852 /* r200_tcl.c 853 */ 854 struct r200_tcl_info tcl; 855 856 /* r200_swtcl.c 857 */ 858 struct r200_swtcl_info swtcl; 859 860 /* r200_vtxfmt.c 861 */ 862 struct r200_vbinfo vb; 863 864 /* Mirrors of some DRI state 865 */ 866 struct r200_dri_mirror dri; 867 868 /* Configuration cache 869 */ 870 driOptionCache optionCache; 871}; 872 873#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx)) 874 875 876static __inline GLuint r200PackColor( GLuint cpp, 877 GLubyte r, GLubyte g, 878 GLubyte b, GLubyte a ) 879{ 880 switch ( cpp ) { 881 case 2: 882 return PACK_COLOR_565( r, g, b ); 883 case 4: 884 return PACK_COLOR_8888( a, r, g, b ); 885 default: 886 return 0; 887 } 888} 889 890#define R200_OLD_PACKETS 0 891 892 893extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv ); 894extern GLboolean r200CreateContext( const __GLcontextModes *glVisual, 895 __DRIcontextPrivate *driContextPriv, 896 void *sharedContextPrivate); 897extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv ); 898extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv, 899 __DRIdrawablePrivate *driDrawPriv, 900 __DRIdrawablePrivate *driReadPriv ); 901extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv ); 902 903/* ================================================================ 904 * Debugging: 905 */ 906#define DO_DEBUG 1 907 908#if DO_DEBUG 909extern int R200_DEBUG; 910#else 911#define R200_DEBUG 0 912#endif 913 914#define DEBUG_TEXTURE 0x001 915#define DEBUG_STATE 0x002 916#define DEBUG_IOCTL 0x004 917#define DEBUG_PRIMS 0x008 918#define DEBUG_VERTS 0x010 919#define DEBUG_FALLBACKS 0x020 920#define DEBUG_VFMT 0x040 921#define DEBUG_CODEGEN 0x080 922#define DEBUG_VERBOSE 0x100 923#define DEBUG_DRI 0x200 924#define DEBUG_DMA 0x400 925#define DEBUG_SANITY 0x800 926#define DEBUG_SYNC 0x1000 927#define DEBUG_PIXEL 0x2000 928#define DEBUG_MEMORY 0x4000 929 930#endif 931#endif /* __R200_CONTEXT_H__ */ 932