1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/************************************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2011-2012 Advanced Micro Devices, Inc. 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2009 VMware, Inc. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved. 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish, 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions: 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software. 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/ 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @file 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TGSI to LLVM IR translation. 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @author Jose Fonseca <jfonseca@vmware.com> 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @author Tom Stellard <thomas.stellard@amd.com> 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef LP_BLD_TGSI_H 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_BLD_TGSI_H 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld.h" 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_tgsi_action.h" 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_limits.h" 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "lp_bld_type.h" 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_compiler.h" 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h" 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tgsi/tgsi_exec.h" 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tgsi/tgsi_scan.h" 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tgsi/tgsi_info.h" 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_CHAN_ALL ~0 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_MAX_INSTRUCTIONS 256 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_full_declaration; 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_full_immediate; 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_full_instruction; 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_full_src_register; 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_opcode_info; 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_token; 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_shader_info; 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_mask_context; 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct gallivm_state; 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_derivatives; 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum lp_build_tex_modifier { 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LP_BLD_TEX_MODIFIER_NONE = 0, 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LP_BLD_TEX_MODIFIER_PROJECTED, 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LP_BLD_TEX_MODIFIER_LOD_BIAS, 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Describe a channel of a register. 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The value can be a: 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - immediate value (i.e. derived from a IMM register) 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - CONST[n].x/y/z/w 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - IN[n].x/y/z/w 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - undetermined (when .file == TGSI_FILE_NULL) 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is one of the analysis results, and is used to described 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the output color in terms of inputs. 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_tgsi_channel_info 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned file:4; /* TGSI_FILE_* */ 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned swizzle:3; /* PIPE_SWIZZLE_x */ 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org union { 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint32_t index; 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org float value; /* for TGSI_FILE_IMMEDIATE */ 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } u; 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Describe a texture sampler interpolator. 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The interpolation is described in terms of regular inputs. 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_tgsi_texture_info 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_tgsi_channel_info coord[4]; 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned target:8; /* TGSI_TEXTURE_* */ 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit:8; /* Sampler unit */ 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned modifier:8; /* LP_BLD_TEX_MODIFIER_* */ 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_tgsi_info 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tgsi_shader_info base; 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Whether any of the texture opcodes access a register file other than 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TGSI_FILE_INPUT. 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We could also handle TGSI_FILE_CONST/IMMEDIATE here, but there is little 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * benefit. 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned indirect_textures:1; 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Whether any immediate values are outside the range of 0 and 1 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unclamped_immediates:1; 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Texture opcode description. Aimed at detecting and described direct 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * texture opcodes. 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned num_texs; 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_tgsi_texture_info tex[PIPE_MAX_SAMPLERS]; 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Output description. Aimed at detecting and describing simple blit 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * shaders. 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_tgsi_channel_info output[PIPE_MAX_SHADER_OUTPUTS][4]; 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Shortcut pointers into the above (for fragment shaders). 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_tgsi_channel_info *cbuf[PIPE_MAX_COLOR_BUFS]; 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Reference to system values. 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_bld_tgsi_system_values { 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef instance_id; 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef vertex_id; 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Sampler code generation interface. 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Although texture sampling is a requirement for TGSI translation, it is 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a very different problem with several different approaches to it. This 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * structure establishes an interface for texture sampling code generation, so 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * that we can easily use different texture sampling strategies. 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_sampler_soa 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (*destroy)( struct lp_build_sampler_soa *sampler ); 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler, 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned num_coords, 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *coords, 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_derivatives *derivs, 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef lod_bias, /* optional */ 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef explicit_lod, /* optional */ 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *texel); 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (*emit_size_query)( const struct lp_build_sampler_soa *sampler, 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef explicit_lod, /* optional */ 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *sizes_out); 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_sampler_aos 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (*emit_fetch_texel)( struct lp_build_sampler_aos *sampler, 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context *bld, 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned target, /* TGSI_TEXTURE_* */ 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef coords, 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_derivatives derivs, 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org enum lp_build_tex_modifier modifier); 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_info(const struct tgsi_token *tokens, 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_tgsi_info *info); 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_soa(struct gallivm_state *gallivm, 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_token *tokens, 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_mask_context *mask, 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef consts_ptr, 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_bld_tgsi_system_values *system_values, 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *pos, 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef (*inputs)[4], 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef (*outputs)[4], 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_sampler_soa *sampler, 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_shader_info *info); 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_aos(struct gallivm_state *gallivm, 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_token *tokens, 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const unsigned char swizzles[4], 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef consts_ptr, 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *inputs, 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *outputs, 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_sampler_aos *sampler, 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_shader_info *info); 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_exec_mask { 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context *bld; 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org boolean has_mask; 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMTypeRef int_vec_type; 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef cond_stack[LP_MAX_TGSI_NESTING]; 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int cond_stack_size; 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef cond_mask; 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMBasicBlockRef loop_block; 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef cont_mask; 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef break_mask; 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef break_var; 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct { 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMBasicBlockRef loop_block; 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef cont_mask; 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef break_mask; 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef break_var; 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } loop_stack[LP_MAX_TGSI_NESTING]; 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int loop_stack_size; 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef ret_mask; 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct { 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int pc; 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef ret_mask; 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } call_stack[LP_MAX_TGSI_NESTING]; 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int call_stack_size; 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef exec_mask; 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef loop_limiter; 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_tgsi_inst_list 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tgsi_full_instruction *instructions; 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint max_instructions; 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint num_instructions; 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_context * bld_base); 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned lp_bld_tgsi_add_instruction( 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tgsi_full_instruction *inst_to_add); 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_tgsi_context; 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef LLVMValueRef (*lp_build_emit_fetch_fn)(struct lp_build_tgsi_context *, 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_src_register *, 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org enum tgsi_opcode_type, 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned); 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_tgsi_context 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context base; 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context uint_bld; 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context int_bld; 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** This array stores functions that are used to transform TGSI opcodes to 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LLVM instructions. 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_action op_actions[TGSI_OPCODE_LAST]; 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* TGSI_OPCODE_RSQ is defined as 1 / sqrt( abs(src0.x) ), rsq_action 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * should compute 1 / sqrt (src0.x) */ 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_action rsq_action; 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_shader_info *info; 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT]; 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *, 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef, unsigned, unsigned, unsigned, unsigned); 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*emit_store)(struct lp_build_tgsi_context *, 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *, 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_opcode_info *, 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef dst[4]); 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*emit_declaration)(struct lp_build_tgsi_context *, 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_declaration *decl); 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*emit_immediate)(struct lp_build_tgsi_context *, 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_immediate *imm); 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Allow the user to store data in this structure rather than passing it 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to every function. */ 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void * userdata; 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org boolean soa; 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int pc; 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tgsi_full_instruction *instructions; 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint max_instructions; 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint num_instructions; 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** This function allows the user to insert some instructions at the 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * beginning of the program. It is optional and does not need to be 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * implemented. 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*emit_prologue)(struct lp_build_tgsi_context*); 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** This function allows the user to insert some instructions at the end of 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the program. This callback is intended to be used for emitting 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * instructions to handle the export for the output registers, but it can 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * be used for any purpose. Implementing this function is optiona, but 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * recommended. 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*emit_epilogue)(struct lp_build_tgsi_context*); 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_tgsi_soa_context 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context bld_base; 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Builder for scalar elements of shader's data type (float) */ 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context elem_bld; 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef consts_ptr; 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *pos; 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS]; 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS]; 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_build_sampler_soa *sampler; 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][TGSI_NUM_CHANNELS]; 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef temps[LP_MAX_TGSI_TEMPS][TGSI_NUM_CHANNELS]; 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef addr[LP_MAX_TGSI_ADDRS][TGSI_NUM_CHANNELS]; 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef preds[LP_MAX_TGSI_PREDS][TGSI_NUM_CHANNELS]; 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * set in the indirect_files field. 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The temps[] array above is unused then. 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef temps_array; 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * set in the indirect_files field. 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The outputs[] array above is unused then. 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef outputs_array; 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * set in the indirect_files field. 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The inputs[] array above is unused then. 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef inputs_array; 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_bld_tgsi_system_values system_values; 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** bitmask indicating which register files are accessed indirectly */ 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned indirect_files; 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_mask_context *mask; 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_exec_mask exec_mask; 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint num_immediates; 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_emit_declaration_soa( 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld, 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_declaration *decl); 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid lp_emit_immediate_soa( 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_immediate *imm); 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_emit_instruction_soa( 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_soa_context *bld, 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst, 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_opcode_info *info); 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_get_temp_ptr_soa( 423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_soa_context *bld, 424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned index, 425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned chan); 426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_get_output_ptr( 429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_soa_context *bld, 430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned index, 431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned chan); 432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_tgsi_aos_context 434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context bld_base; 436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Builder for integer masks and indices */ 438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_context int_bld; 439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * AoS swizzle used: 442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - swizzles[0] = red index 443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - swizzles[1] = green index 444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - swizzles[2] = blue index 445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - swizzles[3] = alpha index 446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned char swizzles[4]; 448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned char inv_swizzles[4]; 449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef consts_ptr; 451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *inputs; 452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *outputs; 453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_sampler_aos *sampler; 455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES]; 457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef temps[LP_MAX_TGSI_TEMPS]; 458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef addr[LP_MAX_TGSI_ADDRS]; 459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef preds[LP_MAX_TGSI_PREDS]; 460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is 462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * set in the indirect_files field. 463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The temps[] array above is unused then. 464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef temps_array; 466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** bitmask indicating which register files are accessed indirectly */ 468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned indirect_files; 469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_build_tgsi_soa_context * 473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_soa_context(struct lp_build_tgsi_context *bld_base) 474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (struct lp_build_tgsi_soa_context *)bld_base; 476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE struct lp_build_tgsi_aos_context * 479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_aos_context(struct lp_build_tgsi_context *bld_base) 480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return (struct lp_build_tgsi_aos_context *)bld_base; 482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_emit_declaration_aos( 486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_aos_context *bld, 487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_declaration *decl); 488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_emit_instruction_aos( 492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_aos_context *bld, 493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst, 494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_opcode_info *info, 495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int *pc); 496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_emit_store_aos( 499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_aos_context *bld, 500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst, 501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned index, 502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef value); 503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid lp_build_fetch_args( 505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_emit_data * emit_data); 507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_inst_llvm_aos( 510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst); 512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_intrinsic( 515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_build_tgsi_action * action, 516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_emit_data * emit_data); 518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_emit_llvm( 521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned tgsi_opcode, 523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_emit_data * emit_data); 524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_emit_llvm_unary( 527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned tgsi_opcode, 529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg0); 530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_emit_llvm_binary( 533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned tgsi_opcode, 535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg0, 536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg1); 537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_emit_llvm_ternary( 540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned tgsi_opcode, 542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg0, 543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg1, 544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef arg2); 545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_inst_llvm( 548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst); 550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLLVMValueRef 552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_emit_fetch( 553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context *bld_base, 554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_full_instruction *inst, 555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned src_op, 556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const unsigned chan_index); 557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgboolean 559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_build_tgsi_llvm( 560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_tgsi_context * bld_base, 561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct tgsi_token *tokens); 562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* LP_BLD_TGSI_H */ 564