Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void ApiVulkanSample::prepare_gui()
if (uses_dynamic_rendering())
{
VkFormat color_format = get_render_context().get_swapchain().get_format();
VkFormat depth_fmt = depth_format;
VkFormat depth_fmt = VK_FORMAT_UNDEFINED;
get_gui().prepare(pipeline_cache, color_format, depth_fmt, shader_stages);
}
else
Expand Down
2 changes: 1 addition & 1 deletion framework/hpp_api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void HPPApiVulkanSample::prepare_gui()
if (uses_dynamic_rendering())
{
vk::Format color_format = get_render_context().get_swapchain().get_format();
vk::Format depth_fmt = depth_format;
vk::Format depth_fmt = vk::Format::eUndefined;
get_gui().prepare(pipeline_cache, color_format, depth_fmt, shader_stages);
}
else
Expand Down
3 changes: 2 additions & 1 deletion framework/vulkan_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,8 @@ template <vkb::BindingType bindingType>
inline void VulkanSample<bindingType>::request_layers(std::unordered_map<std::string, vkb::RequestMode> &requested_layers) const
{
#if defined(VKB_DEBUG) || defined(VKB_VALIDATION_LAYERS)
requested_layers["VK_LAYER_KHRONOS_validation"] = vkb::RequestMode::Required;
// VK_LAYER_KHRONOS_validation must be optional in case layer not available for debug builds (e.g. running with no SDK installed or on iOS Simulator)
requested_layers["VK_LAYER_KHRONOS_validation"] = vkb::RequestMode::Optional;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading to me. I'd expect validation layers to be present when VKB_VALIDATION_LAYERS is on. A build error when validation layers can't be found seems the right answer. The VKB_DEBUG can have optional validation layers. I'd prefer required for VKB_VALIDATION_LAYERS and optional for VKB_DEBUG.

#endif
}

Expand Down
13 changes: 8 additions & 5 deletions samples/api/texture_loading/texture_loading.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2019-2025, Sascha Willems
/* Copyright (c) 2019-2026, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -408,10 +408,13 @@ void TextureLoading::load_texture()
// Free all Vulkan resources used by a texture object
void TextureLoading::destroy_texture(Texture texture)
{
vkDestroyImageView(get_device().get_handle(), texture.view, nullptr);
vkDestroyImage(get_device().get_handle(), texture.image, nullptr);
vkDestroySampler(get_device().get_handle(), texture.sampler, nullptr);
vkFreeMemory(get_device().get_handle(), texture.device_memory, nullptr);
if (has_device())
{
vkDestroyImageView(get_device().get_handle(), texture.view, nullptr);
vkDestroyImage(get_device().get_handle(), texture.image, nullptr);
vkDestroySampler(get_device().get_handle(), texture.sampler, nullptr);
vkFreeMemory(get_device().get_handle(), texture.device_memory, nullptr);
}
}

void TextureLoading::build_command_buffers()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2019-2025, Sascha Willems
/* Copyright (c) 2019-2026, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -285,9 +285,12 @@ void TextureMipMapGeneration::load_texture_generate_mipmaps(std::string file_nam
// Free all Vulkan resources used by a texture object
void TextureMipMapGeneration::destroy_texture(Texture texture)
{
vkDestroyImageView(get_device().get_handle(), texture.view, nullptr);
vkDestroyImage(get_device().get_handle(), texture.image, nullptr);
vkFreeMemory(get_device().get_handle(), texture.device_memory, nullptr);
if (has_device())
{
vkDestroyImageView(get_device().get_handle(), texture.view, nullptr);
vkDestroyImage(get_device().get_handle(), texture.image, nullptr);
vkFreeMemory(get_device().get_handle(), texture.device_memory, nullptr);
}
}

void TextureMipMapGeneration::load_assets()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,24 @@ void DynamicRenderingLocalRead::prepare_pipelines()
VK_CHECK(vkCreateGraphicsPipelines(get_device().get_handle(), pipeline_cache, 1, &pipeline_create_info, nullptr, &composition_pass.pipeline));
}

#if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR
void DynamicRenderingLocalRead::request_instance_extensions(std::unordered_map<std::string, vkb::RequestMode> &requested_extensions) const
{
// On iOS Simulator use layer setting to disable MoltenVK's Metal argument buffers - otherwise incorrect rendering for this sample
vkb::VulkanSampleC::request_instance_extensions(requested_extensions);
requested_extensions[VK_EXT_LAYER_SETTINGS_EXTENSION_NAME] = vkb::RequestMode::Optional;
}

void DynamicRenderingLocalRead::request_layer_settings(std::vector<VkLayerSettingEXT> &requested_layer_settings) const
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #1507, request_layer_settings has changed.
Needs to be adjusted accordingly.

{
// Make this static so layer setting reference remains valid after leaving the current scope
static const int32_t disableMetalArgumentBuffers = 0;

vkb::VulkanSampleC::request_layer_settings(requested_layer_settings);
requested_layer_settings.push_back({"MoltenVK", "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", VK_LAYER_SETTING_TYPE_INT32_EXT, 1, &disableMetalArgumentBuffers});
}
#endif

void DynamicRenderingLocalRead::draw_scene(std::unique_ptr<vkb::scene_graph::SceneC> &scene, VkCommandBuffer cmd, VkPipelineLayout pipeline_layout)
{
for (auto &mesh : scene->get_components<vkb::sg::Mesh>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class DynamicRenderingLocalRead : public ApiVulkanSample
void update_lights_buffer();
void update_uniform_buffer();
void prepare_layouts_and_descriptors();
#if defined(PLATFORM__MACOS) && TARGET_OS_IOS && TARGET_OS_SIMULATOR
void request_instance_extensions(std::unordered_map<std::string, vkb::RequestMode> &requested_extensions) const override;
void request_layer_settings(std::vector<VkLayerSettingEXT> &requested_layer_settings) const override;
#endif

void draw_scene(std::unique_ptr<vkb::scene_graph::SceneC> &scene, VkCommandBuffer cmd, VkPipelineLayout pipeline_layout);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ HPPPipelineCache::~HPPPipelineCache()
get_device().get_handle().destroyPipelineCache(pipeline_cache);
}

vkb::fs::write_temp(get_device().get_resource_cache().serialize(), "hpp_cache.data");
if (has_device())
{
vkb::fs::write_temp(get_device().get_resource_cache().serialize(), "hpp_cache.data");
}
}

bool HPPPipelineCache::prepare(const vkb::ApplicationOptions &options)
Expand Down
5 changes: 4 additions & 1 deletion samples/performance/pipeline_cache/pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ PipelineCache::~PipelineCache()
vkDestroyPipelineCache(get_device().get_handle(), pipeline_cache, nullptr);
}

vkb::fs::write_temp(get_device().get_resource_cache().serialize(), "cache.data");
if (has_device())
{
vkb::fs::write_temp(get_device().get_resource_cache().serialize(), "cache.data");
}
}

bool PipelineCache::prepare(const vkb::ApplicationOptions &options)
Expand Down
Loading