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 18 #include "Device/Config.hpp" 19 #include "System/Types.hpp" 20 #include "Vulkan/VkFormat.h" 21 22 namespace vk { 23 class Image; 24 } 25 26 namespace sw { 27 28 struct Mipmap 29 { 30 const void *buffer; 31 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 46 { 47 Mipmap mipmap[MIPMAP_LEVELS]; 48 49 float4 widthWidthHeightHeight; 50 float4 width; 51 float4 height; 52 float4 depth; 53 }; 54 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, 63 64 FILTER_LAST = FILTER_ANISOTROPIC 65 }; 66 67 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT 68 { 69 MIPMAP_NONE, 70 MIPMAP_POINT, 71 MIPMAP_LINEAR, 72 73 MIPMAP_LAST = MIPMAP_LINEAR 74 }; 75 76 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT 77 { 78 ADDRESSING_UNUSED, 79 ADDRESSING_WRAP, 80 ADDRESSING_CLAMP, 81 ADDRESSING_MIRROR, 82 ADDRESSING_MIRRORONCE, 83 ADDRESSING_BORDER, // Single color 84 ADDRESSING_SEAMLESS, // Border of pixels 85 ADDRESSING_CUBEFACE, // Cube face layer 86 ADDRESSING_LAYER, // Array layer 87 ADDRESSING_TEXELFETCH, 88 89 ADDRESSING_LAST = ADDRESSING_TEXELFETCH 90 }; 91 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; 109 bool largeTexture; 110 111 VkSamplerYcbcrModelConversion ycbcrModel; 112 bool studioSwing; // Narrow range 113 bool swappedChroma; // Cb/Cr components in reverse order 114 115 float mipLodBias = 0.0f; 116 float maxAnisotropy = 0.0f; 117 float minLod = 0.0f; 118 float maxLod = 0.0f; 119 }; 120 121 } // namespace sw 122 123 #endif // sw_Sampler_hpp 124