📄 r300_reg.h
字号:
/* BEGIN: Fragment program instruction set// Fragment programs are written directly into register space.// There are separate instruction streams for texture instructions and ALU// instructions.// In order to synchronize these streams, the program is divided into up// to 4 nodes. Each node begins with a number of TEX operations, followed// by a number of ALU operations.// The first node can have zero TEX ops, all subsequent nodes must have at least// one TEX ops.// All nodes must have at least one ALU op.//// The index of the last node is stored in PFS_CNTL_0: A value of 0 means// 1 node, a value of 3 means 4 nodes.// The total amount of instructions is defined in PFS_CNTL_2. The offsets are// offsets into the respective instruction streams, while *_END points to the// last instruction relative to this offset. */#define R300_PFS_CNTL_0 0x4600# define R300_PFS_CNTL_LAST_NODES_SHIFT 0# define R300_PFS_CNTL_LAST_NODES_MASK (3 << 0)# define R300_PFS_CNTL_FIRST_NODE_HAS_TEX (1 << 3)#define R300_PFS_CNTL_1 0x4604/* There is an unshifted value here which has so far always been equal to the// index of the highest used temporary register. */#define R300_PFS_CNTL_2 0x4608# define R300_PFS_CNTL_ALU_OFFSET_SHIFT 0# define R300_PFS_CNTL_ALU_OFFSET_MASK (63 << 0)# define R300_PFS_CNTL_ALU_END_SHIFT 6# define R300_PFS_CNTL_ALU_END_MASK (63 << 0)# define R300_PFS_CNTL_TEX_OFFSET_SHIFT 12# define R300_PFS_CNTL_TEX_OFFSET_MASK (31 << 12) /* GUESS */# define R300_PFS_CNTL_TEX_END_SHIFT 18# define R300_PFS_CNTL_TEX_END_MASK (31 << 18) /* GUESS *//* gap *//* Nodes are stored backwards. The last active node is always stored in// PFS_NODE_3.// Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The// first node is stored in NODE_2, the second node is stored in NODE_3.//// Offsets are relative to the master offset from PFS_CNTL_2.// LAST_NODE is set for the last node, and only for the last node. */#define R300_PFS_NODE_0 0x4610#define R300_PFS_NODE_1 0x4614#define R300_PFS_NODE_2 0x4618#define R300_PFS_NODE_3 0x461C# define R300_PFS_NODE_ALU_OFFSET_SHIFT 0# define R300_PFS_NODE_ALU_OFFSET_MASK (63 << 0)# define R300_PFS_NODE_ALU_END_SHIFT 6# define R300_PFS_NODE_ALU_END_MASK (63 << 6)# define R300_PFS_NODE_TEX_OFFSET_SHIFT 12# define R300_PFS_NODE_TEX_OFFSET_MASK (31 << 12)# define R300_PFS_NODE_TEX_END_SHIFT 17# define R300_PFS_NODE_TEX_END_MASK (31 << 17)# define R300_PFS_NODE_LAST_NODE (1 << 22)/* TEX// As far as I can tell, texture instructions cannot write into output// registers directly. A subsequent ALU instruction is always necessary,// even if it's just MAD o0, r0, 1, 0 */#define R300_PFS_TEXI_0 0x4620# define R300_FPITX_SRC_SHIFT 0# define R300_FPITX_SRC_MASK (31 << 0)# define R300_FPITX_SRC_CONST (1 << 5) /* GUESS */# define R300_FPITX_DST_SHIFT 6# define R300_FPITX_DST_MASK (31 << 6)# define R300_FPITX_IMAGE_SHIFT 11# define R300_FPITX_IMAGE_MASK (15 << 11) /* GUESS based on layout and native limits *//* Unsure if these are opcodes, or some kind of bitfield, but this is how * they were set when I checked */# define R300_FPITX_OPCODE_SHIFT 15# define R300_FPITX_OP_TEX 1# define R300_FPITX_OP_TXP 3# define R300_FPITX_OP_TXB 4/* ALU// The ALU instructions register blocks are enumerated according to the order// in which fglrx. I assume there is space for 64 instructions, since// each block has space for a maximum of 64 DWORDs, and this matches reported// native limits.//// The basic functional block seems to be one MAD for each color and alpha,// and an adder that adds all components after the MUL.// - ADD, MUL, MAD etc.: use MAD with appropriate neutral operands// - DP4: Use OUTC_DP4, OUTA_DP4// - DP3: Use OUTC_DP3, OUTA_DP4, appropriate alpha operands// - DPH: Use OUTC_DP4, OUTA_DP4, appropriate alpha operands// - CMP: If ARG2 < 0, return ARG1, else return ARG0// - FLR: use FRC+MAD// - XPD: use MAD+MAD// - SGE, SLT: use MAD+CMP// - RSQ: use ABS modifier for argument// - Use OUTC_REPL_ALPHA to write results of an alpha-only operation (e.g. RCP)// into color register// - apparently, there's no quick DST operation// - fglrx set FPI2_UNKNOWN_31 on a "MAD fragment.color, tmp0, tmp1, tmp2"// - fglrx set FPI2_UNKNOWN_31 on a "MAX r2, r1, c0"// - fglrx once set FPI0_UNKNOWN_31 on a "FRC r1, r1"//// Operand selection// First stage selects three sources from the available registers and// constant parameters. This is defined in INSTR1 (color) and INSTR3 (alpha).// fglrx sorts the three source fields: Registers before constants,// lower indices before higher indices; I do not know whether this is necessary.// fglrx fills unused sources with "read constant 0"// According to specs, you cannot select more than two different constants.//// Second stage selects the operands from the sources. This is defined in// INSTR0 (color) and INSTR2 (alpha). You can also select the special constants// zero and one.// Swizzling and negation happens in this stage, as well.//// Important: Color and alpha seem to be mostly separate, i.e. their sources// selection appears to be fully independent (the register storage is probably// physically split into a color and an alpha section).// However (because of the apparent physical split), there is some interaction// WRT swizzling. If, for example, you want to load an R component into an// Alpha operand, this R component is taken from a *color* source, not from// an alpha source. The corresponding register doesn't even have to appear in// the alpha sources list. (I hope this alll makes sense to you)//// Destination selection// The destination register index is in FPI1 (color) and FPI3 (alpha) together// with enable bits.// There are separate enable bits for writing into temporary registers// (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_* /DSTA_OUTPUT).// You can write to both at once, or not write at all (the same index// must be used for both).//// Note: There is a special form for LRP// - Argument order is the same as in ARB_fragment_program.// - Operation is MAD// - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP// - Set FPI0/FPI2_SPECIAL_LRP// Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD */#define R300_PFS_INSTR1_0 0x46C0# define R300_FPI1_SRC0C_SHIFT 0# define R300_FPI1_SRC0C_MASK (31 << 0)# define R300_FPI1_SRC0C_CONST (1 << 5)# define R300_FPI1_SRC1C_SHIFT 6# define R300_FPI1_SRC1C_MASK (31 << 6)# define R300_FPI1_SRC1C_CONST (1 << 11)# define R300_FPI1_SRC2C_SHIFT 12# define R300_FPI1_SRC2C_MASK (31 << 12)# define R300_FPI1_SRC2C_CONST (1 << 17)# define R300_FPI1_DSTC_SHIFT 18# define R300_FPI1_DSTC_MASK (31 << 18)# define R300_FPI1_DSTC_REG_X (1 << 23)# define R300_FPI1_DSTC_REG_Y (1 << 24)# define R300_FPI1_DSTC_REG_Z (1 << 25)# define R300_FPI1_DSTC_OUTPUT_X (1 << 26)# define R300_FPI1_DSTC_OUTPUT_Y (1 << 27)# define R300_FPI1_DSTC_OUTPUT_Z (1 << 28)#define R300_PFS_INSTR3_0 0x47C0# define R300_FPI3_SRC0A_SHIFT 0# define R300_FPI3_SRC0A_MASK (31 << 0)# define R300_FPI3_SRC0A_CONST (1 << 5)# define R300_FPI3_SRC1A_SHIFT 6# define R300_FPI3_SRC1A_MASK (31 << 6)# define R300_FPI3_SRC1A_CONST (1 << 11)# define R300_FPI3_SRC2A_SHIFT 12# define R300_FPI3_SRC2A_MASK (31 << 12)# define R300_FPI3_SRC2A_CONST (1 << 17)# define R300_FPI3_DSTA_SHIFT 18# define R300_FPI3_DSTA_MASK (31 << 18)# define R300_FPI3_DSTA_REG (1 << 23)# define R300_FPI3_DSTA_OUTPUT (1 << 24)#define R300_PFS_INSTR0_0 0x48C0# define R300_FPI0_ARGC_SRC0C_XYZ 0# define R300_FPI0_ARGC_SRC0C_XXX 1# define R300_FPI0_ARGC_SRC0C_YYY 2# define R300_FPI0_ARGC_SRC0C_ZZZ 3# define R300_FPI0_ARGC_SRC1C_XYZ 4# define R300_FPI0_ARGC_SRC1C_XXX 5# define R300_FPI0_ARGC_SRC1C_YYY 6# define R300_FPI0_ARGC_SRC1C_ZZZ 7# define R300_FPI0_ARGC_SRC2C_XYZ 8# define R300_FPI0_ARGC_SRC2C_XXX 9# define R300_FPI0_ARGC_SRC2C_YYY 10# define R300_FPI0_ARGC_SRC2C_ZZZ 11# define R300_FPI0_ARGC_SRC0A 12# define R300_FPI0_ARGC_SRC1A 13# define R300_FPI0_ARGC_SRC2A 14# define R300_FPI0_ARGC_SRC1C_LRP 15# define R300_FPI0_ARGC_ZERO 20# define R300_FPI0_ARGC_ONE 21# define R300_FPI0_ARGC_HALF 22 /* GUESS */# define R300_FPI0_ARGC_SRC0C_YZX 23# define R300_FPI0_ARGC_SRC1C_YZX 24# define R300_FPI0_ARGC_SRC2C_YZX 25# define R300_FPI0_ARGC_SRC0C_ZXY 26# define R300_FPI0_ARGC_SRC1C_ZXY 27# define R300_FPI0_ARGC_SRC2C_ZXY 28# define R300_FPI0_ARGC_SRC0CA_WZY 29# define R300_FPI0_ARGC_SRC1CA_WZY 30# define R300_FPI0_ARGC_SRC2CA_WZY 31# define R300_FPI0_ARG0C_SHIFT 0# define R300_FPI0_ARG0C_MASK (31 << 0)# define R300_FPI0_ARG0C_NEG (1 << 5)# define R300_FPI0_ARG0C_ABS (1 << 6)# define R300_FPI0_ARG1C_SHIFT 7# define R300_FPI0_ARG1C_MASK (31 << 7)# define R300_FPI0_ARG1C_NEG (1 << 12)# define R300_FPI0_ARG1C_ABS (1 << 13)# define R300_FPI0_ARG2C_SHIFT 14# define R300_FPI0_ARG2C_MASK (31 << 14)# define R300_FPI0_ARG2C_NEG (1 << 19)# define R300_FPI0_ARG2C_ABS (1 << 20)# define R300_FPI0_SPECIAL_LRP (1 << 21)# define R300_FPI0_OUTC_MAD (0 << 23)# define R300_FPI0_OUTC_DP3 (1 << 23)# define R300_FPI0_OUTC_DP4 (2 << 23)# define R300_FPI0_OUTC_MIN (4 << 23)# define R300_FPI0_OUTC_MAX (5 << 23)# define R300_FPI0_OUTC_CMP (8 << 23)# define R300_FPI0_OUTC_FRC (9 << 23)# define R300_FPI0_OUTC_REPL_ALPHA (10 << 23)# define R300_FPI0_OUTC_SAT (1 << 30)# define R300_FPI0_UNKNOWN_31 (1 << 31)#define R300_PFS_INSTR2_0 0x49C0# define R300_FPI2_ARGA_SRC0C_X 0# define R300_FPI2_ARGA_SRC0C_Y 1# define R300_FPI2_ARGA_SRC0C_Z 2# define R300_FPI2_ARGA_SRC1C_X 3# define R300_FPI2_ARGA_SRC1C_Y 4# define R300_FPI2_ARGA_SRC1C_Z 5# define R300_FPI2_ARGA_SRC2C_X 6# define R300_FPI2_ARGA_SRC2C_Y 7# define R300_FPI2_ARGA_SRC2C_Z 8# define R300_FPI2_ARGA_SRC0A 9# define R300_FPI2_ARGA_SRC1A 10# define R300_FPI2_ARGA_SRC2A 11# define R300_FPI2_ARGA_SRC1A_LRP 15# define R300_FPI2_ARGA_ZERO 16# define R300_FPI2_ARGA_ONE 17# define R300_FPI2_ARGA_HALF 18 /* GUESS */# define R300_FPI2_ARG0A_SHIFT 0# define R300_FPI2_ARG0A_MASK (31 << 0)# define R300_FPI2_ARG0A_NEG (1 << 5)# define R300_FPI2_ARG0A_ABS (1 << 6) /* GUESS */# define R300_FPI2_ARG1A_SHIFT 7# define R300_FPI2_ARG1A_MASK (31 << 7)# define R300_FPI2_ARG1A_NEG (1 << 12)# define R300_FPI2_ARG1A_ABS (1 << 13) /* GUESS */# define R300_FPI2_ARG2A_SHIFT 14# define R300_FPI2_ARG2A_MASK (31 << 14)# define R300_FPI2_ARG2A_NEG (1 << 19)# define R300_FPI2_ARG2A_ABS (1 << 20) /* GUESS */# define R300_FPI2_SPECIAL_LRP (1 << 21)# define R300_FPI2_OUTA_MAD (0 << 23)# define R300_FPI2_OUTA_DP4 (1 << 23)# define R300_FPI2_OUTA_MIN (2 << 23)# define R300_FPI2_OUTA_MAX (3 << 23)# define R300_FPI2_OUTA_CMP (6 << 23)# define R300_FPI2_OUTA_FRC (7 << 23)# define R300_FPI2_OUTA_EX2 (8 << 23)# define R300_FPI2_OUTA_LG2 (9 << 23)# define R300_FPI2_OUTA_RCP (10 << 23)# define R300_FPI2_OUTA_RSQ (11 << 23)# define R300_FPI2_OUTA_SAT (1 << 30)# define R300_FPI2_UNKNOWN_31 (1 << 31)/* END *//* gap */#define R300_PP_ALPHA_TEST 0x4BD4# define R300_REF_ALPHA_MASK 0x000000ff
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -