1 // Copyright 2018 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 #ifndef VK_SAMPLER_HPP_
16 #define VK_SAMPLER_HPP_
17 
18 #include "VkDevice.hpp"
19 
20 namespace vk
21 {
22 
23 class Sampler : public Object<Sampler, VkSampler>
24 {
25 public:
Sampler(const VkSamplerCreateInfo * pCreateInfo,void * mem)26 	Sampler(const VkSamplerCreateInfo* pCreateInfo, void* mem) :
27 		magFilter(pCreateInfo->magFilter),
28 		minFilter(pCreateInfo->minFilter),
29 		mipmapMode(pCreateInfo->mipmapMode),
30 		addressModeU(pCreateInfo->addressModeU),
31 		addressModeV(pCreateInfo->addressModeV),
32 		addressModeW(pCreateInfo->addressModeW),
33 		mipLodBias(pCreateInfo->mipLodBias),
34 		anisotropyEnable(pCreateInfo->anisotropyEnable),
35 		maxAnisotropy(pCreateInfo->maxAnisotropy),
36 		compareEnable(pCreateInfo->compareEnable),
37 		compareOp(pCreateInfo->compareOp),
38 		minLod(pCreateInfo->minLod),
39 		maxLod(pCreateInfo->maxLod),
40 		borderColor(pCreateInfo->borderColor),
41 		unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
42 	{
43 	}
44 
45 	~Sampler() = delete;
46 
ComputeRequiredAllocationSize(const VkSamplerCreateInfo * pCreateInfo)47 	static size_t ComputeRequiredAllocationSize(const VkSamplerCreateInfo* pCreateInfo)
48 	{
49 		return 0;
50 	}
51 
52 private:
53 	VkFilter                magFilter = VK_FILTER_NEAREST;
54 	VkFilter                minFilter = VK_FILTER_NEAREST;
55 	VkSamplerMipmapMode     mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
56 	VkSamplerAddressMode    addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
57 	VkSamplerAddressMode    addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
58 	VkSamplerAddressMode    addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
59 	float                   mipLodBias = 0.0f;
60 	VkBool32                anisotropyEnable = VK_FALSE;
61 	float                   maxAnisotropy = 0.0f;
62 	VkBool32                compareEnable = VK_FALSE;
63 	VkCompareOp             compareOp = VK_COMPARE_OP_NEVER;
64 	float                   minLod = 0.0f;
65 	float                   maxLod = 0.0f;
66 	VkBorderColor           borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
67 	VkBool32                unnormalizedCoordinates = VK_FALSE;
68 };
69 
Cast(VkSampler object)70 static inline Sampler* Cast(VkSampler object)
71 {
72 	return reinterpret_cast<Sampler*>(object);
73 }
74 
75 } // namespace vk
76 
77 #endif // VK_SAMPLER_HPP_