implementing renderpass and vieport

This commit is contained in:
Dynamitos
2020-04-12 15:47:19 +02:00
parent 3ba8f2c2a0
commit 576747c369
54 changed files with 6234 additions and 4202 deletions
+10 -2
View File
@@ -13,7 +13,15 @@
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}/bin/Debug", "cwd": "${workspaceFolder}/bin/Debug",
"environment": [], "environment": [],
"externalConsole": false "externalConsole": false,
"symbolSearchPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\lib\\x64",
"requireExactSource": false,
"logging": {
"moduleLoad": false,
"exceptions": true,
"trace": true,
"traceResponse": true
}
}, },
{ {
"name": "Test", "name": "Test",
@@ -25,6 +33,6 @@
"cwd": "${workspaceRoot}/bin/Debug/test", "cwd": "${workspaceRoot}/bin/Debug/test",
"environment": [], "environment": [],
"externalConsole": false "externalConsole": false
} },
] ]
} }
+5 -2
View File
@@ -11,6 +11,9 @@
"xiosbase": "cpp", "xiosbase": "cpp",
"xmemory": "cpp", "xmemory": "cpp",
"xtree": "cpp", "xtree": "cpp",
"type_traits": "cpp" "type_traits": "cpp",
} "vector": "cpp",
"*.rh": "cpp",
"memory": "cpp"
},
} }
+6
View File
@@ -58,6 +58,12 @@ target_link_libraries(SeeleEngine ${Vulkan_LIBRARY})
target_link_libraries(SeeleEngine glfw ${GLFW_LIBRARIES}) target_link_libraries(SeeleEngine glfw ${GLFW_LIBRARIES})
target_link_libraries(SeeleEngine ${SLANG_LIBRARY}) target_link_libraries(SeeleEngine ${SLANG_LIBRARY})
if(MSVC)
target_compile_options(SeeleEngine PRIVATE /DEBUG:FASTLINK /Zi /W4)
else()
target_compile_options(SeeleEngine PRIVATE -Wall -Wextra -pedantic)
endif()
add_subdirectory(test/) add_subdirectory(test/)
add_custom_command(TARGET SeeleEngine POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPENDENT_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>) add_custom_command(TARGET SeeleEngine POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPENDENT_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>)
+137 -91
View File
@@ -10,26 +10,24 @@
namespace Seele namespace Seele
{ {
template<typename T> template <typename T>
struct Array struct Array
{ {
public: public:
Array() Array()
: allocated(DEFAULT_ALLOC_SIZE) : allocated(DEFAULT_ALLOC_SIZE), arraySize(0)
, arraySize(0)
{ {
_data = (T*)malloc(DEFAULT_ALLOC_SIZE * sizeof(T)); _data = new T[DEFAULT_ALLOC_SIZE];
assert(_data != nullptr); assert(_data != nullptr);
memset(_data, 0, sizeof(T) * DEFAULT_ALLOC_SIZE); memset(_data, 0, sizeof(T) * DEFAULT_ALLOC_SIZE);
refreshIterators(); refreshIterators();
} }
Array(size_t size, T value = T()) Array(uint32 size, T value = T())
: allocated(size) : allocated(size), arraySize(size)
, arraySize(size)
{ {
_data = (T*)malloc(size * sizeof(T)); _data = new T[size];
assert(_data != nullptr); assert(_data != nullptr);
for (int i = 0; i < size; ++i) for (uint32 i = 0; i < size; ++i)
{ {
assert(i < size); assert(i < size);
_data[i] = value; _data[i] = value;
@@ -37,10 +35,9 @@ namespace Seele
refreshIterators(); refreshIterators();
} }
Array(std::initializer_list<T> init) Array(std::initializer_list<T> init)
: allocated(init.size()) : allocated((uint32)init.size()), arraySize((uint32)init.size())
, arraySize(init.size())
{ {
_data = (T*)malloc(init.size() * sizeof(T)); _data = new T[init.size()];
auto it = init.begin(); auto it = init.begin();
for (size_t i = 0; it != init.end(); i++, it++) for (size_t i = 0; it != init.end(); i++, it++)
{ {
@@ -49,18 +46,16 @@ namespace Seele
} }
refreshIterators(); refreshIterators();
} }
Array(const Array& other) Array(const Array &other)
: allocated(other.allocated) : allocated(other.allocated), arraySize(other.arraySize)
, arraySize(other.arraySize)
{ {
_data = (T*)malloc(other.allocated * sizeof(T)); _data = new T[other.allocated];
assert(_data != nullptr); assert(_data != nullptr);
std::memcpy(_data, other._data, sizeof(T) * allocated); std::memcpy(_data, other._data, sizeof(T) * allocated);
refreshIterators(); refreshIterators();
} }
Array(Array&& other) noexcept Array(Array &&other) noexcept
: allocated(std::move(other.allocated)) : allocated(std::move(other.allocated)), arraySize(std::move(other.arraySize))
, arraySize(std::move(other.arraySize))
{ {
_data = other._data; _data = other._data;
other._data = nullptr; other._data = nullptr;
@@ -68,29 +63,29 @@ namespace Seele
other.arraySize = 0; other.arraySize = 0;
refreshIterators(); refreshIterators();
} }
Array& operator=(const Array& other) noexcept Array &operator=(const Array &other) noexcept
{ {
if(*this != other) if (*this != other)
{ {
if (_data != nullptr) if (_data != nullptr)
{ {
free(_data); delete[] _data;
} }
allocated = other.allocated; allocated = other.allocated;
arraySize = other.arraySize; arraySize = other.arraySize;
_data = (T*)malloc(other.allocated * sizeof(T)); _data = new T[other.allocated];
std::memcpy(_data, other._data, sizeof(T) * allocated); std::memcpy(_data, other._data, sizeof(T) * allocated);
refreshIterators(); refreshIterators();
} }
return *this; return *this;
} }
Array& operator=(Array&& other) noexcept Array &operator=(Array &&other) noexcept
{ {
if(*this != other) if (*this != other)
{ {
if (_data != nullptr) if (_data != nullptr)
{ {
free(_data); delete[] _data;
} }
allocated = std::move(other.allocated); allocated = std::move(other.allocated);
arraySize = std::move(other.arraySize); arraySize = std::move(other.arraySize);
@@ -101,27 +96,30 @@ namespace Seele
} }
~Array() ~Array()
{ {
if(_data) if (_data)
{ {
free(_data); delete[] _data;
_data = nullptr; _data = nullptr;
} }
} }
template<typename X> template <typename X>
class IteratorBase { class IteratorBase
{
public: public:
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
typedef X value_type; typedef X value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef X& reference; typedef X &reference;
typedef X* pointer; typedef X *pointer;
IteratorBase(X* x = nullptr) IteratorBase(X *x = nullptr)
: p(x) : p(x)
{} {
IteratorBase(const IteratorBase& i) }
IteratorBase(const IteratorBase &i)
: p(i.p) : p(i.p)
{} {
}
reference operator*() const reference operator*() const
{ {
return *p; return *p;
@@ -130,55 +128,60 @@ namespace Seele
{ {
return p; return p;
} }
inline bool operator!=(const IteratorBase& other) inline bool operator!=(const IteratorBase &other)
{ {
return p != other.p; return p != other.p;
} }
inline bool operator==(const IteratorBase& other) inline bool operator==(const IteratorBase &other)
{ {
return p == other.p; return p == other.p;
} }
inline int operator-(const IteratorBase& other) inline int operator-(const IteratorBase &other)
{ {
return p - other.p; return (int)(p - other.p);
} }
IteratorBase& operator++() { IteratorBase &operator++()
{
p++; p++;
return *this; return *this;
} }
IteratorBase& operator--() { IteratorBase &operator--()
{
p--; p--;
return *this; return *this;
} }
IteratorBase operator++(int) { IteratorBase operator++(int)
{
IteratorBase tmp(*this); IteratorBase tmp(*this);
++*this; ++*this;
return tmp; return tmp;
} }
IteratorBase operator--(int) { IteratorBase operator--(int)
{
IteratorBase tmp(*this); IteratorBase tmp(*this);
--*this; --*this;
return tmp; return tmp;
} }
private: private:
X* p; X *p;
}; };
typedef IteratorBase<T> Iterator; typedef IteratorBase<T> Iterator;
typedef IteratorBase<const T> ConstIterator; typedef IteratorBase<const T> ConstIterator;
bool operator==(const Array& other) bool operator==(const Array &other)
{ {
return _data == other._data; return _data == other._data;
} }
bool operator!=(const Array& other) bool operator!=(const Array &other)
{ {
return !(*this == other); return !(*this == other);
} }
Iterator find(const T& item) Iterator find(const T &item)
{ {
for (int i = 0; i < arraySize; ++i) for (uint32 i = 0; i < arraySize; ++i)
{ {
if (_data[i] == item) if (_data[i] == item)
{ {
@@ -191,23 +194,33 @@ namespace Seele
{ {
return beginIt; return beginIt;
} }
Iterator begin() const
{
return beginIt;
}
Iterator end() Iterator end()
{ {
return endIt; return endIt;
} }
Iterator end() const
{
return endIt;
}
T& add(const T& item) T &add(const T &item = T())
{ {
if (arraySize == allocated) if (arraySize == allocated)
{ {
uint32 newSize = arraySize + 1; uint32 newSize = arraySize + 1;
allocated = calculateGrowth(newSize); allocated = calculateGrowth(newSize);
void* tempArray = malloc(sizeof(T) * allocated); T *tempArray = new T[allocated];
assert(tempArray != nullptr); assert(tempArray != nullptr);
std::memset(tempArray, 0, sizeof(T) * allocated); for (uint32 i = 0; i < arraySize; ++i)
std::memcpy(tempArray, _data, arraySize * sizeof(T)); {
delete _data; tempArray[i] = _data[i];
_data = (T*)tempArray; }
delete[] _data;
_data = tempArray;
} }
_data[arraySize++] = item; _data[arraySize++] = item;
refreshIterators(); refreshIterators();
@@ -231,6 +244,8 @@ namespace Seele
} }
void clear() void clear()
{ {
delete[] _data;
_data = nullptr;
arraySize = 0; arraySize = 0;
allocated = 0; allocated = 0;
refreshIterators(); refreshIterators();
@@ -243,7 +258,7 @@ namespace Seele
} }
else else
{ {
T* newData = (T*)malloc(newSize * sizeof(T)); T *newData = new T[newSize];
assert(newData != nullptr); assert(newData != nullptr);
allocated = newSize; allocated = newSize;
std::memcpy(newData, _data, sizeof(T) * arraySize); std::memcpy(newData, _data, sizeof(T) * arraySize);
@@ -261,11 +276,11 @@ namespace Seele
{ {
return allocated; return allocated;
} }
inline T* data() const inline T *data() const
{ {
return _data; return _data;
} }
T& back() const T &back() const
{ {
return _data[arraySize - 1]; return _data[arraySize - 1];
} }
@@ -273,23 +288,47 @@ namespace Seele
{ {
arraySize--; arraySize--;
} }
T& operator[](int index) const T &operator[](uint32 index)
{ {
assert(index >= 0 && index < arraySize); assert(index < arraySize);
return _data[index]; return _data[index];
} }
private: inline T &operator[](size_t index)
{
return this->operator[]((uint32)index);
}
inline T &operator[](int32 index)
{
return this->operator[]((uint32)index);
}
const T &operator[](uint32 index) const
{
assert(index < arraySize);
return _data[index];
}
inline const T &operator[](size_t index) const
{
return this->operator[]((uint32)index);
}
inline const T &operator[](int32 index) const
{
return this->operator[]((uint32)index);
}
private:
uint32 calculateGrowth(uint32 newSize) const uint32 calculateGrowth(uint32 newSize) const
{ {
const uint32 oldCapacity = capacity(); const uint32 oldCapacity = capacity();
if (oldCapacity > UINT32_MAX - oldCapacity / 2) { if (oldCapacity > UINT32_MAX - oldCapacity / 2)
{
return newSize; // geometric growth would overflow return newSize; // geometric growth would overflow
} }
const uint32 geometric = oldCapacity + oldCapacity / 2; const uint32 geometric = oldCapacity + oldCapacity / 2;
if (geometric < newSize) { if (geometric < newSize)
{
return newSize; // geometric growth would be insufficient return newSize; // geometric growth would be insufficient
} }
@@ -304,13 +343,13 @@ namespace Seele
uint32 allocated; uint32 allocated;
Iterator beginIt; Iterator beginIt;
Iterator endIt; Iterator endIt;
T* _data; T *_data;
}; };
template<typename T, uint32 N> template <typename T, uint32 N>
struct StaticArray struct StaticArray
{ {
public: public:
StaticArray() StaticArray()
{ {
beginIt = Iterator(_data); beginIt = Iterator(_data);
@@ -326,37 +365,41 @@ namespace Seele
endIt = Iterator(_data + N); endIt = Iterator(_data + N);
} }
~StaticArray() ~StaticArray()
{} {
}
inline uint32 size() const inline uint32 size() const
{ {
return N; return N;
} }
inline T* data() const inline T *data() const
{ {
return _data; return _data;
} }
T& operator[](int index) T &operator[](int index)
{ {
assert(index >= 0 && index < N); assert(index >= 0 && index < N);
return _data[index]; return _data[index];
} }
template<typename X> template <typename X>
class IteratorBase { class IteratorBase
{
public: public:
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
typedef X value_type; typedef X value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef X& reference; typedef X &reference;
typedef X* pointer; typedef X *pointer;
IteratorBase(X* x = nullptr) IteratorBase(X *x = nullptr)
: p(x) : p(x)
{} {
IteratorBase(const IteratorBase& i) }
IteratorBase(const IteratorBase &i)
: p(i.p) : p(i.p)
{} {
}
reference operator*() const reference operator*() const
{ {
return *p; return *p;
@@ -365,32 +408,35 @@ namespace Seele
{ {
return p; return p;
} }
inline bool operator!=(const IteratorBase& other) inline bool operator!=(const IteratorBase &other)
{ {
return p != other.p; return p != other.p;
} }
inline bool operator==(const IteratorBase& other) inline bool operator==(const IteratorBase &other)
{ {
return p == other.p; return p == other.p;
} }
IteratorBase& operator++() { IteratorBase &operator++()
{
p++; p++;
return *this; return *this;
} }
IteratorBase operator++(int) { IteratorBase operator++(int)
{
IteratorBase tmp(*this); IteratorBase tmp(*this);
++*this; ++*this;
return tmp; return tmp;
} }
private: private:
X* p; X *p;
}; };
typedef IteratorBase<T> Iterator; typedef IteratorBase<T> Iterator;
typedef IteratorBase<const T> ConstIterator; typedef IteratorBase<const T> ConstIterator;
private: private:
T _data[N]; T _data[N];
Iterator beginIt; Iterator beginIt;
Iterator endIt; Iterator endIt;
}; };
} } // namespace Seele
+50 -41
View File
@@ -2,17 +2,18 @@
#include "MinimalEngine.h" #include "MinimalEngine.h"
namespace Seele namespace Seele
{ {
template<typename T> template <typename T>
class List class List
{ {
private: private:
struct Node struct Node
{ {
Node* prev; Node *prev;
Node* next; Node *next;
T data; T data;
}; };
public:
public:
List() List()
{ {
root = nullptr; root = nullptr;
@@ -25,21 +26,24 @@ namespace Seele
{ {
clear(); clear();
} }
template<typename X> template <typename X>
class IteratorBase { class IteratorBase
{
public: public:
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
typedef X value_type; typedef X value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef X& reference; typedef X &reference;
typedef X* pointer; typedef X *pointer;
IteratorBase(Node* x = nullptr) IteratorBase(Node *x = nullptr)
: node(x) : node(x)
{} {
IteratorBase(const IteratorBase& i) }
IteratorBase(const IteratorBase &i)
: node(i.node) : node(i.node)
{} {
}
reference operator*() const reference operator*() const
{ {
return node->data; return node->data;
@@ -48,44 +52,49 @@ namespace Seele
{ {
return &node->data; return &node->data;
} }
inline bool operator!=(const IteratorBase& other) inline bool operator!=(const IteratorBase &other)
{ {
return node != other.node; return node != other.node;
} }
inline bool operator==(const IteratorBase& other) inline bool operator==(const IteratorBase &other)
{ {
return node == other.node; return node == other.node;
} }
IteratorBase& operator--() { IteratorBase &operator--()
{
node = node->prev; node = node->prev;
return *this; return *this;
} }
IteratorBase operator--(int) { IteratorBase operator--(int)
{
IteratorBase tmp(*this); IteratorBase tmp(*this);
--* this; --*this;
return tmp; return tmp;
} }
IteratorBase& operator++() { IteratorBase &operator++()
{
node = node->next; node = node->next;
return *this; return *this;
} }
IteratorBase operator++(int) { IteratorBase operator++(int)
{
IteratorBase tmp(*this); IteratorBase tmp(*this);
++* this; ++*this;
return tmp; return tmp;
} }
private: private:
Node* node; Node *node;
friend class List<T>; friend class List<T>;
}; };
typedef IteratorBase<T> Iterator; typedef IteratorBase<T> Iterator;
typedef IteratorBase<const T> ConstIterator; typedef IteratorBase<const T> ConstIterator;
T& front() T &front()
{ {
return root->data; return root->data;
} }
T& back() T &back()
{ {
return tail->prev->data; return tail->prev->data;
} }
@@ -95,7 +104,7 @@ namespace Seele
{ {
return; return;
} }
for (Node* tmp = root; tmp != tail;) for (Node *tmp = root; tmp != tail;)
{ {
tmp = tmp->next; tmp = tmp->next;
delete tmp->prev; delete tmp->prev;
@@ -105,7 +114,7 @@ namespace Seele
root = nullptr; root = nullptr;
} }
//Insert at the end //Insert at the end
Iterator add(const T& value) Iterator add(const T &value)
{ {
if (root == nullptr) if (root == nullptr)
{ {
@@ -113,7 +122,7 @@ namespace Seele
tail = root; tail = root;
} }
tail->data = value; tail->data = value;
Node* newTail = new Node(); Node *newTail = new Node();
newTail->prev = tail; newTail->prev = tail;
newTail->next = nullptr; newTail->next = nullptr;
tail->next = newTail; tail->next = newTail;
@@ -126,8 +135,8 @@ namespace Seele
Iterator remove(Iterator pos) Iterator remove(Iterator pos)
{ {
size--; size--;
Node* prev = pos.node->prev; Node *prev = pos.node->prev;
Node* next = pos.node->next; Node *next = pos.node->next;
if (prev == nullptr) if (prev == nullptr)
{ {
root = next; root = next;
@@ -141,7 +150,7 @@ namespace Seele
refreshIterators(); refreshIterators();
return Iterator(next); return Iterator(next);
} }
Iterator insert(Iterator pos, const T& value) Iterator insert(Iterator pos, const T &value)
{ {
size++; size++;
if (root == nullptr) if (root == nullptr)
@@ -156,8 +165,8 @@ namespace Seele
refreshIterators(); refreshIterators();
return beginIt; return beginIt;
} }
Node* tmp = pos.node->prev; Node *tmp = pos.node->prev;
Node* newNode = new Node(); Node *newNode = new Node();
newNode->data = value; newNode->data = value;
tmp->next = newNode; tmp->next = newNode;
newNode->prev = tmp; newNode->prev = tmp;
@@ -165,9 +174,9 @@ namespace Seele
pos.node->prev = newNode; pos.node->prev = newNode;
return Iterator(newNode); return Iterator(newNode);
} }
Iterator find(const T& value) Iterator find(const T &value)
{ {
for (Node* i = root; i != tail; i = i->next) for (Node *i = root; i != tail; i = i->next)
{ {
if (!(i->data < value) && !(value < i->data)) if (!(i->data < value) && !(value < i->data))
{ {
@@ -193,16 +202,16 @@ namespace Seele
return endIt; return endIt;
} }
private: private:
void refreshIterators() void refreshIterators()
{ {
beginIt = Iterator(root); beginIt = Iterator(root);
endIt = Iterator(tail); endIt = Iterator(tail);
} }
Node* root; Node *root;
Node* tail; Node *tail;
Iterator beginIt; Iterator beginIt;
Iterator endIt; Iterator endIt;
uint32 size; uint32 size;
}; };
} } // namespace Seele
+155 -128
View File
@@ -3,80 +3,81 @@
namespace Seele namespace Seele
{ {
template<typename K, typename V> template <typename K, typename V>
struct Pair struct Pair
{ {
public: public:
Pair() Pair()
: key(K()) : key(K()), value(V())
, value(V()) {
{} }
Pair(K key, V value) Pair(K key, V value)
: key(key) : key(key), value(value)
, value(value) {
{} }
K key; K key;
V value; V value;
}; };
template<typename K, typename V> template <typename K, typename V>
struct Map struct Map
{ {
private: private:
struct Node struct Node
{ {
Pair<K, V> pair; Pair<K, V> pair;
Node* leftChild; Node *leftChild;
Node* rightChild; Node *rightChild;
Node(const K& key) Node(const K &key)
: leftChild(nullptr) : leftChild(nullptr), rightChild(nullptr), pair(key, V())
, rightChild(nullptr) {
, pair(key, V()) }
{}
Node() Node()
: leftChild(nullptr) : leftChild(nullptr), rightChild(nullptr), pair(K(), V())
, rightChild(nullptr) {
, pair(K(), V()) }
{}
~Node() ~Node()
{ {
if(leftChild != nullptr) if (leftChild != nullptr)
{ {
delete leftChild; delete leftChild;
} }
if(rightChild != nullptr) if (rightChild != nullptr)
{ {
delete rightChild; delete rightChild;
} }
} }
}; };
public: public:
Map() Map()
: root(nullptr) : root(nullptr), _size(0)
{} {
}
~Map() ~Map()
{ {
delete root; delete root;
} }
class Iterator { class Iterator
{
public: public:
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
typedef Pair<K, V> value_type; typedef Pair<K, V> value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef Pair<K, V>& reference; typedef Pair<K, V> &reference;
typedef Pair<K, V>* pointer; typedef Pair<K, V> *pointer;
Iterator(Node* x = nullptr) Iterator(Node *x = nullptr)
: node(x) : node(x)
{} {
Iterator(Node* x, Array<Node*>&& beginIt) }
: node(x) Iterator(Node *x, Array<Node *> &&beginIt)
, traversal(std::move(beginIt)) : node(x), traversal(std::move(beginIt))
{} {
Iterator(const Iterator& i) }
: node(i.node) Iterator(const Iterator &i)
, traversal(i.traversal) : node(i.node), traversal(i.traversal)
{} {
}
reference operator*() const reference operator*() const
{ {
return node->pair; return node->pair;
@@ -85,67 +86,73 @@ namespace Seele
{ {
return &node->pair; return &node->pair;
} }
inline bool operator!=(const Iterator& other) inline bool operator!=(const Iterator &other)
{ {
return node != other.node; return node != other.node;
} }
inline bool operator==(const Iterator& other) inline bool operator==(const Iterator &other)
{ {
return node == other.node; return node == other.node;
} }
Iterator& operator++() { Iterator &operator++()
{
node = node->rightChild; node = node->rightChild;
while(node != nullptr && node->leftChild != nullptr) while (node != nullptr && node->leftChild != nullptr)
{ {
traversal.add(node); traversal.add(node);
node = node->leftChild; node = node->leftChild;
} }
if(node == nullptr && traversal.size() > 0) if (node == nullptr && traversal.size() > 0)
{ {
node = traversal.back(); node = traversal.back();
traversal.pop(); traversal.pop();
} }
return *this; return *this;
} }
Iterator& operator--() { Iterator &operator--()
{
node = node->leftChild; node = node->leftChild;
while(node != nullptr && node->rightchild != nullptr) while (node != nullptr && node->rightchild != nullptr)
{ {
traversal.add(node); traversal.add(node);
node = node->rightChild; node = node->rightChild;
} }
if(node == nullptr && traversal.size() > 0) if (node == nullptr && traversal.size() > 0)
{ {
node = traversal.back(); node = traversal.back();
traversal.pop(); traversal.pop();
} }
return *this; return *this;
} }
Iterator operator--(int) { Iterator operator--(int)
{
Iterator tmp(*this); Iterator tmp(*this);
++* this; ++*this;
return tmp; return tmp;
} }
Iterator operator++(int) { Iterator operator++(int)
{
Iterator tmp(*this); Iterator tmp(*this);
++* this; ++*this;
return tmp; return tmp;
} }
private: private:
Node* node; Node *node;
Array<Node*> traversal; Array<Node *> traversal;
}; };
V& operator[](const K& key) V &operator[](const K &key)
{ {
root = splay(root, key); root = splay(root, key);
if (root == nullptr || root->pair.key < key || key < root->pair.key) if (root == nullptr || root->pair.key < key || key < root->pair.key)
{ {
root = insert(root, key); root = insert(root, key);
_size++;
} }
refreshIterators(); refreshIterators();
return root->pair.value; return root->pair.value;
} }
Iterator find(const K& key) Iterator find(const K &key)
{ {
root = splay(root, key); root = splay(root, key);
if (root == nullptr || root->pair.key != key) if (root == nullptr || root->pair.key != key)
@@ -154,13 +161,20 @@ namespace Seele
} }
return Iterator(root); return Iterator(root);
} }
Iterator erase(const K& key) Iterator erase(const K &key)
{ {
root = remove(root, key); root = remove(root, key);
refreshIterators(); refreshIterators();
return Iterator(root); return Iterator(root);
} }
bool exists(const K& key) void clear()
{
delete root;
root = nullptr;
_size = 0;
refreshIterators();
}
bool exists(const K &key)
{ {
return find(key) != endIt; return find(key) != endIt;
} }
@@ -172,18 +186,27 @@ namespace Seele
{ {
return endIt; return endIt;
} }
private: bool empty() const
{
return root == nullptr;
}
uint32 size() const
{
return _size;
}
private:
void refreshIterators() void refreshIterators()
{ {
Node* beginNode = root; Node *beginNode = root;
if(root == nullptr) if (root == nullptr)
{ {
beginIt = Iterator(nullptr); beginIt = Iterator(nullptr);
} }
else else
{ {
Array<Node*> beginTraversal; Array<Node *> beginTraversal;
while(beginNode != nullptr) while (beginNode != nullptr)
{ {
beginTraversal.add(beginNode); beginTraversal.add(beginNode);
beginNode = beginNode->leftChild; beginNode = beginNode->leftChild;
@@ -192,15 +215,15 @@ namespace Seele
beginTraversal.pop(); beginTraversal.pop();
beginIt = Iterator(beginNode, std::move(beginTraversal)); beginIt = Iterator(beginNode, std::move(beginTraversal));
} }
Node* endNode = root; Node *endNode = root;
if(root == nullptr) if (root == nullptr)
{ {
endIt = Iterator(nullptr); endIt = Iterator(nullptr);
} }
else else
{ {
Array<Node*> endTraversal; Array<Node *> endTraversal;
while(endNode != nullptr) while (endNode != nullptr)
{ {
endTraversal.add(endNode); endTraversal.add(endNode);
endNode = endNode->rightChild; endNode = endNode->rightChild;
@@ -208,129 +231,133 @@ namespace Seele
endIt = Iterator(endNode, std::move(endTraversal)); endIt = Iterator(endNode, std::move(endTraversal));
} }
} }
Node* root; Node *root;
Iterator beginIt; Iterator beginIt;
Iterator endIt; Iterator endIt;
Node* rotateRight(Node* node) uint32 _size;
Node *rotateRight(Node *node)
{ {
Node* y = node->leftChild; Node *y = node->leftChild;
node->leftChild = y->rightChild; node->leftChild = y->rightChild;
y->rightChild = node; y->rightChild = node;
return y; return y;
} }
Node* rotateLeft(Node* node) Node *rotateLeft(Node *node)
{ {
Node* y = node->rightChild; Node *y = node->rightChild;
node->rightChild = y->leftChild; node->rightChild = y->leftChild;
y->leftChild = node; y->leftChild = node;
return y; return y;
} }
Node* makeNode(const K& key) Node *makeNode(const K &key)
{ {
return new Node(key); return new Node(key);
} }
Node* insert(Node* root, const K& key) Node *insert(Node *r, const K &key)
{ {
if (root == nullptr) return makeNode(key); if (r == nullptr)
return makeNode(key);
root = splay(root, key); r = splay(r, key);
if (!(root->pair.key < key || key < root->pair.key)) return root; if (!(r->pair.key < key || key < r->pair.key))
return r;
Node* newNode = makeNode(key); Node *newNode = makeNode(key);
if (key < root->pair.key) if (key < r->pair.key)
{ {
newNode->rightChild = root; newNode->rightChild = r;
newNode->leftChild = root->leftChild; newNode->leftChild = r->leftChild;
root->leftChild = nullptr; r->leftChild = nullptr;
} }
else else
{ {
newNode->leftChild = root; newNode->leftChild = r;
newNode->rightChild = root->rightChild; newNode->rightChild = r->rightChild;
root->rightChild = nullptr; r->rightChild = nullptr;
} }
return newNode; return newNode;
} }
Node* remove(Node* root, const K& key) Node *remove(Node *r, const K &key)
{ {
Node* temp; Node *temp;
if (!root) if (!r)
return nullptr; return nullptr;
root = splay(root, key); r = splay(r, key);
if (root->pair.key < key || key < root->pair.key) if (r->pair.key < key || key < r->pair.key)
return root; return r;
if (!root->leftChild) if (!r->leftChild)
{ {
temp = root; temp = r;
root = root->rightChild; r = r->rightChild;
} }
else else
{ {
temp = root; temp = r;
root = splay(root->leftChild, key); r = splay(r->leftChild, key);
root->rightChild = temp->rightChild; r->rightChild = temp->rightChild;
} }
temp->leftChild = nullptr; temp->leftChild = nullptr;
temp->rightChild = nullptr; temp->rightChild = nullptr;
_size--;
delete temp; delete temp;
return root; return r;
} }
Node* splay(Node* root, const K& key) Node *splay(Node *r, const K &key)
{ {
if (root == nullptr || !(root->pair.key < key || key < root->pair.key)) if (r == nullptr || !(r->pair.key < key || key < r->pair.key))
{ {
return root; return r;
} }
if (key < root->pair.key) if (key < r->pair.key)
{ {
if (root->leftChild == nullptr) if (r->leftChild == nullptr)
return root; return r;
if (key < root->leftChild->pair.key) if (key < r->leftChild->pair.key)
{ {
root->leftChild->leftChild = splay(root->leftChild->leftChild, key); r->leftChild->leftChild = splay(r->leftChild->leftChild, key);
root = rotateRight(root); r = rotateRight(r);
} }
else if (root->leftChild->pair.key < key) else if (r->leftChild->pair.key < key)
{ {
root->leftChild->rightChild = splay(root->leftChild->rightChild, key); r->leftChild->rightChild = splay(r->leftChild->rightChild, key);
if (root->leftChild->rightChild != nullptr) if (r->leftChild->rightChild != nullptr)
{ {
root->leftChild = rotateLeft(root->leftChild); r->leftChild = rotateLeft(r->leftChild);
} }
} }
return (root->leftChild == nullptr) ? root : rotateRight(root); return (r->leftChild == nullptr) ? r : rotateRight(r);
} }
else else
{ {
if (root->rightChild == nullptr) if (r->rightChild == nullptr)
return root; return r;
if (key < root->rightChild->pair.key) if (key < r->rightChild->pair.key)
{ {
root->rightChild->leftChild = splay(root->rightChild->leftChild, key); r->rightChild->leftChild = splay(r->rightChild->leftChild, key);
if (root->rightChild->leftChild != nullptr) if (r->rightChild->leftChild != nullptr)
{ {
root->rightChild = rotateRight(root->rightChild); r->rightChild = rotateRight(r->rightChild);
} }
} }
else if (root->rightChild->pair.key < key) else if (r->rightChild->pair.key < key)
{ {
root->rightChild->rightChild = splay(root->rightChild->rightChild, key); r->rightChild->rightChild = splay(r->rightChild->rightChild, key);
root = rotateLeft(root); r = rotateLeft(r);
} }
return (root->rightChild == nullptr) ? root : rotateLeft(root); return (r->rightChild == nullptr) ? r : rotateLeft(r);
} }
} }
}; };
} } // namespace Seele
-2
View File
@@ -14,8 +14,6 @@ target_sources(SeeleEngine
SceneView.cpp SceneView.cpp
WindowManager.h WindowManager.h
WindowManager.cpp WindowManager.cpp
Window.h
Window.cpp
GraphicsResources.h GraphicsResources.h
GraphicsResources.cpp GraphicsResources.cpp
GraphicsEnums.h) GraphicsEnums.h)
-1
View File
@@ -9,5 +9,4 @@ Graphics::Graphics()
Graphics::~Graphics() Graphics::~Graphics()
{ {
} }
+26 -16
View File
@@ -3,22 +3,32 @@
#include "GraphicsResources.h" #include "GraphicsResources.h"
#include "Containers/Array.h" #include "Containers/Array.h"
namespace Seele { namespace Seele
namespace Gfx {
{ namespace Gfx
class Window; {
class Graphics class Graphics
{ {
public: public:
Graphics(); Graphics();
~Graphics(); virtual ~Graphics();
virtual void init(GraphicsInitializer initializer) = 0; virtual void init(GraphicsInitializer initializer) = 0;
virtual void beginFrame(void* windowHandle) = 0; virtual PWindow createWindow(const WindowCreateInfo &createInfo) = 0;
virtual void endFrame(void* windowHandle) = 0; virtual PViewport createViewport(PWindow owner, const ViewportCreateInfo &createInfo) = 0;
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
protected: virtual PRenderPass createRenderPass(PRenderTargetLayout layout) = 0;
virtual void beginRenderPass(PRenderPass renderPass) = 0;
virtual void endRenderPass() = 0;
virtual PTexture2D createTexture2D(const TextureCreateInfo &createInfo) = 0;
virtual PUniformBuffer createUniformBuffer(const BulkResourceData &bulkData) = 0;
virtual PStructuredBuffer createStructuredBuffer(const BulkResourceData &bulkData) = 0;
virtual PVertexBuffer createVertexBuffer(const BulkResourceData &bulkData) = 0;
virtual PIndexBuffer createIndexBuffer(const BulkResourceData &bulkData) = 0;
protected:
friend class Window; friend class Window;
}; };
DEFINE_REF(Graphics); DEFINE_REF(Graphics);
} } // namespace Gfx
} } // namespace Seele
+294 -217
View File
@@ -2,15 +2,18 @@
#include "MinimalEngine.h" #include "MinimalEngine.h"
namespace Seele namespace Seele
{ {
namespace Gfx namespace Gfx
{ {
static bool useAsyncCompute = true; static constexpr bool useAsyncCompute = true;
static constexpr bool waitIdleOnSubmit = false;
static constexpr uint32 numFramesBuffered = 3;
typedef uint32_t SeFlags; typedef uint32_t SeFlags;
typedef uint32_t SeBool32; typedef uint32_t SeBool32;
typedef uint64_t SeDeviceSize; typedef uint64_t SeDeviceSize;
typedef uint32_t SeSampleMask; typedef uint32_t SeSampleMask;
typedef enum SeResult { typedef enum SeResult
{
SE_SUCCESS = 0, SE_SUCCESS = 0,
SE_NOT_READY = 1, SE_NOT_READY = 1,
SE_TIMEOUT = 2, SE_TIMEOUT = 2,
@@ -49,9 +52,10 @@ namespace Seele
SE_RESULT_END_RANGE = SE_INCOMPLETE, SE_RESULT_END_RANGE = SE_INCOMPLETE,
SE_RESULT_RANGE_SIZE = (SE_INCOMPLETE - SE_ERROR_FRAGMENTED_POOL + 1), SE_RESULT_RANGE_SIZE = (SE_INCOMPLETE - SE_ERROR_FRAGMENTED_POOL + 1),
SE_RESULT_MAX_ENUM = 0x7FFFFFFF SE_RESULT_MAX_ENUM = 0x7FFFFFFF
} SeResult; } SeResult;
typedef enum SeStructureType { typedef enum SeStructureType
{
SE_STRUCTURE_TYPE_APPLICATION_INFO = 0, SE_STRUCTURE_TYPE_APPLICATION_INFO = 0,
SE_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1, SE_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
SE_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2, SE_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2,
@@ -495,9 +499,10 @@ namespace Seele
SE_STRUCTURE_TYPE_END_RANGE = SE_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO, SE_STRUCTURE_TYPE_END_RANGE = SE_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO,
SE_STRUCTURE_TYPE_RANGE_SIZE = (SE_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - SE_STRUCTURE_TYPE_APPLICATION_INFO + 1), SE_STRUCTURE_TYPE_RANGE_SIZE = (SE_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - SE_STRUCTURE_TYPE_APPLICATION_INFO + 1),
SE_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF SE_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeStructureType; } SeStructureType;
typedef enum SeSystemAllocationScope { typedef enum SeSystemAllocationScope
{
SE_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0, SE_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
SE_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1, SE_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
SE_SYSTEM_ALLOCATION_SCOPE_CACHE = 2, SE_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
@@ -507,17 +512,19 @@ namespace Seele
SE_SYSTEM_ALLOCATION_SCOPE_END_RANGE = SE_SYSTEM_ALLOCATION_SCOPE_INSTANCE, SE_SYSTEM_ALLOCATION_SCOPE_END_RANGE = SE_SYSTEM_ALLOCATION_SCOPE_INSTANCE,
SE_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (SE_SYSTEM_ALLOCATION_SCOPE_INSTANCE - SE_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1), SE_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (SE_SYSTEM_ALLOCATION_SCOPE_INSTANCE - SE_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1),
SE_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF SE_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF
} SeSystemAllocationScope; } SeSystemAllocationScope;
typedef enum SeInternalAllocationType { typedef enum SeInternalAllocationType
{
SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0, SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0,
SE_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, SE_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
SE_INTERNAL_ALLOCATION_TYPE_END_RANGE = SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, SE_INTERNAL_ALLOCATION_TYPE_END_RANGE = SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
SE_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1), SE_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - SE_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1),
SE_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF SE_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeInternalAllocationType; } SeInternalAllocationType;
typedef enum SeFormat { typedef enum SeFormat
{
SE_FORMAT_UNDEFINED = 0, SE_FORMAT_UNDEFINED = 0,
SE_FORMAT_R4G4_UNORM_PACK8 = 1, SE_FORMAT_R4G4_UNORM_PACK8 = 1,
SE_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, SE_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
@@ -797,9 +804,10 @@ namespace Seele
SE_FORMAT_END_RANGE = SE_FORMAT_ASTC_12x12_SRGB_BLOCK, SE_FORMAT_END_RANGE = SE_FORMAT_ASTC_12x12_SRGB_BLOCK,
SE_FORMAT_RANGE_SIZE = (SE_FORMAT_ASTC_12x12_SRGB_BLOCK - SE_FORMAT_UNDEFINED + 1), SE_FORMAT_RANGE_SIZE = (SE_FORMAT_ASTC_12x12_SRGB_BLOCK - SE_FORMAT_UNDEFINED + 1),
SE_FORMAT_MAX_ENUM = 0x7FFFFFFF SE_FORMAT_MAX_ENUM = 0x7FFFFFFF
} SeFormat; } SeFormat;
typedef enum SeImageType { typedef enum SeImageType
{
SE_IMAGE_TYPE_1D = 0, SE_IMAGE_TYPE_1D = 0,
SE_IMAGE_TYPE_2D = 1, SE_IMAGE_TYPE_2D = 1,
SE_IMAGE_TYPE_3D = 2, SE_IMAGE_TYPE_3D = 2,
@@ -807,9 +815,10 @@ namespace Seele
SE_IMAGE_TYPE_END_RANGE = SE_IMAGE_TYPE_3D, SE_IMAGE_TYPE_END_RANGE = SE_IMAGE_TYPE_3D,
SE_IMAGE_TYPE_RANGE_SIZE = (SE_IMAGE_TYPE_3D - SE_IMAGE_TYPE_1D + 1), SE_IMAGE_TYPE_RANGE_SIZE = (SE_IMAGE_TYPE_3D - SE_IMAGE_TYPE_1D + 1),
SE_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeImageType; } SeImageType;
typedef enum SeImageTiling { typedef enum SeImageTiling
{
SE_IMAGE_TILING_OPTIMAL = 0, SE_IMAGE_TILING_OPTIMAL = 0,
SE_IMAGE_TILING_LINEAR = 1, SE_IMAGE_TILING_LINEAR = 1,
SE_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT = 1000158000, SE_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT = 1000158000,
@@ -817,9 +826,10 @@ namespace Seele
SE_IMAGE_TILING_END_RANGE = SE_IMAGE_TILING_LINEAR, SE_IMAGE_TILING_END_RANGE = SE_IMAGE_TILING_LINEAR,
SE_IMAGE_TILING_RANGE_SIZE = (SE_IMAGE_TILING_LINEAR - SE_IMAGE_TILING_OPTIMAL + 1), SE_IMAGE_TILING_RANGE_SIZE = (SE_IMAGE_TILING_LINEAR - SE_IMAGE_TILING_OPTIMAL + 1),
SE_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF
} SeImageTiling; } SeImageTiling;
typedef enum SePhysicalDeviceType { typedef enum SePhysicalDeviceType
{
SE_PHYSICAL_DEVICE_TYPE_OTHER = 0, SE_PHYSICAL_DEVICE_TYPE_OTHER = 0,
SE_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1, SE_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
SE_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2, SE_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2,
@@ -829,9 +839,10 @@ namespace Seele
SE_PHYSICAL_DEVICE_TYPE_END_RANGE = SE_PHYSICAL_DEVICE_TYPE_CPU, SE_PHYSICAL_DEVICE_TYPE_END_RANGE = SE_PHYSICAL_DEVICE_TYPE_CPU,
SE_PHYSICAL_DEVICE_TYPE_RANGE_SIZE = (SE_PHYSICAL_DEVICE_TYPE_CPU - SE_PHYSICAL_DEVICE_TYPE_OTHER + 1), SE_PHYSICAL_DEVICE_TYPE_RANGE_SIZE = (SE_PHYSICAL_DEVICE_TYPE_CPU - SE_PHYSICAL_DEVICE_TYPE_OTHER + 1),
SE_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF SE_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF
} SePhysicalDeviceType; } SePhysicalDeviceType;
typedef enum SeQueryType { typedef enum SeQueryType
{
SE_QUERY_TYPE_OCCLUSION = 0, SE_QUERY_TYPE_OCCLUSION = 0,
SE_QUERY_TYPE_PIPELINE_STATISTICS = 1, SE_QUERY_TYPE_PIPELINE_STATISTICS = 1,
SE_QUERY_TYPE_TIMESTAMP = 2, SE_QUERY_TYPE_TIMESTAMP = 2,
@@ -842,18 +853,20 @@ namespace Seele
SE_QUERY_TYPE_END_RANGE = SE_QUERY_TYPE_TIMESTAMP, SE_QUERY_TYPE_END_RANGE = SE_QUERY_TYPE_TIMESTAMP,
SE_QUERY_TYPE_RANGE_SIZE = (SE_QUERY_TYPE_TIMESTAMP - SE_QUERY_TYPE_OCCLUSION + 1), SE_QUERY_TYPE_RANGE_SIZE = (SE_QUERY_TYPE_TIMESTAMP - SE_QUERY_TYPE_OCCLUSION + 1),
SE_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF SE_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeQueryType; } SeQueryType;
typedef enum SeSharingMode { typedef enum SeSharingMode
{
SE_SHARING_MODE_EXCLUSIVE = 0, SE_SHARING_MODE_EXCLUSIVE = 0,
SE_SHARING_MODE_CONCURRENT = 1, SE_SHARING_MODE_CONCURRENT = 1,
SE_SHARING_MODE_BEGIN_RANGE = SE_SHARING_MODE_EXCLUSIVE, SE_SHARING_MODE_BEGIN_RANGE = SE_SHARING_MODE_EXCLUSIVE,
SE_SHARING_MODE_END_RANGE = SE_SHARING_MODE_CONCURRENT, SE_SHARING_MODE_END_RANGE = SE_SHARING_MODE_CONCURRENT,
SE_SHARING_MODE_RANGE_SIZE = (SE_SHARING_MODE_CONCURRENT - SE_SHARING_MODE_EXCLUSIVE + 1), SE_SHARING_MODE_RANGE_SIZE = (SE_SHARING_MODE_CONCURRENT - SE_SHARING_MODE_EXCLUSIVE + 1),
SE_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF SE_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF
} SeSharingMode; } SeSharingMode;
typedef enum SeImageLayout { typedef enum SeImageLayout
{
SE_IMAGE_LAYOUT_UNDEFINED = 0, SE_IMAGE_LAYOUT_UNDEFINED = 0,
SE_IMAGE_LAYOUT_GENERAL = 1, SE_IMAGE_LAYOUT_GENERAL = 1,
SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2,
@@ -875,9 +888,10 @@ namespace Seele
SE_IMAGE_LAYOUT_END_RANGE = SE_IMAGE_LAYOUT_PREINITIALIZED, SE_IMAGE_LAYOUT_END_RANGE = SE_IMAGE_LAYOUT_PREINITIALIZED,
SE_IMAGE_LAYOUT_RANGE_SIZE = (SE_IMAGE_LAYOUT_PREINITIALIZED - SE_IMAGE_LAYOUT_UNDEFINED + 1), SE_IMAGE_LAYOUT_RANGE_SIZE = (SE_IMAGE_LAYOUT_PREINITIALIZED - SE_IMAGE_LAYOUT_UNDEFINED + 1),
SE_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF
} SeImageLayout; } SeImageLayout;
typedef enum SeImageViewType { typedef enum SeImageViewType
{
SE_IMAGE_VIEW_TYPE_1D = 0, SE_IMAGE_VIEW_TYPE_1D = 0,
SE_IMAGE_VIEW_TYPE_2D = 1, SE_IMAGE_VIEW_TYPE_2D = 1,
SE_IMAGE_VIEW_TYPE_3D = 2, SE_IMAGE_VIEW_TYPE_3D = 2,
@@ -889,9 +903,10 @@ namespace Seele
SE_IMAGE_VIEW_TYPE_END_RANGE = SE_IMAGE_VIEW_TYPE_CUBE_ARRAY, SE_IMAGE_VIEW_TYPE_END_RANGE = SE_IMAGE_VIEW_TYPE_CUBE_ARRAY,
SE_IMAGE_VIEW_TYPE_RANGE_SIZE = (SE_IMAGE_VIEW_TYPE_CUBE_ARRAY - SE_IMAGE_VIEW_TYPE_1D + 1), SE_IMAGE_VIEW_TYPE_RANGE_SIZE = (SE_IMAGE_VIEW_TYPE_CUBE_ARRAY - SE_IMAGE_VIEW_TYPE_1D + 1),
SE_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeImageViewType; } SeImageViewType;
typedef enum SeComponentSwizzle { typedef enum SeComponentSwizzle
{
SE_COMPONENT_SWIZZLE_IDENTITY = 0, SE_COMPONENT_SWIZZLE_IDENTITY = 0,
SE_COMPONENT_SWIZZLE_ZERO = 1, SE_COMPONENT_SWIZZLE_ZERO = 1,
SE_COMPONENT_SWIZZLE_ONE = 2, SE_COMPONENT_SWIZZLE_ONE = 2,
@@ -903,18 +918,20 @@ namespace Seele
SE_COMPONENT_SWIZZLE_END_RANGE = SE_COMPONENT_SWIZZLE_A, SE_COMPONENT_SWIZZLE_END_RANGE = SE_COMPONENT_SWIZZLE_A,
SE_COMPONENT_SWIZZLE_RANGE_SIZE = (SE_COMPONENT_SWIZZLE_A - SE_COMPONENT_SWIZZLE_IDENTITY + 1), SE_COMPONENT_SWIZZLE_RANGE_SIZE = (SE_COMPONENT_SWIZZLE_A - SE_COMPONENT_SWIZZLE_IDENTITY + 1),
SE_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF SE_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF
} SeComponentSwizzle; } SeComponentSwizzle;
typedef enum SeVertexInputRate { typedef enum SeVertexInputRate
{
SE_VERTEX_INPUT_RATE_VERTEX = 0, SE_VERTEX_INPUT_RATE_VERTEX = 0,
SE_VERTEX_INPUT_RATE_INSTANCE = 1, SE_VERTEX_INPUT_RATE_INSTANCE = 1,
SE_VERTEX_INPUT_RATE_BEGIN_RANGE = SE_VERTEX_INPUT_RATE_VERTEX, SE_VERTEX_INPUT_RATE_BEGIN_RANGE = SE_VERTEX_INPUT_RATE_VERTEX,
SE_VERTEX_INPUT_RATE_END_RANGE = SE_VERTEX_INPUT_RATE_INSTANCE, SE_VERTEX_INPUT_RATE_END_RANGE = SE_VERTEX_INPUT_RATE_INSTANCE,
SE_VERTEX_INPUT_RATE_RANGE_SIZE = (SE_VERTEX_INPUT_RATE_INSTANCE - SE_VERTEX_INPUT_RATE_VERTEX + 1), SE_VERTEX_INPUT_RATE_RANGE_SIZE = (SE_VERTEX_INPUT_RATE_INSTANCE - SE_VERTEX_INPUT_RATE_VERTEX + 1),
SE_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF SE_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF
} SeVertexInputRate; } SeVertexInputRate;
typedef enum SePrimitiveTopology { typedef enum SePrimitiveTopology
{
SE_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, SE_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
SE_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, SE_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
SE_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2, SE_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
@@ -930,9 +947,10 @@ namespace Seele
SE_PRIMITIVE_TOPOLOGY_END_RANGE = SE_PRIMITIVE_TOPOLOGY_PATCH_LIST, SE_PRIMITIVE_TOPOLOGY_END_RANGE = SE_PRIMITIVE_TOPOLOGY_PATCH_LIST,
SE_PRIMITIVE_TOPOLOGY_RANGE_SIZE = (SE_PRIMITIVE_TOPOLOGY_PATCH_LIST - SE_PRIMITIVE_TOPOLOGY_POINT_LIST + 1), SE_PRIMITIVE_TOPOLOGY_RANGE_SIZE = (SE_PRIMITIVE_TOPOLOGY_PATCH_LIST - SE_PRIMITIVE_TOPOLOGY_POINT_LIST + 1),
SE_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF SE_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF
} SePrimitiveTopology; } SePrimitiveTopology;
typedef enum SePolygonMode { typedef enum SePolygonMode
{
SE_POLYGON_MODE_FILL = 0, SE_POLYGON_MODE_FILL = 0,
SE_POLYGON_MODE_LINE = 1, SE_POLYGON_MODE_LINE = 1,
SE_POLYGON_MODE_POINT = 2, SE_POLYGON_MODE_POINT = 2,
@@ -941,18 +959,20 @@ namespace Seele
SE_POLYGON_MODE_END_RANGE = SE_POLYGON_MODE_POINT, SE_POLYGON_MODE_END_RANGE = SE_POLYGON_MODE_POINT,
SE_POLYGON_MODE_RANGE_SIZE = (SE_POLYGON_MODE_POINT - SE_POLYGON_MODE_FILL + 1), SE_POLYGON_MODE_RANGE_SIZE = (SE_POLYGON_MODE_POINT - SE_POLYGON_MODE_FILL + 1),
SE_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF SE_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF
} SePolygonMode; } SePolygonMode;
typedef enum SeFrontFace { typedef enum SeFrontFace
{
SE_FRONT_FACE_COUNTER_CLOCKWISE = 0, SE_FRONT_FACE_COUNTER_CLOCKWISE = 0,
SE_FRONT_FACE_CLOCKWISE = 1, SE_FRONT_FACE_CLOCKWISE = 1,
SE_FRONT_FACE_BEGIN_RANGE = SE_FRONT_FACE_COUNTER_CLOCKWISE, SE_FRONT_FACE_BEGIN_RANGE = SE_FRONT_FACE_COUNTER_CLOCKWISE,
SE_FRONT_FACE_END_RANGE = SE_FRONT_FACE_CLOCKWISE, SE_FRONT_FACE_END_RANGE = SE_FRONT_FACE_CLOCKWISE,
SE_FRONT_FACE_RANGE_SIZE = (SE_FRONT_FACE_CLOCKWISE - SE_FRONT_FACE_COUNTER_CLOCKWISE + 1), SE_FRONT_FACE_RANGE_SIZE = (SE_FRONT_FACE_CLOCKWISE - SE_FRONT_FACE_COUNTER_CLOCKWISE + 1),
SE_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF SE_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF
} SeFrontFace; } SeFrontFace;
typedef enum SeCompareOp { typedef enum SeCompareOp
{
SE_COMPARE_OP_NEVER = 0, SE_COMPARE_OP_NEVER = 0,
SE_COMPARE_OP_LESS = 1, SE_COMPARE_OP_LESS = 1,
SE_COMPARE_OP_EQUAL = 2, SE_COMPARE_OP_EQUAL = 2,
@@ -965,9 +985,10 @@ namespace Seele
SE_COMPARE_OP_END_RANGE = SE_COMPARE_OP_ALWAYS, SE_COMPARE_OP_END_RANGE = SE_COMPARE_OP_ALWAYS,
SE_COMPARE_OP_RANGE_SIZE = (SE_COMPARE_OP_ALWAYS - SE_COMPARE_OP_NEVER + 1), SE_COMPARE_OP_RANGE_SIZE = (SE_COMPARE_OP_ALWAYS - SE_COMPARE_OP_NEVER + 1),
SE_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF SE_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF
} SeCompareOp; } SeCompareOp;
typedef enum SeStencilOp { typedef enum SeStencilOp
{
SE_STENCIL_OP_KEEP = 0, SE_STENCIL_OP_KEEP = 0,
SE_STENCIL_OP_ZERO = 1, SE_STENCIL_OP_ZERO = 1,
SE_STENCIL_OP_REPLACE = 2, SE_STENCIL_OP_REPLACE = 2,
@@ -980,9 +1001,10 @@ namespace Seele
SE_STENCIL_OP_END_RANGE = SE_STENCIL_OP_DECREMENT_AND_WRAP, SE_STENCIL_OP_END_RANGE = SE_STENCIL_OP_DECREMENT_AND_WRAP,
SE_STENCIL_OP_RANGE_SIZE = (SE_STENCIL_OP_DECREMENT_AND_WRAP - SE_STENCIL_OP_KEEP + 1), SE_STENCIL_OP_RANGE_SIZE = (SE_STENCIL_OP_DECREMENT_AND_WRAP - SE_STENCIL_OP_KEEP + 1),
SE_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF SE_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF
} SeStencilOp; } SeStencilOp;
typedef enum SeLogicOp { typedef enum SeLogicOp
{
SE_LOGIC_OP_CLEAR = 0, SE_LOGIC_OP_CLEAR = 0,
SE_LOGIC_OP_AND = 1, SE_LOGIC_OP_AND = 1,
SE_LOGIC_OP_AND_REVERSE = 2, SE_LOGIC_OP_AND_REVERSE = 2,
@@ -1003,9 +1025,10 @@ namespace Seele
SE_LOGIC_OP_END_RANGE = SE_LOGIC_OP_SET, SE_LOGIC_OP_END_RANGE = SE_LOGIC_OP_SET,
SE_LOGIC_OP_RANGE_SIZE = (SE_LOGIC_OP_SET - SE_LOGIC_OP_CLEAR + 1), SE_LOGIC_OP_RANGE_SIZE = (SE_LOGIC_OP_SET - SE_LOGIC_OP_CLEAR + 1),
SE_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF SE_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF
} SeLogicOp; } SeLogicOp;
typedef enum SeBlendFactor { typedef enum SeBlendFactor
{
SE_BLEND_FACTOR_ZERO = 0, SE_BLEND_FACTOR_ZERO = 0,
SE_BLEND_FACTOR_ONE = 1, SE_BLEND_FACTOR_ONE = 1,
SE_BLEND_FACTOR_SRC_COLOR = 2, SE_BLEND_FACTOR_SRC_COLOR = 2,
@@ -1029,9 +1052,10 @@ namespace Seele
SE_BLEND_FACTOR_END_RANGE = SE_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, SE_BLEND_FACTOR_END_RANGE = SE_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
SE_BLEND_FACTOR_RANGE_SIZE = (SE_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - SE_BLEND_FACTOR_ZERO + 1), SE_BLEND_FACTOR_RANGE_SIZE = (SE_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - SE_BLEND_FACTOR_ZERO + 1),
SE_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF SE_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF
} SeBlendFactor; } SeBlendFactor;
typedef enum SeBlendOp { typedef enum SeBlendOp
{
SE_BLEND_OP_ADD = 0, SE_BLEND_OP_ADD = 0,
SE_BLEND_OP_SUBTRACT = 1, SE_BLEND_OP_SUBTRACT = 1,
SE_BLEND_OP_REVERSE_SUBTRACT = 2, SE_BLEND_OP_REVERSE_SUBTRACT = 2,
@@ -1087,9 +1111,10 @@ namespace Seele
SE_BLEND_OP_END_RANGE = SE_BLEND_OP_MAX, SE_BLEND_OP_END_RANGE = SE_BLEND_OP_MAX,
SE_BLEND_OP_RANGE_SIZE = (SE_BLEND_OP_MAX - SE_BLEND_OP_ADD + 1), SE_BLEND_OP_RANGE_SIZE = (SE_BLEND_OP_MAX - SE_BLEND_OP_ADD + 1),
SE_BLEND_OP_MAX_ENUM = 0x7FFFFFFF SE_BLEND_OP_MAX_ENUM = 0x7FFFFFFF
} SeBlendOp; } SeBlendOp;
typedef enum SeDynamicState { typedef enum SeDynamicState
{
SE_DYNAMIC_STATE_VIEWPORT = 0, SE_DYNAMIC_STATE_VIEWPORT = 0,
SE_DYNAMIC_STATE_SCISSOR = 1, SE_DYNAMIC_STATE_SCISSOR = 1,
SE_DYNAMIC_STATE_LINE_WIDTH = 2, SE_DYNAMIC_STATE_LINE_WIDTH = 2,
@@ -1110,9 +1135,10 @@ namespace Seele
SE_DYNAMIC_STATE_END_RANGE = SE_DYNAMIC_STATE_STENCIL_REFERENCE, SE_DYNAMIC_STATE_END_RANGE = SE_DYNAMIC_STATE_STENCIL_REFERENCE,
SE_DYNAMIC_STATE_RANGE_SIZE = (SE_DYNAMIC_STATE_STENCIL_REFERENCE - SE_DYNAMIC_STATE_VIEWPORT + 1), SE_DYNAMIC_STATE_RANGE_SIZE = (SE_DYNAMIC_STATE_STENCIL_REFERENCE - SE_DYNAMIC_STATE_VIEWPORT + 1),
SE_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF SE_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF
} SeDynamicState; } SeDynamicState;
typedef enum SeFilter { typedef enum SeFilter
{
SE_FILTER_NEAREST = 0, SE_FILTER_NEAREST = 0,
SE_FILTER_LINEAR = 1, SE_FILTER_LINEAR = 1,
SE_FILTER_CUBIC_IMG = 1000015000, SE_FILTER_CUBIC_IMG = 1000015000,
@@ -1121,18 +1147,20 @@ namespace Seele
SE_FILTER_END_RANGE = SE_FILTER_LINEAR, SE_FILTER_END_RANGE = SE_FILTER_LINEAR,
SE_FILTER_RANGE_SIZE = (SE_FILTER_LINEAR - SE_FILTER_NEAREST + 1), SE_FILTER_RANGE_SIZE = (SE_FILTER_LINEAR - SE_FILTER_NEAREST + 1),
SE_FILTER_MAX_ENUM = 0x7FFFFFFF SE_FILTER_MAX_ENUM = 0x7FFFFFFF
} SeFilter; } SeFilter;
typedef enum SeSamplerMipmapMode { typedef enum SeSamplerMipmapMode
{
SE_SAMPLER_MIPMAP_MODE_NEAREST = 0, SE_SAMPLER_MIPMAP_MODE_NEAREST = 0,
SE_SAMPLER_MIPMAP_MODE_LINEAR = 1, SE_SAMPLER_MIPMAP_MODE_LINEAR = 1,
SE_SAMPLER_MIPMAP_MODE_BEGIN_RANGE = SE_SAMPLER_MIPMAP_MODE_NEAREST, SE_SAMPLER_MIPMAP_MODE_BEGIN_RANGE = SE_SAMPLER_MIPMAP_MODE_NEAREST,
SE_SAMPLER_MIPMAP_MODE_END_RANGE = SE_SAMPLER_MIPMAP_MODE_LINEAR, SE_SAMPLER_MIPMAP_MODE_END_RANGE = SE_SAMPLER_MIPMAP_MODE_LINEAR,
SE_SAMPLER_MIPMAP_MODE_RANGE_SIZE = (SE_SAMPLER_MIPMAP_MODE_LINEAR - SE_SAMPLER_MIPMAP_MODE_NEAREST + 1), SE_SAMPLER_MIPMAP_MODE_RANGE_SIZE = (SE_SAMPLER_MIPMAP_MODE_LINEAR - SE_SAMPLER_MIPMAP_MODE_NEAREST + 1),
SE_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF SE_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF
} SeSamplerMipmapMode; } SeSamplerMipmapMode;
typedef enum SeSamplerAddressMode { typedef enum SeSamplerAddressMode
{
SE_SAMPLER_ADDRESS_MODE_REPEAT = 0, SE_SAMPLER_ADDRESS_MODE_REPEAT = 0,
SE_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1, SE_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1,
SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2, SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2,
@@ -1143,9 +1171,10 @@ namespace Seele
SE_SAMPLER_ADDRESS_MODE_END_RANGE = SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, SE_SAMPLER_ADDRESS_MODE_END_RANGE = SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
SE_SAMPLER_ADDRESS_MODE_RANGE_SIZE = (SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - SE_SAMPLER_ADDRESS_MODE_REPEAT + 1), SE_SAMPLER_ADDRESS_MODE_RANGE_SIZE = (SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - SE_SAMPLER_ADDRESS_MODE_REPEAT + 1),
SE_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF SE_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF
} SeSamplerAddressMode; } SeSamplerAddressMode;
typedef enum SeBorderColor { typedef enum SeBorderColor
{
SE_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, SE_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0,
SE_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, SE_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1,
SE_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2, SE_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2,
@@ -1156,9 +1185,10 @@ namespace Seele
SE_BORDER_COLOR_END_RANGE = SE_BORDER_COLOR_INT_OPAQUE_WHITE, SE_BORDER_COLOR_END_RANGE = SE_BORDER_COLOR_INT_OPAQUE_WHITE,
SE_BORDER_COLOR_RANGE_SIZE = (SE_BORDER_COLOR_INT_OPAQUE_WHITE - SE_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1), SE_BORDER_COLOR_RANGE_SIZE = (SE_BORDER_COLOR_INT_OPAQUE_WHITE - SE_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1),
SE_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF SE_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF
} SeBorderColor; } SeBorderColor;
typedef enum SeDescriptorType { typedef enum SeDescriptorType
{
SE_DESCRIPTOR_TYPE_SAMPLER = 0, SE_DESCRIPTOR_TYPE_SAMPLER = 0,
SE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, SE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2, SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2,
@@ -1176,9 +1206,10 @@ namespace Seele
SE_DESCRIPTOR_TYPE_END_RANGE = SE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, SE_DESCRIPTOR_TYPE_END_RANGE = SE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
SE_DESCRIPTOR_TYPE_RANGE_SIZE = (SE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - SE_DESCRIPTOR_TYPE_SAMPLER + 1), SE_DESCRIPTOR_TYPE_RANGE_SIZE = (SE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - SE_DESCRIPTOR_TYPE_SAMPLER + 1),
SE_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF SE_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeDescriptorType; } SeDescriptorType;
typedef enum SeAttachmentLoadOp { typedef enum SeAttachmentLoadOp
{
SE_ATTACHMENT_LOAD_OP_LOAD = 0, SE_ATTACHMENT_LOAD_OP_LOAD = 0,
SE_ATTACHMENT_LOAD_OP_CLEAR = 1, SE_ATTACHMENT_LOAD_OP_CLEAR = 1,
SE_ATTACHMENT_LOAD_OP_DONT_CARE = 2, SE_ATTACHMENT_LOAD_OP_DONT_CARE = 2,
@@ -1186,18 +1217,20 @@ namespace Seele
SE_ATTACHMENT_LOAD_OP_END_RANGE = SE_ATTACHMENT_LOAD_OP_DONT_CARE, SE_ATTACHMENT_LOAD_OP_END_RANGE = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
SE_ATTACHMENT_LOAD_OP_RANGE_SIZE = (SE_ATTACHMENT_LOAD_OP_DONT_CARE - SE_ATTACHMENT_LOAD_OP_LOAD + 1), SE_ATTACHMENT_LOAD_OP_RANGE_SIZE = (SE_ATTACHMENT_LOAD_OP_DONT_CARE - SE_ATTACHMENT_LOAD_OP_LOAD + 1),
SE_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF SE_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF
} SeAttachmentLoadOp; } SeAttachmentLoadOp;
typedef enum SeAttachmentStoreOp { typedef enum SeAttachmentStoreOp
{
SE_ATTACHMENT_STORE_OP_STORE = 0, SE_ATTACHMENT_STORE_OP_STORE = 0,
SE_ATTACHMENT_STORE_OP_DONT_CARE = 1, SE_ATTACHMENT_STORE_OP_DONT_CARE = 1,
SE_ATTACHMENT_STORE_OP_BEGIN_RANGE = SE_ATTACHMENT_STORE_OP_STORE, SE_ATTACHMENT_STORE_OP_BEGIN_RANGE = SE_ATTACHMENT_STORE_OP_STORE,
SE_ATTACHMENT_STORE_OP_END_RANGE = SE_ATTACHMENT_STORE_OP_DONT_CARE, SE_ATTACHMENT_STORE_OP_END_RANGE = SE_ATTACHMENT_STORE_OP_DONT_CARE,
SE_ATTACHMENT_STORE_OP_RANGE_SIZE = (SE_ATTACHMENT_STORE_OP_DONT_CARE - SE_ATTACHMENT_STORE_OP_STORE + 1), SE_ATTACHMENT_STORE_OP_RANGE_SIZE = (SE_ATTACHMENT_STORE_OP_DONT_CARE - SE_ATTACHMENT_STORE_OP_STORE + 1),
SE_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF SE_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF
} SeAttachmentStoreOp; } SeAttachmentStoreOp;
typedef enum SePipelineBindPoint { typedef enum SePipelineBindPoint
{
SE_PIPELINE_BIND_POINT_GRAPHICS = 0, SE_PIPELINE_BIND_POINT_GRAPHICS = 0,
SE_PIPELINE_BIND_POINT_COMPUTE = 1, SE_PIPELINE_BIND_POINT_COMPUTE = 1,
SE_PIPELINE_BIND_POINT_RAY_TRACING_NV = 1000165000, SE_PIPELINE_BIND_POINT_RAY_TRACING_NV = 1000165000,
@@ -1205,18 +1238,20 @@ namespace Seele
SE_PIPELINE_BIND_POINT_END_RANGE = SE_PIPELINE_BIND_POINT_COMPUTE, SE_PIPELINE_BIND_POINT_END_RANGE = SE_PIPELINE_BIND_POINT_COMPUTE,
SE_PIPELINE_BIND_POINT_RANGE_SIZE = (SE_PIPELINE_BIND_POINT_COMPUTE - SE_PIPELINE_BIND_POINT_GRAPHICS + 1), SE_PIPELINE_BIND_POINT_RANGE_SIZE = (SE_PIPELINE_BIND_POINT_COMPUTE - SE_PIPELINE_BIND_POINT_GRAPHICS + 1),
SE_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF SE_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF
} SePipelineBindPoint; } SePipelineBindPoint;
typedef enum SeCommandBufferLevel { typedef enum SeCommandBufferLevel
{
SE_COMMAND_BUFFER_LEVEL_PRIMARY = 0, SE_COMMAND_BUFFER_LEVEL_PRIMARY = 0,
SE_COMMAND_BUFFER_LEVEL_SECONDARY = 1, SE_COMMAND_BUFFER_LEVEL_SECONDARY = 1,
SE_COMMAND_BUFFER_LEVEL_BEGIN_RANGE = SE_COMMAND_BUFFER_LEVEL_PRIMARY, SE_COMMAND_BUFFER_LEVEL_BEGIN_RANGE = SE_COMMAND_BUFFER_LEVEL_PRIMARY,
SE_COMMAND_BUFFER_LEVEL_END_RANGE = SE_COMMAND_BUFFER_LEVEL_SECONDARY, SE_COMMAND_BUFFER_LEVEL_END_RANGE = SE_COMMAND_BUFFER_LEVEL_SECONDARY,
SE_COMMAND_BUFFER_LEVEL_RANGE_SIZE = (SE_COMMAND_BUFFER_LEVEL_SECONDARY - SE_COMMAND_BUFFER_LEVEL_PRIMARY + 1), SE_COMMAND_BUFFER_LEVEL_RANGE_SIZE = (SE_COMMAND_BUFFER_LEVEL_SECONDARY - SE_COMMAND_BUFFER_LEVEL_PRIMARY + 1),
SE_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF SE_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF
} SeCommandBufferLevel; } SeCommandBufferLevel;
typedef enum SeIndexType { typedef enum SeIndexType
{
SE_INDEX_TYPE_UINT16 = 0, SE_INDEX_TYPE_UINT16 = 0,
SE_INDEX_TYPE_UINT32 = 1, SE_INDEX_TYPE_UINT32 = 1,
SE_INDEX_TYPE_NONE_NV = 1000165000, SE_INDEX_TYPE_NONE_NV = 1000165000,
@@ -1225,18 +1260,20 @@ namespace Seele
SE_INDEX_TYPE_END_RANGE = SE_INDEX_TYPE_UINT32, SE_INDEX_TYPE_END_RANGE = SE_INDEX_TYPE_UINT32,
SE_INDEX_TYPE_RANGE_SIZE = (SE_INDEX_TYPE_UINT32 - SE_INDEX_TYPE_UINT16 + 1), SE_INDEX_TYPE_RANGE_SIZE = (SE_INDEX_TYPE_UINT32 - SE_INDEX_TYPE_UINT16 + 1),
SE_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF SE_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeIndexType; } SeIndexType;
typedef enum SeSubpassContents { typedef enum SeSubpassContents
{
SE_SUBPASS_CONTENTS_INLINE = 0, SE_SUBPASS_CONTENTS_INLINE = 0,
SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1, SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1,
SE_SUBPASS_CONTENTS_BEGIN_RANGE = SE_SUBPASS_CONTENTS_INLINE, SE_SUBPASS_CONTENTS_BEGIN_RANGE = SE_SUBPASS_CONTENTS_INLINE,
SE_SUBPASS_CONTENTS_END_RANGE = SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, SE_SUBPASS_CONTENTS_END_RANGE = SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS,
SE_SUBPASS_CONTENTS_RANGE_SIZE = (SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS - SE_SUBPASS_CONTENTS_INLINE + 1), SE_SUBPASS_CONTENTS_RANGE_SIZE = (SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS - SE_SUBPASS_CONTENTS_INLINE + 1),
SE_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF SE_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF
} SeSubpassContents; } SeSubpassContents;
typedef enum SeObjectType { typedef enum SeObjectType
{
SE_OBJECT_TYPE_UNKNOWN = 0, SE_OBJECT_TYPE_UNKNOWN = 0,
SE_OBJECT_TYPE_INSTANCE = 1, SE_OBJECT_TYPE_INSTANCE = 1,
SE_OBJECT_TYPE_PHYSICAL_DEVICE = 2, SE_OBJECT_TYPE_PHYSICAL_DEVICE = 2,
@@ -1282,9 +1319,10 @@ namespace Seele
SE_OBJECT_TYPE_END_RANGE = SE_OBJECT_TYPE_COMMAND_POOL, SE_OBJECT_TYPE_END_RANGE = SE_OBJECT_TYPE_COMMAND_POOL,
SE_OBJECT_TYPE_RANGE_SIZE = (SE_OBJECT_TYPE_COMMAND_POOL - SE_OBJECT_TYPE_UNKNOWN + 1), SE_OBJECT_TYPE_RANGE_SIZE = (SE_OBJECT_TYPE_COMMAND_POOL - SE_OBJECT_TYPE_UNKNOWN + 1),
SE_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF SE_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF
} SeObjectType; } SeObjectType;
typedef enum SeVendorId { typedef enum SeVendorId
{
SE_VENDOR_ID_VIV = 0x10001, SE_VENDOR_ID_VIV = 0x10001,
SE_VENDOR_ID_VSI = 0x10002, SE_VENDOR_ID_VSI = 0x10002,
SE_VENDOR_ID_KAZAN = 0x10003, SE_VENDOR_ID_KAZAN = 0x10003,
@@ -1292,10 +1330,11 @@ namespace Seele
SE_VENDOR_ID_END_RANGE = SE_VENDOR_ID_KAZAN, SE_VENDOR_ID_END_RANGE = SE_VENDOR_ID_KAZAN,
SE_VENDOR_ID_RANGE_SIZE = (SE_VENDOR_ID_KAZAN - SE_VENDOR_ID_VIV + 1), SE_VENDOR_ID_RANGE_SIZE = (SE_VENDOR_ID_KAZAN - SE_VENDOR_ID_VIV + 1),
SE_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF SE_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF
} SeVendorId; } SeVendorId;
typedef SeFlags SeInstanceCreateFlags; typedef SeFlags SeInstanceCreateFlags;
typedef enum SeFormatFeatureFlagBits { typedef enum SeFormatFeatureFlagBits
{
SE_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001, SE_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001,
SE_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002, SE_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002,
SE_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004, SE_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004,
@@ -1332,10 +1371,11 @@ namespace Seele
SE_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = SE_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, SE_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = SE_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT,
SE_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = SE_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG, SE_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = SE_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG,
SE_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeFormatFeatureFlagBits; } SeFormatFeatureFlagBits;
typedef SeFlags SeFormatFeatureFlags; typedef SeFlags SeFormatFeatureFlags;
typedef enum SeImageUsageFlagBits { typedef enum SeImageUsageFlagBits
{
SE_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001, SE_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001,
SE_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002, SE_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002,
SE_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, SE_IMAGE_USAGE_SAMPLED_BIT = 0x00000004,
@@ -1347,10 +1387,11 @@ namespace Seele
SE_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = 0x00000100, SE_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = 0x00000100,
SE_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200, SE_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200,
SE_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeImageUsageFlagBits; } SeImageUsageFlagBits;
typedef SeFlags SeImageUsageFlags; typedef SeFlags SeImageUsageFlags;
typedef enum SeImageCreateFlagBits { typedef enum SeImageCreateFlagBits
{
SE_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, SE_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001,
SE_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, SE_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
SE_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, SE_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
@@ -1373,10 +1414,11 @@ namespace Seele
SE_IMAGE_CREATE_DISJOINT_BIT_KHR = SE_IMAGE_CREATE_DISJOINT_BIT, SE_IMAGE_CREATE_DISJOINT_BIT_KHR = SE_IMAGE_CREATE_DISJOINT_BIT,
SE_IMAGE_CREATE_ALIAS_BIT_KHR = SE_IMAGE_CREATE_ALIAS_BIT, SE_IMAGE_CREATE_ALIAS_BIT_KHR = SE_IMAGE_CREATE_ALIAS_BIT,
SE_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeImageCreateFlagBits; } SeImageCreateFlagBits;
typedef SeFlags SeImageCreateFlags; typedef SeFlags SeImageCreateFlags;
typedef enum SeSampleCountFlagBits { typedef enum SeSampleCountFlagBits
{
SE_SAMPLE_COUNT_1_BIT = 0x00000001, SE_SAMPLE_COUNT_1_BIT = 0x00000001,
SE_SAMPLE_COUNT_2_BIT = 0x00000002, SE_SAMPLE_COUNT_2_BIT = 0x00000002,
SE_SAMPLE_COUNT_4_BIT = 0x00000004, SE_SAMPLE_COUNT_4_BIT = 0x00000004,
@@ -1385,20 +1427,22 @@ namespace Seele
SE_SAMPLE_COUNT_32_BIT = 0x00000020, SE_SAMPLE_COUNT_32_BIT = 0x00000020,
SE_SAMPLE_COUNT_64_BIT = 0x00000040, SE_SAMPLE_COUNT_64_BIT = 0x00000040,
SE_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeSampleCountFlagBits; } SeSampleCountFlagBits;
typedef SeFlags SeSampleCountFlags; typedef SeFlags SeSampleCountFlags;
typedef enum SeQueueFlagBits { typedef enum SeQueueFlagBits
{
SE_QUEUE_GRAPHICS_BIT = 0x00000001, SE_QUEUE_GRAPHICS_BIT = 0x00000001,
SE_QUEUE_COMPUTE_BIT = 0x00000002, SE_QUEUE_COMPUTE_BIT = 0x00000002,
SE_QUEUE_TRANSFER_BIT = 0x00000004, SE_QUEUE_TRANSFER_BIT = 0x00000004,
SE_QUEUE_SPARSE_BINDING_BIT = 0x00000008, SE_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
SE_QUEUE_PROTECTED_BIT = 0x00000010, SE_QUEUE_PROTECTED_BIT = 0x00000010,
SE_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeQueueFlagBits; } SeQueueFlagBits;
typedef SeFlags SeQueueFlags; typedef SeFlags SeQueueFlags;
typedef enum SeMemoryPropertyFlagBits { typedef enum SeMemoryPropertyFlagBits
{
SE_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001, SE_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001,
SE_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002, SE_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002,
SE_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004, SE_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004,
@@ -1408,25 +1452,28 @@ namespace Seele
SE_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD = 0x00000040, SE_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD = 0x00000040,
SE_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD = 0x00000080, SE_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD = 0x00000080,
SE_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeMemoryPropertyFlagBits; } SeMemoryPropertyFlagBits;
typedef SeFlags SeMemoryPropertyFlags; typedef SeFlags SeMemoryPropertyFlags;
typedef enum SeMemoryHeapFlagBits { typedef enum SeMemoryHeapFlagBits
{
SE_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001, SE_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
SE_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002, SE_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002,
SE_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = SE_MEMORY_HEAP_MULTI_INSTANCE_BIT, SE_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = SE_MEMORY_HEAP_MULTI_INSTANCE_BIT,
SE_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeMemoryHeapFlagBits; } SeMemoryHeapFlagBits;
typedef SeFlags SeMemoryHeapFlags; typedef SeFlags SeMemoryHeapFlags;
typedef SeFlags SeDeviceCreateFlags; typedef SeFlags SeDeviceCreateFlags;
typedef enum SeDeviceQueueCreateFlagBits { typedef enum SeDeviceQueueCreateFlagBits
{
SE_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 0x00000001, SE_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 0x00000001,
SE_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeDeviceQueueCreateFlagBits; } SeDeviceQueueCreateFlagBits;
typedef SeFlags SeDeviceQueueCreateFlags; typedef SeFlags SeDeviceQueueCreateFlags;
typedef enum SePipelineStageFlagBits { typedef enum SePipelineStageFlagBits
{
SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001,
SE_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, SE_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002,
SE_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, SE_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004,
@@ -1454,11 +1501,12 @@ namespace Seele
SE_PIPELINE_STAGE_MESH_SHADER_BIT_NV = 0x00100000, SE_PIPELINE_STAGE_MESH_SHADER_BIT_NV = 0x00100000,
SE_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000, SE_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000,
SE_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SePipelineStageFlagBits; } SePipelineStageFlagBits;
typedef SeFlags SePipelineStageFlags; typedef SeFlags SePipelineStageFlags;
typedef SeFlags SeMemoryMapFlags; typedef SeFlags SeMemoryMapFlags;
typedef enum SeImageAspectFlagBits { typedef enum SeImageAspectFlagBits
{
SE_IMAGE_ASPECT_COLOR_BIT = 0x00000001, SE_IMAGE_ASPECT_COLOR_BIT = 0x00000001,
SE_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, SE_IMAGE_ASPECT_DEPTH_BIT = 0x00000002,
SE_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, SE_IMAGE_ASPECT_STENCIL_BIT = 0x00000004,
@@ -1474,33 +1522,37 @@ namespace Seele
SE_IMAGE_ASPECT_PLANE_1_BIT_KHR = SE_IMAGE_ASPECT_PLANE_1_BIT, SE_IMAGE_ASPECT_PLANE_1_BIT_KHR = SE_IMAGE_ASPECT_PLANE_1_BIT,
SE_IMAGE_ASPECT_PLANE_2_BIT_KHR = SE_IMAGE_ASPECT_PLANE_2_BIT, SE_IMAGE_ASPECT_PLANE_2_BIT_KHR = SE_IMAGE_ASPECT_PLANE_2_BIT,
SE_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeImageAspectFlagBits; } SeImageAspectFlagBits;
typedef SeFlags SeImageAspectFlags; typedef SeFlags SeImageAspectFlags;
typedef enum SeSparseImageFormatFlagBits { typedef enum SeSparseImageFormatFlagBits
{
SE_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001, SE_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001,
SE_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002, SE_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002,
SE_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004, SE_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004,
SE_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeSparseImageFormatFlagBits; } SeSparseImageFormatFlagBits;
typedef SeFlags SeSparseImageFormatFlags; typedef SeFlags SeSparseImageFormatFlags;
typedef enum SeSparseMemoryBindFlagBits { typedef enum SeSparseMemoryBindFlagBits
{
SE_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001, SE_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001,
SE_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeSparseMemoryBindFlagBits; } SeSparseMemoryBindFlagBits;
typedef SeFlags SeSparseMemoryBindFlags; typedef SeFlags SeSparseMemoryBindFlags;
typedef enum SeFenceCreateFlagBits { typedef enum SeFenceCreateFlagBits
{
SE_FENCE_CREATE_SIGNALED_BIT = 0x00000001, SE_FENCE_CREATE_SIGNALED_BIT = 0x00000001,
SE_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeFenceCreateFlagBits; } SeFenceCreateFlagBits;
typedef SeFlags SeFenceCreateFlags; typedef SeFlags SeFenceCreateFlags;
typedef SeFlags SeSemaphoreCreateFlags; typedef SeFlags SeSemaphoreCreateFlags;
typedef SeFlags SeEventCreateFlags; typedef SeFlags SeEventCreateFlags;
typedef SeFlags SeQueryPoolCreateFlags; typedef SeFlags SeQueryPoolCreateFlags;
typedef enum SeQueryPipelineStatisticFlagBits { typedef enum SeQueryPipelineStatisticFlagBits
{
SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001, SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001,
SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002, SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002,
SE_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004, SE_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004,
@@ -1513,29 +1565,32 @@ namespace Seele
SE_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, SE_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200,
SE_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, SE_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400,
SE_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeQueryPipelineStatisticFlagBits; } SeQueryPipelineStatisticFlagBits;
typedef SeFlags SeQueryPipelineStatisticFlags; typedef SeFlags SeQueryPipelineStatisticFlags;
typedef enum SeQueryResultFlagBits { typedef enum SeQueryResultFlagBits
{
SE_QUERY_RESULT_64_BIT = 0x00000001, SE_QUERY_RESULT_64_BIT = 0x00000001,
SE_QUERY_RESULT_WAIT_BIT = 0x00000002, SE_QUERY_RESULT_WAIT_BIT = 0x00000002,
SE_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, SE_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004,
SE_QUERY_RESULT_PARTIAL_BIT = 0x00000008, SE_QUERY_RESULT_PARTIAL_BIT = 0x00000008,
SE_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeQueryResultFlagBits; } SeQueryResultFlagBits;
typedef SeFlags SeQueryResultFlags; typedef SeFlags SeQueryResultFlags;
typedef enum SeBufferCreateFlagBits { typedef enum SeBufferCreateFlagBits
{
SE_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, SE_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001,
SE_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, SE_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
SE_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, SE_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
SE_BUFFER_CREATE_PROTECTED_BIT = 0x00000008, SE_BUFFER_CREATE_PROTECTED_BIT = 0x00000008,
SE_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000010, SE_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000010,
SE_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeBufferCreateFlagBits; } SeBufferCreateFlagBits;
typedef SeFlags SeBufferCreateFlags; typedef SeFlags SeBufferCreateFlags;
typedef enum SeBufferUsageFlagBits { typedef enum SeBufferUsageFlagBits
{
SE_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001, SE_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001,
SE_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002, SE_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002,
SE_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, SE_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004,
@@ -1551,23 +1606,26 @@ namespace Seele
SE_BUFFER_USAGE_RAY_TRACING_BIT_NV = 0x00000400, SE_BUFFER_USAGE_RAY_TRACING_BIT_NV = 0x00000400,
SE_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = 0x00020000, SE_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = 0x00020000,
SE_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeBufferUsageFlagBits; } SeBufferUsageFlagBits;
typedef SeFlags SeBufferUsageFlags; typedef SeFlags SeBufferUsageFlags;
typedef SeFlags SeBufferViewCreateFlags; typedef SeFlags SeBufferViewCreateFlags;
typedef enum SeImageViewCreateFlagBits { typedef enum SeImageViewCreateFlagBits
{
SE_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001, SE_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001,
SE_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeImageViewCreateFlagBits; } SeImageViewCreateFlagBits;
typedef SeFlags SeImageViewCreateFlags; typedef SeFlags SeImageViewCreateFlags;
typedef enum SeShaderModuleCreateFlagBits { typedef enum SeShaderModuleCreateFlagBits
{
SE_SHADER_MODULE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SHADER_MODULE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeShaderModuleCreateFlagBits; } SeShaderModuleCreateFlagBits;
typedef SeFlags SeShaderModuleCreateFlags; typedef SeFlags SeShaderModuleCreateFlags;
typedef SeFlags SePipelineCacheCreateFlags; typedef SeFlags SePipelineCacheCreateFlags;
typedef enum SePipelineCreateFlagBits { typedef enum SePipelineCreateFlagBits
{
SE_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, SE_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001,
SE_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002, SE_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002,
SE_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004, SE_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004,
@@ -1579,17 +1637,19 @@ namespace Seele
SE_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = SE_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT, SE_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = SE_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT,
SE_PIPELINE_CREATE_DISPATCH_BASE_KHR = SE_PIPELINE_CREATE_DISPATCH_BASE, SE_PIPELINE_CREATE_DISPATCH_BASE_KHR = SE_PIPELINE_CREATE_DISPATCH_BASE,
SE_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SePipelineCreateFlagBits; } SePipelineCreateFlagBits;
typedef SeFlags SePipelineCreateFlags; typedef SeFlags SePipelineCreateFlags;
typedef enum SePipelineShaderStageCreateFlagBits { typedef enum SePipelineShaderStageCreateFlagBits
{
SE_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000001, SE_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000001,
SE_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000002, SE_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000002,
SE_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SePipelineShaderStageCreateFlagBits; } SePipelineShaderStageCreateFlagBits;
typedef SeFlags SePipelineShaderStageCreateFlags; typedef SeFlags SePipelineShaderStageCreateFlags;
typedef enum SeShaderStageFlagBits { typedef enum SeShaderStageFlagBits
{
SE_SHADER_STAGE_VERTEX_BIT = 0x00000001, SE_SHADER_STAGE_VERTEX_BIT = 0x00000001,
SE_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002, SE_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002,
SE_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, SE_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004,
@@ -1607,84 +1667,94 @@ namespace Seele
SE_SHADER_STAGE_TASK_BIT_NV = 0x00000040, SE_SHADER_STAGE_TASK_BIT_NV = 0x00000040,
SE_SHADER_STAGE_MESH_BIT_NV = 0x00000080, SE_SHADER_STAGE_MESH_BIT_NV = 0x00000080,
SE_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeShaderStageFlagBits; } SeShaderStageFlagBits;
typedef SeFlags SePipelineVertexInputStateCreateFlags; typedef SeFlags SePipelineVertexInputStateCreateFlags;
typedef SeFlags SePipelineInputAssemblyStateCreateFlags; typedef SeFlags SePipelineInputAssemblyStateCreateFlags;
typedef SeFlags SePipelineTessellationStateCreateFlags; typedef SeFlags SePipelineTessellationStateCreateFlags;
typedef SeFlags SePipelineViewportStateCreateFlags; typedef SeFlags SePipelineViewportStateCreateFlags;
typedef SeFlags SePipelineRasterizationStateCreateFlags; typedef SeFlags SePipelineRasterizationStateCreateFlags;
typedef enum SeCullModeFlagBits { typedef enum SeCullModeFlagBits
{
SE_CULL_MODE_NONE = 0, SE_CULL_MODE_NONE = 0,
SE_CULL_MODE_FRONT_BIT = 0x00000001, SE_CULL_MODE_FRONT_BIT = 0x00000001,
SE_CULL_MODE_BACK_BIT = 0x00000002, SE_CULL_MODE_BACK_BIT = 0x00000002,
SE_CULL_MODE_FRONT_AND_BACK = 0x00000003, SE_CULL_MODE_FRONT_AND_BACK = 0x00000003,
SE_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeCullModeFlagBits; } SeCullModeFlagBits;
typedef SeFlags SeCullModeFlags; typedef SeFlags SeCullModeFlags;
typedef SeFlags SePipelineMultisampleStateCreateFlags; typedef SeFlags SePipelineMultisampleStateCreateFlags;
typedef SeFlags SePipelineDepthStencilStateCreateFlags; typedef SeFlags SePipelineDepthStencilStateCreateFlags;
typedef SeFlags SePipelineColorBlendStateCreateFlags; typedef SeFlags SePipelineColorBlendStateCreateFlags;
typedef enum SeColorComponentFlagBits { typedef enum SeColorComponentFlagBits
{
SE_COLOR_COMPONENT_R_BIT = 0x00000001, SE_COLOR_COMPONENT_R_BIT = 0x00000001,
SE_COLOR_COMPONENT_G_BIT = 0x00000002, SE_COLOR_COMPONENT_G_BIT = 0x00000002,
SE_COLOR_COMPONENT_B_BIT = 0x00000004, SE_COLOR_COMPONENT_B_BIT = 0x00000004,
SE_COLOR_COMPONENT_A_BIT = 0x00000008, SE_COLOR_COMPONENT_A_BIT = 0x00000008,
SE_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeColorComponentFlagBits; } SeColorComponentFlagBits;
typedef SeFlags SeColorComponentFlags; typedef SeFlags SeColorComponentFlags;
typedef SeFlags SePipelineDynamicStateCreateFlags; typedef SeFlags SePipelineDynamicStateCreateFlags;
typedef SeFlags SePipelineLayoutCreateFlags; typedef SeFlags SePipelineLayoutCreateFlags;
typedef SeFlags SeShaderStageFlags; typedef SeFlags SeShaderStageFlags;
typedef enum SeSamplerCreateFlagBits { typedef enum SeSamplerCreateFlagBits
{
SE_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001, SE_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001,
SE_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002, SE_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002,
SE_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeSamplerCreateFlagBits; } SeSamplerCreateFlagBits;
typedef SeFlags SeSamplerCreateFlags; typedef SeFlags SeSamplerCreateFlags;
typedef enum SeDescriptorSetLayoutCreateFlagBits { typedef enum SeDescriptorSetLayoutCreateFlagBits
{
SE_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, SE_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001,
SE_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = 0x00000002, SE_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = 0x00000002,
SE_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeDescriptorSetLayoutCreateFlagBits; } SeDescriptorSetLayoutCreateFlagBits;
typedef SeFlags SeDescriptorSetLayoutCreateFlags; typedef SeFlags SeDescriptorSetLayoutCreateFlags;
typedef enum SeDescriptorPoolCreateFlagBits { typedef enum SeDescriptorPoolCreateFlagBits
{
SE_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, SE_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001,
SE_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = 0x00000002, SE_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = 0x00000002,
SE_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeDescriptorPoolCreateFlagBits; } SeDescriptorPoolCreateFlagBits;
typedef SeFlags SeDescriptorPoolCreateFlags; typedef SeFlags SeDescriptorPoolCreateFlags;
typedef SeFlags SeDescriptorPoolResetFlags; typedef SeFlags SeDescriptorPoolResetFlags;
typedef enum SeFramebufferCreateFlagBits { typedef enum SeFramebufferCreateFlagBits
{
SE_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR = 0x00000001, SE_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR = 0x00000001,
SE_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeFramebufferCreateFlagBits; } SeFramebufferCreateFlagBits;
typedef SeFlags SeFramebufferCreateFlags; typedef SeFlags SeFramebufferCreateFlags;
typedef enum SeRenderPassCreateFlagBits { typedef enum SeRenderPassCreateFlagBits
{
SE_RENDER_PASS_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_RENDER_PASS_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeRenderPassCreateFlagBits; } SeRenderPassCreateFlagBits;
typedef SeFlags SeRenderPassCreateFlags; typedef SeFlags SeRenderPassCreateFlags;
typedef enum SeAttachmentDescriptionFlagBits { typedef enum SeAttachmentDescriptionFlagBits
{
SE_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, SE_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001,
SE_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeAttachmentDescriptionFlagBits; } SeAttachmentDescriptionFlagBits;
typedef SeFlags SeAttachmentDescriptionFlags; typedef SeFlags SeAttachmentDescriptionFlags;
typedef enum SeSubpassDescriptionFlagBits { typedef enum SeSubpassDescriptionFlagBits
{
SE_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001, SE_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001,
SE_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002, SE_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002,
SE_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeSubpassDescriptionFlagBits; } SeSubpassDescriptionFlagBits;
typedef SeFlags SeSubpassDescriptionFlags; typedef SeFlags SeSubpassDescriptionFlags;
typedef enum SeAccessFlagBits { typedef enum SeAccessFlagBits
{
SE_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001, SE_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001,
SE_ACCESS_INDEX_READ_BIT = 0x00000002, SE_ACCESS_INDEX_READ_BIT = 0x00000002,
SE_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004, SE_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004,
@@ -1714,60 +1784,67 @@ namespace Seele
SE_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000, SE_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000,
SE_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000, SE_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000,
SE_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeAccessFlagBits; } SeAccessFlagBits;
typedef SeFlags SeAccessFlags; typedef SeFlags SeAccessFlags;
typedef enum SeDependencyFlagBits { typedef enum SeDependencyFlagBits
{
SE_DEPENDENCY_BY_REGION_BIT = 0x00000001, SE_DEPENDENCY_BY_REGION_BIT = 0x00000001,
SE_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004, SE_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004,
SE_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002, SE_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002,
SE_DEPENDENCY_VIEW_LOCAL_BIT_KHR = SE_DEPENDENCY_VIEW_LOCAL_BIT, SE_DEPENDENCY_VIEW_LOCAL_BIT_KHR = SE_DEPENDENCY_VIEW_LOCAL_BIT,
SE_DEPENDENCY_DEVICE_GROUP_BIT_KHR = SE_DEPENDENCY_DEVICE_GROUP_BIT, SE_DEPENDENCY_DEVICE_GROUP_BIT_KHR = SE_DEPENDENCY_DEVICE_GROUP_BIT,
SE_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeDependencyFlagBits; } SeDependencyFlagBits;
typedef SeFlags SeDependencyFlags; typedef SeFlags SeDependencyFlags;
typedef enum SeCommandPoolCreateFlagBits { typedef enum SeCommandPoolCreateFlagBits
{
SE_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001, SE_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001,
SE_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002, SE_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
SE_COMMAND_POOL_CREATE_PROTECTED_BIT = 0x00000004, SE_COMMAND_POOL_CREATE_PROTECTED_BIT = 0x00000004,
SE_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeCommandPoolCreateFlagBits; } SeCommandPoolCreateFlagBits;
typedef SeFlags SeCommandPoolCreateFlags; typedef SeFlags SeCommandPoolCreateFlags;
typedef enum SeCommandPoolResetFlagBits { typedef enum SeCommandPoolResetFlagBits
{
SE_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, SE_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
SE_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeCommandPoolResetFlagBits; } SeCommandPoolResetFlagBits;
typedef SeFlags SeCommandPoolResetFlags; typedef SeFlags SeCommandPoolResetFlags;
typedef enum SeCommandBufferUsageFlagBits { typedef enum SeCommandBufferUsageFlagBits
{
SE_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001, SE_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001,
SE_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002, SE_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002,
SE_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004, SE_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004,
SE_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeCommandBufferUsageFlagBits; } SeCommandBufferUsageFlagBits;
typedef SeFlags SeCommandBufferUsageFlags; typedef SeFlags SeCommandBufferUsageFlags;
typedef enum SeQueryControlFlagBits { typedef enum SeQueryControlFlagBits
{
SE_QUERY_CONTROL_PRECISE_BIT = 0x00000001, SE_QUERY_CONTROL_PRECISE_BIT = 0x00000001,
SE_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeQueryControlFlagBits; } SeQueryControlFlagBits;
typedef SeFlags SeQueryControlFlags; typedef SeFlags SeQueryControlFlags;
typedef enum SeCommandBufferResetFlagBits { typedef enum SeCommandBufferResetFlagBits
{
SE_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, SE_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
SE_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeCommandBufferResetFlagBits; } SeCommandBufferResetFlagBits;
typedef SeFlags SeCommandBufferResetFlags; typedef SeFlags SeCommandBufferResetFlags;
typedef enum SeStencilFaceFlagBits { typedef enum SeStencilFaceFlagBits
{
SE_STENCIL_FACE_FRONT_BIT = 0x00000001, SE_STENCIL_FACE_FRONT_BIT = 0x00000001,
SE_STENCIL_FACE_BACK_BIT = 0x00000002, SE_STENCIL_FACE_BACK_BIT = 0x00000002,
SE_STENCIL_FACE_FRONT_AND_BACK = 0x00000003, SE_STENCIL_FACE_FRONT_AND_BACK = 0x00000003,
SE_STENCIL_FRONT_AND_BACK = SE_STENCIL_FACE_FRONT_AND_BACK, SE_STENCIL_FRONT_AND_BACK = SE_STENCIL_FACE_FRONT_AND_BACK,
SE_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF SE_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} SeStencilFaceFlagBits; } SeStencilFaceFlagBits;
typedef SeFlags SeStencilFaceFlags; typedef SeFlags SeStencilFaceFlags;
} } // namespace Gfx
} } // namespace Seele
+39 -25
View File
@@ -1,5 +1,6 @@
#include "GraphicsResources.h" #include "GraphicsResources.h"
using namespace Seele;
using namespace Seele::Gfx; using namespace Seele::Gfx;
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount) void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount)
@@ -30,8 +31,8 @@ void PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layo
} }
if (descriptorSetLayouts[setIndex] != nullptr) if (descriptorSetLayouts[setIndex] != nullptr)
{ {
auto& thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings; auto &thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
auto& otherBindings = layout->descriptorBindings; auto &otherBindings = layout->descriptorBindings;
thisBindings.resize(otherBindings.size()); thisBindings.resize(otherBindings.size());
for (size_t i = 0; i < otherBindings.size(); ++i) for (size_t i = 0; i < otherBindings.size(); ++i)
{ {
@@ -48,44 +49,57 @@ void PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layo
} }
} }
void PipelineLayout::addPushConstants(const SePushConstantRange& pushConstant) void PipelineLayout::addPushConstants(const SePushConstantRange &pushConstant)
{ {
pushConstants.add(pushConstant); pushConstants.add(pushConstant);
} }
UniformBuffer::UniformBuffer()
{
}
UniformBuffer::~UniformBuffer()
{
}
RenderTargetLayout::RenderTargetLayout() RenderTargetLayout::RenderTargetLayout()
: inputAttachments() : inputAttachments(), colorAttachments(), depthAttachment()
, colorAttachments()
, depthAttachment()
{ {
} }
RenderTargetLayout::RenderTargetLayout(PTexture2D depthAttachment) RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment)
: inputAttachments() : inputAttachments(), colorAttachments(), depthAttachment(depthAttachment)
, colorAttachments()
, depthAttachment(depthAttachment)
{ {
} }
RenderTargetLayout::RenderTargetLayout(PTexture2D colorAttachment, PTexture2D depthAttachment) RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
: inputAttachments() : inputAttachments(), depthAttachment(depthAttachment)
, depthAttachment(depthAttachment)
{ {
colorAttachments.add(colorAttachment); colorAttachments.add(colorAttachment);
} }
RenderTargetLayout::RenderTargetLayout(Array<PTexture2D> colorAttachments, PTexture2D depthAttachmet) RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet)
: inputAttachments() : inputAttachments(), colorAttachments(colorAttachments), depthAttachment(depthAttachment)
, colorAttachments(colorAttachments)
, depthAttachment(depthAttachment)
{ {
} }
RenderTargetLayout::RenderTargetLayout(Array<PTexture2D> inputAttachments, Array<PTexture2D> colorAttachments, PTexture2D depthAttachment) RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
: inputAttachments(inputAttachments) : inputAttachments(inputAttachments), colorAttachments(colorAttachments), depthAttachment(depthAttachment)
, colorAttachments(colorAttachments) {
, depthAttachment(depthAttachment) }
Window::Window(const WindowCreateInfo &createInfo)
: sizeX(createInfo.width), sizeY(createInfo.height), bFullscreen(createInfo.bFullscreen), title(createInfo.title), pixelFormat(createInfo.pixelFormat)
{
}
Window::~Window()
{
}
Viewport::Viewport(PWindow owner, const ViewportCreateInfo &viewportInfo)
: sizeX(viewportInfo.sizeX), sizeY(viewportInfo.sizeY), offsetX(viewportInfo.offsetX), offsetY(viewportInfo.offsetY), owner(owner)
{
}
Viewport::~Viewport()
{ {
} }
+282 -151
View File
@@ -9,82 +9,117 @@
namespace Seele namespace Seele
{ {
struct GraphicsInitializer namespace Gfx
{ {
const char* windowLayoutFile; enum class QueueType
const char* applicationName; {
const char* engineName; GRAPHICS = 1,
void* windowHandle; COMPUTE = 2,
TRANSFER = 3,
DEDICATED_TRANSFER = 4
};
} // namespace Gfx
struct GraphicsInitializer
{
const char *windowLayoutFile;
const char *applicationName;
const char *engineName;
void *windowHandle;
/** /**
* layers defines the enabled Vulkan layers used in the instance, * layers defines the enabled Vulkan layers used in the instance,
* if ENABLE_VALIDATION is defined, standard validation is already enabled * if ENABLE_VALIDATION is defined, standard validation is already enabled
* not yet implemented * not yet implemented
*/ */
Array<const char*> layers; Array<const char *> layers;
Array<const char*> instanceExtensions; Array<const char *> instanceExtensions;
Array<const char*> deviceExtensions; Array<const char *> deviceExtensions;
GraphicsInitializer() GraphicsInitializer()
: applicationName("SeeleEngine") : applicationName("SeeleEngine"), engineName("SeeleEngine"), layers{"VK_LAYER_LUNARG_standard_validation"}, instanceExtensions{}, deviceExtensions{"VK_KHR_swapchain"}, windowHandle(nullptr)
, engineName("SeeleEngine")
, layers{ "VK_LAYER_LUNARG_standard_validation" }
, instanceExtensions{}
, deviceExtensions{ "VK_KHR_swapchain" }
, windowHandle(nullptr)
{}
GraphicsInitializer(const GraphicsInitializer& other)
: applicationName(other.applicationName)
, engineName(other.engineName)
, layers(other.layers)
, instanceExtensions(other.instanceExtensions)
, deviceExtensions(other.deviceExtensions)
{ {
} }
}; GraphicsInitializer(const GraphicsInitializer &other)
struct WindowCreateInfo : applicationName(other.applicationName), engineName(other.engineName), layers(other.layers), instanceExtensions(other.instanceExtensions), deviceExtensions(other.deviceExtensions)
{ {
}
};
struct WindowCreateInfo
{
int32 width; int32 width;
int32 height; int32 height;
const char* title; const char *title;
bool bFullscreen; bool bFullscreen;
}; Gfx::SeFormat pixelFormat;
namespace Gfx void *windowHandle;
};
struct ViewportCreateInfo
{
uint32 sizeX;
uint32 sizeY;
uint32 offsetX;
uint32 offsetY;
bool bFullscreen;
bool bVsync;
};
struct TextureCreateInfo
{
uint32 width;
uint32 height;
uint32 depth;
bool bArray;
uint32 arrayLayers;
uint32 mipLevels;
uint32 samples;
Gfx::SeFormat format;
Gfx::SeImageUsageFlagBits usage;
Gfx::QueueType queueType;
TextureCreateInfo()
: width(1), height(1), depth(1), bArray(false), arrayLayers(1), mipLevels(1), samples(1), format(Gfx::SE_FORMAT_R32G32B32A32_SFLOAT), usage(Gfx::SE_IMAGE_USAGE_SAMPLED_BIT)
{ {
struct SePushConstantRange { }
};
//doesnt own the data, only proxy it
struct BulkResourceData
{
uint32 size;
uint8 *data;
Gfx::QueueType owner;
};
namespace Gfx
{
struct SePushConstantRange
{
SeShaderStageFlags stageFlags; SeShaderStageFlags stageFlags;
uint32_t offset; uint32_t offset;
uint32_t size; uint32_t size;
}; };
class RenderCommandBase class RenderCommandBase
{
public:
virtual ~RenderCommandBase()
{ {
}
}; };
DEFINE_REF(RenderCommandBase); DEFINE_REF(RenderCommandBase);
class SamplerState
class SamplerState {
{ public:
public:
virtual ~SamplerState() virtual ~SamplerState()
{ {
} }
}; };
DEFINE_REF(SamplerState); DEFINE_REF(SamplerState);
class DescriptorBinding class DescriptorBinding
{ {
public: public:
DescriptorBinding() DescriptorBinding()
: binding(0) : binding(0), descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM), descriptorCount(0x7fff), shaderStages(SE_SHADER_STAGE_ALL)
, descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM) {
, descriptorCount(-1) }
, shaderStages(SE_SHADER_STAGE_ALL) DescriptorBinding(const DescriptorBinding &other)
{} : binding(other.binding), descriptorType(other.descriptorType), descriptorCount(other.descriptorCount), shaderStages(other.shaderStages)
DescriptorBinding(const DescriptorBinding& other) {
: binding(other.binding) }
, descriptorType(other.descriptorType) void operator=(const DescriptorBinding &other)
, descriptorCount(other.descriptorCount)
, shaderStages(other.shaderStages)
{}
void operator=(const DescriptorBinding& other)
{ {
binding = other.binding; binding = other.binding;
descriptorType = other.descriptorType; descriptorType = other.descriptorType;
@@ -95,24 +130,24 @@ namespace Seele
SeDescriptorType descriptorType; SeDescriptorType descriptorType;
uint32_t descriptorCount; uint32_t descriptorCount;
SeShaderStageFlags shaderStages; SeShaderStageFlags shaderStages;
}; };
DEFINE_REF(DescriptorBinding); DEFINE_REF(DescriptorBinding);
DECLARE_REF(DescriptorSet); DECLARE_REF(DescriptorSet);
class DescriptorAllocator class DescriptorAllocator
{ {
public: public:
DescriptorAllocator() {} DescriptorAllocator() {}
~DescriptorAllocator() {} virtual ~DescriptorAllocator() {}
virtual void allocateDescriptorSet(PDescriptorSet& descriptorSet) = 0; virtual void allocateDescriptorSet(PDescriptorSet &descriptorSet) = 0;
}; };
DEFINE_REF(DescriptorAllocator); DEFINE_REF(DescriptorAllocator);
DECLARE_REF(UniformBuffer); DECLARE_REF(UniformBuffer);
DECLARE_REF(StructuredBuffer); DECLARE_REF(StructuredBuffer);
DECLARE_REF(Texture); DECLARE_REF(Texture);
class DescriptorSet class DescriptorSet
{ {
public: public:
virtual ~DescriptorSet() {} virtual ~DescriptorSet() {}
virtual void writeChanges() = 0; virtual void writeChanges() = 0;
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0; virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
@@ -120,15 +155,15 @@ namespace Seele
virtual void updateSampler(uint32 binding, PSamplerState samplerState) = 0; virtual void updateSampler(uint32 binding, PSamplerState samplerState) = 0;
virtual void updateTexture(uint32 binding, PTexture texture, PSamplerState samplerState = nullptr) = 0; virtual void updateTexture(uint32 binding, PTexture texture, PSamplerState samplerState = nullptr) = 0;
virtual bool operator<(PDescriptorSet other) = 0; virtual bool operator<(PDescriptorSet other) = 0;
}; };
DEFINE_REF(DescriptorSet); DEFINE_REF(DescriptorSet);
class DescriptorLayout class DescriptorLayout
{ {
public: public:
DescriptorLayout() {} DescriptorLayout() {}
virtual ~DescriptorLayout() {} virtual ~DescriptorLayout() {}
void operator=(const DescriptorLayout& other) void operator=(const DescriptorLayout &other)
{ {
descriptorBindings.resize(other.descriptorBindings.size()); descriptorBindings.resize(other.descriptorBindings.size());
std::memcpy(descriptorBindings.data(), other.descriptorBindings.data(), sizeof(DescriptorLayout) * descriptorBindings.size()); std::memcpy(descriptorBindings.data(), other.descriptorBindings.data(), sizeof(DescriptorLayout) * descriptorBindings.size());
@@ -136,108 +171,204 @@ namespace Seele
virtual void create() = 0; virtual void create() = 0;
virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1); virtual void addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1);
virtual PDescriptorSet allocatedDescriptorSet(); virtual PDescriptorSet allocatedDescriptorSet();
const Array<DescriptorBinding>& getBindings() const { return descriptorBindings; } const Array<DescriptorBinding> &getBindings() const { return descriptorBindings; }
protected:
protected:
Array<DescriptorBinding> descriptorBindings; Array<DescriptorBinding> descriptorBindings;
PDescriptorAllocator allocator; PDescriptorAllocator allocator;
friend class PipelineLayout; friend class PipelineLayout;
friend class DescriptorAllocator; friend class DescriptorAllocator;
}; };
DEFINE_REF(DescriptorLayout); DEFINE_REF(DescriptorLayout);
class PipelineLayout class PipelineLayout
{ {
public: public:
PipelineLayout() {} PipelineLayout() {}
virtual ~PipelineLayout() {} virtual ~PipelineLayout() {}
virtual void create() = 0; virtual void create() = 0;
void addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout); void addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout);
void addPushConstants(const SePushConstantRange& pushConstants); void addPushConstants(const SePushConstantRange &pushConstants);
virtual uint32 getHash() const = 0; virtual uint32 getHash() const = 0;
protected:
protected:
Array<PDescriptorLayout> descriptorSetLayouts; Array<PDescriptorLayout> descriptorSetLayouts;
Array<SePushConstantRange> pushConstants; Array<SePushConstantRange> pushConstants;
}; };
DEFINE_REF(PipelineLayout); DEFINE_REF(PipelineLayout);
class VertexDeclaration class VertexDeclaration
{
public:
virtual ~VertexDeclaration()
{ {
}
}; };
DEFINE_REF(VertexDeclaration); DEFINE_REF(VertexDeclaration);
class GraphicsPipeline class GraphicsPipeline
{ {
public: public:
virtual ~GraphicsPipeline() virtual ~GraphicsPipeline()
{ {
} }
}; };
DEFINE_REF(GraphicsPipeline); DEFINE_REF(GraphicsPipeline);
class UniformBuffer class UniformBuffer
{
public:
UniformBuffer();
virtual ~UniformBuffer();
};
DEFINE_REF(UniformBuffer);
class VertexBuffer
{
public:
virtual ~VertexBuffer()
{ {
public:
virtual ~UniformBuffer()
{
} }
}; };
DEFINE_REF(UniformBuffer); DEFINE_REF(VertexBuffer);
class Viewport class IndexBuffer
{
public:
virtual ~IndexBuffer()
{ {
}
}; };
DEFINE_REF(Viewport); DEFINE_REF(IndexBuffer);
class VertexBuffer class StructuredBuffer
{ {
public:
};
DEFINE_REF(VertexBuffer);
class IndexBuffer
{
};
DEFINE_REF(IndexBuffer);
class StructuredBuffer
{
public:
virtual ~StructuredBuffer() virtual ~StructuredBuffer()
{ {
} }
}; };
DEFINE_REF(StructuredBuffer); DEFINE_REF(StructuredBuffer);
class Texture class Texture
{
public:
virtual ~Texture()
{ {
}
}; };
DEFINE_REF(Texture); DEFINE_REF(Texture);
class Texture2D : public Texture class Texture2D : public Texture
{ {
public: public:
virtual ~Texture2D() virtual ~Texture2D()
{ {
} }
}; };
DEFINE_REF(Texture2D); DEFINE_REF(Texture2D);
class RenderTargetLayout class Window
{
public:
Window(const WindowCreateInfo &createInfo);
virtual ~Window();
virtual void beginFrame() = 0;
virtual void endFrame() = 0;
virtual void onWindowCloseEvent() = 0;
virtual PTexture2D getBackBuffer() = 0;
protected:
uint32 sizeX;
uint32 sizeY;
bool bFullscreen;
const char *title;
SeFormat pixelFormat;
};
DEFINE_REF(Window);
class Viewport
{
public:
Viewport(PWindow owner, const ViewportCreateInfo &createInfo);
virtual ~Viewport();
protected:
uint32 sizeX;
uint32 sizeY;
uint32 offsetX;
uint32 offsetY;
PWindow owner;
};
DEFINE_REF(Viewport);
class RenderTargetAttachment
{
public:
RenderTargetAttachment(PTexture2D texture,
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
: texture(texture), loadOp(loadOp), storeOp(storeOp), stencilLoadOp(stencilLoadOp), stencilStoreOp(stencilStoreOp)
{ {
public: }
virtual ~RenderTargetAttachment()
{
}
virtual PTexture2D getTexture()
{
return texture;
}
inline SeAttachmentLoadOp getLoadOp() const { return loadOp; }
inline SeAttachmentStoreOp getStoreOp() const { return storeOp; }
inline SeAttachmentLoadOp getStencilLoadOp() const { return stencilLoadOp; }
inline SeAttachmentStoreOp getStencilStoreOp() const { return stencilStoreOp; }
protected:
PTexture2D texture;
SeAttachmentLoadOp loadOp;
SeAttachmentStoreOp storeOp;
SeAttachmentLoadOp stencilLoadOp;
SeAttachmentStoreOp stencilStoreOp;
};
DEFINE_REF(RenderTargetAttachment);
class SwapchainAttachment : public RenderTargetAttachment
{
public:
SwapchainAttachment(PWindow owner,
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
: RenderTargetAttachment(owner->getBackBuffer(), loadOp, storeOp, stencilLoadOp, stencilStoreOp), owner(owner)
{
}
virtual PTexture2D getTexture() override
{
return owner->getBackBuffer();
}
private:
PWindow owner;
};
DEFINE_REF(SwapchainAttachment);
class RenderTargetLayout
{
public:
RenderTargetLayout(); RenderTargetLayout();
RenderTargetLayout(PTexture2D depthAttachment); RenderTargetLayout(PRenderTargetAttachment depthAttachment);
RenderTargetLayout(PTexture2D colorAttachment, PTexture2D depthAttachment); RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment);
RenderTargetLayout(Array<PTexture2D> colorAttachments, PTexture2D depthAttachmet); RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet);
RenderTargetLayout(Array<PTexture2D> inputAttachments, Array<PTexture2D> colorAttachments, PTexture2D depthAttachment); RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment);
Array<PTexture2D> inputAttachments; Array<PRenderTargetAttachment> inputAttachments;
Array<PTexture2D> colorAttachments; Array<PRenderTargetAttachment> colorAttachments;
PTexture2D depthAttachment; PRenderTargetAttachment depthAttachment;
}; };
DEFINE_REF(RenderTargetLayout); DEFINE_REF(RenderTargetLayout);
class RenderPass class RenderPass
{
public:
virtual ~RenderPass()
{ {
};
DEFINE_REF(RenderPass);
} }
} };
DEFINE_REF(RenderPass);
DEFINE_REF(RenderPass);
} // namespace Gfx
} // namespace Seele
+1 -1
View File
@@ -21,7 +21,7 @@ void Seele::RenderCore::init()
void Seele::RenderCore::renderLoop() void Seele::RenderCore::renderLoop()
{ {
while(windowManager->isActive()) while (windowManager->isActive())
{ {
windowManager->beginFrame(); windowManager->beginFrame();
windowManager->endFrame(); windowManager->endFrame();
+7 -6
View File
@@ -2,15 +2,16 @@
#include "WindowManager.h" #include "WindowManager.h"
namespace Seele namespace Seele
{ {
class RenderCore class RenderCore
{ {
public: public:
RenderCore(); RenderCore();
~RenderCore(); ~RenderCore();
void init(); void init();
void renderLoop(); void renderLoop();
void shutdown(); void shutdown();
private:
private:
PWindowManager windowManager; PWindowManager windowManager;
}; };
} } // namespace Seele
+9 -8
View File
@@ -2,10 +2,10 @@
#include "Graphics.h" #include "Graphics.h"
namespace Seele namespace Seele
{ {
//A renderpath is a general Renderer for a view. //A renderpath is a general Renderer for a view.
class RenderPath class RenderPath
{ {
public: public:
RenderPath(Gfx::PGraphics graphics); RenderPath(Gfx::PGraphics graphics);
virtual ~RenderPath(); virtual ~RenderPath();
virtual void applyArea(Rect area) = 0; virtual void applyArea(Rect area) = 0;
@@ -13,9 +13,10 @@ namespace Seele
virtual void beginFrame() = 0; virtual void beginFrame() = 0;
virtual void render() = 0; virtual void render() = 0;
virtual void endFrame() = 0; virtual void endFrame() = 0;
protected:
protected:
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
Rect area; Rect area;
}; };
DEFINE_REF(RenderPath); DEFINE_REF(RenderPath);
} } // namespace Seele
+2 -1
View File
@@ -9,8 +9,9 @@ Seele::SceneRenderPath::~SceneRenderPath()
{ {
} }
void Seele::SceneRenderPath::applyArea(Rect area) void Seele::SceneRenderPath::applyArea(Rect newArea)
{ {
area = newArea;
} }
void Seele::SceneRenderPath::init() void Seele::SceneRenderPath::init()
+5 -5
View File
@@ -3,9 +3,9 @@
namespace Seele namespace Seele
{ {
class SceneRenderPath : public RenderPath class SceneRenderPath : public RenderPath
{ {
public: public:
SceneRenderPath(Gfx::PGraphics graphics); SceneRenderPath(Gfx::PGraphics graphics);
virtual ~SceneRenderPath(); virtual ~SceneRenderPath();
virtual void applyArea(Rect area) override; virtual void applyArea(Rect area) override;
@@ -13,5 +13,5 @@ namespace Seele
virtual void beginFrame() override; virtual void beginFrame() override;
virtual void render() override; virtual void render() override;
virtual void endFrame() override; virtual void endFrame() override;
}; };
} } // namespace Seele
+5 -5
View File
@@ -2,10 +2,10 @@
#include "View.h" #include "View.h"
namespace Seele namespace Seele
{ {
class SceneView : public View class SceneView : public View
{ {
public: public:
SceneView(Gfx::PGraphics graphics); SceneView(Gfx::PGraphics graphics);
~SceneView(); ~SceneView();
}; };
} } // namespace Seele
+9 -8
View File
@@ -2,19 +2,20 @@
#include "RenderPath.h" #include "RenderPath.h"
namespace Seele namespace Seele
{ {
// A view is a part of the window, which can be anything from a viewport to an editor // A view is a part of the window, which can be anything from a viewport to an editor
class View class View
{ {
public: public:
View(Gfx::PGraphics graphics); View(Gfx::PGraphics graphics);
virtual ~View(); virtual ~View();
void beginFrame(); void beginFrame();
void endFrame(); void endFrame();
void applyArea(Rect area); void applyArea(Rect area);
protected:
protected:
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
PRenderPath renderer; PRenderPath renderer;
}; };
DEFINE_REF(View) DEFINE_REF(View)
} } // namespace Seele
+2 -1
View File
@@ -20,4 +20,5 @@ target_sources(SeeleEngine
VulkanRenderPass.cpp VulkanRenderPass.cpp
VulkanTexture.cpp VulkanTexture.cpp
VulkanQueue.h VulkanQueue.h
VulkanQueue.cpp) VulkanQueue.cpp
VulkanViewport.cpp)
+230 -24
View File
@@ -5,7 +5,7 @@
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
SubAllocation::SubAllocation(Allocation* owner, uint32 allocatedOffset, uint32 size, uint32 alignedOffset, uint32 allocatedSize) SubAllocation::SubAllocation(Allocation* owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize)
: owner(owner) : owner(owner)
, size(size) , size(size)
, allocatedOffset(allocatedOffset) , allocatedOffset(allocatedOffset)
@@ -14,11 +14,43 @@ SubAllocation::SubAllocation(Allocation* owner, uint32 allocatedOffset, uint32 s
{ {
} }
Allocation::Allocation(PGraphics graphics, Allocator* allocator, uint32 size, uint32 memoryTypeIndex, VkMemoryPropertyFlags properties, bool isDedicated) SubAllocation::~SubAllocation()
{
owner->markFree(this);
}
VkDeviceMemory SubAllocation::getHandle() const
{
return owner->getHandle();
}
bool SubAllocation::isReadable() const
{
return owner->isReadable();
}
void* SubAllocation::getMappedPointer()
{
return (uint8*)owner->getMappedPointer() + alignedOffset;
}
void SubAllocation::flushMemory()
{
owner->flushMemory();
}
void SubAllocation::invalidateMemory()
{
owner->invalidateMemory();
}
Allocation::Allocation(PGraphics graphics, Allocator* allocator, VkDeviceSize size, uint8 memoryTypeIndex,
VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo* dedicatedInfo)
: device(graphics->getDevice()) : device(graphics->getDevice())
, allocator(allocator) , allocator(allocator)
, bytesAllocated(0) , bytesAllocated(0)
, bytesUsed(0) , bytesUsed(0)
, readable(properties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
, properties(properties) , properties(properties)
, memoryTypeIndex(memoryTypeIndex) , memoryTypeIndex(memoryTypeIndex)
{ {
@@ -26,38 +58,52 @@ Allocation::Allocation(PGraphics graphics, Allocator* allocator, uint32 size, ui
init::MemoryAllocateInfo(); init::MemoryAllocateInfo();
allocInfo.allocationSize = size; allocInfo.allocationSize = size;
allocInfo.memoryTypeIndex = memoryTypeIndex; allocInfo.memoryTypeIndex = memoryTypeIndex;
isDedicated = dedicatedInfo != nullptr;
allocInfo.pNext = dedicatedInfo;
VK_CHECK(vkAllocateMemory(device, &allocInfo, nullptr, &allocatedMemory)); VK_CHECK(vkAllocateMemory(device, &allocInfo, nullptr, &allocatedMemory));
bytesAllocated = size; bytesAllocated = size;
PSubAllocation freeRange = new SubAllocation(this, 0, size, 0, size); PSubAllocation freeRange = new SubAllocation(this, 0, size, 0, size);
freeRanges.add(freeRange); freeRanges[0] = freeRange;
canMap = (properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
isMapped = false;
} }
PSubAllocation Allocation::getSuballocation(uint32 requestedSize, uint32 alignment) Allocation::~Allocation()
{
allocator->free(this);
}
PSubAllocation Allocation::getSuballocation(VkDeviceSize requestedSize, VkDeviceSize alignment)
{ {
if (isDedicated) if (isDedicated)
{ {
if (activeAllocations.size() == 0) if (activeAllocations.empty())
{ {
assert(requestedSize == bytesAllocated); assert(requestedSize == bytesAllocated);
activeAllocations.add(freeRanges.back()); PSubAllocation suballoc = freeRanges[0];
activeAllocations[0] = suballoc.getHandle();
freeRanges.clear(); freeRanges.clear();
bytesUsed += requestedSize;
return suballoc;
} }
else else
{ {
return nullptr; return nullptr;
} }
} }
for (int i = 0; i < freeRanges.size(); ++i) for (uint32 i = 0; i < freeRanges.size(); ++i)
{ {
PSubAllocation freeAllocation = freeRanges[i]; PSubAllocation freeAllocation = freeRanges[i];
uint32 allocatedOffset = freeAllocation->allocatedOffset; VkDeviceSize allocatedOffset = freeAllocation->allocatedOffset;
uint32 alignedOffset = align(allocatedOffset, alignment); VkDeviceSize alignedOffset = align(allocatedOffset, alignment);
uint32 alignmentAdjustment = alignedOffset - allocatedOffset; VkDeviceSize alignmentAdjustment = alignedOffset - allocatedOffset;
uint32 size = alignmentAdjustment + requestedSize; VkDeviceSize size = alignmentAdjustment + requestedSize;
if (freeAllocation->size == size) if (freeAllocation->size == size)
{ {
freeRanges.remove(i); freeRanges.erase(allocatedOffset);
activeAllocations.add(freeAllocation); activeAllocations[allocatedOffset] = freeAllocation.getHandle();
bytesUsed += size;
return freeAllocation; return freeAllocation;
} }
else if (size < freeAllocation->allocatedSize) else if (size < freeAllocation->allocatedSize)
@@ -67,19 +113,61 @@ PSubAllocation Allocation::getSuballocation(uint32 requestedSize, uint32 alignme
freeAllocation->allocatedOffset += allocatedOffset; freeAllocation->allocatedOffset += allocatedOffset;
freeAllocation->alignedOffset += allocatedOffset; freeAllocation->alignedOffset += allocatedOffset;
PSubAllocation subAlloc = new SubAllocation(this, allocatedOffset, size, alignedOffset, size); PSubAllocation subAlloc = new SubAllocation(this, allocatedOffset, size, alignedOffset, size);
activeAllocations.add(subAlloc); activeAllocations[allocatedOffset] = subAlloc.getHandle();
freeRanges.erase(allocatedOffset);
freeRanges[freeAllocation->allocatedOffset] = freeAllocation;
bytesUsed += size;
return subAlloc; return subAlloc;
} }
} }
return nullptr; return nullptr;
} }
void Allocation::markFree(SubAllocation* allocation)
{
VkDeviceSize lowerBound = allocation->allocatedOffset;
VkDeviceSize upperBound = allocation->allocatedOffset + allocation->allocatedSize;
PSubAllocation allocHandle;
for(auto freeRange : freeRanges)
{
PSubAllocation freeAlloc = freeRange.value;
if(freeAlloc->allocatedOffset + freeAlloc->allocatedSize + 1 == lowerBound)
{
freeAlloc->allocatedSize += allocation->allocatedSize;
allocHandle = freeAlloc;
break;
}
}
auto foundAlloc = freeRanges.find(upperBound + 1);
if(foundAlloc != freeRanges.end())
{
if(allocHandle == nullptr)
{
allocHandle->allocatedSize += foundAlloc->value->allocatedSize;
freeRanges.erase(foundAlloc->key);
}
else
{
allocHandle = foundAlloc->value;
allocHandle->allocatedOffset -= allocation->allocatedSize;
allocHandle->alignedOffset -= allocation->allocatedSize;
}
}
if(allocHandle == nullptr)
{
allocHandle = new SubAllocation(this, allocation->alignedOffset, allocation->size, allocation->alignedOffset, allocation->allocatedSize);
freeRanges[allocation->allocatedOffset] = allocHandle;
}
activeAllocations.erase(allocation->allocatedOffset);
bytesUsed -= allocation->allocatedSize;
}
Allocator::Allocator(PGraphics graphics) Allocator::Allocator(PGraphics graphics)
: graphics(graphics) : graphics(graphics)
{ {
vkGetPhysicalDeviceMemoryProperties(graphics->getPhysicalDevice(), &memProperties); vkGetPhysicalDeviceMemoryProperties(graphics->getPhysicalDevice(), &memProperties);
heaps.resize(memProperties.memoryHeapCount); heaps.resize(memProperties.memoryHeapCount);
for (size_t i = 0; i < memProperties.memoryHeapCount; i++) for (size_t i = 0; i < memProperties.memoryHeapCount; ++i)
{ {
VkMemoryHeap memoryHeap = memProperties.memoryHeaps[i]; VkMemoryHeap memoryHeap = memProperties.memoryHeaps[i];
HeapInfo& heapInfo = heaps[i]; HeapInfo& heapInfo = heaps[i];
@@ -89,25 +177,68 @@ Allocator::Allocator(PGraphics graphics)
Allocator::~Allocator() Allocator::~Allocator()
{ {
for(auto heap : heaps)
{
for(auto alloc : heap.allocations)
{
assert(alloc->activeAllocations.empty());
assert(alloc->freeRanges.size() == 1);
}
heap.allocations.clear();
}
graphics = nullptr;
} }
PSubAllocation Allocator::allocate(uint64 size, const VkMemoryRequirements2& memRequirements2, VkMemoryPropertyFlags properties) PSubAllocation Allocator::allocate(const VkMemoryRequirements2& memRequirements2, VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo* dedicatedInfo)
{ {
// no suitable allocations found, allocate new block
const VkMemoryRequirements& requirements = memRequirements2.memoryRequirements; const VkMemoryRequirements& requirements = memRequirements2.memoryRequirements;
uint32 memoryTypeIndex; uint8 memoryTypeIndex;
VK_CHECK(findMemoryType(requirements.memoryTypeBits, properties, &memoryTypeIndex)); VK_CHECK(findMemoryType(requirements.memoryTypeBits, properties, &memoryTypeIndex));
bool isDedicated = memRequirements2.pNext != nullptr;
PAllocation newAllocation = new Allocation(graphics, this, MemoryBlockSize, memoryTypeIndex, properties, isDedicated);
uint32 heapIndex = memProperties.memoryTypes[memoryTypeIndex].heapIndex; uint32 heapIndex = memProperties.memoryTypes[memoryTypeIndex].heapIndex;
if(memRequirements2.pNext != nullptr)
{
VkMemoryDedicatedRequirements* dedicatedReq = (VkMemoryDedicatedRequirements*)memRequirements2.pNext;
if(dedicatedReq->prefersDedicatedAllocation)
{
PAllocation newAllocation = new Allocation(graphics, this, requirements.size, memoryTypeIndex, properties, dedicatedInfo);
heaps[heapIndex].allocations.add(newAllocation); heaps[heapIndex].allocations.add(newAllocation);
return newAllocation->getSuballocation(size, requirements.alignment); return newAllocation->getSuballocation(requirements.size, requirements.alignment);
}
}
for(auto alloc : heaps[heapIndex].allocations)
{
PSubAllocation suballoc = alloc->getSuballocation(requirements.size, requirements.alignment);
if(suballoc != nullptr)
{
return suballoc;
}
}
// no suitable allocations found, allocate new block
PAllocation newAllocation = new Allocation(graphics, this, (requirements.size > MemoryBlockSize) ? requirements.size : MemoryBlockSize, memoryTypeIndex, properties, nullptr);
heaps[heapIndex].allocations.add(newAllocation);
return newAllocation->getSuballocation(requirements.size, requirements.alignment);
} }
VkResult Allocator::findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint32* typeIndex) void Allocator::free(Allocation* allocation)
{ {
for (int memoryIndex = 0; memoryIndex < memProperties.memoryTypeCount && typeBits; ++memoryIndex) for(auto heap : heaps)
{
for(uint32 i = 0; i < heap.allocations.size(); ++i)
{
if(heap.allocations[i] == allocation)
{
heap.allocations.remove(i, false);
return;
}
}
}
}
VkResult Allocator::findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint8* typeIndex)
{
for (uint8 memoryIndex = 0; memoryIndex < memProperties.memoryTypeCount && typeBits; ++memoryIndex)
{ {
if ((typeBits & 1) == 1) if ((typeBits & 1) == 1)
{ {
@@ -122,3 +253,78 @@ VkResult Allocator::findMemoryType(uint32 typeBits, VkMemoryPropertyFlags proper
return VK_ERROR_FORMAT_NOT_SUPPORTED; return VK_ERROR_FORMAT_NOT_SUPPORTED;
} }
StagingBuffer::StagingBuffer()
{
}
StagingBuffer::~StagingBuffer()
{
}
StagingManager::StagingManager(PGraphics graphics, PAllocator allocator)
: graphics(graphics)
, allocator(allocator)
{
}
StagingManager::~StagingManager()
{
}
void StagingManager::clearPending()
{
}
PStagingBuffer StagingManager::allocateStagingBuffer(uint32 size, VkBufferUsageFlags usage, bool bCPURead)
{
for(auto it = freeBuffers.begin(); it != freeBuffers.end(); ++it)
{
auto freeBuffer = *it;
if(freeBuffer->allocation->getSize() == size && freeBuffer->allocation->isReadable() == bCPURead)
{
activeBuffers.add(freeBuffer.getHandle());
freeBuffers.remove(it, false);
return freeBuffer;
}
}
PStagingBuffer stagingBuffer = new StagingBuffer();
VkBufferCreateInfo stagingBufferCreateInfo = init::BufferCreateInfo(usage, size);
VkDevice vulkanDevice = graphics->getDevice();
VK_CHECK(vkCreateBuffer(vulkanDevice, &stagingBufferCreateInfo, nullptr, &stagingBuffer->buffer));
VkMemoryDedicatedRequirements dedicatedReqs;
dedicatedReqs.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
dedicatedReqs.pNext = nullptr;
VkMemoryRequirements2 memReqs;
memReqs.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
memReqs.pNext = &dedicatedReqs;
VkBufferMemoryRequirementsInfo2 bufferQuery;
bufferQuery.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2;
bufferQuery.pNext = nullptr;
bufferQuery.buffer = stagingBuffer->buffer;
vkGetBufferMemoryRequirements2(vulkanDevice, &bufferQuery, &memReqs);
memReqs.memoryRequirements.alignment =
(16 > memReqs.memoryRequirements.alignment) ?
16 : memReqs.memoryRequirements.alignment;
stagingBuffer->allocation = allocator->allocate(memReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | (bCPURead ? VK_MEMORY_PROPERTY_HOST_CACHED_BIT : VK_MEMORY_PROPERTY_HOST_COHERENT_BIT), stagingBuffer->buffer);
stagingBuffer->bReadable = bCPURead;
vkBindBufferMemory(graphics->getDevice(), stagingBuffer->buffer, stagingBuffer->getMemoryHandle(), stagingBuffer->getOffset());
activeBuffers.add(stagingBuffer.getHandle());
return stagingBuffer;
}
void StagingManager::releaseStagingBuffer(PStagingBuffer buffer)
{
freeBuffers.add(buffer);
activeBuffers.remove(activeBuffers.find(buffer.getHandle()));
}
+179 -37
View File
@@ -6,69 +6,211 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{
DECLARE_REF(Graphics);
class Allocation;
class Allocator;
class SubAllocation
{
public:
SubAllocation(Allocation *owner, VkDeviceSize allocatedOffset, VkDeviceSize size, VkDeviceSize alignedOffset, VkDeviceSize allocatedSize);
~SubAllocation();
VkDeviceMemory getHandle() const;
inline VkDeviceSize getSize() const
{ {
DECLARE_REF(Graphics); return size;
class Allocation; }
class Allocator; inline VkDeviceSize getOffset() const
class SubAllocation
{ {
public: return alignedOffset;
SubAllocation(Allocation* owner, uint32 allocatedOffset, uint32 size, uint32 alignedOffset, uint32 allocatedSize); }
private: inline bool isReadable() const;
Allocation* owner; void *getMappedPointer();
uint32 allocatedOffset; void flushMemory();
uint32 size; void invalidateMemory();
uint32 alignedOffset;
uint32 allocatedSize; private:
Allocation *owner;
VkDeviceSize allocatedOffset;
VkDeviceSize size;
VkDeviceSize alignedOffset;
VkDeviceSize allocatedSize;
friend class Allocation; friend class Allocation;
friend class Allocator; friend class Allocator;
}; };
DEFINE_REF(SubAllocation); DEFINE_REF(SubAllocation);
class Allocation class Allocation
{
public:
Allocation(PGraphics graphics, Allocator *allocator, VkDeviceSize size, uint8 memoryTypeIndex,
VkMemoryPropertyFlags properties, VkMemoryDedicatedAllocateInfo *dedicatedInfo = nullptr);
~Allocation();
PSubAllocation getSuballocation(VkDeviceSize size, VkDeviceSize alignment);
void markFree(SubAllocation *alloc);
inline VkDeviceMemory getHandle() const
{ {
public: return allocatedMemory;
Allocation(PGraphics graphics, Allocator* allocator, uint32 size, uint32 memoryTypeIndex, VkMemoryPropertyFlags properties, bool isDedicated); }
PSubAllocation getSuballocation(uint32 size, uint32 alignment); inline void *getMappedPointer()
private: {
Allocator* allocator; if (!canMap)
{
return nullptr;
}
if (!isMapped)
{
vkMapMemory(device, allocatedMemory, 0, bytesAllocated, 0, &mappedPointer);
isMapped = true;
}
return mappedPointer;
}
inline bool isReadable() const
{
return readable;
}
void flushMemory()
{
VkMappedMemoryRange range;
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.pNext = 0;
range.memory = allocatedMemory;
range.size = bytesAllocated;
range.offset = 0;
vkFlushMappedMemoryRanges(device, 1, &range);
}
void invalidateMemory()
{
VkMappedMemoryRange range;
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.pNext = 0;
range.memory = allocatedMemory;
range.size = bytesAllocated;
vkInvalidateMappedMemoryRanges(device, 1, &range);
}
private:
Allocator *allocator;
VkDevice device; VkDevice device;
VkDeviceMemory allocatedMemory; VkDeviceMemory allocatedMemory;
VkDeviceSize bytesAllocated; VkDeviceSize bytesAllocated;
VkDeviceSize bytesUsed; VkDeviceSize bytesUsed;
VkMemoryPropertyFlags properties; VkMemoryPropertyFlags properties;
Array<PSubAllocation> activeAllocations; Map<VkDeviceSize, SubAllocation *> activeAllocations;
Array<PSubAllocation> freeRanges; Map<VkDeviceSize, PSubAllocation> freeRanges;
void* mappedPointer; void *mappedPointer;
uint8 memoryTypeIndex;
uint8 isDedicated : 1; uint8 isDedicated : 1;
uint8 canMap : 1; uint8 canMap : 1;
uint8 memoryTypeIndex; uint8 isMapped : 1;
uint8 readable : 1;
friend class Allocator; friend class Allocator;
}; };
DEFINE_REF(Allocation); DEFINE_REF(Allocation);
class Allocator class Allocator
{ {
public: public:
Allocator(PGraphics graphics); Allocator(PGraphics graphics);
~Allocator(); ~Allocator();
PSubAllocation allocate(uint64 size, const VkMemoryRequirements2& requirements, VkMemoryPropertyFlags props); PSubAllocation allocate(const VkMemoryRequirements2 &requirements, VkMemoryPropertyFlags props,
VkMemoryDedicatedAllocateInfo *dedicatedInfo = nullptr);
inline PSubAllocation allocate(const VkMemoryRequirements2 &requirements, VkMemoryPropertyFlags props,
VkBuffer buffer)
{
VkMemoryDedicatedAllocateInfo allocInfo;
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
allocInfo.pNext = nullptr;
allocInfo.buffer = buffer;
allocInfo.image = VK_NULL_HANDLE;
return allocate(requirements, props, &allocInfo);
}
inline PSubAllocation allocate(const VkMemoryRequirements2 &requirements, VkMemoryPropertyFlags props,
VkImage image)
{
VkMemoryDedicatedAllocateInfo allocInfo;
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
allocInfo.pNext = nullptr;
allocInfo.buffer = VK_NULL_HANDLE;
allocInfo.image = image;
return allocate(requirements, props, &allocInfo);
}
private: void free(Allocation *allocation);
private:
enum enum
{ {
MemoryBlockSize = 64 * 1024 * 1024 // 64MB MemoryBlockSize = 64 * 1024 * 1024 // 64MB
}; };
struct HeapInfo struct HeapInfo
{ {
uint32 maxSize = 0; VkDeviceSize maxSize = 0;
Array<PAllocation> allocations; Array<PAllocation> allocations;
}; };
Array<HeapInfo> heaps; Array<HeapInfo> heaps;
VkResult findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint32* typeIndex); VkResult findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint8 *typeIndex);
PGraphics graphics; PGraphics graphics;
VkPhysicalDeviceMemoryProperties memProperties; VkPhysicalDeviceMemoryProperties memProperties;
}; };
DEFINE_REF(Allocator); DEFINE_REF(Allocator);
class StagingBuffer
{
public:
StagingBuffer();
~StagingBuffer();
void *getMappedPointer()
{
return allocation->getMappedPointer();
} }
} void flushMappedMemory()
{
allocation->flushMemory();
}
void invalidateMemory()
{
allocation->invalidateMemory();
}
VkBuffer getHandle() const
{
return buffer;
}
VkDeviceMemory getMemoryHandle() const
{
return allocation->getHandle();
}
VkDeviceSize getOffset() const
{
return allocation->getOffset();
}
private:
PSubAllocation allocation;
VkBuffer buffer;
uint8 bReadable;
friend class StagingManager;
};
DEFINE_REF(StagingBuffer);
class StagingManager
{
public:
StagingManager(PGraphics graphics, PAllocator allocator);
~StagingManager();
PStagingBuffer allocateStagingBuffer(uint32 size, VkBufferUsageFlags usageFlags = VK_BUFFER_USAGE_TRANSFER_SRC_BIT, bool bCPURead = false);
void releaseStagingBuffer(PStagingBuffer buffer);
void clearPending();
private:
PGraphics graphics;
PAllocator allocator;
Array<PStagingBuffer> freeBuffers;
Array<StagingBuffer *> activeBuffers;
};
DEFINE_REF(StagingManager);
} // namespace Vulkan
} // namespace Seele
+311 -10
View File
@@ -1,28 +1,329 @@
#include "VulkanGraphicsResources.h" #include "VulkanGraphicsResources.h"
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanGraphics.h"
#include "VulkanCommandBuffer.h"
#include "VulkanAllocator.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
QueueOwnedResource::QueueOwnedResource(PGraphics graphics, QueueType startQueueType) struct PendingBuffer
: graphics(graphics)
, currentOwner(startQueueType)
{ {
} PStagingBuffer stagingBuffer;
Gfx::QueueType prevQueue;
bool bWriteOnly;
};
QueueOwnedResource::~QueueOwnedResource() static Map<Buffer *, PendingBuffer> pendingBuffers;
{
}
Buffer::Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, QueueType queueType) Buffer::Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType)
: QueueOwnedResource(graphics, queueType) : QueueOwnedResource(graphics, queueType), currentBuffer(0), size(size)
{ {
if (usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT ||
usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT ||
usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT ||
usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)
{
numBuffers = 1;
}
else
{
numBuffers = Gfx::numFramesBuffered;
}
usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
usage |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
VkBufferCreateInfo info =
init::BufferCreateInfo(
usage,
size);
VkBufferMemoryRequirementsInfo2 bufferReqInfo;
bufferReqInfo.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2;
bufferReqInfo.pNext = nullptr;
VkMemoryDedicatedRequirements dedicatedRequirements;
dedicatedRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
dedicatedRequirements.pNext = nullptr;
VkMemoryRequirements2 memRequirements;
memRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
memRequirements.pNext = &dedicatedRequirements;
for (uint32 i = 0; i < numBuffers; ++i)
{
vkCreateBuffer(graphics->getDevice(), &info, nullptr, &buffers[i].buffer);
bufferReqInfo.buffer = buffers[i].buffer;
vkGetBufferMemoryRequirements2(graphics->getDevice(), &bufferReqInfo, &memRequirements);
buffers[i].allocation = graphics->getAllocator()->allocate(memRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, buffers[i].buffer);
vkBindBufferMemory(graphics->getDevice(), buffers[i].buffer, buffers[i].allocation->getHandle(), buffers[i].allocation->getOffset());
}
info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
} }
Buffer::~Buffer() Buffer::~Buffer()
{ {
for (uint32 i = 0; i < numBuffers; ++i)
{
vkDestroyBuffer(graphics->getDevice(), buffers[i].buffer, nullptr);
buffers[i].allocation = nullptr;
}
} }
void Buffer::executeOwnershipBarrier(QueueType newOwner) void Buffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
{
VkBufferMemoryBarrier barrier =
init::BufferMemoryBarrier();
PCommandBufferManager sourceManager = getCommands();
PCommandBufferManager dstManager = nullptr;
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
QueueFamilyMapping mapping = graphics->getFamilyMapping();
barrier.srcQueueFamilyIndex = mapping.getQueueTypeFamilyIndex(currentOwner);
barrier.dstQueueFamilyIndex = mapping.getQueueTypeFamilyIndex(newOwner);
assert(barrier.srcQueueFamilyIndex != barrier.dstQueueFamilyIndex);
if (currentOwner == Gfx::QueueType::TRANSFER || currentOwner == Gfx::QueueType::DEDICATED_TRANSFER)
{
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
}
else if (currentOwner == Gfx::QueueType::COMPUTE)
{
barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
srcStage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
}
else if (currentOwner == Gfx::QueueType::GRAPHICS)
{
barrier.srcAccessMask = getSourceAccessMask();
srcStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
}
if (newOwner == Gfx::QueueType::TRANSFER)
{
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstManager = graphics->getTransferCommands();
}
else if (newOwner == Gfx::QueueType::DEDICATED_TRANSFER)
{
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstManager = graphics->getDedicatedTransferCommands();
}
else if (newOwner == Gfx::QueueType::COMPUTE)
{
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
dstStage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
dstManager = graphics->getComputeCommands();
}
else if (newOwner == Gfx::QueueType::GRAPHICS)
{
barrier.dstAccessMask = getDestAccessMask();
dstStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
dstManager = graphics->getGraphicsCommands();
}
VkCommandBuffer srcCommand = sourceManager->getCommands()->getHandle();
VkCommandBuffer dstCommand = dstManager->getCommands()->getHandle();
VkBufferMemoryBarrier dynamicBarriers[Gfx::numFramesBuffered];
for (uint32_t i = 0; i < numBuffers; ++i)
{
dynamicBarriers[i] = barrier;
dynamicBarriers[i].buffer = buffers[i].buffer;
dynamicBarriers[i].offset = 0;
dynamicBarriers[i].size = buffers[i].allocation->getSize();
}
vkCmdPipelineBarrier(srcCommand, srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
vkCmdPipelineBarrier(dstCommand, srcStage, dstStage, 0, 0, nullptr, numBuffers, dynamicBarriers, 0, nullptr);
sourceManager->submitCommands();
cachedCmdBufferManager = dstManager;
}
void *Buffer::lock(bool bWriteOnly)
{
void *data = nullptr;
/*if (bVolatile)
{
if (lockMode == RLM_ReadOnly)
{
assert(0);
}
else
{
throw new std::logic_error("TODO implement volatile buffers");
//device->getRHIDevice()->getTemp
}
}*/
//assert(bStatic || bDynamic || bUAV);
PendingBuffer pending;
pending.bWriteOnly = bWriteOnly;
pending.prevQueue = currentOwner;
if (bWriteOnly)
{
transferOwnership(Gfx::QueueType::DEDICATED_TRANSFER);
PStagingBuffer stagingBuffer = graphics->getStagingManager()->allocateStagingBuffer(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
data = stagingBuffer->getMappedPointer();
pending.stagingBuffer = stagingBuffer;
}
else
{
PCmdBuffer current = getCommands()->getCommands();
getCommands()->submitCommands();
getCommands()->waitForCommands(current);
transferOwnership(Gfx::QueueType::DEDICATED_TRANSFER);
VkCommandBuffer handle = getCommands()->getCommands()->getHandle();
VkBufferMemoryBarrier barrier =
init::BufferMemoryBarrier();
barrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
barrier.buffer = buffers[currentBuffer].buffer;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.offset = 0;
barrier.size = size;
vkCmdPipelineBarrier(handle, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &barrier, 0, nullptr);
PStagingBuffer stagingBuffer = graphics->getStagingManager()->allocateStagingBuffer(size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true);
VkBufferCopy regions;
regions.size = size;
regions.srcOffset = 0;
regions.dstOffset = 0;
vkCmdCopyBuffer(handle, buffers[currentBuffer].buffer, stagingBuffer->getHandle(), 1, &regions);
getCommands()->submitCommands();
vkQueueWaitIdle(getCommands()->getQueue()->getHandle());
stagingBuffer->flushMappedMemory();
pending.stagingBuffer = stagingBuffer;
data = stagingBuffer->getMappedPointer();
}
pendingBuffers[this] = pending;
assert(data);
return data;
}
void Buffer::unlock()
{
auto found = pendingBuffers.find(this);
if (found != pendingBuffers.end())
{
PendingBuffer pending = found->value;
pending.stagingBuffer->flushMappedMemory();
pendingBuffers.erase(this);
if (pending.bWriteOnly)
{
PStagingBuffer stagingBuffer = pending.stagingBuffer;
PCmdBuffer cmdBuffer = getCommands()->getCommands();
VkCommandBuffer cmdHandle = cmdBuffer->getHandle();
VkBufferCopy region;
std::memset(&region, 0, sizeof(VkBufferCopy));
region.size = size;
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, &region);
graphics->getStagingManager()->releaseStagingBuffer(stagingBuffer);
}
transferOwnership(pending.prevQueue);
}
}
UniformBuffer::UniformBuffer(PGraphics graphics, const BulkResourceData &resourceData)
: Buffer(graphics, resourceData.size, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, resourceData.owner)
{
if (resourceData.data != nullptr)
{
void *data = lock();
std::memcpy(data, resourceData.data, resourceData.size);
unlock();
}
}
UniformBuffer::~UniformBuffer()
{ {
} }
VkAccessFlags UniformBuffer::getSourceAccessMask()
{
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags UniformBuffer::getDestAccessMask()
{
return VK_ACCESS_UNIFORM_READ_BIT;
}
StructuredBuffer::StructuredBuffer(PGraphics graphics, const BulkResourceData &resourceData)
: Buffer(graphics, resourceData.size, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, resourceData.owner)
{
if (resourceData.data != nullptr)
{
void *data = lock();
std::memcpy(data, resourceData.data, resourceData.size);
unlock();
}
}
StructuredBuffer::~StructuredBuffer()
{
}
VkAccessFlags StructuredBuffer::getSourceAccessMask()
{
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags StructuredBuffer::getDestAccessMask()
{
return VK_ACCESS_MEMORY_READ_BIT;
}
VertexBuffer::VertexBuffer(PGraphics graphics, const BulkResourceData &resourceData)
: Buffer(graphics, resourceData.size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, resourceData.owner)
{
if (resourceData.data != nullptr)
{
void *data = lock();
std::memcpy(data, resourceData.data, resourceData.size);
unlock();
}
}
VertexBuffer::~VertexBuffer()
{
}
VkAccessFlags VertexBuffer::getSourceAccessMask()
{
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags VertexBuffer::getDestAccessMask()
{
return VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
}
IndexBuffer::IndexBuffer(PGraphics graphics, const BulkResourceData &resourceData)
: Buffer(graphics, resourceData.size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, resourceData.owner)
{
if (resourceData.data != nullptr)
{
void *data = lock();
std::memcpy(data, resourceData.data, resourceData.size);
unlock();
}
}
IndexBuffer::~IndexBuffer()
{
}
VkAccessFlags IndexBuffer::getSourceAccessMask()
{
return VK_ACCESS_MEMORY_WRITE_BIT;
}
VkAccessFlags IndexBuffer::getDestAccessMask()
{
return VK_ACCESS_INDEX_READ_BIT;
}
@@ -9,34 +9,34 @@ using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
CmdBufferBase::CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool) CmdBufferBase::CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool)
: graphics(graphics) : graphics(graphics), owner(cmdPool)
, owner(cmdPool)
{ {
} }
CmdBufferBase::~CmdBufferBase() CmdBufferBase::~CmdBufferBase()
{ {
graphics = nullptr;
} }
CmdBuffer::CmdBuffer(PGraphics graphics, VkCommandPool cmdPool) CmdBuffer::CmdBuffer(PGraphics graphics, VkCommandPool cmdPool)
: CmdBufferBase(graphics, cmdPool) : CmdBufferBase(graphics, cmdPool), renderPass(nullptr), framebuffer(nullptr), subpassIndex(0)
, renderPass(nullptr)
, framebuffer(nullptr)
, subpassIndex(0)
{ {
VkCommandBufferAllocateInfo allocInfo = VkCommandBufferAllocateInfo allocInfo =
init::CommandBufferAllocateInfo(cmdPool, init::CommandBufferAllocateInfo(cmdPool,
VK_COMMAND_BUFFER_LEVEL_PRIMARY, VK_COMMAND_BUFFER_LEVEL_PRIMARY,
1); 1);
VK_CHECK(vkAllocateCommandBuffers(graphics->getDevice(), &allocInfo, &handle)) VK_CHECK(vkAllocateCommandBuffers(graphics->getDevice(), &allocInfo, &handle))
fence = new Fence(graphics);
state = State::ReadyBegin; state = State::ReadyBegin;
} }
CmdBuffer::~CmdBuffer() CmdBuffer::~CmdBuffer()
{ {
vkFreeCommandBuffers(graphics->getDevice(), owner, 1, &handle); vkFreeCommandBuffers(graphics->getDevice(), owner, 1, &handle);
renderPass = nullptr;
framebuffer = nullptr;
waitSemaphores.clear();
} }
void CmdBuffer::begin() void CmdBuffer::begin()
@@ -54,8 +54,11 @@ void CmdBuffer::end()
state = State::Ended; state = State::Ended;
} }
void CmdBuffer::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer) void CmdBuffer::beginRenderPass(PRenderPass newRenderPass, PFramebuffer newFramebuffer)
{ {
renderPass = newRenderPass;
framebuffer = newFramebuffer;
VkRenderPassBeginInfo beginInfo = VkRenderPassBeginInfo beginInfo =
init::RenderPassBeginInfo(); init::RenderPassBeginInfo();
beginInfo.clearValueCount = renderPass->getClearValueCount(); beginInfo.clearValueCount = renderPass->getClearValueCount();
@@ -64,11 +67,49 @@ void CmdBuffer::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer
beginInfo.renderPass = renderPass->getHandle(); beginInfo.renderPass = renderPass->getHandle();
beginInfo.framebuffer = framebuffer->getHandle(); beginInfo.framebuffer = framebuffer->getHandle();
vkCmdBeginRenderPass(handle, &beginInfo, renderPass->getSubpassContents()); vkCmdBeginRenderPass(handle, &beginInfo, renderPass->getSubpassContents());
state = State::RenderPassActive;
} }
void CmdBuffer::endRenderPass() void CmdBuffer::endRenderPass()
{ {
vkCmdEndRenderPass(handle); vkCmdEndRenderPass(handle);
state = State::InsideBegin;
}
void CmdBuffer::executeCommands(Array<PSecondaryCmdBuffer> commands)
{
assert(state == State::RenderPassActive);
Array<VkCommandBuffer> cmdBuffers(commands.size());
for (uint32 i = 0; i < commands.size(); ++i)
{
cmdBuffers[i] = commands[i]->getHandle();
}
vkCmdExecuteCommands(handle, cmdBuffers.size(), cmdBuffers.data());
}
void CmdBuffer::addWaitSemaphore(VkPipelineStageFlags flags, PSemaphore semaphore)
{
waitSemaphores.add(semaphore);
waitFlags.add(flags);
}
void CmdBuffer::refreshFence()
{
if (state == State::Submitted)
{
if (fence->isSignaled())
{
state = State::ReadyBegin;
vkResetCommandBuffer(handle, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
fence->reset();
}
}
else
{
assert(!fence->isSignaled());
}
} }
SecondaryCmdBuffer::SecondaryCmdBuffer(PGraphics graphics, VkCommandPool cmdPool) SecondaryCmdBuffer::SecondaryCmdBuffer(PGraphics graphics, VkCommandPool cmdPool)
@@ -105,8 +146,7 @@ void SecondaryCmdBuffer::end()
} }
CommandBufferManager::CommandBufferManager(PGraphics graphics, PQueue queue) CommandBufferManager::CommandBufferManager(PGraphics graphics, PQueue queue)
: graphics(graphics) : graphics(graphics), queue(queue)
, queue(queue)
{ {
VkCommandPoolCreateInfo info = VkCommandPoolCreateInfo info =
init::CommandPoolCreateInfo(); init::CommandPoolCreateInfo();
@@ -117,11 +157,14 @@ CommandBufferManager::CommandBufferManager(PGraphics graphics, PQueue queue)
activeCmdBuffer = new CmdBuffer(graphics, commandPool); activeCmdBuffer = new CmdBuffer(graphics, commandPool);
activeCmdBuffer->begin(); activeCmdBuffer->begin();
allocatedBuffers.add(activeCmdBuffer);
} }
CommandBufferManager::~CommandBufferManager() CommandBufferManager::~CommandBufferManager()
{ {
vkDestroyCommandPool(graphics->getDevice(), commandPool, nullptr); vkDestroyCommandPool(graphics->getDevice(), commandPool, nullptr);
graphics = nullptr;
queue = nullptr;
} }
PCmdBuffer CommandBufferManager::getCommands() PCmdBuffer CommandBufferManager::getCommands()
@@ -136,16 +179,15 @@ PSecondaryCmdBuffer CommandBufferManager::createSecondaryCmdBuffer()
void CommandBufferManager::submitCommands(PSemaphore signalSemaphore) void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
{ {
if(activeCmdBuffer->state == CmdBuffer::State::InsideBegin if (activeCmdBuffer->state == CmdBuffer::State::InsideBegin || activeCmdBuffer->state == CmdBuffer::State::RenderPassActive)
|| activeCmdBuffer->state == CmdBuffer::State::RenderPassActive)
{ {
if(!activeCmdBuffer->state == CmdBuffer::State::RenderPassActive) if (activeCmdBuffer->state == CmdBuffer::State::RenderPassActive)
{ {
std::cout << "End of renderpass forced" << std::endl; std::cout << "End of renderpass forced" << std::endl;
activeCmdBuffer->endRenderPass(); activeCmdBuffer->endRenderPass();
} }
activeCmdBuffer->end(); activeCmdBuffer->end();
if(signalSemaphore != nullptr) if (signalSemaphore != nullptr)
{ {
queue->submitCommandBuffer(activeCmdBuffer, signalSemaphore->getHandle()); queue->submitCommandBuffer(activeCmdBuffer, signalSemaphore->getHandle());
} }
@@ -154,11 +196,11 @@ void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
queue->submitCommandBuffer(activeCmdBuffer); queue->submitCommandBuffer(activeCmdBuffer);
} }
} }
for(int32_t i = 0; i < allocatedBuffers.size(); ++i) for (uint32 i = 0; i < allocatedBuffers.size(); ++i)
{ {
PCmdBuffer cmdBuffer = allocatedBuffers[i]; PCmdBuffer cmdBuffer = allocatedBuffers[i];
cmdBuffer->refreshFences(); cmdBuffer->refreshFence();
if(cmdBuffer->state == CmdBuffer::State::ReadyBegin) if (cmdBuffer->state == CmdBuffer::State::ReadyBegin)
{ {
activeCmdBuffer = cmdBuffer; activeCmdBuffer = cmdBuffer;
activeCmdBuffer->begin(); activeCmdBuffer->begin();
@@ -173,3 +215,9 @@ void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
allocatedBuffers.add(activeCmdBuffer); allocatedBuffers.add(activeCmdBuffer);
activeCmdBuffer->begin(); activeCmdBuffer->begin();
} }
void CommandBufferManager::waitForCommands(PCmdBuffer cmdBuffer, uint32 timeout)
{
cmdBuffer->fence->wait(timeout);
cmdBuffer->refreshFence();
}
@@ -4,13 +4,13 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(RenderPass); DECLARE_REF(RenderPass);
DECLARE_REF(Framebuffer); DECLARE_REF(Framebuffer);
class CmdBufferBase : public Gfx::RenderCommandBase class CmdBufferBase : public Gfx::RenderCommandBase
{ {
public: public:
CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool); CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool);
virtual ~CmdBufferBase(); virtual ~CmdBufferBase();
inline VkCommandBuffer getHandle() inline VkCommandBuffer getHandle()
@@ -20,17 +20,18 @@ namespace Seele
void reset(); void reset();
VkViewport currentViewport; VkViewport currentViewport;
VkRect2D currentScissor; VkRect2D currentScissor;
protected:
protected:
PGraphics graphics; PGraphics graphics;
VkCommandBuffer handle; VkCommandBuffer handle;
VkCommandPool owner; VkCommandPool owner;
}; };
DEFINE_REF(CmdBufferBase); DEFINE_REF(CmdBufferBase);
DECLARE_REF(SecondaryCmdBuffer); DECLARE_REF(SecondaryCmdBuffer);
class CmdBuffer : public CmdBufferBase class CmdBuffer : public CmdBufferBase
{ {
public: public:
CmdBuffer(PGraphics graphics, VkCommandPool cmdPool); CmdBuffer(PGraphics graphics, VkCommandPool cmdPool);
virtual ~CmdBuffer(); virtual ~CmdBuffer();
void begin(); void begin();
@@ -39,6 +40,7 @@ namespace Seele
void endRenderPass(); void endRenderPass();
void executeCommands(Array<PSecondaryCmdBuffer> secondaryCommands); void executeCommands(Array<PSecondaryCmdBuffer> secondaryCommands);
void addWaitSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore); void addWaitSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore);
void refreshFence();
enum State enum State
{ {
ReadyBegin, ReadyBegin,
@@ -48,44 +50,54 @@ namespace Seele
Submitted, Submitted,
}; };
private: private:
PRenderPass renderPass; PRenderPass renderPass;
PFramebuffer framebuffer; PFramebuffer framebuffer;
PFence fence;
uint32 subpassIndex; uint32 subpassIndex;
State state; State state;
Array<PSemaphore> waitSemaphores;
Array<VkPipelineStageFlags> waitFlags;
friend class SecondaryCmdBuffer; friend class SecondaryCmdBuffer;
friend class CommandBufferManager; friend class CommandBufferManager;
}; friend class Queue;
DEFINE_REF(CmdBuffer); };
DEFINE_REF(CmdBuffer);
class SecondaryCmdBuffer : public CmdBufferBase class SecondaryCmdBuffer : public CmdBufferBase
{ {
public: public:
SecondaryCmdBuffer(PGraphics graphics, VkCommandPool cmdPool); SecondaryCmdBuffer(PGraphics graphics, VkCommandPool cmdPool);
virtual ~SecondaryCmdBuffer(); virtual ~SecondaryCmdBuffer();
void begin(PCmdBuffer parent); void begin(PCmdBuffer parent);
void end(); void end();
private:
};
DEFINE_REF(SecondaryCmdBuffer);
class CommandBufferManager private:
{ };
public: DEFINE_REF(SecondaryCmdBuffer);
class CommandBufferManager
{
public:
CommandBufferManager(PGraphics graphics, PQueue queue); CommandBufferManager(PGraphics graphics, PQueue queue);
virtual ~CommandBufferManager(); virtual ~CommandBufferManager();
inline PQueue getQueue() const
{
return queue;
}
PCmdBuffer getCommands(); PCmdBuffer getCommands();
PSecondaryCmdBuffer createSecondaryCmdBuffer(); PSecondaryCmdBuffer createSecondaryCmdBuffer();
void submitCommands(PSemaphore signalSemaphore = nullptr); void submitCommands(PSemaphore signalSemaphore = nullptr);
void waitForCommands(PCmdBuffer cmdBuffer, float timeToWait = 1.0f); void waitForCommands(PCmdBuffer cmdBuffer, uint32 timeToWait = 1000000u);
private:
private:
PGraphics graphics; PGraphics graphics;
VkCommandPool commandPool; VkCommandPool commandPool;
PQueue queue; PQueue queue;
uint32 queueFamilyIndex; uint32 queueFamilyIndex;
PCmdBuffer activeCmdBuffer; PCmdBuffer activeCmdBuffer;
Array<PCmdBuffer> allocatedBuffers; Array<PCmdBuffer> allocatedBuffers;
}; };
DEFINE_REF(CommandBufferManager); DEFINE_REF(CommandBufferManager);
} } // namespace Vulkan
} } // namespace Seele
@@ -2,6 +2,7 @@
#include "VulkanGraphicsEnums.h" #include "VulkanGraphicsEnums.h"
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanDescriptorSets.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
@@ -23,8 +24,8 @@ void DescriptorLayout::create()
bindings.resize(descriptorBindings.size()); bindings.resize(descriptorBindings.size());
for (size_t i = 0; i < descriptorBindings.size(); ++i) for (size_t i = 0; i < descriptorBindings.size(); ++i)
{ {
VkDescriptorSetLayoutBinding& binding = bindings[i]; VkDescriptorSetLayoutBinding &binding = bindings[i];
const Gfx::DescriptorBinding& rhiBinding = descriptorBindings[i]; const Gfx::DescriptorBinding &rhiBinding = descriptorBindings[i];
binding.binding = rhiBinding.binding; binding.binding = rhiBinding.binding;
binding.descriptorCount = rhiBinding.descriptorCount; binding.descriptorCount = rhiBinding.descriptorCount;
binding.descriptorType = cast(rhiBinding.descriptorType); binding.descriptorType = cast(rhiBinding.descriptorType);
@@ -78,8 +79,8 @@ DescriptorSet::~DescriptorSet()
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
{ {
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>(); PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize()); // VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
// bufferInfos.add(bufferInfo); // bufferInfos.add(bufferInfo);
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back()); VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back());
writeDescriptors.add(writeDescriptor); writeDescriptors.add(writeDescriptor);
@@ -88,8 +89,8 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBu
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer) void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer)
{ {
PStructuredBuffer vulkanBuffer = uniformBuffer.cast<StructuredBuffer>(); PStructuredBuffer vulkanBuffer = uniformBuffer.cast<StructuredBuffer>();
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize()); // VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
// bufferInfos.add(bufferInfo); // bufferInfos.add(bufferInfo);
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, binding, &bufferInfos.back()); VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, binding, &bufferInfos.back());
writeDescriptors.add(writeDescriptor); writeDescriptors.add(writeDescriptor);
@@ -111,23 +112,23 @@ void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSamplerState samplerSt
void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSamplerState samplerState) void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSamplerState samplerState)
{ {
// VulkanTextureBase* vulkanTexture = VulkanTextureBase::cast(texture); PTextureHandle vulkanTexture = TextureBase::cast(texture);
//It is assumed that the image is in the correct layout //It is assumed that the image is in the correct layout
// VkDescriptorImageInfo imageInfo = VkDescriptorImageInfo imageInfo =
// init::DescriptorImageInfo( init::DescriptorImageInfo(
// VK_NULL_HANDLE, VK_NULL_HANDLE,
// vulkanTexture->defaultView.view, vulkanTexture->getView(),
// graphics->getRHIDevice().findLayout(vulkanTexture->surface.image)); vulkanTexture->getLayout());
if (samplerState != nullptr) if (samplerState != nullptr)
{ {
// PVulkanSamplerState vulkanSampler = samplerState.cast<VulkanSamplerState>(); PSamplerState vulkanSampler = samplerState.cast<SamplerState>();
// imageInfo.sampler = vulkanSampler->sampler; imageInfo.sampler = vulkanSampler->sampler;
} }
// imageInfos.add(imageInfo); imageInfos.add(imageInfo);
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, samplerState != nullptr ? VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, binding, &imageInfos.back()); VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, samplerState != nullptr ? VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, binding, &imageInfos.back());
// if (vulkanTexture->surface.usageFlags & TexCreate_UAV) if (vulkanTexture->getUsage() & VK_IMAGE_USAGE_STORAGE_BIT)
{ {
// writeDescriptor.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; writeDescriptor.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
} }
writeDescriptors.add(writeDescriptor); writeDescriptors.add(writeDescriptor);
} }
@@ -149,20 +150,19 @@ void DescriptorSet::writeChanges()
} }
} }
DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout& layout) DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout)
: layout(layout) : layout(layout), graphics(graphics)
, graphics(graphics)
{ {
uint32 perTypeSizes[VK_DESCRIPTOR_TYPE_END_RANGE]; uint32 perTypeSizes[VK_DESCRIPTOR_TYPE_END_RANGE];
std::memset(perTypeSizes, 0, sizeof(perTypeSizes)); std::memset(perTypeSizes, 0, sizeof(perTypeSizes));
for (int i = 0; i < layout.getBindings().size(); ++i) for (uint32 i = 0; i < layout.getBindings().size(); ++i)
{ {
auto& binding = layout.getBindings()[i]; auto &binding = layout.getBindings()[i];
int typeIndex = binding.descriptorType; int typeIndex = binding.descriptorType;
perTypeSizes[typeIndex] += 256; perTypeSizes[typeIndex] += 256;
} }
Array<VkDescriptorPoolSize> poolSizes; Array<VkDescriptorPoolSize> poolSizes;
for (int i = 0; i < VK_DESCRIPTOR_TYPE_END_RANGE; ++i) for (uint32 i = 0; i < VK_DESCRIPTOR_TYPE_END_RANGE; ++i)
{ {
if (perTypeSizes[i] > 0) if (perTypeSizes[i] > 0)
{ {
@@ -179,9 +179,10 @@ DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout& l
DescriptorAllocator::~DescriptorAllocator() DescriptorAllocator::~DescriptorAllocator()
{ {
vkDestroyDescriptorPool(graphics->getDevice(), poolHandle, nullptr); vkDestroyDescriptorPool(graphics->getDevice(), poolHandle, nullptr);
graphics = nullptr;
} }
void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet& descriptorSet) void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet &descriptorSet)
{ {
descriptorSet = new DescriptorSet(graphics, this); descriptorSet = new DescriptorSet(graphics, this);
PDescriptorSet vulkanSet = descriptorSet.cast<DescriptorSet>(); PDescriptorSet vulkanSet = descriptorSet.cast<DescriptorSet>();
@@ -0,0 +1,106 @@
#include "VulkanGraphicsResources.h"
namespace Seele
{
namespace Vulkan
{
DECLARE_REF(Graphics);
class DescriptorLayout : public Gfx::DescriptorLayout
{
public:
DescriptorLayout(PGraphics graphics)
: graphics(graphics), layoutHandle(VK_NULL_HANDLE)
{
}
virtual ~DescriptorLayout();
virtual void create();
inline VkDescriptorSetLayout getHandle() const
{
return layoutHandle;
}
private:
PGraphics graphics;
Array<VkDescriptorSetLayoutBinding> bindings;
VkDescriptorSetLayout layoutHandle;
friend class PipelineStateCacheManager;
};
DEFINE_REF(DescriptorLayout);
class PipelineLayout : public Gfx::PipelineLayout
{
public:
PipelineLayout(PGraphics graphics)
: graphics(graphics), layoutHash(0), layoutHandle(VK_NULL_HANDLE)
{
}
virtual ~PipelineLayout();
virtual void create();
inline VkPipelineLayout getHandle() const
{
return layoutHandle;
}
virtual uint32 getHash() const
{
return layoutHash;
}
private:
Array<VkDescriptorSetLayout> vulkanDescriptorLayouts;
uint32 layoutHash;
VkPipelineLayout layoutHandle;
PGraphics graphics;
friend class PipelineStateCacheManager;
};
DEFINE_REF(PipelineLayout);
class DescriptorSet : public Gfx::DescriptorSet
{
public:
DescriptorSet(PGraphics graphics, PDescriptorAllocator owner)
: graphics(graphics), owner(owner), setHandle(VK_NULL_HANDLE)
{
}
virtual ~DescriptorSet();
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
virtual void updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer);
virtual void updateSampler(uint32_t binding, Gfx::PSamplerState samplerState);
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSamplerState sampler = nullptr);
virtual bool operator<(Gfx::PDescriptorSet other);
inline VkDescriptorSet getHandle() const
{
return setHandle;
}
private:
virtual void writeChanges();
Array<VkDescriptorImageInfo> imageInfos;
Array<VkDescriptorBufferInfo> bufferInfos;
Array<VkWriteDescriptorSet> writeDescriptors;
VkDescriptorSet setHandle;
PDescriptorAllocator owner;
PGraphics graphics;
friend class DescriptorAllocator;
};
DEFINE_REF(DescriptorSet);
class DescriptorAllocator : public Gfx::DescriptorAllocator
{
public:
DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout);
virtual ~DescriptorAllocator();
virtual void allocateDescriptorSet(Gfx::PDescriptorSet &descriptorSet);
inline VkDescriptorPool getHandle()
{
return poolHandle;
}
private:
PGraphics graphics;
int maxSets = 512;
VkDescriptorPool poolHandle;
DescriptorLayout &layout;
};
DEFINE_REF(DescriptorAllocator);
} // namespace Vulkan
} // namespace Seele
@@ -12,23 +12,27 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
, layout(renderTargetLayout) , layout(renderTargetLayout)
, renderPass(renderPass) , renderPass(renderPass)
{ {
FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
Array<VkImageView> attachments; Array<VkImageView> attachments;
for(auto inputAttachment : layout->inputAttachments) for (auto inputAttachment : layout->inputAttachments)
{ {
PTexture2D vkInputAttachment = inputAttachment.cast<Texture2D>(); PTexture2D vkInputAttachment = inputAttachment->getTexture().cast<Texture2D>();
attachments.add(vkInputAttachment->getView()); attachments.add(vkInputAttachment->getView());
description.inputAttachments[description.numInputAttachments++] = vkInputAttachment->getView();
} }
for(auto colorAttachment : layout->colorAttachments) for (auto colorAttachment : layout->colorAttachments)
{ {
PTexture2D vkColorAttachment = colorAttachment.cast<Texture2D>(); PTexture2D vkColorAttachment = colorAttachment->getTexture().cast<Texture2D>();
attachments.add(vkColorAttachment->getView()); attachments.add(vkColorAttachment->getView());
description.colorAttachments[description.numColorAttachments++] = vkColorAttachment->getView();
} }
if(layout->depthAttachment != nullptr) if (layout->depthAttachment != nullptr)
{ {
PTexture2D vkDepthAttachment = layout->depthAttachment.cast<Texture2D>(); PTexture2D vkDepthAttachment = layout->depthAttachment->getTexture().cast<Texture2D>();
attachments.add(vkDepthAttachment->getView()); attachments.add(vkDepthAttachment->getView());
description.depthAttachment = vkDepthAttachment->getView();
} }
VkFramebufferCreateInfo createInfo = VkFramebufferCreateInfo createInfo =
init::FramebufferCreateInfo( init::FramebufferCreateInfo(
renderPass->getHandle(), renderPass->getHandle(),
@@ -36,9 +40,10 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
attachments.data(), attachments.data(),
renderPass->getRenderArea().extent.width, renderPass->getRenderArea().extent.width,
renderPass->getRenderArea().extent.height, renderPass->getRenderArea().extent.height,
1 1);
);
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle)); VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
hash = memCrc32(&description, sizeof(FramebufferDescription));
} }
Framebuffer::~Framebuffer() Framebuffer::~Framebuffer()
+24 -11
View File
@@ -3,24 +3,37 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(RenderPass); DECLARE_REF(RenderPass);
class Framebuffer struct FramebufferDescription
{ {
public: VkImageView inputAttachments[16];
VkImageView colorAttachments[16];
VkImageView depthAttachment;
uint32 numInputAttachments;
uint32 numColorAttachments;
};
class Framebuffer
{
public:
Framebuffer(PGraphics graphics, PRenderPass renderpass, Gfx::PRenderTargetLayout renderTargetLayout); Framebuffer(PGraphics graphics, PRenderPass renderpass, Gfx::PRenderTargetLayout renderTargetLayout);
virtual ~Framebuffer(); virtual ~Framebuffer();
inline VkFramebuffer getHandle() const inline VkFramebuffer getHandle() const
{ {
return handle; return handle;
} }
private: inline uint32 getHash() const
{
return hash;
}
private:
uint32 hash;
PGraphics graphics; PGraphics graphics;
VkFramebuffer handle; VkFramebuffer handle;
Gfx::PRenderTargetLayout layout; Gfx::PRenderTargetLayout layout;
PRenderPass renderPass; PRenderPass renderPass;
}; };
DEFINE_REF(Framebuffer); DEFINE_REF(Framebuffer);
} } // namespace Vulkan
} } // namespace Seele
+121 -29
View File
@@ -1,26 +1,33 @@
#include "Containers/Array.h"
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanAllocator.h" #include "VulkanAllocator.h"
#include "VulkanQueue.h" #include "VulkanQueue.h"
#include "Containers/Array.h"
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanCommandBuffer.h" #include "VulkanCommandBuffer.h"
#include <GLFW/glfw3.h> #include "VulkanRenderPass.h"
#include "VulkanFramebuffer.h"
#include "Graphics/GraphicsResources.h"
#include <glfw/glfw3.h>
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
Graphics::Graphics() Graphics::Graphics()
: callback(VK_NULL_HANDLE), handle(VK_NULL_HANDLE), instance(VK_NULL_HANDLE), physicalDevice(VK_NULL_HANDLE) : callback(VK_NULL_HANDLE), handle(VK_NULL_HANDLE), instance(VK_NULL_HANDLE), physicalDevice(VK_NULL_HANDLE)
{ {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
} }
Graphics::~Graphics() Graphics::~Graphics()
{ {
allocator = nullptr;
stagingManager = nullptr;
graphicsCommands = nullptr;
computeCommands = nullptr;
transferCommands = nullptr;
dedicatedTransferCommands = nullptr;
viewports.clear();
vkDestroyDevice(handle, nullptr); vkDestroyDevice(handle, nullptr);
DestroyDebugReportCallbackEXT(instance, nullptr, callback); DestroyDebugReportCallbackEXT(instance, nullptr, callback);
vkDestroyInstance(instance, nullptr); vkDestroyInstance(instance, nullptr);
glfwTerminate();
} }
void Graphics::init(GraphicsInitializer initInfo) void Graphics::init(GraphicsInitializer initInfo)
@@ -30,27 +37,86 @@ void Graphics::init(GraphicsInitializer initInfo)
pickPhysicalDevice(); pickPhysicalDevice();
createDevice(initInfo); createDevice(initInfo);
allocator = new Allocator(this); allocator = new Allocator(this);
stagingManager = new StagingManager(this, allocator);
graphicsCommands = new CommandBufferManager(this, graphicsQueue); graphicsCommands = new CommandBufferManager(this, graphicsQueue);
computeCommands = new CommandBufferManager(this, computeQueue); computeCommands = new CommandBufferManager(this, computeQueue);
transferCommands = new CommandBufferManager(this, transferQueue); transferCommands = new CommandBufferManager(this, transferQueue);
dedicatedTransferCommands = new CommandBufferManager(this, dedicatedTransferQueue); dedicatedTransferCommands = new CommandBufferManager(this, dedicatedTransferQueue);
} }
void Graphics::beginFrame(void *windowHandle) Gfx::PWindow Graphics::createWindow(const WindowCreateInfo &createInfo)
{ {
GLFWwindow *window = static_cast<GLFWwindow *>(windowHandle); PWindow result = new Window(this, createInfo);
glfwPollEvents(); return result;
} }
void Graphics::endFrame(void *windowHandle) Gfx::PViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreateInfo &viewportInfo)
{ {
GLFWwindow *window = static_cast<GLFWwindow *>(windowHandle); PViewport result = new Viewport(this, owner, viewportInfo);
viewports.add(result);
return result;
}
Gfx::PRenderPass Graphics::createRenderPass(Gfx::PRenderTargetLayout layout)
{
PRenderPass result = new RenderPass(this, layout);
return result;
}
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass)
{
PRenderPass rp = renderPass.cast<RenderPass>();
uint32 framebufferHash = rp->getFramebufferHash();
PFramebuffer framebuffer;
auto found = allocatedFramebuffers.find(framebufferHash);
if(found == allocatedFramebuffers.end())
{
framebuffer = new Framebuffer(this, rp, rp->getLayout());
}
else
{
framebuffer = found->value;
}
graphicsCommands->getCommands()->beginRenderPass(rp, framebuffer);
} }
void *Graphics::createWindow(const WindowCreateInfo &createInfo) void Graphics::endRenderPass()
{ {
GLFWwindow *window = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr); graphicsCommands->getCommands()->endRenderPass();
return window; }
Gfx::PTexture2D Graphics::createTexture2D(const TextureCreateInfo &createInfo)
{
PTexture2D result = new Texture2D(this, createInfo.width, createInfo.height, createInfo.bArray,
createInfo.bArray, createInfo.arrayLayers, createInfo.format,
createInfo.samples, createInfo.usage, createInfo.queueType);
return result;
}
Gfx::PUniformBuffer Graphics::createUniformBuffer(const BulkResourceData &bulkData)
{
PUniformBuffer uniformBuffer = new UniformBuffer(this, bulkData);
return uniformBuffer;
}
Gfx::PStructuredBuffer Graphics::createStructuredBuffer(const BulkResourceData &bulkData)
{
PStructuredBuffer structuredBuffer = new StructuredBuffer(this, bulkData);
return structuredBuffer;
}
Gfx::PVertexBuffer Graphics::createVertexBuffer(const BulkResourceData &bulkData)
{
PVertexBuffer vertexBuffer = new VertexBuffer(this, bulkData);
return vertexBuffer;
}
Gfx::PIndexBuffer Graphics::createIndexBuffer(const BulkResourceData &bulkData)
{
PIndexBuffer indexBuffer = new IndexBuffer(this, bulkData);
return indexBuffer;
}
VkInstance Graphics::getInstance() const
{
return instance;
} }
VkDevice Graphics::getDevice() const VkDevice Graphics::getDevice() const
@@ -84,6 +150,11 @@ PAllocator Graphics::getAllocator()
return allocator; return allocator;
} }
PStagingManager Graphics::getStagingManager()
{
return stagingManager;
}
Array<const char *> Graphics::getRequiredExtensions() Array<const char *> Graphics::getRequiredExtensions()
{ {
Array<const char *> extensions; Array<const char *> extensions;
@@ -143,13 +214,13 @@ void Graphics::pickPhysicalDevice()
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr); vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr);
Array<VkPhysicalDevice> physicalDevices(physicalDeviceCount); Array<VkPhysicalDevice> physicalDevices(physicalDeviceCount);
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data()); vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data());
VkPhysicalDevice bestDevice; VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
uint32 deviceRating = 0; uint32 deviceRating = 0;
for (auto physicalDevice : physicalDevices) for (auto dev : physicalDevices)
{ {
uint32 currentRating = 0; uint32 currentRating = 0;
vkGetPhysicalDeviceProperties(physicalDevice, &props); vkGetPhysicalDeviceProperties(dev, &props);
vkGetPhysicalDeviceFeatures(physicalDevice, &features); vkGetPhysicalDeviceFeatures(dev, &features);
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
{ {
currentRating += 100; currentRating += 100;
@@ -161,10 +232,12 @@ void Graphics::pickPhysicalDevice()
if (currentRating > deviceRating) if (currentRating > deviceRating)
{ {
deviceRating = currentRating; deviceRating = currentRating;
bestDevice = physicalDevice; bestDevice = dev;
} }
} }
this->physicalDevice = bestDevice; physicalDevice = bestDevice;
vkGetPhysicalDeviceProperties(physicalDevice, &props);
vkGetPhysicalDeviceFeatures(physicalDevice, &features);
} }
void Graphics::createDevice(GraphicsInitializer initializer) void Graphics::createDevice(GraphicsInitializer initializer)
@@ -180,11 +253,12 @@ void Graphics::createDevice(GraphicsInitializer initializer)
int32_t dedicatedTransferQueueFamilyIndex = -1; int32_t dedicatedTransferQueueFamilyIndex = -1;
int32_t computeQueueFamilyIndex = -1; int32_t computeQueueFamilyIndex = -1;
int32_t asyncComputeFamilyIndex = -1; int32_t asyncComputeFamilyIndex = -1;
for (int32_t familyIndex = 0; familyIndex < queueProperties.size(); ++familyIndex) uint32 numPriorities = 0;
for (uint32 familyIndex = 0; familyIndex < queueProperties.size(); ++familyIndex)
{ {
uint32 numQueuesForFamily = 0; uint32 numQueuesForFamily = 0;
VkQueueFamilyProperties currProps = queueProperties[familyIndex]; VkQueueFamilyProperties currProps = queueProperties[familyIndex];
bool bSparse = currProps.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT; // bool bSparse = currProps.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT;
currProps.queueFlags = currProps.queueFlags ^ VK_QUEUE_SPARSE_BINDING_BIT; currProps.queueFlags = currProps.queueFlags ^ VK_QUEUE_SPARSE_BINDING_BIT;
if ((currProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT) if ((currProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
{ {
@@ -204,7 +278,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
{ {
if (asyncComputeFamilyIndex == -1) if (asyncComputeFamilyIndex == -1)
{ {
if (familyIndex == graphicsQueueFamilyIndex) if (familyIndex == (uint32)graphicsQueueFamilyIndex)
{ {
if (currProps.queueCount > 1) if (currProps.queueCount > 1)
{ {
@@ -232,13 +306,27 @@ void Graphics::createDevice(GraphicsInitializer initializer)
numQueuesForFamily++; numQueuesForFamily++;
} }
} }
if(numQueuesForFamily > 0) if (numQueuesForFamily > 0)
{ {
VkDeviceQueueCreateInfo info = VkDeviceQueueCreateInfo info =
init::DeviceQueueCreateInfo(familyIndex, numQueuesForFamily); init::DeviceQueueCreateInfo(familyIndex, numQueuesForFamily);
numPriorities += numQueuesForFamily;
queueInfos.add(info); queueInfos.add(info);
} }
} }
Array<float> queuePriorities;
queuePriorities.resize(numPriorities);
float *currentPriority = queuePriorities.data();
for (uint32 index = 0; index < queueInfos.size(); ++index)
{
VkDeviceQueueCreateInfo &currQueue = queueInfos[index];
currQueue.pQueuePriorities = currentPriority;
for (int32_t queueIndex = 0; queueIndex < (int32_t)currQueue.queueCount; ++queueIndex)
{
*currentPriority++ = 1.0f;
}
}
VkDeviceCreateInfo deviceInfo = init::DeviceCreateInfo( VkDeviceCreateInfo deviceInfo = init::DeviceCreateInfo(
queueInfos.data(), queueInfos.data(),
(uint32)queueInfos.size(), (uint32)queueInfos.size(),
@@ -250,28 +338,32 @@ void Graphics::createDevice(GraphicsInitializer initializer)
VK_CHECK(vkCreateDevice(physicalDevice, &deviceInfo, nullptr, &handle)); VK_CHECK(vkCreateDevice(physicalDevice, &deviceInfo, nullptr, &handle));
graphicsQueue = new Queue(this, QueueType::GRAPHICS, graphicsQueueFamilyIndex, 0); graphicsQueue = new Queue(this, Gfx::QueueType::GRAPHICS, graphicsQueueFamilyIndex, 0);
if (Gfx::useAsyncCompute && asyncComputeFamilyIndex != -1) if (Gfx::useAsyncCompute && asyncComputeFamilyIndex != -1)
{ {
if (asyncComputeFamilyIndex == graphicsQueueFamilyIndex) if (asyncComputeFamilyIndex == graphicsQueueFamilyIndex)
{ {
// Same family as graphics, but different queue // Same family as graphics, but different queue
computeQueue = new Queue(this, QueueType::COMPUTE, asyncComputeFamilyIndex, 1); computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeFamilyIndex, 1);
} }
else else
{ {
// Different family // Different family
computeQueue = new Queue(this, QueueType::COMPUTE, asyncComputeFamilyIndex, 0); computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeFamilyIndex, 0);
} }
} }
else else
{ {
computeQueue = new Queue(this, QueueType::COMPUTE, computeQueueFamilyIndex, 0); computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, computeQueueFamilyIndex, 0);
} }
transferQueue = new Queue(this, QueueType::TRANSFER, transferQueueFamilyIndex, 0); transferQueue = new Queue(this, Gfx::QueueType::TRANSFER, transferQueueFamilyIndex, 0);
if (dedicatedTransferQueueFamilyIndex != -1) if (dedicatedTransferQueueFamilyIndex != -1)
{ {
dedicatedTransferQueue = new Queue(this, QueueType::DEDICATED_TRANSFER, dedicatedTransferQueueFamilyIndex, 0); dedicatedTransferQueue = new Queue(this, Gfx::QueueType::DEDICATED_TRANSFER, dedicatedTransferQueueFamilyIndex, 0);
}
else
{
dedicatedTransferQueue = transferQueue;
} }
queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex(); queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex();
queueMapping.computeFamily = computeQueue->getFamilyIndex(); queueMapping.computeFamily = computeQueue->getFamilyIndex();
+39 -18
View File
@@ -1,19 +1,22 @@
#pragma once #pragma once
#include "Graphics/Graphics.h"
#include "VulkanGraphicsResources.h" #include "VulkanGraphicsResources.h"
#include "Graphics/Graphics.h"
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(Allocator); DECLARE_REF(Allocator);
DECLARE_REF(CommandBufferManager); DECLARE_REF(StagingManager);
DECLARE_REF(Queue); DECLARE_REF(CommandBufferManager);
class Graphics : public Gfx::Graphics DECLARE_REF(Queue);
{ DECLARE_REF(Framebuffer);
public: class Graphics : public Gfx::Graphics
{
public:
Graphics(); Graphics();
virtual ~Graphics(); virtual ~Graphics();
VkInstance getInstance() const;
VkDevice getDevice() const; VkDevice getDevice() const;
VkPhysicalDevice getPhysicalDevice() const; VkPhysicalDevice getPhysicalDevice() const;
@@ -22,15 +25,31 @@ namespace Seele
PCommandBufferManager getTransferCommands(); PCommandBufferManager getTransferCommands();
PCommandBufferManager getDedicatedTransferCommands(); PCommandBufferManager getDedicatedTransferCommands();
const QueueFamilyMapping getFamilyMapping() const
{
return queueMapping;
}
PAllocator getAllocator(); PAllocator getAllocator();
PStagingManager getStagingManager();
// Inherited via Graphics // Inherited via Graphics
virtual void init(GraphicsInitializer initializer) override; virtual void init(GraphicsInitializer initializer) override;
virtual void beginFrame(void* windowHandle) override; virtual Gfx::PWindow createWindow(const WindowCreateInfo &createInfo) override;
virtual void endFrame(void* windowHandle) override; virtual Gfx::PViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo &createInfo) override;
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
protected: virtual Gfx::PRenderPass createRenderPass(Gfx::PRenderTargetLayout layout) override;
Array<const char*> getRequiredExtensions(); virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
virtual void endRenderPass() override;
virtual Gfx::PTexture2D createTexture2D(const TextureCreateInfo &createInfo) override;
virtual Gfx::PUniformBuffer createUniformBuffer(const BulkResourceData &bulkData) override;
virtual Gfx::PStructuredBuffer createStructuredBuffer(const BulkResourceData &bulkData) override;
virtual Gfx::PVertexBuffer createVertexBuffer(const BulkResourceData &bulkData) override;
virtual Gfx::PIndexBuffer createIndexBuffer(const BulkResourceData &bulkData) override;
protected:
Array<const char *> getRequiredExtensions();
void initInstance(GraphicsInitializer initInfo); void initInstance(GraphicsInitializer initInfo);
void setupDebugCallback(); void setupDebugCallback();
void pickPhysicalDevice(); void pickPhysicalDevice();
@@ -53,10 +72,12 @@ namespace Seele
VkPhysicalDeviceFeatures features; VkPhysicalDeviceFeatures features;
VkDebugReportCallbackEXT callback; VkDebugReportCallbackEXT callback;
Array<PViewport> viewports; Array<PViewport> viewports;
Map<uint32, PFramebuffer> allocatedFramebuffers;
PAllocator allocator; PAllocator allocator;
PStagingManager stagingManager;
friend class Window; friend class Window;
}; };
DEFINE_REF(Graphics); DEFINE_REF(Graphics);
} } // namespace Vulkan
} } // namespace Seele
@@ -3,7 +3,7 @@
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
using namespace Seele::Gfx; using namespace Seele::Gfx;
VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType& descriptorType) VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType &descriptorType)
{ {
switch (descriptorType) switch (descriptorType)
{ {
@@ -41,7 +41,7 @@ VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType& descrip
return VK_DESCRIPTOR_TYPE_MAX_ENUM; return VK_DESCRIPTOR_TYPE_MAX_ENUM;
} }
Seele::Gfx::SeDescriptorType Seele::Vulkan::cast(const VkDescriptorType& descriptorType) Seele::Gfx::SeDescriptorType Seele::Vulkan::cast(const VkDescriptorType &descriptorType)
{ {
switch (descriptorType) switch (descriptorType)
{ {
@@ -80,7 +80,7 @@ Seele::Gfx::SeDescriptorType Seele::Vulkan::cast(const VkDescriptorType& descrip
return SE_DESCRIPTOR_TYPE_MAX_ENUM; return SE_DESCRIPTOR_TYPE_MAX_ENUM;
} }
VkShaderStageFlagBits Seele::Vulkan::cast(const Seele::Gfx::SeShaderStageFlagBits& stage) VkShaderStageFlagBits Seele::Vulkan::cast(const Seele::Gfx::SeShaderStageFlagBits &stage)
{ {
switch (stage) switch (stage)
{ {
@@ -125,7 +125,7 @@ VkShaderStageFlagBits Seele::Vulkan::cast(const Seele::Gfx::SeShaderStageFlagBit
return VK_SHADER_STAGE_ALL; return VK_SHADER_STAGE_ALL;
} }
Seele::Gfx::SeShaderStageFlagBits Seele::Vulkan::cast(const VkShaderStageFlagBits& stage) Seele::Gfx::SeShaderStageFlagBits Seele::Vulkan::cast(const VkShaderStageFlagBits &stage)
{ {
switch (stage) switch (stage)
{ {
@@ -169,7 +169,7 @@ Seele::Gfx::SeShaderStageFlagBits Seele::Vulkan::cast(const VkShaderStageFlagBit
return SE_SHADER_STAGE_ALL; return SE_SHADER_STAGE_ALL;
} }
VkFormat Seele::Vulkan::cast(const Seele::Gfx::SeFormat& format) VkFormat Seele::Vulkan::cast(const Seele::Gfx::SeFormat &format)
{ {
switch (format) switch (format)
{ {
@@ -631,7 +631,7 @@ VkFormat Seele::Vulkan::cast(const Seele::Gfx::SeFormat& format)
return VK_FORMAT_MAX_ENUM; return VK_FORMAT_MAX_ENUM;
} }
} }
Seele::Gfx::SeFormat Seele::Vulkan::cast(const VkFormat& format) Seele::Gfx::SeFormat Seele::Vulkan::cast(const VkFormat &format)
{ {
switch (format) switch (format)
{ {
@@ -1093,3 +1093,55 @@ Seele::Gfx::SeFormat Seele::Vulkan::cast(const VkFormat& format)
return SE_FORMAT_MAX_ENUM; return SE_FORMAT_MAX_ENUM;
} }
} }
VkAttachmentStoreOp Seele::Vulkan::cast(const Gfx::SeAttachmentStoreOp &storeOp)
{
switch (storeOp)
{
case SE_ATTACHMENT_STORE_OP_STORE:
return VK_ATTACHMENT_STORE_OP_STORE;
case SE_ATTACHMENT_STORE_OP_DONT_CARE:
return VK_ATTACHMENT_STORE_OP_DONT_CARE;
default:
return VK_ATTACHMENT_STORE_OP_MAX_ENUM;
}
}
Gfx::SeAttachmentStoreOp Seele::Vulkan::cast(const VkAttachmentStoreOp &storeOp)
{
switch (storeOp)
{
case VK_ATTACHMENT_STORE_OP_STORE:
return SE_ATTACHMENT_STORE_OP_STORE;
case VK_ATTACHMENT_STORE_OP_DONT_CARE:
return SE_ATTACHMENT_STORE_OP_DONT_CARE;
default:
return SE_ATTACHMENT_STORE_OP_MAX_ENUM;
}
}
VkAttachmentLoadOp Seele::Vulkan::cast(const Gfx::SeAttachmentLoadOp &loadOp)
{
switch (loadOp)
{
case SE_ATTACHMENT_LOAD_OP_LOAD:
return VK_ATTACHMENT_LOAD_OP_LOAD;
case SE_ATTACHMENT_LOAD_OP_CLEAR:
return VK_ATTACHMENT_LOAD_OP_CLEAR;
case SE_ATTACHMENT_LOAD_OP_DONT_CARE:
return VK_ATTACHMENT_LOAD_OP_DONT_CARE;
default:
return VK_ATTACHMENT_LOAD_OP_MAX_ENUM;
}
}
Gfx::SeAttachmentLoadOp Seele::Vulkan::cast(const VkAttachmentLoadOp &loadOp)
{
switch (loadOp)
{
case VK_ATTACHMENT_LOAD_OP_LOAD:
return SE_ATTACHMENT_LOAD_OP_LOAD;
case VK_ATTACHMENT_LOAD_OP_CLEAR:
return SE_ATTACHMENT_LOAD_OP_CLEAR;
case VK_ATTACHMENT_LOAD_OP_DONT_CARE:
return SE_ATTACHMENT_LOAD_OP_DONT_CARE;
default:
return SE_ATTACHMENT_LOAD_OP_MAX_ENUM;
}
}
@@ -3,24 +3,28 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#define VK_CHECK(f) \ #define VK_CHECK(f) \
{ \ { \
VkResult res = (f); \ VkResult res = (f); \
if (res != VK_SUCCESS) \ if (res != VK_SUCCESS) \
{ \ { \
std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \ std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \
assert(res == VK_SUCCESS); \ assert(res == VK_SUCCESS); \
} \ } \
} }
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
VkDescriptorType cast(const Gfx::SeDescriptorType& descriptorType); VkDescriptorType cast(const Gfx::SeDescriptorType &descriptorType);
Gfx::SeDescriptorType cast(const VkDescriptorType& descriptorType); Gfx::SeDescriptorType cast(const VkDescriptorType &descriptorType);
VkShaderStageFlagBits cast(const Gfx::SeShaderStageFlagBits& stage); VkShaderStageFlagBits cast(const Gfx::SeShaderStageFlagBits &stage);
Gfx::SeShaderStageFlagBits cast(const VkShaderStageFlagBits& stage); Gfx::SeShaderStageFlagBits cast(const VkShaderStageFlagBits &stage);
VkFormat cast(const Gfx::SeFormat& format); VkFormat cast(const Gfx::SeFormat &format);
Gfx::SeFormat cast(const VkFormat& format); Gfx::SeFormat cast(const VkFormat &format);
} VkAttachmentStoreOp cast(const Gfx::SeAttachmentStoreOp &storeOp);
} Gfx::SeAttachmentStoreOp cast(const VkAttachmentStoreOp &storeOp);
VkAttachmentLoadOp cast(const Gfx::SeAttachmentLoadOp &loadOp);
Gfx::SeAttachmentLoadOp cast(const VkAttachmentLoadOp &loadOp);
} // namespace Vulkan
} // namespace Seele
@@ -2,10 +2,52 @@
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanGraphicsEnums.h" #include "VulkanGraphicsEnums.h"
#include "VulkanCommandBuffer.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
QueueOwnedResource::QueueOwnedResource(PGraphics graphics, Gfx::QueueType startQueueType)
: graphics(graphics), currentOwner(startQueueType)
{
}
QueueOwnedResource::~QueueOwnedResource()
{
cachedCmdBufferManager = nullptr;
graphics = nullptr;
}
void QueueOwnedResource::transferOwnership(Gfx::QueueType newOwner)
{
if (graphics->getFamilyMapping().needsTransfer(currentOwner, newOwner))
{
executeOwnershipBarrier(newOwner);
currentOwner = newOwner;
}
}
PCommandBufferManager QueueOwnedResource::getCommands()
{
if (cachedCmdBufferManager != nullptr)
{
assert(cachedCmdBufferManager->getQueue()->getFamilyIndex() == graphics->getFamilyMapping().getQueueTypeFamilyIndex(currentOwner));
return cachedCmdBufferManager;
}
switch (currentOwner)
{
case Gfx::QueueType::GRAPHICS:
return graphics->getGraphicsCommands();
case Gfx::QueueType::COMPUTE:
return graphics->getComputeCommands();
case Gfx::QueueType::TRANSFER:
return graphics->getTransferCommands();
case Gfx::QueueType::DEDICATED_TRANSFER:
return graphics->getDedicatedTransferCommands();
}
return nullptr;
}
Semaphore::Semaphore(PGraphics graphics) Semaphore::Semaphore(PGraphics graphics)
: graphics(graphics) : graphics(graphics)
{ {
@@ -16,5 +58,65 @@ Semaphore::Semaphore(PGraphics graphics)
Semaphore::~Semaphore() Semaphore::~Semaphore()
{ {
graphics = nullptr;
vkDestroySemaphore(graphics->getDevice(), handle, nullptr); vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
} }
Fence::Fence(PGraphics graphics)
: graphics(graphics), signaled(false)
{
VkFenceCreateInfo info =
init::FenceCreateInfo(0);
VK_CHECK(vkCreateFence(graphics->getDevice(), &info, nullptr, &fence));
}
Fence::~Fence()
{
vkDestroyFence(graphics->getDevice(), fence, nullptr);
}
bool Fence::isSignaled()
{
if (signaled)
{
return true;
}
VkResult res = vkGetFenceStatus(graphics->getDevice(), fence);
switch (res)
{
case VK_SUCCESS:
signaled = true;
return true;
case VK_NOT_READY:
break;
default:
break;
}
return false;
}
void Fence::reset()
{
if (signaled)
{
vkResetFences(graphics->getDevice(), 1, &fence);
signaled = false;
}
}
void Fence::wait(uint32 timeout)
{
VkFence fences[] = {fence};
VkResult r = vkWaitForFences(graphics->getDevice(), 1, fences, true, timeout * 1000ull);
switch (r)
{
case VK_SUCCESS:
signaled = true;
break;
case VK_TIMEOUT:
break;
default:
VK_CHECK(r);
break;
}
}
@@ -10,6 +10,7 @@ namespace Vulkan
DECLARE_REF(DescriptorAllocator); DECLARE_REF(DescriptorAllocator);
DECLARE_REF(CommandBufferManager); DECLARE_REF(CommandBufferManager);
DECLARE_REF(Graphics); DECLARE_REF(Graphics);
DECLARE_REF(SubAllocation);
class Semaphore class Semaphore
{ {
public: public:
@@ -19,116 +20,32 @@ public:
{ {
return handle; return handle;
} }
private: private:
VkSemaphore handle; VkSemaphore handle;
PGraphics graphics; PGraphics graphics;
}; };
DEFINE_REF(Semaphore); DEFINE_REF(Semaphore);
class DescriptorLayout : public Gfx::DescriptorLayout class Fence
{ {
public: public:
DescriptorLayout(PGraphics graphics) Fence(PGraphics graphics);
: graphics(graphics), layoutHandle(VK_NULL_HANDLE) ~Fence();
bool isSignaled();
void reset();
inline VkFence getHandle() const
{ {
return fence;
} }
virtual ~DescriptorLayout(); void wait(uint32 timeout);
virtual void create();
inline VkDescriptorSetLayout getHandle() const
{
return layoutHandle;
}
private: private:
bool signaled;
VkFence fence;
PGraphics graphics; PGraphics graphics;
Array<VkDescriptorSetLayoutBinding> bindings;
VkDescriptorSetLayout layoutHandle;
friend class PipelineStateCacheManager;
};
DEFINE_REF(DescriptorLayout);
class PipelineLayout : public Gfx::PipelineLayout
{
public:
PipelineLayout(PGraphics graphics)
: graphics(graphics), layoutHash(0), layoutHandle(VK_NULL_HANDLE)
{
}
virtual ~PipelineLayout();
virtual void create();
inline VkPipelineLayout getHandle() const
{
return layoutHandle;
}
virtual uint32 getHash() const
{
return layoutHash;
}
private:
Array<VkDescriptorSetLayout> vulkanDescriptorLayouts;
uint32 layoutHash;
VkPipelineLayout layoutHandle;
PGraphics graphics;
friend class PipelineStateCacheManager;
};
DEFINE_REF(PipelineLayout);
class DescriptorSet : public Gfx::DescriptorSet
{
public:
DescriptorSet(PGraphics graphics, PDescriptorAllocator owner)
: graphics(graphics), owner(owner), setHandle(VK_NULL_HANDLE)
{
}
virtual ~DescriptorSet();
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
virtual void updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer);
virtual void updateSampler(uint32_t binding, Gfx::PSamplerState samplerState);
virtual void updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSamplerState sampler = nullptr);
virtual bool operator<(Gfx::PDescriptorSet other);
inline VkDescriptorSet getHandle() const
{
return setHandle;
}
private:
virtual void writeChanges();
Array<VkDescriptorImageInfo> imageInfos;
Array<VkDescriptorBufferInfo> bufferInfos;
Array<VkWriteDescriptorSet> writeDescriptors;
VkDescriptorSet setHandle;
PDescriptorAllocator owner;
PGraphics graphics;
friend class DescriptorAllocator;
};
DEFINE_REF(DescriptorSet);
class DescriptorAllocator : public Gfx::DescriptorAllocator
{
public:
DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout);
~DescriptorAllocator();
virtual void allocateDescriptorSet(Gfx::PDescriptorSet &descriptorSet);
inline VkDescriptorPool getHandle()
{
return poolHandle;
}
private:
PGraphics graphics;
int maxSets = 512;
VkDescriptorPool poolHandle;
DescriptorLayout &layout;
};
DEFINE_REF(DescriptorAllocator);
enum class QueueType
{
GRAPHICS = 1,
COMPUTE = 2,
TRANSFER = 3,
DEDICATED_TRANSFER = 4
}; };
DEFINE_REF(Fence);
struct QueueFamilyMapping struct QueueFamilyMapping
{ {
@@ -136,23 +53,23 @@ struct QueueFamilyMapping
uint32 computeFamily; uint32 computeFamily;
uint32 transferFamily; uint32 transferFamily;
uint32 dedicatedTransferFamily; uint32 dedicatedTransferFamily;
uint32 getQueueTypeFamilyIndex(QueueType type) uint32 getQueueTypeFamilyIndex(Gfx::QueueType type) const
{ {
switch (type) switch (type)
{ {
case QueueType::GRAPHICS: case Gfx::QueueType::GRAPHICS:
return graphicsFamily; return graphicsFamily;
case QueueType::COMPUTE: case Gfx::QueueType::COMPUTE:
return computeFamily; return computeFamily;
case QueueType::TRANSFER: case Gfx::QueueType::TRANSFER:
return transferFamily; return transferFamily;
case QueueType::DEDICATED_TRANSFER: case Gfx::QueueType::DEDICATED_TRANSFER:
return dedicatedTransferFamily; return dedicatedTransferFamily;
default: default:
return VK_QUEUE_FAMILY_IGNORED; return VK_QUEUE_FAMILY_IGNORED;
} }
} }
bool needsTransfer(QueueType src, QueueType dst) bool needsTransfer(Gfx::QueueType src, Gfx::QueueType dst) const
{ {
uint32 srcIndex = getQueueTypeFamilyIndex(src); uint32 srcIndex = getQueueTypeFamilyIndex(src);
uint32 dstIndex = getQueueTypeFamilyIndex(dst); uint32 dstIndex = getQueueTypeFamilyIndex(dst);
@@ -162,71 +79,179 @@ struct QueueFamilyMapping
class QueueOwnedResource class QueueOwnedResource
{ {
public: public:
QueueOwnedResource(PGraphics graphics, QueueType startQueueType); QueueOwnedResource(PGraphics graphics, Gfx::QueueType startQueueType);
~QueueOwnedResource(); virtual ~QueueOwnedResource();
PCommandBufferManager getCommands(); PCommandBufferManager getCommands();
//Preliminary checks to see if the barrier should be executed at all //Preliminary checks to see if the barrier should be executed at all
void transferOwnership(QueueType newOwner); void transferOwnership(Gfx::QueueType newOwner);
protected: protected:
virtual void executeOwnershipBarrier(QueueType newOwner) = 0; virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) = 0;
QueueType currentOwner; Gfx::QueueType currentOwner;
PGraphics graphics; PGraphics graphics;
CommandBufferManager *cachedCmdBufferManager; PCommandBufferManager cachedCmdBufferManager;
}; };
DEFINE_REF(QueueOwnedResource); DEFINE_REF(QueueOwnedResource);
class Buffer : public QueueOwnedResource class Buffer : public QueueOwnedResource
{ {
public: public:
Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, QueueType queueType = QueueType::GRAPHICS); Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType);
virtual ~Buffer(); virtual ~Buffer();
VkBuffer getHandle() const
{
return buffers[currentBuffer].buffer;
}
void advanceBuffer()
{
currentBuffer = (currentBuffer + 1) % numBuffers;
}
void *lock(bool bWriteOnly = true);
void unlock();
protected:
struct BufferAllocation
{
VkBuffer buffer;
PSubAllocation allocation;
};
BufferAllocation buffers[Gfx::numFramesBuffered];
uint32 numBuffers;
uint32 currentBuffer;
uint32 size;
private:
virtual VkAccessFlags getSourceAccessMask() = 0; virtual VkAccessFlags getSourceAccessMask() = 0;
virtual VkAccessFlags getDestAccessMask() = 0; virtual VkAccessFlags getDestAccessMask() = 0;
// Inherited via QueueOwnedResource // Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(QueueType newOwner); virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
}; };
DEFINE_REF(Buffer); DEFINE_REF(Buffer);
class UniformBuffer : public Buffer, public Gfx::UniformBuffer class UniformBuffer : public Buffer, public Gfx::UniformBuffer
{ {
public:
UniformBuffer(PGraphics graphics, const BulkResourceData &resourceData);
virtual ~UniformBuffer();
protected:
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
}; };
DEFINE_REF(UniformBuffer); DEFINE_REF(UniformBuffer);
class StructuredBuffer : public Buffer, public Gfx::StructuredBuffer class StructuredBuffer : public Buffer, public Gfx::StructuredBuffer
{ {
public:
StructuredBuffer(PGraphics graphics, const BulkResourceData &resourceData);
virtual ~StructuredBuffer();
protected:
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
}; };
DEFINE_REF(StructuredBuffer); DEFINE_REF(StructuredBuffer);
class TextureBase class VertexBuffer : public Buffer, public Gfx::VertexBuffer
{ {
public: public:
TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ, VertexBuffer(PGraphics graphics, const BulkResourceData &resourceData);
bool bArray, uint32 arraySize, uint32 mipLevels, Gfx::SeFormat format, virtual ~VertexBuffer();
uint32 samples, Gfx::SeImageUsageFlags usage);
virtual ~TextureBase();
protected:
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
};
DEFINE_REF(VertexBuffer);
class IndexBuffer : public Buffer, public Gfx::IndexBuffer
{
public:
IndexBuffer(PGraphics graphics, const BulkResourceData &resourceData);
virtual ~IndexBuffer();
protected:
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
};
DEFINE_REF(IndexBuffer);
class TextureHandle : public QueueOwnedResource
{
public:
TextureHandle(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ,
bool bArray, uint32 arraySize, uint32 mipLevels, Gfx::SeFormat format,
uint32 samples, Gfx::SeImageUsageFlags usage, Gfx::QueueType owner = Gfx::QueueType::GRAPHICS, VkImage existingImage = VK_NULL_HANDLE);
virtual ~TextureHandle();
inline VkImageView getView() const
{
return defaultView;
}
inline VkImageLayout getLayout() const
{
return layout;
}
inline VkImageAspectFlags getAspect() const
{
return aspect;
}
inline VkImageUsageFlags getUsage() const
{
return usage;
}
inline Gfx::SeFormat getFormat() const
{
return format;
}
inline bool isDepthStencil() const
{
return aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
}
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
private:
PGraphics graphics; PGraphics graphics;
PSubAllocation allocation;
uint32 sizeX; uint32 sizeX;
uint32 sizeY; uint32 sizeY;
uint32 sizeZ; uint32 sizeZ;
uint32 arrayCount; uint32 arrayCount;
uint32 mipLevels; uint32 mipLevels;
uint32 samples;
Gfx::SeFormat format; Gfx::SeFormat format;
Gfx::SeImageUsageFlags usage;
VkImage image; VkImage image;
VkImageView defaultView; VkImageView defaultView;
VkImageAspectFlags aspect; VkImageAspectFlags aspect;
VkImageLayout layout;
friend class TextureBase;
friend class Texture2D;
};
DEFINE_REF(TextureHandle);
DECLARE_REF(TextureBase);
class TextureBase
{
public:
static PTextureHandle cast(Gfx::PTexture texture)
{
PTextureBase base = texture.cast<TextureBase>();
return base->textureHandle;
}
void changeLayout(VkImageLayout newLayout);
protected:
PTextureHandle textureHandle;
}; };
DEFINE_REF(TextureBase); DEFINE_REF(TextureBase);
class Texture2D : public Gfx::Texture2D class Texture2D : public TextureBase, public Gfx::Texture2D
{ {
public: public:
Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY, Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY,
bool bArray, uint32 arraySize, uint32 mipLevels, bool bArray, uint32 arraySize, uint32 mipLevels, Gfx::SeFormat format,
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage); uint32 samples, Gfx::SeImageUsageFlags usage, Gfx::QueueType owner = Gfx::QueueType::GRAPHICS, VkImage existingImage = VK_NULL_HANDLE);
virtual ~Texture2D(); virtual ~Texture2D();
inline uint32 getSizeX() const inline uint32 getSizeX() const
{ {
@@ -248,8 +273,12 @@ public:
{ {
return textureHandle->defaultView; return textureHandle->defaultView;
} }
inline bool isDepthStencil() const
{
return textureHandle->isDepthStencil();
}
private: private:
PTextureBase textureHandle;
}; };
DEFINE_REF(Texture2D); DEFINE_REF(Texture2D);
@@ -260,16 +289,54 @@ public:
}; };
DEFINE_REF(SamplerState); DEFINE_REF(SamplerState);
class Window : public Gfx::Window
{
public:
Window(PGraphics graphics, const WindowCreateInfo &createInfo);
virtual ~Window();
virtual void beginFrame() override;
virtual void endFrame() override;
virtual Gfx::PTexture2D getBackBuffer() override;
virtual void onWindowCloseEvent() override;
protected:
void advanceBackBuffer();
void recreateSwapchain(const WindowCreateInfo &createInfo);
void present();
void destroySwapchain();
void createSwapchain();
void chooseSurfaceFormat(const Array<VkSurfaceFormatKHR> &available, Gfx::SeFormat preferred);
void choosePresentMode(const Array<VkPresentModeKHR> &modes);
PTexture2D backBufferImages[Gfx::numFramesBuffered];
PSemaphore renderFinished[Gfx::numFramesBuffered];
PSemaphore imageAcquired[Gfx::numFramesBuffered];
PSemaphore imageAcquiredSemaphore;
PGraphics graphics;
VkFormat pixelFormat;
VkPresentModeKHR presentMode;
VkSwapchainKHR swapchain;
VkSurfaceKHR surface;
VkSurfaceFormatKHR surfaceFormat;
void *windowHandle;
int32 currentImageIndex;
int32 acquiredImageIndex;
int32 preAcquiredImageIndex;
int32 semaphoreIndex;
VkInstance instance;
};
DEFINE_REF(Window);
class Viewport : public Gfx::Viewport class Viewport : public Gfx::Viewport
{ {
public: public:
Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
virtual ~Viewport();
protected:
private: private:
uint32 sizeX; PGraphics graphics;
uint32 sizeY; friend class Graphics;
uint32 offsetX;
uint32 offsetY;
VkSwapchainKHR swapchain;
void *windowHandle;
}; };
DECLARE_REF(Viewport); DECLARE_REF(Viewport);
} // namespace Vulkan } // namespace Vulkan
@@ -3,7 +3,7 @@
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
VkApplicationInfo init::ApplicationInfo(const char* appName, uint32_t appVersion, const char* engineName, uint32_t engineVersion, uint32_t apiVersion) VkApplicationInfo init::ApplicationInfo(const char *appName, uint32_t appVersion, const char *engineName, uint32_t engineVersion, uint32_t apiVersion)
{ {
VkApplicationInfo info = {}; VkApplicationInfo info = {};
info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
@@ -11,10 +11,11 @@ VkApplicationInfo init::ApplicationInfo(const char* appName, uint32_t appVersion
info.applicationVersion = appVersion; info.applicationVersion = appVersion;
info.pEngineName = engineName; info.pEngineName = engineName;
info.engineVersion = engineVersion; info.engineVersion = engineVersion;
info.apiVersion = apiVersion;
return info; return info;
} }
VkInstanceCreateInfo init::InstanceCreateInfo(VkApplicationInfo* appInfo, const Array<const char*>& extensions, const Array<const char*>& layers) VkInstanceCreateInfo init::InstanceCreateInfo(VkApplicationInfo *appInfo, const Array<const char *> &extensions, const Array<const char *> &layers)
{ {
VkInstanceCreateInfo info = {}; VkInstanceCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
@@ -41,7 +42,7 @@ VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int qu
return DeviceQueueCreateInfo(queueFamilyIndex, queueCount, &priority); return DeviceQueueCreateInfo(queueFamilyIndex, queueCount, &priority);
} }
VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int queueCount, float* queuePriority) VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int queueCount, float *queuePriority)
{ {
VkDeviceQueueCreateInfo createInfo = {}; VkDeviceQueueCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
@@ -51,7 +52,7 @@ VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int qu
return createInfo; return createInfo;
} }
VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo* queueInfos, uint32_t queueCount, VkPhysicalDeviceFeatures* features) VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo *queueInfos, uint32_t queueCount, VkPhysicalDeviceFeatures *features)
{ {
return DeviceCreateInfo(queueInfos, queueCount, features, nullptr, 0, nullptr, 0); return DeviceCreateInfo(queueInfos, queueCount, features, nullptr, 0, nullptr, 0);
} }
@@ -93,7 +94,7 @@ VkSwapchainCreateInfoKHR init::SwapchainCreateInfo(VkSurfaceKHR surface, uint32_
return createInfo; return createInfo;
} }
VkFramebufferCreateInfo init::FramebufferCreateInfo(VkRenderPass renderPass, uint32_t attachmentCount, VkImageView* attachments, uint32_t width, uint32_t height, uint32_t layers) VkFramebufferCreateInfo init::FramebufferCreateInfo(VkRenderPass renderPass, uint32_t attachmentCount, VkImageView *attachments, uint32_t width, uint32_t height, uint32_t layers)
{ {
VkFramebufferCreateInfo frameBufferCreateInfo = {}; VkFramebufferCreateInfo frameBufferCreateInfo = {};
frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
@@ -121,16 +122,26 @@ VkAttachmentDescription init::AttachmentDescription(VkFormat format, VkSampleCou
return desc; return desc;
} }
VkSubpassDescription init::SubpassDescription(VkPipelineBindPoint bindPoint, uint32_t colorAttachmentCount, VkAttachmentReference* colorReference, uint32_t depthAttachmentCount, VkAttachmentReference* depthReference, uint32_t inputAttachmentCount, VkAttachmentReference* inputReference, uint32_t resolveAttachmentCount, VkAttachmentReference* resolveReference, uint32_t preserveAttachmentCount, VkAttachmentReference* preserveReference) VkSubpassDescription init::SubpassDescription(VkPipelineBindPoint bindPoint,
uint32_t colorAttachmentCount, VkAttachmentReference *colorReference,
VkAttachmentReference *depthReference,
uint32_t inputAttachmentCount, VkAttachmentReference *inputReference,
VkAttachmentReference *resolveReference, uint32_t preserveAttachmentCount, uint32_t *preserveReference)
{ {
VkSubpassDescription desc = {}; VkSubpassDescription desc = {};
desc.pipelineBindPoint = bindPoint; desc.pipelineBindPoint = bindPoint;
desc.colorAttachmentCount = colorAttachmentCount; desc.colorAttachmentCount = colorAttachmentCount;
desc.pColorAttachments = colorReference; desc.pColorAttachments = colorReference;
desc.inputAttachmentCount = inputAttachmentCount;
desc.pInputAttachments = inputReference;
desc.pResolveAttachments = resolveReference;
desc.preserveAttachmentCount = preserveAttachmentCount;
desc.pPreserveAttachments = preserveReference;
desc.pDepthStencilAttachment = depthReference;
return desc; return desc;
} }
VkRenderPassCreateInfo init::RenderPassCreateInfo(uint32_t attachmentCount, const VkAttachmentDescription* attachments, uint32_t subpassCount, const VkSubpassDescription* subpasses, uint32_t dependencyCount, const VkSubpassDependency* subpassDependencies) VkRenderPassCreateInfo init::RenderPassCreateInfo(uint32_t attachmentCount, const VkAttachmentDescription *attachments, uint32_t subpassCount, const VkSubpassDescription *subpasses, uint32_t dependencyCount, const VkSubpassDependency *subpassDependencies)
{ {
VkRenderPassCreateInfo info = {}; VkRenderPassCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
@@ -143,7 +154,7 @@ VkRenderPassCreateInfo init::RenderPassCreateInfo(uint32_t attachmentCount, cons
return info; return info;
} }
VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo* queueInfos, uint32_t queueCount, VkPhysicalDeviceFeatures* features, const char* const* deviceExtensions, uint32_t deviceExtensionCount, const char* const* layers, uint32_t layerCount) VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo *queueInfos, uint32_t queueCount, VkPhysicalDeviceFeatures *features, const char *const *deviceExtensions, uint32_t deviceExtensionCount, const char *const *layers, uint32_t layerCount)
{ {
VkDeviceCreateInfo createInfo = {}; VkDeviceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
@@ -160,6 +171,8 @@ VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo* queueInfos, u
createInfo.ppEnabledLayerNames = layers; createInfo.ppEnabledLayerNames = layers;
#else #else
createInfo.enabledLayerCount = 0; createInfo.enabledLayerCount = 0;
layerCount = 0;
layers = nullptr;
#endif // ENABLE_VALIDATION #endif // ENABLE_VALIDATION
return createInfo; return createInfo;
@@ -230,33 +243,40 @@ VkImageMemoryBarrier init::ImageMemoryBarrier(VkImage image, VkImageLayout oldLa
barrier.srcQueueFamilyIndex = srcQueue; barrier.srcQueueFamilyIndex = srcQueue;
barrier.dstQueueFamilyIndex = dstQueue; barrier.dstQueueFamilyIndex = dstQueue;
barrier.image = image; barrier.image = image;
if (newLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) { if (newLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
{
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
} }
else { else
{
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
} }
barrier.subresourceRange.baseMipLevel = 0; barrier.subresourceRange.baseMipLevel = 0;
barrier.subresourceRange.levelCount = 1; barrier.subresourceRange.levelCount = 1;
barrier.subresourceRange.baseArrayLayer = 0; barrier.subresourceRange.baseArrayLayer = 0;
barrier.subresourceRange.layerCount = 1; barrier.subresourceRange.layerCount = 1;
if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL)
{
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
} }
else if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { else if (oldLayout == VK_IMAGE_LAYOUT_PREINITIALIZED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
{
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
} }
else if (oldLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL && newLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) { else if (oldLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL && newLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
{
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
} }
else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) { else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
{
barrier.srcAccessMask = 0; barrier.srcAccessMask = 0;
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
} }
else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) { else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
{
barrier.srcAccessMask = 0; barrier.srcAccessMask = 0;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
} }
@@ -422,7 +442,7 @@ VkBufferCreateInfo init::BufferCreateInfo(
VkDescriptorPoolCreateInfo init::DescriptorPoolCreateInfo( VkDescriptorPoolCreateInfo init::DescriptorPoolCreateInfo(
uint32_t poolSizeCount, uint32_t poolSizeCount,
VkDescriptorPoolSize* pPoolSizes, VkDescriptorPoolSize *pPoolSizes,
uint32_t maxSets) uint32_t maxSets)
{ {
VkDescriptorPoolCreateInfo descriptorPoolInfo = {}; VkDescriptorPoolCreateInfo descriptorPoolInfo = {};
@@ -459,7 +479,7 @@ VkDescriptorSetLayoutBinding init::DescriptorSetLayoutBinding(
} }
VkDescriptorSetLayoutCreateInfo init::DescriptorSetLayoutCreateInfo( VkDescriptorSetLayoutCreateInfo init::DescriptorSetLayoutCreateInfo(
const VkDescriptorSetLayoutBinding* pBindings, const VkDescriptorSetLayoutBinding *pBindings,
uint32_t bindingCount) uint32_t bindingCount)
{ {
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {}; VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {};
@@ -471,7 +491,7 @@ VkDescriptorSetLayoutCreateInfo init::DescriptorSetLayoutCreateInfo(
} }
VkPipelineLayoutCreateInfo init::PipelineLayoutCreateInfo( VkPipelineLayoutCreateInfo init::PipelineLayoutCreateInfo(
const VkDescriptorSetLayout* pSetLayouts, const VkDescriptorSetLayout *pSetLayouts,
uint32_t setLayoutCount) uint32_t setLayoutCount)
{ {
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {}; VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {};
@@ -484,7 +504,7 @@ VkPipelineLayoutCreateInfo init::PipelineLayoutCreateInfo(
VkDescriptorSetAllocateInfo init::DescriptorSetAllocateInfo( VkDescriptorSetAllocateInfo init::DescriptorSetAllocateInfo(
VkDescriptorPool descriptorPool, VkDescriptorPool descriptorPool,
const VkDescriptorSetLayout* pSetLayouts, const VkDescriptorSetLayout *pSetLayouts,
uint32_t descriptorSetCount) uint32_t descriptorSetCount)
{ {
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {}; VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {};
@@ -522,7 +542,7 @@ VkWriteDescriptorSet init::WriteDescriptorSet(
VkDescriptorSet dstSet, VkDescriptorSet dstSet,
VkDescriptorType type, VkDescriptorType type,
uint32_t binding, uint32_t binding,
VkDescriptorBufferInfo* bufferInfo) VkDescriptorBufferInfo *bufferInfo)
{ {
VkWriteDescriptorSet writeDescriptorSet = {}; VkWriteDescriptorSet writeDescriptorSet = {};
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -540,7 +560,7 @@ VkWriteDescriptorSet init::WriteDescriptorSet(
VkDescriptorSet dstSet, VkDescriptorSet dstSet,
VkDescriptorType type, VkDescriptorType type,
uint32_t binding, uint32_t binding,
VkDescriptorImageInfo* bufferInfo) VkDescriptorImageInfo *bufferInfo)
{ {
VkWriteDescriptorSet writeDescriptorSet = {}; VkWriteDescriptorSet writeDescriptorSet = {};
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@@ -630,7 +650,7 @@ VkPipelineColorBlendAttachmentState init::PipelineColorBlendAttachmentState(
VkPipelineColorBlendStateCreateInfo init::PipelineColorBlendStateCreateInfo( VkPipelineColorBlendStateCreateInfo init::PipelineColorBlendStateCreateInfo(
uint32_t attachmentCount, uint32_t attachmentCount,
const VkPipelineColorBlendAttachmentState* pAttachments) const VkPipelineColorBlendAttachmentState *pAttachments)
{ {
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = {}; VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = {};
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
@@ -674,17 +694,19 @@ VkPipelineMultisampleStateCreateInfo init::PipelineMultisampleStateCreateInfo(
{ {
VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo = {}; VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo = {};
pipelineMultisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; pipelineMultisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
pipelineMultisampleStateCreateInfo.flags = flags;
pipelineMultisampleStateCreateInfo.rasterizationSamples = rasterizationSamples; pipelineMultisampleStateCreateInfo.rasterizationSamples = rasterizationSamples;
return pipelineMultisampleStateCreateInfo; return pipelineMultisampleStateCreateInfo;
} }
VkPipelineDynamicStateCreateInfo init::PipelineDynamicStateCreateInfo( VkPipelineDynamicStateCreateInfo init::PipelineDynamicStateCreateInfo(
const VkDynamicState* pDynamicStates, const VkDynamicState *pDynamicStates,
uint32_t dynamicStateCount, uint32_t dynamicStateCount,
VkPipelineDynamicStateCreateFlags flags) VkPipelineDynamicStateCreateFlags flags)
{ {
VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {}; VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {};
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
pipelineDynamicStateCreateInfo.flags = flags;
pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates; pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates;
pipelineDynamicStateCreateInfo.dynamicStateCount = dynamicStateCount; pipelineDynamicStateCreateInfo.dynamicStateCount = dynamicStateCount;
return pipelineDynamicStateCreateInfo; return pipelineDynamicStateCreateInfo;
@@ -733,7 +755,7 @@ VkPushConstantRange init::PushConstantRange(
return pushConstantRange; return pushConstantRange;
} }
VkPipelineShaderStageCreateInfo init::PipelineShaderStageCreateInfo(VkShaderStageFlagBits stage, VkShaderModule module, const char* entryName) VkPipelineShaderStageCreateInfo init::PipelineShaderStageCreateInfo(VkShaderStageFlagBits stage, VkShaderModule module, const char *entryName)
{ {
VkPipelineShaderStageCreateInfo info = {}; VkPipelineShaderStageCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -743,25 +765,31 @@ VkPipelineShaderStageCreateInfo init::PipelineShaderStageCreateInfo(VkShaderStag
return info; return info;
} }
#pragma warning(disable : 4100)
VkBool32 Seele::Vulkan::debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char* layerPrefix, const char* msg, void* userDataManager) { VkBool32 Seele::Vulkan::debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char *layerPrefix, const char *msg, void *userDataManager)
{
std::cerr << layerPrefix << ": " << msg << std::endl; std::cerr << layerPrefix << ": " << msg << std::endl;
return VK_FALSE; return VK_FALSE;
} }
VkResult Seele::Vulkan::CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) { #pragma warning(default : 4100)
VkResult Seele::Vulkan::CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback)
{
auto func = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT"); auto func = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT");
if (func != nullptr) { if (func != nullptr)
{
return func(instance, pCreateInfo, pAllocator, pCallback); return func(instance, pCreateInfo, pAllocator, pCallback);
} }
else { else
{
return VK_ERROR_EXTENSION_NOT_PRESENT; return VK_ERROR_EXTENSION_NOT_PRESENT;
} }
} }
void Seele::Vulkan::DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT pCallback) void Seele::Vulkan::DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT pCallback)
{ {
auto func = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT"); auto func = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT");
if (func != nullptr) { if (func != nullptr)
{
func(instance, pCallback, pAllocator); func(instance, pCallback, pAllocator);
} }
} }
+102 -105
View File
@@ -4,54 +4,54 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
VkBool32 debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char* layerPrefix, const char* msg, void* userData); VkBool32 debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char *layerPrefix, const char *msg, void *userData);
VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback); VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback);
void DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT pCallback); void DestroyDebugReportCallbackEXT(VkInstance instance, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT pCallback);
namespace init namespace init
{ {
VkApplicationInfo ApplicationInfo( VkApplicationInfo ApplicationInfo(
const char* appName, const char *appName,
uint32_t appVersion, uint32_t appVersion,
const char* engineName, const char *engineName,
uint32_t engineVersion, uint32_t engineVersion,
uint32_t apiVersion); uint32_t apiVersion);
VkInstanceCreateInfo InstanceCreateInfo( VkInstanceCreateInfo InstanceCreateInfo(
VkApplicationInfo* appInfo, VkApplicationInfo *appInfo,
const Array<const char*>& extensions, const Array<const char *> &extensions,
const Array<const char*>& layers); const Array<const char *> &layers);
VkDebugReportCallbackCreateInfoEXT DebugReportCallbackCreateInfo( VkDebugReportCallbackCreateInfoEXT DebugReportCallbackCreateInfo(
VkDebugReportFlagsEXT flags); VkDebugReportFlagsEXT flags);
VkDeviceQueueCreateInfo DeviceQueueCreateInfo( VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
int queueFamilyIndex, int queueFamilyIndex,
int queueCount); int queueCount);
VkDeviceQueueCreateInfo DeviceQueueCreateInfo( VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
int queueFamilyIndex, int queueFamilyIndex,
int queueCount, int queueCount,
float* queuePriority); float *queuePriority);
VkDeviceCreateInfo DeviceCreateInfo( VkDeviceCreateInfo DeviceCreateInfo(
VkDeviceQueueCreateInfo* queueInfos, VkDeviceQueueCreateInfo *queueInfos,
uint32_t queueCount, uint32_t queueCount,
VkPhysicalDeviceFeatures* features, VkPhysicalDeviceFeatures *features,
const char* const* deviceExtensions, const char *const *deviceExtensions,
uint32_t deviceExtensionCount, uint32_t deviceExtensionCount,
const char* const* layers, const char *const *layers,
uint32_t layerCount); uint32_t layerCount);
VkDeviceCreateInfo DeviceCreateInfo( VkDeviceCreateInfo DeviceCreateInfo(
VkDeviceQueueCreateInfo* queueInfos, VkDeviceQueueCreateInfo *queueInfos,
uint32_t queueCount, uint32_t queueCount,
VkPhysicalDeviceFeatures* features); VkPhysicalDeviceFeatures *features);
VkSwapchainCreateInfoKHR SwapchainCreateInfo( VkSwapchainCreateInfoKHR SwapchainCreateInfo(
VkSurfaceKHR surface, VkSurfaceKHR surface,
uint32_t minImageCount, uint32_t minImageCount,
VkFormat imageFormat, VkFormat imageFormat,
@@ -64,7 +64,7 @@ namespace Seele
VkPresentModeKHR presentMode, VkPresentModeKHR presentMode,
VkBool32 clipped); VkBool32 clipped);
VkSwapchainCreateInfoKHR SwapchainCreateInfo( VkSwapchainCreateInfoKHR SwapchainCreateInfo(
VkSurfaceKHR surface, VkSurfaceKHR surface,
uint32_t minImageCount, uint32_t minImageCount,
VkFormat imageFormat, VkFormat imageFormat,
@@ -78,15 +78,15 @@ namespace Seele
VkPresentModeKHR presentMode, VkPresentModeKHR presentMode,
VkBool32 clipped); VkBool32 clipped);
VkFramebufferCreateInfo FramebufferCreateInfo( VkFramebufferCreateInfo FramebufferCreateInfo(
VkRenderPass renderPass, VkRenderPass renderPass,
uint32_t attachmentCount, uint32_t attachmentCount,
VkImageView* attachments, VkImageView *attachments,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
uint32_t layers); uint32_t layers);
VkAttachmentDescription AttachmentDescription( VkAttachmentDescription AttachmentDescription(
VkFormat format, VkFormat format,
VkSampleCountFlagBits sample, VkSampleCountFlagBits sample,
VkAttachmentLoadOp loadOp, VkAttachmentLoadOp loadOp,
@@ -96,210 +96,207 @@ namespace Seele
VkImageLayout imageLayout, VkImageLayout imageLayout,
VkImageLayout finalLayout); VkImageLayout finalLayout);
VkSubpassDescription SubpassDescription( VkSubpassDescription SubpassDescription(
VkPipelineBindPoint bindPoint, VkPipelineBindPoint bindPoint,
uint32_t colorAttachmentCount, uint32_t colorAttachmentCount,
VkAttachmentReference* colorReference, VkAttachmentReference *colorReference,
uint32_t depthAttachmentCount = 0, VkAttachmentReference *depthReference = nullptr,
VkAttachmentReference* depthReference = nullptr,
uint32_t inputAttachmentCount = 0, uint32_t inputAttachmentCount = 0,
VkAttachmentReference* inputReference = nullptr, VkAttachmentReference *inputReference = nullptr,
uint32_t resolveAttachmentCount = 0, VkAttachmentReference *resolveReference = nullptr,
VkAttachmentReference* resolveReference = nullptr,
uint32_t preserveAttachmentCount = 0, uint32_t preserveAttachmentCount = 0,
VkAttachmentReference* preserveReference = nullptr); uint32_t *preserveReference = nullptr);
VkRenderPassCreateInfo RenderPassCreateInfo( VkRenderPassCreateInfo RenderPassCreateInfo(
uint32_t attachmentCount, uint32_t attachmentCount,
const VkAttachmentDescription* attachments, const VkAttachmentDescription *attachments,
uint32_t subpassCount, uint32_t subpassCount,
const VkSubpassDescription* subpasses, const VkSubpassDescription *subpasses,
uint32_t dependencyCount, uint32_t dependencyCount,
const VkSubpassDependency* subpassDependencies); const VkSubpassDependency *subpassDependencies);
VkMemoryAllocateInfo MemoryAllocateInfo(); VkMemoryAllocateInfo MemoryAllocateInfo();
VkCommandBufferAllocateInfo CommandBufferAllocateInfo( VkCommandBufferAllocateInfo CommandBufferAllocateInfo(
VkCommandPool cmdPool, VkCommandPool cmdPool,
VkCommandBufferLevel level, VkCommandBufferLevel level,
uint32_t bufferCount); uint32_t bufferCount);
VkCommandPoolCreateInfo CommandPoolCreateInfo(); VkCommandPoolCreateInfo CommandPoolCreateInfo();
VkCommandBufferBeginInfo CommandBufferBeginInfo(); VkCommandBufferBeginInfo CommandBufferBeginInfo();
VkCommandBufferInheritanceInfo CommandBufferInheritanceInfo(); VkCommandBufferInheritanceInfo CommandBufferInheritanceInfo();
VkRenderPassBeginInfo RenderPassBeginInfo(); VkRenderPassBeginInfo RenderPassBeginInfo();
VkRenderPassCreateInfo RenderPassCreateInfo(); VkRenderPassCreateInfo RenderPassCreateInfo();
VkImageMemoryBarrier ImageMemoryBarrier(VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t srcQueue = VK_QUEUE_FAMILY_IGNORED, uint32_t dstQueue = VK_QUEUE_FAMILY_IGNORED); VkImageMemoryBarrier ImageMemoryBarrier(VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t srcQueue = VK_QUEUE_FAMILY_IGNORED, uint32_t dstQueue = VK_QUEUE_FAMILY_IGNORED);
VkImageMemoryBarrier ImageMemoryBarrier(); VkImageMemoryBarrier ImageMemoryBarrier();
VkBufferMemoryBarrier BufferMemoryBarrier(); VkBufferMemoryBarrier BufferMemoryBarrier();
VkMemoryBarrier MemoryBarrier(); VkMemoryBarrier MemoryBarrier();
VkImageCreateInfo ImageCreateInfo(); VkImageCreateInfo ImageCreateInfo();
VkSamplerCreateInfo SamplerCreateInfo(); VkSamplerCreateInfo SamplerCreateInfo();
VkImageViewCreateInfo ImageViewCreateInfo(); VkImageViewCreateInfo ImageViewCreateInfo();
VkSemaphoreCreateInfo SemaphoreCreateInfo(); VkSemaphoreCreateInfo SemaphoreCreateInfo();
VkFenceCreateInfo FenceCreateInfo( VkFenceCreateInfo FenceCreateInfo(
VkFenceCreateFlags flags); VkFenceCreateFlags flags);
VkEventCreateInfo EventCreateInfo(); VkEventCreateInfo EventCreateInfo();
VkSubmitInfo SubmitInfo(); VkSubmitInfo SubmitInfo();
VkImageSubresourceRange ImageSubresourceRange( VkImageSubresourceRange ImageSubresourceRange(
VkImageAspectFlags aspect = VK_IMAGE_ASPECT_COLOR_BIT, VkImageAspectFlags aspect = VK_IMAGE_ASPECT_COLOR_BIT,
uint32_t startMip = 0); uint32_t startMip = 0);
VkViewport Viewport( VkViewport Viewport(
float width, float width,
float height, float height,
float minDepth, float minDepth,
float maxDepth); float maxDepth);
VkRect2D Rect2D( VkRect2D Rect2D(
int32_t width, int32_t width,
int32_t height, int32_t height,
int32_t offsetX, int32_t offsetX,
int32_t offsetY); int32_t offsetY);
VkBufferCreateInfo BufferCreateInfo(); VkBufferCreateInfo BufferCreateInfo();
VkBufferCreateInfo BufferCreateInfo( VkBufferCreateInfo BufferCreateInfo(
VkBufferUsageFlags usage, VkBufferUsageFlags usage,
VkDeviceSize size); VkDeviceSize size);
VkDescriptorPoolCreateInfo DescriptorPoolCreateInfo( VkDescriptorPoolCreateInfo DescriptorPoolCreateInfo(
uint32_t poolSizeCount, uint32_t poolSizeCount,
VkDescriptorPoolSize* pPoolSizes, VkDescriptorPoolSize *pPoolSizes,
uint32_t maxSets); uint32_t maxSets);
VkDescriptorPoolSize DescriptorPoolSize( VkDescriptorPoolSize DescriptorPoolSize(
VkDescriptorType type, VkDescriptorType type,
uint32_t descriptorCount); uint32_t descriptorCount);
VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding( VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding(
VkDescriptorType type, VkDescriptorType type,
VkShaderStageFlags stageFlags, VkShaderStageFlags stageFlags,
uint32_t binding, uint32_t binding,
uint32_t count); uint32_t count);
VkDescriptorSetLayoutCreateInfo DescriptorSetLayoutCreateInfo( VkDescriptorSetLayoutCreateInfo DescriptorSetLayoutCreateInfo(
const VkDescriptorSetLayoutBinding* pBindings, const VkDescriptorSetLayoutBinding *pBindings,
uint32_t bindingCount); uint32_t bindingCount);
VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo( VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo(
const VkDescriptorSetLayout* pSetLayouts, const VkDescriptorSetLayout *pSetLayouts,
uint32_t setLayoutCount); uint32_t setLayoutCount);
VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo( VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo(
VkDescriptorPool descriptorPool, VkDescriptorPool descriptorPool,
const VkDescriptorSetLayout* pSetLayouts, const VkDescriptorSetLayout *pSetLayouts,
uint32_t descriptorSetCount); uint32_t descriptorSetCount);
VkDescriptorBufferInfo DescriptorBufferInfo( VkDescriptorBufferInfo DescriptorBufferInfo(
VkBuffer buffer, VkBuffer buffer,
VkDeviceSize offset, VkDeviceSize offset,
VkDeviceSize range); VkDeviceSize range);
VkDescriptorImageInfo DescriptorImageInfo( VkDescriptorImageInfo DescriptorImageInfo(
VkSampler sampler, VkSampler sampler,
VkImageView imageView, VkImageView imageView,
VkImageLayout imageLayout); VkImageLayout imageLayout);
VkWriteDescriptorSet WriteDescriptorSet( VkWriteDescriptorSet WriteDescriptorSet(
VkDescriptorSet dstSet, VkDescriptorSet dstSet,
VkDescriptorType type, VkDescriptorType type,
uint32_t binding, uint32_t binding,
VkDescriptorBufferInfo* bufferInfo); VkDescriptorBufferInfo *bufferInfo);
VkWriteDescriptorSet WriteDescriptorSet( VkWriteDescriptorSet WriteDescriptorSet(
VkDescriptorSet dstSet, VkDescriptorSet dstSet,
VkDescriptorType type, VkDescriptorType type,
uint32_t binding, uint32_t binding,
VkDescriptorImageInfo* bufferInfo); VkDescriptorImageInfo *bufferInfo);
VkVertexInputBindingDescription VertexInputBindingDescription(
VkVertexInputBindingDescription VertexInputBindingDescription(
uint32_t binding, uint32_t binding,
uint32_t stride, uint32_t stride,
VkVertexInputRate inputRate); VkVertexInputRate inputRate);
VkVertexInputAttributeDescription VertexInputAttributeDescription( VkVertexInputAttributeDescription VertexInputAttributeDescription(
uint32_t binding, uint32_t binding,
uint32_t location, uint32_t location,
VkFormat format, VkFormat format,
uint32_t offset); uint32_t offset);
VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo(); VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo();
VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo( VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo(
VkPrimitiveTopology topology, VkPrimitiveTopology topology,
VkPipelineInputAssemblyStateCreateFlags flags, VkPipelineInputAssemblyStateCreateFlags flags,
VkBool32 primitiveRestartEnable); VkBool32 primitiveRestartEnable);
VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo( VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo(
VkPolygonMode polygonMode, VkPolygonMode polygonMode,
VkCullModeFlags cullMode, VkCullModeFlags cullMode,
VkFrontFace frontFace, VkFrontFace frontFace,
VkPipelineRasterizationStateCreateFlags flags); VkPipelineRasterizationStateCreateFlags flags);
VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState( VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState(
VkColorComponentFlags colorWriteMask, VkColorComponentFlags colorWriteMask,
VkBool32 blendEnable); VkBool32 blendEnable);
VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo( VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo(
uint32_t attachmentCount, uint32_t attachmentCount,
const VkPipelineColorBlendAttachmentState* pAttachments); const VkPipelineColorBlendAttachmentState *pAttachments);
VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo( VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo(
VkBool32 depthTestEnable, VkBool32 depthTestEnable,
VkBool32 depthWriteEnable, VkBool32 depthWriteEnable,
VkCompareOp depthCompareOp); VkCompareOp depthCompareOp);
VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo( VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo(
uint32_t viewportCount, uint32_t viewportCount,
uint32_t scissorCount, uint32_t scissorCount,
VkPipelineViewportStateCreateFlags flags); VkPipelineViewportStateCreateFlags flags);
VkPipelineMultisampleStateCreateInfo PipelineMultisampleStateCreateInfo( VkPipelineMultisampleStateCreateInfo PipelineMultisampleStateCreateInfo(
VkSampleCountFlagBits rasterizationSamples, VkSampleCountFlagBits rasterizationSamples,
VkPipelineMultisampleStateCreateFlags flags); VkPipelineMultisampleStateCreateFlags flags);
VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo( VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo(
const VkDynamicState* pDynamicStates, const VkDynamicState *pDynamicStates,
uint32_t dynamicStateCount, uint32_t dynamicStateCount,
VkPipelineDynamicStateCreateFlags flags); VkPipelineDynamicStateCreateFlags flags);
VkPipelineTessellationStateCreateInfo PipelineTessellationStateCreateInfo( VkPipelineTessellationStateCreateInfo PipelineTessellationStateCreateInfo(
uint32_t patchControlPoints); uint32_t patchControlPoints);
VkGraphicsPipelineCreateInfo PipelineCreateInfo( VkGraphicsPipelineCreateInfo PipelineCreateInfo(
VkPipelineLayout layout, VkPipelineLayout layout,
VkRenderPass renderPass, VkRenderPass renderPass,
VkPipelineCreateFlags flags); VkPipelineCreateFlags flags);
VkComputePipelineCreateInfo ComputePipelineCreateInfo( VkComputePipelineCreateInfo ComputePipelineCreateInfo(
VkPipelineLayout layout, VkPipelineLayout layout,
VkPipelineCreateFlags flags); VkPipelineCreateFlags flags);
VkPushConstantRange PushConstantRange( VkPushConstantRange PushConstantRange(
VkShaderStageFlags stageFlags, VkShaderStageFlags stageFlags,
uint32_t size, uint32_t size,
uint32_t offset); uint32_t offset);
VkPipelineShaderStageCreateInfo PipelineShaderStageCreateInfo( VkPipelineShaderStageCreateInfo PipelineShaderStageCreateInfo(
VkShaderStageFlagBits stage, VkShaderStageFlagBits stage,
VkShaderModule module, VkShaderModule module,
const char* entryName); const char *entryName);
} } // namespace init
} } // namespace Vulkan
} } // namespace Seele
+47 -1
View File
@@ -1,11 +1,14 @@
#include "VulkanQueue.h" #include "VulkanQueue.h"
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanAllocator.h"
#include "VulkanCommandBuffer.h"
#include "VulkanGraphicsEnums.h"
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
Queue::Queue(PGraphics graphics, QueueType queueType, uint32 familyIndex, uint32 queueIndex) Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex)
: familyIndex(familyIndex) : familyIndex(familyIndex)
, graphics(graphics) , graphics(graphics)
, queueType(queueType) , queueType(queueType)
@@ -17,3 +20,46 @@ Queue::~Queue()
{ {
} }
void Queue::submitCommandBuffer(PCmdBuffer cmdBuffer, uint32 numSignalSemaphores, VkSemaphore* signalSemaphores)
{
assert(cmdBuffer->state == CmdBuffer::State::Ended);
PFence fence = cmdBuffer->fence;
assert(!fence->isSignaled());
const VkCommandBuffer cmdBuffers[] = {cmdBuffer->handle};
VkSubmitInfo submitInfo =
init::SubmitInfo();
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = cmdBuffers;
submitInfo.signalSemaphoreCount = static_cast<uint32>(numSignalSemaphores);
submitInfo.pSignalSemaphores = signalSemaphores;
Array<VkSemaphore> waitSemaphores;
if(cmdBuffer->waitSemaphores.size() > 0)
{
for(PSemaphore semaphore : cmdBuffer->waitSemaphores)
{
waitSemaphores.add(semaphore->getHandle());
}
submitInfo.waitSemaphoreCount = static_cast<uint32>(cmdBuffer->waitSemaphores.size());
submitInfo.pWaitSemaphores = waitSemaphores.data();
submitInfo.pWaitDstStageMask = cmdBuffer->waitFlags.data();
}
VK_CHECK(vkQueueSubmit(queue, 1, &submitInfo, fence->getHandle()));
cmdBuffer->state = CmdBuffer::State::Submitted;
cmdBuffer->waitFlags.clear();
cmdBuffer->waitSemaphores.clear();
if(Gfx::waitIdleOnSubmit)
{
fence->wait(200 * 1000ull);
}
cmdBuffer->refreshFence();
graphics->getStagingManager()->clearPending();
}
+16 -15
View File
@@ -3,16 +3,16 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
DECLARE_REF(CmdBuffer); DECLARE_REF(CmdBuffer);
DECLARE_REF(Graphics); DECLARE_REF(Graphics);
class Queue class Queue
{ {
public: public:
Queue(PGraphics graphics, QueueType queueType, uint32 familyIndex, uint32 queueIndex); Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex);
virtual ~Queue(); virtual ~Queue();
void submitCommandBuffer(PCmdBuffer cmdBuffer, uint32 numSignalSemaphores = 0, VkSemaphore* signalSemaphore = nullptr); void submitCommandBuffer(PCmdBuffer cmdBuffer, uint32 numSignalSemaphores = 0, VkSemaphore *signalSemaphore = nullptr);
inline void submitCommandBuffer(PCmdBuffer cmdBuffer, VkSemaphore signalSemaphore) inline void submitCommandBuffer(PCmdBuffer cmdBuffer, VkSemaphore signalSemaphore)
{ {
submitCommandBuffer(cmdBuffer, 1, &signalSemaphore); submitCommandBuffer(cmdBuffer, 1, &signalSemaphore);
@@ -25,12 +25,13 @@ namespace Seele
{ {
return queue; return queue;
} }
private:
private:
PGraphics graphics; PGraphics graphics;
VkQueue queue; VkQueue queue;
uint32 familyIndex; uint32 familyIndex;
QueueType queueType; Gfx::QueueType queueType;
}; };
DEFINE_REF(Queue) DEFINE_REF(Queue)
} } // namespace Vulkan
} } // namespace Seele
@@ -0,0 +1,127 @@
#include "VulkanRenderPass.h"
#include "VulkanInitializer.h"
#include "VulkanGraphicsEnums.h"
#include "VulkanGraphics.h"
#include "VulkanFramebuffer.h"
using namespace Seele;
using namespace Seele::Vulkan;
RenderPass::RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout)
: layout(layout), graphics(graphics)
{
Array<VkAttachmentDescription> attachments;
Array<VkAttachmentReference> inputRefs;
Array<VkAttachmentReference> colorRefs;
VkAttachmentReference depthRef;
uint32 attachmentCounter = 0;
for (auto inputAttachment : layout->inputAttachments)
{
PTexture2D image = inputAttachment->getTexture().cast<Texture2D>();
VkAttachmentDescription desc = attachments.add();
desc.flags = 0;
desc.format = cast(image->getFormat());
desc.storeOp = cast(inputAttachment->getStoreOp());
desc.loadOp = cast(inputAttachment->getLoadOp());
desc.stencilStoreOp = cast(inputAttachment->getStencilStoreOp());
desc.stencilLoadOp = cast(inputAttachment->getStencilLoadOp());
desc.initialLayout = image->isDepthStencil() ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
desc.finalLayout = desc.initialLayout;
VkAttachmentReference &ref = inputRefs.add();
ref.layout = desc.initialLayout;
ref.attachment = attachmentCounter;
attachmentCounter++;
}
for (auto colorAttachment : layout->colorAttachments)
{
PTexture2D image = colorAttachment->getTexture().cast<Texture2D>();
VkAttachmentDescription desc = attachments.add();
desc.flags = 0;
desc.format = cast(image->getFormat());
desc.storeOp = cast(colorAttachment->getStoreOp());
desc.loadOp = cast(colorAttachment->getLoadOp());
desc.stencilStoreOp = cast(colorAttachment->getStencilStoreOp());
desc.stencilLoadOp = cast(colorAttachment->getStencilLoadOp());
desc.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentReference &ref = colorRefs.add();
ref.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
ref.attachment = attachmentCounter;
attachmentCounter++;
}
if (layout->depthAttachment != nullptr)
{
PTexture2D image = layout->depthAttachment->getTexture().cast<Texture2D>();
VkAttachmentDescription desc = attachments.add();
desc.flags = 0;
desc.format = cast(image->getFormat());
desc.storeOp = cast(layout->depthAttachment->getStoreOp());
desc.loadOp = cast(layout->depthAttachment->getLoadOp());
desc.stencilStoreOp = cast(layout->depthAttachment->getStencilStoreOp());
desc.stencilLoadOp = cast(layout->depthAttachment->getStencilLoadOp());
desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
desc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentReference &ref = depthRef;
ref.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
ref.attachment = attachmentCounter;
attachmentCounter++;
}
VkSubpassDescription subPassDesc =
init::SubpassDescription(
VK_PIPELINE_BIND_POINT_GRAPHICS,
colorRefs.size(),
colorRefs.data(),
&depthRef,
inputRefs.size(),
inputRefs.data());
VkSubpassDependency dependency = {};
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependency.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
VkRenderPassCreateInfo info =
init::RenderPassCreateInfo(
attachments.size(),
attachments.data(),
1,
&subPassDesc,
1,
&dependency);
VK_CHECK(vkCreateRenderPass(graphics->getDevice(), &info, nullptr, &renderPass));
}
RenderPass::~RenderPass()
{
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr);
}
uint32 RenderPass::getFramebufferHash()
{
FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
for(auto inputAttachment : layout->inputAttachments)
{
PTexture2D tex = inputAttachment->getTexture().cast<Texture2D>();
description.inputAttachments[description.numInputAttachments++] = tex->getView();
}
for(auto colorAttachment : layout->colorAttachments)
{
PTexture2D tex = colorAttachment->getTexture().cast<Texture2D>();
description.colorAttachments[description.numColorAttachments++] = tex->getView();
}
if(layout->depthAttachment != nullptr)
{
PTexture2D tex = layout->depthAttachment->getTexture().cast<Texture2D>();
description.depthAttachment = tex->getView();
}
return memCrc32(&description, sizeof(FramebufferDescription));
}
+19 -12
View File
@@ -2,13 +2,14 @@
namespace Seele namespace Seele
{ {
namespace Vulkan namespace Vulkan
{ {
class RenderPass class RenderPass : public Gfx::RenderPass
{ {
public: public:
RenderPass(); RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout);
virtual ~RenderPass(); virtual ~RenderPass();
uint32 getFramebufferHash();
inline VkRenderPass getHandle() const inline VkRenderPass getHandle() const
{ {
return renderPass; return renderPass;
@@ -17,7 +18,7 @@ namespace Seele
{ {
return clearValues.size(); return clearValues.size();
} }
inline VkClearValue* getClearValues() const inline VkClearValue *getClearValues() const
{ {
return clearValues.data(); return clearValues.data();
} }
@@ -29,12 +30,18 @@ namespace Seele
{ {
return subpassContents; return subpassContents;
} }
private: inline Gfx::PRenderTargetLayout getLayout()
{
return layout;
}
private:
PGraphics graphics;
Gfx::PRenderTargetLayout layout;
VkRenderPass renderPass; VkRenderPass renderPass;
Array<VkClearValue> clearValues; Array<VkClearValue> clearValues;
VkRect2D renderArea; VkRect2D renderArea;
VkSubpassContents subpassContents; VkSubpassContents subpassContents;
}; };
DEFINE_REF(RenderPass); DEFINE_REF(RenderPass);
} } // namespace Vulkan
} } // namespace Seele
+129 -23
View File
@@ -2,22 +2,40 @@
#include "VulkanGraphics.h" #include "VulkanGraphics.h"
#include "VulkanInitializer.h" #include "VulkanInitializer.h"
#include "VulkanGraphicsEnums.h" #include "VulkanGraphicsEnums.h"
#include "VulkanAllocator.h"
#include "VulkanCommandBuffer.h"
#include <math.h> #include <math.h>
using namespace Seele; using namespace Seele;
using namespace Seele::Vulkan; using namespace Seele::Vulkan;
TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ, VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format)
bool bArray, uint32 arraySize, uint32 mipLevel,
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage)
: graphics(graphics)
, sizeX(sizeX)
, sizeY(sizeY)
, sizeZ(sizeZ)
, mipLevels(mipLevel)
, format(format)
, arrayCount(bArray ? arraySize : 1)
{ {
switch (format)
{
case Gfx::SE_FORMAT_D16_UNORM:
return VK_IMAGE_ASPECT_DEPTH_BIT;
case Gfx::SE_FORMAT_D32_SFLOAT:
return VK_IMAGE_ASPECT_DEPTH_BIT;
case Gfx::SE_FORMAT_S8_UINT:
return VK_IMAGE_ASPECT_STENCIL_BIT;
case Gfx::SE_FORMAT_D16_UNORM_S8_UINT:
case Gfx::SE_FORMAT_D24_UNORM_S8_UINT:
case Gfx::SE_FORMAT_D32_SFLOAT_S8_UINT:
case Gfx::SE_FORMAT_X8_D24_UNORM_PACK32:
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
default:
return VK_IMAGE_ASPECT_COLOR_BIT;
}
}
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ,
bool bArray, uint32 arraySize, uint32 mipLevel,
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage, Gfx::QueueType owner, VkImage existingImage)
: QueueOwnedResource(graphics, owner), graphics(graphics), sizeX(sizeX), sizeY(sizeY), sizeZ(sizeZ), mipLevels(mipLevel), format(format), samples(samples), usage(usage), arrayCount(bArray ? arraySize : 1), aspect(getAspectFromFormat(format))
{
if (existingImage == VK_NULL_HANDLE)
{
PAllocator allocator = graphics->getAllocator(); PAllocator allocator = graphics->getAllocator();
VkImageCreateInfo info = VkImageCreateInfo info =
init::ImageCreateInfo(); init::ImageCreateInfo();
@@ -27,11 +45,6 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
info.arrayLayers = arraySize; info.arrayLayers = arraySize;
info.format = cast(format); info.format = cast(format);
VkImageViewCreateInfo viewInfo =
init::ImageViewCreateInfo();
viewInfo.subresourceRange = init::ImageSubresourceRange(aspect);
viewInfo.viewType = viewType;
uint32 layerCount = 1; uint32 layerCount = 1;
switch (viewType) switch (viewType)
{ {
@@ -47,6 +60,7 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
info.imageType = VK_IMAGE_TYPE_3D; info.imageType = VK_IMAGE_TYPE_3D;
break; break;
case VK_IMAGE_VIEW_TYPE_CUBE: case VK_IMAGE_VIEW_TYPE_CUBE:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
info.imageType = VK_IMAGE_TYPE_2D; info.imageType = VK_IMAGE_TYPE_2D;
layerCount = 6 * arrayCount; layerCount = 6 * arrayCount;
break; break;
@@ -62,30 +76,122 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
info.usage = usage; info.usage = usage;
VK_CHECK(vkCreateImage(graphics->getDevice(), &info, nullptr, &image)); VK_CHECK(vkCreateImage(graphics->getDevice(), &info, nullptr, &image));
VkMemoryDedicatedRequirements memDedicatedRequirements;
memDedicatedRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
memDedicatedRequirements.pNext = nullptr;
VkImageMemoryRequirementsInfo2 reqInfo;
reqInfo.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2;
reqInfo.pNext = nullptr;
reqInfo.image = image;
VkMemoryRequirements2 requirements;
requirements.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
requirements.pNext = &memDedicatedRequirements;
vkGetImageMemoryRequirements2(graphics->getDevice(), &reqInfo, &requirements);
allocation = allocator->allocate(requirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, image);
vkBindImageMemory(graphics->getDevice(), image, allocation->getHandle(), allocation->getOffset());
}
VkImageViewCreateInfo viewInfo =
init::ImageViewCreateInfo();
viewInfo.subresourceRange = init::ImageSubresourceRange(aspect);
viewInfo.viewType = viewType;
viewInfo.image = image; viewInfo.image = image;
viewInfo.format = cast(format); viewInfo.format = cast(format);
viewInfo.subresourceRange.layerCount = layerCount; viewInfo.subresourceRange.layerCount = (viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY || viewType == VK_IMAGE_VIEW_TYPE_CUBE) ? 6 : 1;
viewInfo.subresourceRange.levelCount = mipLevels; viewInfo.subresourceRange.levelCount = mipLevels;
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView)); VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView));
} }
TextureBase::~TextureBase() TextureHandle::~TextureHandle()
{ {
vkDestroyImageView(graphics->getDevice(), defaultView, nullptr); vkDestroyImageView(graphics->getDevice(), defaultView, nullptr);
vkDestroyImage(graphics->getDevice(), image, nullptr); vkDestroyImage(graphics->getDevice(), image, nullptr);
} }
Texture2D::Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY, void TextureHandle::executeOwnershipBarrier(Gfx::QueueType newOwner)
bool bArray, uint32 arraySize, uint32 mipLevels,
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage)
{ {
textureHandle = new TextureBase(graphics, bArray ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D, VkImageMemoryBarrier imageBarrier =
sizeX, sizeY, 1, bArray, arraySize, mipLevels, format, samples, usage); init::ImageMemoryBarrier();
imageBarrier.image = image;
imageBarrier.oldLayout = layout;
imageBarrier.newLayout = layout;
imageBarrier.subresourceRange = init::ImageSubresourceRange(aspect);
PCommandBufferManager sourceManager = getCommands();
PCommandBufferManager dstManager = nullptr;
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
QueueFamilyMapping mapping = graphics->getFamilyMapping();
imageBarrier.srcQueueFamilyIndex = mapping.getQueueTypeFamilyIndex(currentOwner);
imageBarrier.dstQueueFamilyIndex = mapping.getQueueTypeFamilyIndex(newOwner);
if (currentOwner == Gfx::QueueType::TRANSFER || currentOwner == Gfx::QueueType::DEDICATED_TRANSFER)
{
imageBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
}
else if (currentOwner == Gfx::QueueType::COMPUTE)
{
imageBarrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
srcStage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
}
else if (currentOwner == Gfx::QueueType::GRAPHICS)
{
imageBarrier.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT;
srcStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
}
if (newOwner == Gfx::QueueType::TRANSFER)
{
imageBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstManager = graphics->getTransferCommands();
}
else if(currentOwner == Gfx::QueueType::DEDICATED_TRANSFER)
{
imageBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstManager = graphics->getDedicatedTransferCommands();
}
else if (newOwner == Gfx::QueueType::COMPUTE)
{
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dstStage = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
dstManager = graphics->getComputeCommands();
}
else if (newOwner == Gfx::QueueType::GRAPHICS)
{
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dstStage = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
dstManager = graphics->getGraphicsCommands();
}
VkCommandBuffer sourceCmd = sourceManager->getCommands()->getHandle();
VkCommandBuffer destCmd = dstManager->getCommands()->getHandle();
vkCmdPipelineBarrier(sourceCmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
vkCmdPipelineBarrier(destCmd, srcStage, dstStage, 0, 0, nullptr, 0, nullptr, 1, &imageBarrier);
sourceManager->submitCommands();
cachedCmdBufferManager = dstManager;
}
void TextureBase::changeLayout(VkImageLayout newLayout)
{
VkImageMemoryBarrier barrier =
init::ImageMemoryBarrier(
textureHandle->image,
textureHandle->layout,
newLayout);
vkCmdPipelineBarrier(textureHandle->getCommands()->getCommands()->getHandle(),
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
0, 0, nullptr, 0, nullptr, 1, &barrier);
textureHandle->layout = newLayout;
}
Texture2D::Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY,
bool bArray, uint32 arraySize, uint32 mipLevels, Gfx::SeFormat format,
uint32 samples, Gfx::SeImageUsageFlags usage, Gfx::QueueType owner, VkImage existingImage)
{
textureHandle = new TextureHandle(graphics, bArray ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D,
sizeX, sizeY, 1, bArray, arraySize, mipLevels, format, samples, usage, owner, existingImage);
} }
Texture2D::~Texture2D() Texture2D::~Texture2D()
{ {
} }
@@ -0,0 +1,243 @@
#include "VulkanGraphicsResources.h"
#include "VulkanGraphics.h"
#include "VulkanInitializer.h"
#include "VulkanGraphicsEnums.h"
#include "VulkanCommandBuffer.h"
#include <glfw/glfw3.h>
using namespace Seele;
using namespace Seele::Vulkan;
Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
: Gfx::Window(createInfo), graphics(graphics), instance(graphics->getInstance())
{
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, createInfo.bFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
windowHandle = handle;
//TODO: callbacks
glfwCreateWindowSurface(instance, handle, nullptr, &surface);
createSwapchain();
}
Window::~Window()
{
vkDestroySurfaceKHR(instance, surface, nullptr);
glfwDestroyWindow(static_cast<GLFWwindow *>(windowHandle));
}
void Window::beginFrame()
{
advanceBackBuffer();
}
void Window::endFrame()
{
present();
}
void Window::onWindowCloseEvent()
{
}
Gfx::PTexture2D Window::getBackBuffer()
{
return backBufferImages[currentImageIndex];
}
void Window::advanceBackBuffer()
{
VkResult res = VK_ERROR_OUT_OF_DATE_KHR;
uint32 imageIndex = 0;
const int32 prevSemaphoreIndex = semaphoreIndex;
semaphoreIndex = (semaphoreIndex + 1) % Gfx::numFramesBuffered;
while (res != VK_SUCCESS)
{
res = vkAcquireNextImageKHR(
graphics->getDevice(),
swapchain,
UINT64_MAX,
imageAcquired[semaphoreIndex]->getHandle(),
VK_NULL_HANDLE,
&imageIndex);
if (res == VK_ERROR_OUT_OF_DATE_KHR)
{
semaphoreIndex = prevSemaphoreIndex;
}
if (res == VK_ERROR_SURFACE_LOST_KHR)
{
semaphoreIndex = prevSemaphoreIndex;
}
}
imageAcquiredSemaphore = imageAcquired[semaphoreIndex];
currentImageIndex = imageIndex;
VkImageMemoryBarrier barrier =
init::ImageMemoryBarrier(
backBufferImages[currentImageIndex]->getHandle(),
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
PCmdBuffer cmdBuffer = graphics->getGraphicsCommands()->getCommands();
vkCmdPipelineBarrier(cmdBuffer->getHandle(),
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
0, 0, nullptr, 0, nullptr, 1, &barrier);
cmdBuffer->addWaitSemaphore(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, imageAcquiredSemaphore);
graphics->getGraphicsCommands()->submitCommands();
}
void Window::recreateSwapchain(const WindowCreateInfo &windowInfo)
{
destroySwapchain();
sizeX = windowInfo.width;
sizeY = windowInfo.height;
pixelFormat = cast(windowInfo.pixelFormat);
bFullscreen = windowInfo.bFullscreen;
uint32_t numFormats;
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, nullptr));
Array<VkSurfaceFormatKHR> formats(numFormats);
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(graphics->getPhysicalDevice(), surface, &numFormats, formats.data()));
uint32_t numPresentModes;
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, nullptr));
Array<VkPresentModeKHR> modes(numPresentModes);
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(graphics->getPhysicalDevice(), surface, &numPresentModes, modes.data()));
chooseSurfaceFormat(formats, windowInfo.pixelFormat);
choosePresentMode(modes);
createSwapchain();
}
void Window::present()
{
backBufferImages[currentImageIndex]->changeLayout(VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
graphics->getGraphicsCommands()->submitCommands(renderFinished[currentImageIndex]);
VkSemaphore renderFinishedHandle = renderFinished[currentImageIndex]->getHandle();
VkPresentInfoKHR info;
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
info.pNext = nullptr;
info.swapchainCount = 1;
info.pSwapchains = &swapchain;
info.pImageIndices = (uint32 *)&currentImageIndex;
info.pResults = 0;
info.waitSemaphoreCount = 1;
info.pWaitSemaphores = &renderFinishedHandle;
VkResult presentResult = VK_ERROR_OUT_OF_DATE_KHR;
// Trial and error
while (presentResult != VK_SUCCESS)
{
presentResult = vkQueuePresentKHR(graphics->getGraphicsCommands()->getQueue()->getHandle(), &info);
}
}
void Window::createSwapchain()
{
VkSurfaceCapabilitiesKHR surfProperties;
VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(graphics->getPhysicalDevice(), surface, &surfProperties));
uint32 desiredNumBuffers = Gfx::numFramesBuffered;
VkExtent2D extent;
extent.width = sizeX;
extent.height = sizeY;
VkSwapchainCreateInfoKHR swapchainInfo =
init::SwapchainCreateInfo(
surface,
desiredNumBuffers,
surfaceFormat.format,
surfaceFormat.colorSpace,
extent,
1,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
presentMode,
VK_TRUE);
VK_CHECK(vkCreateSwapchainKHR(graphics->getDevice(), &swapchainInfo, nullptr, &swapchain));
uint32 numSwapchainImages;
VK_CHECK(vkGetSwapchainImagesKHR(graphics->getDevice(), swapchain, &numSwapchainImages, nullptr));
Array<VkImage> swapchainImages(numSwapchainImages);
VK_CHECK(vkGetSwapchainImagesKHR(graphics->getDevice(), swapchain, &numSwapchainImages, swapchainImages.data()));
PCmdBuffer cmdBuffer = graphics->getGraphicsCommands()->getCommands();
for (uint32 i = 0; i < numSwapchainImages; ++i)
{
imageAcquired[i] = new Semaphore(graphics);
renderFinished[i] = new Semaphore(graphics);
backBufferImages[i] = new Texture2D(graphics, sizeX, sizeY, false, 1, 1,
cast(surfaceFormat.format), 1, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
Gfx::QueueType::GRAPHICS, swapchainImages[i]);
VkClearColorValue clearColor;
std::memset(&clearColor, 0, sizeof(VkClearColorValue));
backBufferImages[i]->changeLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
VkImageSubresourceRange range = init::ImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT);
vkCmdClearColorImage(cmdBuffer->getHandle(), backBufferImages[i]->getHandle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearColor, 1, &range);
backBufferImages[i]->changeLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
}
graphics->getGraphicsCommands()->submitCommands();
currentImageIndex = -1;
}
void Window::destroySwapchain()
{
vkDestroySwapchainKHR(graphics->getDevice(), swapchain, nullptr);
for (uint32 i = 0; i < Gfx::numFramesBuffered; ++i)
{
imageAcquired[i] = nullptr;
}
}
void Window::chooseSurfaceFormat(const Array<VkSurfaceFormatKHR> &available, Gfx::SeFormat preferred)
{
VkFormat preferredFormat = cast(preferred);
for (auto availabeFormat : available)
{
if (availabeFormat.format == preferredFormat)
{
surfaceFormat = availabeFormat;
return;
}
}
if (available.size() == 1 && available[0].format == VK_FORMAT_UNDEFINED)
{
surfaceFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
return;
}
for (const auto &availableFormat : available)
{
if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
{
surfaceFormat = availableFormat;
return;
}
}
surfaceFormat = available[0];
}
void Window::choosePresentMode(const Array<VkPresentModeKHR> &modes)
{
for (auto mode : modes)
{
if (mode == VK_PRESENT_MODE_MAILBOX_KHR)
{
presentMode = mode;
return;
}
}
presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
}
Viewport::Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &viewportInfo)
: Gfx::Viewport(owner, viewportInfo), graphics(graphics)
{
}
Viewport::~Viewport()
{
}
-35
View File
@@ -1,35 +0,0 @@
#include "Window.h"
#include "SceneView.h"
using namespace Seele;
Window::Window(const WindowCreateInfo& createInfo, Gfx::PGraphics graphics)
: width(createInfo.width)
, height(createInfo.height)
, graphics(graphics)
{
center = new Section();
center->resizeArea(Rect(1, 1, 0, 0));
center->addView(new SceneView(graphics));
windowHandle = graphics->createWindow(createInfo);
}
Window::~Window()
{
}
void Window::onWindowCloseEvent()
{
}
void Window::beginFrame()
{
graphics->beginFrame(windowHandle);
center->beginFrame();
}
void Window::endFrame()
{
graphics->endFrame(windowHandle);
}
-69
View File
@@ -1,69 +0,0 @@
#pragma once
#include "GraphicsResources.h"
#include "View.h"
namespace Seele {
// A window is divided into 5 sections, using a border layout
// +--------------TOP------------------+
// | |
// L R
// E I
// F CENTER G
// T H
// | T
// +-------------BOTTOM----------------+
// In every section, there can be any number
// of views, when there are multiple, they stack to tabs
class Section
{
public:
Section()
{}
void resizeArea(Rect area)
{
this->area = area;
}
void beginFrame()
{
views[0]->beginFrame();
}
void endFrame()
{
views[0]->endFrame();
}
void addView(PView view)
{
view->applyArea(area);
views.add(view);
}
void clearViews(PView view)
{
views.clear();
}
void removeView(PView view)
{
views.remove(views.find(view));
}
private:
Rect area;
Array<PView> views;
};
DEFINE_REF(Section)
class Gfx::Graphics;
class Window
{
public:
Window(const WindowCreateInfo& createInfo, Gfx::PGraphics graphics);
~Window();
void onWindowCloseEvent();
void beginFrame();
void endFrame();
private:
void* windowHandle;
PSection center;
uint32 width;
uint32 height;
Gfx::PGraphics graphics;
};
DEFINE_REF(Window)
}
+14 -2
View File
@@ -6,15 +6,27 @@ Seele::WindowManager::WindowManager()
graphics = new Vulkan::Graphics(); graphics = new Vulkan::Graphics();
GraphicsInitializer initializer; GraphicsInitializer initializer;
graphics->init(initializer); graphics->init(initializer);
TextureCreateInfo info;
info.width = 4096;
info.height = 4096;
Gfx::PTexture2D testTexture = graphics->createTexture2D(info);
BulkResourceData resourceData;
resourceData.size = 4096;
resourceData.data = new uint8[4096];
for (int i = 0; i < 4096; ++i)
{
resourceData.data[i] = (uint8)i;
}
Gfx::PUniformBuffer testUniform = graphics->createUniformBuffer(resourceData);
} }
Seele::WindowManager::~WindowManager() Seele::WindowManager::~WindowManager()
{ {
} }
void Seele::WindowManager::addWindow(const WindowCreateInfo& createInfo) void Seele::WindowManager::addWindow(const WindowCreateInfo &createInfo)
{ {
PWindow window = new Window(createInfo, graphics); Gfx::PWindow window = graphics->createWindow(createInfo);
windows.add(window); windows.add(window);
} }
+11 -10
View File
@@ -1,25 +1,26 @@
#pragma once #pragma once
#include "GraphicsResources.h" #include "GraphicsResources.h"
#include "Window.h" #include "Graphics.h"
#include "Containers/Array.h" #include "Containers/Array.h"
namespace Seele namespace Seele
{ {
class WindowManager class WindowManager
{ {
public: public:
WindowManager(); WindowManager();
~WindowManager(); ~WindowManager();
void addWindow(const WindowCreateInfo& createInfo); void addWindow(const WindowCreateInfo &createInfo);
void beginFrame(); void beginFrame();
void endFrame(); void endFrame();
inline bool isActive() const inline bool isActive() const
{ {
return windows.size(); return windows.size();
} }
private:
Array<PWindow> windows; private:
Array<Gfx::PWindow> windows;
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
}; };
DEFINE_REF(WindowManager); DEFINE_REF(WindowManager);
} } // namespace Seele
+16 -16
View File
@@ -3,30 +3,30 @@
namespace Seele namespace Seele
{ {
struct Rect struct Rect
{ {
Rect() Rect()
: size(0, 0) : size(0, 0), offset(0, 0)
, offset(0, 0) {
{} }
Rect(float sizeX, float sizeY, float offsetX, float offsetY) Rect(float sizeX, float sizeY, float offsetX, float offsetY)
: size(sizeX, sizeY) : size(sizeX, sizeY), offset(offsetX, offsetY)
, offset(offsetX, offsetY) {
{} }
Rect(Vector2 size, Vector2 offset) Rect(Vector2 size, Vector2 offset)
: size(size) : size(size), offset(offset)
, offset(offset) {
{} }
bool isEmpty() const bool isEmpty() const
{ {
return size.x == 0 || size.y == 0; return size.x == 0 || size.y == 0;
} }
Vector2 size; Vector2 size;
Vector2 offset; Vector2 offset;
}; };
struct Rect3D struct Rect3D
{ {
Vector3 size; Vector3 size;
Vector3 offset; Vector3 offset;
}; };
} } // namespace Seele
+6 -5
View File
@@ -3,8 +3,9 @@
#include <glm/mat2x2.hpp> #include <glm/mat2x2.hpp>
#include <glm/mat3x3.hpp> #include <glm/mat3x3.hpp>
#include <glm/mat4x4.hpp> #include <glm/mat4x4.hpp>
namespace Seele { namespace Seele
typedef glm::mat2 Matrix2; {
typedef glm::mat3 Matrix3; typedef glm::mat2 Matrix2;
typedef glm::mat4 Matrix4; typedef glm::mat3 Matrix3;
} typedef glm::mat4 Matrix4;
} // namespace Seele
+27 -44
View File
@@ -2,9 +2,8 @@
#include <stdint.h> #include <stdint.h>
namespace Seele namespace Seele
{ {
static uint32_t CRCTablesSB8[8][256] = { static uint32_t CRCTablesSB8[8][256] = {
{ {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
@@ -19,10 +18,8 @@ namespace Seele
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d},
}, {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf,
{
0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf,
0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e,
0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d,
0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c,
@@ -37,10 +34,8 @@ namespace Seele
0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81,
0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0,
0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23,
0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72},
}, {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d,
{
0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d,
0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d,
0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd,
0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad,
@@ -55,10 +50,8 @@ namespace Seele
0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d,
0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d,
0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d,
0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed},
}, {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056,
{
0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056,
0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9,
0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68,
0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7,
@@ -73,10 +66,8 @@ namespace Seele
0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50,
0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf,
0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e,
0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1},
}, {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, 0x825097d1,
{
0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, 0x825097d1,
0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, 0xdfd029e3, 0xe2b00053, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, 0xdfd029e3, 0xe2b00053,
0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xc1c12f04, 0xfca106b4, 0xbb017c64, 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, 0x3951ebb5, 0x7ef19165, 0x4391b8d5,
0xa121b886, 0x9c419136, 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0xa121b886, 0x9c419136, 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57,
@@ -91,10 +82,8 @@ namespace Seele
0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, 0x11852c6a, 0x562556ba, 0x6b457f0a,
0x89f57f59, 0xb49556e9, 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x89f57f59, 0xb49556e9, 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888,
0x28d4c7df, 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, 0x28d4c7df, 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e,
0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, 0xca64c78c 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, 0xca64c78c},
}, {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, 0xf156b2d5,
{
0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, 0xf156b2d5,
0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, 0x39dc63eb, 0xf280b04e, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, 0x39dc63eb, 0xf280b04e,
0x07ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x07ac0536, 0xccf0d693, 0x4a64a43d, 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, 0xbb3216e8, 0x3da66446, 0xf6fab7e3,
0x047a07ad, 0xcf26d408, 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x047a07ad, 0xcf26d408, 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578,
@@ -109,10 +98,8 @@ namespace Seele
0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, 0xad760d6a, 0x2be27fc4, 0xe0beac61,
0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x123e1c2f, 0xd962cf8a, 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa,
0x16441b82, 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, 0x16441b82, 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957,
0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, 0xe4c4abcc 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, 0xe4c4abcc},
}, {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, 0xf64870e9,
{
0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, 0xf64870e9,
0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, 0x37e1e793, 0x9196ec27, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, 0x37e1e793, 0x9196ec27,
0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xcfbd399c, 0x69ca3228, 0x582228b5, 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, 0xae6a585c, 0x9f8242c1, 0x39f54975,
0xa863a552, 0x0e14aee6, 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0xa863a552, 0x0e14aee6, 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb,
@@ -127,10 +114,8 @@ namespace Seele
0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62,
0xabc30345, 0x0db408f1, 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0xabc30345, 0x0db408f1, 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac,
0x03a0a617, 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, 0x03a0a617, 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe,
0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, 0x92364a30 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, 0x92364a30},
}, {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, 0xd92012ac,
{
0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, 0xd92012ac,
0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, 0x69312319, 0xa59b2387, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, 0x69312319, 0xa59b2387,
0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa, 0xf9766256, 0x35dc62c8, 0xbb53652b, 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, 0x62737787, 0xecfc7064, 0x205670fa,
0x85cd537d, 0x496753e3, 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x85cd537d, 0x496753e3, 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1,
@@ -145,24 +130,22 @@ namespace Seele
0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x7aa64737, 0xb60c47a9, 0x3883404a, 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, 0xe1a352e6, 0x6f2c5505, 0xa386559b,
0x061d761c, 0xcab77682, 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x061d761c, 0xcab77682, 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0,
0x83d02561, 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, 0x83d02561, 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd,
0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, 0x264b06e6}};
}
};
template<typename T> template <typename T>
inline constexpr T align(const T ptr, int64_t alignment) inline constexpr T align(const T ptr, int64_t alignment)
{ {
return (T)(((uint64_t)ptr + alignment - 1) & ~(alignment - 1)); return (T)(((uint64_t)ptr + alignment - 1) & ~(alignment - 1));
} }
inline uint32_t memCrc32(const void* InData, int32_t Length, uint32_t CRC = 0) inline uint32_t memCrc32(const void *InData, int32_t Length, uint32_t CRC = 0)
{ {
// Based on the Slicing-by-8 implementation found here: // Based on the Slicing-by-8 implementation found here:
// http://slicing-by-8.sourceforge.net/ // http://slicing-by-8.sourceforge.net/
CRC = ~CRC; CRC = ~CRC;
const uint8_t* __restrict Data = (uint8_t*)InData; const uint8_t *__restrict Data = (uint8_t *)InData;
// First we need to align to 32-bits // First we need to align to 32-bits
int32_t InitBytes = (int32_t)(align(Data, 4) - Data); int32_t InitBytes = (int32_t)(align(Data, 4) - Data);
@@ -176,7 +159,7 @@ namespace Seele
CRC = (CRC >> 8) ^ CRCTablesSB8[0][(CRC & 0xFF) ^ *Data++]; CRC = (CRC >> 8) ^ CRCTablesSB8[0][(CRC & 0xFF) ^ *Data++];
} }
auto Data4 = (const uint32_t*)Data; auto Data4 = (const uint32_t *)Data;
for (uint32_t Repeat = Length / 8; Repeat; --Repeat) for (uint32_t Repeat = Length / 8; Repeat; --Repeat)
{ {
uint32_t V1 = *Data4++ ^ CRC; uint32_t V1 = *Data4++ ^ CRC;
@@ -191,7 +174,7 @@ namespace Seele
CRCTablesSB8[1][(V2 >> 16) & 0xFF] ^ CRCTablesSB8[1][(V2 >> 16) & 0xFF] ^
CRCTablesSB8[0][V2 >> 24]; CRCTablesSB8[0][V2 >> 24];
} }
Data = (const uint8_t*)Data4; Data = (const uint8_t *)Data4;
Length %= 8; Length %= 8;
} }
@@ -202,5 +185,5 @@ namespace Seele
} }
return ~CRC; return ~CRC;
}
} }
} // namespace Seele
+12 -11
View File
@@ -2,16 +2,17 @@
#include <glm/vec2.hpp> #include <glm/vec2.hpp>
#include <glm/vec3.hpp> #include <glm/vec3.hpp>
#include <glm/vec4.hpp> #include <glm/vec4.hpp>
namespace Seele { namespace Seele
typedef glm::vec2 Vector2; {
typedef glm::vec3 Vector3; typedef glm::vec2 Vector2;
typedef glm::vec4 Vector4; typedef glm::vec3 Vector3;
typedef glm::vec4 Vector4;
typedef glm::uvec2 UVector2; typedef glm::uvec2 UVector2;
typedef glm::uvec3 UVector3; typedef glm::uvec3 UVector3;
typedef glm::uvec4 UVector4; typedef glm::uvec4 UVector4;
typedef glm::ivec2 IVector2; typedef glm::ivec2 IVector2;
typedef glm::ivec3 IVector3; typedef glm::ivec3 IVector3;
typedef glm::ivec4 IVector4; typedef glm::ivec4 IVector4;
} } // namespace Seele
+81 -5
View File
@@ -35,15 +35,43 @@ namespace Seele
, refCount(rhs.refCount) , refCount(rhs.refCount)
{ {
} }
RefObject(RefObject&& rhs)
: handle(std::move(rhs.handle))
, refCount(std::move(rhs.refCount))
{}
~RefObject() ~RefObject()
{ {
registeredObjects.erase(handle); registeredObjects.erase(handle);
delete handle; delete handle;
} }
RefObject& operator=(const RefObject& rhs)
{
if(*this != rhs)
{
handle = rhs.handle;
refCount = rhs.refCount;
}
return *this;
}
RefObject& operator=(RefObject&& rhs)
{
if(*this != rhs)
{
handle = std::move(rhs.handle);
refCount = std::move(rhs.refCount);
rhs.handle = nullptr;
rhs.refCount = 0;
}
return *this;
}
bool operator==(const RefObject& other) const bool operator==(const RefObject& other) const
{ {
return handle == other.handle; return handle == other.handle;
} }
bool operator!=(const RefObject& other) const
{
return handle != other.handle;
}
bool operator<(const RefObject& other) const bool operator<(const RefObject& other) const
{ {
return handle < other.handle; return handle < other.handle;
@@ -55,7 +83,7 @@ namespace Seele
void removeRef() void removeRef()
{ {
refCount--; refCount--;
if (refCount.load() <= 0) if (refCount.load() == 0)
{ {
delete this; delete this;
} }
@@ -101,14 +129,23 @@ namespace Seele
} }
RefPtr(const RefPtr& other) RefPtr(const RefPtr& other)
: object(other.object) : object(other.object)
{
if(object != nullptr)
{ {
object->addRef(); object->addRef();
} }
}
RefPtr(RefPtr&& rhs)
: object(std::move(rhs.object))
{
rhs.object = nullptr;
//Dont change references, they stay the same
}
template<typename F> template<typename F>
RefPtr(const RefPtr<F>& other) RefPtr(const RefPtr<F>& other)
{ {
F* f = other.getObject()->getHandle(); F* f = other.getObject()->getHandle();
T* t = static_cast<T*>(f); static_cast<T*>(f);
object = (RefObject<T>*)other.getObject(); object = (RefObject<T>*)other.getObject();
object->addRef(); object->addRef();
} }
@@ -123,27 +160,58 @@ namespace Seele
return nullptr; return nullptr;
} }
RefObject<F>* newObject = (RefObject<F>*)object; RefObject<F>* newObject = (RefObject<F>*)object;
RefPtr<F> result(newObject); return RefPtr<F>(newObject);
return result; }
template<typename F>
const RefPtr<F> cast() const
{
T* t = object->getHandle();
F* f = dynamic_cast<F*>(t);
if (f == nullptr)
{
return nullptr;
}
RefObject<F>* newObject = (RefObject<F>*)object;
return RefPtr<F>(newObject);
} }
RefPtr& operator=(const RefPtr& other) RefPtr& operator=(const RefPtr& other)
{ {
if (this != &other) if (*this != other)
{ {
if (object != nullptr) if (object != nullptr)
{ {
object->removeRef(); object->removeRef();
} }
object = other.object; object = other.object;
if(object != nullptr)
{
object->addRef(); object->addRef();
} }
}
return *this;
}
RefPtr& operator=(RefPtr&& rhs)
{
if(*this != rhs)
{
if(object != nullptr)
{
object->removeRef();
}
object = std::move(rhs.object);
rhs.object = nullptr;
}
return *this; return *this;
} }
~RefPtr() ~RefPtr()
{
if(object != nullptr)
{ {
object->removeRef(); object->removeRef();
} }
}
bool operator==(const RefPtr& other) const bool operator==(const RefPtr& other) const
{ {
return object == other.object; return object == other.object;
@@ -166,6 +234,14 @@ namespace Seele
{ {
return object; return object;
} }
T* getHandle()
{
return object->getHandle();
}
const T* getHandle() const
{
return object->getHandle();
}
private: private:
RefObject<T>* object; RefObject<T>* object;
}; };
+2
View File
@@ -54,6 +54,8 @@ BOOST_AUTO_TEST_CASE(inheritance_cast)
Seele::RefPtr<TestStruct> base = derived; Seele::RefPtr<TestStruct> base = derived;
BOOST_REQUIRE_EQUAL(base->data, 10); BOOST_REQUIRE_EQUAL(base->data, 10);
backCast = base.cast<DerivedStruct>(); backCast = base.cast<DerivedStruct>();
BOOST_REQUIRE_EQUAL(backCast->data, 10);
BOOST_REQUIRE_EQUAL(backCast->data2, 20);
} }
BOOST_REQUIRE_EQUAL(backCast->data, 10); BOOST_REQUIRE_EQUAL(backCast->data, 10);
BOOST_REQUIRE_EQUAL(backCast->data2, 20); BOOST_REQUIRE_EQUAL(backCast->data2, 20);
+3 -3
View File
@@ -1,12 +1,12 @@
#include "EngineTest.h" #include "EngineTest.h"
#include "Graphics/GraphicsResources.h" #include "Graphics/Vulkan/VulkanGraphics.h"
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
using namespace Seele; using namespace Seele;
BOOST_AUTO_TEST_SUITE(DescriptorSets) BOOST_AUTO_TEST_SUITE(Vulkan)
BOOST_AUTO_TEST_CASE(descriptor_set_merge) BOOST_AUTO_TEST_CASE(init)
{ {
} }