1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef sw_Sampler_hpp
16 #define sw_Sampler_hpp
18 #include "Main/Config.hpp"
19 #include "Renderer/Surface.hpp"
20 #include "Common/Types.hpp"
26 const void *buffer[6];
45 Mipmap mipmap[MIPMAP_LEVELS];
48 float4 widthHeightLOD;
53 word4 borderColor4[4];
54 float4 borderColorF[4];
68 enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
76 TEXTURE_LAST = TEXTURE_2D_ARRAY
79 enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
83 FILTER_MIN_POINT_MAG_LINEAR,
84 FILTER_MIN_LINEAR_MAG_POINT,
88 FILTER_LAST = FILTER_ANISOTROPIC
91 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
97 MIPMAP_LAST = MIPMAP_LINEAR
100 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
105 ADDRESSING_MIRRORONCE,
108 ADDRESSING_TEXELFETCH,
110 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
113 enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
122 SWIZZLE_LAST = SWIZZLE_ONE
132 TextureType textureType : BITS(TEXTURE_LAST);
133 Format textureFormat : BITS(FORMAT_LAST);
134 FilterType textureFilter : BITS(FILTER_LAST);
135 AddressingMode addressingModeU : BITS(ADDRESSING_LAST);
136 AddressingMode addressingModeV : BITS(ADDRESSING_LAST);
137 AddressingMode addressingModeW : BITS(ADDRESSING_LAST);
138 MipmapType mipmapFilter : BITS(FILTER_LAST);
140 SwizzleType swizzleR : BITS(SWIZZLE_LAST);
141 SwizzleType swizzleG : BITS(SWIZZLE_LAST);
142 SwizzleType swizzleB : BITS(SWIZZLE_LAST);
143 SwizzleType swizzleA : BITS(SWIZZLE_LAST);
144 bool highPrecisionFiltering : 1;
147 bool compressedFormat : 1;
155 State samplerState() const;
157 void setTextureLevel(int face, int level, Surface *surface, TextureType type);
159 void setTextureFilter(FilterType textureFilter);
160 void setMipmapFilter(MipmapType mipmapFilter);
161 void setGatherEnable(bool enable);
162 void setAddressingModeU(AddressingMode addressingMode);
163 void setAddressingModeV(AddressingMode addressingMode);
164 void setAddressingModeW(AddressingMode addressingMode);
165 void setReadSRGB(bool sRGB);
166 void setBorderColor(const Color<float> &borderColor);
167 void setMaxAnisotropy(float maxAnisotropy);
168 void setHighPrecisionFiltering(bool highPrecisionFiltering);
169 void setSwizzleR(SwizzleType swizzleR);
170 void setSwizzleG(SwizzleType swizzleG);
171 void setSwizzleB(SwizzleType swizzleB);
172 void setSwizzleA(SwizzleType swizzleA);
173 void setBaseLevel(int baseLevel);
174 void setMaxLevel(int maxLevel);
175 void setMinLod(float minLod);
176 void setMaxLod(float maxLod);
178 static void setFilterQuality(FilterType maximumFilterQuality);
179 static void setMipmapQuality(MipmapType maximumFilterQuality);
180 void setMipmapLOD(float lod);
182 bool hasTexture() const;
183 bool hasUnsignedTexture() const;
184 bool hasCubeTexture() const;
185 bool hasVolumeTexture() const;
187 const Texture &getTextureData();
190 MipmapType mipmapFilter() const;
191 TextureType getTextureType() const;
192 FilterType getTextureFilter() const;
193 AddressingMode getAddressingModeU() const;
194 AddressingMode getAddressingModeV() const;
195 AddressingMode getAddressingModeW() const;
197 Format externalTextureFormat;
198 Format internalTextureFormat;
199 TextureType textureType;
201 FilterType textureFilter;
202 AddressingMode addressingModeU;
203 AddressingMode addressingModeV;
204 AddressingMode addressingModeW;
205 MipmapType mipmapFilterState;
208 bool highPrecisionFiltering;
210 SwizzleType swizzleR;
211 SwizzleType swizzleG;
212 SwizzleType swizzleB;
213 SwizzleType swizzleA;
217 static FilterType maximumTextureFilterQuality;
218 static MipmapType maximumMipmapFilterQuality;
222 #endif // sw_Sampler_hpp