aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dsinclair@google.com>2019-09-19 13:21:19 -0400
committerGitHub <noreply@github.com>2019-09-19 13:21:19 -0400
commit1c8cc31a5bd3a7b075b7bc1c64972d2cc7b4af64 (patch)
tree16efcb7a14f84942be741510f24eb3ae87df1d56
parent190ada84226b26023df785875192cab5e408f027 (diff)
downloadamber-1c8cc31a5bd3a7b075b7bc1c64972d2cc7b4af64.tar.gz
Create Format directly instead of going through DatumType. (#658)
This CL switches some DatumType uses to directly creating Formats instead of converting after creation.
-rw-r--r--src/pipeline.cc7
-rw-r--r--src/vkscript/command_parser.cc2
-rw-r--r--src/vkscript/parser.cc6
3 files changed, 8 insertions, 7 deletions
diff --git a/src/pipeline.cc b/src/pipeline.cc
index 5b94161..b9685f7 100644
--- a/src/pipeline.cc
+++ b/src/pipeline.cc
@@ -540,9 +540,10 @@ Result Pipeline::GenerateOpenCLPodBuffers() {
: BufferType::kUniform);
// Use an 8-bit type because all the data in the descriptor map is
// byte-based and it simplifies the logic for sizing below.
- DatumType char_type;
- char_type.SetType(DataType::kUint8);
- buffer->SetFormat(char_type.AsFormat());
+ auto fmt = MakeUnique<Format>();
+ fmt->AddComponent(FormatComponentType::kR, FormatMode::kUInt, 8);
+
+ buffer->SetFormat(std::move(fmt));
buffer->SetName(GetName() + "_pod_buffer_" +
std::to_string(descriptor_set) + "_" +
std::to_string(binding));
diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc
index 745d320..6d560d6 100644
--- a/src/vkscript/command_parser.cc
+++ b/src/vkscript/command_parser.cc
@@ -2061,7 +2061,7 @@ Result CommandParser::ProcessProbeSSBO() {
auto fmt = tp.GetType().AsFormat();
if (buffer->FormatIsDefault() || !buffer->GetFormat())
- buffer->SetFormat(tp.GetType().AsFormat());
+ buffer->SetFormat(MakeUnique<Format>(*fmt));
else if (buffer->GetFormat() && !buffer->GetFormat()->Equal(fmt.get()))
return Result("probe format does not match buffer format");
diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc
index db846fc..a1c849e 100644
--- a/src/vkscript/parser.cc
+++ b/src/vkscript/parser.cc
@@ -287,13 +287,13 @@ Result Parser::ProcessIndicesBlock(const SectionParser::Section& section) {
}
if (!indices.empty()) {
- DatumType type;
- type.SetType(DataType::kUint32);
+ auto fmt = MakeUnique<Format>();
+ fmt->AddComponent(FormatComponentType::kR, FormatMode::kUInt, 32);
auto b = MakeUnique<Buffer>(BufferType::kIndex);
auto* buf = b.get();
b->SetName("indices");
- b->SetFormat(type.AsFormat());
+ b->SetFormat(std::move(fmt));
b->SetData(std::move(indices));
Result r = script_->AddBuffer(std::move(b));
if (!r.IsSuccess())