diff options
author | dan sinclair <dsinclair@google.com> | 2019-09-30 13:22:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-30 13:22:18 -0400 |
commit | 8348fd411b80336dbf013305e861570c50d53f40 (patch) | |
tree | 99910d0617227c58d6b8f51db5ac5c2b656f2e0c /src/pipeline.cc | |
parent | 3624da9a117643a3d6cb12f80838f668f763c89e (diff) | |
download | amber-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/pipeline.cc')
-rw-r--r-- | src/pipeline.cc | 29 |
1 files changed, 16 insertions, 13 deletions
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; |