Path: blob/21.2-virgl/src/microsoft/spirv_to_dxil/spirv_to_dxil.h
4564 views
/*1* Copyright © Microsoft Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef SPIRV_TO_DXIL_H24#define SPIRV_TO_DXIL_H2526#include <stdbool.h>27#include <stddef.h>28#include <stdint.h>2930#ifdef __cplusplus31extern "C" {32#endif3334// NB: I've copy and pasted some types into this header so we don't have to35// include other headers. This will surely break if any of these types change.3637// Copy of gl_shader_stage38typedef enum {39DXIL_SPIRV_SHADER_NONE = -1,40DXIL_SPIRV_SHADER_VERTEX = 0,41DXIL_SPIRV_SHADER_TESS_CTRL = 1,42DXIL_SPIRV_SHADER_TESS_EVAL = 2,43DXIL_SPIRV_SHADER_GEOMETRY = 3,44DXIL_SPIRV_SHADER_FRAGMENT = 4,45DXIL_SPIRV_SHADER_COMPUTE = 5,46DXIL_SPIRV_SHADER_KERNEL = 6,47} dxil_spirv_shader_stage;4849// Copy of nir_spirv_const_value50typedef union {51bool b;52float f32;53double f64;54int8_t i8;55uint8_t u8;56int16_t i16;57uint16_t u16;58int32_t i32;59uint32_t u32;60int64_t i64;61uint64_t u64;62} dxil_spirv_const_value;6364// Copy of nir_spirv_specialization65struct dxil_spirv_specialization {66uint32_t id;67dxil_spirv_const_value value;68bool defined_on_module;69};7071/**72* Compile a SPIR-V module into DXIL.73* \param words SPIR-V module to compile74* \param word_count number of words in the SPIR-V module75* \param specializations specialization constants to compile with the shader76* \param num_specializations number of specialization constants77* \param buffer will contain the DXIL bytes on success. Needs to be freed()78* \param size length of returned buffer79* \return true if compilation succeeded80*/81bool82spirv_to_dxil(const uint32_t* words,83size_t word_count,84struct dxil_spirv_specialization* specializations,85unsigned int num_specializations,86dxil_spirv_shader_stage stage,87const char* entry_point_name,88void** buffer,89size_t* size);9091/**92* Free the buffer allocated by spirv_to_dxil.93*/94void95spirv_to_dxil_free(void* buffer);9697#ifdef __cplusplus98}99#endif100101#endif102103104