Skip to content

Commit

Permalink
add vertex input rate argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Hatrickek authored and martty committed Jun 30, 2024
1 parent 780ef64 commit 150de5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions include/vuk/runtime/CommandBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ namespace vuk {
fixed_vector<FormatOrIgnore, VUK_MAX_ATTRIBUTES> list;
};

enum class VertexInputRate {
eVertex = VK_VERTEX_INPUT_RATE_VERTEX,
eInstance = VK_VERTEX_INPUT_RATE_INSTANCE,
};

struct DrawIndirectCommand {
uint32_t vertexCount = {};
uint32_t instanceCount = {};
Expand Down Expand Up @@ -400,15 +405,15 @@ namespace vuk {
/// @param buffer The buffer to be bound
/// @param first_location First location assigned to the attributes
/// @param format_list List of formats packed in buffer to generate attributes from
CommandBuffer& bind_vertex_buffer(unsigned binding, const Buffer& buffer, unsigned first_location, Packed format_list);
CommandBuffer& bind_vertex_buffer(unsigned binding, const Buffer& buffer, unsigned first_location, Packed format_list, VertexInputRate input_rate = VertexInputRate::eVertex);
/// @brief Binds a vertex buffer to the given binding point and configures attributes sourced from this buffer based on a span of attribute descriptions and
/// stride
/// @param binding The binding point of the buffer
/// @param buffer The buffer to be bound
/// @param attribute_descriptions Attributes that are sourced from this buffer
/// @param stride Stride of a vertex sourced from this buffer
CommandBuffer&
bind_vertex_buffer(unsigned binding, const Buffer& buffer, std::span<VertexInputAttributeDescription> attribute_descriptions, uint32_t stride);
bind_vertex_buffer(unsigned binding, const Buffer& buffer, std::span<VertexInputAttributeDescription> attribute_descriptions, uint32_t stride, VertexInputRate input_rate = VertexInputRate::eVertex);

/// @brief Update push constants for the specified stages with bytes
/// @param stages Pipeline stages that can see the updated bytes
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/vk/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace vuk {
return bind_ray_tracing_pipeline(ctx.get_named_pipeline(p));
}

CommandBuffer& CommandBuffer::bind_vertex_buffer(unsigned binding, const Buffer& buf, unsigned first_attribute, Packed format) {
CommandBuffer& CommandBuffer::bind_vertex_buffer(unsigned binding, const Buffer& buf, unsigned first_attribute, Packed format, VertexInputRate input_rate) {
VUK_EARLY_RET();
assert(binding < VUK_MAX_ATTRIBUTES && "Vertex buffer binding must be smaller than VUK_MAX_ATTRIBUTES.");
uint32_t location = first_attribute;
Expand All @@ -317,7 +317,7 @@ namespace vuk {

VkVertexInputBindingDescription vibd;
vibd.binding = binding;
vibd.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
vibd.inputRate = (VkVertexInputRate)input_rate;
vibd.stride = offset;
binding_descriptions[binding] = vibd;
VUK_SB_SET(set_binding_descriptions, binding, true);
Expand All @@ -328,7 +328,7 @@ namespace vuk {
return *this;
}

CommandBuffer& CommandBuffer::bind_vertex_buffer(unsigned binding, const Buffer& buf, std::span<VertexInputAttributeDescription> viads, uint32_t stride) {
CommandBuffer& CommandBuffer::bind_vertex_buffer(unsigned binding, const Buffer& buf, std::span<VertexInputAttributeDescription> viads, uint32_t stride, VertexInputRate input_rate) {
VUK_EARLY_RET();
assert(binding < VUK_MAX_ATTRIBUTES && "Vertex buffer binding must be smaller than VUK_MAX_ATTRIBUTES.");
for (auto& viad : viads) {
Expand All @@ -338,7 +338,7 @@ namespace vuk {

VkVertexInputBindingDescription vibd;
vibd.binding = binding;
vibd.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
vibd.inputRate = (VkVertexInputRate)input_rate;
vibd.stride = stride;
binding_descriptions[binding] = vibd;
VUK_SB_SET(set_binding_descriptions, binding, true);
Expand Down

0 comments on commit 150de5c

Please sign in to comment.