KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rhi_bind_group.h
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#pragma once
21
22#include <rhi/rhi_types.h>
23#include <rhi/rhi_handle.h>
24#include <algorithm>
25#include <cstdint>
26#include <vector>
27
29constexpr int RHI_MAX_BIND_GROUPS = 4;
30
38
40enum class RHI_SHADER_STAGE : uint32_t
41{
42 NONE = 0,
43 VERTEX = 1u << 0,
44 FRAGMENT = 1u << 1,
45 COMPUTE = 1u << 2,
46 ALL = ( 1u << 0 ) | ( 1u << 1 )
47};
48
50{
51 return static_cast<RHI_SHADER_STAGE>( static_cast<uint32_t>( a )
52 & static_cast<uint32_t>( b ) );
53}
54
56{
57 return static_cast<uint32_t>( a ) == 0;
58}
59
65{
69};
70
76constexpr uint32_t RHI_UBO_BINDING = 1;
77
84
86{
88 std::vector<RHI_BINDING_ENTRY> entries;
89
94 bool Validate() const;
95
97 bool IsCompatible( const RHI_BIND_GROUP_LAYOUT_DESC& aOther ) const;
98
100 const RHI_BINDING_ENTRY* Find( uint32_t aBinding ) const
101 {
102 auto it = std::ranges::find( entries, aBinding, &RHI_BINDING_ENTRY::binding );
103
104 return it == entries.end() ? nullptr : &*it;
105 }
106};
107
108
121
123{
125 std::vector<RHI_BIND_GROUP_RESOURCE> entries;
126};
@ NONE
Definition eda_fill.h:42
RHI_SHADER_STAGE operator&(RHI_SHADER_STAGE a, RHI_SHADER_STAGE b)
RHI_SHADER_STAGE
Bit flags for the shader stages that see a binding.
@ ALL
Graphics stages only, compute is opted into explicitly.
constexpr uint32_t RHI_UBO_BINDING
MSL is generated with –msl-decoration-binding, so a Metal buffer index is its binding number in every...
RHI_BIND_FREQUENCY
How often a group's resources change.
bool operator!(RHI_SHADER_STAGE a)
RHI_BINDING_TYPE
constexpr int RHI_MAX_BIND_GROUPS
Most bind groups one pipeline can use.
RHI_HANDLE< RHI_TAG_TEXTURE > RHI_TextureHandle
Definition rhi_handle.h:84
RHI_HANDLE< RHI_TAG_BUFFER > RHI_BufferHandle
Definition rhi_handle.h:83
RHI_HANDLE< RHI_TAG_BIND_GROUP_LAYOUT > RHI_BindGroupLayoutHandle
Definition rhi_handle.h:89
RHI_BINDING_TYPE type
RHI_SHADER_STAGE stages
uint32_t binding
std::vector< RHI_BIND_GROUP_RESOURCE > entries
RHI_BindGroupLayoutHandle layout
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
Buffer bindings set bufferHandle; a COMBINED_TEXTURE_SAMPLER binding sets textureHandle.
RHI_BufferHandle bufferHandle
RHI_TextureHandle textureHandle