Skip to content

Commit 1a0f97f

Browse files
committed
Address PR comment - add comment to VulkanProgram
1 parent 4bb3eeb commit 1a0f97f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

filament/backend/src/vulkan/VulkanAsyncHandles.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ struct PushConstantDescription {
6363
uint32_t mRangeCount;
6464
};
6565

66+
// Encapsulates a VkShaderModule. Note: this is a ThreadSafeResource
67+
// because we may use parallel compilation, in which case ref counts may
68+
// be modified on multiple backend threads. This is simply to avoid
69+
// destroying a VkShaderModule mid-compilation of a pipeline. It is
70+
// still assumed that all calls will originate from the backend.
6671
struct VulkanProgram : public HwProgram, fvkmemory::ThreadSafeResource {
6772
using BindingList = fvkutils::StaticVector<uint16_t, MAX_SAMPLER_COUNT>;
6873

filament/backend/src/vulkan/VulkanCommands.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <atomic>
3737
#include <chrono>
3838
#include <list>
39+
#include <type_traits>
3940
#include <utility>
4041
#include <variant>
4142

@@ -72,11 +73,11 @@ struct VulkanCommandBuffer {
7273

7374
~VulkanCommandBuffer();
7475

75-
inline void acquire(fvkmemory::resource_ptr<fvkmemory::Resource> resource) {
76-
mResources.push_back(resource);
77-
}
78-
79-
inline void acquire(fvkmemory::resource_ptr<fvkmemory::ThreadSafeResource> resource) {
76+
template <typename T,
77+
typename = std::enable_if_t<
78+
std::is_same_v<T, fvkmemory::Resource> ||
79+
std::is_same_v<T, fvkmemory::ThreadSafeResource>>>
80+
inline void acquire(fvkmemory::resource_ptr<T> resource) {
8081
mResources.push_back(resource);
8182
}
8283

0 commit comments

Comments
 (0)