aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--samples/image_diff.cc6
-rw-r--r--src/amberscript/parser.cc15
-rw-r--r--src/buffer.cc4
-rw-r--r--src/buffer.h8
-rw-r--r--src/buffer_test.cc18
-rw-r--r--src/command.h6
-rw-r--r--src/format.cc28
-rw-r--r--src/format.h3
-rw-r--r--src/format_test.cc25
-rw-r--r--src/pipeline.cc29
-rw-r--r--src/pipeline.h7
-rw-r--r--src/pipeline_test.cc16
-rw-r--r--src/script.h7
-rw-r--r--src/verifier_test.cc86
-rw-r--r--src/vkscript/command_parser.cc30
-rw-r--r--src/vkscript/parser.cc14
-rw-r--r--src/vulkan/engine_vulkan.cc2
-rw-r--r--src/vulkan/graphics_pipeline.cc28
-rw-r--r--src/vulkan/graphics_pipeline.h2
-rw-r--r--src/vulkan/push_constant.cc2
-rw-r--r--src/vulkan/vertex_buffer_test.cc28
21 files changed, 187 insertions, 177 deletions
diff --git a/samples/image_diff.cc b/samples/image_diff.cc
index bba657e..033d412 100644
--- a/samples/image_diff.cc
+++ b/samples/image_diff.cc
@@ -115,11 +115,11 @@ int main(int argc, const char** argv) {
return 1;
}
+ amber::FormatParser fp;
+ auto fmt = fp.Parse("R8G8B8A8_UNORM");
amber::Buffer buffers[2];
-
for (size_t i = 0; i < 2; ++i) {
- amber::FormatParser fp;
- buffers[i].SetFormat(fp.Parse("R8G8B8A8_UNORM"));
+ buffers[i].SetFormat(fmt.get());
amber::Result res =
LoadPngToBuffer(options.input_filenames[i], &buffers[i]);
if (!res.IsSuccess()) {
diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc
index 7d72f50..9c8a300 100644
--- a/src/amberscript/parser.cc
+++ b/src/amberscript/parser.cc
@@ -887,9 +887,11 @@ Result Parser::ParsePipelineSet(Pipeline* pipeline) {
Pipeline::ArgSetInfo info;
info.name = arg_name;
info.ordinal = arg_no;
- info.fmt = std::move(fmt);
+ info.fmt = fmt.get();
info.value = value;
pipeline->SetArg(std::move(info));
+ script_->RegisterFormat(std::move(fmt));
+
return ValidateEndOfStatement("SET command");
}
@@ -926,7 +928,8 @@ Result Parser::ParseBuffer() {
if (fmt == nullptr)
return Result("invalid BUFFER FORMAT");
- buffer->SetFormat(std::move(fmt));
+ buffer->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
} else {
return Result("unknown BUFFER command provided: " + cmd);
}
@@ -947,14 +950,16 @@ Result Parser::ParseBufferInitializer(Buffer* buffer) {
FormatParser fp;
auto fmt = fp.Parse(token->AsString());
if (fmt != nullptr) {
- buffer->SetFormat(std::move(fmt));
+ buffer->SetFormat(fmt.get());
} else {
fmt = ToFormat(token->AsString());
if (!fmt)
return Result("invalid data_type provided");
- buffer->SetFormat(std::move(fmt));
+ buffer->SetFormat(fmt.get());
}
+ script_->RegisterFormat(std::move(fmt));
+
token = tokenizer_->NextToken();
if (!token->IsString())
return Result("BUFFER missing initializer");
@@ -1596,7 +1601,7 @@ Result Parser::ParseExpect() {
}
probe->SetComparator(cmp);
- probe->SetFormat(MakeUnique<Format>(*buffer->GetFormat()));
+ probe->SetFormat(buffer->GetFormat());
probe->SetOffset(static_cast<uint32_t>(x));
std::vector<Value> values;
diff --git a/src/buffer.cc b/src/buffer.cc
index 695d9d4..fd4e1c6 100644
--- a/src/buffer.cc
+++ b/src/buffer.cc
@@ -113,7 +113,7 @@ Result Buffer::CopyTo(Buffer* buffer) const {
}
Result Buffer::IsEqual(Buffer* buffer) const {
- if (!buffer->format_->Equal(format_.get()))
+ if (!buffer->format_->Equal(format_))
return Result{"Buffers have a different format"};
if (buffer->element_count_ != element_count_)
return Result{"Buffers have a different size"};
@@ -172,7 +172,7 @@ std::vector<double> Buffer::CalculateDiffs(const Buffer* buffer) const {
}
Result Buffer::CompareRMSE(Buffer* buffer, float tolerance) const {
- if (!buffer->format_->Equal(format_.get()))
+ if (!buffer->format_->Equal(format_))
return Result{"Buffers have a different format"};
if (buffer->element_count_ != element_count_)
return Result{"Buffers have a different size"};
diff --git a/src/buffer.h b/src/buffer.h
index 9fb6484..813b6aa 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -66,12 +66,12 @@ class Buffer {
void SetBufferType(BufferType type) { buffer_type_ = type; }
/// Sets the Format of the buffer to |format|.
- void SetFormat(std::unique_ptr<Format> format) {
+ void SetFormat(Format* format) {
format_is_default_ = false;
- format_ = std::move(format);
+ format_ = format;
}
/// Returns the Format describing the buffer data.
- Format* GetFormat() const { return format_.get(); }
+ Format* GetFormat() const { return format_; }
void SetFormatIsDefault(bool val) { format_is_default_ = val; }
bool FormatIsDefault() const { return format_is_default_; }
@@ -215,7 +215,7 @@ class Buffer {
uint32_t height_ = 0;
bool format_is_default_ = false;
std::vector<uint8_t> bytes_;
- std::unique_ptr<Format> format_;
+ Format* format_ = nullptr;
};
} // namespace amber
diff --git a/src/buffer_test.cc b/src/buffer_test.cc
index 6059d13..5c52c0f 100644
--- a/src/buffer_test.cc
+++ b/src/buffer_test.cc
@@ -32,8 +32,10 @@ TEST_F(BufferTest, EmptyByDefault) {
TEST_F(BufferTest, Size) {
FormatParser fp;
+ auto fmt = fp.Parse("R16_SINT");
+
Buffer b(BufferType::kColor);
- b.SetFormat(fp.Parse("R16_SINT"));
+ b.SetFormat(fmt.get());
b.SetElementCount(10);
EXPECT_EQ(10, b.ElementCount());
EXPECT_EQ(10, b.ValueCount());
@@ -45,8 +47,10 @@ TEST_F(BufferTest, SizeFromData) {
values.resize(5);
FormatParser fp;
+ auto fmt = fp.Parse("R32_SFLOAT");
+
Buffer b(BufferType::kColor);
- b.SetFormat(fp.Parse("R32_SFLOAT"));
+ b.SetFormat(fmt.get());
b.SetData(std::move(values));
EXPECT_EQ(5, b.ElementCount());
@@ -59,8 +63,10 @@ TEST_F(BufferTest, SizeFromDataDoesNotOverrideSize) {
values.resize(5);
FormatParser fp;
+ auto fmt = fp.Parse("R32_SFLOAT");
+
Buffer b(BufferType::kColor);
- b.SetFormat(fp.Parse("R32_SFLOAT"));
+ b.SetFormat(fmt.get());
b.SetElementCount(20);
b.SetData(std::move(values));
@@ -75,7 +81,7 @@ TEST_F(BufferTest, SizeMatrixStd430) {
fmt->SetColumnCount(3);
Buffer b(BufferType::kColor);
- b.SetFormat(std::move(fmt));
+ b.SetFormat(fmt.get());
b.SetElementCount(10);
EXPECT_EQ(10, b.ElementCount());
@@ -90,7 +96,7 @@ TEST_F(BufferTest, SizeMatrixStd140) {
fmt->SetLayout(Format::Layout::kStd140);
Buffer b(BufferType::kColor);
- b.SetFormat(std::move(fmt));
+ b.SetFormat(fmt.get());
b.SetElementCount(10);
EXPECT_EQ(10, b.ElementCount());
@@ -104,7 +110,7 @@ TEST_F(BufferTest, SizeMatrixPaddedStd430) {
fmt->SetColumnCount(3);
Buffer b(BufferType::kColor);
- b.SetFormat(std::move(fmt));
+ b.SetFormat(fmt.get());
b.SetValueCount(9);
EXPECT_EQ(1U, b.ElementCount());
diff --git a/src/command.h b/src/command.h
index f10f8fe..07a785a 100644
--- a/src/command.h
+++ b/src/command.h
@@ -396,8 +396,8 @@ class ProbeSSBOCommand : public Probe {
void SetOffset(uint32_t offset) { offset_ = offset; }
uint32_t GetOffset() const { return offset_; }
- void SetFormat(std::unique_ptr<Format> fmt) { format_ = std::move(fmt); }
- Format* GetFormat() const { return format_.get(); }
+ void SetFormat(Format* fmt) { format_ = fmt; }
+ Format* GetFormat() const { return format_; }
void SetValues(std::vector<Value>&& values) { values_ = std::move(values); }
const std::vector<Value>& GetValues() const { return values_; }
@@ -409,7 +409,7 @@ class ProbeSSBOCommand : public Probe {
uint32_t descriptor_set_id_ = 0;
uint32_t binding_num_ = 0;
uint32_t offset_ = 0;
- std::unique_ptr<Format> format_;
+ Format* format_;
std::vector<Value> values_;
};
diff --git a/src/format.cc b/src/format.cc
index 57b5814..66e5e76 100644
--- a/src/format.cc
+++ b/src/format.cc
@@ -20,36 +20,8 @@ namespace amber {
Format::Format() = default;
-Format::Format(const Format& b) {
- type_ = b.type_;
- layout_ = b.layout_;
- pack_size_in_bytes_ = b.pack_size_in_bytes_;
- column_count_ = b.column_count_;
-
- for (const auto& comp : b.components_) {
- components_.push_back(
- MakeUnique<Component>(comp->type, comp->mode, comp->num_bits));
- }
- RebuildSegments();
-}
-
Format::~Format() = default;
-Format& Format::operator=(const Format& b) {
- type_ = b.type_;
- layout_ = b.layout_;
- pack_size_in_bytes_ = b.pack_size_in_bytes_;
- column_count_ = b.column_count_;
-
- for (const auto& comp : b.components_) {
- components_.push_back(
- MakeUnique<Component>(comp->type, comp->mode, comp->num_bits));
- }
- RebuildSegments();
-
- return *this;
-}
-
uint32_t Format::SizeInBytes() const {
uint32_t size = 0;
for (const auto& seg : segments_)
diff --git a/src/format.h b/src/format.h
index 901a2eb..c101790 100644
--- a/src/format.h
+++ b/src/format.h
@@ -123,11 +123,8 @@ class Format {
/// Creates a format of unknown type.
Format();
- Format(const Format&);
~Format();
- Format& operator=(const Format&);
-
/// Returns true if |b| describes the same format as this object.
bool Equal(const Format* b) const;
diff --git a/src/format_test.cc b/src/format_test.cc
index a27a34f..b148888 100644
--- a/src/format_test.cc
+++ b/src/format_test.cc
@@ -22,31 +22,6 @@ namespace amber {
using FormatTest = testing::Test;
-TEST_F(FormatTest, Copy) {
- FormatParser fp;
- auto fmt = fp.Parse("R32G32B32_SFLOAT");
- fmt->SetLayout(Format::Layout::kStd140);
- fmt->SetColumnCount(1);
-
- auto copy = MakeUnique<Format>(*fmt.get());
- EXPECT_TRUE(copy->IsFloat());
- EXPECT_EQ(16U, copy->SizeInBytes());
- EXPECT_EQ(4U, copy->GetSegments().size());
- EXPECT_EQ(FormatType::kR32G32B32_SFLOAT, copy->GetFormatType());
-
- auto& segs = copy->GetSegments();
- EXPECT_EQ(FormatComponentType::kR, segs[0].GetComponent()->type);
- EXPECT_EQ(FormatMode::kSFloat, segs[0].GetComponent()->mode);
- EXPECT_EQ(32U, segs[0].GetComponent()->num_bits);
- EXPECT_EQ(FormatComponentType::kG, segs[1].GetComponent()->type);
- EXPECT_EQ(FormatMode::kSFloat, segs[1].GetComponent()->mode);
- EXPECT_EQ(32U, segs[1].GetComponent()->num_bits);
- EXPECT_EQ(FormatComponentType::kB, segs[2].GetComponent()->type);
- EXPECT_EQ(FormatMode::kSFloat, segs[2].GetComponent()->mode);
- EXPECT_EQ(32U, segs[2].GetComponent()->num_bits);
- EXPECT_TRUE(segs[3].IsPadding());
-}
-
TEST_F(FormatTest, SizeInBytesVector) {
FormatParser fp;
auto fmt = fp.Parse("R32G32B32_SFLOAT");
diff --git a/src/pipeline.cc b/src/pipeline.cc
index 017a714..5d0d030 100644
--- a/src/pipeline.cc
+++ b/src/pipeline.cc
@@ -53,14 +53,7 @@ std::unique_ptr<Pipeline> Pipeline::Clone() const {
clone->index_buffer_ = index_buffer_;
clone->fb_width_ = fb_width_;
clone->fb_height_ = fb_height_;
-
- for (const auto& args : set_arg_values_) {
- clone->set_arg_values_.push_back({});
- clone->set_arg_values_.back().name = args.name;
- clone->set_arg_values_.back().ordinal = args.ordinal;
- clone->set_arg_values_.back().fmt = MakeUnique<Format>(*args.fmt);
- clone->set_arg_values_.back().value = args.value;
- }
+ clone->set_arg_values_ = set_arg_values_;
if (!opencl_pod_buffers_.empty()) {
// Generate specific buffers for the clone.
@@ -317,21 +310,27 @@ Result Pipeline::SetPushConstantBuffer(Buffer* buf) {
return {};
}
-std::unique_ptr<Buffer> Pipeline::GenerateDefaultColorAttachmentBuffer() const {
+std::unique_ptr<Buffer> Pipeline::GenerateDefaultColorAttachmentBuffer() {
FormatParser fp;
+ auto fmt = fp.Parse(kDefaultColorBufferFormat);
std::unique_ptr<Buffer> buf = MakeUnique<Buffer>(BufferType::kColor);
buf->SetName(kGeneratedColorBuffer);
- buf->SetFormat(fp.Parse(kDefaultColorBufferFormat));
+ buf->SetFormat(fmt.get());
+
+ formats_.push_back(std::move(fmt));
return buf;
}
-std::unique_ptr<Buffer> Pipeline::GenerateDefaultDepthAttachmentBuffer() const {
+std::unique_ptr<Buffer> Pipeline::GenerateDefaultDepthAttachmentBuffer() {
FormatParser fp;
+ auto fmt = fp.Parse(kDefaultDepthBufferFormat);
std::unique_ptr<Buffer> buf = MakeUnique<Buffer>(BufferType::kDepth);
buf->SetName(kGeneratedDepthBuffer);
- buf->SetFormat(fp.Parse(kDefaultDepthBufferFormat));
+ buf->SetFormat(fmt.get());
+
+ formats_.push_back(std::move(fmt));
return buf;
}
@@ -551,7 +550,9 @@ Result Pipeline::GenerateOpenCLPodBuffers() {
// byte-based and it simplifies the logic for sizing below.
FormatParser fp;
auto fmt = fp.Parse("R8_UINT");
- buffer->SetFormat(std::move(fmt));
+ buffer->SetFormat(fmt.get());
+ formats_.push_back(std::move(fmt));
+
buffer->SetName(GetName() + "_pod_buffer_" +
std::to_string(descriptor_set) + "_" +
std::to_string(binding));
@@ -567,6 +568,7 @@ Result Pipeline::GenerateOpenCLPodBuffers() {
if (buffer->ValueCount() < offset + arg_size) {
buffer->SetSizeInElements(offset + arg_size);
}
+
// Check the data size.
if (arg_size != arg_info.fmt->SizeInBytes()) {
std::string message = "SET command uses incorrect data size: kernel " +
@@ -578,6 +580,7 @@ Result Pipeline::GenerateOpenCLPodBuffers() {
}
return Result(message);
}
+
Result r = buffer->SetDataWithOffset({arg_info.value}, offset);
if (!r.IsSuccess())
return r;
diff --git a/src/pipeline.h b/src/pipeline.h
index 5cb63d4..a13347c 100644
--- a/src/pipeline.h
+++ b/src/pipeline.h
@@ -237,15 +237,15 @@ class Pipeline {
Result Validate() const;
/// Generates a default color attachment in B8G8R8A8_UNORM.
- std::unique_ptr<Buffer> GenerateDefaultColorAttachmentBuffer() const;
+ std::unique_ptr<Buffer> GenerateDefaultColorAttachmentBuffer();
/// Generates a default depth attachment in D32_SFLOAT_S8_UINT format.
- std::unique_ptr<Buffer> GenerateDefaultDepthAttachmentBuffer() const;
+ std::unique_ptr<Buffer> GenerateDefaultDepthAttachmentBuffer();
/// Information on values set for OpenCL-C plain-old-data args.
struct ArgSetInfo {
std::string name;
uint32_t ordinal = 0;
- std::unique_ptr<Format> fmt;
+ Format* fmt = nullptr;
Value value;
};
@@ -271,6 +271,7 @@ class Pipeline {
std::vector<BufferInfo> color_attachments_;
std::vector<BufferInfo> vertex_buffers_;
std::vector<BufferInfo> buffers_;
+ std::vector<std::unique_ptr<Format>> formats_;
BufferInfo depth_buffer_;
BufferInfo push_constant_buffer_;
Buffer* index_buffer_ = nullptr;
diff --git a/src/pipeline_test.cc b/src/pipeline_test.cc
index 5084133..55d86e5 100644
--- a/src/pipeline_test.cc
+++ b/src/pipeline_test.cc
@@ -532,21 +532,21 @@ TEST_F(PipelineTest, OpenCLGeneratePodBuffers) {
Pipeline::ArgSetInfo arg_info1;
arg_info1.name = "arg_a";
arg_info1.ordinal = 99;
- arg_info1.fmt = MakeUnique<Format>(*int_fmt);
+ arg_info1.fmt = int_fmt.get();
arg_info1.value = int_value;
p.SetArg(std::move(arg_info1));
Pipeline::ArgSetInfo arg_info2;
arg_info2.name = "arg_b";
arg_info2.ordinal = 99;
- arg_info2.fmt = MakeUnique<Format>(*char_fmt);
+ arg_info2.fmt = char_fmt.get();
arg_info2.value = int_value;
p.SetArg(std::move(arg_info2));
Pipeline::ArgSetInfo arg_info3;
arg_info3.name = "arg_c";
arg_info3.ordinal = 99;
- arg_info3.fmt = MakeUnique<Format>(*int_fmt);
+ arg_info3.fmt = int_fmt.get();
arg_info3.value = int_value;
p.SetArg(std::move(arg_info3));
@@ -595,7 +595,7 @@ TEST_F(PipelineTest, OpenCLGeneratePodBuffersBadName) {
Pipeline::ArgSetInfo arg_info1;
arg_info1.name = "arg_z";
arg_info1.ordinal = 99;
- arg_info1.fmt = std::move(int_fmt);
+ arg_info1.fmt = int_fmt.get();
arg_info1.value = int_value;
p.SetArg(std::move(arg_info1));
@@ -637,7 +637,7 @@ TEST_F(PipelineTest, OpenCLGeneratePodBuffersBadSize) {
Pipeline::ArgSetInfo arg_info1;
arg_info1.name = "";
arg_info1.ordinal = 0;
- arg_info1.fmt = std::move(short_fmt);
+ arg_info1.fmt = short_fmt.get();
arg_info1.value = int_value;
p.SetArg(std::move(arg_info1));
@@ -698,21 +698,21 @@ TEST_F(PipelineTest, OpenCLClone) {
Pipeline::ArgSetInfo arg_info1;
arg_info1.name = "arg_a";
arg_info1.ordinal = 99;
- arg_info1.fmt = MakeUnique<Format>(*int_fmt);
+ arg_info1.fmt = int_fmt.get();
arg_info1.value = int_value;
p.SetArg(std::move(arg_info1));
Pipeline::ArgSetInfo arg_info2;
arg_info2.name = "arg_b";
arg_info2.ordinal = 99;
- arg_info2.fmt = MakeUnique<Format>(*char_fmt);
+ arg_info2.fmt = char_fmt.get();
arg_info2.value = int_value;
p.SetArg(std::move(arg_info2));
Pipeline::ArgSetInfo arg_info3;
arg_info3.name = "arg_c";
arg_info3.ordinal = 99;
- arg_info3.fmt = MakeUnique<Format>(*int_fmt);
+ arg_info3.fmt = int_fmt.get();
arg_info3.value = int_value;
p.SetArg(std::move(arg_info3));
diff --git a/src/script.h b/src/script.h
index 3e0dc3c..62b4433 100644
--- a/src/script.h
+++ b/src/script.h
@@ -27,6 +27,7 @@
#include "src/buffer.h"
#include "src/command.h"
#include "src/engine.h"
+#include "src/format.h"
#include "src/pipeline.h"
#include "src/shader.h"
@@ -170,6 +171,11 @@ class Script : public RecipeImpl {
/// Retrieves the SPIR-V target environment.
const std::string& GetSpvTargetEnv() const { return spv_env_; }
+ Format* RegisterFormat(std::unique_ptr<Format> fmt) {
+ formats_.push_back(std::move(fmt));
+ return formats_.back().get();
+ }
+
private:
struct {
std::vector<std::string> required_features;
@@ -186,6 +192,7 @@ class Script : public RecipeImpl {
std::vector<std::unique_ptr<Command>> commands_;
std::vector<std::unique_ptr<Buffer>> buffers_;
std::vector<std::unique_ptr<Pipeline>> pipelines_;
+ std::vector<std::unique_ptr<Format>> formats_;
};
} // namespace amber
diff --git a/src/verifier_test.cc b/src/verifier_test.cc
index fb7e903..3cbe86b 100644
--- a/src/verifier_test.cc
+++ b/src/verifier_test.cc
@@ -651,7 +651,8 @@ TEST_F(VerifierTest, ProbeSSBOUint8Single) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R8_UINT"));
+ auto fmt = fp.Parse("R8_UINT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -674,7 +675,9 @@ TEST_F(VerifierTest, ProbeSSBOUint8Multiple) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R8_UINT"));
+ auto fmt = fp.Parse("R8_UINT");
+
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -698,7 +701,9 @@ TEST_F(VerifierTest, ProbeSSBOUint8Many) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R8_UINT"));
+ auto fmt = fp.Parse("R8_UINT");
+
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -726,7 +731,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Single) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_UINT"));
+ auto fmt = fp.Parse("R32_UINT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -749,7 +755,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Multiple) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_UINT"));
+ auto fmt = fp.Parse("R32_UINT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -774,7 +781,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Many) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_UINT"));
+ auto fmt = fp.Parse("R32_UINT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -802,7 +810,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatSingle) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_SFLOAT"));
+ auto fmt = fp.Parse("R32_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -825,7 +834,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatMultiple) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_SFLOAT"));
+ auto fmt = fp.Parse("R32_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -850,7 +860,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatMany) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R32_SFLOAT"));
+ auto fmt = fp.Parse("R32_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -878,7 +889,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleSingle) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -901,7 +913,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleMultiple) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -926,7 +939,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleMany) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -954,7 +968,8 @@ TEST_F(VerifierTest, ProbeSSBOEqualFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kEqual);
std::vector<Value> values;
@@ -981,7 +996,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteTolerance) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kFuzzyEqual);
std::vector<Probe::Tolerance> tolerances;
@@ -1015,7 +1031,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteToleranceFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kFuzzyEqual);
std::vector<Probe::Tolerance> tolerances;
@@ -1046,7 +1063,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeTolerance) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kFuzzyEqual);
std::vector<Probe::Tolerance> tolerances;
@@ -1080,7 +1098,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeToleranceFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kFuzzyEqual);
std::vector<Probe::Tolerance> tolerances;
@@ -1111,7 +1130,8 @@ TEST_F(VerifierTest, ProbeSSBONotEqual) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kNotEqual);
std::vector<Value> values;
@@ -1136,7 +1156,8 @@ TEST_F(VerifierTest, ProbeSSBONotEqualFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kNotEqual);
std::vector<Value> values;
@@ -1163,7 +1184,8 @@ TEST_F(VerifierTest, ProbeSSBOLess) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kLess);
std::vector<Value> values;
@@ -1188,7 +1210,8 @@ TEST_F(VerifierTest, ProbeSSBOLessFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kLess);
std::vector<Value> values;
@@ -1215,7 +1238,8 @@ TEST_F(VerifierTest, ProbeSSBOLessOrEqual) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kLessOrEqual);
std::vector<Value> values;
@@ -1240,7 +1264,8 @@ TEST_F(VerifierTest, ProbeSSBOLessOrEqualFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kLessOrEqual);
std::vector<Value> values;
@@ -1267,7 +1292,8 @@ TEST_F(VerifierTest, ProbeSSBOGreater) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kGreater);
std::vector<Value> values;
@@ -1292,7 +1318,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kGreater);
std::vector<Value> values;
@@ -1319,7 +1346,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterOrEqual) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kGreaterOrEqual);
std::vector<Value> values;
@@ -1344,7 +1372,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterOrEqualFail) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("R64_SFLOAT"));
+ auto fmt = fp.Parse("R64_SFLOAT");
+ probe_ssbo.SetFormat(fmt.get());
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kGreaterOrEqual);
std::vector<Value> values;
@@ -1399,7 +1428,8 @@ TEST_F(VerifierTest, ProbeSSBOWithPadding) {
ProbeSSBOCommand probe_ssbo(color_buf.get());
FormatParser fp;
- probe_ssbo.SetFormat(fp.Parse("float/vec2"));
+ auto fmt = fp.Parse("float/vec2");
+ probe_ssbo.SetFormat(fmt.get());
ASSERT_TRUE(probe_ssbo.GetFormat() != nullptr);
probe_ssbo.SetComparator(ProbeSSBOCommand::Comparator::kLessOrEqual);
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());
diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc
index f3ad45f..6ae7684 100644
--- a/src/vkscript/parser.cc
+++ b/src/vkscript/parser.cc
@@ -178,7 +178,8 @@ Result Parser::ProcessRequireBlock(const SectionParser::Section& section) {
}
script_->GetPipeline(kDefaultPipelineName)
->GetColorAttachments()[0]
- .buffer->SetFormat(std::move(fmt));
+ .buffer->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
} else if (str == "depthstencil") {
token = tokenizer.NextToken();
@@ -199,7 +200,9 @@ Result Parser::ProcessRequireBlock(const SectionParser::Section& section) {
// Generate and add a depth buffer
auto depth_buf = pipeline->GenerateDefaultDepthAttachmentBuffer();
- depth_buf->SetFormat(std::move(fmt));
+ depth_buf->SetFormat(fmt.get());
+ script_->RegisterFormat(std::move(fmt));
+
Result r = pipeline->SetDepthBuffer(depth_buf.get());
if (!r.IsSuccess())
return r;
@@ -292,8 +295,10 @@ Result Parser::ProcessIndicesBlock(const SectionParser::Section& section) {
auto b = MakeUnique<Buffer>(BufferType::kIndex);
auto* buf = b.get();
b->SetName("indices");
- b->SetFormat(std::move(fmt));
+ b->SetFormat(fmt.get());
b->SetData(std::move(indices));
+ script_->RegisterFormat(std::move(fmt));
+
Result r = script_->AddBuffer(std::move(b));
if (!r.IsSuccess())
return r;
@@ -422,9 +427,10 @@ Result Parser::ProcessVertexDataBlock(const SectionParser::Section& section) {
auto buffer = MakeUnique<Buffer>(BufferType::kVertex);
auto* buf = buffer.get();
buffer->SetName("Vertices" + std::to_string(i));
- buffer->SetFormat(std::move(headers[i].format));
+ buffer->SetFormat(headers[i].format.get());
buffer->SetData(std::move(values[i]));
script_->AddBuffer(std::move(buffer));
+ script_->RegisterFormat(std::move(headers[i].format));
pipeline->AddVertexBuffer(buf, headers[i].location);
}
diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc
index 7b592d6..4689409 100644
--- a/src/vulkan/engine_vulkan.cc
+++ b/src/vulkan/engine_vulkan.cc
@@ -411,7 +411,7 @@ Result EngineVulkan::DoDrawRect(const DrawRectCommand* command) {
FormatParser fp;
auto fmt = fp.Parse("R32G32_SFLOAT");
auto buf = MakeUnique<Buffer>();
- buf->SetFormat(std::move(fmt));
+ buf->SetFormat(fmt.get());
buf->SetData(std::move(values));
auto vertex_buffer = MakeUnique<VertexBuffer>(device_.get());
diff --git a/src/vulkan/graphics_pipeline.cc b/src/vulkan/graphics_pipeline.cc
index 63881b3..a63819a 100644
--- a/src/vulkan/graphics_pipeline.cc
+++ b/src/vulkan/graphics_pipeline.cc
@@ -387,10 +387,8 @@ GraphicsPipeline::GraphicsPipeline(
: Pipeline(PipelineType::kGraphics,
device,
fence_timeout_ms,
- shader_stage_info) {
- if (depth_stencil_format != nullptr)
- depth_stencil_format_ = *depth_stencil_format;
-
+ shader_stage_info),
+ depth_stencil_format_(depth_stencil_format) {
for (const auto& info : color_buffers)
color_buffers_.push_back(&info);
}
@@ -428,9 +426,10 @@ Result GraphicsPipeline::CreateRenderPass() {
subpass_desc.colorAttachmentCount = static_cast<uint32_t>(color_refer.size());
subpass_desc.pColorAttachments = color_refer.data();
- if (depth_stencil_format_.IsFormatKnown()) {
+ if (depth_stencil_format_ && depth_stencil_format_->IsFormatKnown()) {
attachment_desc.push_back(kDefaultAttachmentDesc);
- attachment_desc.back().format = device_->GetVkFormat(depth_stencil_format_);
+ attachment_desc.back().format =
+ device_->GetVkFormat(*depth_stencil_format_);
attachment_desc.back().initialLayout =
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
attachment_desc.back().finalLayout =
@@ -651,7 +650,7 @@ Result GraphicsPipeline::CreateVkGraphicsPipeline(
}
VkPipelineDepthStencilStateCreateInfo depthstencil_info;
- if (depth_stencil_format_.IsFormatKnown()) {
+ if (depth_stencil_format_ && depth_stencil_format_->IsFormatKnown()) {
depthstencil_info = GetVkPipelineDepthStencilInfo(pipeline_data);
pipeline_info.pDepthStencilState = &depthstencil_info;
}
@@ -696,7 +695,7 @@ Result GraphicsPipeline::Initialize(uint32_t width,
return r;
frame_ = MakeUnique<FrameBuffer>(device_, color_buffers_, width, height);
- r = frame_->Initialize(render_pass_, &depth_stencil_format_);
+ r = frame_->Initialize(render_pass_, depth_stencil_format_);
if (!r.IsSuccess())
return r;
@@ -742,7 +741,7 @@ Result GraphicsPipeline::SetClearColor(float r, float g, float b, float a) {
}
Result GraphicsPipeline::SetClearStencil(uint32_t stencil) {
- if (!depth_stencil_format_.IsFormatKnown()) {
+ if (!depth_stencil_format_ || !depth_stencil_format_->IsFormatKnown()) {
return Result(
"Vulkan::ClearStencilCommand No DepthStencil Buffer for FrameBuffer "
"Exists");
@@ -753,7 +752,7 @@ Result GraphicsPipeline::SetClearStencil(uint32_t stencil) {
}
Result GraphicsPipeline::SetClearDepth(float depth) {
- if (!depth_stencil_format_.IsFormatKnown()) {
+ if (!depth_stencil_format_ || !depth_stencil_format_->IsFormatKnown()) {
return Result(
"Vulkan::ClearStencilCommand No DepthStencil Buffer for FrameBuffer "
"Exists");
@@ -772,16 +771,17 @@ Result GraphicsPipeline::Clear() {
if (!r.IsSuccess())
return r;
- if (!depth_stencil_format_.IsFormatKnown())
+ if (!depth_stencil_format_ || !depth_stencil_format_->IsFormatKnown())
return {};
VkClearValue depth_clear;
depth_clear.depthStencil = {clear_depth_, clear_stencil_};
return ClearBuffer(
- depth_clear, depth_stencil_format_.HasStencilComponent()
- ? VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT
- : VK_IMAGE_ASPECT_DEPTH_BIT);
+ depth_clear,
+ depth_stencil_format_ && depth_stencil_format_->HasStencilComponent()
+ ? VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT
+ : VK_IMAGE_ASPECT_DEPTH_BIT);
}
Result GraphicsPipeline::ClearBuffer(const VkClearValue& clear_value,
diff --git a/src/vulkan/graphics_pipeline.h b/src/vulkan/graphics_pipeline.h
index 20f8918..e08bdc3 100644
--- a/src/vulkan/graphics_pipeline.h
+++ b/src/vulkan/graphics_pipeline.h
@@ -90,7 +90,7 @@ class GraphicsPipeline : public Pipeline {
// color buffers are owned by the amber::Pipeline.
std::vector<const amber::Pipeline::BufferInfo*> color_buffers_;
- Format depth_stencil_format_;
+ Format* depth_stencil_format_;
std::unique_ptr<IndexBuffer> index_buffer_;
uint32_t frame_width_ = 0;
diff --git a/src/vulkan/push_constant.cc b/src/vulkan/push_constant.cc
index 4ba2b00..dd9a24f 100644
--- a/src/vulkan/push_constant.cc
+++ b/src/vulkan/push_constant.cc
@@ -123,7 +123,7 @@ Result PushConstant::UpdateMemoryWithInput(const BufferInput& input) {
}
if (!buffer_->GetFormat()) {
- buffer_->SetFormat(MakeUnique<Format>(*(input.buffer->GetFormat())));
+ buffer_->SetFormat(input.buffer->GetFormat());
} else if (!buffer_->GetFormat()->Equal(input.buffer->GetFormat())) {
return Result("Vulkan: push constants must all have the same format");
}
diff --git a/src/vulkan/vertex_buffer_test.cc b/src/vulkan/vertex_buffer_test.cc
index 3269e06..ae170ae 100644
--- a/src/vulkan/vertex_buffer_test.cc
+++ b/src/vulkan/vertex_buffer_test.cc
@@ -56,10 +56,10 @@ class VertexBufferTest : public testing::Test {
~VertexBufferTest() = default;
Result SetIntData(uint8_t location,
- std::unique_ptr<Format> format,
+ Format* format,
std::vector<Value> values) {
auto buffer = MakeUnique<Buffer>();
- buffer->SetFormat(std::move(format));
+ buffer->SetFormat(format);
buffer->SetData(std::move(values));
vertex_buffer_->SetData(location, buffer.get());
@@ -67,10 +67,10 @@ class VertexBufferTest : public testing::Test {
}
Result SetDoubleData(uint8_t location,
- std::unique_ptr<Format> format,
+ Format* format,
std::vector<Value> values) {
auto buffer = MakeUnique<Buffer>();
- buffer->SetFormat(std::move(format));
+ buffer->SetFormat(format);
buffer->SetData(std::move(values));
vertex_buffer_->SetData(location, buffer.get());
@@ -100,7 +100,7 @@ TEST_F(VertexBufferTest, R8G8B8A8_UINT) {
FormatParser fp;
auto fmt = fp.Parse("R8G8B8A8_UINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const uint8_t* ptr = static_cast<const uint8_t*>(GetVkBufferPtr());
EXPECT_EQ(55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -118,7 +118,7 @@ TEST_F(VertexBufferTest, R16G16B16A16_UINT) {
FormatParser fp;
auto fmt = fp.Parse("R16G16B16A16_UINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const uint16_t* ptr = static_cast<const uint16_t*>(GetVkBufferPtr());
EXPECT_EQ(55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -136,7 +136,7 @@ TEST_F(VertexBufferTest, R32G32B32A32_UINT) {
FormatParser fp;
auto fmt = fp.Parse("R32G32B32A32_UINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const uint32_t* ptr = static_cast<const uint32_t*>(GetVkBufferPtr());
EXPECT_EQ(55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -154,7 +154,7 @@ TEST_F(VertexBufferTest, R64G64B64A64_UINT) {
FormatParser fp;
auto fmt = fp.Parse("R64G64B64A64_UINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const uint64_t* ptr = static_cast<const uint64_t*>(GetVkBufferPtr());
EXPECT_EQ(55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -172,7 +172,7 @@ TEST_F(VertexBufferTest, R8G8B8A8_SNORM) {
FormatParser fp;
auto fmt = fp.Parse("R8G8B8A8_SNORM");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const int8_t* ptr = static_cast<const int8_t*>(GetVkBufferPtr());
EXPECT_EQ(-55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -190,7 +190,7 @@ TEST_F(VertexBufferTest, R16G16B16A16_SNORM) {
FormatParser fp;
auto fmt = fp.Parse("R16G16B16A16_SNORM");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const int16_t* ptr = static_cast<const int16_t*>(GetVkBufferPtr());
EXPECT_EQ(-55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -208,7 +208,7 @@ TEST_F(VertexBufferTest, R32G32B32A32_SINT) {
FormatParser fp;
auto fmt = fp.Parse("R32G32B32A32_SINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const int32_t* ptr = static_cast<const int32_t*>(GetVkBufferPtr());
EXPECT_EQ(-55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -226,7 +226,7 @@ TEST_F(VertexBufferTest, R64G64B64A64_SINT) {
FormatParser fp;
auto fmt = fp.Parse("R64G64B64A64_SINT");
- Result r = SetIntData(0, std::move(fmt), values);
+ Result r = SetIntData(0, fmt.get(), values);
const int64_t* ptr = static_cast<const int64_t*>(GetVkBufferPtr());
EXPECT_EQ(-55, ptr[0]);
EXPECT_EQ(3, ptr[1]);
@@ -243,7 +243,7 @@ TEST_F(VertexBufferTest, R32G32B32_SFLOAT) {
FormatParser fp;
auto fmt = fp.Parse("R32G32B32_SFLOAT");
- Result r = SetDoubleData(0, std::move(fmt), values);
+ Result r = SetDoubleData(0, fmt.get(), values);
const float* ptr = static_cast<const float*>(GetVkBufferPtr());
EXPECT_FLOAT_EQ(-6.0f, ptr[0]);
EXPECT_FLOAT_EQ(14.0f, ptr[1]);
@@ -259,7 +259,7 @@ TEST_F(VertexBufferTest, R64G64B64_SFLOAT) {
FormatParser fp;
auto fmt = fp.Parse("R64G64B64_SFLOAT");
- Result r = SetDoubleData(0, std::move(fmt), values);
+ Result r = SetDoubleData(0, fmt.get(), values);
const double* ptr = static_cast<const double*>(GetVkBufferPtr());
EXPECT_DOUBLE_EQ(-6.0, ptr[0]);
EXPECT_DOUBLE_EQ(14.0, ptr[1]);