diff options
author | dan sinclair <dj2@everburning.com> | 2019-03-12 18:06:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-12 18:06:01 -0400 |
commit | bfd22e9810a5de410373a99d1305bba7fbdd22ee (patch) | |
tree | 73c63b504970b34ba1c70d3f83e4f9644206efbc /src/pipeline.cc | |
parent | 06e174dcbf63370ea802fe302e07250845bf74cf (diff) | |
download | amber-bfd22e9810a5de410373a99d1305bba7fbdd22ee.tar.gz |
Store BufferType in buffer. (#355)
Previously the buffer type existed in both the Buffer and
Pipeline::BufferInfo. These buffer types could diverge, which could
cause issues with thinking the buffer is of an incorrect type.
This CL removes the buffer type from BufferInfo and always uses the
buffer to retrieve the type.
Diffstat (limited to 'src/pipeline.cc')
-rw-r--r-- | src/pipeline.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pipeline.cc b/src/pipeline.cc index d45dc05..6dafb37 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -218,8 +218,9 @@ Result Pipeline::AddColorAttachment(Buffer* buf, uint32_t location) { Result Pipeline::SetDepthBuffer(Buffer* buf) { if (depth_buffer_.buffer != nullptr) return Result("can only bind one depth buffer in a PIPELINE"); + if (buf->GetBufferType() != BufferType::kDepth) + return Result("expected a depth buffer"); - depth_buffer_.type = BufferType::kDepth; depth_buffer_.buffer = buf; depth_buffer_.width = fb_width_; depth_buffer_.height = fb_height_; @@ -244,10 +245,11 @@ Result Pipeline::AddVertexBuffer(Buffer* buf, uint32_t location) { if (vtex.buffer == buf) return Result("vertex buffer may only be bound to a PIPELINE once"); } + if (buf->GetBufferType() != BufferType::kVertex) + return Result("expected a vertex buffer"); vertex_buffers_.push_back(BufferInfo{buf}); vertex_buffers_.back().location = location; - vertex_buffers_.back().type = BufferType::kVertex; return {}; } |