Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a2xx/ir2.h
4574 views
/*1* Copyright (C) 2018 Jonathan Marek <[email protected]>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* 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, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Jonathan Marek <[email protected]>24*/2526#ifndef IR2_H_27#define IR2_H_2829#include "compiler/nir/nir.h"30#include "pipe/p_context.h"3132struct ir2_fetch_info {33/* dword offset of the fetch instruction */34uint16_t offset;35union {36/* swizzle to merge with tgsi swizzle */37struct {38uint16_t dst_swiz;39} vtx;40/* sampler id to patch const_idx */41struct {42uint16_t samp_id;43uint8_t src_swiz;44} tex;45};46};4748struct ir2_shader_info {49/* compiler shader */50uint32_t *dwords;5152/* size of the compiled shader in dwords */53uint16_t sizedwords;5455/* highest GPR # used by shader */56int8_t max_reg;5758/* offset in dwords of first MEMORY export CF (for a20x hw binning) */59int16_t mem_export_ptr;6061/* fetch instruction info for patching */62uint16_t num_fetch_instrs;63struct ir2_fetch_info fetch_info[64];64};6566struct ir2_frag_linkage {67unsigned inputs_count;68struct {69uint8_t slot;70uint8_t ncomp;71} inputs[16];7273/* driver_location of fragcoord.zw, -1 if not used */74int fragcoord;75};7677struct ir2_shader_variant {78struct ir2_shader_info info;79struct ir2_frag_linkage f;80};8182struct fd2_shader_stateobj;83struct tgsi_token;8485void ir2_compile(struct fd2_shader_stateobj *so, unsigned variant,86struct fd2_shader_stateobj *fp);8788struct nir_shader *ir2_tgsi_to_nir(const struct tgsi_token *tokens,89struct pipe_screen *screen);9091const nir_shader_compiler_options *ir2_get_compiler_options(void);9293int ir2_optimize_nir(nir_shader *s, bool lower);9495#endif /* IR2_H_ */969798