blob: d64a4d539fcbbff257e20ee60fde1166515199ba [file] [log] [blame]
Ben Claytoneac32c42019-04-26 11:25:57 +01001// 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
Ben Claytoneac32c42019-04-26 11:25:57 +010015#include "VkSampler.hpp"
16
Nicolas Capens157ba262019-12-10 17:49:14 -050017namespace vk {
Ben Claytoneac32c42019-04-26 11:25:57 +010018
Antonio Maioranod9ba4b72020-05-04 14:38:59 -040019SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion, VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision)
Nicolas Capensf948cd12020-03-23 13:00:43 -040020 : Memset(this, 0)
21 , magFilter(pCreateInfo->magFilter)
22 , minFilter(pCreateInfo->minFilter)
23 , mipmapMode(pCreateInfo->mipmapMode)
24 , addressModeU(pCreateInfo->addressModeU)
25 , addressModeV(pCreateInfo->addressModeV)
26 , addressModeW(pCreateInfo->addressModeW)
27 , mipLodBias(pCreateInfo->mipLodBias)
28 , anisotropyEnable(pCreateInfo->anisotropyEnable)
29 , maxAnisotropy(pCreateInfo->maxAnisotropy)
30 , compareEnable(pCreateInfo->compareEnable)
31 , compareOp(pCreateInfo->compareOp)
32 , minLod(ClampLod(pCreateInfo->minLod))
33 , maxLod(ClampLod(pCreateInfo->maxLod))
34 , borderColor(pCreateInfo->borderColor)
35 , unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
Antonio Maioranod9ba4b72020-05-04 14:38:59 -040036 , filteringPrecision(filteringPrecision)
Nicolas Capensf948cd12020-03-23 13:00:43 -040037{
38 if(ycbcrConversion)
39 {
40 ycbcrModel = ycbcrConversion->ycbcrModel;
41 studioSwing = (ycbcrConversion->ycbcrRange == VK_SAMPLER_YCBCR_RANGE_ITU_NARROW);
42 swappedChroma = (ycbcrConversion->components.r != VK_COMPONENT_SWIZZLE_R);
43 }
44}
45
Nicolas Capens73c4a0c2020-03-17 17:29:11 -040046Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
47 : SamplerState(samplerState)
48 , id(samplerID)
Nicolas Capensf948cd12020-03-23 13:00:43 -040049{
50}
51
Nicolas Capens157ba262019-12-10 17:49:14 -050052} // namespace vk