1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2007 VMware, Inc. 4848b8605Smrg * All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the 8848b8605Smrg * "Software"), to deal in the Software without restriction, including 9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 12848b8605Smrg * the following conditions: 13848b8605Smrg * 14848b8605Smrg * The above copyright notice and this permission notice (including the 15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 16848b8605Smrg * of the Software. 17848b8605Smrg * 18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25848b8605Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg#ifndef TGSI_UTIL_H 29848b8605Smrg#define TGSI_UTIL_H 30848b8605Smrg 31b8e80941Smrg#include "pipe/p_shader_tokens.h" 32b8e80941Smrg 33848b8605Smrg#if defined __cplusplus 34848b8605Smrgextern "C" { 35848b8605Smrg#endif 36848b8605Smrg 37848b8605Smrgstruct tgsi_src_register; 38848b8605Smrgstruct tgsi_full_src_register; 39848b8605Smrgstruct tgsi_full_instruction; 40848b8605Smrg 41848b8605Smrgvoid * 42b8e80941Smrgtgsi_align_128bit(void *unaligned); 43848b8605Smrg 44848b8605Smrgunsigned 45b8e80941Smrgtgsi_util_get_src_register_swizzle(const struct tgsi_src_register *reg, 46b8e80941Smrg unsigned component); 47848b8605Smrg 48848b8605Smrg 49848b8605Smrgunsigned 50848b8605Smrgtgsi_util_get_full_src_register_swizzle( 51848b8605Smrg const struct tgsi_full_src_register *reg, 52848b8605Smrg unsigned component ); 53848b8605Smrg 54848b8605Smrgvoid 55b8e80941Smrgtgsi_util_set_src_register_swizzle(struct tgsi_src_register *reg, 56b8e80941Smrg unsigned swizzle, 57b8e80941Smrg unsigned component); 58b8e80941Smrg 59848b8605Smrg 60848b8605Smrg#define TGSI_UTIL_SIGN_CLEAR 0 /* Force positive */ 61848b8605Smrg#define TGSI_UTIL_SIGN_SET 1 /* Force negative */ 62848b8605Smrg#define TGSI_UTIL_SIGN_TOGGLE 2 /* Negate */ 63848b8605Smrg#define TGSI_UTIL_SIGN_KEEP 3 /* No change */ 64848b8605Smrg 65848b8605Smrgunsigned 66848b8605Smrgtgsi_util_get_full_src_register_sign_mode( 67848b8605Smrg const struct tgsi_full_src_register *reg, 68b8e80941Smrg unsigned component); 69848b8605Smrg 70848b8605Smrgvoid 71b8e80941Smrgtgsi_util_set_full_src_register_sign_mode(struct tgsi_full_src_register *reg, 72b8e80941Smrg unsigned sign_mode); 73848b8605Smrg 74848b8605Smrgunsigned 75848b8605Smrgtgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst, 76848b8605Smrg unsigned src_idx); 77848b8605Smrg 78848b8605Smrgstruct tgsi_src_register 79848b8605Smrgtgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg); 80848b8605Smrg 81848b8605Smrgint 82b8e80941Smrgtgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex); 83b8e80941Smrg 84b8e80941Smrgint 85b8e80941Smrgtgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex); 86b8e80941Smrg 87b8e80941Smrgboolean 88b8e80941Smrgtgsi_is_shadow_target(enum tgsi_texture_type target); 89b8e80941Smrg 90b8e80941Smrg 91b8e80941Smrgstatic inline boolean 92b8e80941Smrgtgsi_is_msaa_target(enum tgsi_texture_type target) 93b8e80941Smrg{ 94b8e80941Smrg return (target == TGSI_TEXTURE_2D_MSAA || 95b8e80941Smrg target == TGSI_TEXTURE_2D_ARRAY_MSAA); 96b8e80941Smrg} 97b8e80941Smrg 98b8e80941Smrgstatic inline bool 99b8e80941Smrgtgsi_is_array_sampler(enum tgsi_texture_type target) 100b8e80941Smrg{ 101b8e80941Smrg return target == TGSI_TEXTURE_1D_ARRAY || 102b8e80941Smrg target == TGSI_TEXTURE_SHADOW1D_ARRAY || 103b8e80941Smrg target == TGSI_TEXTURE_2D_ARRAY || 104b8e80941Smrg target == TGSI_TEXTURE_SHADOW2D_ARRAY || 105b8e80941Smrg target == TGSI_TEXTURE_CUBE_ARRAY || 106b8e80941Smrg target == TGSI_TEXTURE_SHADOWCUBE_ARRAY || 107b8e80941Smrg target == TGSI_TEXTURE_2D_ARRAY_MSAA; 108b8e80941Smrg} 109848b8605Smrg 110848b8605Smrg#if defined __cplusplus 111848b8605Smrg} 112848b8605Smrg#endif 113848b8605Smrg 114848b8605Smrg#endif /* TGSI_UTIL_H */ 115