Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
DescriptorSets.inl
Go to the documentation of this file.
1/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30*/
31
32#pragma once
33#ifndef DVD_DESCRIPTOR_SETS_INL_
34#define DVD_DESCRIPTOR_SETS_INL_
35
36namespace Divide
37{
38 inline bool ImageView::operator==( const ImageView& other ) const noexcept
39 {
40 return _subRange == other._subRange &&
41 _descriptor == other._descriptor &&
42 TargetType(*this) == TargetType(other) &&
43 _srcTexture == other._srcTexture;
44 }
45
46 inline bool ImageView::operator!=( const ImageView& other ) const noexcept
47 {
48 return _srcTexture != other._srcTexture ||
49 _subRange != other._subRange ||
50 TargetType(*this) != TargetType(other) ||
51 _descriptor != other._descriptor;
52 }
53
54
55 inline bool DescriptorSetBindingData::operator==( const DescriptorSetBindingData& other ) const noexcept
56 {
57 if ( _type != other._type )
58 {
59 return false;
60 }
61
62 switch ( _type )
63 {
65 case DescriptorSetBindingType::SHADER_STORAGE_BUFFER : return _buffer == other._buffer;
66 case DescriptorSetBindingType::COMBINED_IMAGE_SAMPLER: return _sampledImage == other._sampledImage;
67 case DescriptorSetBindingType::IMAGE : return _imageView == other._imageView;
68
70 }
71
72 return true;
73 }
74
75 inline bool DescriptorSetBindingData::operator!=( const DescriptorSetBindingData& other ) const noexcept
76 {
77 if ( _type == other._type )
78 {
79 switch ( _type )
80 {
82 case DescriptorSetBindingType::SHADER_STORAGE_BUFFER: return _buffer != other._buffer;
83 case DescriptorSetBindingType::COMBINED_IMAGE_SAMPLER: return _sampledImage != other._sampledImage;
84 case DescriptorSetBindingType::IMAGE: return _imageView != other._imageView;
85
86 case DescriptorSetBindingType::COUNT: return false;
87 }
88 }
89
90 return true;
91 }
92
93 inline bool operator==( const DescriptorSet& lhs, const DescriptorSet& rhs ) noexcept
94 {
95 return lhs._bindingCount == rhs._bindingCount &&
96 lhs._bindings == rhs._bindings;
97 }
98
99 inline bool operator!=( const DescriptorSet& lhs, const DescriptorSet& rhs ) noexcept
100 {
101 return lhs._bindingCount != rhs._bindingCount ||
102 lhs._bindings != rhs._bindings;
103 }
104
105 inline void Set( DescriptorSetBindingData& dataInOut, const DescriptorImageView& view ) noexcept
106 {
107 dataInOut._imageView = view;
108 dataInOut._type = DescriptorSetBindingType::IMAGE;
109 }
110
111 inline void Set( DescriptorSetBindingData& dataInOut, const ImageView& view, const ImageUsage usage ) noexcept
112 {
113 Set(dataInOut, DescriptorImageView{view, usage});
114 }
115
116 inline void Set( DescriptorSetBindingData& dataInOut, const ImageView& view, const SamplerDescriptor sampler ) noexcept
117 {
118 dataInOut._sampledImage._image = view;
119 dataInOut._sampledImage._sampler = sampler;
120 dataInOut._sampledImage._samplerHash = GetHash( sampler );
121 dataInOut._sampledImage._imageHash = GetHash( view );
122
124 }
125
126 void Set( DescriptorSetBindingData& dataInOut, const Handle<Texture> defaultTextureView, const SamplerDescriptor sampler ) noexcept;
127
128 inline DescriptorSetBinding& AddBinding( DescriptorSet& setInOut, const U8 slot, const U16 stageVisibilityMask )
129 {
130 return setInOut._bindings[setInOut._bindingCount++] = DescriptorSetBinding
131 {
132 ._shaderStageVisibility = stageVisibilityMask,
133 ._slot = slot
134 };
135 }
136
137 inline DescriptorSetBinding& AddBinding( DescriptorSet& setInOut, const U8 slot, const ShaderStageVisibility stageVisibility )
138 {
139 return AddBinding( setInOut, slot, to_U16( stageVisibility ) );
140 }
141} //namespace Divide
142
143#endif //DVD_DESCRIPTOR_SETS_INL_
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
FORCE_INLINE bool operator!=(const GUIDWrapper &lhs, const GUIDWrapper &rhs) noexcept
Definition: GUIDWrapper.h:67
TextureType TargetType(const ImageView &imageView) noexcept
constexpr U16 to_U16(const T value)
uint8_t U8
size_t GetHash(const PropertyDescriptor< T > &descriptor) noexcept
Definition: Resource.inl:40
uint16_t U16
void Set(DescriptorSetBindingData &dataInOut, ShaderBuffer *buffer, const BufferRange range) noexcept
DescriptorSetBinding & AddBinding(DescriptorSet &setInOut, U8 slot, U16 stageVisibilityMask)
ShaderStageVisibility
bool operator==(const DisplayManager::OutputDisplayProperties &lhs, const DisplayManager::OutputDisplayProperties &rhs) noexcept
Definition: Application.inl:37
bool operator!=(const DescriptorSetBindingData &rhs) const noexcept
bool operator==(const DescriptorSetBindingData &rhs) const noexcept
std::array< DescriptorSetBinding, MAX_BINDINGS_PER_DESCRIPTOR_SET > _bindings
bool operator==(const ImageView &other) const noexcept
bool operator!=(const ImageView &other) const noexcept