xref: /aosp_15_r20/external/swiftshader/src/Vulkan/VkSampler.cpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1*03ce13f7SAndroid Build Coastguard Worker // Copyright 2019 The SwiftShader Authors. All Rights Reserved.
2*03ce13f7SAndroid Build Coastguard Worker //
3*03ce13f7SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*03ce13f7SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*03ce13f7SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*03ce13f7SAndroid Build Coastguard Worker //
7*03ce13f7SAndroid Build Coastguard Worker //    http://www.apache.org/licenses/LICENSE-2.0
8*03ce13f7SAndroid Build Coastguard Worker //
9*03ce13f7SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*03ce13f7SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*03ce13f7SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*03ce13f7SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*03ce13f7SAndroid Build Coastguard Worker // limitations under the License.
14*03ce13f7SAndroid Build Coastguard Worker 
15*03ce13f7SAndroid Build Coastguard Worker #include "VkSampler.hpp"
16*03ce13f7SAndroid Build Coastguard Worker 
17*03ce13f7SAndroid Build Coastguard Worker namespace vk {
18*03ce13f7SAndroid Build Coastguard Worker 
SamplerState(const VkSamplerCreateInfo * pCreateInfo,const vk::SamplerYcbcrConversion * ycbcrConversion,const VkClearColorValue & customBorderColor)19*03ce13f7SAndroid Build Coastguard Worker SamplerState::SamplerState(const VkSamplerCreateInfo *pCreateInfo, const vk::SamplerYcbcrConversion *ycbcrConversion,
20*03ce13f7SAndroid Build Coastguard Worker                            const VkClearColorValue &customBorderColor)
21*03ce13f7SAndroid Build Coastguard Worker     : Memset(this, 0)
22*03ce13f7SAndroid Build Coastguard Worker     , magFilter(pCreateInfo->magFilter)
23*03ce13f7SAndroid Build Coastguard Worker     , minFilter(pCreateInfo->minFilter)
24*03ce13f7SAndroid Build Coastguard Worker     , mipmapMode(pCreateInfo->mipmapMode)
25*03ce13f7SAndroid Build Coastguard Worker     , addressModeU(pCreateInfo->addressModeU)
26*03ce13f7SAndroid Build Coastguard Worker     , addressModeV(pCreateInfo->addressModeV)
27*03ce13f7SAndroid Build Coastguard Worker     , addressModeW(pCreateInfo->addressModeW)
28*03ce13f7SAndroid Build Coastguard Worker     , mipLodBias(pCreateInfo->mipLodBias)
29*03ce13f7SAndroid Build Coastguard Worker     , anisotropyEnable(pCreateInfo->anisotropyEnable)
30*03ce13f7SAndroid Build Coastguard Worker     , maxAnisotropy(pCreateInfo->maxAnisotropy)
31*03ce13f7SAndroid Build Coastguard Worker     , compareEnable(pCreateInfo->compareEnable)
32*03ce13f7SAndroid Build Coastguard Worker     , compareOp(pCreateInfo->compareOp)
33*03ce13f7SAndroid Build Coastguard Worker     , minLod(ClampLod(pCreateInfo->minLod))
34*03ce13f7SAndroid Build Coastguard Worker     , maxLod(ClampLod(pCreateInfo->maxLod))
35*03ce13f7SAndroid Build Coastguard Worker     , borderColor(pCreateInfo->borderColor)
36*03ce13f7SAndroid Build Coastguard Worker     , customBorderColor(customBorderColor)
37*03ce13f7SAndroid Build Coastguard Worker     , unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
38*03ce13f7SAndroid Build Coastguard Worker #ifdef SWIFTSHADER_HIGH_PRECISION_FILTERING
39*03ce13f7SAndroid Build Coastguard Worker     , highPrecisionFiltering(true)
40*03ce13f7SAndroid Build Coastguard Worker #endif
41*03ce13f7SAndroid Build Coastguard Worker {
42*03ce13f7SAndroid Build Coastguard Worker 	if(ycbcrConversion)
43*03ce13f7SAndroid Build Coastguard Worker 	{
44*03ce13f7SAndroid Build Coastguard Worker 		ycbcrModel = ycbcrConversion->ycbcrModel;
45*03ce13f7SAndroid Build Coastguard Worker 		studioSwing = (ycbcrConversion->ycbcrRange == VK_SAMPLER_YCBCR_RANGE_ITU_NARROW);
46*03ce13f7SAndroid Build Coastguard Worker 		swappedChroma = (ycbcrConversion->components.r != VK_COMPONENT_SWIZZLE_R);
47*03ce13f7SAndroid Build Coastguard Worker         chromaFilter = ycbcrConversion->chromaFilter;
48*03ce13f7SAndroid Build Coastguard Worker         chromaXOffset = ycbcrConversion->xChromaOffset;
49*03ce13f7SAndroid Build Coastguard Worker         chromaYOffset = ycbcrConversion->yChromaOffset;
50*03ce13f7SAndroid Build Coastguard Worker 	}
51*03ce13f7SAndroid Build Coastguard Worker }
52*03ce13f7SAndroid Build Coastguard Worker 
Sampler(const VkSamplerCreateInfo * pCreateInfo,void * mem,const SamplerState & samplerState,uint32_t samplerID)53*03ce13f7SAndroid Build Coastguard Worker Sampler::Sampler(const VkSamplerCreateInfo *pCreateInfo, void *mem, const SamplerState &samplerState, uint32_t samplerID)
54*03ce13f7SAndroid Build Coastguard Worker     : SamplerState(samplerState)
55*03ce13f7SAndroid Build Coastguard Worker     , id(samplerID)
56*03ce13f7SAndroid Build Coastguard Worker {
57*03ce13f7SAndroid Build Coastguard Worker }
58*03ce13f7SAndroid Build Coastguard Worker 
59*03ce13f7SAndroid Build Coastguard Worker }  // namespace vk
60