Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv30/nv30_vertprog.h
4574 views
#ifndef __NV30_SHADER_H__1#define __NV30_SHADER_H__23/* Vertex programs instruction set4*5* 128bit opcodes, split into 4 32-bit ones for ease of use.6*7* Non-native instructions8* ABS - MOV + NV40_VP_INST0_DEST_ABS9* POW - EX2 + MUL + LG210* SUB - ADD, second source negated11* SWZ - MOV12*13* Register access14* - Only one INPUT can be accessed per-instruction (move extras into TEMPs)15* - Only one CONST can be accessed per-instruction (move extras into TEMPs)16*17* Relative Addressing18* According to the value returned for19* MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB20*21* there are only two address registers available. The destination in the22* ARL instruction is set to TEMP <n> (The temp isn't actually written).23*24* When using vanilla ARB_v_p, the proprietary driver will squish both the25* available ADDRESS regs into the first hardware reg in the X and Y26* components.27*28* To use an address reg as an index into consts, the CONST_SRC is set to29* (const_base + offset) and INDEX_CONST is set.30*31* To access the second address reg use ADDR_REG_SELECT_1. A particular32* component of the address regs is selected with ADDR_SWZ.33*34* Only one address register can be accessed per instruction.35*36* Conditional execution (see NV_vertex_program{2,3} for details) Conditional37* execution of an instruction is enabled by setting COND_TEST_ENABLE, and38* selecting the condition which will allow the test to pass with39* COND_{FL,LT,...}. It is possible to swizzle the values in the condition40* register, which allows for testing against an individual component.41*42* Branching:43*44* The BRA/CAL instructions seem to follow a slightly different opcode45* layout. The destination instruction ID (IADDR) overlaps a source field.46* Instruction ID's seem to be numbered based on the UPLOAD_FROM_ID FIFO47* command, and is incremented automatically on each UPLOAD_INST FIFO48* command.49*50* Conditional branching is achieved by using the condition tests described51* above. There doesn't appear to be dedicated looping instructions, but52* this can be done using a temp reg + conditional branching.53*54* Subroutines may be uploaded before the main program itself, but the first55* executed instruction is determined by the PROGRAM_START_ID FIFO command.56*57*/5859/* DWORD 0 */6061/* guess that this is the same as nv40 */62#define NV30_VP_INST_INDEX_INPUT (1 << 27)6364#define NV30_VP_INST_ADDR_REG_SELECT_1 (1 << 24)65#define NV30_VP_INST_SRC2_ABS (1 << 23) /* guess */66#define NV30_VP_INST_SRC1_ABS (1 << 22) /* guess */67#define NV30_VP_INST_SRC0_ABS (1 << 21) /* guess */68#define NV30_VP_INST_VEC_RESULT (1 << 20)69#define NV30_VP_INST_DEST_TEMP_ID_SHIFT 1670#define NV30_VP_INST_DEST_TEMP_ID_MASK (0x0F << 16)71#define NV30_VP_INST_COND_UPDATE_ENABLE (1<<15)72#define NV30_VP_INST_VEC_DEST_TEMP_MASK (0x1F << 16)73#define NV30_VP_INST_COND_TEST_ENABLE (1<<14)74#define NV30_VP_INST_COND_SHIFT 1175#define NV30_VP_INST_COND_MASK (0x07 << 11)76#define NV30_VP_INST_COND_SWZ_X_SHIFT 977#define NV30_VP_INST_COND_SWZ_X_MASK (0x03 << 9)78#define NV30_VP_INST_COND_SWZ_Y_SHIFT 779#define NV30_VP_INST_COND_SWZ_Y_MASK (0x03 << 7)80#define NV30_VP_INST_COND_SWZ_Z_SHIFT 581#define NV30_VP_INST_COND_SWZ_Z_MASK (0x03 << 5)82#define NV30_VP_INST_COND_SWZ_W_SHIFT 383#define NV30_VP_INST_COND_SWZ_W_MASK (0x03 << 3)84#define NV30_VP_INST_COND_SWZ_ALL_SHIFT 385#define NV30_VP_INST_COND_SWZ_ALL_MASK (0xFF << 3)86#define NV30_VP_INST_ADDR_SWZ_SHIFT 187#define NV30_VP_INST_ADDR_SWZ_MASK (0x03 << 1)88#define NV30_VP_INST_SCA_OPCODEH_SHIFT 089#define NV30_VP_INST_SCA_OPCODEH_MASK (0x01 << 0)9091/* DWORD 1 */92#define NV30_VP_INST_SCA_OPCODEL_SHIFT 2893#define NV30_VP_INST_SCA_OPCODEL_MASK (0x0F << 28)94#define NV30_VP_INST_VEC_OPCODE_SHIFT 2395#define NV30_VP_INST_VEC_OPCODE_MASK (0x1F << 23)96#define NV30_VP_INST_CONST_SRC_SHIFT 1497#define NV30_VP_INST_CONST_SRC_MASK (0xFF << 14)98#define NV30_VP_INST_INPUT_SRC_SHIFT 9 /*NV20*/99#define NV30_VP_INST_INPUT_SRC_MASK (0x0F << 9) /*NV20*/100#define NV30_VP_INST_SRC0H_SHIFT 0 /*NV20*/101#define NV30_VP_INST_SRC0H_MASK (0x1FF << 0) /*NV20*/102103/* Please note: the IADDR fields overlap other fields because they are used104* only for branch instructions. See Branching: label above105*106* DWORD 2107*/108#define NV30_VP_INST_SRC0L_SHIFT 26 /*NV20*/109#define NV30_VP_INST_SRC0L_MASK (0x3F <<26) /* NV30_VP_SRC0_LOW_MASK << 26 */110#define NV30_VP_INST_SRC1_SHIFT 11 /*NV20*/111#define NV30_VP_INST_SRC1_MASK (0x7FFF<<11) /*NV20*/112#define NV30_VP_INST_SRC2H_SHIFT 0 /*NV20*/113#define NV30_VP_INST_SRC2H_MASK (0x7FF << 0) /* NV30_VP_SRC2_HIGH_MASK >> 4*/114#define NV30_VP_INST_IADDR_SHIFT 2115#define NV30_VP_INST_IADDR_MASK (0x1FF << 2) /* NV30_VP_SRC2_LOW_MASK << 28 */116117/* DWORD 3 */118#define NV30_VP_INST_SRC2L_SHIFT 28 /*NV20*/119#define NV30_VP_INST_SRC2L_MASK (0x0F <<28) /*NV20*/120#define NV30_VP_INST_STEMP_WRITEMASK_SHIFT 24121#define NV30_VP_INST_STEMP_WRITEMASK_MASK (0x0F << 24)122#define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT 20123#define NV30_VP_INST_VTEMP_WRITEMASK_MASK (0x0F << 20)124#define NV30_VP_INST_SDEST_WRITEMASK_SHIFT 16125#define NV30_VP_INST_SDEST_WRITEMASK_MASK (0x0F << 16)126#define NV30_VP_INST_VDEST_WRITEMASK_SHIFT 12 /*NV20*/127#define NV30_VP_INST_VDEST_WRITEMASK_MASK (0x0F << 12) /*NV20*/128#define NV30_VP_INST_DEST_SHIFT 2129#define NV30_VP_INST_DEST_MASK (0x1F << 2)130# define NV30_VP_INST_DEST_POS 0131# define NV30_VP_INST_DEST_BFC0 1132# define NV30_VP_INST_DEST_BFC1 2133# define NV30_VP_INST_DEST_COL0 3134# define NV30_VP_INST_DEST_COL1 4135# define NV30_VP_INST_DEST_FOGC 5136# define NV30_VP_INST_DEST_PSZ 6137# define NV30_VP_INST_DEST_TC(n) (8+(n))138# define NV30_VP_INST_DEST_CLP(n) (17 + (n))139140/* guess that this is the same as nv40 */141#define NV30_VP_INST_INDEX_CONST (1 << 1)142143/* Useful to split the source selection regs into their pieces */144#define NV30_VP_SRC0_HIGH_SHIFT 6145#define NV30_VP_SRC0_HIGH_MASK 0x00007FC0146#define NV30_VP_SRC0_LOW_MASK 0x0000003F147#define NV30_VP_SRC2_HIGH_SHIFT 4148#define NV30_VP_SRC2_HIGH_MASK 0x00007FF0149#define NV30_VP_SRC2_LOW_MASK 0x0000000F150151152/* Source-register definition - matches NV20 exactly */153#define NV30_VP_SRC_NEGATE (1<<14)154#define NV30_VP_SRC_SWZ_X_SHIFT 12155#define NV30_VP_SRC_REG_SWZ_X_MASK (0x03 <<12)156#define NV30_VP_SRC_SWZ_Y_SHIFT 10157#define NV30_VP_SRC_REG_SWZ_Y_MASK (0x03 <<10)158#define NV30_VP_SRC_SWZ_Z_SHIFT 8159#define NV30_VP_SRC_REG_SWZ_Z_MASK (0x03 << 8)160#define NV30_VP_SRC_SWZ_W_SHIFT 6161#define NV30_VP_SRC_REG_SWZ_W_MASK (0x03 << 6)162#define NV30_VP_SRC_REG_SWZ_ALL_SHIFT 6163#define NV30_VP_SRC_REG_SWZ_ALL_MASK (0xFF << 6)164#define NV30_VP_SRC_TEMP_SRC_SHIFT 2165#define NV30_VP_SRC_REG_TEMP_ID_MASK (0x0F << 0)166#define NV30_VP_SRC_REG_TYPE_SHIFT 0167#define NV30_VP_SRC_REG_TYPE_MASK (0x03 << 0)168#define NV30_VP_SRC_REG_TYPE_TEMP 1169#define NV30_VP_SRC_REG_TYPE_INPUT 2170#define NV30_VP_SRC_REG_TYPE_CONST 3 /* guess */171172#include "nv30/nvfx_shader.h"173174#endif175176177