mirror of OpenBSD xenocara tree github.com/openbsd/xenocara
openbsd
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at jcs 136 lines 5.4 kB view raw
1/* 2 * Copyright © 2017 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#ifndef NIR_FORMAT_CONVERT_H 25#define NIR_FORMAT_CONVERT_H 26 27#include "nir_builder.h" 28#include "util/format/u_formats.h" 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34static inline nir_def * 35nir_shift_imm(nir_builder *b, nir_def *value, int left_shift) 36{ 37 if (left_shift > 0) 38 return nir_ishl_imm(b, value, left_shift); 39 else if (left_shift < 0) 40 return nir_ushr_imm(b, value, -left_shift); 41 else 42 return value; 43} 44 45static inline nir_def * 46nir_shift(nir_builder *b, nir_def *value, nir_def *left_shift) 47{ 48 return nir_bcsel(b, 49 nir_ige_imm(b, left_shift, 0), 50 nir_ishl(b, value, left_shift), 51 nir_ushr(b, value, nir_ineg(b, left_shift))); 52} 53 54static inline nir_def * 55nir_mask_shift(struct nir_builder *b, nir_def *src, 56 uint32_t mask, int left_shift) 57{ 58 return nir_shift_imm(b, nir_iand_imm(b, src, mask), left_shift); 59} 60 61static inline nir_def * 62nir_mask_shift_or(struct nir_builder *b, nir_def *dst, nir_def *src, 63 uint32_t src_mask, int src_left_shift) 64{ 65 return nir_ior(b, nir_mask_shift(b, src, src_mask, src_left_shift), dst); 66} 67 68nir_def *nir_format_mask_uvec(nir_builder *b, nir_def *src, 69 const unsigned *bits); 70nir_def *nir_format_sign_extend_ivec(nir_builder *b, nir_def *src, 71 const unsigned *bits); 72nir_def *nir_format_unpack_int(nir_builder *b, nir_def *packed, 73 const unsigned *bits, 74 unsigned num_components, 75 bool sign_extend); 76 77static inline nir_def * 78nir_format_unpack_uint(nir_builder *b, nir_def *packed, 79 const unsigned *bits, unsigned num_components) 80{ 81 return nir_format_unpack_int(b, packed, bits, num_components, false); 82} 83 84static inline nir_def * 85nir_format_unpack_sint(nir_builder *b, nir_def *packed, 86 const unsigned *bits, unsigned num_components) 87{ 88 return nir_format_unpack_int(b, packed, bits, num_components, true); 89} 90 91nir_def *nir_format_pack_uint_unmasked(nir_builder *b, nir_def *color, 92 const unsigned *bits, 93 unsigned num_components); 94nir_def *nir_format_pack_uint_unmasked_ssa(nir_builder *b, nir_def *color, 95 nir_def *bits); 96nir_def *nir_format_pack_uint(nir_builder *b, nir_def *color, 97 const unsigned *bits, 98 unsigned num_components); 99 100nir_def *nir_format_bitcast_uvec_unmasked(nir_builder *b, nir_def *src, 101 unsigned src_bits, 102 unsigned dst_bits); 103 104nir_def *nir_format_unorm_to_float(nir_builder *b, nir_def *u, 105 const unsigned *bits); 106nir_def *nir_format_snorm_to_float(nir_builder *b, nir_def *s, 107 const unsigned *bits); 108nir_def *nir_format_float_to_unorm(nir_builder *b, nir_def *f, 109 const unsigned *bits); 110nir_def *nir_format_float_to_snorm(nir_builder *b, nir_def *f, 111 const unsigned *bits); 112 113nir_def *nir_format_float_to_half(nir_builder *b, nir_def *f); 114nir_def *nir_format_linear_to_srgb(nir_builder *b, nir_def *c); 115nir_def *nir_format_srgb_to_linear(nir_builder *b, nir_def *c); 116 117nir_def *nir_format_clamp_uint(nir_builder *b, nir_def *f, 118 const unsigned *bits); 119nir_def *nir_format_clamp_sint(nir_builder *b, nir_def *f, 120 const unsigned *bits); 121 122nir_def *nir_format_unpack_11f11f10f(nir_builder *b, nir_def *packed); 123nir_def *nir_format_pack_11f11f10f(nir_builder *b, nir_def *color); 124nir_def *nir_format_unpack_r9g9b9e5(nir_builder *b, nir_def *packed); 125nir_def *nir_format_pack_r9g9b9e5(nir_builder *b, nir_def *color); 126 127nir_def *nir_format_unpack_rgba(nir_builder *b, nir_def *packed, 128 enum pipe_format format); 129nir_def *nir_format_pack_rgba(nir_builder *b, enum pipe_format format, 130 nir_def *rgba); 131 132#ifdef __cplusplus 133} /* extern "C" */ 134#endif 135 136#endif /* NIR_FORMAT_CONVERT_H */