Path: blob/21.2-virgl/src/gallium/drivers/zink/zink_compiler.h
4570 views
/*1* Copyright 2018 Collabora Ltd.2*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* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the 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 NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/2223#ifndef ZINK_COMPILER_H24#define ZINK_COMPILER_H2526#include "pipe/p_defines.h"27#include "pipe/p_state.h"2829#include "compiler/nir/nir.h"30#include "compiler/shader_info.h"31#include "util/u_live_shader_cache.h"3233#include <vulkan/vulkan.h>34#include "zink_descriptors.h"3536#define ZINK_WORKGROUP_SIZE_X 137#define ZINK_WORKGROUP_SIZE_Y 238#define ZINK_WORKGROUP_SIZE_Z 33940struct pipe_screen;41struct zink_context;42struct zink_screen;43struct zink_shader_key;44struct zink_shader_module;45struct zink_gfx_program;4647struct nir_shader_compiler_options;48struct nir_shader;4950struct set;5152struct tgsi_token;53struct zink_so_info {54struct pipe_stream_output_info so_info;55unsigned so_info_slots[PIPE_MAX_SO_OUTPUTS];56bool have_xfb;57};585960const void *61zink_get_compiler_options(struct pipe_screen *screen,62enum pipe_shader_ir ir,63enum pipe_shader_type shader);6465struct nir_shader *66zink_tgsi_to_nir(struct pipe_screen *screen, const struct tgsi_token *tokens);6768struct zink_shader {69struct util_live_shader base;70struct nir_shader *nir;7172struct zink_so_info streamout;7374struct {75int index;76int binding;77VkDescriptorType type;78unsigned char size;79} bindings[ZINK_DESCRIPTOR_TYPES][ZINK_MAX_DESCRIPTORS_PER_TYPE];80size_t num_bindings[ZINK_DESCRIPTOR_TYPES];81unsigned num_texel_buffers;82uint32_t ubos_used; // bitfield of which ubo indices are used83uint32_t ssbos_used; // bitfield of which ssbo indices are used84struct set *programs;8586union {87struct zink_shader *generated; // a generated shader that this shader "owns"88bool is_generated; // if this is a driver-created shader (e.g., tcs)89};90};9192void93zink_screen_init_compiler(struct zink_screen *screen);94void95zink_compiler_assign_io(nir_shader *producer, nir_shader *consumer);96VkShaderModule97zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, nir_shader *nir, struct zink_shader_key *key);9899struct zink_shader *100zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,101const struct pipe_stream_output_info *so_info);102103void104zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize);105106void107zink_shader_free(struct zink_context *ctx, struct zink_shader *shader);108109struct zink_shader *110zink_shader_tcs_create(struct zink_context *ctx, struct zink_shader *vs);111112static inline bool113zink_shader_descriptor_is_buffer(struct zink_shader *zs, enum zink_descriptor_type type, unsigned i)114{115return zs->bindings[type][i].type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER ||116zs->bindings[type][i].type == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;117}118119#endif120121122