vsg: include/vsg/state/Sampler.h Source File

vsg 1.1.10 VulkanSceneGraph library |

Loading...
Searching...
No Matches
Sampler.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/vk/Device.h>
16#include <vsg/vk/vk_buffer.h>
17
18namespace vsg
19{
20 // forward declare
21 class Context;
22
24 class VSG_DECLSPEC Sampler : public Inherit<Object, Sampler>
25 {
26 public:
27 Sampler();
28
30 VkSamplerCreateFlags flags = 0;
31 VkFilter magFilter = VK_FILTER_LINEAR;
32 VkFilter minFilter = VK_FILTER_LINEAR;
33 VkSamplerMipmapMode mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
34 VkSamplerAddressMode addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
35 VkSamplerAddressMode addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
36 VkSamplerAddressMode addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
37 float mipLodBias = 0.0f;
38 VkBool32 anisotropyEnable = VK_FALSE;
39 float maxAnisotropy = 0.0f;
40 VkBool32 compareEnable = VK_FALSE;
41 VkCompareOp compareOp = VK_COMPARE_OP_NEVER;
42 float minLod = 0.0f;
43 float maxLod = 0.0f;
44 VkBorderColor borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
45 VkBool32 unnormalizedCoordinates = VK_FALSE;
46
47 // Vulkan VkSampler handle
48 VkSampler vk(uint32_t deviceID) const { return _implementation[deviceID]->_sampler; }
49
50 void compile(Context& context);
51
52 void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
53 void release() { _implementation.clear(); }
54
55 public:
56 int compare(const Object& rhs_object) const override;
57
58 void read(Input& input) override;
59 void write(Output& output) const override;
60
61 protected:
62 virtual ~Sampler();
63
64 struct Implementation : public Inherit<Object, Implementation>
65 {
66 Implementation(Device* device, const VkSamplerCreateInfo& createSamplerInfo);
67
68 virtual ~Implementation();
69
70 VkSampler _sampler;
71 ref_ptr<Device> _device;
72 };
73
74 vk_buffer<ref_ptr<Implementation>> _implementation;
75 };
76 VSG_type_name(vsg::Sampler)
77
78} // namespace vsg
vsg::Context
Definition Context.h:67
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:39
vsg::Input
Definition Input.h:44
vsg::Object
Definition Object.h:60
vsg::Output
Definition Output.h:41
vsg::Sampler
Sampler encapsulates the VkSampler and the VkSamplerCreateInfo settings used to set it up.
Definition Sampler.h:25
vsg::Sampler::compare
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
vsg::Sampler::flags
VkSamplerCreateFlags flags
VkSamplerCreateInfo settings.
Definition Sampler.h:30
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::vk_buffer
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28