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];
44 Mipmap mipmap[MIPMAP_LEVELS];
47 float4 widthHeightLOD;
52 word4 borderColor4[4];
53 float4 borderColorF[4];
67 enum TextureType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
75 TEXTURE_LAST = TEXTURE_2D_ARRAY
78 enum FilterType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
82 FILTER_MIN_POINT_MAG_LINEAR,
83 FILTER_MIN_LINEAR_MAG_POINT,
87 FILTER_LAST = FILTER_ANISOTROPIC
90 enum MipmapType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
96 MIPMAP_LAST = MIPMAP_LINEAR
99 enum AddressingMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
104 ADDRESSING_MIRRORONCE,
107 ADDRESSING_TEXELFETCH,
109 ADDRESSING_LAST = ADDRESSING_TEXELFETCH
112 enum SwizzleType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
121 SWIZZLE_LAST = SWIZZLE_ONE
131 TextureType textureType : BITS(TEXTURE_LAST);
132 Format textureFormat : BITS(FORMAT_LAST);
133 FilterType textureFilter : BITS(FILTER_LAST);
134 AddressingMode addressingModeU : BITS(ADDRESSING_LAST);
135 AddressingMode addressingModeV : BITS(ADDRESSING_LAST);
136 AddressingMode addressingModeW : BITS(ADDRESSING_LAST);
137 MipmapType mipmapFilter : BITS(FILTER_LAST);
139 SwizzleType swizzleR : BITS(SWIZZLE_LAST);
140 SwizzleType swizzleG : BITS(SWIZZLE_LAST);
141 SwizzleType swizzleB : BITS(SWIZZLE_LAST);
142 SwizzleType swizzleA : BITS(SWIZZLE_LAST);
145 bool compressedFormat : 1;
153 State samplerState() const;
155 void setTextureLevel(int face, int level, Surface *surface, TextureType type);
157 void setTextureFilter(FilterType textureFilter);
158 void setMipmapFilter(MipmapType mipmapFilter);
159 void setGatherEnable(bool enable);
160 void setAddressingModeU(AddressingMode addressingMode);
161 void setAddressingModeV(AddressingMode addressingMode);
162 void setAddressingModeW(AddressingMode addressingMode);
163 void setReadSRGB(bool sRGB);
164 void setBorderColor(const Color<float> &borderColor);
165 void setMaxAnisotropy(float maxAnisotropy);
166 void setSwizzleR(SwizzleType swizzleR);
167 void setSwizzleG(SwizzleType swizzleG);
168 void setSwizzleB(SwizzleType swizzleB);
169 void setSwizzleA(SwizzleType swizzleA);
170 void setBaseLevel(int baseLevel);
171 void setMaxLevel(int maxLevel);
172 void setMinLod(float minLod);
173 void setMaxLod(float maxLod);
175 static void setFilterQuality(FilterType maximumFilterQuality);
176 static void setMipmapQuality(MipmapType maximumFilterQuality);
177 void setMipmapLOD(float lod);
179 bool hasTexture() const;
180 bool hasUnsignedTexture() const;
181 bool hasCubeTexture() const;
182 bool hasVolumeTexture() const;
184 const Texture &getTextureData();
187 MipmapType mipmapFilter() const;
188 TextureType getTextureType() const;
189 FilterType getTextureFilter() const;
190 AddressingMode getAddressingModeU() const;
191 AddressingMode getAddressingModeV() const;
192 AddressingMode getAddressingModeW() const;
194 Format externalTextureFormat;
195 Format internalTextureFormat;
196 TextureType textureType;
198 FilterType textureFilter;
199 AddressingMode addressingModeU;
200 AddressingMode addressingModeV;
201 AddressingMode addressingModeW;
202 MipmapType mipmapFilterState;
206 SwizzleType swizzleR;
207 SwizzleType swizzleG;
208 SwizzleType swizzleB;
209 SwizzleType swizzleA;
213 static FilterType maximumTextureFilterQuality;
214 static MipmapType maximumMipmapFilterQuality;
218 #endif // sw_Sampler_hpp