Path: blob/21.2-virgl/src/gallium/auxiliary/gallivm/lp_bld_format.h
4565 views
/**************************************************************************1*2* Copyright 2009 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef LP_BLD_FORMAT_H28#define LP_BLD_FORMAT_H293031/**32* @file33* Pixel format helpers.34*/3536#include "gallivm/lp_bld.h"37#include "gallivm/lp_bld_init.h"3839#include "pipe/p_format.h"4041struct util_format_description;42struct lp_type;43struct lp_build_context;444546#define LP_BUILD_FORMAT_CACHE_DEBUG 047/*48* Block cache49*50* Optional block cache to be used when unpacking big pixel blocks.51* Must be a power of 252*/5354#define LP_BUILD_FORMAT_CACHE_SIZE 1285556/*57* Note: cache_data needs 16 byte alignment.58*/59struct lp_build_format_cache60{61PIPE_ALIGN_VAR(16) uint32_t cache_data[LP_BUILD_FORMAT_CACHE_SIZE][4][4];62uint64_t cache_tags[LP_BUILD_FORMAT_CACHE_SIZE];63#if LP_BUILD_FORMAT_CACHE_DEBUG64uint64_t cache_access_total;65uint64_t cache_access_miss;66#endif67};686970enum {71LP_BUILD_FORMAT_CACHE_MEMBER_DATA = 0,72LP_BUILD_FORMAT_CACHE_MEMBER_TAGS,73#if LP_BUILD_FORMAT_CACHE_DEBUG74LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_TOTAL,75LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_MISS,76#endif77LP_BUILD_FORMAT_CACHE_MEMBER_COUNT78};798081LLVMTypeRef82lp_build_format_cache_type(struct gallivm_state *gallivm);838485/*86* AoS87*/8889LLVMValueRef90lp_build_format_swizzle_aos(const struct util_format_description *desc,91struct lp_build_context *bld,92LLVMValueRef unswizzled);9394LLVMValueRef95lp_build_pack_rgba_aos(struct gallivm_state *gallivm,96const struct util_format_description *desc,97LLVMValueRef rgba);9899LLVMValueRef100lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,101const struct util_format_description *format_desc,102struct lp_type type,103boolean aligned,104LLVMValueRef base_ptr,105LLVMValueRef offset,106LLVMValueRef i,107LLVMValueRef j,108LLVMValueRef cache);109110LLVMValueRef111lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,112const struct util_format_description *format_desc,113struct lp_type type,114LLVMValueRef base_ptr,115LLVMValueRef offset);116117118/*119* SoA120*/121122void123lp_build_format_swizzle_soa(const struct util_format_description *format_desc,124struct lp_build_context *bld,125const LLVMValueRef unswizzled[4],126LLVMValueRef swizzled_out[4]);127128void129lp_build_unpack_rgba_soa(struct gallivm_state *gallivm,130const struct util_format_description *format_desc,131struct lp_type type,132LLVMValueRef packed,133LLVMValueRef rgba_out[4]);134135void136lp_build_rgba8_to_fi32_soa(struct gallivm_state *gallivm,137struct lp_type dst_type,138LLVMValueRef packed,139LLVMValueRef *rgba);140141void142lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,143const struct util_format_description *format_desc,144struct lp_type type,145boolean aligned,146LLVMValueRef base_ptr,147LLVMValueRef offsets,148LLVMValueRef i,149LLVMValueRef j,150LLVMValueRef cache,151LLVMValueRef rgba_out[4]);152153void154lp_build_store_rgba_soa(struct gallivm_state *gallivm,155const struct util_format_description *format_desc,156struct lp_type type,157LLVMValueRef exec_mask,158LLVMValueRef base_ptr,159LLVMValueRef offset,160LLVMValueRef out_of_bounds,161const LLVMValueRef rgba_in[4]);162163/*164* YUV165*/166167LLVMValueRef168lp_build_fetch_subsampled_rgba_aos(struct gallivm_state *gallivm,169const struct util_format_description *format_desc,170unsigned n,171LLVMValueRef base_ptr,172LLVMValueRef offset,173LLVMValueRef i,174LLVMValueRef j);175176177/*178* S3TC179*/180181LLVMValueRef182lp_build_fetch_s3tc_rgba_aos(struct gallivm_state *gallivm,183const struct util_format_description *format_desc,184unsigned n,185LLVMValueRef base_ptr,186LLVMValueRef offset,187LLVMValueRef i,188LLVMValueRef j,189LLVMValueRef cache);190191/*192* RGTC193*/194195LLVMValueRef196lp_build_fetch_rgtc_rgba_aos(struct gallivm_state *gallivm,197const struct util_format_description *format_desc,198unsigned n,199LLVMValueRef base_ptr,200LLVMValueRef offset,201LLVMValueRef i,202LLVMValueRef j,203LLVMValueRef cache);204205/*206* special float formats207*/208209LLVMValueRef210lp_build_float_to_smallfloat(struct gallivm_state *gallivm,211struct lp_type i32_type,212LLVMValueRef src,213unsigned mantissa_bits,214unsigned exponent_bits,215unsigned mantissa_start,216boolean has_sign);217218LLVMValueRef219lp_build_smallfloat_to_float(struct gallivm_state *gallivm,220struct lp_type f32_type,221LLVMValueRef src,222unsigned mantissa_bits,223unsigned exponent_bits,224unsigned mantissa_start,225boolean has_sign);226227LLVMValueRef228lp_build_float_to_r11g11b10(struct gallivm_state *gallivm,229const LLVMValueRef *src);230231void232lp_build_r11g11b10_to_float(struct gallivm_state *gallivm,233LLVMValueRef src,234LLVMValueRef *dst);235236void237lp_build_rgb9e5_to_float(struct gallivm_state *gallivm,238LLVMValueRef src,239LLVMValueRef *dst);240241LLVMValueRef242lp_build_float_to_srgb_packed(struct gallivm_state *gallivm,243const struct util_format_description *dst_fmt,244struct lp_type src_type,245LLVMValueRef *src);246247LLVMValueRef248lp_build_srgb_to_linear(struct gallivm_state *gallivm,249struct lp_type src_type,250unsigned chan_bits,251LLVMValueRef src);252253254#endif /* !LP_BLD_FORMAT_H */255256257