diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ac20ef2..241afc51c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ set(NAME VulkanCppExamples) include(${CMAKE_SOURCE_DIR}/cmake/ezvcpkg/ezvcpkg.cmake) ezvcpkg_fetch( + COMMIT af2287382b1991dbdcb7e5112d236f3323b9dd7a PACKAGES assimp basisu imgui glad glfw3 gli glm vulkan UPDATE_TOOLCHAIN ) diff --git a/base/common.hpp b/base/common.hpp index 4f82af2e4..776735df1 100644 --- a/base/common.hpp +++ b/base/common.hpp @@ -54,6 +54,15 @@ // Vulkan! #include +#include "keycodes.hpp" +#if defined(__ANDROID__) +#include "android.hpp" +#else +#include "gl.hpp" +// Cross platform window management (except android) +#include "glfw/glfw.hpp" +#endif + using glm::ivec2; using glm::mat3; using glm::mat4; @@ -96,15 +105,6 @@ class Vectors { static const vec3 ZERO4; }; -#include "keycodes.hpp" -#if defined(__ANDROID__) -#include "android.hpp" - -#else -#include "gl.hpp" -// Cross platform window management (except android) -#include "glfw/glfw.hpp" -#endif // Boilerplate for running an example #if defined(__ANDROID__) diff --git a/base/ui.cpp b/base/ui.cpp index dfd0fec2f..5e5038d64 100644 --- a/base/ui.cpp +++ b/base/ui.cpp @@ -19,8 +19,8 @@ using namespace vkx; using namespace vkx::ui; -void UIOverlay::create(const UIOverlayCreateInfo& createInfo) { - this->createInfo = createInfo; +void UIOverlay::create(const UIOverlayCreateInfo& createInfo_) { + createInfo = createInfo_; #if defined(__ANDROID__) // Screen density if (vkx::android::screenDensity >= ACONFIGURATION_DENSITY_XXXHIGH) { @@ -62,6 +62,7 @@ void UIOverlay::create(const UIOverlayCreateInfo& createInfo) { /** Free up all Vulkan resources acquired by the UI overlay */ UIOverlay::~UIOverlay() { + destroy(); } void UIOverlay::destroy() { @@ -79,6 +80,7 @@ void UIOverlay::destroy() { context.device.freeCommandBuffers(commandPool, cmdBuffers); context.device.destroyCommandPool(commandPool); context.device.destroyFence(fence); + commandPool = nullptr; } } @@ -217,7 +219,7 @@ void UIOverlay::preparePipeline() { /** Prepare a separate render pass for rendering the UI as an overlay */ void UIOverlay::prepareRenderPass() { - vk::AttachmentDescription attachments[2] = {}; + std::array attachments; // Color attachment attachments[0].format = createInfo.colorformat; @@ -236,7 +238,7 @@ void UIOverlay::prepareRenderPass() { vk::AttachmentReference colorReference{ 0, vk::ImageLayout::eColorAttachmentOptimal }; vk::AttachmentReference depthReference{ 1, vk::ImageLayout::eDepthStencilAttachmentOptimal }; - vk::SubpassDependency subpassDependencies[2]; + std::array subpassDependencies; // Transition from final to initial (VK_SUBPASS_EXTERNAL refers to all commmands executed outside of the actual renderpass) subpassDependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; @@ -263,11 +265,11 @@ void UIOverlay::prepareRenderPass() { vk::RenderPassCreateInfo renderPassInfo; renderPassInfo.attachmentCount = 2; - renderPassInfo.pAttachments = attachments; + renderPassInfo.pAttachments = attachments.data(); renderPassInfo.subpassCount = 1; renderPassInfo.pSubpasses = &subpassDescription; renderPassInfo.dependencyCount = 2; - renderPassInfo.pDependencies = subpassDependencies; + renderPassInfo.pDependencies = subpassDependencies.data(); renderPass = context.device.createRenderPass(renderPassInfo); } @@ -292,7 +294,7 @@ void UIOverlay::updateCommandBuffers() { if (cmdBuffers.size()) { context.trashAll(cmdBuffers, - [&](const std::vector& buffers) { context.device.freeCommandBuffers(commandPool, buffers); }); + [this](const std::vector& buffers) { context.device.freeCommandBuffers(commandPool, buffers); }); cmdBuffers.clear(); } @@ -404,8 +406,8 @@ void UIOverlay::update() { } // Upload data - ImDrawVert* vtxDst = (ImDrawVert*)vertexBuffer.mapped; - ImDrawIdx* idxDst = (ImDrawIdx*)indexBuffer.mapped; + auto vtxDst = (ImDrawVert*)vertexBuffer.mapped; + auto idxDst = (ImDrawIdx*)indexBuffer.mapped; for (int n = 0; n < imDrawData->CmdListsCount; n++) { const ImDrawList* cmd_list = imDrawData->CmdLists[n]; @@ -465,8 +467,8 @@ bool UIOverlay::checkBox(const char* caption, int32_t* value) const { return res; } -bool UIOverlay::inputFloat(const char* caption, float* value, float step, uint32_t precision) const { - return ImGui::InputFloat(caption, value, step, step * 10.0f, precision); +bool UIOverlay::inputFloat(const char* caption, float* value, float step, const char* format) const { + return ImGui::InputFloat(caption, value, step, step * 10.0f, format); } bool UIOverlay::sliderFloat(const char* caption, float* value, float min, float max) const { @@ -486,7 +488,7 @@ bool UIOverlay::comboBox(const char* caption, int32_t* itemindex, const std::vec for (size_t i = 0; i < items.size(); i++) { charitems.push_back(items[i].c_str()); } - uint32_t itemCount = static_cast(charitems.size()); + auto itemCount = static_cast(charitems.size()); return ImGui::Combo(caption, itemindex, &charitems[0], itemCount, itemCount); } diff --git a/base/ui.hpp b/base/ui.hpp index b6c75da17..c44761f8e 100644 --- a/base/ui.hpp +++ b/base/ui.hpp @@ -53,7 +53,8 @@ class UIOverlay { struct PushConstBlock { glm::vec2 scale; glm::vec2 translate; - } pushConstBlock; + }; + PushConstBlock pushConstBlock; void prepareResources(); void preparePipeline(); @@ -66,7 +67,7 @@ class UIOverlay { std::vector cmdBuffers; - UIOverlay(const vks::Context& context) + explicit UIOverlay(const vks::Context& context) : context(context) {} ~UIOverlay(); @@ -81,7 +82,7 @@ class UIOverlay { bool header(const char* caption) const; bool checkBox(const char* caption, bool* value) const; bool checkBox(const char* caption, int32_t* value) const; - bool inputFloat(const char* caption, float* value, float step, uint32_t precision) const; + bool inputFloat(const char* caption, float* value, float step, const char* precision = "%.3f") const; bool sliderFloat(const char* caption, float* value, float min, float max) const; bool sliderInt(const char* caption, int32_t* value, int32_t min, int32_t max) const; bool comboBox(const char* caption, int32_t* itemindex, const std::vector& items) const; diff --git a/base/vks/filesystem.cpp b/base/vks/filesystem.cpp index 2e8e8e8d7..d844cd415 100644 --- a/base/vks/filesystem.cpp +++ b/base/vks/filesystem.cpp @@ -10,18 +10,18 @@ namespace vks { namespace file { -void withBinaryFileContents(const std::string& filename, std::function handler) { - withBinaryFileContents(filename, [&](const char* filename, size_t size, const void* data) { handler(size, data); }); +void withBinaryFileContents(const std::string& filename, const SimpleHandler& handler) { + withBinaryFileContents(filename, [&handler](const char*, size_t size, const void* data_) { handler(size, data_); }); } -void withBinaryFileContents(const std::string& filename, std::function handler) { +void withBinaryFileContents(const std::string& filename, const NamedHandler& handler) { auto storage = storage::Storage::readFile(filename); handler(filename.c_str(), storage->size(), storage->data()); } std::vector readBinaryFile(const std::string& filename) { std::vector result; - withBinaryFileContents(filename, [&](size_t size, const void* data) { + withBinaryFileContents(filename, [&result](size_t size, const void* data) { result.resize(size); memcpy(result.data(), data, size); }); @@ -33,7 +33,7 @@ std::string readTextFile(const std::string& fileName) { std::ifstream fileStream(fileName, std::ios::in); if (!fileStream.is_open()) { - throw std::runtime_error("File " + fileName + " not found"); + throw std::invalid_argument("File " + fileName + " not found"); } std::string line = ""; while (!fileStream.eof()) { diff --git a/base/vks/filesystem.hpp b/base/vks/filesystem.hpp index 03f172b40..8e72fb819 100644 --- a/base/vks/filesystem.hpp +++ b/base/vks/filesystem.hpp @@ -7,9 +7,12 @@ namespace vks { namespace file { -void withBinaryFileContents(const std::string& filename, std::function handler); +using SimpleHandler = std::function; +using NamedHandler = std::function; -void withBinaryFileContents(const std::string& filename, std::function handler); +void withBinaryFileContents(const std::string& filename, const SimpleHandler& handler); + +void withBinaryFileContents(const std::string& filename, const NamedHandler& handler); std::string readTextFile(const std::string& fileName); diff --git a/base/vks/model.cpp b/base/vks/model.cpp index 4afe1ade0..8c75f710c 100644 --- a/base/vks/model.cpp +++ b/base/vks/model.cpp @@ -21,8 +21,8 @@ using namespace vks::model; const int Model::defaultFlags = aiProcess_FlipWindingOrder | aiProcess_Triangulate | aiProcess_PreTransformVertices | aiProcess_CalcTangentSpace | aiProcess_GenSmoothNormals; -void Model::loadFromFile(const Context& context, const std::string& filename, const VertexLayout& layout, const ModelCreateInfo& createInfo, const int flags) { - this->layout = layout; +void Model::loadFromFile(const Context& context, const std::string& filename, const VertexLayout& layout_, const ModelCreateInfo& createInfo, const int flags) { + layout = layout_; scale = createInfo.scale; uvscale = createInfo.uvscale; center = createInfo.center; @@ -32,15 +32,14 @@ void Model::loadFromFile(const Context& context, const std::string& filename, co Assimp::Importer importer; const aiScene* pScene; - // Load file - vks::file::withBinaryFileContents(filename, [&](const char* filename, size_t size, const void* data) { - pScene = importer.ReadFileFromMemory(data, size, flags, filename); + vks::file::withBinaryFileContents(filename, [flags, &pScene, &importer](const char* filename_, size_t size, const void* data) { + pScene = importer.ReadFileFromMemory(data, size, flags, filename_); }); if (!pScene) { std::string error = importer.GetErrorString(); - throw std::runtime_error( + throw std::invalid_argument( error + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version."); } @@ -158,6 +157,9 @@ void Model::appendVertex(std::vector& outputBuffer, const aiScene* pSce vertexBuffer.push_back(0.0f); vertexBuffer.push_back(0.0f); break; + default: + throw new std::invalid_argument("Bad case"); + }; } appendOutput(outputBuffer, vertexBuffer); diff --git a/base/vks/pipelines.hpp b/base/vks/pipelines.hpp index 9ba960502..dbb66f019 100644 --- a/base/vks/pipelines.hpp +++ b/base/vks/pipelines.hpp @@ -3,6 +3,7 @@ #include "context.hpp" #include "model.hpp" #include "shaders.hpp" +#include namespace vks { namespace pipelines { struct PipelineRasterizationStateCreateInfo : public vk::PipelineRasterizationStateCreateInfo { @@ -72,7 +73,7 @@ struct PipelineVertexInputStateCreateInfo : public vk::PipelineVertexInputStateC auto attributeIndexOffset = (uint32_t)attributeDescriptions.size(); for (uint32_t i = 0; i < componentsSize; ++i) { const auto& component = vertexLayout.components[i]; - const auto format = vertexLayout.componentFormat(component); + const auto format = vks::model::VertexLayout::componentFormat(component); const auto offset = vertexLayout.offset(i); attributeDescriptions.emplace_back(attributeIndexOffset + i, binding, format, offset); } @@ -188,7 +189,7 @@ struct GraphicsPipelineBuilder { vk::Pipeline create(const vk::PipelineCache& cache) { update(); - return device.createGraphicsPipeline(cache, pipelineCreateInfo); + return device.createGraphicsPipeline(cache, pipelineCreateInfo).value; } vk::Pipeline create() { return create(pipelineCache); } diff --git a/base/vulkanExampleBase.cpp b/base/vulkanExampleBase.cpp index d06950096..8efca14d2 100644 --- a/base/vulkanExampleBase.cpp +++ b/base/vulkanExampleBase.cpp @@ -242,9 +242,9 @@ void ExampleBase::renderLoop() { } std::string ExampleBase::getWindowTitle() { - std::string device(context.deviceProperties.deviceName); + std::string deviceName = context.deviceProperties.deviceName; std::string windowTitle; - windowTitle = title + " - " + device + " - " + std::to_string(frameCounter) + " fps"; + windowTitle = title + " - " + deviceName + " - " + std::to_string(frameCounter) + " fps"; return windowTitle; } @@ -665,7 +665,7 @@ void ExampleBase::updateOverlay() { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); ImGui::SetNextWindowPos(ImVec2(10, 10)); - ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiSetCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_FirstUseEver); ImGui::Begin("Vulkan Example", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); ImGui::TextUnformatted(title.c_str()); ImGui::TextUnformatted(context.deviceProperties.deviceName); diff --git a/cmake/ezvcpkg/ezvcpkg.cmake b/cmake/ezvcpkg/ezvcpkg.cmake index 3ea0860c4..662eedfa8 100644 --- a/cmake/ezvcpkg/ezvcpkg.cmake +++ b/cmake/ezvcpkg/ezvcpkg.cmake @@ -107,7 +107,7 @@ macro(EZVCPKG_BOOTSTRAP) # present and the user will have the default checkout, rather than their requested commit message(STATUS "EZVCPKG Checking out commit ${EZVCPKG_COMMIT}") execute_process( - COMMAND ${GIT_EXECUTABLE} "checkout" ${EZVCPKG_COMMIT} + COMMAND ${GIT_EXECUTABLE} "-c" "advice.detachedHead=false" "checkout" ${EZVCPKG_COMMIT} WORKING_DIRECTORY ${EZVCPKG_DIR} OUTPUT_QUIET) endif() diff --git a/cmake/macros/TargetAssimp.cmake b/cmake/macros/TargetAssimp.cmake index e6dcc9df4..1f359ff8c 100644 --- a/cmake/macros/TargetAssimp.cmake +++ b/cmake/macros/TargetAssimp.cmake @@ -5,8 +5,9 @@ # Distributed under the Apache License, Version 2.0. # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # + macro(TARGET_ASSIMP) - find_package(ASSIMP CONFIG REQUIRED) - target_include_directories(${TARGET_NAME} PUBLIC ${ASSIMP_INCLUDE_DIRS}) - target_link_libraries(${TARGET_NAME} PRIVATE ${ASSIMP_LIBRARIES}) + find_package(assimp REQUIRED) + target_include_directories(${TARGET_NAME} PUBLIC assimp::assimp) + target_link_libraries(${TARGET_NAME} PRIVATE assimp::assimp) endmacro() diff --git a/cmake/macros/TargetGlm.cmake b/cmake/macros/TargetGlm.cmake index ae03ef605..4d1b222fd 100644 --- a/cmake/macros/TargetGlm.cmake +++ b/cmake/macros/TargetGlm.cmake @@ -1,6 +1,6 @@ macro(TARGET_GLM) find_package(glm CONFIG REQUIRED) - target_link_libraries(${TARGET_NAME} PUBLIC glm) + target_link_libraries(${TARGET_NAME} PUBLIC glm::glm) target_compile_definitions(${TARGET_NAME} PUBLIC GLM_FORCE_RADIANS) target_compile_definitions(${TARGET_NAME} PUBLIC GLM_FORCE_CTOR_INIT) endmacro() diff --git a/examples/bloom/bloom.cpp b/examples/bloom/bloom.cpp index 904ff28f4..779834ace 100644 --- a/examples/bloom/bloom.cpp +++ b/examples/bloom/bloom.cpp @@ -432,7 +432,7 @@ class VulkanExample : public vkx::OffscreenExampleBase { if (ui.checkBox("Bloom", &bloom)) { buildCommandBuffers(); } - if (ui.inputFloat("Scale", &ubos.blurParams.blurScale, 0.1f, 2)) { + if (ui.inputFloat("Scale", &ubos.blurParams.blurScale, 0.1f, "%.2f")) { updateUniformBuffersBlur(); } } diff --git a/examples/computecloth/computecloth.cpp b/examples/computecloth/computecloth.cpp index 3aefc4514..766dee08e 100644 --- a/examples/computecloth/computecloth.cpp +++ b/examples/computecloth/computecloth.cpp @@ -116,7 +116,7 @@ struct Compute : public vkx::Compute { computePipelineCreateInfo.layout = pipelineLayout; computePipelineCreateInfo.stage = vks::shaders::loadShader(context.device, vkx::getAssetPath() + "shaders/computecloth/cloth.comp.spv", vk::ShaderStageFlagBits::eCompute); - pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); } diff --git a/examples/computecullandlod/computecullandlod.cpp b/examples/computecullandlod/computecullandlod.cpp index 0d1f0353b..4cadc6bdb 100644 --- a/examples/computecullandlod/computecullandlod.cpp +++ b/examples/computecullandlod/computecullandlod.cpp @@ -152,7 +152,7 @@ struct Compute : public vkx::Compute { specializationInfo.pData = &specializationData; computePipelineCreateInfo.stage.pSpecializationInfo = &specializationInfo; - pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); } @@ -272,7 +272,7 @@ class VulkanExample : public vkx::ExampleBase { } } - void updateDrawCommandBuffer(const vk::CommandBuffer& drawCommandBuffer) { + void updateDrawCommandBuffer(const vk::CommandBuffer& drawCommandBuffer) override { drawCommandBuffer.setViewport(0, viewport()); drawCommandBuffer.setScissor(0, scissor()); drawCommandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, descriptorSet, nullptr); @@ -451,7 +451,7 @@ class VulkanExample : public vkx::ExampleBase { compute.uniformData.scene.copy(uboScene); } - void draw() { + void draw() override { ExampleBase::prepareFrame(); // Submit compute shader for frustum culling diff --git a/examples/computeheadless/computeheadless.cpp b/examples/computeheadless/computeheadless.cpp index fab77e52c..0f8e7e711 100644 --- a/examples/computeheadless/computeheadless.cpp +++ b/examples/computeheadless/computeheadless.cpp @@ -51,7 +51,7 @@ class VulkanExample { #endif context.createInstance(); context.createDevice(); - LOG("GPU: %s\n", context.deviceProperties.deviceName); + LOG("GPU: %s\n", context.deviceProperties.deviceName.data()); // Get a compute queue queue = context.device.getQueue(context.queueIndices.compute, 0); @@ -117,7 +117,7 @@ class VulkanExample { vk::SpecializationMapEntry specializationMapEntry{ 0, 0, sizeof(uint32_t) }; vk::SpecializationInfo specializationInfo{ 1, &specializationMapEntry, sizeof(SpecializationData), &specializationData }; computePipelineCreateInfo.stage.pSpecializationInfo = &specializationInfo; - pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); } diff --git a/examples/computenbody/computenbody.cpp b/examples/computenbody/computenbody.cpp index 8c3f30807..9e615ed17 100644 --- a/examples/computenbody/computenbody.cpp +++ b/examples/computenbody/computenbody.cpp @@ -130,12 +130,12 @@ class ComputeNBody : public vkx::Compute { vk::SpecializationInfo specializationInfo{ static_cast(specializationMapEntries.size()), specializationMapEntries.data(), sizeof(specializationData), &specializationData }; computePipelineCreateInfo.stage.pSpecializationInfo = &specializationInfo; - pipelineCalculate = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipelineCalculate = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); // 2nd pass computePipelineCreateInfo.stage = vks::shaders::loadShader(device, vkx::getAssetPath() + "shaders/computenbody/particle_integrate.comp.spv", vk::ShaderStageFlagBits::eCompute); - pipelineIntegrate = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipelineIntegrate = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); // Create a command buffer for compute operations diff --git a/examples/computeparticles/computeparticles.cpp b/examples/computeparticles/computeparticles.cpp index bb75161b7..feeceafcf 100644 --- a/examples/computeparticles/computeparticles.cpp +++ b/examples/computeparticles/computeparticles.cpp @@ -107,7 +107,7 @@ class ComputeParticles : public vkx::Compute { computePipelineCreateInfo.stage = vks::shaders::loadShader(device, vkx::getAssetPath() + "shaders/computeparticles/particle.comp.spv", vk::ShaderStageFlagBits::eCompute); - pipeline = device.createComputePipelines(context.pipelineCache, computePipelineCreateInfo)[0]; + pipeline = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; device.destroyShaderModule(computePipelineCreateInfo.stage.module); } diff --git a/examples/computeshader/computeshader.cpp b/examples/computeshader/computeshader.cpp index 66e921f0f..03ac701eb 100644 --- a/examples/computeshader/computeshader.cpp +++ b/examples/computeshader/computeshader.cpp @@ -104,7 +104,7 @@ class ComputeImage : public vkx::Compute { for (auto& shaderName : shaderNames) { std::string fileName = vkx::getAssetPath() + "shaders/computeshader/" + shaderName + ".comp.spv"; computePipelineCreateInfo.stage = vks::shaders::loadShader(device, fileName.c_str(), vk::ShaderStageFlagBits::eCompute); - pipelines.push_back(device.createComputePipelines(context.pipelineCache, computePipelineCreateInfo, nullptr)[0]); + pipelines.push_back(device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo, nullptr).value); device.destroyShaderModule(computePipelineCreateInfo.stage.module); } diff --git a/examples/context/context.cpp b/examples/context/context.cpp index fd0d6819b..ea1be5a25 100644 --- a/examples/context/context.cpp +++ b/examples/context/context.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include namespace vkx { diff --git a/examples/displacement/displacement.cpp b/examples/displacement/displacement.cpp index a324525f2..2f856b82b 100644 --- a/examples/displacement/displacement.cpp +++ b/examples/displacement/displacement.cpp @@ -9,7 +9,7 @@ #include // Vertex layout for this example -vks::model::VertexLayout vertexLayout{ { +const vks::model::VertexLayout vertexLayout{ { vks::model::Component::VERTEX_COMPONENT_POSITION, vks::model::Component::VERTEX_COMPONENT_NORMAL, vks::model::Component::VERTEX_COMPONENT_UV, @@ -267,10 +267,10 @@ class VulkanExample : public vkx::ExampleBase { if (ui.checkBox("Tessellation displacement", &displacement)) { updateUniformBuffers(); } - if (ui.inputFloat("Strength", &uboTessEval.tessStrength, 0.025f, 3)) { + if (ui.inputFloat("Strength", &uboTessEval.tessStrength, 0.025f)) { updateUniformBuffers(); } - if (ui.inputFloat("Level", &uboTessControl.tessLevel, 0.5f, 2)) { + if (ui.inputFloat("Level", &uboTessControl.tessLevel, 0.5f, "%.2f")) { updateUniformBuffers(); } if (deviceFeatures.fillModeNonSolid) { diff --git a/examples/hdr/hdr.cpp b/examples/hdr/hdr.cpp index f996f44a3..c7dbb80a8 100644 --- a/examples/hdr/hdr.cpp +++ b/examples/hdr/hdr.cpp @@ -644,7 +644,7 @@ class VulkanExample : public vkx::ExampleBase { updateUniformBuffers(); buildDeferredCommandBuffer(); } - if (ui.inputFloat("Exposure", &uboParams.exposure, 0.025f, 3)) { + if (ui.inputFloat("Exposure", &uboParams.exposure, 0.025f)) { updateParams(); } if (ui.checkBox("Bloom", &bloom)) { diff --git a/examples/occlusionquery/occlusionquery.cpp b/examples/occlusionquery/occlusionquery.cpp index 56802339a..55241515d 100644 --- a/examples/occlusionquery/occlusionquery.cpp +++ b/examples/occlusionquery/occlusionquery.cpp @@ -60,7 +60,7 @@ class VulkanExample : public vkx::ExampleBase { vk::QueryPool queryPool; // Passed query samples - std::array passedSamples{ 1, 1 }; + std::vector passedSamples{ 1, 1 }; VulkanExample() { passedSamples[0] = passedSamples[1] = 1; @@ -118,7 +118,8 @@ class VulkanExample : public vkx::ExampleBase { // We use vkGetQueryResults to copy the results into a host visible buffer // you can use vk::QueryResultFlagBits::eWithAvailability // which also returns the state of the result (ready) in the result - device.getQueryPoolResults(queryPool, 0, 2, vk::ArrayProxy{ passedSamples }, sizeof(uint64_t), queryResultFlags); + passedSamples = device.getQueryPoolResults(queryPool, 0, 2, 2 * sizeof(uint64_t), sizeof(uint64_t), queryResultFlags).value; + //vk::ArrayProxy{ passedSamples }; } void updateCommandBufferPreDraw(const vk::CommandBuffer& cmdBuffer) override { diff --git a/examples/pbribl/pbribl.cpp b/examples/pbribl/pbribl.cpp index a9bfed27c..801a798fe 100644 --- a/examples/pbribl/pbribl.cpp +++ b/examples/pbribl/pbribl.cpp @@ -353,10 +353,10 @@ class VulkanExample : public vkx::ExampleBase { updateUniformBuffers(); buildCommandBuffers(); } - if (ui.inputFloat("Exposure", &uboParams.exposure, 0.1f, 2)) { + if (ui.inputFloat("Exposure", &uboParams.exposure, 0.1f, "%.2f")) { updateParams(); } - if (ui.inputFloat("Gamma", &uboParams.gamma, 0.1f, 2)) { + if (ui.inputFloat("Gamma", &uboParams.gamma, 0.1f, "%.2f")) { updateParams(); } if (ui.checkBox("Skybox", &displaySkybox)) { diff --git a/examples/pbrtexture/pbrtexture.cpp b/examples/pbrtexture/pbrtexture.cpp index 8f70aea3c..b92078063 100644 --- a/examples/pbrtexture/pbrtexture.cpp +++ b/examples/pbrtexture/pbrtexture.cpp @@ -277,10 +277,10 @@ class VulkanExample : public vkx::ExampleBase { void OnUpdateUIOverlay() override { if (ui.header("Settings")) { - if (ui.inputFloat("Exposure", &uboParams.exposure, 0.1f, 2)) { + if (ui.inputFloat("Exposure", &uboParams.exposure, 0.1f, "%.2f")) { updateParams(); } - if (ui.inputFloat("Gamma", &uboParams.gamma, 0.1f, 2)) { + if (ui.inputFloat("Gamma", &uboParams.gamma, 0.1f, "%.2f")) { updateParams(); } if (ui.checkBox("Skybox", &displaySkybox)) { diff --git a/examples/pipelinestatistics/pipelinestatistics.cpp b/examples/pipelinestatistics/pipelinestatistics.cpp index 8b95e204e..e3e82a418 100644 --- a/examples/pipelinestatistics/pipelinestatistics.cpp +++ b/examples/pipelinestatistics/pipelinestatistics.cpp @@ -127,12 +127,12 @@ class VulkanExample : public vkx::ExampleBase { device.getQueryPoolResults(queryPool, 0, 1, pipelineStats, sizeof(uint64_t), vk::QueryResultFlagBits::e64); } - void updateCommandBufferPreDraw(const vk::CommandBuffer& drawCmdBuffer) { + void updateCommandBufferPreDraw(const vk::CommandBuffer& drawCmdBuffer) override { // Reset timestamp query pool drawCmdBuffer.resetQueryPool(queryPool, 0, static_cast(pipelineStats.size())); } - void updateDrawCommandBuffer(const vk::CommandBuffer& drawCmdBuffer) { + void updateDrawCommandBuffer(const vk::CommandBuffer& drawCmdBuffer) override { drawCmdBuffer.setViewport(0, viewport()); drawCmdBuffer.setScissor(0, scissor()); @@ -158,7 +158,7 @@ class VulkanExample : public vkx::ExampleBase { drawCmdBuffer.endQuery(queryPool, 0); } - void draw() { + void draw() override { ExampleBase::prepareFrame(); drawCurrentCommandBuffer(); diff --git a/examples/raytracing/raytracing.cpp b/examples/raytracing/raytracing.cpp index 998b0ce8e..41bdb687a 100644 --- a/examples/raytracing/raytracing.cpp +++ b/examples/raytracing/raytracing.cpp @@ -277,7 +277,7 @@ class VulkanExample : public vkx::ExampleBase { computePipelineCreateInfo.layout = computePipelineLayout; computePipelineCreateInfo.stage = vks::shaders::loadShader(device, getAssetPath() + "shaders/raytracing/raytracing.comp.spv", vk::ShaderStageFlagBits::eCompute); - pipelines.compute = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo); + pipelines.compute = device.createComputePipeline(context.pipelineCache, computePipelineCreateInfo).value; } // Prepare and initialize uniform buffer containing shader uniforms diff --git a/examples/stencilbuffer/stencilbuffer.cpp b/examples/stencilbuffer/stencilbuffer.cpp index 392e9e261..25e963f8c 100644 --- a/examples/stencilbuffer/stencilbuffer.cpp +++ b/examples/stencilbuffer/stencilbuffer.cpp @@ -168,7 +168,7 @@ class VulkanExample : public vkx::ExampleBase { void OnUpdateUIOverlay() override { if (ui.header("Settings")) { - if (ui.inputFloat("Outline width", &uboVS.outlineWidth, 0.05f, 2)) { + if (ui.inputFloat("Outline width", &uboVS.outlineWidth, 0.05f, "%.2f")) { updateUniformBuffers(); } } diff --git a/examples/terraintessellation/terraintessellation.cpp b/examples/terraintessellation/terraintessellation.cpp index 02b2b7899..fc486f7a9 100644 --- a/examples/terraintessellation/terraintessellation.cpp +++ b/examples/terraintessellation/terraintessellation.cpp @@ -391,7 +391,7 @@ class VulkanExample : public vkx::ExampleBase { uniformData.skysphereVertex.copy(uboVS); } - void draw() { + void draw() override { ExampleBase::prepareFrame(); drawCurrentCommandBuffer(); @@ -424,7 +424,7 @@ class VulkanExample : public vkx::ExampleBase { if (ui.checkBox("Tessellation", &tessellation)) { updateUniformBuffers(); } - if (ui.inputFloat("Factor", &uboTess.tessellationFactor, 0.05f, 2)) { + if (ui.inputFloat("Factor", &uboTess.tessellationFactor, 0.05f, "%.2f")) { updateUniformBuffers(); } if (deviceFeatures.fillModeNonSolid) { diff --git a/examples/tessellation/tessellation.cpp b/examples/tessellation/tessellation.cpp index 6215da75e..aadd20425 100644 --- a/examples/tessellation/tessellation.cpp +++ b/examples/tessellation/tessellation.cpp @@ -232,7 +232,7 @@ class VulkanExample : public vkx::ExampleBase { virtual void OnUpdateUIOverlay() { if (ui.header("Settings")) { - if (ui.inputFloat("Tessellation level", &uboTC.tessLevel, 0.25f, 2)) { + if (ui.inputFloat("Tessellation level", &uboTC.tessLevel, 0.25f, "%.2f")) { updateUniformBuffers(); } if (deviceFeatures.fillModeNonSolid) { diff --git a/examples/texturesparseresidency/texturesparseresidency.cpp b/examples/texturesparseresidency/texturesparseresidency.cpp index e64a6154d..f525d10ce 100644 --- a/examples/texturesparseresidency/texturesparseresidency.cpp +++ b/examples/texturesparseresidency/texturesparseresidency.cpp @@ -203,7 +203,7 @@ class VulkanExample : public vkx::ExampleBase { uniformBufferVS.destroy(); } - virtual void getEnabledFeatures() { + virtual void getEnabledFeatures() override { if (deviceFeatures.sparseBinding && deviceFeatures.sparseResidencyImage2D) { enabledFeatures.sparseBinding = VK_TRUE; enabledFeatures.sparseResidencyImage2D = VK_TRUE; @@ -524,7 +524,7 @@ class VulkanExample : public vkx::ExampleBase { texture.destroy(); } - void updateDrawCommandBuffer(const vk::CommandBuffer& drawCmdBuffer) { + void updateDrawCommandBuffer(const vk::CommandBuffer& drawCmdBuffer) override { drawCmdBuffer.setViewport(0, viewport()); drawCmdBuffer.setScissor(0, scissor()); drawCmdBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayout, 0, 1, &descriptorSet, 0, NULL); @@ -599,7 +599,7 @@ class VulkanExample : public vkx::ExampleBase { memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS)); } - void prepare() { + void prepare() override { ExampleBase::prepare(); // Check if the GPU supports sparse residency for 2D images if (!context.deviceFeatures.sparseResidencyImage2D) { diff --git a/examples/triangle/triangle.cpp b/examples/triangle/triangle.cpp index 5ae14581d..6c51b5e8b 100644 --- a/examples/triangle/triangle.cpp +++ b/examples/triangle/triangle.cpp @@ -655,7 +655,7 @@ class TriangleExample : public glfw::Window { pipelineCreateInfo.pDynamicState = &dynamicState; // Create rendering pipeline - pipeline = device.createGraphicsPipelines(context.pipelineCache, pipelineCreateInfo, nullptr)[0]; + pipeline = device.createGraphicsPipelines(context.pipelineCache, pipelineCreateInfo, nullptr).value[0]; for (const auto& shaderStage : shaderStages) { device.destroyShaderModule(shaderStage.module);