Skip to content
Snippets Groups Projects
Commit dc479587 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#33] Add VertexInput to vk::Format conversion

parent bacca130
No related branches found
No related tags found
1 merge request!29Resolve "Pipeline Buffer Input"
Pipeline #25275 passed
......@@ -3,6 +3,7 @@
#include <unordered_map>
#include <vector>
#include <iostream>
#include <vulkan/vulkan.hpp>
namespace vkcv{
enum class VertexFormat{
......@@ -33,5 +34,6 @@ namespace vkcv{
uint32_t stride;
};
// currently assuming default 32 bit formats, no lower precision or normalized variants supported
vk::Format vertexFormatToVulkanFormat(const VertexFormat format);
}
\ No newline at end of file
......@@ -79,7 +79,7 @@ namespace vkcv
uint32_t location = attachment.second.location;
uint32_t binding = attachment.second.binding;
uint32_t offset = attachment.second.offset;
VertexFormat format = attachment.second.format; // TODO: Format -> Where does this belong? -> This is not compatible with vk::Format
vk::Format vertexFormat = vertexFormatToVulkanFormat(attachment.second.format);
vertexBindingDescriptions.push_back({binding, layout.stride, vk::VertexInputRate::eVertex}); // TODO: What's about the input rate?
vertexAttributeDescriptions.push_back({location, binding, vk::Format::eR32G32B32Sfloat, offset});
}
......
......@@ -50,4 +50,18 @@ namespace vkcv {
}
}
vk::Format vertexFormatToVulkanFormat(const VertexFormat format) {
switch (format) {
case VertexFormat::FLOAT : return vk::Format::eR32Sfloat;
case VertexFormat::FLOAT2 : return vk::Format::eR32G32Sfloat;
case VertexFormat::FLOAT3 : return vk::Format::eR32G32B32Sfloat;
case VertexFormat::FLOAT4 : return vk::Format::eR32G32B32A32Sfloat;
case VertexFormat::INT : return vk::Format::eR32Sint;
case VertexFormat::INT2 : return vk::Format::eR32G32Sint;
case VertexFormat::INT3 : return vk::Format::eR32G32B32Sint;
case VertexFormat::INT4 : return vk::Format::eR32G32B32A32Sint;
default: std::cerr << "Warning: Unknown vertex format" << std::endl; return vk::Format::eUndefined;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment