Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef sw_Sampler_hpp |
| 16 | #define sw_Sampler_hpp |
| 17 | |
Alexis Hetu | 696926d | 2019-03-18 11:30:01 -0400 | [diff] [blame] | 18 | #include "Device/Color.hpp" |
Nicolas Capens | 1d8c8db | 2018-11-05 16:30:42 -0500 | [diff] [blame] | 19 | #include "Device/Config.hpp" |
Nicolas Capens | 1d8c8db | 2018-11-05 16:30:42 -0500 | [diff] [blame] | 20 | #include "System/Types.hpp" |
Alexis Hetu | 696926d | 2019-03-18 11:30:01 -0400 | [diff] [blame] | 21 | #include "Vulkan/VkFormat.h" |
| 22 | |
| 23 | namespace vk |
| 24 | { |
| 25 | class Image; |
| 26 | } |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 27 | |
| 28 | namespace sw |
| 29 | { |
| 30 | struct Mipmap |
| 31 | { |
Nicolas Capens | bb575d4 | 2019-05-31 15:36:59 -0400 | [diff] [blame] | 32 | const void *buffer; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 33 | |
Nicolas Capens | fcc6441 | 2019-05-16 12:35:21 -0400 | [diff] [blame] | 34 | short4 uHalf; |
| 35 | short4 vHalf; |
| 36 | short4 wHalf; |
Alexis Hetu | 710fcd5 | 2019-05-24 17:20:21 -0400 | [diff] [blame] | 37 | int4 width; |
| 38 | int4 height; |
| 39 | int4 depth; |
Nicolas Capens | fcc6441 | 2019-05-16 12:35:21 -0400 | [diff] [blame] | 40 | short4 onePitchP; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 41 | int4 pitchP; |
| 42 | int4 sliceP; |
| 43 | }; |
| 44 | |
| 45 | struct Texture |
| 46 | { |
| 47 | Mipmap mipmap[MIPMAP_LEVELS]; |
| 48 | |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 49 | float4 widthWidthHeightHeight; |
| 50 | float4 width; |
| 51 | float4 height; |
| 52 | float4 depth; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | enum SamplerType |
| 56 | { |
| 57 | SAMPLER_PIXEL, |
| 58 | SAMPLER_VERTEX |
| 59 | }; |
| 60 | |
| 61 | enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 62 | { |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 63 | TEXTURE_NULL, // TODO(b/129523279): Eliminate |
| 64 | TEXTURE_1D, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 65 | TEXTURE_2D, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 66 | TEXTURE_3D, |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 67 | TEXTURE_CUBE, |
Nicolas Capens | 8ac0bd6 | 2019-06-06 13:03:56 -0400 | [diff] [blame] | 68 | TEXTURE_1D_ARRAY, // Treated as 2D texture with second coordinate 0. TODO(b/134669567) |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 69 | TEXTURE_2D_ARRAY, |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 70 | TEXTURE_CUBE_ARRAY, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 71 | |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 72 | TEXTURE_LAST = TEXTURE_CUBE_ARRAY |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 76 | { |
| 77 | FILTER_POINT, |
| 78 | FILTER_GATHER, |
| 79 | FILTER_MIN_POINT_MAG_LINEAR, |
| 80 | FILTER_MIN_LINEAR_MAG_POINT, |
| 81 | FILTER_LINEAR, |
| 82 | FILTER_ANISOTROPIC, |
| 83 | |
| 84 | FILTER_LAST = FILTER_ANISOTROPIC |
| 85 | }; |
| 86 | |
| 87 | enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 88 | { |
| 89 | MIPMAP_NONE, |
| 90 | MIPMAP_POINT, |
| 91 | MIPMAP_LINEAR, |
| 92 | |
| 93 | MIPMAP_LAST = MIPMAP_LINEAR |
| 94 | }; |
| 95 | |
| 96 | enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 97 | { |
Nicolas Capens | 8da5253 | 2019-05-07 14:22:31 -0400 | [diff] [blame] | 98 | ADDRESSING_UNUSED, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 99 | ADDRESSING_WRAP, |
| 100 | ADDRESSING_CLAMP, |
| 101 | ADDRESSING_MIRROR, |
| 102 | ADDRESSING_MIRRORONCE, |
| 103 | ADDRESSING_BORDER, // Single color |
| 104 | ADDRESSING_SEAMLESS, // Border of pixels |
Nicolas Capens | bb575d4 | 2019-05-31 15:36:59 -0400 | [diff] [blame] | 105 | ADDRESSING_CUBEFACE, // Cube face layer |
| 106 | ADDRESSING_LAYER, // Array layer |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 107 | ADDRESSING_TEXELFETCH, |
| 108 | |
| 109 | ADDRESSING_LAST = ADDRESSING_TEXELFETCH |
| 110 | }; |
| 111 | |
| 112 | enum CompareFunc ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 113 | { |
| 114 | COMPARE_BYPASS, |
| 115 | COMPARE_LESSEQUAL, |
| 116 | COMPARE_GREATEREQUAL, |
| 117 | COMPARE_LESS, |
| 118 | COMPARE_GREATER, |
| 119 | COMPARE_EQUAL, |
| 120 | COMPARE_NOTEQUAL, |
| 121 | COMPARE_ALWAYS, |
| 122 | COMPARE_NEVER, |
| 123 | |
| 124 | COMPARE_LAST = COMPARE_NEVER |
| 125 | }; |
| 126 | |
| 127 | enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 128 | { |
| 129 | SWIZZLE_RED, |
| 130 | SWIZZLE_GREEN, |
| 131 | SWIZZLE_BLUE, |
| 132 | SWIZZLE_ALPHA, |
| 133 | SWIZZLE_ZERO, |
| 134 | SWIZZLE_ONE, |
| 135 | |
| 136 | SWIZZLE_LAST = SWIZZLE_ONE |
| 137 | }; |
| 138 | |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 139 | struct Sampler |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 140 | { |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 141 | TextureType textureType; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 142 | vk::Format textureFormat; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 143 | FilterType textureFilter; |
| 144 | AddressingMode addressingModeU; |
| 145 | AddressingMode addressingModeV; |
| 146 | AddressingMode addressingModeW; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 147 | MipmapType mipmapFilter; |
Chris Forbes | 3c203531 | 2019-04-25 08:30:58 -0700 | [diff] [blame] | 148 | VkComponentMapping swizzle; |
Nicolas Capens | 5725315 | 2019-05-10 20:25:17 -0700 | [diff] [blame] | 149 | int gatherComponent; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 150 | bool highPrecisionFiltering; |
Chris Forbes | c71c17f | 2019-05-04 10:01:04 -0700 | [diff] [blame] | 151 | bool compareEnable; |
| 152 | VkCompareOp compareOp; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 153 | VkBorderColor border; |
Alexis Hetu | 036cc9a | 2019-05-16 17:24:22 -0400 | [diff] [blame] | 154 | bool unnormalizedCoordinates; |
Alexis Hetu | 710fcd5 | 2019-05-24 17:20:21 -0400 | [diff] [blame] | 155 | bool largeTexture; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 156 | |
Nicolas Capens | 51e9e56 | 2019-05-16 14:01:16 -0400 | [diff] [blame] | 157 | VkSamplerYcbcrModelConversion ycbcrModel; |
| 158 | bool studioSwing; // Narrow range |
| 159 | bool swappedChroma; // Cb/Cr components in reverse order |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 160 | }; |
| 161 | } |
| 162 | |
| 163 | #endif // sw_Sampler_hpp |