aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorasuonpaa <34128694+asuonpaa@users.noreply.github.com>2020-12-16 16:40:10 +0200
committerGitHub <noreply@github.com>2020-12-16 14:40:10 +0000
commitf8a6fdbe4dc9890fa967091f43b5f7669962c403 (patch)
treef7156dbafad1c5aa1ab7ac4e78a035647f5da589 /src
parentcc1dec6104f5e0e656d8439296265a19393628df (diff)
downloadamber-f8a6fdbe4dc9890fa967091f43b5f7669962c403.tar.gz
VERTEX_DATA: add format, offset, stride parameters (#929)
Adds parameters to the VERTEX_DATA AmberScript command: FORMAT, OFFSET, STRIDE.
Diffstat (limited to 'src')
-rw-r--r--src/amberscript/parser.cc60
-rw-r--r--src/amberscript/parser_bind_test.cc310
-rw-r--r--src/pipeline.cc8
-rw-r--r--src/pipeline.h16
-rw-r--r--src/pipeline_test.cc10
-rw-r--r--src/vkscript/parser.cc4
-rw-r--r--src/vulkan/engine_vulkan.cc10
-rw-r--r--src/vulkan/vertex_buffer.cc12
-rw-r--r--src/vulkan/vertex_buffer.h7
-rw-r--r--src/vulkan/vertex_buffer_test.cc3
10 files changed, 414 insertions, 26 deletions
diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc
index 1a5a197..778a659 100644
--- a/src/amberscript/parser.cc
+++ b/src/amberscript/parser.cc
@@ -1301,20 +1301,60 @@ Result Parser::ParsePipelineVertexData(Pipeline* pipeline) {
const uint32_t location = token->AsUint32();
InputRate rate = InputRate::kVertex;
+ uint32_t offset = 0;
+ Format* format = buffer->GetFormat();
+ uint32_t stride = 0;
+
token = tokenizer_->PeekNextToken();
- if (token->IsIdentifier() && token->AsString() == "RATE") {
- tokenizer_->NextToken();
- token = tokenizer_->NextToken();
- if (!token->IsIdentifier())
- return Result("missing input rate value for RATE");
- if (token->AsString() == "instance") {
- rate = InputRate::kInstance;
- } else if (token->AsString() != "vertex") {
- return Result("expecting 'vertex' or 'instance' for RATE value");
+ while (token->IsIdentifier()) {
+ if (token->AsString() == "RATE") {
+ tokenizer_->NextToken();
+ token = tokenizer_->NextToken();
+ if (!token->IsIdentifier())
+ return Result("missing input rate value for RATE");
+ if (token->AsString() == "instance") {
+ rate = InputRate::kInstance;
+ } else if (token->AsString() != "vertex") {
+ return Result("expecting 'vertex' or 'instance' for RATE value");
+ }
+ } else if (token->AsString() == "OFFSET") {
+ tokenizer_->NextToken();
+ token = tokenizer_->NextToken();
+ if (!token->IsInteger())
+ return Result("expected unsigned integer for OFFSET");
+ offset = token->AsUint32();
+ } else if (token->AsString() == "STRIDE") {
+ tokenizer_->NextToken();
+ token = tokenizer_->NextToken();
+ if (!token->IsInteger())
+ return Result("expected unsigned integer for STRIDE");
+ stride = token->AsUint32();
+ if (stride == 0)
+ return Result("STRIDE needs to be larger than zero");
+ } else if (token->AsString() == "FORMAT") {
+ tokenizer_->NextToken();
+ token = tokenizer_->NextToken();
+ if (!token->IsIdentifier())
+ return Result("vertex data FORMAT must be an identifier");
+ auto type = script_->ParseType(token->AsString());
+ if (!type)
+ return Result("invalid vertex data FORMAT");
+ auto fmt = MakeUnique<Format>(type);
+ format = fmt.get();
+ script_->RegisterFormat(std::move(fmt));
+ } else {
+ return Result("unexpected identifier for VERTEX_DATA command: " +
+ token->ToOriginalString());
}
+
+ token = tokenizer_->PeekNextToken();
}
- Result r = pipeline->AddVertexBuffer(buffer, location, rate);
+ if (stride == 0)
+ stride = format->SizeInBytes();
+
+ Result r =
+ pipeline->AddVertexBuffer(buffer, location, rate, format, offset, stride);
if (!r.IsSuccess())
return r;
diff --git a/src/amberscript/parser_bind_test.cc b/src/amberscript/parser_bind_test.cc
index 7f07980..64e6692 100644
--- a/src/amberscript/parser_bind_test.cc
+++ b/src/amberscript/parser_bind_test.cc
@@ -842,7 +842,8 @@ END)";
Parser parser;
Result r = parser.Parse(in);
ASSERT_FALSE(r.IsSuccess());
- EXPECT_EQ("12: extra parameters after VERTEX_DATA command: EXTRA", r.Error());
+ EXPECT_EQ("12: unexpected identifier for VERTEX_DATA command: EXTRA",
+ r.Error());
}
TEST_F(AmberScriptParserTest, BindVertexDataInputRate) {
@@ -927,6 +928,313 @@ END)";
EXPECT_EQ("12: expecting 'vertex' or 'instance' for RATE value", r.Error());
}
+TEST_F(AmberScriptParserTest, BindVertexDataOffset) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 OFFSET 5
+ VERTEX_DATA my_buf2 LOCATION 1 OFFSET 10
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ auto script = parser.GetScript();
+ const auto& pipelines = script->GetPipelines();
+ ASSERT_EQ(1U, pipelines.size());
+
+ const auto* pipeline = pipelines[0].get();
+ const auto& vertex_buffers = pipeline->GetVertexBuffers();
+ ASSERT_EQ(2u, vertex_buffers.size());
+
+ const auto& info1 = vertex_buffers[0];
+ ASSERT_TRUE(info1.buffer != nullptr);
+ EXPECT_EQ(0u, info1.location);
+ EXPECT_EQ(5u, info1.offset);
+
+ const auto& info2 = vertex_buffers[1];
+ ASSERT_TRUE(info2.buffer != nullptr);
+ EXPECT_EQ(1u, info2.location);
+ EXPECT_EQ(10u, info2.offset);
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataOffsetMissingValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 OFFSET
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("13: expected unsigned integer for OFFSET", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataOffsetIncorrectValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 OFFSET foo
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("12: expected unsigned integer for OFFSET", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataStride) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 STRIDE 5
+ VERTEX_DATA my_buf2 LOCATION 1 STRIDE 10
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ auto script = parser.GetScript();
+ const auto& pipelines = script->GetPipelines();
+ ASSERT_EQ(1U, pipelines.size());
+
+ const auto* pipeline = pipelines[0].get();
+ const auto& vertex_buffers = pipeline->GetVertexBuffers();
+ ASSERT_EQ(2u, vertex_buffers.size());
+
+ const auto& info1 = vertex_buffers[0];
+ ASSERT_TRUE(info1.buffer != nullptr);
+ EXPECT_EQ(0u, info1.location);
+ EXPECT_EQ(5u, info1.stride);
+
+ const auto& info2 = vertex_buffers[1];
+ ASSERT_TRUE(info2.buffer != nullptr);
+ EXPECT_EQ(1u, info2.location);
+ EXPECT_EQ(10u, info2.stride);
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataStrideFromFormat) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0
+ VERTEX_DATA my_buf2 LOCATION 1 FORMAT R16_UINT
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ auto script = parser.GetScript();
+ const auto& pipelines = script->GetPipelines();
+ ASSERT_EQ(1U, pipelines.size());
+
+ const auto* pipeline = pipelines[0].get();
+ const auto& vertex_buffers = pipeline->GetVertexBuffers();
+ ASSERT_EQ(2u, vertex_buffers.size());
+
+ const auto& info1 = vertex_buffers[0];
+ ASSERT_TRUE(info1.buffer != nullptr);
+ EXPECT_EQ(0u, info1.location);
+ EXPECT_EQ(1u, info1.stride);
+
+ const auto& info2 = vertex_buffers[1];
+ ASSERT_TRUE(info2.buffer != nullptr);
+ EXPECT_EQ(1u, info2.location);
+ EXPECT_EQ(2u, info2.stride);
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataStrideMissingValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 STRIDE
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("13: expected unsigned integer for STRIDE", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataStrideIncorrectValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 STRIDE foo
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("12: expected unsigned integer for STRIDE", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataStrideZero) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 STRIDE 0
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("12: STRIDE needs to be larger than zero", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataFormat) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 FORMAT R8G8_UNORM
+ VERTEX_DATA my_buf2 LOCATION 1 FORMAT R8_SRGB
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_TRUE(r.IsSuccess()) << r.Error();
+
+ auto script = parser.GetScript();
+ const auto& pipelines = script->GetPipelines();
+ ASSERT_EQ(1U, pipelines.size());
+
+ const auto* pipeline = pipelines[0].get();
+ const auto& vertex_buffers = pipeline->GetVertexBuffers();
+ ASSERT_EQ(2u, vertex_buffers.size());
+
+ const auto& info1 = vertex_buffers[0];
+ ASSERT_TRUE(info1.buffer != nullptr);
+ EXPECT_EQ(0u, info1.location);
+ EXPECT_EQ(FormatType::kR8G8_UNORM, info1.format->GetFormatType());
+
+ const auto& info2 = vertex_buffers[1];
+ ASSERT_TRUE(info2.buffer != nullptr);
+ EXPECT_EQ(1u, info2.location);
+ EXPECT_EQ(FormatType::kR8_SRGB, info2.format->GetFormatType());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataFormatMissingValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 FORMAT
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("13: vertex data FORMAT must be an identifier", r.Error());
+}
+
+TEST_F(AmberScriptParserTest, BindVertexDataFormatIncorrectValue) {
+ std::string in = R"(
+SHADER vertex my_shader PASSTHROUGH
+SHADER fragment my_fragment GLSL
+# GLSL Shader
+END
+BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5
+
+PIPELINE graphics my_pipeline
+ ATTACH my_shader
+ ATTACH my_fragment
+
+ VERTEX_DATA my_buf LOCATION 0 FORMAT foo
+END)";
+
+ Parser parser;
+ Result r = parser.Parse(in);
+ ASSERT_FALSE(r.IsSuccess());
+ EXPECT_EQ("12: invalid vertex data FORMAT", r.Error());
+}
+
TEST_F(AmberScriptParserTest, BindIndexData) {
std::string in = R"(
SHADER vertex my_shader PASSTHROUGH
diff --git a/src/pipeline.cc b/src/pipeline.cc
index beb09b1..ca1a561 100644
--- a/src/pipeline.cc
+++ b/src/pipeline.cc
@@ -423,7 +423,10 @@ Result Pipeline::SetIndexBuffer(Buffer* buf) {
Result Pipeline::AddVertexBuffer(Buffer* buf,
uint32_t location,
- InputRate rate) {
+ InputRate rate,
+ Format* format,
+ uint32_t offset,
+ uint32_t stride) {
for (const auto& vtex : vertex_buffers_) {
if (vtex.location == location)
return Result("can not bind two vertex buffers to the same LOCATION");
@@ -435,6 +438,9 @@ Result Pipeline::AddVertexBuffer(Buffer* buf,
vertex_buffers_.back().location = location;
vertex_buffers_.back().type = BufferType::kVertex;
vertex_buffers_.back().input_rate = rate;
+ vertex_buffers_.back().format = format;
+ vertex_buffers_.back().offset = offset;
+ vertex_buffers_.back().stride = stride;
return {};
}
diff --git a/src/pipeline.h b/src/pipeline.h
index bdb1679..ec38a3a 100644
--- a/src/pipeline.h
+++ b/src/pipeline.h
@@ -199,7 +199,10 @@ class Pipeline {
uint32_t arg_no = 0;
BufferType type = BufferType::kUnknown;
InputRate input_rate = InputRate::kVertex;
- Sampler* sampler;
+ Format* format;
+ uint32_t offset = 0;
+ uint32_t stride = 0;
+ Sampler* sampler = nullptr;
};
/// Information on a sampler attached to the pipeline.
@@ -315,8 +318,15 @@ class Pipeline {
return vertex_buffers_;
}
/// Adds |buf| as a vertex buffer at |location| in the pipeline using |rate|
- /// as the input rate.
- Result AddVertexBuffer(Buffer* buf, uint32_t location, InputRate rate);
+ /// as the input rate, |format| as vertex data format, |offset| as a starting
+ /// offset for the vertex buffer data, and |stride| for the data stride in
+ /// bytes.
+ Result AddVertexBuffer(Buffer* buf,
+ uint32_t location,
+ InputRate rate,
+ Format* format,
+ uint32_t offset,
+ uint32_t stride);
/// Binds |buf| as the index buffer for this pipeline.
Result SetIndexBuffer(Buffer* buf);
diff --git a/src/pipeline_test.cc b/src/pipeline_test.cc
index 96a62aa..e16313c 100644
--- a/src/pipeline_test.cc
+++ b/src/pipeline_test.cc
@@ -353,7 +353,11 @@ TEST_F(PipelineTest, Clone) {
auto vtex_buf = MakeUnique<Buffer>();
vtex_buf->SetName("vertex_buffer");
- p.AddVertexBuffer(vtex_buf.get(), 1, InputRate::kVertex);
+ TypeParser parser;
+ auto int_type = parser.Parse("R32_SINT");
+ auto int_fmt = MakeUnique<Format>(int_type.get());
+ p.AddVertexBuffer(vtex_buf.get(), 1, InputRate::kVertex, int_fmt.get(), 5,
+ 10);
auto idx_buf = MakeUnique<Buffer>();
idx_buf->SetName("Index Buffer");
@@ -385,6 +389,10 @@ TEST_F(PipelineTest, Clone) {
ASSERT_EQ(1U, vtex_buffers.size());
EXPECT_EQ(1, vtex_buffers[0].location);
EXPECT_EQ("vertex_buffer", vtex_buffers[0].buffer->GetName());
+ EXPECT_EQ(InputRate::kVertex, vtex_buffers[0].input_rate);
+ EXPECT_EQ(FormatType::kR32_SINT, vtex_buffers[0].format->GetFormatType());
+ EXPECT_EQ(5, vtex_buffers[0].offset);
+ EXPECT_EQ(10, vtex_buffers[0].stride);
auto bufs = clone->GetBuffers();
ASSERT_EQ(2U, bufs.size());
diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc
index aae55cc..c84e2d9 100644
--- a/src/vkscript/parser.cc
+++ b/src/vkscript/parser.cc
@@ -444,7 +444,9 @@ Result Parser::ProcessVertexDataBlock(const SectionParser::Section& section) {
script_->AddBuffer(std::move(buffer));
- pipeline->AddVertexBuffer(buf, headers[i].location, InputRate::kVertex);
+ pipeline->AddVertexBuffer(buf, headers[i].location, InputRate::kVertex,
+ buf->GetFormat(), 0,
+ buf->GetFormat()->SizeInBytes());
}
return {};
diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc
index 035c269..536993f 100644
--- a/src/vulkan/engine_vulkan.cc
+++ b/src/vulkan/engine_vulkan.cc
@@ -209,7 +209,9 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) {
info.vertex_buffer = MakeUnique<VertexBuffer>(device_.get());
info.vertex_buffer->SetData(static_cast<uint8_t>(vtex_info.location),
- vtex_info.buffer, vtex_info.input_rate);
+ vtex_info.buffer, vtex_info.input_rate,
+ vtex_info.format, vtex_info.offset,
+ vtex_info.stride);
}
if (pipeline->GetIndexBuffer()) {
@@ -502,7 +504,8 @@ Result EngineVulkan::DoDrawRect(const DrawRectCommand* command) {
buf->SetData(std::move(values));
auto vertex_buffer = MakeUnique<VertexBuffer>(device_.get());
- vertex_buffer->SetData(0, buf.get(), InputRate::kVertex);
+ vertex_buffer->SetData(0, buf.get(), InputRate::kVertex, buf->GetFormat(), 0,
+ buf->GetFormat()->SizeInBytes());
DrawArraysCommand draw(command->GetPipeline(), *command->GetPipelineData());
draw.SetTopology(command->IsPatch() ? Topology::kPatchList
@@ -589,7 +592,8 @@ Result EngineVulkan::DoDrawGrid(const DrawGridCommand* command) {
buf->SetData(std::move(values));
auto vertex_buffer = MakeUnique<VertexBuffer>(device_.get());
- vertex_buffer->SetData(0, buf.get(), InputRate::kVertex);
+ vertex_buffer->SetData(0, buf.get(), InputRate::kVertex, buf->GetFormat(), 0,
+ buf->GetFormat()->SizeInBytes());
DrawArraysCommand draw(command->GetPipeline(), *command->GetPipelineData());
draw.SetTopology(Topology::kTriangleList);
diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc
index 409c0f1..ea7e5eb 100644
--- a/src/vulkan/vertex_buffer.cc
+++ b/src/vulkan/vertex_buffer.cc
@@ -36,18 +36,22 @@ VertexBuffer::VertexBuffer(Device* device) : device_(device) {}
VertexBuffer::~VertexBuffer() = default;
-void VertexBuffer::SetData(uint8_t location, Buffer* buffer, InputRate rate) {
- auto format = buffer->GetFormat();
+void VertexBuffer::SetData(uint8_t location,
+ Buffer* buffer,
+ InputRate rate,
+ Format* format,
+ uint32_t offset,
+ uint32_t stride) {
const uint32_t binding = static_cast<uint32_t>(vertex_attr_desc_.size());
vertex_attr_desc_.emplace_back();
vertex_attr_desc_.back().binding = binding;
vertex_attr_desc_.back().location = location;
- vertex_attr_desc_.back().offset = 0u;
+ vertex_attr_desc_.back().offset = offset;
vertex_attr_desc_.back().format = device_->GetVkFormat(*format);
vertex_binding_desc_.emplace_back();
vertex_binding_desc_.back().binding = binding;
- vertex_binding_desc_.back().stride = format->SizeInBytes();
+ vertex_binding_desc_.back().stride = stride;
vertex_binding_desc_.back().inputRate = GetVkInputRate(rate);
data_.push_back(buffer);
diff --git a/src/vulkan/vertex_buffer.h b/src/vulkan/vertex_buffer.h
index 2837a9e..4c49e46 100644
--- a/src/vulkan/vertex_buffer.h
+++ b/src/vulkan/vertex_buffer.h
@@ -40,7 +40,12 @@ class VertexBuffer {
Result SendVertexData(CommandBuffer* command);
bool VertexDataSent() const { return !is_vertex_data_pending_; }
- void SetData(uint8_t location, Buffer* buffer, InputRate rate);
+ void SetData(uint8_t location,
+ Buffer* buffer,
+ InputRate rate,
+ Format* format,
+ uint32_t offset,
+ uint32_t stride);
const std::vector<VkVertexInputAttributeDescription>& GetVkVertexInputAttr()
const {
diff --git a/src/vulkan/vertex_buffer_test.cc b/src/vulkan/vertex_buffer_test.cc
index 914933e..eb8a7bd 100644
--- a/src/vulkan/vertex_buffer_test.cc
+++ b/src/vulkan/vertex_buffer_test.cc
@@ -151,7 +151,8 @@ class VertexBufferTest : public testing::Test {
buffer->SetFormat(format);
buffer->SetData(std::move(values));
- vertex_buffer_->SetData(location, buffer.get(), InputRate::kVertex);
+ vertex_buffer_->SetData(location, buffer.get(), InputRate::kVertex, format,
+ 0, format->SizeInBytes());
return vertex_buffer_->SendVertexData(commandBuffer_.get());
}