KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rhi_bind_group.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <rhi/rhi_bind_group.h>
21
22#include <algorithm>
23#include <unordered_set>
24
25
27{
28 int groupIndex = static_cast<int>( frequency );
29
30 if( groupIndex < 0 || groupIndex >= RHI_MAX_BIND_GROUPS )
31 return false;
32
33 if( entries.empty() )
34 return true;
35
36 std::unordered_set<uint32_t> seen;
37 seen.reserve( entries.size() );
38
39 for( const auto& entry : entries )
40 {
41 if( !seen.insert( entry.binding ).second )
42 return false;
43
44 if( !entry.stages )
45 return false;
46 }
47
48 return true;
49}
50
51
53{
54 if( entries.size() != aOther.entries.size() )
55 return false;
56
57 for( const RHI_BINDING_ENTRY& entry : entries )
58 {
59 const RHI_BINDING_ENTRY* other = aOther.Find( entry.binding );
60
61 if( !other || other->type != entry.type || other->stages != entry.stages )
62 return false;
63 }
64
65 return true;
66}
constexpr int RHI_MAX_BIND_GROUPS
Most bind groups one pipeline can use.
RHI_BINDING_TYPE type
RHI_SHADER_STAGE stages
const RHI_BINDING_ENTRY * Find(uint32_t aBinding) const
bool IsCompatible(const RHI_BIND_GROUP_LAYOUT_DESC &aOther) const
std::vector< RHI_BINDING_ENTRY > entries
RHI_BIND_FREQUENCY frequency