José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 1 | /********************************************************** |
| 2 | * Copyright 2011 VMware, Inc. All rights reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person |
| 5 | * obtaining a copy of this software and associated documentation |
| 6 | * files (the "Software"), to deal in the Software without |
| 7 | * restriction, including without limitation the rights to use, copy, |
| 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies |
| 9 | * of the Software, and to permit persons to whom the Software is |
| 10 | * furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be |
| 13 | * included in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | * |
| 24 | **********************************************************/ |
| 25 | |
| 26 | #ifndef SVGA_FORMAT_H_ |
| 27 | #define SVGA_FORMAT_H_ |
| 28 | |
| 29 | |
Brian Paul | 32f669e | 2011-12-07 17:05:48 -0700 | [diff] [blame] | 30 | #include "pipe/p_format.h" |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 31 | #include "svga_context.h" |
José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 32 | #include "svga_types.h" |
| 33 | #include "svga_reg.h" |
| 34 | #include "svga3d_reg.h" |
| 35 | |
| 36 | |
| 37 | struct svga_screen; |
| 38 | |
| 39 | |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Vertex format flags. These are used to specify that some vertex formats |
| 42 | * need extra processing/conversion in the vertex shader. For example, |
| 43 | * setting the W component to 1, or swapping R/B, or converting packed uint |
| 44 | * types to signed int/snorm. |
| 45 | */ |
| 46 | #define VF_ADJUST_RANGE (1 << 0) |
| 47 | #define VF_W_TO_1 (1 << 1) |
| 48 | #define VF_U_TO_F_CAST (1 << 2) /* convert uint to float */ |
| 49 | #define VF_I_TO_F_CAST (1 << 3) /* convert sint to float */ |
| 50 | #define VF_BGRA (1 << 4) /* swap R/B */ |
| 51 | #define VF_PUINT_TO_SNORM (1 << 5) /* 10_10_10_2 to snorm */ |
| 52 | #define VF_PUINT_TO_USCALED (1 << 6) /* 10_10_10_2 to uscaled */ |
| 53 | #define VF_PUINT_TO_SSCALED (1 << 7) /* 10_10_10_2 to sscaled */ |
| 54 | |
Charmaine Lee | 6303231 | 2015-12-22 11:20:41 -0800 | [diff] [blame] | 55 | /** |
| 56 | * Texture format flags. |
| 57 | */ |
| 58 | #define TF_GEN_MIPS (1 << 8) /* supports hw generate mipmap */ |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 59 | |
| 60 | void |
| 61 | svga_translate_vertex_format_vgpu10(enum pipe_format format, |
| 62 | SVGA3dSurfaceFormat *svga_format, |
| 63 | unsigned *vf_flags); |
| 64 | |
José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 65 | enum SVGA3dSurfaceFormat |
Brian Paul | 2ad4ba0 | 2016-09-20 17:01:20 -0600 | [diff] [blame] | 66 | svga_translate_format(const struct svga_screen *ss, |
José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 67 | enum pipe_format format, |
| 68 | unsigned bind); |
| 69 | |
| 70 | void |
| 71 | svga_get_format_cap(struct svga_screen *ss, |
| 72 | SVGA3dSurfaceFormat format, |
| 73 | SVGA3dSurfaceFormatCaps *caps); |
| 74 | |
Brian Paul | 32f669e | 2011-12-07 17:05:48 -0700 | [diff] [blame] | 75 | void |
| 76 | svga_format_size(SVGA3dSurfaceFormat format, |
| 77 | unsigned *block_width, |
| 78 | unsigned *block_height, |
| 79 | unsigned *bytes_per_block); |
| 80 | |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 81 | const char * |
| 82 | svga_format_name(SVGA3dSurfaceFormat format); |
| 83 | |
| 84 | boolean |
| 85 | svga_format_is_integer(SVGA3dSurfaceFormat format); |
| 86 | |
Charmaine Lee | 6303231 | 2015-12-22 11:20:41 -0800 | [diff] [blame] | 87 | boolean |
| 88 | svga_format_support_gen_mips(enum pipe_format format); |
| 89 | |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 90 | enum tgsi_return_type |
| 91 | svga_get_texture_datatype(enum pipe_format format); |
| 92 | |
| 93 | |
| 94 | // XXX: Move this to svga_context? |
| 95 | boolean |
| 96 | svga_has_any_integer_cbufs(const struct svga_context *svga); |
| 97 | |
| 98 | |
| 99 | SVGA3dSurfaceFormat |
| 100 | svga_typeless_format(SVGA3dSurfaceFormat format); |
| 101 | |
José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 102 | |
Brian Paul | 1a90e3e | 2015-11-16 10:31:46 -0700 | [diff] [blame] | 103 | SVGA3dSurfaceFormat |
| 104 | svga_sampler_format(SVGA3dSurfaceFormat format); |
| 105 | |
| 106 | |
Brian Paul | 46e7355 | 2016-06-27 11:17:45 -0600 | [diff] [blame] | 107 | bool |
| 108 | svga_format_is_uncompressed_snorm(SVGA3dSurfaceFormat format); |
| 109 | |
| 110 | |
Charmaine Lee | 0d221fc | 2016-10-24 10:50:29 -0700 | [diff] [blame] | 111 | bool |
| 112 | svga_format_is_typeless(SVGA3dSurfaceFormat format); |
| 113 | |
Thomas Hellstrom | ca59fd1 | 2017-04-07 14:54:56 +0200 | [diff] [blame] | 114 | bool |
| 115 | svga_format_is_shareable(const struct svga_screen *ss, |
| 116 | enum pipe_format pformat, |
| 117 | SVGA3dSurfaceFormat sformat, |
| 118 | unsigned bind, |
| 119 | bool verbose); |
Neha Bhende | 1b415a5 | 2017-04-27 10:37:02 -0700 | [diff] [blame] | 120 | |
| 121 | SVGA3dSurfaceFormat |
| 122 | svga_linear_to_srgb(SVGA3dSurfaceFormat format); |
José Fonseca | 974b641 | 2011-04-27 12:02:08 +0100 | [diff] [blame] | 123 | #endif /* SVGA_FORMAT_H_ */ |