aboutsummaryrefslogtreecommitdiff
path: root/src/vkscript/command_parser.cc
diff options
context:
space:
mode:
authordan sinclair <dsinclair@google.com>2019-09-30 13:22:18 -0400
committerGitHub <noreply@github.com>2019-09-30 13:22:18 -0400
commit8348fd411b80336dbf013305e861570c50d53f40 (patch)
tree99910d0617227c58d6b8f51db5ac5c2b656f2e0c /src/vkscript/command_parser.cc
parent3624da9a117643a3d6cb12f80838f668f763c89e (diff)
downloadamber-8348fd411b80336dbf013305e861570c50d53f40.tar.gz
Store formats in pipeline and scripts. (#677)
This CL removes the unique_ptr from the probe and buffer classes and stores pointers instead. The lifetimes are managed by the pipeline and script objects. This removes the need to do the copy and assignment operators for the format class.
Diffstat (limited to 'src/vkscript/command_parser.cc')
-rw-r--r--src/vkscript/command_parser.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc
index b60993f..5123991 100644
--- a/src/vkscript/command_parser.cc
+++ b/src/vkscript/command_parser.cc
@@ -594,10 +594,12 @@ Result CommandParser::ProcessSSBO() {
return Result("Invalid type provided: " + token->AsString());
auto* buf = cmd->GetBuffer();
- if (buf->FormatIsDefault() || !buf->GetFormat())
- buf->SetFormat(std::move(fmt));
- else if (!buf->GetFormat()->Equal(fmt.get()))
+ if (buf->FormatIsDefault() || !buf->GetFormat()) {
+ buf->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
+ } else if (!buf->GetFormat()->Equal(fmt.get())) {
return Result("probe ssbo format does not match buffer format");
+ }
token = tokenizer_->NextToken();
if (!token->IsInteger()) {
@@ -641,7 +643,8 @@ Result CommandParser::ProcessSSBO() {
if (!buf->GetFormat()) {
FormatParser fp;
auto fmt = fp.Parse("R8_SINT");
- buf->SetFormat(std::move(fmt));
+ buf->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
// This has to come after the SetFormat() call because SetFormat() resets
// the value back to false.
buf->SetFormatIsDefault(true);
@@ -746,10 +749,12 @@ Result CommandParser::ProcessUniform() {
fmt->SetLayout(Format::Layout::kStd140);
auto* buf = cmd->GetBuffer();
- if (buf->FormatIsDefault() || !buf->GetFormat())
- buf->SetFormat(std::move(fmt));
- else if (!buf->GetFormat()->Equal(fmt.get()))
+ if (buf->FormatIsDefault() || !buf->GetFormat()) {
+ buf->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
+ } else if (!buf->GetFormat()->Equal(fmt.get())) {
return Result("probe ssbo format does not match buffer format");
+ }
token = tokenizer_->NextToken();
if (!token->IsInteger()) {
@@ -2056,18 +2061,21 @@ Result CommandParser::ProcessProbeSSBO() {
std::to_string(binding));
}
- if (buffer->FormatIsDefault() || !buffer->GetFormat())
- buffer->SetFormat(MakeUnique<Format>(*fmt));
- else if (buffer->GetFormat() && !buffer->GetFormat()->Equal(fmt.get()))
+ if (buffer->FormatIsDefault() || !buffer->GetFormat()) {
+ buffer->SetFormat(fmt.get());
+ } else if (buffer->GetFormat() && !buffer->GetFormat()->Equal(fmt.get())) {
return Result("probe format does not match buffer format");
+ }
auto cmd = MakeUnique<ProbeSSBOCommand>(buffer);
cmd->SetLine(cur_line);
cmd->SetTolerances(current_tolerances_);
- cmd->SetFormat(std::move(fmt));
+ cmd->SetFormat(fmt.get());
cmd->SetDescriptorSet(set);
cmd->SetBinding(binding);
+ script_->RegisterFormat(std::move(fmt));
+
if (!token->IsInteger())
return Result("Invalid offset for probe ssbo command: " +
token->ToOriginalString());