1/**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28#ifndef TGSI_UTIL_H
29#define TGSI_UTIL_H
30
31#if defined __cplusplus
32extern "C" {
33#endif
34
35#include "pipe/p_shader_tokens.h"
36
37struct tgsi_src_register;
38struct tgsi_full_src_register;
39struct tgsi_full_instruction;
40
41void *
42tgsi_align_128bit(
43   void *unaligned );
44
45unsigned
46tgsi_util_get_src_register_swizzle(
47   const struct tgsi_src_register *reg,
48   unsigned component );
49
50
51unsigned
52tgsi_util_get_full_src_register_swizzle(
53   const struct tgsi_full_src_register *reg,
54   unsigned component );
55
56void
57tgsi_util_set_src_register_swizzle(
58   struct tgsi_src_register *reg,
59   unsigned swizzle,
60   unsigned component );
61
62#define TGSI_UTIL_SIGN_CLEAR    0   /* Force positive */
63#define TGSI_UTIL_SIGN_SET      1   /* Force negative */
64#define TGSI_UTIL_SIGN_TOGGLE   2   /* Negate */
65#define TGSI_UTIL_SIGN_KEEP     3   /* No change */
66
67unsigned
68tgsi_util_get_full_src_register_sign_mode(
69   const struct tgsi_full_src_register *reg,
70   unsigned component );
71
72void
73tgsi_util_set_full_src_register_sign_mode(
74   struct tgsi_full_src_register *reg,
75   unsigned sign_mode );
76
77unsigned
78tgsi_util_get_inst_usage_mask(const struct tgsi_full_instruction *inst,
79                              unsigned src_idx);
80
81struct tgsi_src_register
82tgsi_util_get_src_from_ind(const struct tgsi_ind_register *reg);
83
84int
85tgsi_util_get_texture_coord_dim(unsigned tgsi_tex);
86
87int
88tgsi_util_get_shadow_ref_src_index(unsigned tgsi_tex);
89
90boolean
91tgsi_is_shadow_target(unsigned target);
92
93
94static inline boolean
95tgsi_is_msaa_target(unsigned target)
96{
97   return (target == TGSI_TEXTURE_2D_MSAA ||
98           target == TGSI_TEXTURE_2D_ARRAY_MSAA);
99}
100
101#if defined __cplusplus
102}
103#endif
104
105#endif /* TGSI_UTIL_H */
106