1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/************************************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2009 VMware, Inc. 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All rights reserved. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish, 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions: 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/ 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Texture sampling code generation 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This file is nothing more than ugly glue between three largely independent 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * entities: 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - TGSI -> LLVM translation (i.e., lp_build_tgsi_soa) 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - texture sampling code generation (i.e., lp_build_sample_soa) 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * - LLVM pipe driver 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All interesting code is in the functions mentioned above. There is really 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * nothing to see here. 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @author Jose Fonseca <jfonseca@vmware.com> 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_defines.h" 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_shader_tokens.h" 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_debug.h" 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_const.h" 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_type.h" 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_sample.h" 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "gallivm/lp_bld_tgsi.h" 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "lp_jit.h" 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "lp_tex_sample.h" 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "lp_debug.h" 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This provides the bridge between the sampler state store in 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * lp_jit_context and lp_jit_texture and the sampler code 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * generator. It provides the texture layout information required by 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the texture sampler code generator in terms of the state stored in 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * lp_jit_context and lp_jit_texture in runtime. 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct llvmpipe_sampler_dynamic_state 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_sampler_dynamic_state base; 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_sampler_static_state *static_state; 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef context_ptr; 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This is the bridge between our sampler and the TGSI translator. 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_llvm_sampler_soa 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_build_sampler_soa base; 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct llvmpipe_sampler_dynamic_state dynamic_state; 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fetch the specified member of the lp_jit_texture structure. 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \param emit_load if TRUE, emit the LLVM load instruction to actually 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * fetch the field's value. Otherwise, just emit the 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GEP code to address the field. 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * @sa http://llvm.org/docs/GetElementPtr.html 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic LLVMValueRef 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned member_index, 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const char *member_name, 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org boolean emit_load) 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct llvmpipe_sampler_dynamic_state *state = 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (struct llvmpipe_sampler_dynamic_state *)base; 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMBuilderRef builder = gallivm->builder; 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef indices[4]; 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef ptr; 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef res; 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(unit < PIPE_MAX_SAMPLERS); 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* context[0] */ 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org indices[0] = lp_build_const_int32(gallivm, 0); 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* context[0].textures */ 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_TEXTURES); 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* context[0].textures[unit] */ 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org indices[2] = lp_build_const_int32(gallivm, unit); 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* context[0].textures[unit].member */ 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org indices[3] = lp_build_const_int32(gallivm, member_index); 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (emit_load) 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res = LLVMBuildLoad(builder, ptr, ""); 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org res = ptr; 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_build_name(res, "context.texture%u.%s", unit, member_name); 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return res; 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Helper macro to instantiate the functions that generate the code to 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * fetch the members of lp_jit_texture to fulfill the sampler code 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * generator requests. 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This complexity is the price we have to pay to keep the texture 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * sampler code generator a reusable module without dependencies to 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * llvmpipe internals. 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \ 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static LLVMValueRef \ 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \ 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, \ 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit) \ 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { \ 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return lp_llvm_texture_member(base, gallivm, unit, _index, #_name, _emit_load ); \ 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH, TRUE) 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT, TRUE) 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH, TRUE) 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(first_level, LP_JIT_TEXTURE_FIRST_LEVEL, TRUE) 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL, TRUE) 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(row_stride, LP_JIT_TEXTURE_ROW_STRIDE, FALSE) 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(img_stride, LP_JIT_TEXTURE_IMG_STRIDE, FALSE) 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA, FALSE) 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(min_lod, LP_JIT_TEXTURE_MIN_LOD, TRUE) 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(max_lod, LP_JIT_TEXTURE_MAX_LOD, TRUE) 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(lod_bias, LP_JIT_TEXTURE_LOD_BIAS, TRUE) 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgLP_LLVM_TEXTURE_MEMBER(border_color, LP_JIT_TEXTURE_BORDER_COLOR, FALSE) 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FREE(sampler); 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fetch filtered values from texture. 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The 'texel' parameter returns four vectors corresponding to R, G, B, A. 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned num_coords, 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const LLVMValueRef *coords, 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct lp_derivatives *derivs, 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef lod_bias, /* optional */ 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef explicit_lod, /* optional */ 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *texel) 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(unit < PIPE_MAX_SAMPLERS); 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (LP_PERF & PERF_NO_TEX) { 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_build_sample_nop(gallivm, type, num_coords, coords, texel); 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_build_sample_soa(gallivm, 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &sampler->dynamic_state.static_state[unit], 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &sampler->dynamic_state.base, 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type, 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unit, 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org num_coords, coords, 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org derivs, 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lod_bias, explicit_lod, 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org texel); 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Fetch the texture size. 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gallivm_state *gallivm, 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_type type, 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned unit, 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef explicit_lod, /* optional */ 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef *sizes_out) 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_llvm_sampler_soa *sampler = (struct lp_llvm_sampler_soa *)base; 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(unit < PIPE_MAX_SAMPLERS); 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org lp_build_size_query_soa(gallivm, 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &sampler->dynamic_state.static_state[unit], 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &sampler->dynamic_state.base, 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org type, 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unit, 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org explicit_lod, 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sizes_out); 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct lp_build_sampler_soa * 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orglp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LLVMValueRef context_ptr) 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct lp_llvm_sampler_soa *sampler; 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler = CALLOC_STRUCT(lp_llvm_sampler_soa); 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if(!sampler) 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->base.destroy = lp_llvm_sampler_soa_destroy; 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->base.emit_fetch_texel = lp_llvm_sampler_soa_emit_fetch_texel; 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->base.emit_size_query = lp_llvm_sampler_soa_emit_size_query; 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.width = lp_llvm_texture_width; 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.height = lp_llvm_texture_height; 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.depth = lp_llvm_texture_depth; 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.first_level = lp_llvm_texture_first_level; 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.last_level = lp_llvm_texture_last_level; 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.row_stride = lp_llvm_texture_row_stride; 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.img_stride = lp_llvm_texture_img_stride; 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.data_ptr = lp_llvm_texture_data_ptr; 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.min_lod = lp_llvm_texture_min_lod; 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.max_lod = lp_llvm_texture_max_lod; 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.lod_bias = lp_llvm_texture_lod_bias; 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.base.border_color = lp_llvm_texture_border_color; 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.static_state = static_state; 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler->dynamic_state.context_ptr = context_ptr; 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return &sampler->base; 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 263