From 2b4115d78c837da42ff67e504cfe56b1f6b2ceaf Mon Sep 17 00:00:00 2001 From: Mara Vogt <mvogt@uni-koblenz.de> Date: Sun, 13 Jun 2021 16:41:42 +0200 Subject: [PATCH] [#63]fixed merge mistakes --- include/vkcv/VertexLayout.hpp | 3 ++- modules/asset_loader/src/vkcv/asset/asset_loader.cpp | 6 +++--- projects/cmd_sync_test/src/main.cpp | 11 +++++++---- projects/first_mesh/src/main.cpp | 10 +++++----- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/vkcv/VertexLayout.hpp b/include/vkcv/VertexLayout.hpp index ef40ef6c..247bb478 100644 --- a/include/vkcv/VertexLayout.hpp +++ b/include/vkcv/VertexLayout.hpp @@ -44,10 +44,11 @@ uint32_t getFormatSize(VertexFormat format); struct VertexInputAttachment{ VertexInputAttachment() = delete; - VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept; + VertexInputAttachment(uint32_t location, uint32_t binding, std::string name, VertexFormat format, uint32_t offset) noexcept; uint32_t location; uint32_t binding; + std::string name; VertexFormat format; uint32_t offset; }; diff --git a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp index f9539dcb..b7604092 100644 --- a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp +++ b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp @@ -167,11 +167,11 @@ int loadMesh(const std::string &path, Mesh &mesh) { IndexType indexType; switch(indexAccessor.componentType) { case fx::gltf::Accessor::ComponentType::UnsignedByte: - indexType = UINT8; break; + indexType = IndexType::UINT8; break; case fx::gltf::Accessor::ComponentType::UnsignedShort: - indexType = UINT16; break; + indexType = IndexType::UINT16; break; case fx::gltf::Accessor::ComponentType::UnsignedInt: - indexType = UINT32; break; + indexType = IndexType::UINT32; break; default: vkcv_log(LogLevel::ERROR, "Index type (%u) not supported", static_cast<uint16_t>(indexAccessor.componentType)); diff --git a/projects/cmd_sync_test/src/main.cpp b/projects/cmd_sync_test/src/main.cpp index 2494793f..4c77e6ae 100644 --- a/projects/cmd_sync_test/src/main.cpp +++ b/projects/cmd_sync_test/src/main.cpp @@ -33,10 +33,10 @@ int main(int argc, const char** argv) { { "VK_KHR_swapchain" } ); - vkcv::asset::Mesh mesh; + vkcv::asset::Scene mesh; const char* path = argc > 1 ? argv[1] : "resources/cube/cube.gltf"; - int result = vkcv::asset::loadMesh(path, mesh); + int result = vkcv::asset::loadScene(path, mesh); if (result == 1) { std::cout << "Mesh loading successful!" << std::endl; @@ -121,8 +121,11 @@ int main(int argc, const char** argv) { return EXIT_FAILURE; } - vkcv::Image texture = core.createImage(vk::Format::eR8G8B8A8Srgb, mesh.texture_hack.w, mesh.texture_hack.h); - texture.fill(mesh.texture_hack.img); + //vkcv::Image texture = core.createImage(vk::Format::eR8G8B8A8Srgb, mesh.texture_hack.w, mesh.texture_hack.h); + //texture.fill(mesh.texture_hack.img); + vkcv::asset::Texture &tex = mesh.textures[0]; + vkcv::Image texture = core.createImage(vk::Format::eR8G8B8A8Srgb, tex.w, tex.h); + texture.fill(tex.data.data()); vkcv::SamplerHandle sampler = core.createSampler( vkcv::SamplerFilterType::LINEAR, diff --git a/projects/first_mesh/src/main.cpp b/projects/first_mesh/src/main.cpp index 469c70ed..611ab6cc 100644 --- a/projects/first_mesh/src/main.cpp +++ b/projects/first_mesh/src/main.cpp @@ -103,7 +103,7 @@ int main(int argc, const char** argv) { UINT32_MAX, UINT32_MAX, trianglePass, - mesh.vertexGroups[0].vertexBuffer.attributes, + mesh.vertexGroups[2].vertexBuffer.attributes, { core.getDescriptorSet(descriptorSet).layout }, true); vkcv::PipelineHandle trianglePipeline = core.createGraphicsPipeline(trianglePipelineDefinition); @@ -127,9 +127,9 @@ int main(int argc, const char** argv) { ); const std::vector<vkcv::VertexBufferBinding> vertexBufferBindings = { - vkcv::VertexBufferBinding( mesh.vertexGroups[0].vertexBuffer.attributes[0].offset, vertexBuffer.getVulkanHandle() ), - vkcv::VertexBufferBinding( mesh.vertexGroups[0].vertexBuffer.attributes[1].offset, vertexBuffer.getVulkanHandle() ), - vkcv::VertexBufferBinding( mesh.vertexGroups[0].vertexBuffer.attributes[2].offset, vertexBuffer.getVulkanHandle() ) + vkcv::VertexBufferBinding( mesh.vertexGroups[2].vertexBuffer.attributes[0].offset, vertexBuffer.getVulkanHandle() ), + vkcv::VertexBufferBinding( mesh.vertexGroups[2].vertexBuffer.attributes[1].offset, vertexBuffer.getVulkanHandle() ), + vkcv::VertexBufferBinding( mesh.vertexGroups[2].vertexBuffer.attributes[2].offset, vertexBuffer.getVulkanHandle() ) }; vkcv::DescriptorWrites setWrites; @@ -141,7 +141,7 @@ int main(int argc, const char** argv) { const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle(); - const vkcv::Mesh renderMesh(vertexBufferBindings, indexBuffer.getVulkanHandle(), mesh.vertexGroups[0].numIndices); + const vkcv::Mesh renderMesh(vertexBufferBindings, indexBuffer.getVulkanHandle(), mesh.vertexGroups[2].numIndices); vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSet).vulkanHandle); vkcv::DrawcallInfo drawcall(renderMesh, { descriptorUsage }); -- GitLab