1 /* 2 * Copyright © 2017 Intel 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 VK_SHADER_MODULE_H 25 #define VK_SHADER_MODULE_H 26 27 #include <vulkan/vulkan_core.h> 28 29 #include "util/mesa-blake3.h" 30 #include "compiler/shader_enums.h" 31 #include "vk_object.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 struct nir_shader; 38 struct nir_shader_compiler_options; 39 struct spirv_to_nir_options; 40 41 struct vk_shader_module { 42 struct vk_object_base base; 43 struct nir_shader *nir; 44 blake3_hash hash; 45 uint32_t size; 46 char data[0]; 47 }; 48 49 extern const uint8_t vk_shaderModuleIdentifierAlgorithmUUID[VK_UUID_SIZE]; 50 51 VK_DEFINE_NONDISP_HANDLE_CASTS(vk_shader_module, base, VkShaderModule, 52 VK_OBJECT_TYPE_SHADER_MODULE) 53 54 void vk_shader_module_init(struct vk_device *device, 55 struct vk_shader_module *module, 56 const VkShaderModuleCreateInfo *create_info); 57 58 uint32_t vk_shader_module_spirv_version(const struct vk_shader_module *mod); 59 60 /* this should only be used for stack-allocated, temporary objects */ 61 #define vk_shader_module_handle_from_nir(_nir) \ 62 ((VkShaderModule)(uintptr_t)&(struct vk_shader_module) { \ 63 .base.type = VK_OBJECT_TYPE_SHADER_MODULE, \ 64 .nir = _nir, \ 65 }) 66 #define vk_shader_module_from_nir(_nir) \ 67 (struct vk_shader_module) { \ 68 .base.type = VK_OBJECT_TYPE_SHADER_MODULE, \ 69 .nir = _nir, \ 70 } 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* VK_SHADER_MODULE_H */ 77