1 /* 2 * Copyright © Microsoft Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 #ifndef DXIL_SIGNATURE_H 25 #define DXIL_SIGNATURE_H 26 27 #include "dxil_enums.h" 28 #include "nir.h" 29 #include "util/string_buffer.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /* struct taken from DXILContainer 36 * Enums values were replaced by uint32_t since they must occupy 32 bit 37 */ 38 39 struct dxil_signature_element { 40 uint32_t stream; // Stream index (parameters must appear in non-decreasing stream order) 41 uint32_t semantic_name_offset; // Offset to char * stream from start of DxilProgramSignature. 42 uint32_t semantic_index; // Semantic Index 43 uint32_t system_value; // Semantic type. Similar to DxilSemantic::Kind, but a serialized rather than processing rep. 44 uint32_t comp_type; // Type of bits. 45 uint32_t reg; // Register Index (row index) 46 uint8_t mask; // Mask (column allocation) 47 union { // Unconditional cases useful for validation of shader linkage. 48 uint8_t never_writes_mask; // For an output signature, the shader the signature belongs to never 49 // writes the masked components of the output register. 50 uint8_t always_reads_mask; // For an input signature, the shader the signature belongs to always 51 // reads the masked components of the input register. 52 }; 53 uint16_t pad; 54 uint32_t min_precision; // Minimum precision of input/output data 55 }; 56 57 struct dxil_signature_record { 58 struct dxil_signature_element elements[32]; 59 unsigned num_elements; 60 const char *sysvalue; 61 char *name; 62 uint8_t sig_comp_type; 63 }; 64 65 struct dxil_psv_sem_index_table { 66 uint32_t data[80]; 67 uint32_t size; 68 }; 69 70 struct dxil_psv_signature_element { 71 uint32_t semantic_name_offset; // Offset into StringTable 72 uint32_t semantic_indexes_offset; // Offset into PSVSemanticIndexTable, count == Rows 73 uint8_t rows; // Number of rows this element occupies 74 uint8_t start_row; // Starting row of packing location if allocated 75 uint8_t cols_and_start; // 0:4 = Cols, 4:6 = StartCol, 6:7 == Allocated 76 uint8_t semantic_kind; // PSVSemanticKind 77 uint8_t component_type; // DxilProgramSigCompType 78 uint8_t interpolation_mode; // DXIL::InterpolationMode or D3D10_SB_INTERPOLATION_MODE 79 uint8_t dynamic_mask_and_stream; // 0:4 = DynamicIndexMask, 4:6 = OutputStream (0-3) 80 uint8_t reserved; 81 }; 82 83 struct dxil_psv_runtime_info_0 { 84 union { 85 struct { 86 char output_position_present; 87 } vs; 88 89 struct { 90 uint32_t input_control_point_count; 91 uint32_t output_control_point_count; 92 uint32_t tessellator_domain; 93 uint32_t tessellator_output_primitive; 94 } hs; 95 96 struct { 97 uint32_t input_control_point_count; 98 char output_position_present; 99 uint32_t tessellator_domain; 100 } ds; 101 102 struct { 103 uint32_t input_primitive; 104 uint32_t output_toplology; 105 uint32_t output_stream_mask; 106 char output_position_present; 107 } gs; 108 109 struct { 110 char depth_output; 111 char sample_frequency; 112 } ps; 113 114 /* Maximum sized defining the union size (MSInfo)*/ 115 struct { 116 uint32_t dummy1[3]; 117 uint16_t dummy2[2]; 118 } dummy; 119 }; 120 uint32_t min_expected_wave_lane_count; // minimum lane count required, 0 if unused 121 uint32_t max_expected_wave_lane_count; // maximum lane count required, 0xffffffff if unused 122 }; 123 124 struct dxil_psv_runtime_info_1 { 125 struct dxil_psv_runtime_info_0 psv0; 126 uint8_t shader_stage; // PSVShaderKind 127 uint8_t uses_view_id; 128 union { 129 uint16_t max_vertex_count; // MaxVertexCount for GS only (max 1024) 130 uint8_t sig_patch_const_or_prim_vectors; // Output for HS; Input for DS; Primitive output for MS (overlaps MS1::SigPrimVectors) 131 // struct { uint8_t dummy[2]; } fill; 132 }; 133 134 // PSVSignatureElement counts 135 uint8_t sig_input_elements; 136 uint8_t sig_output_elements; 137 uint8_t sig_patch_const_or_prim_elements; 138 139 // Number of packed vectors per signature 140 uint8_t sig_input_vectors; 141 uint8_t sig_output_vectors[4]; 142 }; 143 144 struct dxil_psv_runtime_info_2 { 145 struct dxil_psv_runtime_info_1 psv1; 146 uint32_t num_threads_x; 147 uint32_t num_threads_y; 148 uint32_t num_threads_z; 149 }; 150 151 struct dxil_mdnode; 152 struct dxil_module; 153 154 void 155 preprocess_signatures(struct dxil_module *mod, nir_shader *s, unsigned input_clip_size); 156 157 const struct dxil_mdnode * 158 get_signatures(struct dxil_module *mod); 159 160 #ifdef __cplusplus 161 } 162 #endif 163 164 #endif 165