blob: 11cb00e3dfb325884b2d192326ac14669b045789 [file] [log] [blame]
// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VkSampler.hpp"
namespace vk {
SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion)
: Memset(this, 0)
, magFilter(pCreateInfo->magFilter)
, minFilter(pCreateInfo->minFilter)
, mipmapMode(pCreateInfo->mipmapMode)
, addressModeU(pCreateInfo->addressModeU)
, addressModeV(pCreateInfo->addressModeV)
, addressModeW(pCreateInfo->addressModeW)
, mipLodBias(pCreateInfo->mipLodBias)
, anisotropyEnable(pCreateInfo->anisotropyEnable)
, maxAnisotropy(pCreateInfo->maxAnisotropy)
, compareEnable(pCreateInfo->compareEnable)
, compareOp(pCreateInfo->compareOp)
, minLod(ClampLod(pCreateInfo->minLod))
, maxLod(ClampLod(pCreateInfo->maxLod))
, borderColor(pCreateInfo->borderColor)
, unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
{
if(ycbcrConversion)
{
ycbcrModel = ycbcrConversion->ycbcrModel;
studioSwing = (ycbcrConversion->ycbcrRange == VK_SAMPLER_YCBCR_RANGE_ITU_NARROW);
swappedChroma = (ycbcrConversion->components.r != VK_COMPONENT_SWIZZLE_R);
}
}
Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
: SamplerState(samplerState)
, id(samplerID)
{
}
} // namespace vk