#pragma once // Xenia: removed winapifamily.h dependency. // ---------------------------------------------------------------------------- // // D3D11 Tokenized Program Format // // Copyright (c) Microsoft Corporation. // // ---------------------------------------------------------------------------- // // High Level Goals // // - Serve as the runtime/DDI representation for all D3D11 tokenized code, // for all classes of programs, including pixel program, vertex program, // geometry program, etc. // // - Any information that HLSL needs to give to drivers is encoded in // this token format in some form. // // - Enable common tools and source code for managing all tokenizable // program formats. // // - Support extensible token definitions, allowing full customizations for // specific program classes, while maintaining general conventions for all // program models. // // - Binary backwards compatible with D3D10. Any token name that was originally // defined with "D3D10" in it is unchanged; D3D11 only adds new tokens. // // ---------------------------------------------------------------------------- // // Low Level Feature Summary // // - DWORD based tokens always, for simplicity // - Opcode token is generally a single DWORD, though there is a bit indicating // if extended information (extra DWORD(s)) are present // - Operand tokens are a completely self contained, extensible format, // with scalar and 4-vector data types as first class citizens, but // allowance for extension to n-component vectors. // - Initial operand token identifies register type, register file // structure/dimensionality and mode of indexing for each dimension, // and choice of component selection mechanism (i.e. mask vs. swizzle etc). // - Optional additional extended operand tokens can defined things like // modifiers (which are not needed by default). // - Operand's immediate index value(s), if needed, appear as subsequent DWORD // values, and if relative addressing is specified, an additional completely // self contained operand definition appears nested in the token sequence. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Version Token (VerTok) // // [07:00] minor version number (0-255) // [15:08] major version number (0-255) // [31:16] D3D10_SB_TOKENIZED_PROGRAM_TYPE // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_TOKENIZED_PROGRAM_TYPE { D3D10_SB_PIXEL_SHADER = 0, D3D10_SB_VERTEX_SHADER = 1, D3D10_SB_GEOMETRY_SHADER = 2, // D3D11 Shaders D3D11_SB_HULL_SHADER = 3, D3D11_SB_DOMAIN_SHADER = 4, D3D11_SB_COMPUTE_SHADER = 5, D3D11_SB_RESERVED0 = 0xFFF0 } D3D10_SB_TOKENIZED_PROGRAM_TYPE; #define D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK 0xffff0000 #define D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT 16 // DECODER MACRO: Retrieve program type from version token #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_TYPE(VerTok) ((D3D10_SB_TOKENIZED_PROGRAM_TYPE)(((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK)>>D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT)) #define D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK 0x000000f0 #define D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT 4 #define D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK 0x0000000f // DECODER MACRO: Retrieve major version # from version token #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION(VerTok) (((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK)>>D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT) // DECODER MACRO: Retrieve minor version # from version token #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION(VerTok) ((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK) // ENCODER MACRO: Create complete VerTok #define ENCODE_D3D10_SB_TOKENIZED_PROGRAM_VERSION_TOKEN(ProgType,MajorVer,MinorVer) ((((ProgType)<> D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT) // ENCODER MACRO: Store instruction length // portion of OpcodeToken0, in # of DWORDs // including the opcode token(s). // Valid range is 1-127. #define ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(Length) (((Length)<>D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT)) // ENCODER MACRO: Store "zero" or "nonzero" in the opcode // specific control range of OpcodeToken0 #define ENCODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(Boolean) (((Boolean)<>D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT)) // ENCODER MACRO: Given a set of // D3D10_SB_OPERAND_4_COMPONENT_[X|Y|Z|W] values // or'd together, encode them in OpcodeToken0. #define ENCODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(ComponentMask) (((ComponentMask)<>D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT)) // ENCODER MACRO: Encode the return type for the resinfo instruction // in the opcode specific control range of OpcodeToken0 #define ENCODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(ReturnType) (((ReturnType)<> D3D10_SB_OPCODE_EXTENDED_SHIFT) // ENCODER MACRO: Store in OpcodeToken0 whether the opcode is extended // by an additional opcode token. #define ENCODE_D3D10_SB_OPCODE_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPCODE_EXTENDED_MASK:0) // ---------------------------------------------------------------------------- // Extended Opcode Format (OpcodeToken1) // // If bit31 of an opcode token is set, the // opcode has an additional extended opcode token DWORD // directly following OpcodeToken0. Other tokens // expected for the opcode, such as the operand // token(s) always follow // OpcodeToken0 AND OpcodeToken1..n (extended // opcode tokens, if present). // // [05:00] D3D10_SB_EXTENDED_OPCODE_TYPE // [30:06] if([05:00] == D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS) // { // This custom opcode contains controls for SAMPLE. // [08:06] Ignored, 0. // [12:09] U texel immediate offset (4 bit 2's comp) (0 default) // [16:13] V texel immediate offset (4 bit 2's comp) (0 default) // [20:17] W texel immediate offset (4 bit 2's comp) (0 default) // [30:14] Ignored, 0. // } // else if( [05:00] == D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM ) // { // [10:06] D3D10_SB_RESOURCE_DIMENSION // [22:11] When dimension is D3D11_SB_RESOURCE_DIMENSION_STRUCTURED_BUFFER this holds the buffer stride, otherwise 0 // [30:23] Ignored, 0. // } // else if( [05:00] == D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE ) // { // [09:06] D3D10_SB_RESOURCE_RETURN_TYPE for component X // [13:10] D3D10_SB_RESOURCE_RETURN_TYPE for component Y // [17:14] D3D10_SB_RESOURCE_RETURN_TYPE for component Z // [21:18] D3D10_SB_RESOURCE_RETURN_TYPE for component W // [30:22] Ignored, 0. // } // else // { // [30:04] Ignored, 0. // } // [31] 0 normally. 1 there is another extended opcode. Any number // of extended opcode tokens can be chained. It is possible that some extended // opcode tokens could include multiple DWORDS - that is defined // on a case by case basis. // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_EXTENDED_OPCODE_TYPE { D3D10_SB_EXTENDED_OPCODE_EMPTY = 0, D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS = 1, D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM = 2, D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE = 3, } D3D10_SB_EXTENDED_OPCODE_TYPE; #define D3D11_SB_MAX_SIMULTANEOUS_EXTENDED_OPCODES 3 #define D3D10_SB_EXTENDED_OPCODE_TYPE_MASK 0x0000003f // DECODER MACRO: Given an extended opcode // token (OpcodeToken1), figure out what type // of token it is (from D3D10_SB_EXTENDED_OPCODE_TYPE enum) // to be able to interpret the rest of the token's contents. #define DECODE_D3D10_SB_EXTENDED_OPCODE_TYPE(OpcodeToken1) ((D3D10_SB_EXTENDED_OPCODE_TYPE)((OpcodeToken1)&D3D10_SB_EXTENDED_OPCODE_TYPE_MASK)) // ENCODER MACRO: Store extended opcode token // type in OpcodeToken1. #define ENCODE_D3D10_SB_EXTENDED_OPCODE_TYPE(ExtOpcodeType) ((ExtOpcodeType)&D3D10_SB_EXTENDED_OPCODE_TYPE_MASK) typedef enum D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD { D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_U = 0, D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_V = 1, D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_W = 2, } D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD; #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK (3) #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) (9+4*((Coord)&D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK)) #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord) (0x0000000f<>(D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord)))) // ENCODER MACRO: Store the immediate texel address offset // for U or V or W Coord (D3D10_SB_ADDRESS_OFFSET_COORD) in an extended // opcode token (OpcodeToken1) that has extended opcode // type == D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS (opcode type encoded separately) // A 2's complement number is expected as input, from which the LSB 4 bits are extracted. #define ENCODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET(Coord,ImmediateOffset) (((ImmediateOffset)<>D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT)) // ENCODER MACRO: Store resource dimension // (D3D10_SB_RESOURCE_DIMENSION enum) into a // an extended resource declaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM) #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION(ResourceDim) (((ResourceDim)<>D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT) // ENCODER MACRO: Store resource dimension structure stride // (12-bit unsigned integer) into a // an extended resource declaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM) #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(Stride) (((Stride)<> \ (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT))&D3D10_SB_RESOURCE_RETURN_TYPE_MASK)) // ENCODER MACRO: Generate a resource return type for a component in an extended // resource delcaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE) #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE(ReturnType, Component) \ (((ReturnType)&D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT)) // ---------------------------------------------------------------------------- // Custom-Data Block Format // // DWORD 0 (CustomDataDescTok): // [10:00] == D3D10_SB_OPCODE_CUSTOMDATA // [31:11] == D3D10_SB_CUSTOMDATA_CLASS // // DWORD 1: // 32-bit unsigned integer count of number // of DWORDs in custom-data block, // including DWORD 0 and DWORD 1. // So the minimum value is 0x00000002, // meaning empty custom-data. // // Layout of custom-data contents, for the various meta-data classes, // not defined in this file. // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_CUSTOMDATA_CLASS { D3D10_SB_CUSTOMDATA_COMMENT = 0, D3D10_SB_CUSTOMDATA_DEBUGINFO, D3D10_SB_CUSTOMDATA_OPAQUE, D3D10_SB_CUSTOMDATA_DCL_IMMEDIATE_CONSTANT_BUFFER, D3D11_SB_CUSTOMDATA_SHADER_MESSAGE, D3D11_SB_CUSTOMDATA_SHADER_CLIP_PLANE_CONSTANT_MAPPINGS_FOR_DX9, } D3D10_SB_CUSTOMDATA_CLASS; #define D3D10_SB_CUSTOMDATA_CLASS_MASK 0xfffff800 #define D3D10_SB_CUSTOMDATA_CLASS_SHIFT 11 // DECODER MACRO: Find out what class of custom-data is present. // The contents of the custom-data block are defined // for each class of custom-data. #define DECODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataDescTok) ((D3D10_SB_CUSTOMDATA_CLASS)(((CustomDataDescTok)&D3D10_SB_CUSTOMDATA_CLASS_MASK)>>D3D10_SB_CUSTOMDATA_CLASS_SHIFT)) // ENCODER MACRO: Create complete CustomDataDescTok #define ENCODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataClass) (ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_CUSTOMDATA)|(((CustomDataClass)<= D3D10_SB_OPERAND_INDEX_1D ) // D3D10_SB_OPERAND_INDEX_REPRESENTATION for first operand index // else // Ignored, 0 // [27:25] if( [21:20] >= D3D10_SB_OPERAND_INDEX_2D ) // D3D10_SB_OPERAND_INDEX_REPRESENTATION for second operand index // else // Ignored, 0 // [30:28] if( [21:20] == D3D10_SB_OPERAND_INDEX_3D ) // D3D10_SB_OPERAND_INDEX_REPRESENTATION for third operand index // else // Ignored, 0 // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. // // ---------------------------------------------------------------------------- // Number of components in data vector referred to by operand. typedef enum D3D10_SB_OPERAND_NUM_COMPONENTS { D3D10_SB_OPERAND_0_COMPONENT = 0, D3D10_SB_OPERAND_1_COMPONENT = 1, D3D10_SB_OPERAND_4_COMPONENT = 2, D3D10_SB_OPERAND_N_COMPONENT = 3 // unused for now } D3D10_SB_OPERAND_NUM_COMPONENTS; #define D3D10_SB_OPERAND_NUM_COMPONENTS_MASK 0x00000003 // DECODER MACRO: Extract from OperandToken0 how many components // the data vector referred to by the operand contains. // (D3D10_SB_OPERAND_NUM_COMPONENTS enum) #define DECODE_D3D10_SB_OPERAND_NUM_COMPONENTS(OperandToken0) ((D3D10_SB_OPERAND_NUM_COMPONENTS)((OperandToken0)&D3D10_SB_OPERAND_NUM_COMPONENTS_MASK)) // ENCODER MACRO: Define in OperandToken0 how many components // the data vector referred to by the operand contains. // (D3D10_SB_OPERAND_NUM_COMPONENTS enum). #define ENCODE_D3D10_SB_OPERAND_NUM_COMPONENTS(NumComp) ((NumComp)&D3D10_SB_OPERAND_NUM_COMPONENTS_MASK) typedef enum D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE { D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE = 0, // mask 4 components D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE = 1, // swizzle 4 components D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE = 2, // select 1 of 4 components } D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE; #define D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK 0x0000000c #define D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT 2 // DECODER MACRO: For an operand representing 4component data, // extract from OperandToken0 the method for selecting data from // the 4 components (D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE). #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(OperandToken0) ((D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE)(((OperandToken0)&D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK)>>D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT)) // ENCODER MACRO: For an operand representing 4component data, // encode in OperandToken0 a value from D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(SelectionMode) (((SelectionMode)<>(D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT+2*((DestComp)&D3D10_SB_4_COMPONENT_NAME_MASK)))&D3D10_SB_4_COMPONENT_NAME_MASK)) // ENCODER MACRO: Generate a 4 component swizzle given // 4 D3D10_SB_4_COMPONENT_NAME source values for dest // components x, y, z, w respectively. #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(XSrc,YSrc,ZSrc,WSrc) ((((XSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)| \ (((YSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<2)| \ (((ZSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<4)| \ (((WSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<6) \ )<>D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT)) // ENCODER MACRO: Given a D3D10_SB_4_COMPONENT_NAME selecting // a single component for D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE, // encode it into OperandToken0 #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1(SelectedComp) (((SelectedComp)<>D3D10_SB_OPERAND_TYPE_SHIFT)) // ENCODER MACRO: Store operand type in OperandToken0. #define ENCODE_D3D10_SB_OPERAND_TYPE(OperandType) (((OperandType)<>D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT)) // ENCODER MACRO: Store operand index dimension // (D3D10_SB_OPERAND_INDEX_DIMENSION enum) in OperandToken0. #define ENCODE_D3D10_SB_OPERAND_INDEX_DIMENSION(OperandIndexDim) (((OperandIndexDim)<>D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim))) // ENCODER MACRO: Store in OperandToken0 what representation // an operand index is provided as (D3D10_SB_OPERAND_INDEX_REPRESENTATION enum), // for index dimension [0], [1] or [2], depending on D3D10_SB_OPERAND_INDEX_DIMENSION. #define ENCODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION(Dim,IndexRepresentation) (((IndexRepresentation)<>D3D10_SB_OPERAND_EXTENDED_SHIFT) // ENCODER MACRO: Store in OperandToken0 whether the operand is extended // by an additional operand token. #define ENCODE_D3D10_SB_OPERAND_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPERAND_EXTENDED_MASK:0) // ---------------------------------------------------------------------------- // Extended Instruction Operand Format (OperandToken1) // // If bit31 of an operand token is set, the // operand has additional data in a second DWORD // directly following OperandToken0. Other tokens // expected for the operand, such as immmediate // values or relative address operands (full // operands in themselves) always follow // OperandToken0 AND OperandToken1..n (extended // operand tokens, if present). // // [05:00] D3D10_SB_EXTENDED_OPERAND_TYPE // [16:06] if([05:00] == D3D10_SB_EXTENDED_OPERAND_MODIFIER) // { // [13:06] D3D10_SB_OPERAND_MODIFIER // [16:14] Min Precision: D3D11_SB_OPERAND_MIN_PRECISION // [17:17] Non-uniform: D3D12_SB_OPERAND_NON_UNIFORM // } // else // { // [17:06] Ignored, 0. // } // [30:18] Ignored, 0. // [31] 0 normally. 1 if second order extended operand definition, // meaning next DWORD contains yet ANOTHER extended operand // description. Currently no second order extensions defined. // This would be useful if a particular extended operand does // not have enough space to store the required information in // a single token and so is extended further. // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_EXTENDED_OPERAND_TYPE { D3D10_SB_EXTENDED_OPERAND_EMPTY = 0, // Might be used if this // enum is full and // further extended opcode // is needed. D3D10_SB_EXTENDED_OPERAND_MODIFIER = 1, } D3D10_SB_EXTENDED_OPERAND_TYPE; #define D3D10_SB_EXTENDED_OPERAND_TYPE_MASK 0x0000003f // DECODER MACRO: Given an extended operand // token (OperandToken1), figure out what type // of token it is (from D3D10_SB_EXTENDED_OPERAND_TYPE enum) // to be able to interpret the rest of the token's contents. #define DECODE_D3D10_SB_EXTENDED_OPERAND_TYPE(OperandToken1) ((D3D10_SB_EXTENDED_OPERAND_TYPE)((OperandToken1)&D3D10_SB_EXTENDED_OPERAND_TYPE_MASK)) // ENCODER MACRO: Store extended operand token // type in OperandToken1. #define ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(ExtOperandType) ((ExtOperandType)&D3D10_SB_EXTENDED_OPERAND_TYPE_MASK) typedef enum D3D10_SB_OPERAND_MODIFIER { D3D10_SB_OPERAND_MODIFIER_NONE = 0, // Nop. This is the implied // default if the extended // operand is not present for // an operand for which source // modifiers are meaningful D3D10_SB_OPERAND_MODIFIER_NEG = 1, // Negate D3D10_SB_OPERAND_MODIFIER_ABS = 2, // Absolute value, abs() D3D10_SB_OPERAND_MODIFIER_ABSNEG = 3, // -abs() } D3D10_SB_OPERAND_MODIFIER; #define D3D10_SB_OPERAND_MODIFIER_MASK 0x00003fc0 #define D3D10_SB_OPERAND_MODIFIER_SHIFT 6 // DECODER MACRO: Given a D3D10_SB_EXTENDED_OPERAND_MODIFIER // extended token (OperandToken1), determine the source modifier // (D3D10_SB_OPERAND_MODIFIER enum) #define DECODE_D3D10_SB_OPERAND_MODIFIER(OperandToken1) ((D3D10_SB_OPERAND_MODIFIER)(((OperandToken1)&D3D10_SB_OPERAND_MODIFIER_MASK)>>D3D10_SB_OPERAND_MODIFIER_SHIFT)) // ENCODER MACRO: Generate a complete source modifier extended token // (OperandToken1), given D3D10_SB_OPERAND_MODIFIER enum (the // ext. operand type is also set to D3D10_SB_EXTENDED_OPERAND_MODIFIER). #define ENCODE_D3D10_SB_EXTENDED_OPERAND_MODIFIER(SourceMod) ((((SourceMod)<> D3D11_SB_OPERAND_MIN_PRECISION_SHIFT)) // ENCODER MACRO: Encode minimum precision for execution // into the extended operand token, OperandToken1 #define ENCODE_D3D11_SB_OPERAND_MIN_PRECISION(MinPrecision) (((MinPrecision)<< D3D11_SB_OPERAND_MIN_PRECISION_SHIFT)& D3D11_SB_OPERAND_MIN_PRECISION_MASK) // Non-uniform extended operand modifier. #define D3D12_SB_OPERAND_NON_UNIFORM_MASK 0x00020000 #define D3D12_SB_OPERAND_NON_UNIFORM_SHIFT 17 // DECODER MACRO: For an OperandToken1 that can specify a non-uniform operand #define DECODE_D3D12_SB_OPERAND_NON_UNIFORM(OperandToken1) (((OperandToken1)& D3D12_SB_OPERAND_NON_UNIFORM_MASK)>> D3D12_SB_OPERAND_NON_UNIFORM_SHIFT) // ENCODER MACRO: Encode non-uniform state into the extended operand token, OperandToken1 #define ENCODE_D3D12_SB_OPERAND_NON_UNIFORM(NonUniform) (((NonUniform)<< D3D12_SB_OPERAND_NON_UNIFORM_SHIFT)& D3D12_SB_OPERAND_NON_UNIFORM_MASK) #define D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK 0x80000000 #define D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT 31 // DECODER MACRO: Determine if an extended operand token // (OperandToken1) is further extended by yet another token // (OperandToken2). Currently there are no secondary // extended operand tokens. #define DECODE_IS_D3D10_SB_OPERAND_DOUBLE_EXTENDED(OperandToken1) (((OperandToken1)&D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK)>>D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT) // ENCODER MACRO: Store in OperandToken1 whether the operand is extended // by an additional operand token. Currently there are no secondary // extended operand tokens. #define ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK:0) // ---------------------------------------------------------------------------- // Name Token (NameToken) (used in declaration statements) // // [15:00] D3D10_SB_NAME enumeration // [31:16] Reserved, 0 // // ---------------------------------------------------------------------------- #define D3D10_SB_NAME_MASK 0x0000ffff // DECODER MACRO: Get the name from NameToken #define DECODE_D3D10_SB_NAME(NameToken) ((D3D10_SB_NAME)((NameToken)&D3D10_SB_NAME_MASK)) // ENCODER MACRO: Generate a complete NameToken given a D3D10_SB_NAME #define ENCODE_D3D10_SB_NAME(Name) ((Name)&D3D10_SB_NAME_MASK) //--------------------------------------------------------------------- // Declaration Statements // // Declarations start with a standard opcode token, // having opcode type being D3D10_SB_OPCODE_DCL*. // Each particular declaration type has custom // operand token(s), described below. //--------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Global Flags Declaration // // OpcodeToken0: // // [10:00] D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS // [11:11] Refactoring allowed if bit set. // [12:12] Enable double precision float ops. // [13:13] Force early depth-stencil test. // [14:14] Enable RAW and structured buffers in non-CS 4.x shaders. // [15:15] Skip optimizations of shader IL when translating to native code // [16:16] Enable minimum-precision data types // [17:17] Enable 11.1 double-precision floating-point instruction extensions // [18:18] Enable 11.1 non-double instruction extensions // [23:19] Reserved for future flags. // [30:24] Instruction length in DWORDs including the opcode token. == 1 // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by no operands. // // ---------------------------------------------------------------------------- #define D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED (1<<11) #define D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS (1<<12) #define D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL (1<<13) #define D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS (1<<14) #define D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION (1<<15) #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION (1<<16) #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS (1<<17) #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS (1<<18) #define D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND (1<<19) #define D3D10_SB_GLOBAL_FLAGS_MASK 0x00fff800 // DECODER MACRO: Get global flags #define DECODE_D3D10_SB_GLOBAL_FLAGS(OpcodeToken0) ((OpcodeToken0)&D3D10_SB_GLOBAL_FLAGS_MASK) // ENCODER MACRO: Encode global flags #define ENCODE_D3D10_SB_GLOBAL_FLAGS(Flags) ((Flags)&D3D10_SB_GLOBAL_FLAGS_MASK) // ---------------------------------------------------------------------------- // Resource Declaration (non multisampled) // // OpcodeToken0: // // [10:00] D3D10_SB_OPCODE_DCL_RESOURCE // [15:11] D3D10_SB_RESOURCE_DIMENSION // [23:16] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 2 operands on Shader Models 4.0 through 5.0: // (1) an operand, starting with OperandToken0, defining which // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared. // (2) a Resource Return Type token (ResourceReturnTypeToken) // // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (t[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of resources in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the t# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (t[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of resource within space (may be dynamically indexed) // (2) a Resource Return Type token (ResourceReturnTypeToken) // (3) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- #define D3D10_SB_RESOURCE_DIMENSION_MASK 0x0000F800 #define D3D10_SB_RESOURCE_DIMENSION_SHIFT 11 // DECODER MACRO: Given a resource declaration token, // (OpcodeToken0), determine the resource dimension // (D3D10_SB_RESOURCE_DIMENSION enum) #define DECODE_D3D10_SB_RESOURCE_DIMENSION(OpcodeToken0) ((D3D10_SB_RESOURCE_DIMENSION)(((OpcodeToken0)&D3D10_SB_RESOURCE_DIMENSION_MASK)>>D3D10_SB_RESOURCE_DIMENSION_SHIFT)) // ENCODER MACRO: Store resource dimension // (D3D10_SB_RESOURCE_DIMENSION enum) into a // a resource declaration token (OpcodeToken0) #define ENCODE_D3D10_SB_RESOURCE_DIMENSION(ResourceDim) (((ResourceDim)<[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of resources in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the t# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (t[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of resource within space (may be dynamically indexed) // (2) a Resource Return Type token (ResourceReturnTypeToken) // (3) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- // use same macro for encoding/decoding resource dimension aas the non-msaa declaration #define D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK 0x07F0000 #define D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT 16 // DECODER MACRO: Given a resource declaration token, // (OpcodeToken0), determine the resource sample count (1..127) #define DECODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK)>>D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT)) // ENCODER MACRO: Store resource sample count up to 127 into a // a resource declaration token (OpcodeToken0) #define ENCODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(SampleCount) (((SampleCount > 127 ? 127 : SampleCount)<> \ (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS))&D3D10_SB_RESOURCE_RETURN_TYPE_MASK)) // ENCODER MACRO: Generate a resource return type for a component #define ENCODE_D3D10_SB_RESOURCE_RETURN_TYPE(ReturnType, Component) \ (((ReturnType)&D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS)) // ---------------------------------------------------------------------------- // Sampler Declaration // // OpcodeToken0: // // [10:00] D3D10_SB_OPCODE_DCL_SAMPLER // [14:11] D3D10_SB_SAMPLER_MODE // [23:15] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 1 operand on Shader Models 4.0 through 5.0: // (1) Operand starting with OperandToken0, defining which sampler // (D3D10_SB_OPERAND_TYPE_SAMPLER) register # is being declared. // // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // s# register (D3D10_SB_OPERAND_TYPE_SAMPLER) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (s[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of samplers in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the s# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (s[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of sampler within space (may be dynamically indexed) // (2) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_SAMPLER_MODE { D3D10_SB_SAMPLER_MODE_DEFAULT = 0, D3D10_SB_SAMPLER_MODE_COMPARISON = 1, D3D10_SB_SAMPLER_MODE_MONO = 2, } D3D10_SB_SAMPLER_MODE; #define D3D10_SB_SAMPLER_MODE_MASK 0x00007800 #define D3D10_SB_SAMPLER_MODE_SHIFT 11 // DECODER MACRO: Find out if a Constant Buffer is going to be indexed or not #define DECODE_D3D10_SB_SAMPLER_MODE(OpcodeToken0) ((D3D10_SB_SAMPLER_MODE)(((OpcodeToken0)&D3D10_SB_SAMPLER_MODE_MASK)>>D3D10_SB_SAMPLER_MODE_SHIFT)) // ENCODER MACRO: Generate a resource return type for a component #define ENCODE_D3D10_SB_SAMPLER_MODE(SamplerMode) (((SamplerMode)<>D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT)) // ENCODER MACRO: Encode interpolation mode for a register. #define ENCODE_D3D10_SB_INPUT_INTERPOLATION_MODE(InterpolationMode) (((InterpolationMode)<[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of constant buffers in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the cb#[] is used in shader instructions: (cb[][]) // 1 : variable ID being used (matches dcl) // 2 : absolute index of constant buffer within space (may be dynamically indexed) // 3 : location of vector within constant buffer being referenced, // which may also be dynamically indexed, with no access pattern flag required. // (2) a DWORD indicating the size of the constant buffer as a count of 16-byte vectors. // Each vector is 32-bit*4 elements == 128-bits == 16 bytes. // If the size is specified as 0, the CB size is not known (any size CB // can be bound to the slot). // (3) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- typedef enum D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN { D3D10_SB_CONSTANT_BUFFER_IMMEDIATE_INDEXED = 0, D3D10_SB_CONSTANT_BUFFER_DYNAMIC_INDEXED = 1 } D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN; #define D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK 0x00000800 #define D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT 11 // DECODER MACRO: Find out if a Constant Buffer is going to be indexed or not #define DECODE_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(OpcodeToken0) ((D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN)(((OpcodeToken0)&D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK)>>D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT)) // ENCODER MACRO: Encode the access pattern for the Constant Buffer #define ENCODE_D3D10_SB_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(AccessPattern) (((AccessPattern)<>D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT)) // ENCODER MACRO: Store primitive topology // (D3D10_SB_PRIMITIVE enum) into a // a primitive topology declaration token (OpcodeToken0) #define ENCODE_D3D10_SB_GS_INPUT_PRIMITIVE(Prim) (((Prim)<>D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT)) // ENCODER MACRO: Store primitive topology // (D3D10_SB_PRIMITIVE_TOPOLOGY enum) into a // a primitive topology declaration token (OpcodeToken0) #define ENCODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(PrimTopology) (((PrimTopology)<>D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT)) // ENCODER MACRO: Store input control point count into a declaration token #define ENCODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(Count) (((Count)<>D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT)) // ENCODER MACRO: Store output control point count into a declaration token #define ENCODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(Count) (((Count)<>D3D11_SB_TESS_DOMAIN_SHIFT)) // ENCODER MACRO: Store tessellator domain // (D3D11_SB_TESSELLATOR_DOMAIN enum) into a // a tessellator domain declaration token (OpcodeToken0) #define ENCODE_D3D11_SB_TESS_DOMAIN(Domain) (((Domain)<>D3D11_SB_TESS_PARTITIONING_SHIFT)) // ENCODER MACRO: Store tessellator partitioning // (D3D11_SB_TESSELLATOR_PARTITIONING enum) into a // a tessellator partitioning declaration token (OpcodeToken0) #define ENCODE_D3D11_SB_TESS_PARTITIONING(Partitioning) (((Partitioning)<>D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT)) // ENCODER MACRO: Store tessellator output primitive // (D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE enum) into a // a tessellator output primitive declaration token (OpcodeToken0) #define ENCODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(OutputPrimitive) (((OutputPrimitive)<>D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT)) // ENCODER MACRO: Encode the return type for instructions // in the opcode specific control range of OpcodeToken0 #define ENCODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(ReturnType) (((ReturnType)<>D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT) ? true : false) #define ENCODE_D3D11_SB_INTERFACE_INDEXED_BIT(IndexedBit) (((IndexedBit)<>D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT)) #define ENCODE_D3D11_SB_INTERFACE_TABLE_LENGTH(TableLength) (((TableLength)<>D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT)) #define ENCODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(ArrayLength) (((ArrayLength)<[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of UAV's in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the u# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (u[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of uav within space (may be dynamically indexed) // (2) a Resource Return Type token (ResourceReturnTypeToken) // (3) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- // UAV access scope flags #define D3D11_SB_GLOBALLY_COHERENT_ACCESS 0x00010000 #define D3D11_SB_ACCESS_COHERENCY_MASK 0x00010000 // DECODER MACRO: Retrieve flags for sync instruction from OpcodeToken0. #define DECODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_ACCESS_COHERENCY_MASK) // ENCODER MACRO: Given a set of sync instruciton flags, encode them in OpcodeToken0. #define ENCODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(Flags) ((Flags)&D3D11_SB_ACCESS_COHERENCY_MASK) // Additional UAV access flags #define D3D11_SB_RASTERIZER_ORDERED_ACCESS 0x00020000 // Resource flags mask. Use to retrieve all resource flags, including the order preserving counter. #define D3D11_SB_RESOURCE_FLAGS_MASK (D3D11_SB_GLOBALLY_COHERENT_ACCESS|D3D11_SB_RASTERIZER_ORDERED_ACCESS|D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER) // DECODER MACRO: Retrieve UAV access flags for from OpcodeToken0. #define DECODE_D3D11_SB_RESOURCE_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_RESOURCE_FLAGS_MASK) // ENCODER MACRO: Given UAV access flags, encode them in OpcodeToken0. #define ENCODE_D3D11_SB_RESOURCE_FLAGS(Flags) ((Flags)&D3D11_SB_RESOURCE_FLAGS_MASK) // ---------------------------------------------------------------------------- // Raw Unordered Access View Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW // [15:11] Ignored, 0 // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT) // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0 // [23:18] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 1 operand on Shader Models 4.0 through 5.0: // (1) an operand, starting with OperandToken0, defining which // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared. // // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (u[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of UAV's in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the u# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (u[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of uav within space (may be dynamically indexed) // (2) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Structured Unordered Access View Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED // [15:11] Ignored, 0 // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT) // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0 // [22:18] Ignored, 0 // [23:23] D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER or 0 // // The presence of this flag means that if a UAV is bound to the // corresponding slot, it must have been created with // D3D11_BUFFER_UAV_FLAG_COUNTER at the API. Also, the shader // can contain either imm_atomic_alloc or _consume instructions // operating on the given UAV. // // If this flag is not present, the shader can still contain // either imm_atomic_alloc or imm_atomic_consume instructions for // this UAV. But if such instructions are present in this case, // and a UAV is bound corresponding slot, it must have been created // with the D3D11_BUFFER_UAV_FLAG_APPEND flag at the API. // Append buffers have a counter as well, but values returned // to the shader are only valid for the lifetime of the shader // invocation. // // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 2 operands: // (1) an operand, starting with OperandToken0, defining which // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is // being declared. // (2) a DWORD indicating UINT32 byte stride // // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (u[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of UAV's in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the u# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (u[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of uav within space (may be dynamically indexed) // (2) a DWORD indicating UINT32 byte stride // (3) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- // UAV flags #define D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER 0x00800000 #define D3D11_SB_UAV_FLAGS_MASK 0x00800000 // DECODER MACRO: Retrieve flags about UAV from OpcodeToken0. #define DECODE_D3D11_SB_UAV_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_UAV_FLAGS_MASK) // ENCODER MACRO: Given a set of UAV flags, encode them in OpcodeToken0. #define ENCODE_D3D11_SB_UAV_FLAGS(Flags) ((Flags)&D3D11_SB_UAV_FLAGS_MASK) // ---------------------------------------------------------------------------- // Raw Thread Group Shared Memory Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW // [23:11] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 2 operands: // (1) an operand, starting with OperandToken0, defining which // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is being declared. // (2) a DWORD indicating the element count, # of 32-bit scalars.. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Structured Thread Group Shared Memory Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED // [23:11] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 3 operands: // (1) an operand, starting with OperandToken0, defining which // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is // being declared. // (2) a DWORD indicating UINT32 struct byte stride // (3) a DWORD indicating UINT32 struct count // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Raw Shader Resource View Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_RAW // [23:11] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 1 operand: // (1) an operand, starting with OperandToken0, defining which // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared. // // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (t[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of resources in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the t# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (t[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of resource within space (may be dynamically indexed) // (2) a DWORD indicating the space index. // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Structured Shader Resource View Declaration // // OpcodeToken0: // // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED // [23:11] Ignored, 0 // [30:24] Instruction length in DWORDs including the opcode token. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD // contains extended operand description. This dcl is currently not // extended. // // OpcodeToken0 is followed by 2 operands: // (1) an operand, starting with OperandToken0, defining which // g# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is // being declared. // (2) a DWORD indicating UINT32 struct byte stride // // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later: // (1) an operand, starting with OperandToken0, defining which // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D, // and the meaning of the index dimensions are as follows: (t[:]) // 1 : variable ID being declared // 2 : the lower bound of the range of resources in the space // 3 : the upper bound (inclusive) of this range // As opposed to when the t# is used in shader instructions, where the register // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index // dimensions are as follows: (t[]): // 1 : variable ID being used (matches dcl) // 2 : absolute index of resource within space (may be dynamically indexed) // (2) a DWORD indicating UINT32 struct byte stride // (3) a DWORD indicating the space index. // // ----------------------------------------------------------------------------