📄 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.**************************************************************************//* * Authors: * Keith Whitwell <keith@tungstengraphics.com> * 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"#include "radeon_context.h"/* PPC doesnt support 16 bit elts ... */#ifndef MESA_BIG_ENDIAN#define USER_BUFFERS#define RADEON_VTXFMT_A#define HW_VBOS#endif//#define OPTIMIZE_ELTS#define CB_DPATHstruct r300_context;typedef struct r300_context r300ContextRec;typedef struct r300_context *r300ContextPtr;#include "radeon_lock.h"#include "mm.h"/* Checkpoint.. for convenience */#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }/* 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!*/#if 1#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;\ } \ }#else#define WARN_ONCE(a, ...) {}#endif /* We should probably change types within vertex_shader and pixel_shader structure later on */#define CARD32 GLuint#include "vertex_shader.h"#include "r300_fragprog.h"#undef CARD32static __inline__ uint32_t r300PackFloat32(float fl){ union { float fl; uint32_t u; } u; u.fl = fl; return u.u;}/************ 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) */ int aos_format; /* format of components */ int aos_reg; /* VAP register assignment */};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 */ GLuint dirty_state; /* Flags (1 per texunit) for whether or not this texobj has dirty hardware state (pp_*) that needs to be brought into the texunit. */ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS]; /* Six, for the cube faces */ 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 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;};#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 R300_RR_CMD_0 0 /* rr is variable size (at least 1) */#define R300_RR_ROUTE_0 1#define R300_RR_ROUTE_1 2#define R300_RR_ROUTE_2 3#define R300_RR_ROUTE_3 4#define R300_RR_ROUTE_4 5#define R300_RR_ROUTE_5 6#define R300_RR_ROUTE_6 7#define R300_RR_ROUTE_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 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#define R300_FPP_CMD_0 0#define R300_FPP_PARAM_0 1#define R300_FPP_CMDSIZE (32*4+1)#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_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_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 unk2080; /* (2080) */ struct r300_state_atom vof; /* VAP output format register 0x2090 */ struct r300_state_atom vte; /* (20B0) */ struct r300_state_atom unk2134; /* (2134) */ struct r300_state_atom unk2140; /* (2140) */ struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */ struct r300_state_atom vic; /* vap input control (2180) */ struct r300_state_atom unk21DC; /* (21DC) */ struct r300_state_atom unk221C; /* (221C) */ struct r300_state_atom unk2220; /* (2220) */ struct r300_state_atom unk2288; /* (2288) */ struct r300_state_atom pvs; /* pvs_cntl (22D0) */ struct r300_state_atom gb_enable; /* (4008) */ struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */ struct r300_state_atom unk4200; /* (4200) */ struct r300_state_atom unk4214; /* (4214) */ struct r300_state_atom ps; /* pointsize (421C) */ struct r300_state_atom unk4230; /* (4230) */ struct r300_state_atom lcntl; /* line control */ struct r300_state_atom unk4260; /* (4260) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -