14a49301eSmrg/**************************************************************************
24a49301eSmrg *
3af69d88dSmrg * Copyright 2007 VMware, Inc.
44a49301eSmrg * All Rights Reserved.
54a49301eSmrg *
64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a
74a49301eSmrg * copy of this software and associated documentation files (the
84a49301eSmrg * "Software"), to deal in the Software without restriction, including
94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish,
104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to
114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to
124a49301eSmrg * the following conditions:
134a49301eSmrg *
144a49301eSmrg * The above copyright notice and this permission notice (including the
154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions
164a49301eSmrg * of the Software.
174a49301eSmrg *
184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
254a49301eSmrg *
264a49301eSmrg **************************************************************************/
274a49301eSmrg
284a49301eSmrg#ifndef TGSI_UTIL_H
294a49301eSmrg#define TGSI_UTIL_H
304a49301eSmrg
317ec681f3Smrg#include <stdbool.h>
3201e04c3fSmrg#include "pipe/p_shader_tokens.h"
3301e04c3fSmrg
344a49301eSmrg#if defined __cplusplus
354a49301eSmrgextern "C" {
364a49301eSmrg#endif
374a49301eSmrg
384a49301eSmrgstruct tgsi_src_register;
394a49301eSmrgstruct tgsi_full_src_register;
403464ebd5Sriastradhstruct tgsi_full_instruction;
414a49301eSmrg
424a49301eSmrgvoid *
4301e04c3fSmrgtgsi_align_128bit(void *unaligned);
444a49301eSmrg
454a49301eSmrgunsigned
4601e04c3fSmrgtgsi_util_get_src_register_swizzle(const struct tgsi_src_register *reg,
4701e04c3fSmrg                                   unsigned component);
484a49301eSmrg
494a49301eSmrg
504a49301eSmrgunsigned
514a49301eSmrgtgsi_util_get_full_src_register_swizzle(
524a49301eSmrg   const struct tgsi_full_src_register *reg,
534a49301eSmrg   unsigned component );
544a49301eSmrg
554a49301eSmrgvoid
5601e04c3fSmrgtgsi_util_set_src_register_swizzle(struct tgsi_src_register *reg,
5701e04c3fSmrg                                   unsigned swizzle,
5801e04c3fSmrg                                   unsigned component);
5901e04c3fSmrg
603464ebd5Sriastradhunsigned
613464ebd5Sriastradhtgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
623464ebd5Sriastradh                              unsigned src_idx);
633464ebd5Sriastradh
64af69d88dSmrgstruct tgsi_src_register
65af69d88dSmrgtgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg);
66af69d88dSmrg
67af69d88dSmrgint
6801e04c3fSmrgtgsi_util_get_texture_coord_dim(enum tgsi_texture_type tgsi_tex);
6901e04c3fSmrg
7001e04c3fSmrgint
7101e04c3fSmrgtgsi_util_get_shadow_ref_src_index(enum tgsi_texture_type tgsi_tex);
7201e04c3fSmrg
737ec681f3Smrgbool
7401e04c3fSmrgtgsi_is_shadow_target(enum tgsi_texture_type target);
7501e04c3fSmrg
7601e04c3fSmrg
777ec681f3Smrgstatic inline bool
7801e04c3fSmrgtgsi_is_msaa_target(enum tgsi_texture_type target)
7901e04c3fSmrg{
8001e04c3fSmrg   return (target == TGSI_TEXTURE_2D_MSAA ||
8101e04c3fSmrg           target == TGSI_TEXTURE_2D_ARRAY_MSAA);
8201e04c3fSmrg}
8301e04c3fSmrg
8401e04c3fSmrgstatic inline bool
8501e04c3fSmrgtgsi_is_array_sampler(enum tgsi_texture_type target)
8601e04c3fSmrg{
8701e04c3fSmrg   return target == TGSI_TEXTURE_1D_ARRAY ||
8801e04c3fSmrg          target == TGSI_TEXTURE_SHADOW1D_ARRAY ||
8901e04c3fSmrg          target == TGSI_TEXTURE_2D_ARRAY ||
9001e04c3fSmrg          target == TGSI_TEXTURE_SHADOW2D_ARRAY ||
9101e04c3fSmrg          target == TGSI_TEXTURE_CUBE_ARRAY ||
9201e04c3fSmrg          target == TGSI_TEXTURE_SHADOWCUBE_ARRAY ||
9301e04c3fSmrg          target == TGSI_TEXTURE_2D_ARRAY_MSAA;
9401e04c3fSmrg}
95af69d88dSmrg
964a49301eSmrg#if defined __cplusplus
974a49301eSmrg}
984a49301eSmrg#endif
994a49301eSmrg
1004a49301eSmrg#endif /* TGSI_UTIL_H */
101