Skip to content
Snippets Groups Projects
Commit c2596c02 authored by Trevor Hollmann's avatar Trevor Hollmann
Browse files

[#63] Add convenience enum for vertex component type.

As requested by @tfrish in mattermost. That's only the additions in
lines 16..24. The rest of the changes are a clean-up of spaces and tabs.
parent a8140303
No related branches found
No related tags found
1 merge request!51Resolve "Laden mehrer Meshes mit Materials und Textures"
Pipeline #25451 passed
...@@ -6,50 +6,56 @@ ...@@ -6,50 +6,56 @@
namespace vkcv{ namespace vkcv{
/* With these enums, 0 is reserved to signal uninitialized or invalid data. */ /* With these enums, 0 is reserved to signal uninitialized or invalid data. */
enum class PrimitiveType : uint32_t { enum class PrimitiveType : uint32_t {
UNDEFINED = 0, UNDEFINED = 0,
POSITION = 1, POSITION = 1,
NORMAL = 2, NORMAL = 2,
TEXCOORD_0 = 3 TEXCOORD_0 = 3
}; };
/* This struct describes one vertex attribute of a vertex buffer. */
typedef struct { /* These integer values are used the same way in OpenGL, Vulkan and glTF. This
PrimitiveType type; // POSITION, NORMAL, ... * enum is not needed for translation, it's only for the programmers
uint32_t offset; // offset in bytes * convenience (easier to read in if/switch statements etc). While this enum
uint32_t length; // length of ... in bytes * exists in (almost) the same definition in the fx-gltf library, we want to
uint32_t stride; // stride in bytes * avoid exposing that dependency, thus it is re-defined here. */
uint16_t componentType; // eg. 5126 for float enum class VertexComponentType : uint16_t {
uint8_t componentCount; // eg. 3 for vec3 NONE=0, INT8=5120, UINT8=5121, INT16=5122, UINT16=5123,
} VertexAttribute; UINT32=5125, FLOAT32=5126
};
enum class VertexFormat{
FLOAT, /* This struct describes one vertex attribute of a vertex buffer. */
FLOAT2, typedef struct {
FLOAT3, PrimitiveType type; // POSITION, NORMAL, ...
FLOAT4, uint32_t offset; // offset in bytes
INT, uint32_t length; // length of ... in bytes
INT2, uint32_t stride; // stride in bytes
INT3, uint16_t componentType; // eg. 5126 for float
INT4 uint8_t componentCount; // eg. 3 for vec3
}; } VertexAttribute;
uint32_t getFormatSize(VertexFormat format); enum class VertexFormat {
FLOAT, FLOAT2, FLOAT3, FLOAT4,
struct VertexInputAttachment{ INT, INT2, INT3, INT4
VertexInputAttachment() = delete; };
VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept;
uint32_t getFormatSize(VertexFormat format);
uint32_t location;
uint32_t binding; struct VertexInputAttachment{
VertexFormat format; VertexInputAttachment() = delete;
uint32_t offset; VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept;
};
uint32_t location;
struct VertexLayout{ uint32_t binding;
VertexLayout() noexcept; VertexFormat format;
VertexLayout(const std::vector<VertexInputAttachment> &inputs) noexcept; uint32_t offset;
std::unordered_map<uint32_t, VertexInputAttachment> attachmentMap; };
uint32_t stride;
}; struct VertexLayout{
} VertexLayout() noexcept;
\ No newline at end of file VertexLayout(const std::vector<VertexInputAttachment> &inputs) noexcept;
std::unordered_map<uint32_t, VertexInputAttachment> attachmentMap;
uint32_t stride;
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment