Skip to content

Commit 072c812

Browse files
cube: Fix protected memory pNext chains
The chains were including the structs even when protected memory isn't desired, triggering validation errors.
1 parent 4d5e1f8 commit 072c812

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cube/cube.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ void Demo::create_device() {
812812
}
813813

814814
auto const protected_memory_features = vk::PhysicalDeviceProtectedMemoryFeatures().setProtectedMemory(protected_output);
815-
auto deviceInfo = vk::DeviceCreateInfo().setPNext(&protected_memory_features).setQueueCreateInfos(queues).setPEnabledExtensionNames(enabled_device_extensions);
815+
auto deviceInfo = vk::DeviceCreateInfo().setPNext(protected_output ? &protected_memory_features : nullptr).setQueueCreateInfos(queues).setPEnabledExtensionNames(enabled_device_extensions);
816816
auto device_return = gpu.createDevice(deviceInfo);
817817
VERIFY(device_return.result == vk::Result::eSuccess);
818818
device = device_return.value;
@@ -863,7 +863,7 @@ void Demo::draw() {
863863
auto protected_submit_info = vk::ProtectedSubmitInfo().setProtectedSubmit(protected_output);
864864

865865
auto submit_result = graphics_queue.submit(vk::SubmitInfo()
866-
.setPNext(&protected_submit_info)
866+
.setPNext(protected_output ? &protected_submit_info : nullptr)
867867
.setWaitDstStageMask(pipe_stage_flags)
868868
.setWaitSemaphores(image_acquired_semaphores[frame_index])
869869
.setCommandBuffers(swapchain_image_resources[current_buffer].cmd)
@@ -1021,7 +1021,7 @@ void Demo::flush_init_cmd() {
10211021
auto fence = fence_return.value;
10221022

10231023
auto const protected_submit_info = vk::ProtectedSubmitInfo().setProtectedSubmit(protected_output);
1024-
result = graphics_queue.submit(vk::SubmitInfo().setPNext(&protected_submit_info).setCommandBuffers(cmd), fence);
1024+
result = graphics_queue.submit(vk::SubmitInfo().setPNext(protected_output ? &protected_submit_info : nullptr).setCommandBuffers(cmd), fence);
10251025
VERIFY(result == vk::Result::eSuccess);
10261026

10271027
result = device.waitForFences(fence, VK_TRUE, UINT64_MAX);

0 commit comments

Comments
 (0)