Path: blob/21.2-virgl/src/compiler/spirv/nir_spirv.h
4545 views
/*1* Copyright © 2015 Intel 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*22* Authors:23* Jason Ekstrand ([email protected])24*25*/2627#ifndef _NIR_SPIRV_H_28#define _NIR_SPIRV_H_2930#include "util/disk_cache.h"31#include "compiler/nir/nir.h"32#include "compiler/shader_info.h"3334#ifdef __cplusplus35extern "C" {36#endif3738struct nir_spirv_specialization {39uint32_t id;40nir_const_value value;41bool defined_on_module;42};4344enum nir_spirv_debug_level {45NIR_SPIRV_DEBUG_LEVEL_INVALID = -1,46NIR_SPIRV_DEBUG_LEVEL_INFO,47NIR_SPIRV_DEBUG_LEVEL_WARNING,48NIR_SPIRV_DEBUG_LEVEL_ERROR,49};5051enum nir_spirv_execution_environment {52NIR_SPIRV_VULKAN = 0,53NIR_SPIRV_OPENCL,54NIR_SPIRV_OPENGL,55};5657struct spirv_to_nir_options {58enum nir_spirv_execution_environment environment;5960/* Whether to make FragCoord to a system value, the same as61* GLSLFragCoordIsSysVal in GLSL.62*/63bool frag_coord_is_sysval;6465/* Whether to keep ViewIndex as an input instead of rewriting to a sysval.66*/67bool view_index_is_input;6869/* Create a nir library. */70bool create_library;7172/* Whether to use nir_intrinsic_deref_buffer_array_length intrinsic instead73* of nir_intrinsic_get_ssbo_size to lower OpArrayLength.74*/75bool use_deref_buffer_array_length;7677/* Initial value for shader_info::float_controls_execution_mode,78* indicates hardware requirements rather than shader author intent79*/80uint16_t float_controls_execution_mode;8182struct spirv_supported_capabilities caps;8384/* Address format for various kinds of pointers. */85nir_address_format ubo_addr_format;86nir_address_format ssbo_addr_format;87nir_address_format phys_ssbo_addr_format;88nir_address_format push_const_addr_format;89nir_address_format shared_addr_format;90nir_address_format global_addr_format;91nir_address_format temp_addr_format;92nir_address_format constant_addr_format;9394const nir_shader *clc_shader;9596struct {97void (*func)(void *private_data,98enum nir_spirv_debug_level level,99size_t spirv_offset,100const char *message);101void *private_data;102} debug;103};104105bool gl_spirv_validation(const uint32_t *words, size_t word_count,106struct nir_spirv_specialization *spec, unsigned num_spec,107gl_shader_stage stage, const char *entry_point_name);108109nir_shader *spirv_to_nir(const uint32_t *words, size_t word_count,110struct nir_spirv_specialization *specializations,111unsigned num_specializations,112gl_shader_stage stage, const char *entry_point_name,113const struct spirv_to_nir_options *options,114const nir_shader_compiler_options *nir_options);115116bool nir_can_find_libclc(unsigned ptr_bit_size);117118nir_shader *119nir_load_libclc_shader(unsigned ptr_bit_size,120struct disk_cache *disk_cache,121const struct spirv_to_nir_options *spirv_options,122const nir_shader_compiler_options *nir_options);123124bool nir_lower_libclc(nir_shader *shader, const nir_shader *clc_shader);125126#ifdef __cplusplus127}128#endif129130#endif /* _NIR_SPIRV_H_ */131132133