1 2 /* 3 * Copyright © Microsoft Corporation 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 * IN THE SOFTWARE. 23 */ 24 25 #ifndef DXIL_SPIRV_NIR_H 26 #define DXIL_SPIRV_NIR_H 27 28 #include "spirv_to_dxil.h" 29 #include "nir.h" 30 31 const struct spirv_to_nir_options* 32 dxil_spirv_nir_get_spirv_options(void); 33 34 void 35 dxil_spirv_nir_prep(nir_shader *nir); 36 37 /* The pipeline will require runtime data if, and only if, any of the multiple reported 38 * runtime data required flags is true. 39 */ 40 41 void 42 dxil_spirv_nir_link(nir_shader *nir, nir_shader *prev_stage_nir, 43 const struct dxil_spirv_runtime_conf *conf, 44 struct dxil_spirv_metadata *metadata); 45 46 void 47 dxil_spirv_nir_passes(nir_shader *nir, 48 const struct dxil_spirv_runtime_conf *conf, 49 struct dxil_spirv_metadata *metadata); 50 51 struct dxil_spirv_binding_remapping { 52 /* If ~0, don't lower to bindless */ 53 uint32_t descriptor_set; 54 uint32_t binding; 55 bool is_sampler; 56 }; 57 struct dxil_spirv_nir_lower_bindless_options { 58 uint32_t num_descriptor_sets; 59 uint32_t dynamic_buffer_binding; 60 void(*remap_binding)(struct dxil_spirv_binding_remapping *inout, void *context); 61 void *callback_context; 62 }; 63 64 /* Each entry in a bindless descriptor set follows this layout. The first 32 bits are 65 * either a texture or buffer descriptor index in the descriptor heap. For pure 66 * sampler types, these bits are unused. The upper 32 bits are either a buffer 67 * offset, or for samplers (including combined image+sampler), a sampler index. */ 68 struct dxil_spirv_bindless_entry { 69 union { 70 uint32_t texture_idx; 71 uint32_t buffer_idx; 72 }; 73 union { 74 uint32_t buffer_offset; 75 uint32_t sampler_idx; 76 }; 77 }; 78 79 bool 80 dxil_spirv_nir_lower_bindless(nir_shader *nir, struct dxil_spirv_nir_lower_bindless_options *options); 81 82 bool 83 dxil_spirv_nir_lower_buffer_device_address(nir_shader *nir); 84 85 bool 86 dxil_spirv_nir_lower_yz_flip(nir_shader *shader, 87 const struct dxil_spirv_runtime_conf *rt_conf, 88 bool *reads_sysval_ubo); 89 90 #endif 91