Skip to content
Snippets Groups Projects
Verified Commit f85a24e3 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#79] Fix for stride zero

parent 74a935a9
No related branches found
No related tags found
1 merge request!69Resolve "Rework Asset Loader API"
Pipeline #26459 passed
......@@ -32,7 +32,7 @@ namespace vkcv::asset {
* @param type The accessor type
* @return An unsigned integer count
*/
static uint8_t getComponentCount(const fx::gltf::Accessor::Type type) {
static uint32_t getComponentCount(const fx::gltf::Accessor::Type type) {
switch (type) {
case fx::gltf::Accessor::Type::Scalar:
return 1;
......@@ -52,6 +52,22 @@ namespace vkcv::asset {
return 0;
}
}
static uint32_t getComponentSize(ComponentType type) {
switch (type) {
case ComponentType::INT8:
case ComponentType::UINT8:
return 1;
case ComponentType::INT16:
case ComponentType::UINT16:
return 2;
case ComponentType::UINT32:
case ComponentType::FLOAT32:
return 4;
default:
return 0;
}
}
/**
* Translate the component type used in the index accessor of fx-gltf to our
......@@ -124,6 +140,11 @@ namespace vkcv::asset {
att.stride = buf.byteStride;
att.componentType = static_cast<ComponentType>(accessor.componentType);
att.componentCount = getComponentCount(accessor.type);
/* Assume tightly packed stride as not explicitly provided */
if (att.stride == 0) {
att.stride = att.componentCount * getComponentSize(att.componentType);
}
}
if ((att.type == PrimitiveType::UNDEFINED) ||
......
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