-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Descriptor Sets to Filament (#8165)
We add the concept of the descriptor set as a way to describe shader resources into Filament. This is a comprehensive change across Filament. Info on descriptor sets is available here: https://docs.vulkan.org/spec/latest/chapters/descriptorsets.html Co-authored-by: Benjamin Doherty <bendoherty@google.com> Co-authored-by: Mathias Agopian <mathias@google.com> Co-authored-by: Sungun Park <sungunpark@google.com>
- Loading branch information
1 parent
3d4fc78
commit 2cade20
Showing
173 changed files
with
8,702 additions
and
5,426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
filament/backend/include/backend/DescriptorSetOffsetArray.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (C) 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef TNT_FILAMENT_BACKEND_COMMANDSTREAMVECTOR_H | ||
#define TNT_FILAMENT_BACKEND_COMMANDSTREAMVECTOR_H | ||
|
||
#include <backend/DriverApiForward.h> | ||
|
||
#include <initializer_list> | ||
#include <memory> | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
|
||
namespace filament::backend { | ||
|
||
void* allocateFromCommandStream(DriverApi& driver, size_t size, size_t alignment) noexcept; | ||
|
||
class DescriptorSetOffsetArray { | ||
public: | ||
using value_type = uint32_t; | ||
using reference = value_type&; | ||
using const_reference = value_type const&; | ||
using size_type = uint32_t; | ||
using difference_type = int32_t; | ||
using pointer = value_type*; | ||
using const_pointer = value_type const*; | ||
using iterator = pointer; | ||
using const_iterator = const_pointer; | ||
|
||
DescriptorSetOffsetArray() noexcept = default; | ||
|
||
~DescriptorSetOffsetArray() noexcept = default; | ||
|
||
DescriptorSetOffsetArray(size_type size, DriverApi& driver) noexcept { | ||
mOffsets = (value_type *)allocateFromCommandStream(driver, | ||
size * sizeof(value_type), alignof(value_type)); | ||
std::uninitialized_fill_n(mOffsets, size, 0); | ||
} | ||
|
||
DescriptorSetOffsetArray(std::initializer_list<uint32_t> list, DriverApi& driver) noexcept { | ||
mOffsets = (value_type *)allocateFromCommandStream(driver, | ||
list.size() * sizeof(value_type), alignof(value_type)); | ||
std::uninitialized_copy(list.begin(), list.end(), mOffsets); | ||
} | ||
|
||
DescriptorSetOffsetArray(DescriptorSetOffsetArray const&) = delete; | ||
DescriptorSetOffsetArray& operator=(DescriptorSetOffsetArray const&) = delete; | ||
|
||
DescriptorSetOffsetArray(DescriptorSetOffsetArray&& rhs) noexcept | ||
: mOffsets(rhs.mOffsets) { | ||
rhs.mOffsets = nullptr; | ||
} | ||
|
||
DescriptorSetOffsetArray& operator=(DescriptorSetOffsetArray&& rhs) noexcept { | ||
if (this != &rhs) { | ||
mOffsets = rhs.mOffsets; | ||
rhs.mOffsets = nullptr; | ||
} | ||
return *this; | ||
} | ||
|
||
bool empty() const noexcept { return mOffsets == nullptr; } | ||
|
||
value_type* data() noexcept { return mOffsets; } | ||
const value_type* data() const noexcept { return mOffsets; } | ||
|
||
|
||
reference operator[](size_type n) noexcept { | ||
return *(data() + n); | ||
} | ||
|
||
const_reference operator[](size_type n) const noexcept { | ||
return *(data() + n); | ||
} | ||
|
||
void clear() noexcept { | ||
mOffsets = nullptr; | ||
} | ||
|
||
private: | ||
value_type *mOffsets = nullptr; | ||
}; | ||
|
||
} // namespace filament::backend | ||
|
||
#endif //TNT_FILAMENT_BACKEND_COMMANDSTREAMVECTOR_H |
Oops, something went wrong.