From d9a6b1069f8008e83a74ae6c08fc7b0235aa2830 Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Mon, 18 Dec 2023 17:37:22 +0100 Subject: [PATCH] Fix validation errors and issues in shader objects sample (#850) * Fix validation errors for shader object extension Destroy samplers before (re)creation Remove unnecessary base class calls Excplicitly reset command pool before recreating command buffers * Remove merge artefacts --- samples/extensions/shader_object/shader_object.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/samples/extensions/shader_object/shader_object.cpp b/samples/extensions/shader_object/shader_object.cpp index 8981f977e..1144d1e59 100644 --- a/samples/extensions/shader_object/shader_object.cpp +++ b/samples/extensions/shader_object/shader_object.cpp @@ -1,5 +1,6 @@ /* * Copyright 2023 Nintendo + * Copyright 2023, Sascha Willems * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,10 +172,6 @@ bool ShaderObject::prepare(const vkb::ApplicationOptions &options) camera.set_rotation({19.f, 312.f, 0.f}); camera.set_perspective(60.f, static_cast(width) / static_cast(height), 1024.f, 0.1f); - // For UI need to setup FBO and render pass - setup_framebuffer(); - setup_render_pass(); - // Setup resources for sample create_default_sampler(); load_assets(); @@ -410,6 +407,7 @@ void ShaderObject::load_assets() VkSamplerCreateInfo sampler_create_info = vkb::initializers::sampler_create_info(); // Setup a mirroring sampler for the height map + vkDestroySampler(get_device().get_handle(), heightmap_texture.sampler, nullptr); sampler_create_info.magFilter = VK_FILTER_LINEAR; sampler_create_info.minFilter = VK_FILTER_LINEAR; sampler_create_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; @@ -423,6 +421,7 @@ void ShaderObject::load_assets() VK_CHECK(vkCreateSampler(get_device().get_handle(), &sampler_create_info, nullptr, &heightmap_texture.sampler)); // Setup a repeating sampler for the terrain texture layers + vkDestroySampler(get_device().get_handle(), terrain_array_textures.sampler, nullptr); sampler_create_info = vkb::initializers::sampler_create_info(); sampler_create_info.magFilter = VK_FILTER_LINEAR; sampler_create_info.minFilter = VK_FILTER_LINEAR; @@ -1426,8 +1425,8 @@ void ShaderObject::set_initial_state(VkCommandBuffer cmd) const VkViewport viewport = vkb::initializers::viewport(static_cast(width), static_cast(height), 0.0f, 1.0f); const VkRect2D scissor = vkb::initializers::rect2D(width, height, 0, 0); - vkCmdSetViewport(cmd, 0, 1, &viewport); - vkCmdSetScissor(cmd, 0, 1, &scissor); + vkCmdSetViewportWithCountEXT(cmd, 1, &viewport); + vkCmdSetScissorWithCountEXT(cmd, 1, &scissor); } // Rasterization is always enabled