Skip to content

Commit d3db211

Browse files
committed
Add optional feature zeroInitializeDeviceMemory
1 parent 34228aa commit d3db211

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/engine/renderer-vulkan/GraphicsCore/CapabilityPack.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ constexpr Array featuresExperimental {
182182

183183
constexpr Array featuresOptional {
184184
"swapchainMaintenance1",
185-
"descriptorHeap"
185+
"descriptorHeap",
186+
"zeroInitializeDeviceMemory"
186187
};
187188

188189
constexpr bool EngineConfigSupportedMinimal( const EngineConfig& config );

src/engine/renderer-vulkan/GraphicsCore/Memory/EngineAllocator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ MemoryPool EngineAllocator::AllocMemoryPool( const MemoryHeap::MemoryType type,
234234
.flags = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT
235235
};
236236

237+
if ( zeroInitMemory ) {
238+
memoryFlags.flags |= VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT;
239+
}
240+
237241
VkMemoryDedicatedAllocateInfo dedicatedMemoryInfo {
238242
.image = image ? ( VkImage ) dedicatedResource : nullptr,
239243
.buffer = image ? nullptr : ( VkBuffer ) dedicatedResource
@@ -465,6 +469,8 @@ void EngineAllocator::Init() {
465469

466470
reqs = GetBufferRequirements( VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, 262144 );
467471
memoryHeapEngineToCore = MemoryHeapForUsage( MemoryHeap::ENGINE_TO_CORE, reqs.type, memoryIDEngineToCore );
472+
473+
zeroInitMemory = featuresConfig.zeroInitializeDeviceMemory;
468474
}
469475

470476
void EngineAllocator::Free() {

src/engine/renderer-vulkan/GraphicsCore/Memory/EngineAllocator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class EngineAllocator {
129129

130130
bool rebar;
131131
bool unifiedMemory;
132+
133+
bool zeroInitMemory;
132134
};
133135

134136
MemoryRequirements GetBufferRequirements( const VkBufferUsageFlags type, const uint64 size );

0 commit comments

Comments
 (0)