📄 r300_context.h
字号:
/*Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.The Weather Channel (TM) funded Tungsten Graphics to develop theinitial release of the Radeon 8500 driver under the XFree86 license.This notice must be preserved.Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice (including thenext paragraph) shall be included in all copies or substantialportions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//** * \file * * \author Keith Whitwell <keith@tungstengraphics.com> * \author Nicolai Haehnle <prefect_@gmx.net> */#ifndef __R300_CONTEXT_H__#define __R300_CONTEXT_H__#include "tnl/t_vertex.h"#include "drm.h"#include "radeon_drm.h"#include "dri_util.h"#include "texmem.h"#include "macros.h"#include "mtypes.h"#include "colormac.h"#define USER_BUFFERSstruct r300_context;typedef struct r300_context r300ContextRec;typedef struct r300_context *r300ContextPtr;#include "radeon_lock.h"#include "mm.h"/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html . I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble with other compilers ... GLUE!*/#define WARN_ONCE(a, ...) { \ static int warn##__LINE__=1; \ if(warn##__LINE__){ \ fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \ fprintf(stderr, "File %s function %s line %d\n", \ __FILE__, __FUNCTION__, __LINE__); \ fprintf(stderr, a, ## __VA_ARGS__);\ fprintf(stderr, "***************************************************************************\n"); \ warn##__LINE__=0;\ } \ }#include "r300_vertprog.h"#include "r500_fragprog.h"/** * This function takes a float and packs it into a uint32_t */static INLINE uint32_t r300PackFloat32(float fl){ union { float fl; uint32_t u; } u; u.fl = fl; return u.u;}/* This is probably wrong for some values, I need to test this * some more. Range checking would be a good idea also.. * * But it works for most things. I'll fix it later if someone * else with a better clue doesn't */static INLINE uint32_t r300PackFloat24(float f){ float mantissa; int exponent; uint32_t float24 = 0; if (f == 0.0) return 0; mantissa = frexpf(f, &exponent); /* Handle -ve */ if (mantissa < 0) { float24 |= (1 << 23); mantissa = mantissa * -1.0; } /* Handle exponent, bias of 63 */ exponent += 62; float24 |= (exponent << 16); /* Kill 7 LSB of mantissa */ float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7; return float24;}/************ DMA BUFFERS **************//* Need refcounting on dma buffers: */struct r300_dma_buffer { int refcount; /**< the number of retained regions in buf */ drmBufPtr buf; int id;};#undef GET_START#ifdef USER_BUFFERS#define GET_START(rvb) (r300GartOffsetFromVirtual(rmesa, (rvb)->address+(rvb)->start))#else#define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset + \ (rvb)->address - rmesa->dma.buf0_address + \ (rvb)->start)#endif/* A retained region, eg vertices for indexed vertices. */struct r300_dma_region { struct r300_dma_buffer *buf; char *address; /* == buf->address */ int start, end, ptr; /* offsets from start of buf */ int aos_offset; /* address in GART memory */ int aos_stride; /* distance between elements, in dwords */ int aos_size; /* number of components (1-4) */};struct r300_dma { /* Active dma region. Allocations for vertices and retained * regions come from here. Also used for emitting random vertices, * these may be flushed by calling flush_current(); */ struct r300_dma_region current; void (*flush) (r300ContextPtr); char *buf0_address; /* start of buf[0], for index calcs */ /* Number of "in-flight" DMA buffers, i.e. the number of buffers * for which a DISCARD command is currently queued in the command buffer. */ GLuint nr_released_bufs;}; /* Texture related */typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;/* Texture object in locally shared texture space. */struct r300_tex_obj { driTextureObject base; GLuint bufAddr; /* Offset to start of locally shared texture block */ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS]; /* Six, for the cube faces */ GLboolean image_override; /* Image overridden by GLX_EXT_tfp */ GLuint pitch; /* this isn't sent to hardware just used in calculations */ /* hardware register values */ /* Note that R200 has 8 registers per texture and R300 only 7 */ GLuint filter; GLuint filter_1; GLuint pitch_reg; GLuint size; /* npot only */ GLuint format; GLuint offset; /* Image location in the card's address space. All cube faces follow. */ GLuint unknown4; GLuint unknown5; /* end hardware registers */ /* registers computed by r200 code - keep them here to compare against what is actually written. to be removed later.. */ GLuint pp_border_color; GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */ GLuint format_x; GLboolean border_fallback; GLuint tile_bits; /* hw texture tile bits used on this texture */};struct r300_texture_env_state { r300TexObjPtr texobj; GLenum format; GLenum envMode;};/* The blit width for texture uploads */#define R300_BLIT_WIDTH_BYTES 1024#define R300_MAX_TEXTURE_UNITS 8struct r300_texture_state { struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS]; int tc_count; /* number of incoming texture coordinates from VAP */};/** * A block of hardware state. * * When check returns non-zero, the returned number of dwords must be * copied verbatim into the command buffer in order to update a state atom * when it is dirty. */struct r300_state_atom { struct r300_state_atom *next, *prev; const char *name; /* for debug */ int cmd_size; /* maximum size in dwords */ GLuint idx; /* index in an array (e.g. textures) */ uint32_t *cmd; GLboolean dirty; int (*check) (r300ContextPtr, struct r300_state_atom * atom);};#define R300_VPT_CMD_0 0#define R300_VPT_XSCALE 1#define R300_VPT_XOFFSET 2#define R300_VPT_YSCALE 3#define R300_VPT_YOFFSET 4#define R300_VPT_ZSCALE 5#define R300_VPT_ZOFFSET 6#define R300_VPT_CMDSIZE 7#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */#define R300_VIR_CNTL_0 1#define R300_VIR_CNTL_1 2#define R300_VIR_CNTL_2 3#define R300_VIR_CNTL_3 4#define R300_VIR_CNTL_4 5#define R300_VIR_CNTL_5 6#define R300_VIR_CNTL_6 7#define R300_VIR_CNTL_7 8#define R300_VIR_CMDSIZE 9#define R300_VIC_CMD_0 0#define R300_VIC_CNTL_0 1#define R300_VIC_CNTL_1 2#define R300_VIC_CMDSIZE 3#define R300_VOF_CMD_0 0#define R300_VOF_CNTL_0 1#define R300_VOF_CNTL_1 2#define R300_VOF_CMDSIZE 3#define R300_PVS_CMD_0 0#define R300_PVS_CNTL_1 1#define R300_PVS_CNTL_2 2#define R300_PVS_CNTL_3 3#define R300_PVS_CMDSIZE 4#define R300_GB_MISC_CMD_0 0#define R300_GB_MISC_MSPOS_0 1#define R300_GB_MISC_MSPOS_1 2#define R300_GB_MISC_TILE_CONFIG 3#define R300_GB_MISC_SELECT 4#define R300_GB_MISC_AA_CONFIG 5#define R300_GB_MISC_CMDSIZE 6#define R300_TXE_CMD_0 0#define R300_TXE_ENABLE 1#define R300_TXE_CMDSIZE 2#define R300_PS_CMD_0 0#define R300_PS_POINTSIZE 1#define R300_PS_CMDSIZE 2#define R300_ZBS_CMD_0 0#define R300_ZBS_T_FACTOR 1#define R300_ZBS_T_CONSTANT 2#define R300_ZBS_W_FACTOR 3#define R300_ZBS_W_CONSTANT 4#define R300_ZBS_CMDSIZE 5#define R300_CUL_CMD_0 0#define R300_CUL_CULL 1#define R300_CUL_CMDSIZE 2#define R300_RC_CMD_0 0#define R300_RC_CNTL_0 1#define R300_RC_CNTL_1 2#define R300_RC_CMDSIZE 3#define R300_RI_CMD_0 0#define R300_RI_INTERP_0 1#define R300_RI_INTERP_1 2#define R300_RI_INTERP_2 3#define R300_RI_INTERP_3 4#define R300_RI_INTERP_4 5#define R300_RI_INTERP_5 6#define R300_RI_INTERP_6 7#define R300_RI_INTERP_7 8#define R300_RI_CMDSIZE 9#define R500_RI_CMDSIZE 17#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */#define R300_RR_INST_0 1#define R300_RR_INST_1 2#define R300_RR_INST_2 3#define R300_RR_INST_3 4#define R300_RR_INST_4 5#define R300_RR_INST_5 6#define R300_RR_INST_6 7#define R300_RR_INST_7 8#define R300_RR_CMDSIZE 9#define R300_FP_CMD_0 0#define R300_FP_CNTL0 1#define R300_FP_CNTL1 2#define R300_FP_CNTL2 3#define R300_FP_CMD_1 4#define R300_FP_NODE0 5#define R300_FP_NODE1 6#define R300_FP_NODE2 7#define R300_FP_NODE3 8#define R300_FP_CMDSIZE 9#define R500_FP_CMD_0 0#define R500_FP_CNTL 1#define R500_FP_PIXSIZE 2#define R500_FP_CMD_1 3#define R500_FP_CODE_ADDR 4#define R500_FP_CODE_RANGE 5#define R500_FP_CODE_OFFSET 6#define R500_FP_CMD_2 7#define R500_FP_FC_CNTL 8#define R500_FP_CMDSIZE 9#define R300_FPT_CMD_0 0#define R300_FPT_INSTR_0 1#define R300_FPT_CMDSIZE 65#define R300_FPI_CMD_0 0#define R300_FPI_INSTR_0 1#define R300_FPI_CMDSIZE 65/* R500 has space for 512 instructions - 6 dwords per instruction */#define R500_FPI_CMDSIZE (512*6+1)#define R300_FPP_CMD_0 0#define R300_FPP_PARAM_0 1#define R300_FPP_CMDSIZE (32*4+1)/* R500 has spcae for 256 constants - 4 dwords per constant */#define R500_FPP_CMDSIZE (256*4+1)#define R300_FOGS_CMD_0 0#define R300_FOGS_STATE 1#define R300_FOGS_CMDSIZE 2#define R300_FOGC_CMD_0 0#define R300_FOGC_R 1#define R300_FOGC_G 2#define R300_FOGC_B 3#define R300_FOGC_CMDSIZE 4#define R300_FOGP_CMD_0 0#define R300_FOGP_SCALE 1#define R300_FOGP_START 2#define R300_FOGP_CMDSIZE 3#define R300_AT_CMD_0 0#define R300_AT_ALPHA_TEST 1#define R300_AT_UNKNOWN 2#define R300_AT_CMDSIZE 3#define R300_BLD_CMD_0 0#define R300_BLD_CBLEND 1#define R300_BLD_ABLEND 2#define R300_BLD_CMDSIZE 3#define R300_CMK_CMD_0 0#define R300_CMK_COLORMASK 1#define R300_CMK_CMDSIZE 2#define R300_CB_CMD_0 0#define R300_CB_OFFSET 1#define R300_CB_CMD_1 2#define R300_CB_PITCH 3#define R300_CB_CMDSIZE 4#define R300_ZS_CMD_0 0#define R300_ZS_CNTL_0 1#define R300_ZS_CNTL_1 2#define R300_ZS_CNTL_2 3#define R300_ZS_CMDSIZE 4#define R300_ZB_CMD_0 0#define R300_ZB_OFFSET 1#define R300_ZB_PITCH 2#define R300_ZB_CMDSIZE 3#define R300_VAP_CNTL_FLUSH 0#define R300_VAP_CNTL_FLUSH_1 1#define R300_VAP_CNTL_CMD 2#define R300_VAP_CNTL_INSTR 3#define R300_VAP_CNTL_SIZE 4#define R300_VPI_CMD_0 0#define R300_VPI_INSTR_0 1#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */#define R300_VPP_CMD_0 0#define R300_VPP_PARAM_0 1#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */#define R300_VPUCP_CMD_0 0#define R300_VPUCP_X 1#define R300_VPUCP_Y 2#define R300_VPUCP_Z 3#define R300_VPUCP_W 4#define R300_VPUCP_CMDSIZE 5 /* 256 4-component parameters */#define R300_VPS_CMD_0 0#define R300_VPS_ZERO_0 1#define R300_VPS_ZERO_1 2#define R300_VPS_POINTSIZE 3#define R300_VPS_ZERO_3 4#define R300_VPS_CMDSIZE 5 /* the layout is common for all fields inside tex */#define R300_TEX_CMD_0 0#define R300_TEX_VALUE_0 1/* We don't really use this, instead specify mtu+1 dynamically#define R300_TEX_CMDSIZE (MAX_TEXTURE_UNITS+1)*//** * Cache for hardware register state. */struct r300_hw_state { struct r300_state_atom atomlist; GLboolean is_dirty; GLboolean all_dirty; int max_state_size; /* in dwords */ struct r300_state_atom vpt; /* viewport (1D98) */ struct r300_state_atom vap_cntl; struct r300_state_atom vap_index_offset; /* 0x208c r5xx only */ struct r300_state_atom vof; /* VAP output format register 0x2090 */ struct r300_state_atom vte; /* (20B0) */ struct r300_state_atom vap_vf_max_vtx_indx; /* Maximum Vertex Indx Clamp (2134) */ struct r300_state_atom vap_cntl_status; struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */ struct r300_state_atom vic; /* vap input control (2180) */ struct r300_state_atom vap_psc_sgn_norm_cntl; /* Programmable Stream Control Signed Normalize Control (21DC) */ struct r300_state_atom vap_clip_cntl; struct r300_state_atom vap_clip; struct r300_state_atom vap_pvs_vtx_timeout_reg; /* Vertex timeout register (2288) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -