summaryrefslogtreecommitdiff
path: root/src/entities.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-09-27 16:18:17 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-09-27 16:18:17 -0400
commit104224b9022794fd9eff77154482630bcf18348c (patch)
tree4e456f9350789a29d9f4b828f4fa195728ec3f13 /src/entities.cpp
parentb14582679d0a113cb8571a7e6764436391d6af48 (diff)
align render-time binding indexes with pipeline layout
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 1b85784..5afd985 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -75,26 +75,28 @@ void EntityType_Init() {
const long vertexBindingCount = 4;
long index = 0;
VkVertexInputBindingDescription vertInputBD[vertexBindingCount];
- for (long i = 0; i < vertexBindingCount; ++i) {
- vertInputBD[i].binding = i;
- }
// model vertex
+ vertInputBD[index].binding = index;
vertInputBD[index].stride = sizeof(glm::vec3);
vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
index += 1;
// model normals
+ vertInputBD[index].binding = index;
vertInputBD[index].stride = sizeof(glm::vec3);
vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
index += 1;
// model UV
+ vertInputBD[index].binding = index;
vertInputBD[index].stride = sizeof(glm::vec2);
vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
index += 1;
// model index
+ // vertInputBD[index].binding = index;
// vertInputBD[index].stride = sizeof(uint16_t);
- // vertInputBD[index++].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
+ // vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
// index += 1;
// instance
+ vertInputBD[index].binding = index;
vertInputBD[index].stride = sizeof(glm::vec3) * 3;
vertInputBD[index].inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
@@ -355,6 +357,7 @@ void EntityType_Load(EntityType &et) {
* This should be moved to window.cpp.
*/
grBinds.vkPipelineLayout = vkPipelineLayout_Texture;
+ grBinds.graphicsPipeline = vkPipelines.Texture;
cgltf_options options{};
// TODO allocator
@@ -679,6 +682,7 @@ void EntityType_Load(EntityType &et) {
long index = 0;
if (et.Importer_GLTF.AccessorIndexVertex > -1) {
const auto &acc = gltfData->accessors[et.Importer_GLTF.AccessorIndexVertex];
+ grBinds.vertexFirstBinding = index;
grBinds.vertexBindingCount = 1;
bufferCI.size = acc.buffer_view->size;
bufferCI.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
@@ -688,6 +692,7 @@ void EntityType_Load(EntityType &et) {
}
if (et.Importer_GLTF.AccessorIndexNormal > -1) {
const auto &acc = gltfData->accessors[et.Importer_GLTF.AccessorIndexNormal];
+ grBinds.normalsFirstBinding = index;
grBinds.normalsBindingCount = 1;
bufferCI.size = acc.buffer_view->size;
vkCreateBuffer(vkDevice, &bufferCI, vkAllocator, &grBinds.normalsBuffer);
@@ -696,14 +701,19 @@ void EntityType_Load(EntityType &et) {
}
if (et.Importer_GLTF.AccessorIndexUV > -1) {
const auto &acc = gltfData->accessors[et.Importer_GLTF.AccessorIndexUV];
+ grBinds.uvFirstBinding = index;
grBinds.uvBindingCount = 1;
bufferCI.size = acc.buffer_view->size;
vkCreateBuffer(vkDevice, &bufferCI, vkAllocator, &grBinds.uvBuffer);
vkGetBufferMemoryRequirements(vkDevice, grBinds.uvBuffer, &vkMemoryRequirements[index++]);
}
+ // 2023-09-27 - JCB
+ // I don't know where else to put this
+ grBinds.instanceFirstBinding = index;
if (et.Importer_GLTF.AccessorIndexIndex > -1) {
const auto &acc = gltfData->accessors[et.Importer_GLTF.AccessorIndexIndex];
+ // grBinds.indexFirstBinding = index;
grBinds.indexBindingCount = 1;
grBinds.indexCount = acc.count;
bufferCI.size = acc.buffer_view->size;