• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision,const VkClearColorValue & customBorderColor)19 SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
20                            VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision, 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     , filteringPrecision(filteringPrecision)
39 {
40 	if(ycbcrConversion)
41 	{
42 		ycbcrModel = ycbcrConversion->ycbcrModel;
43 		studioSwing = (ycbcrConversion->ycbcrRange == VK_SAMPLER_YCBCR_RANGE_ITU_NARROW);
44 		swappedChroma = (ycbcrConversion->components.r != VK_COMPONENT_SWIZZLE_R);
45 	}
46 }
47 
Sampler(const VkSamplerCreateInfo * pCreateInfo,void * mem,const SamplerState & samplerState,uint32_t samplerID)48 Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
49     : SamplerState(samplerState)
50     , id(samplerID)
51 {
52 }
53 
54 }  // namespace vk
55