17ec681f3Smrg/* 27ec681f3Smrg * Copyright © Microsoft Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef DXIL_SIGNATURE_H 257ec681f3Smrg#define DXIL_SIGNATURE_H 267ec681f3Smrg 277ec681f3Smrg#include "dxil_enums.h" 287ec681f3Smrg#include "nir.h" 297ec681f3Smrg#include "util/string_buffer.h" 307ec681f3Smrg 317ec681f3Smrg#ifdef __cplusplus 327ec681f3Smrgextern "C" { 337ec681f3Smrg#endif 347ec681f3Smrg 357ec681f3Smrg/* struct taken from DXILContainer 367ec681f3Smrg * Enums values were replaced by uint32_t since they must occupy 32 bit 377ec681f3Smrg */ 387ec681f3Smrg 397ec681f3Smrgstruct dxil_signature_element { 407ec681f3Smrg uint32_t stream; // Stream index (parameters must appear in non-decreasing stream order) 417ec681f3Smrg uint32_t semantic_name_offset; // Offset to char * stream from start of DxilProgramSignature. 427ec681f3Smrg uint32_t semantic_index; // Semantic Index 437ec681f3Smrg uint32_t system_value; // Semantic type. Similar to DxilSemantic::Kind, but a serialized rather than processing rep. 447ec681f3Smrg uint32_t comp_type; // Type of bits. 457ec681f3Smrg uint32_t reg; // Register Index (row index) 467ec681f3Smrg uint8_t mask; // Mask (column allocation) 477ec681f3Smrg union { // Unconditional cases useful for validation of shader linkage. 487ec681f3Smrg uint8_t never_writes_mask; // For an output signature, the shader the signature belongs to never 497ec681f3Smrg // writes the masked components of the output register. 507ec681f3Smrg uint8_t always_reads_mask; // For an input signature, the shader the signature belongs to always 517ec681f3Smrg // reads the masked components of the input register. 527ec681f3Smrg }; 537ec681f3Smrg uint16_t pad; 547ec681f3Smrg uint32_t min_precision; // Minimum precision of input/output data 557ec681f3Smrg}; 567ec681f3Smrg 577ec681f3Smrgstruct dxil_signature_record { 587ec681f3Smrg struct dxil_signature_element elements[32]; 597ec681f3Smrg unsigned num_elements; 607ec681f3Smrg const char *sysvalue; 617ec681f3Smrg char *name; 627ec681f3Smrg}; 637ec681f3Smrg 647ec681f3Smrgstruct dxil_psv_sem_index_table { 657ec681f3Smrg uint32_t data[80]; 667ec681f3Smrg uint32_t size; 677ec681f3Smrg}; 687ec681f3Smrg 697ec681f3Smrgstruct dxil_psv_signature_element { 707ec681f3Smrg uint32_t semantic_name_offset; // Offset into StringTable 717ec681f3Smrg uint32_t semantic_indexes_offset; // Offset into PSVSemanticIndexTable, count == Rows 727ec681f3Smrg uint8_t rows; // Number of rows this element occupies 737ec681f3Smrg uint8_t start_row; // Starting row of packing location if allocated 747ec681f3Smrg uint8_t cols_and_start; // 0:4 = Cols, 4:6 = StartCol, 6:7 == Allocated 757ec681f3Smrg uint8_t semantic_kind; // PSVSemanticKind 767ec681f3Smrg uint8_t component_type; // DxilProgramSigCompType 777ec681f3Smrg uint8_t interpolation_mode; // DXIL::InterpolationMode or D3D10_SB_INTERPOLATION_MODE 787ec681f3Smrg uint8_t dynamic_mask_and_stream; // 0:4 = DynamicIndexMask, 4:6 = OutputStream (0-3) 797ec681f3Smrg uint8_t reserved; 807ec681f3Smrg}; 817ec681f3Smrg 827ec681f3Smrgstruct dxil_psv_runtime_info_0 { 837ec681f3Smrg union { 847ec681f3Smrg struct { 857ec681f3Smrg char output_position_present; 867ec681f3Smrg } vs; 877ec681f3Smrg 887ec681f3Smrg struct { 897ec681f3Smrg uint32_t input_primitive; 907ec681f3Smrg uint32_t output_toplology; 917ec681f3Smrg uint32_t output_stream_mask; 927ec681f3Smrg char output_position_present; 937ec681f3Smrg } gs; 947ec681f3Smrg 957ec681f3Smrg struct { 967ec681f3Smrg char depth_output; 977ec681f3Smrg char sample_frequency; 987ec681f3Smrg } ps; 997ec681f3Smrg 1007ec681f3Smrg /* Maximum sized defining the union size (MSInfo)*/ 1017ec681f3Smrg struct { 1027ec681f3Smrg uint32_t dummy1[3]; 1037ec681f3Smrg uint16_t dummy2[2]; 1047ec681f3Smrg } dummy; 1057ec681f3Smrg }; 1067ec681f3Smrg uint32_t min_expected_wave_lane_count; // minimum lane count required, 0 if unused 1077ec681f3Smrg uint32_t max_expected_wave_lane_count; // maximum lane count required, 0xffffffff if unused 1087ec681f3Smrg}; 1097ec681f3Smrg 1107ec681f3Smrgstruct dxil_psv_runtime_info_1 { 1117ec681f3Smrg struct dxil_psv_runtime_info_0 psv0; 1127ec681f3Smrg uint8_t shader_stage; // PSVShaderKind 1137ec681f3Smrg uint8_t uses_view_id; 1147ec681f3Smrg union { 1157ec681f3Smrg uint16_t max_vertex_count; // MaxVertexCount for GS only (max 1024) 1167ec681f3Smrg uint8_t sig_patch_const_or_prim_vectors; // Output for HS; Input for DS; Primitive output for MS (overlaps MS1::SigPrimVectors) 1177ec681f3Smrg // struct { uint8_t dummy[2]; } fill; 1187ec681f3Smrg }; 1197ec681f3Smrg 1207ec681f3Smrg // PSVSignatureElement counts 1217ec681f3Smrg uint8_t sig_input_elements; 1227ec681f3Smrg uint8_t sig_output_elements; 1237ec681f3Smrg uint8_t sig_patch_const_or_prim_elements; 1247ec681f3Smrg 1257ec681f3Smrg // Number of packed vectors per signature 1267ec681f3Smrg uint8_t sig_input_vectors; 1277ec681f3Smrg uint8_t sig_output_vectors[4]; 1287ec681f3Smrg}; 1297ec681f3Smrg 1307ec681f3Smrgstruct dxil_mdnode; 1317ec681f3Smrgstruct dxil_module; 1327ec681f3Smrg 1337ec681f3Smrgconst struct dxil_mdnode * 1347ec681f3Smrgget_signatures(struct dxil_module *mod, nir_shader *s, bool vulkan); 1357ec681f3Smrg 1367ec681f3Smrg#ifdef __cplusplus 1377ec681f3Smrg} 1387ec681f3Smrg#endif 1397ec681f3Smrg 1407ec681f3Smrg#endif 141