Do not indent C++ namespace contents
This is a style change. Visual Studio defaults to indenting namespace
contents, and this was adopted for a long time, but with the new Vulkan
implementation this was abandoned. However the legacy code borrowed from
the OpenGL ES implementation still used indentation so it was
inconsistent.
The justification for not indenting namespace contents is that
namespaces are merely a way to avoid name clashes with other projects
we don't control directly (and in rare cases internal subprojects when
we want to reuse the same names). Hence the vast majority of files have
a single namespace, and unlike indentation used for ease of discerning
control flow blocks, class contents, or function contents, which can
become highly nested, there is no such readability advantage to
indenting namespace contents.
This is also the Google style recommendation (though no justification or
discussion is provided):
https://google.github.io/styleguide/cppguide.html#Namespace_Formatting
One reasonable counter-argument is consistency with other blocks of
curly brackets, but considering that most namespaces span almost the
entire file, it's a substantial waste of line length.
Because there is no indentation, there's also no need to have the open
and closing brackets line up as a visual aid, like we prefer for other
uses of curly brackets. So we place the open bracket on the same line as
the namespace keyword.
A comment is added to the closing bracket to discern it from other
closing brackets. It also makes it easier to find the end of anonymous
namespaces which typically go at the top of the source file.
This change is make separately from applying clang-format because diff
tools mark all these unindented lines as changes and this makes it hard
to review the smaller style changes made by clang-format. The OpenGL ES
and Direct3D code is left untouched because it is in maintenance mode
and in case of regressions we want easy 'blame' tool usage.
Bug: b/144825072
Change-Id: Ie2925ebd697e1ffa7c4cbdc9a946531f11f4d934
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39348
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/Debug/EventListener.hpp b/src/Vulkan/Debug/EventListener.hpp
index 6d96066..8de0dfd 100644
--- a/src/Vulkan/Debug/EventListener.hpp
+++ b/src/Vulkan/Debug/EventListener.hpp
@@ -15,10 +15,8 @@
#ifndef VK_DEBUG_EVENT_LISTENER_HPP_
#define VK_DEBUG_EVENT_LISTENER_HPP_
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class Thread;
diff --git a/src/Vulkan/Debug/File.cpp b/src/Vulkan/Debug/File.cpp
index 2185a0b..8fc0c54 100644
--- a/src/Vulkan/Debug/File.cpp
+++ b/src/Vulkan/Debug/File.cpp
@@ -17,8 +17,7 @@
#include <mutex>
#include <unordered_set>
-namespace
-{
+namespace {
////////////////////////////////////////////////////////////////////////////////
// FileBase
@@ -104,10 +103,8 @@
} // anonymous namespace
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
std::shared_ptr<File> File::createVirtual(ID id, std::string name, std::string source)
{
diff --git a/src/Vulkan/Debug/File.hpp b/src/Vulkan/Debug/File.hpp
index d67316d..9472c6b 100644
--- a/src/Vulkan/Debug/File.hpp
+++ b/src/Vulkan/Debug/File.hpp
@@ -20,10 +20,8 @@
#include <memory>
#include <string>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class File
{
diff --git a/src/Vulkan/Debug/ID.hpp b/src/Vulkan/Debug/ID.hpp
index 709baf5..29ebd2e 100644
--- a/src/Vulkan/Debug/ID.hpp
+++ b/src/Vulkan/Debug/ID.hpp
@@ -17,10 +17,8 @@
#include <functional> // std::hash
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
// ID is a strongly-typed identifier backed by a int.
// The template parameter T is not actually used by the implementation of
@@ -51,8 +49,8 @@
} // namespace dbg
} // namespace vk
-namespace std
-{
+namespace std {
+
// std::hash implementation for vk::dbg::ID<T>
template <typename T>
struct hash<vk::dbg::ID<T> >
@@ -62,6 +60,7 @@
return std::hash<int>()(id.value());
}
};
+
} // namespace std
#endif // VK_DEBUG_ID_HPP_
diff --git a/src/Vulkan/Debug/Location.hpp b/src/Vulkan/Debug/Location.hpp
index fbc66dc..9b3d883 100644
--- a/src/Vulkan/Debug/Location.hpp
+++ b/src/Vulkan/Debug/Location.hpp
@@ -17,10 +17,8 @@
#include <memory>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class File;
diff --git a/src/Vulkan/Debug/Thread.cpp b/src/Vulkan/Debug/Thread.cpp
index b61c5d9..b2c0088 100644
--- a/src/Vulkan/Debug/Thread.cpp
+++ b/src/Vulkan/Debug/Thread.cpp
@@ -18,10 +18,8 @@
#include "EventListener.hpp"
#include "File.hpp"
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
Thread::Thread(ID id, Context* ctx) :
id(id),
diff --git a/src/Vulkan/Debug/Thread.hpp b/src/Vulkan/Debug/Thread.hpp
index 8199d67..a2b63a9 100644
--- a/src/Vulkan/Debug/Thread.hpp
+++ b/src/Vulkan/Debug/Thread.hpp
@@ -25,10 +25,8 @@
#include <string>
#include <vector>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class File;
class VariableContainer;
diff --git a/src/Vulkan/Debug/Type.cpp b/src/Vulkan/Debug/Type.cpp
index fd9643e..f4049c3 100644
--- a/src/Vulkan/Debug/Type.cpp
+++ b/src/Vulkan/Debug/Type.cpp
@@ -14,10 +14,8 @@
#include "Type.hpp"
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
// clang-format off
std::shared_ptr<Type> TypeOf<bool>::get() { static auto ty = std::make_shared<Type>(Kind::Bool); return ty; }
diff --git a/src/Vulkan/Debug/Type.hpp b/src/Vulkan/Debug/Type.hpp
index d73fd72..07ceaf1 100644
--- a/src/Vulkan/Debug/Type.hpp
+++ b/src/Vulkan/Debug/Type.hpp
@@ -20,10 +20,8 @@
#include <cstdint>
#include <string>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class VariableContainer;
class Value;
diff --git a/src/Vulkan/Debug/Value.cpp b/src/Vulkan/Debug/Value.cpp
index db7f1ca..02ad6f9 100644
--- a/src/Vulkan/Debug/Value.cpp
+++ b/src/Vulkan/Debug/Value.cpp
@@ -16,10 +16,8 @@
#include "Value.hpp"
#include "Variable.hpp"
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
const FormatFlags FormatFlags::Default = {
"[", // listPrefix
diff --git a/src/Vulkan/Debug/Value.hpp b/src/Vulkan/Debug/Value.hpp
index c45b33c..69353d1 100644
--- a/src/Vulkan/Debug/Value.hpp
+++ b/src/Vulkan/Debug/Value.hpp
@@ -18,10 +18,8 @@
#include <memory>
#include <string>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
class Type;
diff --git a/src/Vulkan/Debug/Variable.hpp b/src/Vulkan/Debug/Variable.hpp
index 15b50b3..f24ca47 100644
--- a/src/Vulkan/Debug/Variable.hpp
+++ b/src/Vulkan/Debug/Variable.hpp
@@ -25,10 +25,8 @@
#include <unordered_map>
#include <vector>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
// Variable is a named value.
struct Variable
diff --git a/src/Vulkan/Debug/WeakMap.hpp b/src/Vulkan/Debug/WeakMap.hpp
index 984ca05..0019c16 100644
--- a/src/Vulkan/Debug/WeakMap.hpp
+++ b/src/Vulkan/Debug/WeakMap.hpp
@@ -18,10 +18,8 @@
#include <map>
#include <memory>
-namespace vk
-{
-namespace dbg
-{
+namespace vk {
+namespace dbg {
// WeakMap is an associative container of keys of type K to values of type
// std::weak_ptr<V>.
diff --git a/src/Vulkan/VkBuffer.cpp b/src/Vulkan/VkBuffer.cpp
index f8d1211..ce14bf3 100644
--- a/src/Vulkan/VkBuffer.cpp
+++ b/src/Vulkan/VkBuffer.cpp
@@ -18,8 +18,7 @@
#include <cstring>
-namespace vk
-{
+namespace vk {
Buffer::Buffer(const VkBufferCreateInfo* pCreateInfo, void* mem) :
flags(pCreateInfo->flags), size(pCreateInfo->size), usage(pCreateInfo->usage),
@@ -140,4 +139,4 @@
return reinterpret_cast<uint8_t*>(getOffsetPointer(size + 1));
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkBuffer.hpp b/src/Vulkan/VkBuffer.hpp
index 23c42e1..7dc1005 100644
--- a/src/Vulkan/VkBuffer.hpp
+++ b/src/Vulkan/VkBuffer.hpp
@@ -17,8 +17,7 @@
#include "VkObject.hpp"
-namespace vk
-{
+namespace vk {
class DeviceMemory;
@@ -59,6 +58,6 @@
return Buffer::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_BUFFER_HPP_
diff --git a/src/Vulkan/VkBufferView.cpp b/src/Vulkan/VkBufferView.cpp
index 0f4848d..085acfe 100644
--- a/src/Vulkan/VkBufferView.cpp
+++ b/src/Vulkan/VkBufferView.cpp
@@ -16,8 +16,7 @@
#include "VkBuffer.hpp"
#include "VkFormat.h"
-namespace vk
-{
+namespace vk {
BufferView::BufferView(const VkBufferViewCreateInfo* pCreateInfo, void* mem) :
buffer(vk::Cast(pCreateInfo->buffer)), format(pCreateInfo->format), offset(pCreateInfo->offset)
@@ -37,4 +36,4 @@
return buffer->getOffsetPointer(offset);
}
-}
\ No newline at end of file
+} // namespace vk
\ No newline at end of file
diff --git a/src/Vulkan/VkBufferView.hpp b/src/Vulkan/VkBufferView.hpp
index 45a87e9..bf20a6a 100644
--- a/src/Vulkan/VkBufferView.hpp
+++ b/src/Vulkan/VkBufferView.hpp
@@ -19,8 +19,7 @@
#include "VkFormat.h"
#include "VkImageView.hpp"
-namespace vk
-{
+namespace vk {
class Buffer;
@@ -52,6 +51,6 @@
return BufferView::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_BUFFER_VIEW_HPP_
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index d8c1930..e025b4b 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -1737,4 +1737,4 @@
}
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkCommandBuffer.hpp b/src/Vulkan/VkCommandBuffer.hpp
index 01664e4..d4d3ec1 100644
--- a/src/Vulkan/VkCommandBuffer.hpp
+++ b/src/Vulkan/VkCommandBuffer.hpp
@@ -23,15 +23,15 @@
#include <memory>
#include <vector>
-namespace sw
-{
- class Context;
- class Renderer;
- class TaskEvents;
-}
+namespace sw {
-namespace vk
-{
+class Context;
+class Renderer;
+class TaskEvents;
+
+} // namespace sw
+
+namespace vk {
class Buffer;
class Event;
@@ -206,6 +206,6 @@
return DispatchableCommandBuffer::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_COMMAND_BUFFER_HPP_
diff --git a/src/Vulkan/VkCommandPool.cpp b/src/Vulkan/VkCommandPool.cpp
index 17934ea..9cb1603 100644
--- a/src/Vulkan/VkCommandPool.cpp
+++ b/src/Vulkan/VkCommandPool.cpp
@@ -18,8 +18,7 @@
#include <algorithm>
#include <new>
-namespace vk
-{
+namespace vk {
CommandPool::CommandPool(const VkCommandPoolCreateInfo* pCreateInfo, void* mem)
{
@@ -112,4 +111,4 @@
// TODO (b/119827933): Optimize memory usage here
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkCommandPool.hpp b/src/Vulkan/VkCommandPool.hpp
index e07a248..0f4c130 100644
--- a/src/Vulkan/VkCommandPool.hpp
+++ b/src/Vulkan/VkCommandPool.hpp
@@ -18,8 +18,7 @@
#include "VkObject.hpp"
#include <set>
-namespace vk
-{
+namespace vk {
class CommandPool : public Object<CommandPool, VkCommandPool>
{
@@ -43,6 +42,6 @@
return CommandPool::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_COMMAND_POOL_HPP_
diff --git a/src/Vulkan/VkConfig.h b/src/Vulkan/VkConfig.h
index f2014c8..1a39e0d 100644
--- a/src/Vulkan/VkConfig.h
+++ b/src/Vulkan/VkConfig.h
@@ -19,8 +19,7 @@
#include <Vulkan/VulkanPlatform.h>
-namespace vk
-{
+namespace vk {
// Note: Constant array initialization requires a string literal.
// constexpr char* or char[] does not work for that purpose.
@@ -82,7 +81,7 @@
constexpr float SUBPIXEL_PRECISION_FACTOR = static_cast<float>(1 << SUBPIXEL_PRECISION_BITS);
constexpr int SUBPIXEL_PRECISION_MASK = 0xFFFFFFFF >> (32 - SUBPIXEL_PRECISION_BITS);
-}
+} // namespace vk
#if defined(__linux__) || defined(__ANDROID__)
#define SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD 1
diff --git a/src/Vulkan/VkDebug.cpp b/src/Vulkan/VkDebug.cpp
index 37beb7a..7b7cf85 100644
--- a/src/Vulkan/VkDebug.cpp
+++ b/src/Vulkan/VkDebug.cpp
@@ -83,10 +83,9 @@
#endif
}
-}
+} // anonymous namespace
-namespace vk
-{
+namespace vk {
void tracev(const char *format, va_list args)
{
@@ -164,4 +163,4 @@
}
}
-}
+} // namespace vk
diff --git a/src/Vulkan/VkDebug.hpp b/src/Vulkan/VkDebug.hpp
index 95b4ff9..40462ed 100644
--- a/src/Vulkan/VkDebug.hpp
+++ b/src/Vulkan/VkDebug.hpp
@@ -32,22 +32,23 @@
#define CHECK_PRINTF_ARGS
#endif
-namespace vk
-{
- // Outputs text to the debugging log
- void trace(const char *format, ...) CHECK_PRINTF_ARGS;
- inline void trace() {}
+namespace vk {
- // Outputs text to the debugging log and prints to stderr.
- void warn(const char *format, ...) CHECK_PRINTF_ARGS;
- inline void warn() {}
+// Outputs text to the debugging log
+void trace(const char *format, ...) CHECK_PRINTF_ARGS;
+inline void trace() {}
- // Outputs the message to the debugging log and stderr, and calls abort().
- void abort(const char *format, ...) CHECK_PRINTF_ARGS;
+// Outputs text to the debugging log and prints to stderr.
+void warn(const char *format, ...) CHECK_PRINTF_ARGS;
+inline void warn() {}
- // Outputs text to the debugging log, and asserts once if a debugger is attached.
- void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
-}
+// Outputs the message to the debugging log and stderr, and calls abort().
+void abort(const char *format, ...) CHECK_PRINTF_ARGS;
+
+// Outputs text to the debugging log, and asserts once if a debugger is attached.
+void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
+
+} // namespace vk
// A macro to output a trace of a function call and its arguments to the
// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
diff --git a/src/Vulkan/VkDescriptorPool.cpp b/src/Vulkan/VkDescriptorPool.cpp
index 79b46cc..3c9b2dd 100644
--- a/src/Vulkan/VkDescriptorPool.cpp
+++ b/src/Vulkan/VkDescriptorPool.cpp
@@ -33,10 +33,9 @@
return reinterpret_cast<uint8_t*>(vk::Cast(descriptorSet));
}
-}
+} // anonymous namespace
-namespace vk
-{
+namespace vk {
DescriptorPool::DescriptorPool(const VkDescriptorPoolCreateInfo* pCreateInfo, void* mem) :
pool(static_cast<uint8_t*>(mem)),
@@ -230,4 +229,4 @@
return totalFreeSize;
}
-} // namespace vk
\ No newline at end of file
+} // namespace vk
\ No newline at end of file
diff --git a/src/Vulkan/VkDescriptorPool.hpp b/src/Vulkan/VkDescriptorPool.hpp
index 8c8a600..c222018 100644
--- a/src/Vulkan/VkDescriptorPool.hpp
+++ b/src/Vulkan/VkDescriptorPool.hpp
@@ -18,46 +18,46 @@
#include "VkObject.hpp"
#include <set>
-namespace vk
+namespace vk {
+
+class DescriptorPool : public Object<DescriptorPool, VkDescriptorPool>
{
- class DescriptorPool : public Object<DescriptorPool, VkDescriptorPool>
+public:
+ DescriptorPool(const VkDescriptorPoolCreateInfo* pCreateInfo, void* mem);
+ void destroy(const VkAllocationCallbacks* pAllocator);
+
+ static size_t ComputeRequiredAllocationSize(const VkDescriptorPoolCreateInfo* pCreateInfo);
+
+ VkResult allocateSets(uint32_t descriptorSetCount, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets);
+ void freeSets(uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets);
+ VkResult reset();
+
+private:
+ VkResult allocateSets(size_t* sizes, uint32_t numAllocs, VkDescriptorSet* pDescriptorSets);
+ uint8_t* findAvailableMemory(size_t size);
+ void freeSet(const VkDescriptorSet descriptorSet);
+ size_t computeTotalFreeSize() const;
+
+ struct Node
{
- public:
- DescriptorPool(const VkDescriptorPoolCreateInfo* pCreateInfo, void* mem);
- void destroy(const VkAllocationCallbacks* pAllocator);
+ Node(uint8_t* set, size_t size) : set(set), size(size) {}
+ bool operator<(const Node& node) const { return set < node.set; }
+ bool operator==(const uint8_t* other) const { return set == other; }
- static size_t ComputeRequiredAllocationSize(const VkDescriptorPoolCreateInfo* pCreateInfo);
-
- VkResult allocateSets(uint32_t descriptorSetCount, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets);
- void freeSets(uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets);
- VkResult reset();
-
- private:
- VkResult allocateSets(size_t* sizes, uint32_t numAllocs, VkDescriptorSet* pDescriptorSets);
- uint8_t* findAvailableMemory(size_t size);
- void freeSet(const VkDescriptorSet descriptorSet);
- size_t computeTotalFreeSize() const;
-
- struct Node
- {
- Node(uint8_t* set, size_t size) : set(set), size(size) {}
- bool operator<(const Node& node) const { return set < node.set; }
- bool operator==(const uint8_t* other) const { return set == other; }
-
- uint8_t* set = nullptr;
- size_t size = 0;
- };
- std::set<Node> nodes;
-
- uint8_t* pool = nullptr;
- size_t poolSize = 0;
+ uint8_t* set = nullptr;
+ size_t size = 0;
};
+ std::set<Node> nodes;
- static inline DescriptorPool* Cast(VkDescriptorPool object)
- {
- return DescriptorPool::Cast(object);
- }
+ uint8_t* pool = nullptr;
+ size_t poolSize = 0;
+};
-} // namespace vk
+static inline DescriptorPool* Cast(VkDescriptorPool object)
+{
+ return DescriptorPool::Cast(object);
+}
+
+} // namespace vk
#endif // VK_DESCRIPTOR_POOL_HPP_
diff --git a/src/Vulkan/VkDescriptorSet.hpp b/src/Vulkan/VkDescriptorSet.hpp
index fc50148..89486b5 100644
--- a/src/Vulkan/VkDescriptorSet.hpp
+++ b/src/Vulkan/VkDescriptorSet.hpp
@@ -20,35 +20,35 @@
#include <array>
#include <memory>
-namespace vk
+namespace vk {
+
+class DescriptorSetLayout;
+
+struct alignas(16) DescriptorSetHeader
{
- class DescriptorSetLayout;
+ DescriptorSetLayout* layout;
+};
- struct alignas(16) DescriptorSetHeader
+class alignas(16) DescriptorSet
+{
+public:
+ static inline DescriptorSet* Cast(VkDescriptorSet object)
{
- DescriptorSetLayout* layout;
- };
-
- class alignas(16) DescriptorSet
- {
- public:
- static inline DescriptorSet* Cast(VkDescriptorSet object)
- {
- return static_cast<DescriptorSet*>(static_cast<void*>(object));
- }
-
- using Bindings = std::array<vk::DescriptorSet*, vk::MAX_BOUND_DESCRIPTOR_SETS>;
- using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
-
- DescriptorSetHeader header;
- alignas(16) uint8_t data[1];
- };
-
- inline DescriptorSet* Cast(VkDescriptorSet object)
- {
- return DescriptorSet::Cast(object);
+ return static_cast<DescriptorSet*>(static_cast<void*>(object));
}
-} // namespace vk
+ using Bindings = std::array<vk::DescriptorSet*, vk::MAX_BOUND_DESCRIPTOR_SETS>;
+ using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
+
+ DescriptorSetHeader header;
+ alignas(16) uint8_t data[1];
+};
+
+inline DescriptorSet* Cast(VkDescriptorSet object)
+{
+ return DescriptorSet::Cast(object);
+}
+
+} // namespace vk
#endif // VK_DESCRIPTOR_SET_HPP_
diff --git a/src/Vulkan/VkDescriptorSetLayout.cpp b/src/Vulkan/VkDescriptorSetLayout.cpp
index b294ce8..6c6de49 100644
--- a/src/Vulkan/VkDescriptorSetLayout.cpp
+++ b/src/Vulkan/VkDescriptorSetLayout.cpp
@@ -24,8 +24,7 @@
#include <algorithm>
#include <cstring>
-namespace
-{
+namespace {
static bool UsesImmutableSamplers(const VkDescriptorSetLayoutBinding& binding)
{
@@ -34,10 +33,9 @@
(binding.pImmutableSamplers != nullptr));
}
-}
+} // anonymous namespace
-namespace vk
-{
+namespace vk {
DescriptorSetLayout::DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo* pCreateInfo, void* mem) :
flags(pCreateInfo->flags), bindingCount(pCreateInfo->bindingCount), bindings(reinterpret_cast<VkDescriptorSetLayoutBinding*>(mem))
@@ -646,4 +644,4 @@
memcpy(memToWrite, memToRead, writeSize);
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkDescriptorSetLayout.hpp b/src/Vulkan/VkDescriptorSetLayout.hpp
index 81ada71..9a7b333 100644
--- a/src/Vulkan/VkDescriptorSetLayout.hpp
+++ b/src/Vulkan/VkDescriptorSetLayout.hpp
@@ -21,8 +21,7 @@
#include "Vulkan/VkImageView.hpp"
#include "Device/Sampler.hpp"
-namespace vk
-{
+namespace vk {
class DescriptorSet;
class Device;
@@ -146,6 +145,6 @@
return DescriptorSetLayout::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_DESCRIPTOR_SET_LAYOUT_HPP_
diff --git a/src/Vulkan/VkDescriptorUpdateTemplate.cpp b/src/Vulkan/VkDescriptorUpdateTemplate.cpp
index e70ad73..3a83120 100644
--- a/src/Vulkan/VkDescriptorUpdateTemplate.cpp
+++ b/src/Vulkan/VkDescriptorUpdateTemplate.cpp
@@ -17,33 +17,34 @@
#include "VkDescriptorSetLayout.hpp"
#include <cstring>
-namespace vk
+namespace vk {
+
+DescriptorUpdateTemplate::DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem) :
+ descriptorUpdateEntryCount(pCreateInfo->descriptorUpdateEntryCount),
+ descriptorUpdateEntries(reinterpret_cast<VkDescriptorUpdateTemplateEntry*>(mem)),
+ descriptorSetLayout(vk::Cast(pCreateInfo->descriptorSetLayout))
{
- DescriptorUpdateTemplate::DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem) :
- descriptorUpdateEntryCount(pCreateInfo->descriptorUpdateEntryCount),
- descriptorUpdateEntries(reinterpret_cast<VkDescriptorUpdateTemplateEntry*>(mem)),
- descriptorSetLayout(vk::Cast(pCreateInfo->descriptorSetLayout))
+ for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
{
- for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
- {
- descriptorUpdateEntries[i] = pCreateInfo->pDescriptorUpdateEntries[i];
- }
+ descriptorUpdateEntries[i] = pCreateInfo->pDescriptorUpdateEntries[i];
}
+}
- size_t DescriptorUpdateTemplate::ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info)
+size_t DescriptorUpdateTemplate::ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info)
+{
+ return info->descriptorUpdateEntryCount * sizeof(VkDescriptorUpdateTemplateEntry);
+}
+
+void DescriptorUpdateTemplate::updateDescriptorSet(Device* device, VkDescriptorSet vkDescriptorSet, const void* pData)
+{
+
+ DescriptorSet* descriptorSet = vk::Cast(vkDescriptorSet);
+
+ for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
{
- return info->descriptorUpdateEntryCount * sizeof(VkDescriptorUpdateTemplateEntry);
+ DescriptorSetLayout::WriteDescriptorSet(device, descriptorSet, descriptorUpdateEntries[i],
+ reinterpret_cast<char const *>(pData));
}
+}
- void DescriptorUpdateTemplate::updateDescriptorSet(Device* device, VkDescriptorSet vkDescriptorSet, const void* pData)
- {
-
- DescriptorSet* descriptorSet = vk::Cast(vkDescriptorSet);
-
- for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
- {
- DescriptorSetLayout::WriteDescriptorSet(device, descriptorSet, descriptorUpdateEntries[i],
- reinterpret_cast<char const *>(pData));
- }
- }
-}
\ No newline at end of file
+} // namespace vk
\ No newline at end of file
diff --git a/src/Vulkan/VkDescriptorUpdateTemplate.hpp b/src/Vulkan/VkDescriptorUpdateTemplate.hpp
index 90a8b96..0884b1e 100644
--- a/src/Vulkan/VkDescriptorUpdateTemplate.hpp
+++ b/src/Vulkan/VkDescriptorUpdateTemplate.hpp
@@ -1,47 +1,47 @@
-// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
-//
-// 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 VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
-#define VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
-
-#include "VkObject.hpp"
-
-namespace vk
-{
- class DescriptorSetLayout;
- class Device;
-
- class DescriptorUpdateTemplate : public Object<DescriptorUpdateTemplate, VkDescriptorUpdateTemplate>
- {
- public:
- DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem);
-
- static size_t ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info);
-
- void updateDescriptorSet(Device* device, VkDescriptorSet descriptorSet, const void* pData);
-
- private:
- uint32_t descriptorUpdateEntryCount = 0;
- VkDescriptorUpdateTemplateEntry* descriptorUpdateEntries = nullptr;
- DescriptorSetLayout* descriptorSetLayout = nullptr;
- };
-
- static inline DescriptorUpdateTemplate* Cast(VkDescriptorUpdateTemplate object)
- {
- return DescriptorUpdateTemplate::Cast(object);
- }
-
-} // namespace vk
-
-#endif // VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// 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 VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
+#define VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
+
+#include "VkObject.hpp"
+
+namespace vk {
+
+class DescriptorSetLayout;
+class Device;
+
+class DescriptorUpdateTemplate : public Object<DescriptorUpdateTemplate, VkDescriptorUpdateTemplate>
+{
+public:
+ DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem);
+
+ static size_t ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info);
+
+ void updateDescriptorSet(Device* device, VkDescriptorSet descriptorSet, const void* pData);
+
+private:
+ uint32_t descriptorUpdateEntryCount = 0;
+ VkDescriptorUpdateTemplateEntry* descriptorUpdateEntries = nullptr;
+ DescriptorSetLayout* descriptorSetLayout = nullptr;
+};
+
+static inline DescriptorUpdateTemplate* Cast(VkDescriptorUpdateTemplate object)
+{
+ return DescriptorUpdateTemplate::Cast(object);
+}
+
+} // namespace vk
+
+#endif // VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_
diff --git a/src/Vulkan/VkDestroy.h b/src/Vulkan/VkDestroy.h
index 114e2d0..7acd062 100644
--- a/src/Vulkan/VkDestroy.h
+++ b/src/Vulkan/VkDestroy.h
@@ -39,8 +39,7 @@
#include <type_traits>
-namespace vk
-{
+namespace vk {
// Because Vulkan uses optional allocation callbacks, we use them in a custom
// placement new operator in the VkObjectBase class for simplicity.
@@ -66,4 +65,4 @@
}
}
-}
+} // namespace vk
diff --git a/src/Vulkan/VkDevice.cpp b/src/Vulkan/VkDevice.cpp
index e1f454e..a8fcd9c 100644
--- a/src/Vulkan/VkDevice.cpp
+++ b/src/Vulkan/VkDevice.cpp
@@ -25,16 +25,16 @@
#include <climits>
#include <new> // Must #include this to use "placement new"
-namespace
+namespace {
+
+std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> now()
{
- std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> now()
- {
- return std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now());
- }
+ return std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now());
}
-namespace vk
-{
+} // anonymous namespace
+
+namespace vk {
std::shared_ptr<rr::Routine> Device::SamplingRoutineCache::query(const vk::Device::SamplingRoutineCache::Key& key) const
{
@@ -264,4 +264,4 @@
return samplingRoutineCacheMutex;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkDevice.hpp b/src/Vulkan/VkDevice.hpp
index 4aeb14c..24882e0 100644
--- a/src/Vulkan/VkDevice.hpp
+++ b/src/Vulkan/VkDevice.hpp
@@ -21,18 +21,10 @@
#include <memory>
#include <mutex>
-namespace marl
-{
- class Scheduler;
-}
+namespace marl { class Scheduler; }
+namespace sw { class Blitter; }
-namespace sw
-{
- class Blitter;
-}
-
-namespace vk
-{
+namespace vk {
class PhysicalDevice;
class Queue;
@@ -131,6 +123,6 @@
return static_cast<std::size_t>(hash); // Truncates to 32-bits on 32-bit platforms.
}
-} // namespace vk
+} // namespace vk
#endif // VK_DEVICE_HPP_
diff --git a/src/Vulkan/VkDeviceMemory.cpp b/src/Vulkan/VkDeviceMemory.cpp
index aeadf15..faaa4b5 100644
--- a/src/Vulkan/VkDeviceMemory.cpp
+++ b/src/Vulkan/VkDeviceMemory.cpp
@@ -16,8 +16,7 @@
#include "VkConfig.h"
-namespace vk
-{
+namespace vk {
// Base abstract interface for a device memory implementation.
class DeviceMemory::ExternalBase
@@ -86,7 +85,6 @@
class DeviceMemoryHostExternalBase : public DeviceMemory::ExternalBase
{
public:
-
// Does not support any external memory type at all.
static const VkExternalMemoryHandleTypeFlagBits typeFlagBit = (VkExternalMemoryHandleTypeFlagBits)0;
@@ -129,8 +127,7 @@
# endif
#endif
-namespace vk
-{
+namespace vk {
static void findTraits(const VkMemoryAllocateInfo* pAllocateInfo,
ExternalMemoryTraits* pTraits)
@@ -231,4 +228,4 @@
}
#endif
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkDeviceMemory.hpp b/src/Vulkan/VkDeviceMemory.hpp
index 230f0c9..d529ec9 100644
--- a/src/Vulkan/VkDeviceMemory.hpp
+++ b/src/Vulkan/VkDeviceMemory.hpp
@@ -18,8 +18,7 @@
#include "VkConfig.h"
#include "VkObject.hpp"
-namespace vk
-{
+namespace vk {
class DeviceMemory : public Object<DeviceMemory, VkDeviceMemory>
{
@@ -61,6 +60,6 @@
}
-} // namespace vk
+} // namespace vk
#endif // VK_DEVICE_MEMORY_HPP_
diff --git a/src/Vulkan/VkEvent.hpp b/src/Vulkan/VkEvent.hpp
index 57901ef..3304558 100644
--- a/src/Vulkan/VkEvent.hpp
+++ b/src/Vulkan/VkEvent.hpp
@@ -19,8 +19,7 @@
#include <condition_variable>
#include <mutex>
-namespace vk
-{
+namespace vk {
class Event : public Object<Event, VkEvent>
{
@@ -73,6 +72,6 @@
return Event::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_EVENT_HPP_
diff --git a/src/Vulkan/VkFence.hpp b/src/Vulkan/VkFence.hpp
index 586d42f..af8becd 100644
--- a/src/Vulkan/VkFence.hpp
+++ b/src/Vulkan/VkFence.hpp
@@ -22,8 +22,7 @@
#include "marl/event.h"
#include "marl/waitgroup.h"
-namespace vk
-{
+namespace vk {
class Fence : public Object<Fence, VkFence>, public sw::TaskEvents
{
@@ -88,6 +87,6 @@
return Fence::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_FENCE_HPP_
diff --git a/src/Vulkan/VkFormat.cpp b/src/Vulkan/VkFormat.cpp
index 8e07ea4..f454d94 100644
--- a/src/Vulkan/VkFormat.cpp
+++ b/src/Vulkan/VkFormat.cpp
@@ -16,8 +16,7 @@
#include "VkDebug.hpp"
#include "System/Math.hpp"
-namespace vk
-{
+namespace vk {
bool Format::isUnsignedNormalized() const
{
@@ -2231,4 +2230,4 @@
return false;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkFormat.h b/src/Vulkan/VkFormat.h
index 77b9ad5..486bf50 100644
--- a/src/Vulkan/VkFormat.h
+++ b/src/Vulkan/VkFormat.h
@@ -17,13 +17,9 @@
#include <Vulkan/VulkanPlatform.h>
-namespace sw
-{
- struct float4;
-}
+namespace sw { struct float4; }
-namespace vk
-{
+namespace vk {
class Format
{
@@ -76,6 +72,6 @@
VkFormat format = VK_FORMAT_UNDEFINED;
};
-} // namespace vk
+} // namespace vk
#endif // VK_FORMAT_UTILS_HPP_
\ No newline at end of file
diff --git a/src/Vulkan/VkFramebuffer.cpp b/src/Vulkan/VkFramebuffer.cpp
index 7c3617f..33be291 100644
--- a/src/Vulkan/VkFramebuffer.cpp
+++ b/src/Vulkan/VkFramebuffer.cpp
@@ -18,8 +18,7 @@
#include <algorithm>
#include <memory.h>
-namespace vk
-{
+namespace vk {
Framebuffer::Framebuffer(const VkFramebufferCreateInfo* pCreateInfo, void* mem) :
attachmentCount(pCreateInfo->attachmentCount),
@@ -151,4 +150,4 @@
return pCreateInfo->attachmentCount * sizeof(void*);
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkFramebuffer.hpp b/src/Vulkan/VkFramebuffer.hpp
index ce9b16a..a4c50bb 100644
--- a/src/Vulkan/VkFramebuffer.hpp
+++ b/src/Vulkan/VkFramebuffer.hpp
@@ -17,8 +17,7 @@
#include "VkObject.hpp"
-namespace vk
-{
+namespace vk {
class ImageView;
class RenderPass;
@@ -49,6 +48,6 @@
return Framebuffer::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_FRAMEBUFFER_HPP_
diff --git a/src/Vulkan/VkGetProcAddress.cpp b/src/Vulkan/VkGetProcAddress.cpp
index 5613da2..46d19cd 100644
--- a/src/Vulkan/VkGetProcAddress.cpp
+++ b/src/Vulkan/VkGetProcAddress.cpp
@@ -25,8 +25,7 @@
#include <vulkan/vk_android_native_buffer.h>
#endif
-namespace vk
-{
+namespace vk {
#define MAKE_VULKAN_GLOBAL_ENTRY(aFunction) { #aFunction, reinterpret_cast<PFN_vkVoidFunction>(aFunction) }
static const std::unordered_map<std::string, PFN_vkVoidFunction> globalFunctionPointers =
@@ -441,7 +440,7 @@
return nullptr;
}
-}
+} // namespace vk
#ifdef __ANDROID__
diff --git a/src/Vulkan/VkGetProcAddress.h b/src/Vulkan/VkGetProcAddress.h
index 27562ff..6eb017f 100644
--- a/src/Vulkan/VkGetProcAddress.h
+++ b/src/Vulkan/VkGetProcAddress.h
@@ -17,8 +17,7 @@
#include <Vulkan/VulkanPlatform.h>
-namespace vk
-{
+namespace vk {
class Device;
class Instance;
@@ -26,6 +25,6 @@
PFN_vkVoidFunction GetInstanceProcAddr(Instance* instance, const char* pName);
PFN_vkVoidFunction GetDeviceProcAddr(Device* device, const char* pName);
-}
+} // namespace vk
#endif // VK_UTILS_HPP_
\ No newline at end of file
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index 0b7224f..e5d38e1 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -24,38 +24,38 @@
#include "System/GrallocAndroid.hpp"
#endif
-namespace
+namespace {
+
+ETC_Decoder::InputType GetInputType(const vk::Format& format)
{
- ETC_Decoder::InputType GetInputType(const vk::Format& format)
+ switch(format)
{
- switch(format)
- {
- case VK_FORMAT_EAC_R11_UNORM_BLOCK:
- return ETC_Decoder::ETC_R_UNSIGNED;
- case VK_FORMAT_EAC_R11_SNORM_BLOCK:
- return ETC_Decoder::ETC_R_SIGNED;
- case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
- return ETC_Decoder::ETC_RG_UNSIGNED;
- case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
- return ETC_Decoder::ETC_RG_SIGNED;
- case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
- case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
- return ETC_Decoder::ETC_RGB;
- case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
- case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
- return ETC_Decoder::ETC_RGB_PUNCHTHROUGH_ALPHA;
- case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
- case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
- return ETC_Decoder::ETC_RGBA;
- default:
- UNIMPLEMENTED("format: %d", int(format));
- return ETC_Decoder::ETC_RGBA;
- }
+ case VK_FORMAT_EAC_R11_UNORM_BLOCK:
+ return ETC_Decoder::ETC_R_UNSIGNED;
+ case VK_FORMAT_EAC_R11_SNORM_BLOCK:
+ return ETC_Decoder::ETC_R_SIGNED;
+ case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
+ return ETC_Decoder::ETC_RG_UNSIGNED;
+ case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
+ return ETC_Decoder::ETC_RG_SIGNED;
+ case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
+ case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
+ return ETC_Decoder::ETC_RGB;
+ case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
+ case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
+ return ETC_Decoder::ETC_RGB_PUNCHTHROUGH_ALPHA;
+ case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
+ case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
+ return ETC_Decoder::ETC_RGBA;
+ default:
+ UNIMPLEMENTED("format: %d", int(format));
+ return ETC_Decoder::ETC_RGBA;
}
}
-namespace vk
-{
+} // anonymous namespace
+
+namespace vk {
Image::Image(const VkImageCreateInfo* pCreateInfo, void* mem, Device *device) :
device(device),
@@ -992,4 +992,4 @@
}
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkImage.hpp b/src/Vulkan/VkImage.hpp
index f717b99..bc67d7e 100644
--- a/src/Vulkan/VkImage.hpp
+++ b/src/Vulkan/VkImage.hpp
@@ -22,8 +22,7 @@
#include <vulkan/vk_android_native_buffer.h> // For VkSwapchainImageUsageFlagsANDROID and buffer_handle_t
#endif
-namespace vk
-{
+namespace vk {
class Buffer;
class Device;
@@ -135,6 +134,6 @@
return Image::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_IMAGE_HPP_
diff --git a/src/Vulkan/VkImageView.cpp b/src/Vulkan/VkImageView.cpp
index 3a169b8..27c2f38 100644
--- a/src/Vulkan/VkImageView.cpp
+++ b/src/Vulkan/VkImageView.cpp
@@ -16,43 +16,43 @@
#include "VkImage.hpp"
#include <System/Math.hpp>
-namespace
+namespace {
+
+VkComponentMapping ResolveComponentMapping(VkComponentMapping m, vk::Format format)
{
- VkComponentMapping ResolveComponentMapping(VkComponentMapping m, vk::Format format)
- {
- m = vk::ResolveIdentityMapping(m);
+ m = vk::ResolveIdentityMapping(m);
- // Replace non-present components with zero/one swizzles so that the sampler
- // will give us correct interactions between channel replacement and texel replacement,
- // where we've had to invent new channels behind the app's back (eg transparent decompression
- // of ETC2 RGB -> BGRA8)
- VkComponentSwizzle table[] = {
- VK_COMPONENT_SWIZZLE_IDENTITY,
- VK_COMPONENT_SWIZZLE_ZERO,
- VK_COMPONENT_SWIZZLE_ONE,
- VK_COMPONENT_SWIZZLE_R,
- format.componentCount() < 2 ? VK_COMPONENT_SWIZZLE_ZERO : VK_COMPONENT_SWIZZLE_G,
- format.componentCount() < 3 ? VK_COMPONENT_SWIZZLE_ZERO : VK_COMPONENT_SWIZZLE_B,
- format.componentCount() < 4 ? VK_COMPONENT_SWIZZLE_ONE : VK_COMPONENT_SWIZZLE_A,
- };
+ // Replace non-present components with zero/one swizzles so that the sampler
+ // will give us correct interactions between channel replacement and texel replacement,
+ // where we've had to invent new channels behind the app's back (eg transparent decompression
+ // of ETC2 RGB -> BGRA8)
+ VkComponentSwizzle table[] = {
+ VK_COMPONENT_SWIZZLE_IDENTITY,
+ VK_COMPONENT_SWIZZLE_ZERO,
+ VK_COMPONENT_SWIZZLE_ONE,
+ VK_COMPONENT_SWIZZLE_R,
+ format.componentCount() < 2 ? VK_COMPONENT_SWIZZLE_ZERO : VK_COMPONENT_SWIZZLE_G,
+ format.componentCount() < 3 ? VK_COMPONENT_SWIZZLE_ZERO : VK_COMPONENT_SWIZZLE_B,
+ format.componentCount() < 4 ? VK_COMPONENT_SWIZZLE_ONE : VK_COMPONENT_SWIZZLE_A,
+ };
- return {table[m.r], table[m.g], table[m.b], table[m.a]};
- }
-
- VkImageSubresourceRange ResolveRemainingLevelsLayers(VkImageSubresourceRange range, const vk::Image *image)
- {
- return {
- range.aspectMask,
- range.baseMipLevel,
- (range.levelCount == VK_REMAINING_MIP_LEVELS) ? (image->getMipLevels() - range.baseMipLevel) : range.levelCount,
- range.baseArrayLayer,
- (range.layerCount == VK_REMAINING_ARRAY_LAYERS) ? (image->getArrayLayers() - range.baseArrayLayer) : range.layerCount,
- };
- }
+ return {table[m.r], table[m.g], table[m.b], table[m.a]};
}
-namespace vk
+VkImageSubresourceRange ResolveRemainingLevelsLayers(VkImageSubresourceRange range, const vk::Image *image)
{
+ return {
+ range.aspectMask,
+ range.baseMipLevel,
+ (range.levelCount == VK_REMAINING_MIP_LEVELS) ? (image->getMipLevels() - range.baseMipLevel) : range.levelCount,
+ range.baseArrayLayer,
+ (range.layerCount == VK_REMAINING_ARRAY_LAYERS) ? (image->getArrayLayers() - range.baseArrayLayer) : range.layerCount,
+ };
+}
+
+} // anonymous namespace
+
+namespace vk {
std::atomic<uint32_t> ImageView::nextID(1);
@@ -298,4 +298,4 @@
return getImage(usage)->getTexelPointer(offset, imageSubresourceLayers);
}
-}
+} // namespace vk
diff --git a/src/Vulkan/VkImageView.hpp b/src/Vulkan/VkImageView.hpp
index 8563520..86adedd 100644
--- a/src/Vulkan/VkImageView.hpp
+++ b/src/Vulkan/VkImageView.hpp
@@ -22,8 +22,8 @@
#include <atomic>
-namespace vk
-{
+namespace vk {
+
class SamplerYcbcrConversion;
class ImageView : public Object<ImageView, VkImageView>
@@ -111,6 +111,6 @@
return ImageView::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_IMAGE_VIEW_HPP_
diff --git a/src/Vulkan/VkInstance.cpp b/src/Vulkan/VkInstance.cpp
index f93dc7f..70dee28 100644
--- a/src/Vulkan/VkInstance.cpp
+++ b/src/Vulkan/VkInstance.cpp
@@ -15,8 +15,7 @@
#include "VkInstance.hpp"
#include "VkDestroy.h"
-namespace vk
-{
+namespace vk {
Instance::Instance(const VkInstanceCreateInfo* pCreateInfo, void* mem, VkPhysicalDevice physicalDevice)
: physicalDevice(physicalDevice)
@@ -69,4 +68,4 @@
return VK_SUCCESS;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkInstance.hpp b/src/Vulkan/VkInstance.hpp
index 10eac6d..0234d9c 100644
--- a/src/Vulkan/VkInstance.hpp
+++ b/src/Vulkan/VkInstance.hpp
@@ -17,8 +17,7 @@
#include "VkObject.hpp"
-namespace vk
-{
+namespace vk {
class Instance
{
@@ -45,6 +44,6 @@
return DispatchableInstance::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_INSTANCE_HPP_
diff --git a/src/Vulkan/VkMemory.cpp b/src/Vulkan/VkMemory.cpp
index 769b0db..128e648 100644
--- a/src/Vulkan/VkMemory.cpp
+++ b/src/Vulkan/VkMemory.cpp
@@ -19,8 +19,7 @@
#include "VkMemory.h"
#include "System/Memory.hpp"
-namespace vk
-{
+namespace vk {
void* allocate(size_t count, size_t alignment, const VkAllocationCallbacks* pAllocator, VkSystemAllocationScope allocationScope)
{
@@ -34,6 +33,6 @@
pAllocator ? pAllocator->pfnFree(pAllocator->pUserData, ptr) : sw::deallocate(ptr);
}
-} // namespace vk
+} // namespace vk
#endif // VK_OBJECT_HPP_
diff --git a/src/Vulkan/VkMemory.h b/src/Vulkan/VkMemory.h
index bbc6006..e6f51b7 100644
--- a/src/Vulkan/VkMemory.h
+++ b/src/Vulkan/VkMemory.h
@@ -17,8 +17,7 @@
#include <Vulkan/VulkanPlatform.h>
-namespace vk
-{
+namespace vk {
void* allocate(size_t count, size_t alignment, const VkAllocationCallbacks* pAllocator,
VkSystemAllocationScope allocationScope = VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@@ -30,6 +29,6 @@
return static_cast<T*>(allocate(count, alignof(T), pAllocator, T::GetAllocationScope()));
}
-} // namespace vk
+} // namespace vk
#endif // VK_MEMORY_HPP_
diff --git a/src/Vulkan/VkObject.hpp b/src/Vulkan/VkObject.hpp
index b401af5..105cc94 100644
--- a/src/Vulkan/VkObject.hpp
+++ b/src/Vulkan/VkObject.hpp
@@ -23,8 +23,7 @@
#include <Vulkan/VulkanPlatform.h>
#include <vulkan/vk_icd.h>
-namespace vk
-{
+namespace vk {
template<typename T, typename VkT>
static inline T* VkTtoT(VkT vkObject)
@@ -166,6 +165,6 @@
}
};
-} // namespace vk
+} // namespace vk
#endif // VK_OBJECT_HPP_
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 5a32b2f..5dac6ff 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -20,8 +20,7 @@
#include <limits>
#include <cstring>
-namespace vk
-{
+namespace vk {
static void setExternalMemoryProperties(VkExternalMemoryHandleTypeFlagBits handleType, VkExternalMemoryProperties* properties)
{
@@ -873,4 +872,4 @@
return properties;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkPhysicalDevice.hpp b/src/Vulkan/VkPhysicalDevice.hpp
index a7faecf..c4007cc 100644
--- a/src/Vulkan/VkPhysicalDevice.hpp
+++ b/src/Vulkan/VkPhysicalDevice.hpp
@@ -22,8 +22,7 @@
#include <vulkan/vk_android_native_buffer.h>
#endif
-namespace vk
-{
+namespace vk {
class PhysicalDevice
{
@@ -89,6 +88,6 @@
return DispatchablePhysicalDevice::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_PHYSICAL_DEVICE_HPP_
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 5baa9dd..f72d229 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -29,8 +29,7 @@
#include <iostream>
-namespace
-{
+namespace {
sw::StreamType getStreamType(VkFormat format)
{
@@ -240,8 +239,7 @@
} // anonymous namespace
-namespace vk
-{
+namespace vk {
Pipeline::Pipeline(PipelineLayout const *layout, const Device *device)
: layout(layout),
@@ -696,4 +694,4 @@
groupCountX, groupCountY, groupCountZ);
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkPipeline.hpp b/src/Vulkan/VkPipeline.hpp
index 52cfc90..1d50226 100644
--- a/src/Vulkan/VkPipeline.hpp
+++ b/src/Vulkan/VkPipeline.hpp
@@ -21,14 +21,14 @@
#include "Device/Renderer.hpp"
#include <memory>
-namespace sw
-{
- class ComputeProgram;
- class SpirvShader;
-}
+namespace sw {
-namespace vk
-{
+class ComputeProgram;
+class SpirvShader;
+
+} // namespace sw
+
+namespace vk {
class PipelineCache;
class PipelineLayout;
@@ -145,6 +145,6 @@
return Pipeline::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_PIPELINE_HPP_
diff --git a/src/Vulkan/VkPipelineCache.cpp b/src/Vulkan/VkPipelineCache.cpp
index f9fe9cf..40fa5c3 100644
--- a/src/Vulkan/VkPipelineCache.cpp
+++ b/src/Vulkan/VkPipelineCache.cpp
@@ -15,8 +15,7 @@
#include "VkPipelineCache.hpp"
#include <cstring>
-namespace vk
-{
+namespace vk {
PipelineCache::SpirvShaderKey::SpecializationInfo::SpecializationInfo(const VkSpecializationInfo* specializationInfo)
{
@@ -250,4 +249,4 @@
computePrograms[key] = computeProgram;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkPipelineCache.hpp b/src/Vulkan/VkPipelineCache.hpp
index 7e701ed..efe5563 100644
--- a/src/Vulkan/VkPipelineCache.hpp
+++ b/src/Vulkan/VkPipelineCache.hpp
@@ -25,14 +25,14 @@
#include <string>
#include <vector>
-namespace sw
-{
- class ComputeProgram;
- class SpirvShader;
-}
+namespace sw {
-namespace vk
-{
+class ComputeProgram;
+class SpirvShader;
+
+} // namespace sw
+
+namespace vk {
class PipelineLayout;
class RenderPass;
@@ -145,6 +145,6 @@
return PipelineCache::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_PIPELINE_CACHE_HPP_
diff --git a/src/Vulkan/VkPipelineLayout.cpp b/src/Vulkan/VkPipelineLayout.cpp
index da0d3ae..6d42c34 100644
--- a/src/Vulkan/VkPipelineLayout.cpp
+++ b/src/Vulkan/VkPipelineLayout.cpp
@@ -15,8 +15,7 @@
#include "VkPipelineLayout.hpp"
#include <cstring>
-namespace vk
-{
+namespace vk {
PipelineLayout::PipelineLayout(const VkPipelineLayoutCreateInfo* pCreateInfo, void* mem)
: setLayoutCount(pCreateInfo->setLayoutCount), pushConstantRangeCount(pCreateInfo->pushConstantRangeCount)
@@ -40,9 +39,9 @@
uint32_t dynamicOffsetBase = 0;
for (uint32_t i = 0; i < setLayoutCount; i++)
{
- uint32_t dynamicDescriptorCount = setLayouts[i]->getDynamicDescriptorCount();
- ASSERT_OR_RETURN((dynamicOffsetBase + dynamicDescriptorCount) <= MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC);
- dynamicOffsetBases[i] = dynamicOffsetBase;
+ uint32_t dynamicDescriptorCount = setLayouts[i]->getDynamicDescriptorCount();
+ ASSERT_OR_RETURN((dynamicOffsetBase + dynamicDescriptorCount) <= MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC);
+ dynamicOffsetBases[i] = dynamicOffsetBase;
dynamicOffsetBase += dynamicDescriptorCount;
}
}
@@ -76,4 +75,4 @@
return dynamicOffsetBases[descriptorSet];
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkPipelineLayout.hpp b/src/Vulkan/VkPipelineLayout.hpp
index f450c5d..7821396 100644
--- a/src/Vulkan/VkPipelineLayout.hpp
+++ b/src/Vulkan/VkPipelineLayout.hpp
@@ -17,8 +17,7 @@
#include "VkDescriptorSetLayout.hpp"
-namespace vk
-{
+namespace vk {
class PipelineLayout : public Object<PipelineLayout, VkPipelineLayout>
{
@@ -48,6 +47,6 @@
return PipelineLayout::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_PIPELINE_LAYOUT_HPP_
diff --git a/src/Vulkan/VkQueryPool.cpp b/src/Vulkan/VkQueryPool.cpp
index 5aa9b08..6c4f975 100644
--- a/src/Vulkan/VkQueryPool.cpp
+++ b/src/Vulkan/VkQueryPool.cpp
@@ -18,201 +18,202 @@
#include <cstring>
#include <new>
-namespace vk
+namespace vk {
+
+Query::Query() : finished(marl::Event::Mode::Manual), state(UNAVAILABLE), type(INVALID_TYPE), value(0) {}
+
+void Query::reset()
{
- Query::Query() : finished(marl::Event::Mode::Manual), state(UNAVAILABLE), type(INVALID_TYPE), value(0) {}
+ finished.clear();
+ auto prevState = state.exchange(UNAVAILABLE);
+ ASSERT(prevState != ACTIVE);
+ type = INVALID_TYPE;
+ value = 0;
+}
- void Query::reset()
+void Query::prepare(VkQueryType ty)
+{
+ auto prevState = state.exchange(ACTIVE);
+ ASSERT(prevState == UNAVAILABLE);
+ type = ty;
+}
+
+void Query::start()
+{
+ ASSERT(state == ACTIVE);
+ wg.add();
+}
+
+void Query::finish()
+{
+ if (wg.done())
{
- finished.clear();
- auto prevState = state.exchange(UNAVAILABLE);
- ASSERT(prevState != ACTIVE);
- type = INVALID_TYPE;
- value = 0;
+ auto prevState = state.exchange(FINISHED);
+ ASSERT(prevState == ACTIVE);
+ finished.signal();
+ }
+}
+
+Query::Data Query::getData() const
+{
+ Data out;
+ out.state = state;
+ out.value = value;
+ return out;
+}
+
+VkQueryType Query::getType() const
+{
+ return type;
+}
+
+void Query::wait()
+{
+ finished.wait();
+}
+
+void Query::set(int64_t v)
+{
+ value = v;
+}
+
+void Query::add(int64_t v)
+{
+ value += v;
+}
+
+QueryPool::QueryPool(const VkQueryPoolCreateInfo* pCreateInfo, void* mem) :
+ pool(reinterpret_cast<Query*>(mem)), type(pCreateInfo->queryType),
+ count(pCreateInfo->queryCount)
+{
+ // According to the Vulkan spec, section 34.1. Features:
+ // "pipelineStatisticsQuery specifies whether the pipeline statistics
+ // queries are supported. If this feature is not enabled, queries of
+ // type VK_QUERY_TYPE_PIPELINE_STATISTICS cannot be created, and
+ // none of the VkQueryPipelineStatisticFlagBits bits can be set in the
+ // pipelineStatistics member of the VkQueryPoolCreateInfo structure."
+ if(type == VK_QUERY_TYPE_PIPELINE_STATISTICS)
+ {
+ UNIMPLEMENTED("pCreateInfo->queryType");
}
- void Query::prepare(VkQueryType ty)
+ // Construct all queries
+ for(uint32_t i = 0; i < count; i++)
{
- auto prevState = state.exchange(ACTIVE);
- ASSERT(prevState == UNAVAILABLE);
- type = ty;
+ new (&pool[i]) Query();
}
+}
- void Query::start()
- {
- ASSERT(state == ACTIVE);
- wg.add();
- }
+void QueryPool::destroy(const VkAllocationCallbacks* pAllocator)
+{
+ vk::deallocate(pool, pAllocator);
+}
- void Query::finish()
+size_t QueryPool::ComputeRequiredAllocationSize(const VkQueryPoolCreateInfo* pCreateInfo)
+{
+ return sizeof(Query) * pCreateInfo->queryCount;
+}
+
+VkResult QueryPool::getResults(uint32_t firstQuery, uint32_t queryCount, size_t dataSize,
+ void* pData, VkDeviceSize stride, VkQueryResultFlags flags) const
+{
+ // dataSize must be large enough to contain the result of each query
+ ASSERT(static_cast<size_t>(stride * queryCount) <= dataSize);
+
+ // The sum of firstQuery and queryCount must be less than or equal to the number of queries
+ ASSERT((firstQuery + queryCount) <= count);
+
+ VkResult result = VK_SUCCESS;
+ uint8_t* data = static_cast<uint8_t*>(pData);
+ for(uint32_t i = firstQuery; i < (firstQuery + queryCount); i++, data += stride)
{
- if (wg.done())
+ // If VK_QUERY_RESULT_WAIT_BIT and VK_QUERY_RESULT_PARTIAL_BIT are both not set
+ // then no result values are written to pData for queries that are in the
+ // unavailable state at the time of the call, and vkGetQueryPoolResults returns
+ // VK_NOT_READY. However, availability state is still written to pData for those
+ // queries if VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set.
+ auto &query = pool[i];
+
+ if(flags & VK_QUERY_RESULT_WAIT_BIT) // Must wait for query to finish
{
- auto prevState = state.exchange(FINISHED);
- ASSERT(prevState == ACTIVE);
- finished.signal();
- }
- }
-
- Query::Data Query::getData() const
- {
- Data out;
- out.state = state;
- out.value = value;
- return out;
- }
-
- VkQueryType Query::getType() const
- {
- return type;
- }
-
- void Query::wait()
- {
- finished.wait();
- }
-
- void Query::set(int64_t v)
- {
- value = v;
- }
-
- void Query::add(int64_t v)
- {
- value += v;
- }
-
- QueryPool::QueryPool(const VkQueryPoolCreateInfo* pCreateInfo, void* mem) :
- pool(reinterpret_cast<Query*>(mem)), type(pCreateInfo->queryType),
- count(pCreateInfo->queryCount)
- {
- // According to the Vulkan spec, section 34.1. Features:
- // "pipelineStatisticsQuery specifies whether the pipeline statistics
- // queries are supported. If this feature is not enabled, queries of
- // type VK_QUERY_TYPE_PIPELINE_STATISTICS cannot be created, and
- // none of the VkQueryPipelineStatisticFlagBits bits can be set in the
- // pipelineStatistics member of the VkQueryPoolCreateInfo structure."
- if(type == VK_QUERY_TYPE_PIPELINE_STATISTICS)
- {
- UNIMPLEMENTED("pCreateInfo->queryType");
+ query.wait();
}
- // Construct all queries
- for(uint32_t i = 0; i < count; i++)
+ const auto current = query.getData();
+
+ bool writeResult = true;
+ if(current.state == Query::ACTIVE)
{
- new (&pool[i]) Query();
+ result = VK_NOT_READY;
+ writeResult = (flags & VK_QUERY_RESULT_PARTIAL_BIT); // Allow writing partial results
}
- }
- void QueryPool::destroy(const VkAllocationCallbacks* pAllocator)
- {
- vk::deallocate(pool, pAllocator);
- }
-
- size_t QueryPool::ComputeRequiredAllocationSize(const VkQueryPoolCreateInfo* pCreateInfo)
- {
- return sizeof(Query) * pCreateInfo->queryCount;
- }
-
- VkResult QueryPool::getResults(uint32_t firstQuery, uint32_t queryCount, size_t dataSize,
- void* pData, VkDeviceSize stride, VkQueryResultFlags flags) const
- {
- // dataSize must be large enough to contain the result of each query
- ASSERT(static_cast<size_t>(stride * queryCount) <= dataSize);
-
- // The sum of firstQuery and queryCount must be less than or equal to the number of queries
- ASSERT((firstQuery + queryCount) <= count);
-
- VkResult result = VK_SUCCESS;
- uint8_t* data = static_cast<uint8_t*>(pData);
- for(uint32_t i = firstQuery; i < (firstQuery + queryCount); i++, data += stride)
+ if(flags & VK_QUERY_RESULT_64_BIT)
{
- // If VK_QUERY_RESULT_WAIT_BIT and VK_QUERY_RESULT_PARTIAL_BIT are both not set
- // then no result values are written to pData for queries that are in the
- // unavailable state at the time of the call, and vkGetQueryPoolResults returns
- // VK_NOT_READY. However, availability state is still written to pData for those
- // queries if VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set.
- auto &query = pool[i];
-
- if(flags & VK_QUERY_RESULT_WAIT_BIT) // Must wait for query to finish
+ uint64_t* result64 = reinterpret_cast<uint64_t*>(data);
+ if(writeResult)
{
- query.wait();
+ result64[0] = current.value;
}
-
- const auto current = query.getData();
-
- bool writeResult = true;
- if(current.state == Query::ACTIVE)
+ if(flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) // Output query availablity
{
- result = VK_NOT_READY;
- writeResult = (flags & VK_QUERY_RESULT_PARTIAL_BIT); // Allow writing partial results
- }
-
- if(flags & VK_QUERY_RESULT_64_BIT)
- {
- uint64_t* result64 = reinterpret_cast<uint64_t*>(data);
- if(writeResult)
- {
- result64[0] = current.value;
- }
- if(flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) // Output query availablity
- {
- result64[1] = current.state;
- }
- }
- else
- {
- uint32_t* result32 = reinterpret_cast<uint32_t*>(data);
- if(writeResult)
- {
- result32[0] = static_cast<uint32_t>(current.value);
- }
- if(flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) // Output query availablity
- {
- result32[1] = current.state;
- }
+ result64[1] = current.state;
}
}
-
- return result;
- }
-
- void QueryPool::begin(uint32_t query, VkQueryControlFlags flags)
- {
- ASSERT(query < count);
-
- if(flags != 0)
+ else
{
- UNIMPLEMENTED("flags");
- }
-
- pool[query].prepare(type);
- pool[query].start();
- }
-
- void QueryPool::end(uint32_t query)
- {
- ASSERT(query < count);
- pool[query].finish();
- }
-
- void QueryPool::reset(uint32_t firstQuery, uint32_t queryCount)
- {
- // The sum of firstQuery and queryCount must be less than or equal to the number of queries
- ASSERT((firstQuery + queryCount) <= count);
-
- for(uint32_t i = firstQuery; i < (firstQuery + queryCount); i++)
- {
- pool[i].reset();
+ uint32_t* result32 = reinterpret_cast<uint32_t*>(data);
+ if(writeResult)
+ {
+ result32[0] = static_cast<uint32_t>(current.value);
+ }
+ if(flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) // Output query availablity
+ {
+ result32[1] = current.state;
+ }
}
}
- void QueryPool::writeTimestamp(uint32_t query)
- {
- ASSERT(query < count);
- ASSERT(type == VK_QUERY_TYPE_TIMESTAMP);
+ return result;
+}
- pool[query].set(std::chrono::time_point_cast<std::chrono::nanoseconds>(
- std::chrono::system_clock::now()).time_since_epoch().count());
+void QueryPool::begin(uint32_t query, VkQueryControlFlags flags)
+{
+ ASSERT(query < count);
+
+ if(flags != 0)
+ {
+ UNIMPLEMENTED("flags");
}
-} // namespace vk
+
+ pool[query].prepare(type);
+ pool[query].start();
+}
+
+void QueryPool::end(uint32_t query)
+{
+ ASSERT(query < count);
+ pool[query].finish();
+}
+
+void QueryPool::reset(uint32_t firstQuery, uint32_t queryCount)
+{
+ // The sum of firstQuery and queryCount must be less than or equal to the number of queries
+ ASSERT((firstQuery + queryCount) <= count);
+
+ for(uint32_t i = firstQuery; i < (firstQuery + queryCount); i++)
+ {
+ pool[i].reset();
+ }
+}
+
+void QueryPool::writeTimestamp(uint32_t query)
+{
+ ASSERT(query < count);
+ ASSERT(type == VK_QUERY_TYPE_TIMESTAMP);
+
+ pool[query].set(std::chrono::time_point_cast<std::chrono::nanoseconds>(
+ std::chrono::system_clock::now()).time_since_epoch().count());
+}
+
+} // namespace vk
diff --git a/src/Vulkan/VkQueryPool.hpp b/src/Vulkan/VkQueryPool.hpp
index 5ad3115..6e887b1 100644
--- a/src/Vulkan/VkQueryPool.hpp
+++ b/src/Vulkan/VkQueryPool.hpp
@@ -24,8 +24,7 @@
#include <condition_variable>
#include <mutex>
-namespace vk
-{
+namespace vk {
class Query
{
@@ -119,6 +118,6 @@
return QueryPool::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_QUERY_POOL_HPP_
diff --git a/src/Vulkan/VkQueue.cpp b/src/Vulkan/VkQueue.cpp
index 25e30e9..4c5f798 100644
--- a/src/Vulkan/VkQueue.cpp
+++ b/src/Vulkan/VkQueue.cpp
@@ -26,8 +26,7 @@
#include <cstring>
-namespace
-{
+namespace {
VkSubmitInfo* DeepCopySubmitInfo(uint32_t submitCount, const VkSubmitInfo* pSubmits)
{
@@ -74,10 +73,9 @@
return submits;
}
-} // anonymous namespace
+} // anonymous namespace
-namespace vk
-{
+namespace vk {
Queue::Queue(Device* device, marl::Scheduler *scheduler) : device(device)
{
@@ -240,4 +238,4 @@
}
#endif
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkQueue.hpp b/src/Vulkan/VkQueue.hpp
index cf1f955..e5c600e 100644
--- a/src/Vulkan/VkQueue.hpp
+++ b/src/Vulkan/VkQueue.hpp
@@ -22,19 +22,16 @@
#include "System/Synchronization.hpp"
-namespace marl
-{
- class Scheduler;
-}
+namespace marl { class Scheduler; }
-namespace sw
-{
- class Context;
- class Renderer;
-}
+namespace sw {
-namespace vk
-{
+class Context;
+class Renderer;
+
+} // namespace sw
+
+namespace vk {
class Device;
class Fence;
@@ -85,6 +82,6 @@
return reinterpret_cast<Queue*>(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_QUEUE_HPP_
diff --git a/src/Vulkan/VkRenderPass.cpp b/src/Vulkan/VkRenderPass.cpp
index 2a360c0..27de7a6 100644
--- a/src/Vulkan/VkRenderPass.cpp
+++ b/src/Vulkan/VkRenderPass.cpp
@@ -16,8 +16,7 @@
#include "VkStringify.hpp"
#include <cstring>
-namespace vk
-{
+namespace vk {
RenderPass::RenderPass(const VkRenderPassCreateInfo* pCreateInfo, void* mem) :
attachmentCount(pCreateInfo->attachmentCount),
@@ -221,4 +220,4 @@
attachmentViewMasks[attachment] |= viewMasks[subpass];
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkRenderPass.hpp b/src/Vulkan/VkRenderPass.hpp
index 338c8aa..70cf2a8 100644
--- a/src/Vulkan/VkRenderPass.hpp
+++ b/src/Vulkan/VkRenderPass.hpp
@@ -19,8 +19,7 @@
#include <vector>
-namespace vk
-{
+namespace vk {
class RenderPass : public Object<RenderPass, VkRenderPass>
{
@@ -101,6 +100,6 @@
return RenderPass::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_RENDER_PASS_HPP_
\ No newline at end of file
diff --git a/src/Vulkan/VkSampler.cpp b/src/Vulkan/VkSampler.cpp
index d80f699..c19515b 100644
--- a/src/Vulkan/VkSampler.cpp
+++ b/src/Vulkan/VkSampler.cpp
@@ -15,9 +15,8 @@
#include "VkSampler.hpp"
-namespace vk
-{
+namespace vk {
std::atomic<uint32_t> Sampler::nextID(1);
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkSampler.hpp b/src/Vulkan/VkSampler.hpp
index af9da6d..042a7c7 100644
--- a/src/Vulkan/VkSampler.hpp
+++ b/src/Vulkan/VkSampler.hpp
@@ -22,8 +22,7 @@
#include <atomic>
-namespace vk
-{
+namespace vk {
class Sampler : public Object<Sampler, VkSampler>
{
@@ -124,6 +123,6 @@
return SamplerYcbcrConversion::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_SAMPLER_HPP_
\ No newline at end of file
diff --git a/src/Vulkan/VkSemaphore.cpp b/src/Vulkan/VkSemaphore.cpp
index bb1878f..eb7231e 100644
--- a/src/Vulkan/VkSemaphore.cpp
+++ b/src/Vulkan/VkSemaphore.cpp
@@ -36,8 +36,7 @@
#include <mutex>
#include <utility>
-namespace vk
-{
+namespace vk {
// An implementation of VkSemaphore based on Marl primitives.
class Semaphore::Impl
diff --git a/src/Vulkan/VkSemaphore.hpp b/src/Vulkan/VkSemaphore.hpp
index 53ad4c2..742fc8a 100644
--- a/src/Vulkan/VkSemaphore.hpp
+++ b/src/Vulkan/VkSemaphore.hpp
@@ -22,8 +22,7 @@
#include <zircon/types.h>
#endif
-namespace vk
-{
+namespace vk {
class Semaphore : public Object<Semaphore, VkSemaphore>
{
@@ -64,6 +63,6 @@
return Semaphore::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_SEMAPHORE_HPP_
diff --git a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
index 9e3e23b..4da9d39 100644
--- a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
+++ b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
@@ -24,8 +24,7 @@
// VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA
// which is not official yet but used by Fuchsia at the moment.
-namespace vk
-{
+namespace vk {
class Semaphore::External {
public:
diff --git a/src/Vulkan/VkSemaphoreExternalLinux.hpp b/src/Vulkan/VkSemaphoreExternalLinux.hpp
index 89ab2dc..9ba6c65 100644
--- a/src/Vulkan/VkSemaphoreExternalLinux.hpp
+++ b/src/Vulkan/VkSemaphoreExternalLinux.hpp
@@ -127,8 +127,7 @@
bool signaled = false;
};
-namespace vk
-{
+namespace vk {
class Semaphore::External {
public:
diff --git a/src/Vulkan/VkSemaphoreExternalNone.hpp b/src/Vulkan/VkSemaphoreExternalNone.hpp
index d056e6c..1b64003 100644
--- a/src/Vulkan/VkSemaphoreExternalNone.hpp
+++ b/src/Vulkan/VkSemaphoreExternalNone.hpp
@@ -15,8 +15,7 @@
#ifndef VK_SEMAPHORE_EXTERNAL_NONE_H_
#define VK_SEMAPHORE_EXTERNAL_NONE_H_
-namespace vk
-{
+namespace vk {
// Empty external sempahore implementation.
class Semaphore::External {
diff --git a/src/Vulkan/VkShaderModule.cpp b/src/Vulkan/VkShaderModule.cpp
index ce5e831..78a5ed4 100644
--- a/src/Vulkan/VkShaderModule.cpp
+++ b/src/Vulkan/VkShaderModule.cpp
@@ -16,8 +16,7 @@
#include <cstring>
-namespace vk
-{
+namespace vk {
std::atomic<uint32_t> ShaderModule::serialCounter(1); // Start at 1, 0 is invalid shader.
@@ -38,4 +37,4 @@
return pCreateInfo->codeSize;
}
-} // namespace vk
+} // namespace vk
diff --git a/src/Vulkan/VkShaderModule.hpp b/src/Vulkan/VkShaderModule.hpp
index ba30b59..c7e5ff9 100644
--- a/src/Vulkan/VkShaderModule.hpp
+++ b/src/Vulkan/VkShaderModule.hpp
@@ -20,13 +20,9 @@
#include <atomic>
#include <vector>
-namespace rr
-{
- class Routine;
-}
+namespace rr { class Routine; }
-namespace vk
-{
+namespace vk {
class ShaderModule : public Object<ShaderModule, VkShaderModule>
{
@@ -55,6 +51,6 @@
return ShaderModule::Cast(object);
}
-} // namespace vk
+} // namespace vk
#endif // VK_SHADER_MODULE_HPP_