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