aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2019-03-28 09:58:30 -0400
committerGitHub <noreply@github.com>2019-03-28 09:58:30 -0400
commit7fa3e97ad0028fbac3ffeb7c47f19cfc4309fef5 (patch)
tree23245cd31900928141041717c18158de46169292 /src
parent367b63beab07b3881d339918ffb024a5237122a6 (diff)
downloadamber-7fa3e97ad0028fbac3ffeb7c47f19cfc4309fef5.tar.gz
Remove buffer_data file. (#419)
With the amber::Buffer class being used through most of the code, we no-longer need the separation of BufferType into its own file. This Cl puts BufferType back into the buffer.h file.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.h23
-rw-r--r--src/buffer_data.h44
-rw-r--r--src/engine.h2
-rw-r--r--src/vulkan/device.cc4
-rw-r--r--src/vulkan/device.h4
-rw-r--r--src/vulkan/engine_vulkan.cc12
-rw-r--r--src/vulkan/graphics_pipeline.h1
7 files changed, 32 insertions, 58 deletions
diff --git a/src/buffer.h b/src/buffer.h
index d03a4a4..e119927 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -23,7 +23,6 @@
#include "amber/result.h"
#include "amber/value.h"
-#include "src/buffer_data.h"
#include "src/datum_type.h"
#include "src/format.h"
@@ -32,6 +31,28 @@ namespace amber {
class DataBuffer;
class FormatBuffer;
+/// Types of buffers which can be created.
+enum class BufferType : int8_t {
+ /// Unknown buffer type
+ kUnknown = -1,
+ /// A color buffer.
+ kColor = 0,
+ /// A depth/stencil buffer.
+ kDepth,
+ /// An index buffer.
+ kIndex,
+ /// A sampled buffer.
+ kSampled,
+ /// A storage buffer.
+ kStorage,
+ /// A uniform buffer.
+ kUniform,
+ /// A push constant buffer.
+ kPushConstant,
+ /// A vertex buffer.
+ kVertex
+};
+
/// A buffer stores data. The buffer maybe provided from the input script, or
/// maybe created as needed. A buffer must have a unique name.
class Buffer {
diff --git a/src/buffer_data.h b/src/buffer_data.h
deleted file mode 100644
index 2705067..0000000
--- a/src/buffer_data.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2018 The Amber Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef SRC_BUFFER_DATA_H_
-#define SRC_BUFFER_DATA_H_
-
-namespace amber {
-
-/// Types of buffers which can be created.
-enum class BufferType : int8_t {
- /// Unknown buffer type
- kUnknown = -1,
- /// A color buffer.
- kColor = 0,
- /// A depth/stencil buffer.
- kDepth,
- /// An index buffer.
- kIndex,
- /// A sampled buffer.
- kSampled,
- /// A storage buffer.
- kStorage,
- /// A uniform buffer.
- kUniform,
- /// A push constant buffer.
- kPushConstant,
- /// A vertex buffer.
- kVertex
-};
-
-} // namespace amber
-
-#endif // SRC_BUFFER_DATA_H_
diff --git a/src/engine.h b/src/engine.h
index e7ef10c..219ca92 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -21,7 +21,7 @@
#include "amber/amber.h"
#include "amber/result.h"
-#include "src/buffer_data.h"
+#include "src/buffer.h"
#include "src/command.h"
#include "src/format.h"
#include "src/pipeline.h"
diff --git a/src/vulkan/device.cc b/src/vulkan/device.cc
index 5621ae1..b985ac7 100644
--- a/src/vulkan/device.cc
+++ b/src/vulkan/device.cc
@@ -461,7 +461,7 @@ Result Device::Initialize(
}
bool Device::IsFormatSupportedByPhysicalDevice(const Format& format,
- BufferType type) {
+ Buffer* buffer) {
VkFormat vk_format = GetVkFormat(format);
VkFormatProperties properties = VkFormatProperties();
GetPtrs()->vkGetPhysicalDeviceFormatProperties(physical_device_, vk_format,
@@ -469,7 +469,7 @@ bool Device::IsFormatSupportedByPhysicalDevice(const Format& format,
VkFormatFeatureFlagBits flag = VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
bool is_buffer_type_image = false;
- switch (type) {
+ switch (buffer->GetBufferType()) {
case BufferType::kColor:
flag = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
is_buffer_type_image = true;
diff --git a/src/vulkan/device.h b/src/vulkan/device.h
index e55bf88..28c9b81 100644
--- a/src/vulkan/device.h
+++ b/src/vulkan/device.h
@@ -23,7 +23,7 @@
#include "amber/amber.h"
#include "amber/result.h"
#include "amber/vulkan_header.h"
-#include "src/buffer_data.h"
+#include "src/buffer.h"
#include "src/format.h"
namespace amber {
@@ -50,7 +50,7 @@ class Device {
const VkPhysicalDeviceFeatures2KHR& available_features2,
const std::vector<std::string>& available_extensions);
- bool IsFormatSupportedByPhysicalDevice(const Format& format, BufferType type);
+ bool IsFormatSupportedByPhysicalDevice(const Format& format, Buffer* buffer);
VkDevice GetVkDevice() const { return device_; }
VkQueue GetVkQueue() const { return queue_; }
diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc
index 33eb9d5..268a6fe 100644
--- a/src/vulkan/engine_vulkan.cc
+++ b/src/vulkan/engine_vulkan.cc
@@ -148,18 +148,17 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) {
for (const auto& colour_info : pipeline->GetColorAttachments()) {
auto& fmt = colour_info.buffer->AsFormatBuffer()->GetFormat();
- if (!device_->IsFormatSupportedByPhysicalDevice(
- fmt, colour_info.buffer->GetBufferType())) {
+ if (!device_->IsFormatSupportedByPhysicalDevice(fmt, colour_info.buffer))
return Result("Vulkan color attachment format is not supported");
- }
}
Format depth_fmt;
if (pipeline->GetDepthBuffer().buffer) {
const auto& depth_info = pipeline->GetDepthBuffer();
+
depth_fmt = depth_info.buffer->AsFormatBuffer()->GetFormat();
- if (!device_->IsFormatSupportedByPhysicalDevice(
- depth_fmt, depth_info.buffer->GetBufferType())) {
+ if (!device_->IsFormatSupportedByPhysicalDevice(depth_fmt,
+ depth_info.buffer)) {
return Result("Vulkan depth attachment format is not supported");
}
}
@@ -195,8 +194,7 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) {
auto& fmt = vtex_info.buffer->IsFormatBuffer()
? vtex_info.buffer->AsFormatBuffer()->GetFormat()
: Format();
- if (!device_->IsFormatSupportedByPhysicalDevice(
- fmt, vtex_info.buffer->GetBufferType()))
+ if (!device_->IsFormatSupportedByPhysicalDevice(fmt, vtex_info.buffer))
return Result("Vulkan vertex buffer format is not supported");
if (!info.vertex_buffer)
diff --git a/src/vulkan/graphics_pipeline.h b/src/vulkan/graphics_pipeline.h
index fa84948..a57f645 100644
--- a/src/vulkan/graphics_pipeline.h
+++ b/src/vulkan/graphics_pipeline.h
@@ -21,7 +21,6 @@
#include "amber/result.h"
#include "amber/value.h"
#include "amber/vulkan_header.h"
-#include "src/buffer_data.h"
#include "src/format.h"
#include "src/pipeline.h"
#include "src/vulkan/frame_buffer.h"