blob: 1458fa31f9297183bd1ebb5d778b1592952b911b [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
Nicolas Capens8532b0f2021-05-20 02:52:30 -040019SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
20 VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision, const VkClearColorValue &customBorderColor)
Nicolas Capensf948cd12020-03-23 13:00:43 -040021 : 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)
Nicolas Capens8532b0f2021-05-20 02:52:30 -040036 , customBorderColor(customBorderColor)
Nicolas Capensf948cd12020-03-23 13:00:43 -040037 , unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
Antonio Maioranod9ba4b72020-05-04 14:38:59 -040038 , filteringPrecision(filteringPrecision)
Nicolas Capensf948cd12020-03-23 13:00:43 -040039{
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
Nicolas Capens73c4a0c2020-03-17 17:29:11 -040048Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
49 : SamplerState(samplerState)
50 , id(samplerID)
Nicolas Capensf948cd12020-03-23 13:00:43 -040051{
52}
53
Nicolas Capens157ba262019-12-10 17:49:14 -050054} // namespace vk