diff --git a/examples/computeparticles/computeparticles.cpp b/examples/computeparticles/computeparticles.cpp index 7e6b9cdb..508724ea 100644 --- a/examples/computeparticles/computeparticles.cpp +++ b/examples/computeparticles/computeparticles.cpp @@ -10,7 +10,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 #if defined(__ANDROID__) // Lower particle count on Android for performance reasons #define PARTICLE_COUNT 128 * 1024 @@ -169,7 +168,7 @@ public: vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, graphics.pipelineLayout, 0, 1, &graphics.descriptorSet, 0, NULL); VkDeviceSize offsets[1] = { 0 }; - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &compute.storageBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &compute.storageBuffer.buffer, offsets); vkCmdDraw(drawCmdBuffers[i], PARTICLE_COUNT, 1, 0, 0); drawUI(drawCmdBuffers[i]); @@ -349,7 +348,7 @@ public: vertices.bindingDescriptions.resize(1); vertices.bindingDescriptions[0] = vks::initializers::vertexInputBindingDescription( - VERTEX_BUFFER_BIND_ID, + 0, sizeof(Particle), VK_VERTEX_INPUT_RATE_VERTEX); @@ -359,14 +358,14 @@ public: // Location 0 : Position vertices.attributeDescriptions[0] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 0, VK_FORMAT_R32G32_SFLOAT, offsetof(Particle, pos)); // Location 1 : Gradient position vertices.attributeDescriptions[1] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 1, VK_FORMAT_R32G32B32A32_SFLOAT, offsetof(Particle, gradientPos)); diff --git a/examples/computeraytracing/computeraytracing.cpp b/examples/computeraytracing/computeraytracing.cpp index 48a3d4b0..c0f6badc 100644 --- a/examples/computeraytracing/computeraytracing.cpp +++ b/examples/computeraytracing/computeraytracing.cpp @@ -8,8 +8,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 - #if defined(__ANDROID__) #define TEX_DIM 1024 #else diff --git a/examples/computeshader/computeshader.cpp b/examples/computeshader/computeshader.cpp index d634fa80..a79be4ff 100644 --- a/examples/computeshader/computeshader.cpp +++ b/examples/computeshader/computeshader.cpp @@ -8,8 +8,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 - // Vertex layout for this example struct Vertex { float pos[3]; @@ -251,7 +249,7 @@ public: vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor); VkDeviceSize offsets[1] = { 0 }; - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &vertexBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &vertexBuffer.buffer, offsets); vkCmdBindIndexBuffer(drawCmdBuffers[i], indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32); // Left (pre compute) @@ -332,16 +330,16 @@ public: { // Binding description vertices.bindingDescriptions = { - vks::initializers::vertexInputBindingDescription(VERTEX_BUFFER_BIND_ID, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX) + vks::initializers::vertexInputBindingDescription(0, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX) }; // Attribute descriptions // Describes memory layout and shader positions vertices.attributeDescriptions = { // Location 0: Position - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)), + vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)), // Location 1: Texture coordinates - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 1, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, uv)), + vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, uv)), }; // Assign to vertex buffer diff --git a/examples/deferredshadows/deferredshadows.cpp b/examples/deferredshadows/deferredshadows.cpp index 3b295fb2..b7ce7b0d 100644 --- a/examples/deferredshadows/deferredshadows.cpp +++ b/examples/deferredshadows/deferredshadows.cpp @@ -10,8 +10,6 @@ #include "VulkanFrameBuffer.hpp" #include "VulkanglTFModel.h" -#define VERTEX_BUFFER_BIND_ID 0 - // Shadowmap properties #if defined(__ANDROID__) #define SHADOWMAP_DIM 1024 diff --git a/examples/distancefieldfonts/distancefieldfonts.cpp b/examples/distancefieldfonts/distancefieldfonts.cpp index 57588e1e..cc6fda4f 100644 --- a/examples/distancefieldfonts/distancefieldfonts.cpp +++ b/examples/distancefieldfonts/distancefieldfonts.cpp @@ -10,8 +10,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 - // Vertex layout for this example struct Vertex { float pos[3]; @@ -222,7 +220,7 @@ public: // Signed distance field font vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets.sdf, 0, NULL); vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.sdf); - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &vertexBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &vertexBuffer.buffer, offsets); vkCmdBindIndexBuffer(drawCmdBuffers[i], indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32); vkCmdDrawIndexed(drawCmdBuffers[i], indexCount, 1, 0, 0, 0); @@ -325,7 +323,7 @@ public: vertices.bindingDescriptions.resize(1); vertices.bindingDescriptions[0] = vks::initializers::vertexInputBindingDescription( - VERTEX_BUFFER_BIND_ID, + 0, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX); @@ -335,14 +333,14 @@ public: // Location 0 : Position vertices.attributeDescriptions[0] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0); // Location 1 : Texture coordinates vertices.attributeDescriptions[1] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 1, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 3); diff --git a/examples/dynamicuniformbuffer/dynamicuniformbuffer.cpp b/examples/dynamicuniformbuffer/dynamicuniformbuffer.cpp index 83870995..893e0e22 100644 --- a/examples/dynamicuniformbuffer/dynamicuniformbuffer.cpp +++ b/examples/dynamicuniformbuffer/dynamicuniformbuffer.cpp @@ -18,7 +18,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 #define OBJECT_INSTANCES 125 // Vertex layout for this example @@ -146,7 +145,7 @@ public: vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); VkDeviceSize offsets[1] = { 0 }; - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &vertexBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &vertexBuffer.buffer, offsets); vkCmdBindIndexBuffer(drawCmdBuffers[i], indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32); // Render multiple objects using different model matrices by dynamically offsetting into one uniform buffer @@ -260,11 +259,11 @@ public: // Vertex bindings and attributes VkVertexInputBindingDescription vertexInputBinding = { - vks::initializers::vertexInputBindingDescription(VERTEX_BUFFER_BIND_ID, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX) + vks::initializers::vertexInputBindingDescription(0, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX) }; std::vector vertexInputAttributes = { - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)), // Location 0 : Position - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 1, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, color)), // Location 1 : Color + vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)), // Location 0 : Position + vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, color)), // Location 1 : Color }; VkPipelineVertexInputStateCreateInfo vertexInputStateCI = vks::initializers::pipelineVertexInputStateCreateInfo(); vertexInputStateCI.vertexBindingDescriptionCount = 1; diff --git a/examples/geometryshader/geometryshader.cpp b/examples/geometryshader/geometryshader.cpp index 9fdfb00c..d245ec54 100644 --- a/examples/geometryshader/geometryshader.cpp +++ b/examples/geometryshader/geometryshader.cpp @@ -9,8 +9,6 @@ #include "vulkanexamplebase.h" #include "VulkanglTFModel.h" -#define VERTEX_BUFFER_BIND_ID 0 - class VulkanExample : public VulkanExampleBase { public: diff --git a/examples/instancing/instancing.cpp b/examples/instancing/instancing.cpp index bbdd41d1..9050cb71 100644 --- a/examples/instancing/instancing.cpp +++ b/examples/instancing/instancing.cpp @@ -9,8 +9,6 @@ #include "vulkanexamplebase.h" #include "VulkanglTFModel.h" -#define VERTEX_BUFFER_BIND_ID 0 -#define INSTANCE_BUFFER_BIND_ID 1 #if defined(__ANDROID__) #define INSTANCE_COUNT 4096 #else @@ -148,9 +146,9 @@ public: vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets.instancedRocks, 0, NULL); vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.instancedRocks); // Binding point 0 : Mesh vertex buffer - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &models.rock.vertices.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &models.rock.vertices.buffer, offsets); // Binding point 1 : Instance data buffer - vkCmdBindVertexBuffers(drawCmdBuffers[i], INSTANCE_BUFFER_BIND_ID, 1, &instanceBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 1, 1, &instanceBuffer.buffer, offsets); // Bind index buffer vkCmdBindIndexBuffer(drawCmdBuffers[i], models.rock.indices.buffer, 0, VK_INDEX_TYPE_UINT32); @@ -260,9 +258,9 @@ public: // The instancing pipeline uses a vertex input state with two bindings bindingDescriptions = { // Binding point 0: Mesh vertex layout description at per-vertex rate - vks::initializers::vertexInputBindingDescription(VERTEX_BUFFER_BIND_ID, sizeof(vkglTF::Vertex), VK_VERTEX_INPUT_RATE_VERTEX), + vks::initializers::vertexInputBindingDescription(0, sizeof(vkglTF::Vertex), VK_VERTEX_INPUT_RATE_VERTEX), // Binding point 1: Instanced data at per-instance rate - vks::initializers::vertexInputBindingDescription(INSTANCE_BUFFER_BIND_ID, sizeof(InstanceData), VK_VERTEX_INPUT_RATE_INSTANCE) + vks::initializers::vertexInputBindingDescription(1, sizeof(InstanceData), VK_VERTEX_INPUT_RATE_INSTANCE) }; // Vertex attribute bindings @@ -274,16 +272,16 @@ public: attributeDescriptions = { // Per-vertex attributes // These are advanced for each vertex fetched by the vertex shader - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 0: Position - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 1: Normal - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 2, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 6), // Location 2: Texture coordinates - vks::initializers::vertexInputAttributeDescription(VERTEX_BUFFER_BIND_ID, 3, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 8), // Location 3: Color + vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 0: Position + vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 1: Normal + vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 6), // Location 2: Texture coordinates + vks::initializers::vertexInputAttributeDescription(0, 3, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 8), // Location 3: Color // Per-Instance attributes // These are advanced for each instance rendered - vks::initializers::vertexInputAttributeDescription(INSTANCE_BUFFER_BIND_ID, 4, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 4: Position - vks::initializers::vertexInputAttributeDescription(INSTANCE_BUFFER_BIND_ID, 5, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 5: Rotation - vks::initializers::vertexInputAttributeDescription(INSTANCE_BUFFER_BIND_ID, 6, VK_FORMAT_R32_SFLOAT,sizeof(float) * 6), // Location 6: Scale - vks::initializers::vertexInputAttributeDescription(INSTANCE_BUFFER_BIND_ID, 7, VK_FORMAT_R32_SINT, sizeof(float) * 7), // Location 7: Texture array layer index + vks::initializers::vertexInputAttributeDescription(1, 4, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 4: Position + vks::initializers::vertexInputAttributeDescription(1, 5, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 5: Rotation + vks::initializers::vertexInputAttributeDescription(1, 6, VK_FORMAT_R32_SFLOAT,sizeof(float) * 6), // Location 6: Scale + vks::initializers::vertexInputAttributeDescription(1, 7, VK_FORMAT_R32_SINT, sizeof(float) * 7), // Location 7: Texture array layer index }; inputState.pVertexBindingDescriptions = bindingDescriptions.data(); inputState.pVertexAttributeDescriptions = attributeDescriptions.data(); diff --git a/examples/occlusionquery/occlusionquery.cpp b/examples/occlusionquery/occlusionquery.cpp index 2801ccca..2079d310 100644 --- a/examples/occlusionquery/occlusionquery.cpp +++ b/examples/occlusionquery/occlusionquery.cpp @@ -9,7 +9,6 @@ #include "vulkanexamplebase.h" #include "VulkanglTFModel.h" -#define VERTEX_BUFFER_BIND_ID 0 class VulkanExample : public VulkanExampleBase { public: diff --git a/examples/sphericalenvmapping/sphericalenvmapping.cpp b/examples/sphericalenvmapping/sphericalenvmapping.cpp index f6af384e..b3d931dc 100644 --- a/examples/sphericalenvmapping/sphericalenvmapping.cpp +++ b/examples/sphericalenvmapping/sphericalenvmapping.cpp @@ -13,7 +13,6 @@ #include "vulkanexamplebase.h" #include "VulkanglTFModel.h" -#define VERTEX_BUFFER_BIND_ID 0 class VulkanExample : public VulkanExampleBase { public: diff --git a/examples/texture/texture.cpp b/examples/texture/texture.cpp index fe1cb723..9c9dfbaa 100644 --- a/examples/texture/texture.cpp +++ b/examples/texture/texture.cpp @@ -10,7 +10,6 @@ #include #include -#define VERTEX_BUFFER_BIND_ID 0 // Vertex layout for this example struct Vertex { float pos[3]; @@ -485,7 +484,7 @@ public: vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.solid); VkDeviceSize offsets[1] = { 0 }; - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &vertexBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &vertexBuffer.buffer, offsets); vkCmdBindIndexBuffer(drawCmdBuffers[i], indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32); vkCmdDrawIndexed(drawCmdBuffers[i], indexCount, 1, 0, 0, 0); @@ -551,7 +550,7 @@ public: vertices.bindingDescriptions.resize(1); vertices.bindingDescriptions[0] = vks::initializers::vertexInputBindingDescription( - VERTEX_BUFFER_BIND_ID, + 0, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX); @@ -561,21 +560,21 @@ public: // Location 0 : Position vertices.attributeDescriptions[0] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)); // Location 1 : Texture coordinates vertices.attributeDescriptions[1] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 1, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, uv)); // Location 1 : Vertex normal vertices.attributeDescriptions[2] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 2, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, normal)); diff --git a/examples/texture3d/texture3d.cpp b/examples/texture3d/texture3d.cpp index d02a4ab1..f7de92b3 100644 --- a/examples/texture3d/texture3d.cpp +++ b/examples/texture3d/texture3d.cpp @@ -8,7 +8,6 @@ #include "vulkanexamplebase.h" -#define VERTEX_BUFFER_BIND_ID 0 // Vertex layout for this example struct Vertex { float pos[3]; @@ -461,7 +460,7 @@ public: vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.solid); VkDeviceSize offsets[1] = { 0 }; - vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &vertexBuffer.buffer, offsets); + vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &vertexBuffer.buffer, offsets); vkCmdBindIndexBuffer(drawCmdBuffers[i], indexBuffer.buffer, 0, VK_INDEX_TYPE_UINT32); vkCmdDrawIndexed(drawCmdBuffers[i], indexCount, 1, 0, 0, 0); @@ -526,7 +525,7 @@ public: vertices.inputBinding.resize(1); vertices.inputBinding[0] = vks::initializers::vertexInputBindingDescription( - VERTEX_BUFFER_BIND_ID, + 0, sizeof(Vertex), VK_VERTEX_INPUT_RATE_VERTEX); @@ -536,21 +535,21 @@ public: // Location 0 : Position vertices.inputAttributes[0] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, pos)); // Location 1 : Texture coordinates vertices.inputAttributes[1] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 1, VK_FORMAT_R32G32_SFLOAT, offsetof(Vertex, uv)); // Location 1 : Vertex normal vertices.inputAttributes[2] = vks::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, + 0, 2, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, normal));