aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2019-03-25 10:57:33 -0400
committerGitHub <noreply@github.com>2019-03-25 10:57:33 -0400
commit11d47964eedc0a69a686237e3caa3b7d1408b263 (patch)
tree9e10ab4661cbf7c2031cb43e0561aca2f17c3996 /src
parent724d61f7ae34d5b20787f73b26f20af67ad32d2d (diff)
downloadamber-11d47964eedc0a69a686237e3caa3b7d1408b263.tar.gz
[vulkan] remove unnecessary Result returns. (#412)
This CL removes the Result returns from methods which always return success.
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/buffer_descriptor.cc3
-rw-r--r--src/vulkan/frame_buffer.cc7
-rw-r--r--src/vulkan/frame_buffer.h2
-rw-r--r--src/vulkan/graphics_pipeline.cc10
-rw-r--r--src/vulkan/index_buffer.cc3
-rw-r--r--src/vulkan/resource.cc2
-rw-r--r--src/vulkan/resource.h2
-rw-r--r--src/vulkan/transfer_buffer.cc8
-rw-r--r--src/vulkan/transfer_buffer.h4
-rw-r--r--src/vulkan/transfer_image.cc3
-rw-r--r--src/vulkan/transfer_image.h4
-rw-r--r--src/vulkan/vertex_buffer.cc3
-rw-r--r--src/vulkan/vertex_buffer_test.cc2
13 files changed, 22 insertions, 31 deletions
diff --git a/src/vulkan/buffer_descriptor.cc b/src/vulkan/buffer_descriptor.cc
index 360adb6..f25c61e 100644
--- a/src/vulkan/buffer_descriptor.cc
+++ b/src/vulkan/buffer_descriptor.cc
@@ -85,7 +85,8 @@ Result BufferDescriptor::RecordCopyDataToHost(CommandBuffer* command) {
"Vulkan: BufferDescriptor::RecordCopyDataToHost() no transfer buffer");
}
- return transfer_buffer_->CopyToHost(command);
+ transfer_buffer_->CopyToHost(command);
+ return {};
}
Result BufferDescriptor::MoveResourceToBufferOutput() {
diff --git a/src/vulkan/frame_buffer.cc b/src/vulkan/frame_buffer.cc
index da89331..982800b 100644
--- a/src/vulkan/frame_buffer.cc
+++ b/src/vulkan/frame_buffer.cc
@@ -174,14 +174,11 @@ Result FrameBuffer::ChangeFrameImageLayout(CommandBuffer* command,
return {};
}
-Result FrameBuffer::CopyColorImagesToHost(CommandBuffer* command) {
+void FrameBuffer::CopyColorImagesToHost(CommandBuffer* command) {
for (auto& img : color_images_) {
ChangeFrameImageLayout(command, FrameImageState::kProbe);
- Result r = img->CopyToHost(command);
- if (!r.IsSuccess())
- return r;
+ img->CopyToHost(command);
}
- return {};
}
void FrameBuffer::CopyImagesToBuffers() {
diff --git a/src/vulkan/frame_buffer.h b/src/vulkan/frame_buffer.h
index 0999982..ed32d52 100644
--- a/src/vulkan/frame_buffer.h
+++ b/src/vulkan/frame_buffer.h
@@ -56,7 +56,7 @@ class FrameBuffer {
// Only record the command for copying the image that backs this
// framebuffer to the host accessible buffer. The actual submission
// of the command must be done later.
- Result CopyColorImagesToHost(CommandBuffer* command);
+ void CopyColorImagesToHost(CommandBuffer* command);
void CopyImagesToBuffers();
diff --git a/src/vulkan/graphics_pipeline.cc b/src/vulkan/graphics_pipeline.cc
index b9f7736..3102cb3 100644
--- a/src/vulkan/graphics_pipeline.cc
+++ b/src/vulkan/graphics_pipeline.cc
@@ -815,11 +815,9 @@ Result GraphicsPipeline::ClearBuffer(const VkClearValue& clear_value,
command_->GetVkCommandBuffer(), 1, &clear_attachment, 1, &clear_rect);
}
- Result r = frame_->CopyColorImagesToHost(command_.get());
- if (!r.IsSuccess())
- return r;
+ frame_->CopyColorImagesToHost(command_.get());
- r = cmd_buf_guard.Submit(GetFenceTimeout());
+ Result r = cmd_buf_guard.Submit(GetFenceTimeout());
if (!r.IsSuccess())
return r;
@@ -907,9 +905,7 @@ Result GraphicsPipeline::Draw(const DrawArraysCommand* command,
}
}
- r = frame_->CopyColorImagesToHost(command_.get());
- if (!r.IsSuccess())
- return r;
+ frame_->CopyColorImagesToHost(command_.get());
r = cmd_buf_guard.Submit(GetFenceTimeout());
if (!r.IsSuccess())
diff --git a/src/vulkan/index_buffer.cc b/src/vulkan/index_buffer.cc
index 625a40b..a3c10d3 100644
--- a/src/vulkan/index_buffer.cc
+++ b/src/vulkan/index_buffer.cc
@@ -50,7 +50,8 @@ Result IndexBuffer::SendIndexData(
std::memcpy(transfer_buffer_->HostAccessibleMemoryPtr(),
buffer->ValuePtr()->data(), buffer->GetSizeInBytes());
- return transfer_buffer_->CopyToDevice(command);
+ transfer_buffer_->CopyToDevice(command);
+ return {};
}
Result IndexBuffer::BindToCommandBuffer(CommandBuffer* command) {
diff --git a/src/vulkan/resource.cc b/src/vulkan/resource.cc
index 697c066..154328b 100644
--- a/src/vulkan/resource.cc
+++ b/src/vulkan/resource.cc
@@ -105,7 +105,7 @@ Resource::Resource(Device* device,
Resource::~Resource() = default;
Result Resource::CreateVkBuffer(VkBuffer* buffer, VkBufferUsageFlags usage) {
- if (buffer == nullptr)
+ if (!buffer)
return Result("Vulkan::Given VkBuffer pointer is nullptr");
VkBufferCreateInfo buffer_info = VkBufferCreateInfo();
diff --git a/src/vulkan/resource.h b/src/vulkan/resource.h
index 24462c9..8a9e07e 100644
--- a/src/vulkan/resource.h
+++ b/src/vulkan/resource.h
@@ -47,7 +47,7 @@ class Resource {
public:
virtual ~Resource();
- virtual Result CopyToHost(CommandBuffer* command) = 0;
+ virtual void CopyToHost(CommandBuffer* command) = 0;
void* HostAccessibleMemoryPtr() const { return memory_ptr_; }
diff --git a/src/vulkan/transfer_buffer.cc b/src/vulkan/transfer_buffer.cc
index f361db1..1db1893 100644
--- a/src/vulkan/transfer_buffer.cc
+++ b/src/vulkan/transfer_buffer.cc
@@ -100,18 +100,16 @@ Result TransferBuffer::CreateVkBufferView(VkFormat format) {
return {};
}
-Result TransferBuffer::CopyToDevice(CommandBuffer* command) {
+void TransferBuffer::CopyToDevice(CommandBuffer* command) {
// This is redundant because this buffer is always host visible
// and coherent and vkQueueSubmit will make writes from host
- // avaliable (See chapter 6.9. "Host Write Ordering Guarantees" in
+ // available (See chapter 6.9. "Host Write Ordering Guarantees" in
// Vulkan spec), but we prefer to keep it to simplify our own code.
MemoryBarrier(command);
- return {};
}
-Result TransferBuffer::CopyToHost(CommandBuffer* command) {
+void TransferBuffer::CopyToHost(CommandBuffer* command) {
MemoryBarrier(command);
- return {};
}
void TransferBuffer::UpdateMemoryWithRawData(
diff --git a/src/vulkan/transfer_buffer.h b/src/vulkan/transfer_buffer.h
index 61ea89b..09226bc 100644
--- a/src/vulkan/transfer_buffer.h
+++ b/src/vulkan/transfer_buffer.h
@@ -51,7 +51,7 @@ class TransferBuffer : public Resource {
// Since |buffer_| is mapped to host accessible and host coherent
// memory |memory_|, this method only conducts memory barrier to
// make it available to device domain.
- virtual Result CopyToDevice(CommandBuffer* command);
+ virtual void CopyToDevice(CommandBuffer* command);
// Fill memory from 0 to |raw_data.size()| with |raw_data|.
void UpdateMemoryWithRawData(const std::vector<uint8_t>& raw_data);
@@ -59,7 +59,7 @@ class TransferBuffer : public Resource {
// Since |buffer_| is mapped to host accessible and host coherent
// memory |memory_|, this method only conducts memory barrier to
// make it available to host domain.
- Result CopyToHost(CommandBuffer* command) override;
+ void CopyToHost(CommandBuffer* command) override;
private:
VkBuffer buffer_ = VK_NULL_HANDLE;
diff --git a/src/vulkan/transfer_image.cc b/src/vulkan/transfer_image.cc
index f6e334d..82857cd 100644
--- a/src/vulkan/transfer_image.cc
+++ b/src/vulkan/transfer_image.cc
@@ -157,7 +157,7 @@ Result TransferImage::CreateVkImageView() {
return {};
}
-Result TransferImage::CopyToHost(CommandBuffer* command) {
+void TransferImage::CopyToHost(CommandBuffer* command) {
VkBufferImageCopy copy_region = VkBufferImageCopy();
copy_region.bufferOffset = 0;
// Row length of 0 results in tight packing of rows, so the row stride
@@ -180,7 +180,6 @@ Result TransferImage::CopyToHost(CommandBuffer* command) {
&copy_region);
MemoryBarrier(command);
- return {};
}
void TransferImage::ChangeLayout(CommandBuffer* command,
diff --git a/src/vulkan/transfer_image.h b/src/vulkan/transfer_image.h
index 879a3eb..8e93711 100644
--- a/src/vulkan/transfer_image.h
+++ b/src/vulkan/transfer_image.h
@@ -40,8 +40,6 @@ class TransferImage : public Resource {
VkImage GetVkImage() const { return image_; }
VkImageView GetVkImageView() const { return view_; }
- // TODO(jaebaek): Implement CopyToDevice
-
void ChangeLayout(CommandBuffer* command,
VkImageLayout old_layout,
VkImageLayout new_layout,
@@ -51,7 +49,7 @@ class TransferImage : public Resource {
// Only record the command for copying this image to its secondary
// host-accessible buffer. The actual submission of the command
// must be done later.
- Result CopyToHost(CommandBuffer* command) override;
+ void CopyToHost(CommandBuffer* command) override;
private:
Result CreateVkImageView();
diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc
index 36d5b03..2fd8e59 100644
--- a/src/vulkan/vertex_buffer.cc
+++ b/src/vulkan/vertex_buffer.cc
@@ -56,7 +56,8 @@ Result VertexBuffer::FillVertexBufferWithData(CommandBuffer* command) {
ptr_in_stride_begin += Get4BytesAlignedStride();
}
- return transfer_buffer_->CopyToDevice(command);
+ transfer_buffer_->CopyToDevice(command);
+ return {};
}
void VertexBuffer::BindToCommandBuffer(CommandBuffer* command) {
diff --git a/src/vulkan/vertex_buffer_test.cc b/src/vulkan/vertex_buffer_test.cc
index e02f53c..eaedd67 100644
--- a/src/vulkan/vertex_buffer_test.cc
+++ b/src/vulkan/vertex_buffer_test.cc
@@ -40,7 +40,7 @@ class BufferForTest : public TransferBuffer {
}
~BufferForTest() override = default;
- Result CopyToDevice(CommandBuffer*) override { return Result(); }
+ void CopyToDevice(CommandBuffer*) override {}
private:
std::vector<uint8_t> memory_;