From 72edbf0dfdb14f961df4aa7f014d45d90a96dfa5 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Mon, 24 Jun 2019 17:52:17 -0400 Subject: [PATCH 1/4] set max element count --- src/vkscript/command_parser.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 911c0e563..79aa6e9f5 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -615,6 +615,10 @@ Result CommandParser::ProcessSSBO() { if (!r.IsSuccess()) return r; + // Resize the buffer so we'll know the max size + if (buf->ElementCount() < values.size()) + buf->SetElementCount(values.size()); + cmd->SetValues(std::move(values)); } else { From e9d4ac37642a810a08522c22f5ec9e50ce1219d2 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 25 Jun 2019 10:48:11 -0400 Subject: [PATCH 2/4] fix implicit casting error --- src/vkscript/command_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 79aa6e9f5..e94a5c5fa 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -617,7 +617,7 @@ Result CommandParser::ProcessSSBO() { // Resize the buffer so we'll know the max size if (buf->ElementCount() < values.size()) - buf->SetElementCount(values.size()); + buf->SetElementCount(static_cast(values.size())); cmd->SetValues(std::move(values)); From 0f42bc0d01e68795adc4d2a80d12641661607595 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 25 Jun 2019 13:07:32 -0400 Subject: [PATCH 3/4] count in offset --- src/vkscript/command_parser.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index e94a5c5fa..963053b7b 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -615,9 +615,7 @@ Result CommandParser::ProcessSSBO() { if (!r.IsSuccess()) return r; - // Resize the buffer so we'll know the max size - if (buf->ElementCount() < values.size()) - buf->SetElementCount(static_cast(values.size())); + buf->SetDataWithOffset(values, cmd->GetOffset()); cmd->SetValues(std::move(values)); From cb2c11a0dd3a78a8ebcd4d22ae53d6239032ce5c Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 25 Jun 2019 14:07:39 -0400 Subject: [PATCH 4/4] don't set the data --- src/vkscript/command_parser.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 963053b7b..02c7ed2f8 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -615,7 +615,21 @@ Result CommandParser::ProcessSSBO() { if (!r.IsSuccess()) return r; - buf->SetDataWithOffset(values, cmd->GetOffset()); + // Multiply by the input needed because the value count will use the needed + // input as the multiplier + uint32_t value_count = + ((cmd->GetOffset() / buf->GetFormat()->SizeInBytes()) * + buf->GetFormat()->InputNeededPerElement()) + + static_cast(values.size()); + // The buffer should only be resized to become bigger. This means that if a + // command was run to set the buffer size we'll honour that size until a + // request happens to make the buffer bigger. + if (value_count > buf->ValueCount()) + buf->SetValueCount(value_count); + + // Even if the value count doesn't change, the buffer is still resized + // because this maybe the first time data is set into the buffer. + buf->ResizeTo(buf->GetSizeInBytes()); cmd->SetValues(std::move(values));