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 | |
Nicolas Capens | 1d8c8db | 2018-11-05 16:30:42 -0500 | [diff] [blame] | 18 | #include "Device/Config.hpp" |
Nicolas Capens | 1d8c8db | 2018-11-05 16:30:42 -0500 | [diff] [blame] | 19 | #include "System/Types.hpp" |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 20 | #include "Vulkan/VkFormat.hpp" |
Alexis Hetu | 696926d | 2019-03-18 11:30:01 -0400 | [diff] [blame] | 21 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 22 | namespace vk { |
| 23 | class Image; |
| 24 | } |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 25 | |
| 26 | namespace sw { |
| 27 | |
| 28 | struct Mipmap |
Alexis Hetu | 696926d | 2019-03-18 11:30:01 -0400 | [diff] [blame] | 29 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 30 | const void *buffer; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 31 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 32 | short4 uHalf; |
| 33 | short4 vHalf; |
| 34 | short4 wHalf; |
| 35 | int4 width; |
| 36 | int4 height; |
| 37 | int4 depth; |
| 38 | short4 onePitchP; |
| 39 | int4 pitchP; |
| 40 | int4 sliceP; |
| 41 | int4 samplePitchP; |
| 42 | int4 sampleMax; |
| 43 | }; |
| 44 | |
| 45 | struct Texture |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 46 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 47 | Mipmap mipmap[MIPMAP_LEVELS]; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 48 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 49 | float4 widthWidthHeightHeight; |
| 50 | float4 width; |
| 51 | float4 height; |
| 52 | float4 depth; |
| 53 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 54 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 55 | enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 56 | { |
| 57 | FILTER_POINT, |
| 58 | FILTER_GATHER, |
| 59 | FILTER_MIN_POINT_MAG_LINEAR, |
| 60 | FILTER_MIN_LINEAR_MAG_POINT, |
| 61 | FILTER_LINEAR, |
| 62 | FILTER_ANISOTROPIC, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 63 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 64 | FILTER_LAST = FILTER_ANISOTROPIC |
| 65 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 66 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 67 | enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 68 | { |
| 69 | MIPMAP_NONE, |
| 70 | MIPMAP_POINT, |
| 71 | MIPMAP_LINEAR, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 72 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 73 | MIPMAP_LAST = MIPMAP_LINEAR |
| 74 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 75 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 76 | enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT |
| 77 | { |
| 78 | ADDRESSING_UNUSED, |
| 79 | ADDRESSING_WRAP, |
| 80 | ADDRESSING_CLAMP, |
| 81 | ADDRESSING_MIRROR, |
| 82 | ADDRESSING_MIRRORONCE, |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 83 | ADDRESSING_BORDER, // Single color |
| 84 | ADDRESSING_SEAMLESS, // Border of pixels |
| 85 | ADDRESSING_CUBEFACE, // Cube face layer |
| 86 | ADDRESSING_LAYER, // Array layer |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 87 | ADDRESSING_TEXELFETCH, |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 88 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 89 | ADDRESSING_LAST = ADDRESSING_TEXELFETCH |
| 90 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 91 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 92 | struct Sampler |
| 93 | { |
| 94 | VkImageViewType textureType; |
| 95 | vk::Format textureFormat; |
| 96 | FilterType textureFilter; |
| 97 | AddressingMode addressingModeU; |
| 98 | AddressingMode addressingModeV; |
| 99 | AddressingMode addressingModeW; |
| 100 | AddressingMode addressingModeY; |
| 101 | MipmapType mipmapFilter; |
| 102 | VkComponentMapping swizzle; |
| 103 | int gatherComponent; |
| 104 | bool highPrecisionFiltering; |
| 105 | bool compareEnable; |
| 106 | VkCompareOp compareOp; |
| 107 | VkBorderColor border; |
| 108 | bool unnormalizedCoordinates; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 109 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 110 | VkSamplerYcbcrModelConversion ycbcrModel; |
| 111 | bool studioSwing; // Narrow range |
| 112 | bool swappedChroma; // Cb/Cr components in reverse order |
Nicolas Capens | 7f46917 | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 113 | |
| 114 | float mipLodBias = 0.0f; |
| 115 | float maxAnisotropy = 0.0f; |
| 116 | float minLod = 0.0f; |
| 117 | float maxLod = 0.0f; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 118 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 119 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 120 | } // namespace sw |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 121 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 122 | #endif // sw_Sampler_hpp |