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 | { |
| 32 | const void *buffer[6]; |
| 33 | |
| 34 | float4 fWidth; |
| 35 | float4 fHeight; |
| 36 | float4 fDepth; |
| 37 | |
| 38 | short uHalf[4]; |
| 39 | short vHalf[4]; |
| 40 | short wHalf[4]; |
| 41 | short width[4]; |
| 42 | short height[4]; |
| 43 | short depth[4]; |
| 44 | short onePitchP[4]; |
| 45 | int4 pitchP; |
| 46 | int4 sliceP; |
| 47 | }; |
| 48 | |
| 49 | struct Texture |
| 50 | { |
| 51 | Mipmap mipmap[MIPMAP_LEVELS]; |
| 52 | |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 53 | float4 widthWidthHeightHeight; |
| 54 | float4 width; |
| 55 | float4 height; |
| 56 | float4 depth; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | enum SamplerType |
| 60 | { |
| 61 | SAMPLER_PIXEL, |
| 62 | SAMPLER_VERTEX |
| 63 | }; |
| 64 | |
| 65 | enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 66 | { |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 67 | TEXTURE_NULL, // TODO(b/129523279): Eliminate |
| 68 | TEXTURE_1D, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 69 | TEXTURE_2D, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 70 | TEXTURE_3D, |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 71 | TEXTURE_CUBE, |
Nicolas Capens | e2535df | 2019-05-06 10:37:50 -0400 | [diff] [blame] | 72 | TEXTURE_1D_ARRAY, // Treated as 2D texture with second coordinate 0. |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 73 | TEXTURE_2D_ARRAY, |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 74 | TEXTURE_CUBE_ARRAY, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 75 | |
Nicolas Capens | a47a516 | 2019-04-24 02:41:27 -0400 | [diff] [blame] | 76 | TEXTURE_LAST = TEXTURE_CUBE_ARRAY |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 80 | { |
| 81 | FILTER_POINT, |
| 82 | FILTER_GATHER, |
| 83 | FILTER_MIN_POINT_MAG_LINEAR, |
| 84 | FILTER_MIN_LINEAR_MAG_POINT, |
| 85 | FILTER_LINEAR, |
| 86 | FILTER_ANISOTROPIC, |
| 87 | |
| 88 | FILTER_LAST = FILTER_ANISOTROPIC |
| 89 | }; |
| 90 | |
| 91 | enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 92 | { |
| 93 | MIPMAP_NONE, |
| 94 | MIPMAP_POINT, |
| 95 | MIPMAP_LINEAR, |
| 96 | |
| 97 | MIPMAP_LAST = MIPMAP_LINEAR |
| 98 | }; |
| 99 | |
| 100 | enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 101 | { |
Nicolas Capens | 8da5253 | 2019-05-07 14:22:31 -0400 | [diff] [blame] | 102 | ADDRESSING_UNUSED, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 103 | ADDRESSING_WRAP, |
| 104 | ADDRESSING_CLAMP, |
| 105 | ADDRESSING_MIRROR, |
| 106 | ADDRESSING_MIRRORONCE, |
| 107 | ADDRESSING_BORDER, // Single color |
| 108 | ADDRESSING_SEAMLESS, // Border of pixels |
| 109 | ADDRESSING_LAYER, |
| 110 | ADDRESSING_TEXELFETCH, |
| 111 | |
| 112 | ADDRESSING_LAST = ADDRESSING_TEXELFETCH |
| 113 | }; |
| 114 | |
| 115 | enum CompareFunc ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 116 | { |
| 117 | COMPARE_BYPASS, |
| 118 | COMPARE_LESSEQUAL, |
| 119 | COMPARE_GREATEREQUAL, |
| 120 | COMPARE_LESS, |
| 121 | COMPARE_GREATER, |
| 122 | COMPARE_EQUAL, |
| 123 | COMPARE_NOTEQUAL, |
| 124 | COMPARE_ALWAYS, |
| 125 | COMPARE_NEVER, |
| 126 | |
| 127 | COMPARE_LAST = COMPARE_NEVER |
| 128 | }; |
| 129 | |
| 130 | enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 131 | { |
| 132 | SWIZZLE_RED, |
| 133 | SWIZZLE_GREEN, |
| 134 | SWIZZLE_BLUE, |
| 135 | SWIZZLE_ALPHA, |
| 136 | SWIZZLE_ZERO, |
| 137 | SWIZZLE_ONE, |
| 138 | |
| 139 | SWIZZLE_LAST = SWIZZLE_ONE |
| 140 | }; |
| 141 | |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 142 | struct Sampler |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 143 | { |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 144 | TextureType textureType; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 145 | vk::Format textureFormat; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 146 | FilterType textureFilter; |
| 147 | AddressingMode addressingModeU; |
| 148 | AddressingMode addressingModeV; |
| 149 | AddressingMode addressingModeW; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 150 | MipmapType mipmapFilter; |
Chris Forbes | 3c203531 | 2019-04-25 08:30:58 -0700 | [diff] [blame] | 151 | VkComponentMapping swizzle; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 152 | bool highPrecisionFiltering; |
Chris Forbes | c71c17f | 2019-05-04 10:01:04 -0700 | [diff] [blame] | 153 | bool compareEnable; |
| 154 | VkCompareOp compareOp; |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 155 | VkBorderColor border; |
Alexis Hetu | 036cc9a | 2019-05-16 17:24:22 -0400 | [diff] [blame^] | 156 | bool unnormalizedCoordinates; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 157 | |
Nicolas Capens | 1e7120e | 2019-04-30 17:33:26 -0400 | [diff] [blame] | 158 | #if PERF_PROFILE |
| 159 | bool compressedFormat; |
| 160 | #endif |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 161 | }; |
| 162 | } |
| 163 | |
| 164 | #endif // sw_Sampler_hpp |