Skip to content

Commit

Permalink
Fix validation errors and issues in shader objects sample (KhronosGro…
Browse files Browse the repository at this point in the history
…up#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
  • Loading branch information
SaschaWillems authored Dec 18, 2023
1 parent 41344ab commit d9a6b10
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions samples/extensions/shader_object/shader_object.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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<float>(width) / static_cast<float>(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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1426,8 +1425,8 @@ void ShaderObject::set_initial_state(VkCommandBuffer cmd)
const VkViewport viewport = vkb::initializers::viewport(static_cast<float>(width), static_cast<float>(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
Expand Down

0 comments on commit d9a6b10

Please sign in to comment.