diff options
Diffstat (limited to 'src/vkscript/command_parser.cc')
-rw-r--r-- | src/vkscript/command_parser.cc | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 5123991..dd4f918 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -22,9 +22,9 @@ #include <utility> #include "src/command_data.h" -#include "src/format_parser.h" #include "src/make_unique.h" #include "src/tokenizer.h" +#include "src/type_parser.h" #include "src/vkscript/datum_type_parser.h" namespace amber { @@ -491,7 +491,7 @@ Result CommandParser::ParseValues(const std::string& name, while (!token->IsEOL() && !token->IsEOS()) { Value v; - if ((fmt->IsFloat() || fmt->IsDouble())) { + if ((fmt->IsFloat32() || fmt->IsFloat64())) { if (!token->IsInteger() && !token->IsDouble()) { return Result(std::string("Invalid value provided to ") + name + " command: " + token->ToOriginalString()); @@ -520,7 +520,7 @@ Result CommandParser::ParseValues(const std::string& name, // This could overflow, but I don't really expect us to get command files // that big .... - size_t num_per_row = fmt->RowCount(); + size_t num_per_row = fmt->GetType()->RowCount(); if (seen == 0 || (seen % num_per_row) != 0) { return Result(std::string("Incorrect number of values provided to ") + name + " command"); @@ -589,14 +589,16 @@ Result CommandParser::ProcessSSBO() { token->ToOriginalString()); DatumTypeParser tp; - auto fmt = tp.Parse(token->AsString()); - if (!fmt) + auto type = tp.Parse(token->AsString()); + if (!type) return Result("Invalid type provided: " + token->AsString()); + auto fmt = MakeUnique<Format>(type.get()); auto* buf = cmd->GetBuffer(); if (buf->FormatIsDefault() || !buf->GetFormat()) { buf->SetFormat(fmt.get()); script_->RegisterFormat(std::move(fmt)); + script_->RegisterType(std::move(type)); } else if (!buf->GetFormat()->Equal(fmt.get())) { return Result("probe ssbo format does not match buffer format"); } @@ -641,10 +643,13 @@ Result CommandParser::ProcessSSBO() { // Set a default format into the buffer if needed. if (!buf->GetFormat()) { - FormatParser fp; - auto fmt = fp.Parse("R8_SINT"); + TypeParser parser; + auto type = parser.Parse("R8_SINT"); + auto fmt = MakeUnique<Format>(type.get()); buf->SetFormat(fmt.get()); script_->RegisterFormat(std::move(fmt)); + script_->RegisterType(std::move(type)); + // This has to come after the SetFormat() call because SetFormat() resets // the value back to false. buf->SetFormatIsDefault(true); @@ -740,10 +745,12 @@ Result CommandParser::ProcessUniform() { } DatumTypeParser tp; - auto fmt = tp.Parse(token->AsString()); - if (!fmt) + auto type = tp.Parse(token->AsString()); + if (!type) return Result("Invalid type provided: " + token->AsString()); + auto fmt = MakeUnique<Format>(type.get()); + // uniform is always std140. if (is_ubo) fmt->SetLayout(Format::Layout::kStd140); @@ -752,6 +759,7 @@ Result CommandParser::ProcessUniform() { if (buf->FormatIsDefault() || !buf->GetFormat()) { buf->SetFormat(fmt.get()); script_->RegisterFormat(std::move(fmt)); + script_->RegisterType(std::move(type)); } else if (!buf->GetFormat()->Equal(fmt.get())) { return Result("probe ssbo format does not match buffer format"); } @@ -2018,8 +2026,8 @@ Result CommandParser::ProcessProbeSSBO() { token->ToOriginalString()); DatumTypeParser tp; - auto fmt = tp.Parse(token->AsString()); - if (!fmt) + auto type = tp.Parse(token->AsString()); + if (!type) return Result("Invalid type provided: " + token->AsString()); token = tokenizer_->NextToken(); @@ -2061,6 +2069,7 @@ Result CommandParser::ProcessProbeSSBO() { std::to_string(binding)); } + auto fmt = MakeUnique<Format>(type.get()); if (buffer->FormatIsDefault() || !buffer->GetFormat()) { buffer->SetFormat(fmt.get()); } else if (buffer->GetFormat() && !buffer->GetFormat()->Equal(fmt.get())) { @@ -2075,6 +2084,7 @@ Result CommandParser::ProcessProbeSSBO() { cmd->SetBinding(binding); script_->RegisterFormat(std::move(fmt)); + script_->RegisterType(std::move(type)); if (!token->IsInteger()) return Result("Invalid offset for probe ssbo command: " + |