1 // Copyright 2019 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 #include "VkSampler.hpp"
16
17 namespace vk {
18
SamplerState(const VkSamplerCreateInfo * pCreateInfo,const vk::SamplerYcbcrConversion * ycbcrConversion,const VkClearColorValue & customBorderColor)19 SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
20 const VkClearColorValue &customBorderColor)
21 : Memset(this, 0)
22 , magFilter(pCreateInfo->magFilter)
23 , minFilter(pCreateInfo->minFilter)
24 , mipmapMode(pCreateInfo->mipmapMode)
25 , addressModeU(pCreateInfo->addressModeU)
26 , addressModeV(pCreateInfo->addressModeV)
27 , addressModeW(pCreateInfo->addressModeW)
28 , mipLodBias(pCreateInfo->mipLodBias)
29 , anisotropyEnable(pCreateInfo->anisotropyEnable)
30 , maxAnisotropy(pCreateInfo->maxAnisotropy)
31 , compareEnable(pCreateInfo->compareEnable)
32 , compareOp(pCreateInfo->compareOp)
33 , minLod(ClampLod(pCreateInfo->minLod))
34 , maxLod(ClampLod(pCreateInfo->maxLod))
35 , borderColor(pCreateInfo->borderColor)
36 , customBorderColor(customBorderColor)
37 , unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
38 #ifdef SWIFTSHADER_HIGH_PRECISION_FILTERING
39 , highPrecisionFiltering(true)
40 #endif
41 {
42 if(ycbcrConversion)
43 {
44 ycbcrModel = ycbcrConversion->ycbcrModel;
45 studioSwing = (ycbcrConversion->ycbcrRange == VK_SAMPLER_YCBCR_RANGE_ITU_NARROW);
46 swappedChroma = (ycbcrConversion->components.r != VK_COMPONENT_SWIZZLE_R);
47 chromaFilter = ycbcrConversion->chromaFilter;
48 chromaXOffset = ycbcrConversion->xChromaOffset;
49 chromaYOffset = ycbcrConversion->yChromaOffset;
50 }
51 }
52
Sampler(const VkSamplerCreateInfo * pCreateInfo,void * mem,const SamplerState & samplerState,uint32_t samplerID)53 Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
54 : SamplerState(samplerState)
55 , id(samplerID)
56 {
57 }
58
59 } // namespace vk
60