implementing renderpass and vieport
This commit is contained in:
Vendored
+10
-2
@@ -13,7 +13,15 @@
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}/bin/Debug",
|
||||
"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",
|
||||
@@ -25,6 +33,6 @@
|
||||
"cwd": "${workspaceRoot}/bin/Debug/test",
|
||||
"environment": [],
|
||||
"externalConsole": false
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
Vendored
+5
-2
@@ -11,6 +11,9 @@
|
||||
"xiosbase": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xtree": "cpp",
|
||||
"type_traits": "cpp"
|
||||
}
|
||||
"type_traits": "cpp",
|
||||
"vector": "cpp",
|
||||
"*.rh": "cpp",
|
||||
"memory": "cpp"
|
||||
},
|
||||
}
|
||||
@@ -58,6 +58,12 @@ target_link_libraries(SeeleEngine ${Vulkan_LIBRARY})
|
||||
target_link_libraries(SeeleEngine glfw ${GLFW_LIBRARIES})
|
||||
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_custom_command(TARGET SeeleEngine POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPENDENT_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>)
|
||||
|
||||
+137
-91
@@ -10,26 +10,24 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
template<typename T>
|
||||
struct Array
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
struct Array
|
||||
{
|
||||
public:
|
||||
Array()
|
||||
: allocated(DEFAULT_ALLOC_SIZE)
|
||||
, arraySize(0)
|
||||
: allocated(DEFAULT_ALLOC_SIZE), arraySize(0)
|
||||
{
|
||||
_data = (T*)malloc(DEFAULT_ALLOC_SIZE * sizeof(T));
|
||||
_data = new T[DEFAULT_ALLOC_SIZE];
|
||||
assert(_data != nullptr);
|
||||
memset(_data, 0, sizeof(T) * DEFAULT_ALLOC_SIZE);
|
||||
refreshIterators();
|
||||
}
|
||||
Array(size_t size, T value = T())
|
||||
: allocated(size)
|
||||
, arraySize(size)
|
||||
Array(uint32 size, T value = T())
|
||||
: allocated(size), arraySize(size)
|
||||
{
|
||||
_data = (T*)malloc(size * sizeof(T));
|
||||
_data = new T[size];
|
||||
assert(_data != nullptr);
|
||||
for (int i = 0; i < size; ++i)
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
{
|
||||
assert(i < size);
|
||||
_data[i] = value;
|
||||
@@ -37,10 +35,9 @@ namespace Seele
|
||||
refreshIterators();
|
||||
}
|
||||
Array(std::initializer_list<T> init)
|
||||
: allocated(init.size())
|
||||
, arraySize(init.size())
|
||||
: allocated((uint32)init.size()), arraySize((uint32)init.size())
|
||||
{
|
||||
_data = (T*)malloc(init.size() * sizeof(T));
|
||||
_data = new T[init.size()];
|
||||
auto it = init.begin();
|
||||
for (size_t i = 0; it != init.end(); i++, it++)
|
||||
{
|
||||
@@ -49,18 +46,16 @@ namespace Seele
|
||||
}
|
||||
refreshIterators();
|
||||
}
|
||||
Array(const Array& other)
|
||||
: allocated(other.allocated)
|
||||
, arraySize(other.arraySize)
|
||||
Array(const Array &other)
|
||||
: allocated(other.allocated), arraySize(other.arraySize)
|
||||
{
|
||||
_data = (T*)malloc(other.allocated * sizeof(T));
|
||||
_data = new T[other.allocated];
|
||||
assert(_data != nullptr);
|
||||
std::memcpy(_data, other._data, sizeof(T) * allocated);
|
||||
refreshIterators();
|
||||
}
|
||||
Array(Array&& other) noexcept
|
||||
: allocated(std::move(other.allocated))
|
||||
, arraySize(std::move(other.arraySize))
|
||||
Array(Array &&other) noexcept
|
||||
: allocated(std::move(other.allocated)), arraySize(std::move(other.arraySize))
|
||||
{
|
||||
_data = other._data;
|
||||
other._data = nullptr;
|
||||
@@ -68,29 +63,29 @@ namespace Seele
|
||||
other.arraySize = 0;
|
||||
refreshIterators();
|
||||
}
|
||||
Array& operator=(const Array& other) noexcept
|
||||
Array &operator=(const Array &other) noexcept
|
||||
{
|
||||
if(*this != other)
|
||||
if (*this != other)
|
||||
{
|
||||
if (_data != nullptr)
|
||||
{
|
||||
free(_data);
|
||||
delete[] _data;
|
||||
}
|
||||
allocated = other.allocated;
|
||||
arraySize = other.arraySize;
|
||||
_data = (T*)malloc(other.allocated * sizeof(T));
|
||||
_data = new T[other.allocated];
|
||||
std::memcpy(_data, other._data, sizeof(T) * allocated);
|
||||
refreshIterators();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Array& operator=(Array&& other) noexcept
|
||||
Array &operator=(Array &&other) noexcept
|
||||
{
|
||||
if(*this != other)
|
||||
if (*this != other)
|
||||
{
|
||||
if (_data != nullptr)
|
||||
{
|
||||
free(_data);
|
||||
delete[] _data;
|
||||
}
|
||||
allocated = std::move(other.allocated);
|
||||
arraySize = std::move(other.arraySize);
|
||||
@@ -101,27 +96,30 @@ namespace Seele
|
||||
}
|
||||
~Array()
|
||||
{
|
||||
if(_data)
|
||||
if (_data)
|
||||
{
|
||||
free(_data);
|
||||
delete[] _data;
|
||||
_data = nullptr;
|
||||
}
|
||||
}
|
||||
template<typename X>
|
||||
class IteratorBase {
|
||||
template <typename X>
|
||||
class IteratorBase
|
||||
{
|
||||
public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef X value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef X& reference;
|
||||
typedef X* pointer;
|
||||
typedef X &reference;
|
||||
typedef X *pointer;
|
||||
|
||||
IteratorBase(X* x = nullptr)
|
||||
IteratorBase(X *x = nullptr)
|
||||
: p(x)
|
||||
{}
|
||||
IteratorBase(const IteratorBase& i)
|
||||
{
|
||||
}
|
||||
IteratorBase(const IteratorBase &i)
|
||||
: p(i.p)
|
||||
{}
|
||||
{
|
||||
}
|
||||
reference operator*() const
|
||||
{
|
||||
return *p;
|
||||
@@ -130,55 +128,60 @@ namespace Seele
|
||||
{
|
||||
return p;
|
||||
}
|
||||
inline bool operator!=(const IteratorBase& other)
|
||||
inline bool operator!=(const IteratorBase &other)
|
||||
{
|
||||
return p != other.p;
|
||||
}
|
||||
inline bool operator==(const IteratorBase& other)
|
||||
inline bool operator==(const IteratorBase &other)
|
||||
{
|
||||
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++;
|
||||
return *this;
|
||||
}
|
||||
IteratorBase& operator--() {
|
||||
IteratorBase &operator--()
|
||||
{
|
||||
p--;
|
||||
return *this;
|
||||
}
|
||||
IteratorBase operator++(int) {
|
||||
IteratorBase operator++(int)
|
||||
{
|
||||
IteratorBase tmp(*this);
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
IteratorBase operator--(int) {
|
||||
IteratorBase operator--(int)
|
||||
{
|
||||
IteratorBase tmp(*this);
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
X* p;
|
||||
X *p;
|
||||
};
|
||||
typedef IteratorBase<T> Iterator;
|
||||
typedef IteratorBase<const T> ConstIterator;
|
||||
|
||||
bool operator==(const Array& other)
|
||||
bool operator==(const Array &other)
|
||||
{
|
||||
return _data == other._data;
|
||||
}
|
||||
|
||||
bool operator!=(const Array& other)
|
||||
bool operator!=(const Array &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)
|
||||
{
|
||||
@@ -191,23 +194,33 @@ namespace Seele
|
||||
{
|
||||
return beginIt;
|
||||
}
|
||||
Iterator begin() const
|
||||
{
|
||||
return beginIt;
|
||||
}
|
||||
Iterator end()
|
||||
{
|
||||
return endIt;
|
||||
}
|
||||
Iterator end() const
|
||||
{
|
||||
return endIt;
|
||||
}
|
||||
|
||||
T& add(const T& item)
|
||||
T &add(const T &item = T())
|
||||
{
|
||||
if (arraySize == allocated)
|
||||
{
|
||||
uint32 newSize = arraySize + 1;
|
||||
allocated = calculateGrowth(newSize);
|
||||
void* tempArray = malloc(sizeof(T) * allocated);
|
||||
T *tempArray = new T[allocated];
|
||||
assert(tempArray != nullptr);
|
||||
std::memset(tempArray, 0, sizeof(T) * allocated);
|
||||
std::memcpy(tempArray, _data, arraySize * sizeof(T));
|
||||
delete _data;
|
||||
_data = (T*)tempArray;
|
||||
for (uint32 i = 0; i < arraySize; ++i)
|
||||
{
|
||||
tempArray[i] = _data[i];
|
||||
}
|
||||
delete[] _data;
|
||||
_data = tempArray;
|
||||
}
|
||||
_data[arraySize++] = item;
|
||||
refreshIterators();
|
||||
@@ -231,6 +244,8 @@ namespace Seele
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
delete[] _data;
|
||||
_data = nullptr;
|
||||
arraySize = 0;
|
||||
allocated = 0;
|
||||
refreshIterators();
|
||||
@@ -243,7 +258,7 @@ namespace Seele
|
||||
}
|
||||
else
|
||||
{
|
||||
T* newData = (T*)malloc(newSize * sizeof(T));
|
||||
T *newData = new T[newSize];
|
||||
assert(newData != nullptr);
|
||||
allocated = newSize;
|
||||
std::memcpy(newData, _data, sizeof(T) * arraySize);
|
||||
@@ -261,11 +276,11 @@ namespace Seele
|
||||
{
|
||||
return allocated;
|
||||
}
|
||||
inline T* data() const
|
||||
inline T *data() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
T& back() const
|
||||
T &back() const
|
||||
{
|
||||
return _data[arraySize - 1];
|
||||
}
|
||||
@@ -273,23 +288,47 @@ namespace Seele
|
||||
{
|
||||
arraySize--;
|
||||
}
|
||||
T& operator[](int index) const
|
||||
T &operator[](uint32 index)
|
||||
{
|
||||
assert(index >= 0 && index < arraySize);
|
||||
assert(index < arraySize);
|
||||
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
|
||||
{
|
||||
const uint32 oldCapacity = capacity();
|
||||
|
||||
if (oldCapacity > UINT32_MAX - oldCapacity / 2) {
|
||||
if (oldCapacity > UINT32_MAX - oldCapacity / 2)
|
||||
{
|
||||
return newSize; // geometric growth would overflow
|
||||
}
|
||||
|
||||
const uint32 geometric = oldCapacity + oldCapacity / 2;
|
||||
|
||||
if (geometric < newSize) {
|
||||
if (geometric < newSize)
|
||||
{
|
||||
return newSize; // geometric growth would be insufficient
|
||||
}
|
||||
|
||||
@@ -304,13 +343,13 @@ namespace Seele
|
||||
uint32 allocated;
|
||||
Iterator beginIt;
|
||||
Iterator endIt;
|
||||
T* _data;
|
||||
};
|
||||
T *_data;
|
||||
};
|
||||
|
||||
template<typename T, uint32 N>
|
||||
struct StaticArray
|
||||
{
|
||||
public:
|
||||
template <typename T, uint32 N>
|
||||
struct StaticArray
|
||||
{
|
||||
public:
|
||||
StaticArray()
|
||||
{
|
||||
beginIt = Iterator(_data);
|
||||
@@ -326,37 +365,41 @@ namespace Seele
|
||||
endIt = Iterator(_data + N);
|
||||
}
|
||||
~StaticArray()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
inline uint32 size() const
|
||||
{
|
||||
return N;
|
||||
}
|
||||
inline T* data() const
|
||||
inline T *data() const
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
T& operator[](int index)
|
||||
T &operator[](int index)
|
||||
{
|
||||
assert(index >= 0 && index < N);
|
||||
return _data[index];
|
||||
}
|
||||
|
||||
template<typename X>
|
||||
class IteratorBase {
|
||||
template <typename X>
|
||||
class IteratorBase
|
||||
{
|
||||
public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef X value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef X& reference;
|
||||
typedef X* pointer;
|
||||
typedef X &reference;
|
||||
typedef X *pointer;
|
||||
|
||||
IteratorBase(X* x = nullptr)
|
||||
IteratorBase(X *x = nullptr)
|
||||
: p(x)
|
||||
{}
|
||||
IteratorBase(const IteratorBase& i)
|
||||
{
|
||||
}
|
||||
IteratorBase(const IteratorBase &i)
|
||||
: p(i.p)
|
||||
{}
|
||||
{
|
||||
}
|
||||
reference operator*() const
|
||||
{
|
||||
return *p;
|
||||
@@ -365,32 +408,35 @@ namespace Seele
|
||||
{
|
||||
return p;
|
||||
}
|
||||
inline bool operator!=(const IteratorBase& other)
|
||||
inline bool operator!=(const IteratorBase &other)
|
||||
{
|
||||
return p != other.p;
|
||||
}
|
||||
inline bool operator==(const IteratorBase& other)
|
||||
inline bool operator==(const IteratorBase &other)
|
||||
{
|
||||
return p == other.p;
|
||||
}
|
||||
IteratorBase& operator++() {
|
||||
IteratorBase &operator++()
|
||||
{
|
||||
p++;
|
||||
return *this;
|
||||
}
|
||||
IteratorBase operator++(int) {
|
||||
IteratorBase operator++(int)
|
||||
{
|
||||
IteratorBase tmp(*this);
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
X* p;
|
||||
X *p;
|
||||
};
|
||||
typedef IteratorBase<T> Iterator;
|
||||
typedef IteratorBase<const T> ConstIterator;
|
||||
|
||||
private:
|
||||
private:
|
||||
T _data[N];
|
||||
Iterator beginIt;
|
||||
Iterator endIt;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -2,17 +2,18 @@
|
||||
#include "MinimalEngine.h"
|
||||
namespace Seele
|
||||
{
|
||||
template<typename T>
|
||||
class List
|
||||
{
|
||||
private:
|
||||
template <typename T>
|
||||
class List
|
||||
{
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
Node* prev;
|
||||
Node* next;
|
||||
Node *prev;
|
||||
Node *next;
|
||||
T data;
|
||||
};
|
||||
public:
|
||||
|
||||
public:
|
||||
List()
|
||||
{
|
||||
root = nullptr;
|
||||
@@ -25,21 +26,24 @@ namespace Seele
|
||||
{
|
||||
clear();
|
||||
}
|
||||
template<typename X>
|
||||
class IteratorBase {
|
||||
template <typename X>
|
||||
class IteratorBase
|
||||
{
|
||||
public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef X value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef X& reference;
|
||||
typedef X* pointer;
|
||||
typedef X &reference;
|
||||
typedef X *pointer;
|
||||
|
||||
IteratorBase(Node* x = nullptr)
|
||||
IteratorBase(Node *x = nullptr)
|
||||
: node(x)
|
||||
{}
|
||||
IteratorBase(const IteratorBase& i)
|
||||
{
|
||||
}
|
||||
IteratorBase(const IteratorBase &i)
|
||||
: node(i.node)
|
||||
{}
|
||||
{
|
||||
}
|
||||
reference operator*() const
|
||||
{
|
||||
return node->data;
|
||||
@@ -48,44 +52,49 @@ namespace Seele
|
||||
{
|
||||
return &node->data;
|
||||
}
|
||||
inline bool operator!=(const IteratorBase& other)
|
||||
inline bool operator!=(const IteratorBase &other)
|
||||
{
|
||||
return node != other.node;
|
||||
}
|
||||
inline bool operator==(const IteratorBase& other)
|
||||
inline bool operator==(const IteratorBase &other)
|
||||
{
|
||||
return node == other.node;
|
||||
}
|
||||
IteratorBase& operator--() {
|
||||
IteratorBase &operator--()
|
||||
{
|
||||
node = node->prev;
|
||||
return *this;
|
||||
}
|
||||
IteratorBase operator--(int) {
|
||||
IteratorBase operator--(int)
|
||||
{
|
||||
IteratorBase tmp(*this);
|
||||
--* this;
|
||||
--*this;
|
||||
return tmp;
|
||||
}
|
||||
IteratorBase& operator++() {
|
||||
IteratorBase &operator++()
|
||||
{
|
||||
node = node->next;
|
||||
return *this;
|
||||
}
|
||||
IteratorBase operator++(int) {
|
||||
IteratorBase operator++(int)
|
||||
{
|
||||
IteratorBase tmp(*this);
|
||||
++* this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
Node* node;
|
||||
Node *node;
|
||||
friend class List<T>;
|
||||
};
|
||||
typedef IteratorBase<T> Iterator;
|
||||
typedef IteratorBase<const T> ConstIterator;
|
||||
|
||||
T& front()
|
||||
T &front()
|
||||
{
|
||||
return root->data;
|
||||
}
|
||||
T& back()
|
||||
T &back()
|
||||
{
|
||||
return tail->prev->data;
|
||||
}
|
||||
@@ -95,7 +104,7 @@ namespace Seele
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Node* tmp = root; tmp != tail;)
|
||||
for (Node *tmp = root; tmp != tail;)
|
||||
{
|
||||
tmp = tmp->next;
|
||||
delete tmp->prev;
|
||||
@@ -105,7 +114,7 @@ namespace Seele
|
||||
root = nullptr;
|
||||
}
|
||||
//Insert at the end
|
||||
Iterator add(const T& value)
|
||||
Iterator add(const T &value)
|
||||
{
|
||||
if (root == nullptr)
|
||||
{
|
||||
@@ -113,7 +122,7 @@ namespace Seele
|
||||
tail = root;
|
||||
}
|
||||
tail->data = value;
|
||||
Node* newTail = new Node();
|
||||
Node *newTail = new Node();
|
||||
newTail->prev = tail;
|
||||
newTail->next = nullptr;
|
||||
tail->next = newTail;
|
||||
@@ -126,8 +135,8 @@ namespace Seele
|
||||
Iterator remove(Iterator pos)
|
||||
{
|
||||
size--;
|
||||
Node* prev = pos.node->prev;
|
||||
Node* next = pos.node->next;
|
||||
Node *prev = pos.node->prev;
|
||||
Node *next = pos.node->next;
|
||||
if (prev == nullptr)
|
||||
{
|
||||
root = next;
|
||||
@@ -141,7 +150,7 @@ namespace Seele
|
||||
refreshIterators();
|
||||
return Iterator(next);
|
||||
}
|
||||
Iterator insert(Iterator pos, const T& value)
|
||||
Iterator insert(Iterator pos, const T &value)
|
||||
{
|
||||
size++;
|
||||
if (root == nullptr)
|
||||
@@ -156,8 +165,8 @@ namespace Seele
|
||||
refreshIterators();
|
||||
return beginIt;
|
||||
}
|
||||
Node* tmp = pos.node->prev;
|
||||
Node* newNode = new Node();
|
||||
Node *tmp = pos.node->prev;
|
||||
Node *newNode = new Node();
|
||||
newNode->data = value;
|
||||
tmp->next = newNode;
|
||||
newNode->prev = tmp;
|
||||
@@ -165,9 +174,9 @@ namespace Seele
|
||||
pos.node->prev = 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))
|
||||
{
|
||||
@@ -193,16 +202,16 @@ namespace Seele
|
||||
return endIt;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void refreshIterators()
|
||||
{
|
||||
beginIt = Iterator(root);
|
||||
endIt = Iterator(tail);
|
||||
}
|
||||
Node* root;
|
||||
Node* tail;
|
||||
Node *root;
|
||||
Node *tail;
|
||||
Iterator beginIt;
|
||||
Iterator endIt;
|
||||
uint32 size;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
+155
-128
@@ -3,80 +3,81 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
template<typename K, typename V>
|
||||
struct Pair
|
||||
{
|
||||
public:
|
||||
template <typename K, typename V>
|
||||
struct Pair
|
||||
{
|
||||
public:
|
||||
Pair()
|
||||
: key(K())
|
||||
, value(V())
|
||||
{}
|
||||
: key(K()), value(V())
|
||||
{
|
||||
}
|
||||
Pair(K key, V value)
|
||||
: key(key)
|
||||
, value(value)
|
||||
{}
|
||||
: key(key), value(value)
|
||||
{
|
||||
}
|
||||
K key;
|
||||
V value;
|
||||
};
|
||||
template<typename K, typename V>
|
||||
struct Map
|
||||
{
|
||||
private:
|
||||
};
|
||||
template <typename K, typename V>
|
||||
struct Map
|
||||
{
|
||||
private:
|
||||
struct Node
|
||||
{
|
||||
Pair<K, V> pair;
|
||||
Node* leftChild;
|
||||
Node* rightChild;
|
||||
Node(const K& key)
|
||||
: leftChild(nullptr)
|
||||
, rightChild(nullptr)
|
||||
, pair(key, V())
|
||||
{}
|
||||
Node *leftChild;
|
||||
Node *rightChild;
|
||||
Node(const K &key)
|
||||
: leftChild(nullptr), rightChild(nullptr), pair(key, V())
|
||||
{
|
||||
}
|
||||
Node()
|
||||
: leftChild(nullptr)
|
||||
, rightChild(nullptr)
|
||||
, pair(K(), V())
|
||||
{}
|
||||
: leftChild(nullptr), rightChild(nullptr), pair(K(), V())
|
||||
{
|
||||
}
|
||||
~Node()
|
||||
{
|
||||
if(leftChild != nullptr)
|
||||
if (leftChild != nullptr)
|
||||
{
|
||||
delete leftChild;
|
||||
}
|
||||
if(rightChild != nullptr)
|
||||
if (rightChild != nullptr)
|
||||
{
|
||||
delete rightChild;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
Map()
|
||||
: root(nullptr)
|
||||
{}
|
||||
: root(nullptr), _size(0)
|
||||
{
|
||||
}
|
||||
~Map()
|
||||
{
|
||||
delete root;
|
||||
}
|
||||
class Iterator {
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef Pair<K, V> value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef Pair<K, V>& reference;
|
||||
typedef Pair<K, V>* pointer;
|
||||
typedef Pair<K, V> &reference;
|
||||
typedef Pair<K, V> *pointer;
|
||||
|
||||
Iterator(Node* x = nullptr)
|
||||
Iterator(Node *x = nullptr)
|
||||
: node(x)
|
||||
{}
|
||||
Iterator(Node* x, Array<Node*>&& beginIt)
|
||||
: node(x)
|
||||
, traversal(std::move(beginIt))
|
||||
{}
|
||||
Iterator(const Iterator& i)
|
||||
: node(i.node)
|
||||
, traversal(i.traversal)
|
||||
{}
|
||||
{
|
||||
}
|
||||
Iterator(Node *x, Array<Node *> &&beginIt)
|
||||
: node(x), traversal(std::move(beginIt))
|
||||
{
|
||||
}
|
||||
Iterator(const Iterator &i)
|
||||
: node(i.node), traversal(i.traversal)
|
||||
{
|
||||
}
|
||||
reference operator*() const
|
||||
{
|
||||
return node->pair;
|
||||
@@ -85,67 +86,73 @@ namespace Seele
|
||||
{
|
||||
return &node->pair;
|
||||
}
|
||||
inline bool operator!=(const Iterator& other)
|
||||
inline bool operator!=(const Iterator &other)
|
||||
{
|
||||
return node != other.node;
|
||||
}
|
||||
inline bool operator==(const Iterator& other)
|
||||
inline bool operator==(const Iterator &other)
|
||||
{
|
||||
return node == other.node;
|
||||
}
|
||||
Iterator& operator++() {
|
||||
Iterator &operator++()
|
||||
{
|
||||
node = node->rightChild;
|
||||
while(node != nullptr && node->leftChild != nullptr)
|
||||
while (node != nullptr && node->leftChild != nullptr)
|
||||
{
|
||||
traversal.add(node);
|
||||
node = node->leftChild;
|
||||
}
|
||||
if(node == nullptr && traversal.size() > 0)
|
||||
if (node == nullptr && traversal.size() > 0)
|
||||
{
|
||||
node = traversal.back();
|
||||
traversal.pop();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Iterator& operator--() {
|
||||
Iterator &operator--()
|
||||
{
|
||||
node = node->leftChild;
|
||||
while(node != nullptr && node->rightchild != nullptr)
|
||||
while (node != nullptr && node->rightchild != nullptr)
|
||||
{
|
||||
traversal.add(node);
|
||||
node = node->rightChild;
|
||||
}
|
||||
if(node == nullptr && traversal.size() > 0)
|
||||
if (node == nullptr && traversal.size() > 0)
|
||||
{
|
||||
node = traversal.back();
|
||||
traversal.pop();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Iterator operator--(int) {
|
||||
Iterator operator--(int)
|
||||
{
|
||||
Iterator tmp(*this);
|
||||
++* this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
Iterator operator++(int) {
|
||||
Iterator operator++(int)
|
||||
{
|
||||
Iterator tmp(*this);
|
||||
++* this;
|
||||
++*this;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private:
|
||||
Node* node;
|
||||
Array<Node*> traversal;
|
||||
Node *node;
|
||||
Array<Node *> traversal;
|
||||
};
|
||||
V& operator[](const K& key)
|
||||
V &operator[](const K &key)
|
||||
{
|
||||
root = splay(root, key);
|
||||
if (root == nullptr || root->pair.key < key || key < root->pair.key)
|
||||
{
|
||||
root = insert(root, key);
|
||||
_size++;
|
||||
}
|
||||
refreshIterators();
|
||||
return root->pair.value;
|
||||
}
|
||||
Iterator find(const K& key)
|
||||
Iterator find(const K &key)
|
||||
{
|
||||
root = splay(root, key);
|
||||
if (root == nullptr || root->pair.key != key)
|
||||
@@ -154,13 +161,20 @@ namespace Seele
|
||||
}
|
||||
return Iterator(root);
|
||||
}
|
||||
Iterator erase(const K& key)
|
||||
Iterator erase(const K &key)
|
||||
{
|
||||
root = remove(root, key);
|
||||
refreshIterators();
|
||||
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;
|
||||
}
|
||||
@@ -172,18 +186,27 @@ namespace Seele
|
||||
{
|
||||
return endIt;
|
||||
}
|
||||
private:
|
||||
bool empty() const
|
||||
{
|
||||
return root == nullptr;
|
||||
}
|
||||
uint32 size() const
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
private:
|
||||
void refreshIterators()
|
||||
{
|
||||
Node* beginNode = root;
|
||||
if(root == nullptr)
|
||||
Node *beginNode = root;
|
||||
if (root == nullptr)
|
||||
{
|
||||
beginIt = Iterator(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array<Node*> beginTraversal;
|
||||
while(beginNode != nullptr)
|
||||
Array<Node *> beginTraversal;
|
||||
while (beginNode != nullptr)
|
||||
{
|
||||
beginTraversal.add(beginNode);
|
||||
beginNode = beginNode->leftChild;
|
||||
@@ -192,15 +215,15 @@ namespace Seele
|
||||
beginTraversal.pop();
|
||||
beginIt = Iterator(beginNode, std::move(beginTraversal));
|
||||
}
|
||||
Node* endNode = root;
|
||||
if(root == nullptr)
|
||||
Node *endNode = root;
|
||||
if (root == nullptr)
|
||||
{
|
||||
endIt = Iterator(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array<Node*> endTraversal;
|
||||
while(endNode != nullptr)
|
||||
Array<Node *> endTraversal;
|
||||
while (endNode != nullptr)
|
||||
{
|
||||
endTraversal.add(endNode);
|
||||
endNode = endNode->rightChild;
|
||||
@@ -208,129 +231,133 @@ namespace Seele
|
||||
endIt = Iterator(endNode, std::move(endTraversal));
|
||||
}
|
||||
}
|
||||
Node* root;
|
||||
Node *root;
|
||||
Iterator beginIt;
|
||||
Iterator endIt;
|
||||
Node* rotateRight(Node* node)
|
||||
uint32 _size;
|
||||
Node *rotateRight(Node *node)
|
||||
{
|
||||
Node* y = node->leftChild;
|
||||
Node *y = node->leftChild;
|
||||
node->leftChild = y->rightChild;
|
||||
y->rightChild = node;
|
||||
return y;
|
||||
}
|
||||
Node* rotateLeft(Node* node)
|
||||
Node *rotateLeft(Node *node)
|
||||
{
|
||||
Node* y = node->rightChild;
|
||||
Node *y = node->rightChild;
|
||||
node->rightChild = y->leftChild;
|
||||
y->leftChild = node;
|
||||
return y;
|
||||
}
|
||||
Node* makeNode(const K& key)
|
||||
Node *makeNode(const K &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->leftChild = root->leftChild;
|
||||
root->leftChild = nullptr;
|
||||
newNode->rightChild = r;
|
||||
newNode->leftChild = r->leftChild;
|
||||
r->leftChild = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
newNode->leftChild = root;
|
||||
newNode->rightChild = root->rightChild;
|
||||
root->rightChild = nullptr;
|
||||
newNode->leftChild = r;
|
||||
newNode->rightChild = r->rightChild;
|
||||
r->rightChild = nullptr;
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
Node* remove(Node* root, const K& key)
|
||||
Node *remove(Node *r, const K &key)
|
||||
{
|
||||
Node* temp;
|
||||
if (!root)
|
||||
Node *temp;
|
||||
if (!r)
|
||||
return nullptr;
|
||||
|
||||
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;
|
||||
|
||||
if (!root->leftChild)
|
||||
if (!r->leftChild)
|
||||
{
|
||||
temp = root;
|
||||
root = root->rightChild;
|
||||
temp = r;
|
||||
r = r->rightChild;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = root;
|
||||
temp = r;
|
||||
|
||||
root = splay(root->leftChild, key);
|
||||
root->rightChild = temp->rightChild;
|
||||
r = splay(r->leftChild, key);
|
||||
r->rightChild = temp->rightChild;
|
||||
}
|
||||
temp->leftChild = nullptr;
|
||||
temp->rightChild = nullptr;
|
||||
_size--;
|
||||
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)
|
||||
return root;
|
||||
if (r->leftChild == nullptr)
|
||||
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
|
||||
{
|
||||
if (root->rightChild == nullptr)
|
||||
return root;
|
||||
if (r->rightChild == nullptr)
|
||||
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);
|
||||
root = rotateLeft(root);
|
||||
r->rightChild->rightChild = splay(r->rightChild->rightChild, key);
|
||||
r = rotateLeft(r);
|
||||
}
|
||||
return (root->rightChild == nullptr) ? root : rotateLeft(root);
|
||||
return (r->rightChild == nullptr) ? r : rotateLeft(r);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -14,8 +14,6 @@ target_sources(SeeleEngine
|
||||
SceneView.cpp
|
||||
WindowManager.h
|
||||
WindowManager.cpp
|
||||
Window.h
|
||||
Window.cpp
|
||||
GraphicsResources.h
|
||||
GraphicsResources.cpp
|
||||
GraphicsEnums.h)
|
||||
|
||||
@@ -9,5 +9,4 @@ Graphics::Graphics()
|
||||
|
||||
Graphics::~Graphics()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,22 +3,32 @@
|
||||
#include "GraphicsResources.h"
|
||||
#include "Containers/Array.h"
|
||||
|
||||
namespace Seele {
|
||||
namespace Gfx
|
||||
{
|
||||
class Window;
|
||||
class Graphics
|
||||
{
|
||||
public:
|
||||
namespace Seele
|
||||
{
|
||||
namespace Gfx
|
||||
{
|
||||
class Graphics
|
||||
{
|
||||
public:
|
||||
Graphics();
|
||||
~Graphics();
|
||||
virtual ~Graphics();
|
||||
virtual void init(GraphicsInitializer initializer) = 0;
|
||||
virtual void beginFrame(void* windowHandle) = 0;
|
||||
virtual void endFrame(void* windowHandle) = 0;
|
||||
virtual void* createWindow(const WindowCreateInfo& createInfo) = 0;
|
||||
protected:
|
||||
virtual PWindow createWindow(const WindowCreateInfo &createInfo) = 0;
|
||||
virtual PViewport createViewport(PWindow owner, const ViewportCreateInfo &createInfo) = 0;
|
||||
|
||||
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;
|
||||
};
|
||||
DEFINE_REF(Graphics);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(Graphics);
|
||||
} // namespace Gfx
|
||||
} // namespace Seele
|
||||
+294
-217
@@ -2,15 +2,18 @@
|
||||
#include "MinimalEngine.h"
|
||||
namespace Seele
|
||||
{
|
||||
namespace Gfx
|
||||
{
|
||||
static bool useAsyncCompute = true;
|
||||
namespace Gfx
|
||||
{
|
||||
static constexpr bool useAsyncCompute = true;
|
||||
static constexpr bool waitIdleOnSubmit = false;
|
||||
static constexpr uint32 numFramesBuffered = 3;
|
||||
|
||||
typedef uint32_t SeFlags;
|
||||
typedef uint32_t SeBool32;
|
||||
typedef uint64_t SeDeviceSize;
|
||||
typedef uint32_t SeSampleMask;
|
||||
typedef enum SeResult {
|
||||
typedef uint32_t SeFlags;
|
||||
typedef uint32_t SeBool32;
|
||||
typedef uint64_t SeDeviceSize;
|
||||
typedef uint32_t SeSampleMask;
|
||||
typedef enum SeResult
|
||||
{
|
||||
SE_SUCCESS = 0,
|
||||
SE_NOT_READY = 1,
|
||||
SE_TIMEOUT = 2,
|
||||
@@ -49,9 +52,10 @@ namespace Seele
|
||||
SE_RESULT_END_RANGE = SE_INCOMPLETE,
|
||||
SE_RESULT_RANGE_SIZE = (SE_INCOMPLETE - SE_ERROR_FRAGMENTED_POOL + 1),
|
||||
SE_RESULT_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeResult;
|
||||
} SeResult;
|
||||
|
||||
typedef enum SeStructureType {
|
||||
typedef enum SeStructureType
|
||||
{
|
||||
SE_STRUCTURE_TYPE_APPLICATION_INFO = 0,
|
||||
SE_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
|
||||
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_RANGE_SIZE = (SE_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - SE_STRUCTURE_TYPE_APPLICATION_INFO + 1),
|
||||
SE_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeStructureType;
|
||||
} SeStructureType;
|
||||
|
||||
typedef enum SeSystemAllocationScope {
|
||||
typedef enum SeSystemAllocationScope
|
||||
{
|
||||
SE_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
|
||||
SE_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
|
||||
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_RANGE_SIZE = (SE_SYSTEM_ALLOCATION_SCOPE_INSTANCE - SE_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1),
|
||||
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_BEGIN_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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeInternalAllocationType;
|
||||
} SeInternalAllocationType;
|
||||
|
||||
typedef enum SeFormat {
|
||||
typedef enum SeFormat
|
||||
{
|
||||
SE_FORMAT_UNDEFINED = 0,
|
||||
SE_FORMAT_R4G4_UNORM_PACK8 = 1,
|
||||
SE_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
|
||||
@@ -797,9 +804,10 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFormat;
|
||||
} SeFormat;
|
||||
|
||||
typedef enum SeImageType {
|
||||
typedef enum SeImageType
|
||||
{
|
||||
SE_IMAGE_TYPE_1D = 0,
|
||||
SE_IMAGE_TYPE_2D = 1,
|
||||
SE_IMAGE_TYPE_3D = 2,
|
||||
@@ -807,9 +815,10 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageType;
|
||||
} SeImageType;
|
||||
|
||||
typedef enum SeImageTiling {
|
||||
typedef enum SeImageTiling
|
||||
{
|
||||
SE_IMAGE_TILING_OPTIMAL = 0,
|
||||
SE_IMAGE_TILING_LINEAR = 1,
|
||||
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_RANGE_SIZE = (SE_IMAGE_TILING_LINEAR - SE_IMAGE_TILING_OPTIMAL + 1),
|
||||
SE_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageTiling;
|
||||
} SeImageTiling;
|
||||
|
||||
typedef enum SePhysicalDeviceType {
|
||||
typedef enum SePhysicalDeviceType
|
||||
{
|
||||
SE_PHYSICAL_DEVICE_TYPE_OTHER = 0,
|
||||
SE_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
|
||||
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_RANGE_SIZE = (SE_PHYSICAL_DEVICE_TYPE_CPU - SE_PHYSICAL_DEVICE_TYPE_OTHER + 1),
|
||||
SE_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePhysicalDeviceType;
|
||||
} SePhysicalDeviceType;
|
||||
|
||||
typedef enum SeQueryType {
|
||||
typedef enum SeQueryType
|
||||
{
|
||||
SE_QUERY_TYPE_OCCLUSION = 0,
|
||||
SE_QUERY_TYPE_PIPELINE_STATISTICS = 1,
|
||||
SE_QUERY_TYPE_TIMESTAMP = 2,
|
||||
@@ -842,18 +853,20 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeQueryType;
|
||||
} SeQueryType;
|
||||
|
||||
typedef enum SeSharingMode {
|
||||
typedef enum SeSharingMode
|
||||
{
|
||||
SE_SHARING_MODE_EXCLUSIVE = 0,
|
||||
SE_SHARING_MODE_CONCURRENT = 1,
|
||||
SE_SHARING_MODE_BEGIN_RANGE = SE_SHARING_MODE_EXCLUSIVE,
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSharingMode;
|
||||
} SeSharingMode;
|
||||
|
||||
typedef enum SeImageLayout {
|
||||
typedef enum SeImageLayout
|
||||
{
|
||||
SE_IMAGE_LAYOUT_UNDEFINED = 0,
|
||||
SE_IMAGE_LAYOUT_GENERAL = 1,
|
||||
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_RANGE_SIZE = (SE_IMAGE_LAYOUT_PREINITIALIZED - SE_IMAGE_LAYOUT_UNDEFINED + 1),
|
||||
SE_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageLayout;
|
||||
} SeImageLayout;
|
||||
|
||||
typedef enum SeImageViewType {
|
||||
typedef enum SeImageViewType
|
||||
{
|
||||
SE_IMAGE_VIEW_TYPE_1D = 0,
|
||||
SE_IMAGE_VIEW_TYPE_2D = 1,
|
||||
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_RANGE_SIZE = (SE_IMAGE_VIEW_TYPE_CUBE_ARRAY - SE_IMAGE_VIEW_TYPE_1D + 1),
|
||||
SE_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageViewType;
|
||||
} SeImageViewType;
|
||||
|
||||
typedef enum SeComponentSwizzle {
|
||||
typedef enum SeComponentSwizzle
|
||||
{
|
||||
SE_COMPONENT_SWIZZLE_IDENTITY = 0,
|
||||
SE_COMPONENT_SWIZZLE_ZERO = 1,
|
||||
SE_COMPONENT_SWIZZLE_ONE = 2,
|
||||
@@ -903,18 +918,20 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeComponentSwizzle;
|
||||
} SeComponentSwizzle;
|
||||
|
||||
typedef enum SeVertexInputRate {
|
||||
typedef enum SeVertexInputRate
|
||||
{
|
||||
SE_VERTEX_INPUT_RATE_VERTEX = 0,
|
||||
SE_VERTEX_INPUT_RATE_INSTANCE = 1,
|
||||
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_RANGE_SIZE = (SE_VERTEX_INPUT_RATE_INSTANCE - SE_VERTEX_INPUT_RATE_VERTEX + 1),
|
||||
SE_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeVertexInputRate;
|
||||
} SeVertexInputRate;
|
||||
|
||||
typedef enum SePrimitiveTopology {
|
||||
typedef enum SePrimitiveTopology
|
||||
{
|
||||
SE_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
|
||||
SE_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
|
||||
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_RANGE_SIZE = (SE_PRIMITIVE_TOPOLOGY_PATCH_LIST - SE_PRIMITIVE_TOPOLOGY_POINT_LIST + 1),
|
||||
SE_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePrimitiveTopology;
|
||||
} SePrimitiveTopology;
|
||||
|
||||
typedef enum SePolygonMode {
|
||||
typedef enum SePolygonMode
|
||||
{
|
||||
SE_POLYGON_MODE_FILL = 0,
|
||||
SE_POLYGON_MODE_LINE = 1,
|
||||
SE_POLYGON_MODE_POINT = 2,
|
||||
@@ -941,18 +959,20 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePolygonMode;
|
||||
} SePolygonMode;
|
||||
|
||||
typedef enum SeFrontFace {
|
||||
typedef enum SeFrontFace
|
||||
{
|
||||
SE_FRONT_FACE_COUNTER_CLOCKWISE = 0,
|
||||
SE_FRONT_FACE_CLOCKWISE = 1,
|
||||
SE_FRONT_FACE_BEGIN_RANGE = SE_FRONT_FACE_COUNTER_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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFrontFace;
|
||||
} SeFrontFace;
|
||||
|
||||
typedef enum SeCompareOp {
|
||||
typedef enum SeCompareOp
|
||||
{
|
||||
SE_COMPARE_OP_NEVER = 0,
|
||||
SE_COMPARE_OP_LESS = 1,
|
||||
SE_COMPARE_OP_EQUAL = 2,
|
||||
@@ -965,9 +985,10 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCompareOp;
|
||||
} SeCompareOp;
|
||||
|
||||
typedef enum SeStencilOp {
|
||||
typedef enum SeStencilOp
|
||||
{
|
||||
SE_STENCIL_OP_KEEP = 0,
|
||||
SE_STENCIL_OP_ZERO = 1,
|
||||
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_RANGE_SIZE = (SE_STENCIL_OP_DECREMENT_AND_WRAP - SE_STENCIL_OP_KEEP + 1),
|
||||
SE_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeStencilOp;
|
||||
} SeStencilOp;
|
||||
|
||||
typedef enum SeLogicOp {
|
||||
typedef enum SeLogicOp
|
||||
{
|
||||
SE_LOGIC_OP_CLEAR = 0,
|
||||
SE_LOGIC_OP_AND = 1,
|
||||
SE_LOGIC_OP_AND_REVERSE = 2,
|
||||
@@ -1003,9 +1025,10 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeLogicOp;
|
||||
} SeLogicOp;
|
||||
|
||||
typedef enum SeBlendFactor {
|
||||
typedef enum SeBlendFactor
|
||||
{
|
||||
SE_BLEND_FACTOR_ZERO = 0,
|
||||
SE_BLEND_FACTOR_ONE = 1,
|
||||
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_RANGE_SIZE = (SE_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - SE_BLEND_FACTOR_ZERO + 1),
|
||||
SE_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeBlendFactor;
|
||||
} SeBlendFactor;
|
||||
|
||||
typedef enum SeBlendOp {
|
||||
typedef enum SeBlendOp
|
||||
{
|
||||
SE_BLEND_OP_ADD = 0,
|
||||
SE_BLEND_OP_SUBTRACT = 1,
|
||||
SE_BLEND_OP_REVERSE_SUBTRACT = 2,
|
||||
@@ -1087,9 +1111,10 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeBlendOp;
|
||||
} SeBlendOp;
|
||||
|
||||
typedef enum SeDynamicState {
|
||||
typedef enum SeDynamicState
|
||||
{
|
||||
SE_DYNAMIC_STATE_VIEWPORT = 0,
|
||||
SE_DYNAMIC_STATE_SCISSOR = 1,
|
||||
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_RANGE_SIZE = (SE_DYNAMIC_STATE_STENCIL_REFERENCE - SE_DYNAMIC_STATE_VIEWPORT + 1),
|
||||
SE_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDynamicState;
|
||||
} SeDynamicState;
|
||||
|
||||
typedef enum SeFilter {
|
||||
typedef enum SeFilter
|
||||
{
|
||||
SE_FILTER_NEAREST = 0,
|
||||
SE_FILTER_LINEAR = 1,
|
||||
SE_FILTER_CUBIC_IMG = 1000015000,
|
||||
@@ -1121,18 +1147,20 @@ namespace Seele
|
||||
SE_FILTER_END_RANGE = SE_FILTER_LINEAR,
|
||||
SE_FILTER_RANGE_SIZE = (SE_FILTER_LINEAR - SE_FILTER_NEAREST + 1),
|
||||
SE_FILTER_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFilter;
|
||||
} SeFilter;
|
||||
|
||||
typedef enum SeSamplerMipmapMode {
|
||||
typedef enum SeSamplerMipmapMode
|
||||
{
|
||||
SE_SAMPLER_MIPMAP_MODE_NEAREST = 0,
|
||||
SE_SAMPLER_MIPMAP_MODE_LINEAR = 1,
|
||||
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_RANGE_SIZE = (SE_SAMPLER_MIPMAP_MODE_LINEAR - SE_SAMPLER_MIPMAP_MODE_NEAREST + 1),
|
||||
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_MIRRORED_REPEAT = 1,
|
||||
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_RANGE_SIZE = (SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - SE_SAMPLER_ADDRESS_MODE_REPEAT + 1),
|
||||
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_INT_TRANSPARENT_BLACK = 1,
|
||||
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_RANGE_SIZE = (SE_BORDER_COLOR_INT_OPAQUE_WHITE - SE_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1),
|
||||
SE_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeBorderColor;
|
||||
} SeBorderColor;
|
||||
|
||||
typedef enum SeDescriptorType {
|
||||
typedef enum SeDescriptorType
|
||||
{
|
||||
SE_DESCRIPTOR_TYPE_SAMPLER = 0,
|
||||
SE_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
|
||||
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_RANGE_SIZE = (SE_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - SE_DESCRIPTOR_TYPE_SAMPLER + 1),
|
||||
SE_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDescriptorType;
|
||||
} SeDescriptorType;
|
||||
|
||||
typedef enum SeAttachmentLoadOp {
|
||||
typedef enum SeAttachmentLoadOp
|
||||
{
|
||||
SE_ATTACHMENT_LOAD_OP_LOAD = 0,
|
||||
SE_ATTACHMENT_LOAD_OP_CLEAR = 1,
|
||||
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_RANGE_SIZE = (SE_ATTACHMENT_LOAD_OP_DONT_CARE - SE_ATTACHMENT_LOAD_OP_LOAD + 1),
|
||||
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_DONT_CARE = 1,
|
||||
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_RANGE_SIZE = (SE_ATTACHMENT_STORE_OP_DONT_CARE - SE_ATTACHMENT_STORE_OP_STORE + 1),
|
||||
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_COMPUTE = 1,
|
||||
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_RANGE_SIZE = (SE_PIPELINE_BIND_POINT_COMPUTE - SE_PIPELINE_BIND_POINT_GRAPHICS + 1),
|
||||
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_SECONDARY = 1,
|
||||
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_RANGE_SIZE = (SE_COMMAND_BUFFER_LEVEL_SECONDARY - SE_COMMAND_BUFFER_LEVEL_PRIMARY + 1),
|
||||
SE_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCommandBufferLevel;
|
||||
} SeCommandBufferLevel;
|
||||
|
||||
typedef enum SeIndexType {
|
||||
typedef enum SeIndexType
|
||||
{
|
||||
SE_INDEX_TYPE_UINT16 = 0,
|
||||
SE_INDEX_TYPE_UINT32 = 1,
|
||||
SE_INDEX_TYPE_NONE_NV = 1000165000,
|
||||
@@ -1225,18 +1260,20 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeIndexType;
|
||||
} SeIndexType;
|
||||
|
||||
typedef enum SeSubpassContents {
|
||||
typedef enum SeSubpassContents
|
||||
{
|
||||
SE_SUBPASS_CONTENTS_INLINE = 0,
|
||||
SE_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1,
|
||||
SE_SUBPASS_CONTENTS_BEGIN_RANGE = SE_SUBPASS_CONTENTS_INLINE,
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSubpassContents;
|
||||
} SeSubpassContents;
|
||||
|
||||
typedef enum SeObjectType {
|
||||
typedef enum SeObjectType
|
||||
{
|
||||
SE_OBJECT_TYPE_UNKNOWN = 0,
|
||||
SE_OBJECT_TYPE_INSTANCE = 1,
|
||||
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_RANGE_SIZE = (SE_OBJECT_TYPE_COMMAND_POOL - SE_OBJECT_TYPE_UNKNOWN + 1),
|
||||
SE_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeObjectType;
|
||||
} SeObjectType;
|
||||
|
||||
typedef enum SeVendorId {
|
||||
typedef enum SeVendorId
|
||||
{
|
||||
SE_VENDOR_ID_VIV = 0x10001,
|
||||
SE_VENDOR_ID_VSI = 0x10002,
|
||||
SE_VENDOR_ID_KAZAN = 0x10003,
|
||||
@@ -1292,10 +1330,11 @@ namespace Seele
|
||||
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_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeVendorId;
|
||||
typedef SeFlags SeInstanceCreateFlags;
|
||||
} SeVendorId;
|
||||
typedef SeFlags SeInstanceCreateFlags;
|
||||
|
||||
typedef enum SeFormatFeatureFlagBits {
|
||||
typedef enum SeFormatFeatureFlagBits
|
||||
{
|
||||
SE_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001,
|
||||
SE_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002,
|
||||
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_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = SE_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG,
|
||||
SE_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFormatFeatureFlagBits;
|
||||
typedef SeFlags SeFormatFeatureFlags;
|
||||
} SeFormatFeatureFlagBits;
|
||||
typedef SeFlags SeFormatFeatureFlags;
|
||||
|
||||
typedef enum SeImageUsageFlagBits {
|
||||
typedef enum SeImageUsageFlagBits
|
||||
{
|
||||
SE_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001,
|
||||
SE_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002,
|
||||
SE_IMAGE_USAGE_SAMPLED_BIT = 0x00000004,
|
||||
@@ -1347,10 +1387,11 @@ namespace Seele
|
||||
SE_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = 0x00000100,
|
||||
SE_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200,
|
||||
SE_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageUsageFlagBits;
|
||||
typedef SeFlags SeImageUsageFlags;
|
||||
} SeImageUsageFlagBits;
|
||||
typedef SeFlags SeImageUsageFlags;
|
||||
|
||||
typedef enum SeImageCreateFlagBits {
|
||||
typedef enum SeImageCreateFlagBits
|
||||
{
|
||||
SE_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001,
|
||||
SE_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
|
||||
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_ALIAS_BIT_KHR = SE_IMAGE_CREATE_ALIAS_BIT,
|
||||
SE_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageCreateFlagBits;
|
||||
typedef SeFlags SeImageCreateFlags;
|
||||
} SeImageCreateFlagBits;
|
||||
typedef SeFlags SeImageCreateFlags;
|
||||
|
||||
typedef enum SeSampleCountFlagBits {
|
||||
typedef enum SeSampleCountFlagBits
|
||||
{
|
||||
SE_SAMPLE_COUNT_1_BIT = 0x00000001,
|
||||
SE_SAMPLE_COUNT_2_BIT = 0x00000002,
|
||||
SE_SAMPLE_COUNT_4_BIT = 0x00000004,
|
||||
@@ -1385,20 +1427,22 @@ namespace Seele
|
||||
SE_SAMPLE_COUNT_32_BIT = 0x00000020,
|
||||
SE_SAMPLE_COUNT_64_BIT = 0x00000040,
|
||||
SE_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSampleCountFlagBits;
|
||||
typedef SeFlags SeSampleCountFlags;
|
||||
} SeSampleCountFlagBits;
|
||||
typedef SeFlags SeSampleCountFlags;
|
||||
|
||||
typedef enum SeQueueFlagBits {
|
||||
typedef enum SeQueueFlagBits
|
||||
{
|
||||
SE_QUEUE_GRAPHICS_BIT = 0x00000001,
|
||||
SE_QUEUE_COMPUTE_BIT = 0x00000002,
|
||||
SE_QUEUE_TRANSFER_BIT = 0x00000004,
|
||||
SE_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
|
||||
SE_QUEUE_PROTECTED_BIT = 0x00000010,
|
||||
SE_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeQueueFlagBits;
|
||||
typedef SeFlags SeQueueFlags;
|
||||
} SeQueueFlagBits;
|
||||
typedef SeFlags SeQueueFlags;
|
||||
|
||||
typedef enum SeMemoryPropertyFlagBits {
|
||||
typedef enum SeMemoryPropertyFlagBits
|
||||
{
|
||||
SE_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001,
|
||||
SE_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002,
|
||||
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_UNCACHED_BIT_AMD = 0x00000080,
|
||||
SE_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeMemoryPropertyFlagBits;
|
||||
typedef SeFlags SeMemoryPropertyFlags;
|
||||
} SeMemoryPropertyFlagBits;
|
||||
typedef SeFlags SeMemoryPropertyFlags;
|
||||
|
||||
typedef enum SeMemoryHeapFlagBits {
|
||||
typedef enum SeMemoryHeapFlagBits
|
||||
{
|
||||
SE_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
|
||||
SE_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002,
|
||||
SE_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = SE_MEMORY_HEAP_MULTI_INSTANCE_BIT,
|
||||
SE_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeMemoryHeapFlagBits;
|
||||
typedef SeFlags SeMemoryHeapFlags;
|
||||
typedef SeFlags SeDeviceCreateFlags;
|
||||
} SeMemoryHeapFlagBits;
|
||||
typedef SeFlags SeMemoryHeapFlags;
|
||||
typedef SeFlags SeDeviceCreateFlags;
|
||||
|
||||
typedef enum SeDeviceQueueCreateFlagBits {
|
||||
typedef enum SeDeviceQueueCreateFlagBits
|
||||
{
|
||||
SE_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 0x00000001,
|
||||
SE_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDeviceQueueCreateFlagBits;
|
||||
typedef SeFlags SeDeviceQueueCreateFlags;
|
||||
} SeDeviceQueueCreateFlagBits;
|
||||
typedef SeFlags SeDeviceQueueCreateFlags;
|
||||
|
||||
typedef enum SePipelineStageFlagBits {
|
||||
typedef enum SePipelineStageFlagBits
|
||||
{
|
||||
SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001,
|
||||
SE_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002,
|
||||
SE_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004,
|
||||
@@ -1454,11 +1501,12 @@ namespace Seele
|
||||
SE_PIPELINE_STAGE_MESH_SHADER_BIT_NV = 0x00100000,
|
||||
SE_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000,
|
||||
SE_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePipelineStageFlagBits;
|
||||
typedef SeFlags SePipelineStageFlags;
|
||||
typedef SeFlags SeMemoryMapFlags;
|
||||
} SePipelineStageFlagBits;
|
||||
typedef SeFlags SePipelineStageFlags;
|
||||
typedef SeFlags SeMemoryMapFlags;
|
||||
|
||||
typedef enum SeImageAspectFlagBits {
|
||||
typedef enum SeImageAspectFlagBits
|
||||
{
|
||||
SE_IMAGE_ASPECT_COLOR_BIT = 0x00000001,
|
||||
SE_IMAGE_ASPECT_DEPTH_BIT = 0x00000002,
|
||||
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_2_BIT_KHR = SE_IMAGE_ASPECT_PLANE_2_BIT,
|
||||
SE_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageAspectFlagBits;
|
||||
typedef SeFlags SeImageAspectFlags;
|
||||
} SeImageAspectFlagBits;
|
||||
typedef SeFlags SeImageAspectFlags;
|
||||
|
||||
typedef enum SeSparseImageFormatFlagBits {
|
||||
typedef enum SeSparseImageFormatFlagBits
|
||||
{
|
||||
SE_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001,
|
||||
SE_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002,
|
||||
SE_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004,
|
||||
SE_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSparseImageFormatFlagBits;
|
||||
typedef SeFlags SeSparseImageFormatFlags;
|
||||
} SeSparseImageFormatFlagBits;
|
||||
typedef SeFlags SeSparseImageFormatFlags;
|
||||
|
||||
typedef enum SeSparseMemoryBindFlagBits {
|
||||
typedef enum SeSparseMemoryBindFlagBits
|
||||
{
|
||||
SE_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001,
|
||||
SE_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSparseMemoryBindFlagBits;
|
||||
typedef SeFlags SeSparseMemoryBindFlags;
|
||||
} SeSparseMemoryBindFlagBits;
|
||||
typedef SeFlags SeSparseMemoryBindFlags;
|
||||
|
||||
typedef enum SeFenceCreateFlagBits {
|
||||
typedef enum SeFenceCreateFlagBits
|
||||
{
|
||||
SE_FENCE_CREATE_SIGNALED_BIT = 0x00000001,
|
||||
SE_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFenceCreateFlagBits;
|
||||
typedef SeFlags SeFenceCreateFlags;
|
||||
typedef SeFlags SeSemaphoreCreateFlags;
|
||||
typedef SeFlags SeEventCreateFlags;
|
||||
typedef SeFlags SeQueryPoolCreateFlags;
|
||||
} SeFenceCreateFlagBits;
|
||||
typedef SeFlags SeFenceCreateFlags;
|
||||
typedef SeFlags SeSemaphoreCreateFlags;
|
||||
typedef SeFlags SeEventCreateFlags;
|
||||
typedef SeFlags SeQueryPoolCreateFlags;
|
||||
|
||||
typedef enum SeQueryPipelineStatisticFlagBits {
|
||||
typedef enum SeQueryPipelineStatisticFlagBits
|
||||
{
|
||||
SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001,
|
||||
SE_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002,
|
||||
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_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400,
|
||||
SE_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeQueryPipelineStatisticFlagBits;
|
||||
typedef SeFlags SeQueryPipelineStatisticFlags;
|
||||
} SeQueryPipelineStatisticFlagBits;
|
||||
typedef SeFlags SeQueryPipelineStatisticFlags;
|
||||
|
||||
typedef enum SeQueryResultFlagBits {
|
||||
typedef enum SeQueryResultFlagBits
|
||||
{
|
||||
SE_QUERY_RESULT_64_BIT = 0x00000001,
|
||||
SE_QUERY_RESULT_WAIT_BIT = 0x00000002,
|
||||
SE_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004,
|
||||
SE_QUERY_RESULT_PARTIAL_BIT = 0x00000008,
|
||||
SE_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeQueryResultFlagBits;
|
||||
typedef SeFlags SeQueryResultFlags;
|
||||
} SeQueryResultFlagBits;
|
||||
typedef SeFlags SeQueryResultFlags;
|
||||
|
||||
typedef enum SeBufferCreateFlagBits {
|
||||
typedef enum SeBufferCreateFlagBits
|
||||
{
|
||||
SE_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001,
|
||||
SE_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
|
||||
SE_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
|
||||
SE_BUFFER_CREATE_PROTECTED_BIT = 0x00000008,
|
||||
SE_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000010,
|
||||
SE_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeBufferCreateFlagBits;
|
||||
typedef SeFlags SeBufferCreateFlags;
|
||||
} SeBufferCreateFlagBits;
|
||||
typedef SeFlags SeBufferCreateFlags;
|
||||
|
||||
typedef enum SeBufferUsageFlagBits {
|
||||
typedef enum SeBufferUsageFlagBits
|
||||
{
|
||||
SE_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001,
|
||||
SE_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002,
|
||||
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_SHADER_DEVICE_ADDRESS_BIT_EXT = 0x00020000,
|
||||
SE_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeBufferUsageFlagBits;
|
||||
typedef SeFlags SeBufferUsageFlags;
|
||||
typedef SeFlags SeBufferViewCreateFlags;
|
||||
} SeBufferUsageFlagBits;
|
||||
typedef SeFlags SeBufferUsageFlags;
|
||||
typedef SeFlags SeBufferViewCreateFlags;
|
||||
|
||||
typedef enum SeImageViewCreateFlagBits {
|
||||
typedef enum SeImageViewCreateFlagBits
|
||||
{
|
||||
SE_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001,
|
||||
SE_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeImageViewCreateFlagBits;
|
||||
typedef SeFlags SeImageViewCreateFlags;
|
||||
} SeImageViewCreateFlagBits;
|
||||
typedef SeFlags SeImageViewCreateFlags;
|
||||
|
||||
typedef enum SeShaderModuleCreateFlagBits {
|
||||
typedef enum SeShaderModuleCreateFlagBits
|
||||
{
|
||||
SE_SHADER_MODULE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeShaderModuleCreateFlagBits;
|
||||
typedef SeFlags SeShaderModuleCreateFlags;
|
||||
typedef SeFlags SePipelineCacheCreateFlags;
|
||||
} SeShaderModuleCreateFlagBits;
|
||||
typedef SeFlags SeShaderModuleCreateFlags;
|
||||
typedef SeFlags SePipelineCacheCreateFlags;
|
||||
|
||||
typedef enum SePipelineCreateFlagBits {
|
||||
typedef enum SePipelineCreateFlagBits
|
||||
{
|
||||
SE_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001,
|
||||
SE_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002,
|
||||
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_DISPATCH_BASE_KHR = SE_PIPELINE_CREATE_DISPATCH_BASE,
|
||||
SE_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePipelineCreateFlagBits;
|
||||
typedef SeFlags SePipelineCreateFlags;
|
||||
} SePipelineCreateFlagBits;
|
||||
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_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000002,
|
||||
SE_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SePipelineShaderStageCreateFlagBits;
|
||||
typedef SeFlags SePipelineShaderStageCreateFlags;
|
||||
} SePipelineShaderStageCreateFlagBits;
|
||||
typedef SeFlags SePipelineShaderStageCreateFlags;
|
||||
|
||||
typedef enum SeShaderStageFlagBits {
|
||||
typedef enum SeShaderStageFlagBits
|
||||
{
|
||||
SE_SHADER_STAGE_VERTEX_BIT = 0x00000001,
|
||||
SE_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002,
|
||||
SE_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004,
|
||||
@@ -1607,84 +1667,94 @@ namespace Seele
|
||||
SE_SHADER_STAGE_TASK_BIT_NV = 0x00000040,
|
||||
SE_SHADER_STAGE_MESH_BIT_NV = 0x00000080,
|
||||
SE_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeShaderStageFlagBits;
|
||||
typedef SeFlags SePipelineVertexInputStateCreateFlags;
|
||||
typedef SeFlags SePipelineInputAssemblyStateCreateFlags;
|
||||
typedef SeFlags SePipelineTessellationStateCreateFlags;
|
||||
typedef SeFlags SePipelineViewportStateCreateFlags;
|
||||
typedef SeFlags SePipelineRasterizationStateCreateFlags;
|
||||
} SeShaderStageFlagBits;
|
||||
typedef SeFlags SePipelineVertexInputStateCreateFlags;
|
||||
typedef SeFlags SePipelineInputAssemblyStateCreateFlags;
|
||||
typedef SeFlags SePipelineTessellationStateCreateFlags;
|
||||
typedef SeFlags SePipelineViewportStateCreateFlags;
|
||||
typedef SeFlags SePipelineRasterizationStateCreateFlags;
|
||||
|
||||
typedef enum SeCullModeFlagBits {
|
||||
typedef enum SeCullModeFlagBits
|
||||
{
|
||||
SE_CULL_MODE_NONE = 0,
|
||||
SE_CULL_MODE_FRONT_BIT = 0x00000001,
|
||||
SE_CULL_MODE_BACK_BIT = 0x00000002,
|
||||
SE_CULL_MODE_FRONT_AND_BACK = 0x00000003,
|
||||
SE_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCullModeFlagBits;
|
||||
typedef SeFlags SeCullModeFlags;
|
||||
typedef SeFlags SePipelineMultisampleStateCreateFlags;
|
||||
typedef SeFlags SePipelineDepthStencilStateCreateFlags;
|
||||
typedef SeFlags SePipelineColorBlendStateCreateFlags;
|
||||
} SeCullModeFlagBits;
|
||||
typedef SeFlags SeCullModeFlags;
|
||||
typedef SeFlags SePipelineMultisampleStateCreateFlags;
|
||||
typedef SeFlags SePipelineDepthStencilStateCreateFlags;
|
||||
typedef SeFlags SePipelineColorBlendStateCreateFlags;
|
||||
|
||||
typedef enum SeColorComponentFlagBits {
|
||||
typedef enum SeColorComponentFlagBits
|
||||
{
|
||||
SE_COLOR_COMPONENT_R_BIT = 0x00000001,
|
||||
SE_COLOR_COMPONENT_G_BIT = 0x00000002,
|
||||
SE_COLOR_COMPONENT_B_BIT = 0x00000004,
|
||||
SE_COLOR_COMPONENT_A_BIT = 0x00000008,
|
||||
SE_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeColorComponentFlagBits;
|
||||
typedef SeFlags SeColorComponentFlags;
|
||||
typedef SeFlags SePipelineDynamicStateCreateFlags;
|
||||
typedef SeFlags SePipelineLayoutCreateFlags;
|
||||
typedef SeFlags SeShaderStageFlags;
|
||||
} SeColorComponentFlagBits;
|
||||
typedef SeFlags SeColorComponentFlags;
|
||||
typedef SeFlags SePipelineDynamicStateCreateFlags;
|
||||
typedef SeFlags SePipelineLayoutCreateFlags;
|
||||
typedef SeFlags SeShaderStageFlags;
|
||||
|
||||
typedef enum SeSamplerCreateFlagBits {
|
||||
typedef enum SeSamplerCreateFlagBits
|
||||
{
|
||||
SE_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001,
|
||||
SE_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002,
|
||||
SE_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSamplerCreateFlagBits;
|
||||
typedef SeFlags SeSamplerCreateFlags;
|
||||
} SeSamplerCreateFlagBits;
|
||||
typedef SeFlags SeSamplerCreateFlags;
|
||||
|
||||
typedef enum SeDescriptorSetLayoutCreateFlagBits {
|
||||
typedef enum SeDescriptorSetLayoutCreateFlagBits
|
||||
{
|
||||
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_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDescriptorSetLayoutCreateFlagBits;
|
||||
typedef SeFlags SeDescriptorSetLayoutCreateFlags;
|
||||
} SeDescriptorSetLayoutCreateFlagBits;
|
||||
typedef SeFlags SeDescriptorSetLayoutCreateFlags;
|
||||
|
||||
typedef enum SeDescriptorPoolCreateFlagBits {
|
||||
typedef enum SeDescriptorPoolCreateFlagBits
|
||||
{
|
||||
SE_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001,
|
||||
SE_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = 0x00000002,
|
||||
SE_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDescriptorPoolCreateFlagBits;
|
||||
typedef SeFlags SeDescriptorPoolCreateFlags;
|
||||
typedef SeFlags SeDescriptorPoolResetFlags;
|
||||
} SeDescriptorPoolCreateFlagBits;
|
||||
typedef SeFlags SeDescriptorPoolCreateFlags;
|
||||
typedef SeFlags SeDescriptorPoolResetFlags;
|
||||
|
||||
typedef enum SeFramebufferCreateFlagBits {
|
||||
typedef enum SeFramebufferCreateFlagBits
|
||||
{
|
||||
SE_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR = 0x00000001,
|
||||
SE_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeFramebufferCreateFlagBits;
|
||||
typedef SeFlags SeFramebufferCreateFlags;
|
||||
} SeFramebufferCreateFlagBits;
|
||||
typedef SeFlags SeFramebufferCreateFlags;
|
||||
|
||||
typedef enum SeRenderPassCreateFlagBits {
|
||||
typedef enum SeRenderPassCreateFlagBits
|
||||
{
|
||||
SE_RENDER_PASS_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeRenderPassCreateFlagBits;
|
||||
typedef SeFlags SeRenderPassCreateFlags;
|
||||
} SeRenderPassCreateFlagBits;
|
||||
typedef SeFlags SeRenderPassCreateFlags;
|
||||
|
||||
typedef enum SeAttachmentDescriptionFlagBits {
|
||||
typedef enum SeAttachmentDescriptionFlagBits
|
||||
{
|
||||
SE_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001,
|
||||
SE_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeAttachmentDescriptionFlagBits;
|
||||
typedef SeFlags SeAttachmentDescriptionFlags;
|
||||
} SeAttachmentDescriptionFlagBits;
|
||||
typedef SeFlags SeAttachmentDescriptionFlags;
|
||||
|
||||
typedef enum SeSubpassDescriptionFlagBits {
|
||||
typedef enum SeSubpassDescriptionFlagBits
|
||||
{
|
||||
SE_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001,
|
||||
SE_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002,
|
||||
SE_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeSubpassDescriptionFlagBits;
|
||||
typedef SeFlags SeSubpassDescriptionFlags;
|
||||
} SeSubpassDescriptionFlagBits;
|
||||
typedef SeFlags SeSubpassDescriptionFlags;
|
||||
|
||||
typedef enum SeAccessFlagBits {
|
||||
typedef enum SeAccessFlagBits
|
||||
{
|
||||
SE_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001,
|
||||
SE_ACCESS_INDEX_READ_BIT = 0x00000002,
|
||||
SE_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004,
|
||||
@@ -1714,60 +1784,67 @@ namespace Seele
|
||||
SE_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000,
|
||||
SE_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000,
|
||||
SE_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeAccessFlagBits;
|
||||
typedef SeFlags SeAccessFlags;
|
||||
} SeAccessFlagBits;
|
||||
typedef SeFlags SeAccessFlags;
|
||||
|
||||
typedef enum SeDependencyFlagBits {
|
||||
typedef enum SeDependencyFlagBits
|
||||
{
|
||||
SE_DEPENDENCY_BY_REGION_BIT = 0x00000001,
|
||||
SE_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004,
|
||||
SE_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002,
|
||||
SE_DEPENDENCY_VIEW_LOCAL_BIT_KHR = SE_DEPENDENCY_VIEW_LOCAL_BIT,
|
||||
SE_DEPENDENCY_DEVICE_GROUP_BIT_KHR = SE_DEPENDENCY_DEVICE_GROUP_BIT,
|
||||
SE_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeDependencyFlagBits;
|
||||
typedef SeFlags SeDependencyFlags;
|
||||
} SeDependencyFlagBits;
|
||||
typedef SeFlags SeDependencyFlags;
|
||||
|
||||
typedef enum SeCommandPoolCreateFlagBits {
|
||||
typedef enum SeCommandPoolCreateFlagBits
|
||||
{
|
||||
SE_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001,
|
||||
SE_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
|
||||
SE_COMMAND_POOL_CREATE_PROTECTED_BIT = 0x00000004,
|
||||
SE_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCommandPoolCreateFlagBits;
|
||||
typedef SeFlags SeCommandPoolCreateFlags;
|
||||
} SeCommandPoolCreateFlagBits;
|
||||
typedef SeFlags SeCommandPoolCreateFlags;
|
||||
|
||||
typedef enum SeCommandPoolResetFlagBits {
|
||||
typedef enum SeCommandPoolResetFlagBits
|
||||
{
|
||||
SE_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
|
||||
SE_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCommandPoolResetFlagBits;
|
||||
typedef SeFlags SeCommandPoolResetFlags;
|
||||
} SeCommandPoolResetFlagBits;
|
||||
typedef SeFlags SeCommandPoolResetFlags;
|
||||
|
||||
typedef enum SeCommandBufferUsageFlagBits {
|
||||
typedef enum SeCommandBufferUsageFlagBits
|
||||
{
|
||||
SE_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001,
|
||||
SE_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002,
|
||||
SE_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004,
|
||||
SE_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCommandBufferUsageFlagBits;
|
||||
typedef SeFlags SeCommandBufferUsageFlags;
|
||||
} SeCommandBufferUsageFlagBits;
|
||||
typedef SeFlags SeCommandBufferUsageFlags;
|
||||
|
||||
typedef enum SeQueryControlFlagBits {
|
||||
typedef enum SeQueryControlFlagBits
|
||||
{
|
||||
SE_QUERY_CONTROL_PRECISE_BIT = 0x00000001,
|
||||
SE_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeQueryControlFlagBits;
|
||||
typedef SeFlags SeQueryControlFlags;
|
||||
} SeQueryControlFlagBits;
|
||||
typedef SeFlags SeQueryControlFlags;
|
||||
|
||||
typedef enum SeCommandBufferResetFlagBits {
|
||||
typedef enum SeCommandBufferResetFlagBits
|
||||
{
|
||||
SE_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
|
||||
SE_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeCommandBufferResetFlagBits;
|
||||
typedef SeFlags SeCommandBufferResetFlags;
|
||||
} SeCommandBufferResetFlagBits;
|
||||
typedef SeFlags SeCommandBufferResetFlags;
|
||||
|
||||
typedef enum SeStencilFaceFlagBits {
|
||||
typedef enum SeStencilFaceFlagBits
|
||||
{
|
||||
SE_STENCIL_FACE_FRONT_BIT = 0x00000001,
|
||||
SE_STENCIL_FACE_BACK_BIT = 0x00000002,
|
||||
SE_STENCIL_FACE_FRONT_AND_BACK = 0x00000003,
|
||||
SE_STENCIL_FRONT_AND_BACK = SE_STENCIL_FACE_FRONT_AND_BACK,
|
||||
SE_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} SeStencilFaceFlagBits;
|
||||
typedef SeFlags SeStencilFaceFlags;
|
||||
}
|
||||
}
|
||||
} SeStencilFaceFlagBits;
|
||||
typedef SeFlags SeStencilFaceFlags;
|
||||
} // namespace Gfx
|
||||
} // namespace Seele
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "GraphicsResources.h"
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Gfx;
|
||||
|
||||
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, uint32 arrayCount)
|
||||
@@ -30,8 +31,8 @@ void PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layo
|
||||
}
|
||||
if (descriptorSetLayouts[setIndex] != nullptr)
|
||||
{
|
||||
auto& thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
|
||||
auto& otherBindings = layout->descriptorBindings;
|
||||
auto &thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
|
||||
auto &otherBindings = layout->descriptorBindings;
|
||||
thisBindings.resize(otherBindings.size());
|
||||
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);
|
||||
}
|
||||
|
||||
UniformBuffer::UniformBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
UniformBuffer::~UniformBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
RenderTargetLayout::RenderTargetLayout()
|
||||
: inputAttachments()
|
||||
, colorAttachments()
|
||||
, depthAttachment()
|
||||
: inputAttachments(), colorAttachments(), depthAttachment()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RenderTargetLayout::RenderTargetLayout(PTexture2D depthAttachment)
|
||||
: inputAttachments()
|
||||
, colorAttachments()
|
||||
, depthAttachment(depthAttachment)
|
||||
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment depthAttachment)
|
||||
: inputAttachments(), colorAttachments(), depthAttachment(depthAttachment)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RenderTargetLayout::RenderTargetLayout(PTexture2D colorAttachment, PTexture2D depthAttachment)
|
||||
: inputAttachments()
|
||||
, depthAttachment(depthAttachment)
|
||||
RenderTargetLayout::RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment)
|
||||
: inputAttachments(), depthAttachment(depthAttachment)
|
||||
{
|
||||
colorAttachments.add(colorAttachment);
|
||||
}
|
||||
RenderTargetLayout::RenderTargetLayout(Array<PTexture2D> colorAttachments, PTexture2D depthAttachmet)
|
||||
: inputAttachments()
|
||||
, colorAttachments(colorAttachments)
|
||||
, depthAttachment(depthAttachment)
|
||||
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet)
|
||||
: inputAttachments(), colorAttachments(colorAttachments), depthAttachment(depthAttachment)
|
||||
{
|
||||
|
||||
}
|
||||
RenderTargetLayout::RenderTargetLayout(Array<PTexture2D> inputAttachments, Array<PTexture2D> colorAttachments, PTexture2D depthAttachment)
|
||||
: inputAttachments(inputAttachments)
|
||||
, colorAttachments(colorAttachments)
|
||||
, depthAttachment(depthAttachment)
|
||||
RenderTargetLayout::RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment)
|
||||
: inputAttachments(inputAttachments), 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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -9,82 +9,117 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
struct GraphicsInitializer
|
||||
{
|
||||
const char* windowLayoutFile;
|
||||
const char* applicationName;
|
||||
const char* engineName;
|
||||
void* windowHandle;
|
||||
namespace Gfx
|
||||
{
|
||||
enum class QueueType
|
||||
{
|
||||
GRAPHICS = 1,
|
||||
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,
|
||||
* if ENABLE_VALIDATION is defined, standard validation is already enabled
|
||||
* not yet implemented
|
||||
*/
|
||||
Array<const char*> layers;
|
||||
Array<const char*> instanceExtensions;
|
||||
Array<const char*> deviceExtensions;
|
||||
Array<const char *> layers;
|
||||
Array<const char *> instanceExtensions;
|
||||
Array<const char *> deviceExtensions;
|
||||
GraphicsInitializer()
|
||||
: applicationName("SeeleEngine")
|
||||
, 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)
|
||||
: applicationName("SeeleEngine"), engineName("SeeleEngine"), layers{"VK_LAYER_LUNARG_standard_validation"}, instanceExtensions{}, deviceExtensions{"VK_KHR_swapchain"}, windowHandle(nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
struct WindowCreateInfo
|
||||
GraphicsInitializer(const GraphicsInitializer &other)
|
||||
: applicationName(other.applicationName), engineName(other.engineName), layers(other.layers), instanceExtensions(other.instanceExtensions), deviceExtensions(other.deviceExtensions)
|
||||
{
|
||||
}
|
||||
};
|
||||
struct WindowCreateInfo
|
||||
{
|
||||
int32 width;
|
||||
int32 height;
|
||||
const char* title;
|
||||
const char *title;
|
||||
bool bFullscreen;
|
||||
};
|
||||
namespace Gfx
|
||||
Gfx::SeFormat pixelFormat;
|
||||
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;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
};
|
||||
class RenderCommandBase
|
||||
};
|
||||
class RenderCommandBase
|
||||
{
|
||||
public:
|
||||
virtual ~RenderCommandBase()
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(RenderCommandBase);
|
||||
|
||||
class SamplerState
|
||||
{
|
||||
public:
|
||||
}
|
||||
};
|
||||
DEFINE_REF(RenderCommandBase);
|
||||
class SamplerState
|
||||
{
|
||||
public:
|
||||
virtual ~SamplerState()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
DEFINE_REF(SamplerState);
|
||||
class DescriptorBinding
|
||||
{
|
||||
public:
|
||||
};
|
||||
DEFINE_REF(SamplerState);
|
||||
class DescriptorBinding
|
||||
{
|
||||
public:
|
||||
DescriptorBinding()
|
||||
: binding(0)
|
||||
, 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)
|
||||
{}
|
||||
void operator=(const DescriptorBinding& other)
|
||||
: binding(0), descriptorType(SE_DESCRIPTOR_TYPE_MAX_ENUM), descriptorCount(0x7fff), shaderStages(SE_SHADER_STAGE_ALL)
|
||||
{
|
||||
}
|
||||
DescriptorBinding(const DescriptorBinding &other)
|
||||
: binding(other.binding), descriptorType(other.descriptorType), descriptorCount(other.descriptorCount), shaderStages(other.shaderStages)
|
||||
{
|
||||
}
|
||||
void operator=(const DescriptorBinding &other)
|
||||
{
|
||||
binding = other.binding;
|
||||
descriptorType = other.descriptorType;
|
||||
@@ -95,24 +130,24 @@ namespace Seele
|
||||
SeDescriptorType descriptorType;
|
||||
uint32_t descriptorCount;
|
||||
SeShaderStageFlags shaderStages;
|
||||
};
|
||||
DEFINE_REF(DescriptorBinding);
|
||||
};
|
||||
DEFINE_REF(DescriptorBinding);
|
||||
|
||||
DECLARE_REF(DescriptorSet);
|
||||
class DescriptorAllocator
|
||||
{
|
||||
public:
|
||||
DECLARE_REF(DescriptorSet);
|
||||
class DescriptorAllocator
|
||||
{
|
||||
public:
|
||||
DescriptorAllocator() {}
|
||||
~DescriptorAllocator() {}
|
||||
virtual void allocateDescriptorSet(PDescriptorSet& descriptorSet) = 0;
|
||||
};
|
||||
DEFINE_REF(DescriptorAllocator);
|
||||
DECLARE_REF(UniformBuffer);
|
||||
DECLARE_REF(StructuredBuffer);
|
||||
DECLARE_REF(Texture);
|
||||
class DescriptorSet
|
||||
{
|
||||
public:
|
||||
virtual ~DescriptorAllocator() {}
|
||||
virtual void allocateDescriptorSet(PDescriptorSet &descriptorSet) = 0;
|
||||
};
|
||||
DEFINE_REF(DescriptorAllocator);
|
||||
DECLARE_REF(UniformBuffer);
|
||||
DECLARE_REF(StructuredBuffer);
|
||||
DECLARE_REF(Texture);
|
||||
class DescriptorSet
|
||||
{
|
||||
public:
|
||||
virtual ~DescriptorSet() {}
|
||||
virtual void writeChanges() = 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 updateTexture(uint32 binding, PTexture texture, PSamplerState samplerState = nullptr) = 0;
|
||||
virtual bool operator<(PDescriptorSet other) = 0;
|
||||
};
|
||||
DEFINE_REF(DescriptorSet);
|
||||
};
|
||||
DEFINE_REF(DescriptorSet);
|
||||
|
||||
class DescriptorLayout
|
||||
{
|
||||
public:
|
||||
class DescriptorLayout
|
||||
{
|
||||
public:
|
||||
DescriptorLayout() {}
|
||||
virtual ~DescriptorLayout() {}
|
||||
void operator=(const DescriptorLayout& other)
|
||||
void operator=(const DescriptorLayout &other)
|
||||
{
|
||||
descriptorBindings.resize(other.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 addDescriptorBinding(uint32 binding, SeDescriptorType type, uint32 arrayCount = 1);
|
||||
virtual PDescriptorSet allocatedDescriptorSet();
|
||||
const Array<DescriptorBinding>& getBindings() const { return descriptorBindings; }
|
||||
protected:
|
||||
const Array<DescriptorBinding> &getBindings() const { return descriptorBindings; }
|
||||
|
||||
protected:
|
||||
Array<DescriptorBinding> descriptorBindings;
|
||||
PDescriptorAllocator allocator;
|
||||
friend class PipelineLayout;
|
||||
friend class DescriptorAllocator;
|
||||
};
|
||||
DEFINE_REF(DescriptorLayout);
|
||||
class PipelineLayout
|
||||
{
|
||||
public:
|
||||
};
|
||||
DEFINE_REF(DescriptorLayout);
|
||||
class PipelineLayout
|
||||
{
|
||||
public:
|
||||
PipelineLayout() {}
|
||||
virtual ~PipelineLayout() {}
|
||||
virtual void create() = 0;
|
||||
void addDescriptorLayout(uint32 setIndex, PDescriptorLayout layout);
|
||||
void addPushConstants(const SePushConstantRange& pushConstants);
|
||||
void addPushConstants(const SePushConstantRange &pushConstants);
|
||||
virtual uint32 getHash() const = 0;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
Array<PDescriptorLayout> descriptorSetLayouts;
|
||||
Array<SePushConstantRange> pushConstants;
|
||||
};
|
||||
DEFINE_REF(PipelineLayout);
|
||||
class VertexDeclaration
|
||||
};
|
||||
DEFINE_REF(PipelineLayout);
|
||||
class VertexDeclaration
|
||||
{
|
||||
public:
|
||||
virtual ~VertexDeclaration()
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(VertexDeclaration);
|
||||
class GraphicsPipeline
|
||||
{
|
||||
public:
|
||||
}
|
||||
};
|
||||
DEFINE_REF(VertexDeclaration);
|
||||
class GraphicsPipeline
|
||||
{
|
||||
public:
|
||||
virtual ~GraphicsPipeline()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
DEFINE_REF(GraphicsPipeline);
|
||||
class UniformBuffer
|
||||
};
|
||||
DEFINE_REF(GraphicsPipeline);
|
||||
class UniformBuffer
|
||||
{
|
||||
public:
|
||||
UniformBuffer();
|
||||
virtual ~UniformBuffer();
|
||||
};
|
||||
DEFINE_REF(UniformBuffer);
|
||||
class VertexBuffer
|
||||
{
|
||||
public:
|
||||
virtual ~VertexBuffer()
|
||||
{
|
||||
public:
|
||||
virtual ~UniformBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
DEFINE_REF(UniformBuffer);
|
||||
class Viewport
|
||||
};
|
||||
DEFINE_REF(VertexBuffer);
|
||||
class IndexBuffer
|
||||
{
|
||||
public:
|
||||
virtual ~IndexBuffer()
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(Viewport);
|
||||
class VertexBuffer
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(VertexBuffer);
|
||||
class IndexBuffer
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(IndexBuffer);
|
||||
class StructuredBuffer
|
||||
{
|
||||
public:
|
||||
}
|
||||
};
|
||||
DEFINE_REF(IndexBuffer);
|
||||
class StructuredBuffer
|
||||
{
|
||||
public:
|
||||
virtual ~StructuredBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
DEFINE_REF(StructuredBuffer);
|
||||
class Texture
|
||||
};
|
||||
DEFINE_REF(StructuredBuffer);
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
virtual ~Texture()
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(Texture);
|
||||
class Texture2D : public Texture
|
||||
{
|
||||
public:
|
||||
}
|
||||
};
|
||||
DEFINE_REF(Texture);
|
||||
class Texture2D : public Texture
|
||||
{
|
||||
public:
|
||||
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(PTexture2D depthAttachment);
|
||||
RenderTargetLayout(PTexture2D colorAttachment, PTexture2D depthAttachment);
|
||||
RenderTargetLayout(Array<PTexture2D> colorAttachments, PTexture2D depthAttachmet);
|
||||
RenderTargetLayout(Array<PTexture2D> inputAttachments, Array<PTexture2D> colorAttachments, PTexture2D depthAttachment);
|
||||
Array<PTexture2D> inputAttachments;
|
||||
Array<PTexture2D> colorAttachments;
|
||||
PTexture2D depthAttachment;
|
||||
};
|
||||
DEFINE_REF(RenderTargetLayout);
|
||||
RenderTargetLayout(PRenderTargetAttachment depthAttachment);
|
||||
RenderTargetLayout(PRenderTargetAttachment colorAttachment, PRenderTargetAttachment depthAttachment);
|
||||
RenderTargetLayout(Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachmet);
|
||||
RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment);
|
||||
Array<PRenderTargetAttachment> inputAttachments;
|
||||
Array<PRenderTargetAttachment> colorAttachments;
|
||||
PRenderTargetAttachment depthAttachment;
|
||||
};
|
||||
DEFINE_REF(RenderTargetLayout);
|
||||
|
||||
class RenderPass
|
||||
class RenderPass
|
||||
{
|
||||
public:
|
||||
virtual ~RenderPass()
|
||||
{
|
||||
|
||||
};
|
||||
DEFINE_REF(RenderPass);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(RenderPass);
|
||||
|
||||
DEFINE_REF(RenderPass);
|
||||
} // namespace Gfx
|
||||
} // namespace Seele
|
||||
@@ -21,7 +21,7 @@ void Seele::RenderCore::init()
|
||||
|
||||
void Seele::RenderCore::renderLoop()
|
||||
{
|
||||
while(windowManager->isActive())
|
||||
while (windowManager->isActive())
|
||||
{
|
||||
windowManager->beginFrame();
|
||||
windowManager->endFrame();
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
#include "WindowManager.h"
|
||||
namespace Seele
|
||||
{
|
||||
class RenderCore
|
||||
{
|
||||
public:
|
||||
class RenderCore
|
||||
{
|
||||
public:
|
||||
RenderCore();
|
||||
~RenderCore();
|
||||
void init();
|
||||
void renderLoop();
|
||||
void shutdown();
|
||||
private:
|
||||
|
||||
private:
|
||||
PWindowManager windowManager;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -2,10 +2,10 @@
|
||||
#include "Graphics.h"
|
||||
namespace Seele
|
||||
{
|
||||
//A renderpath is a general Renderer for a view.
|
||||
class RenderPath
|
||||
{
|
||||
public:
|
||||
//A renderpath is a general Renderer for a view.
|
||||
class RenderPath
|
||||
{
|
||||
public:
|
||||
RenderPath(Gfx::PGraphics graphics);
|
||||
virtual ~RenderPath();
|
||||
virtual void applyArea(Rect area) = 0;
|
||||
@@ -13,9 +13,10 @@ namespace Seele
|
||||
virtual void beginFrame() = 0;
|
||||
virtual void render() = 0;
|
||||
virtual void endFrame() = 0;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
Gfx::PGraphics graphics;
|
||||
Rect area;
|
||||
};
|
||||
DEFINE_REF(RenderPath);
|
||||
}
|
||||
};
|
||||
DEFINE_REF(RenderPath);
|
||||
} // namespace Seele
|
||||
@@ -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()
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class SceneRenderPath : public RenderPath
|
||||
{
|
||||
public:
|
||||
class SceneRenderPath : public RenderPath
|
||||
{
|
||||
public:
|
||||
SceneRenderPath(Gfx::PGraphics graphics);
|
||||
virtual ~SceneRenderPath();
|
||||
virtual void applyArea(Rect area) override;
|
||||
@@ -13,5 +13,5 @@ namespace Seele
|
||||
virtual void beginFrame() override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -2,10 +2,10 @@
|
||||
#include "View.h"
|
||||
namespace Seele
|
||||
{
|
||||
class SceneView : public View
|
||||
{
|
||||
public:
|
||||
class SceneView : public View
|
||||
{
|
||||
public:
|
||||
SceneView(Gfx::PGraphics graphics);
|
||||
~SceneView();
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -2,19 +2,20 @@
|
||||
#include "RenderPath.h"
|
||||
namespace Seele
|
||||
{
|
||||
// A view is a part of the window, which can be anything from a viewport to an editor
|
||||
class View
|
||||
{
|
||||
public:
|
||||
// A view is a part of the window, which can be anything from a viewport to an editor
|
||||
class View
|
||||
{
|
||||
public:
|
||||
View(Gfx::PGraphics graphics);
|
||||
virtual ~View();
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
void applyArea(Rect area);
|
||||
protected:
|
||||
|
||||
protected:
|
||||
Gfx::PGraphics graphics;
|
||||
PRenderPath renderer;
|
||||
};
|
||||
};
|
||||
|
||||
DEFINE_REF(View)
|
||||
}
|
||||
DEFINE_REF(View)
|
||||
} // namespace Seele
|
||||
@@ -20,4 +20,5 @@ target_sources(SeeleEngine
|
||||
VulkanRenderPass.cpp
|
||||
VulkanTexture.cpp
|
||||
VulkanQueue.h
|
||||
VulkanQueue.cpp)
|
||||
VulkanQueue.cpp
|
||||
VulkanViewport.cpp)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
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)
|
||||
, size(size)
|
||||
, 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())
|
||||
, allocator(allocator)
|
||||
, bytesAllocated(0)
|
||||
, bytesUsed(0)
|
||||
, readable(properties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
|
||||
, properties(properties)
|
||||
, memoryTypeIndex(memoryTypeIndex)
|
||||
{
|
||||
@@ -26,38 +58,52 @@ Allocation::Allocation(PGraphics graphics, Allocator* allocator, uint32 size, ui
|
||||
init::MemoryAllocateInfo();
|
||||
allocInfo.allocationSize = size;
|
||||
allocInfo.memoryTypeIndex = memoryTypeIndex;
|
||||
isDedicated = dedicatedInfo != nullptr;
|
||||
allocInfo.pNext = dedicatedInfo;
|
||||
VK_CHECK(vkAllocateMemory(device, &allocInfo, nullptr, &allocatedMemory));
|
||||
bytesAllocated = 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 (activeAllocations.size() == 0)
|
||||
if (activeAllocations.empty())
|
||||
{
|
||||
assert(requestedSize == bytesAllocated);
|
||||
activeAllocations.add(freeRanges.back());
|
||||
PSubAllocation suballoc = freeRanges[0];
|
||||
activeAllocations[0] = suballoc.getHandle();
|
||||
freeRanges.clear();
|
||||
bytesUsed += requestedSize;
|
||||
return suballoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < freeRanges.size(); ++i)
|
||||
for (uint32 i = 0; i < freeRanges.size(); ++i)
|
||||
{
|
||||
PSubAllocation freeAllocation = freeRanges[i];
|
||||
uint32 allocatedOffset = freeAllocation->allocatedOffset;
|
||||
uint32 alignedOffset = align(allocatedOffset, alignment);
|
||||
uint32 alignmentAdjustment = alignedOffset - allocatedOffset;
|
||||
uint32 size = alignmentAdjustment + requestedSize;
|
||||
VkDeviceSize allocatedOffset = freeAllocation->allocatedOffset;
|
||||
VkDeviceSize alignedOffset = align(allocatedOffset, alignment);
|
||||
VkDeviceSize alignmentAdjustment = alignedOffset - allocatedOffset;
|
||||
VkDeviceSize size = alignmentAdjustment + requestedSize;
|
||||
if (freeAllocation->size == size)
|
||||
{
|
||||
freeRanges.remove(i);
|
||||
activeAllocations.add(freeAllocation);
|
||||
freeRanges.erase(allocatedOffset);
|
||||
activeAllocations[allocatedOffset] = freeAllocation.getHandle();
|
||||
bytesUsed += size;
|
||||
return freeAllocation;
|
||||
}
|
||||
else if (size < freeAllocation->allocatedSize)
|
||||
@@ -67,19 +113,61 @@ PSubAllocation Allocation::getSuballocation(uint32 requestedSize, uint32 alignme
|
||||
freeAllocation->allocatedOffset += allocatedOffset;
|
||||
freeAllocation->alignedOffset += allocatedOffset;
|
||||
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 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)
|
||||
: graphics(graphics)
|
||||
{
|
||||
vkGetPhysicalDeviceMemoryProperties(graphics->getPhysicalDevice(), &memProperties);
|
||||
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];
|
||||
HeapInfo& heapInfo = heaps[i];
|
||||
@@ -89,25 +177,68 @@ Allocator::Allocator(PGraphics graphics)
|
||||
|
||||
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;
|
||||
uint32 memoryTypeIndex;
|
||||
uint8 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;
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@@ -122,3 +253,78 @@ VkResult Allocator::findMemoryType(uint32 typeBits, VkMemoryPropertyFlags proper
|
||||
|
||||
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()));
|
||||
}
|
||||
@@ -6,69 +6,211 @@
|
||||
|
||||
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);
|
||||
class Allocation;
|
||||
class Allocator;
|
||||
class SubAllocation
|
||||
return size;
|
||||
}
|
||||
inline VkDeviceSize getOffset() const
|
||||
{
|
||||
public:
|
||||
SubAllocation(Allocation* owner, uint32 allocatedOffset, uint32 size, uint32 alignedOffset, uint32 allocatedSize);
|
||||
private:
|
||||
Allocation* owner;
|
||||
uint32 allocatedOffset;
|
||||
uint32 size;
|
||||
uint32 alignedOffset;
|
||||
uint32 allocatedSize;
|
||||
return alignedOffset;
|
||||
}
|
||||
inline bool isReadable() const;
|
||||
void *getMappedPointer();
|
||||
void flushMemory();
|
||||
void invalidateMemory();
|
||||
|
||||
private:
|
||||
Allocation *owner;
|
||||
VkDeviceSize allocatedOffset;
|
||||
VkDeviceSize size;
|
||||
VkDeviceSize alignedOffset;
|
||||
VkDeviceSize allocatedSize;
|
||||
friend class Allocation;
|
||||
friend class Allocator;
|
||||
};
|
||||
DEFINE_REF(SubAllocation);
|
||||
class Allocation
|
||||
};
|
||||
DEFINE_REF(SubAllocation);
|
||||
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:
|
||||
Allocation(PGraphics graphics, Allocator* allocator, uint32 size, uint32 memoryTypeIndex, VkMemoryPropertyFlags properties, bool isDedicated);
|
||||
PSubAllocation getSuballocation(uint32 size, uint32 alignment);
|
||||
private:
|
||||
Allocator* allocator;
|
||||
return allocatedMemory;
|
||||
}
|
||||
inline void *getMappedPointer()
|
||||
{
|
||||
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;
|
||||
VkDeviceMemory allocatedMemory;
|
||||
VkDeviceSize bytesAllocated;
|
||||
VkDeviceSize bytesUsed;
|
||||
VkMemoryPropertyFlags properties;
|
||||
Array<PSubAllocation> activeAllocations;
|
||||
Array<PSubAllocation> freeRanges;
|
||||
void* mappedPointer;
|
||||
Map<VkDeviceSize, SubAllocation *> activeAllocations;
|
||||
Map<VkDeviceSize, PSubAllocation> freeRanges;
|
||||
void *mappedPointer;
|
||||
uint8 memoryTypeIndex;
|
||||
uint8 isDedicated : 1;
|
||||
uint8 canMap : 1;
|
||||
uint8 memoryTypeIndex;
|
||||
uint8 isMapped : 1;
|
||||
uint8 readable : 1;
|
||||
friend class Allocator;
|
||||
};
|
||||
DEFINE_REF(Allocation);
|
||||
};
|
||||
DEFINE_REF(Allocation);
|
||||
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
Allocator(PGraphics graphics);
|
||||
~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
|
||||
{
|
||||
MemoryBlockSize = 64 * 1024 * 1024 // 64MB
|
||||
};
|
||||
struct HeapInfo
|
||||
{
|
||||
uint32 maxSize = 0;
|
||||
VkDeviceSize maxSize = 0;
|
||||
Array<PAllocation> allocations;
|
||||
};
|
||||
Array<HeapInfo> heaps;
|
||||
VkResult findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint32* typeIndex);
|
||||
VkResult findMemoryType(uint32 typeBits, VkMemoryPropertyFlags properties, uint8 *typeIndex);
|
||||
PGraphics graphics;
|
||||
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
|
||||
@@ -1,28 +1,329 @@
|
||||
#include "VulkanGraphicsResources.h"
|
||||
#include "VulkanInitializer.h"
|
||||
#include "VulkanGraphics.h"
|
||||
#include "VulkanCommandBuffer.h"
|
||||
#include "VulkanAllocator.h"
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
QueueOwnedResource::QueueOwnedResource(PGraphics graphics, QueueType startQueueType)
|
||||
: graphics(graphics)
|
||||
, currentOwner(startQueueType)
|
||||
struct PendingBuffer
|
||||
{
|
||||
}
|
||||
PStagingBuffer stagingBuffer;
|
||||
Gfx::QueueType prevQueue;
|
||||
bool bWriteOnly;
|
||||
};
|
||||
|
||||
QueueOwnedResource::~QueueOwnedResource()
|
||||
{
|
||||
}
|
||||
static Map<Buffer *, PendingBuffer> pendingBuffers;
|
||||
|
||||
Buffer::Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, QueueType queueType)
|
||||
: QueueOwnedResource(graphics, queueType)
|
||||
Buffer::Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType 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()
|
||||
{
|
||||
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, ®ions);
|
||||
|
||||
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(®ion, 0, sizeof(VkBufferCopy));
|
||||
region.size = size;
|
||||
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
||||
|
||||
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;
|
||||
|
||||
CmdBufferBase::CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool)
|
||||
: graphics(graphics)
|
||||
, owner(cmdPool)
|
||||
: graphics(graphics), owner(cmdPool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CmdBufferBase::~CmdBufferBase()
|
||||
{
|
||||
graphics = nullptr;
|
||||
}
|
||||
|
||||
CmdBuffer::CmdBuffer(PGraphics graphics, VkCommandPool cmdPool)
|
||||
: CmdBufferBase(graphics, cmdPool)
|
||||
, renderPass(nullptr)
|
||||
, framebuffer(nullptr)
|
||||
, subpassIndex(0)
|
||||
: CmdBufferBase(graphics, cmdPool), renderPass(nullptr), framebuffer(nullptr), subpassIndex(0)
|
||||
{
|
||||
VkCommandBufferAllocateInfo allocInfo =
|
||||
init::CommandBufferAllocateInfo(cmdPool,
|
||||
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||
1);
|
||||
|
||||
VK_CHECK(vkAllocateCommandBuffers(graphics->getDevice(), &allocInfo, &handle))
|
||||
|
||||
fence = new Fence(graphics);
|
||||
state = State::ReadyBegin;
|
||||
}
|
||||
|
||||
CmdBuffer::~CmdBuffer()
|
||||
{
|
||||
vkFreeCommandBuffers(graphics->getDevice(), owner, 1, &handle);
|
||||
renderPass = nullptr;
|
||||
framebuffer = nullptr;
|
||||
waitSemaphores.clear();
|
||||
}
|
||||
|
||||
void CmdBuffer::begin()
|
||||
@@ -54,8 +54,11 @@ void CmdBuffer::end()
|
||||
state = State::Ended;
|
||||
}
|
||||
|
||||
void CmdBuffer::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer)
|
||||
void CmdBuffer::beginRenderPass(PRenderPass newRenderPass, PFramebuffer newFramebuffer)
|
||||
{
|
||||
renderPass = newRenderPass;
|
||||
framebuffer = newFramebuffer;
|
||||
|
||||
VkRenderPassBeginInfo beginInfo =
|
||||
init::RenderPassBeginInfo();
|
||||
beginInfo.clearValueCount = renderPass->getClearValueCount();
|
||||
@@ -64,11 +67,49 @@ void CmdBuffer::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer
|
||||
beginInfo.renderPass = renderPass->getHandle();
|
||||
beginInfo.framebuffer = framebuffer->getHandle();
|
||||
vkCmdBeginRenderPass(handle, &beginInfo, renderPass->getSubpassContents());
|
||||
state = State::RenderPassActive;
|
||||
}
|
||||
|
||||
void CmdBuffer::endRenderPass()
|
||||
{
|
||||
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)
|
||||
@@ -105,8 +146,7 @@ void SecondaryCmdBuffer::end()
|
||||
}
|
||||
|
||||
CommandBufferManager::CommandBufferManager(PGraphics graphics, PQueue queue)
|
||||
: graphics(graphics)
|
||||
, queue(queue)
|
||||
: graphics(graphics), queue(queue)
|
||||
{
|
||||
VkCommandPoolCreateInfo info =
|
||||
init::CommandPoolCreateInfo();
|
||||
@@ -117,11 +157,14 @@ CommandBufferManager::CommandBufferManager(PGraphics graphics, PQueue queue)
|
||||
|
||||
activeCmdBuffer = new CmdBuffer(graphics, commandPool);
|
||||
activeCmdBuffer->begin();
|
||||
allocatedBuffers.add(activeCmdBuffer);
|
||||
}
|
||||
|
||||
CommandBufferManager::~CommandBufferManager()
|
||||
{
|
||||
vkDestroyCommandPool(graphics->getDevice(), commandPool, nullptr);
|
||||
graphics = nullptr;
|
||||
queue = nullptr;
|
||||
}
|
||||
|
||||
PCmdBuffer CommandBufferManager::getCommands()
|
||||
@@ -136,16 +179,15 @@ PSecondaryCmdBuffer CommandBufferManager::createSecondaryCmdBuffer()
|
||||
|
||||
void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
|
||||
{
|
||||
if(activeCmdBuffer->state == CmdBuffer::State::InsideBegin
|
||||
|| activeCmdBuffer->state == CmdBuffer::State::RenderPassActive)
|
||||
if (activeCmdBuffer->state == CmdBuffer::State::InsideBegin || 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;
|
||||
activeCmdBuffer->endRenderPass();
|
||||
}
|
||||
activeCmdBuffer->end();
|
||||
if(signalSemaphore != nullptr)
|
||||
if (signalSemaphore != nullptr)
|
||||
{
|
||||
queue->submitCommandBuffer(activeCmdBuffer, signalSemaphore->getHandle());
|
||||
}
|
||||
@@ -154,11 +196,11 @@ void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
|
||||
queue->submitCommandBuffer(activeCmdBuffer);
|
||||
}
|
||||
}
|
||||
for(int32_t i = 0; i < allocatedBuffers.size(); ++i)
|
||||
for (uint32 i = 0; i < allocatedBuffers.size(); ++i)
|
||||
{
|
||||
PCmdBuffer cmdBuffer = allocatedBuffers[i];
|
||||
cmdBuffer->refreshFences();
|
||||
if(cmdBuffer->state == CmdBuffer::State::ReadyBegin)
|
||||
cmdBuffer->refreshFence();
|
||||
if (cmdBuffer->state == CmdBuffer::State::ReadyBegin)
|
||||
{
|
||||
activeCmdBuffer = cmdBuffer;
|
||||
activeCmdBuffer->begin();
|
||||
@@ -173,3 +215,9 @@ void CommandBufferManager::submitCommands(PSemaphore signalSemaphore)
|
||||
allocatedBuffers.add(activeCmdBuffer);
|
||||
activeCmdBuffer->begin();
|
||||
}
|
||||
|
||||
void CommandBufferManager::waitForCommands(PCmdBuffer cmdBuffer, uint32 timeout)
|
||||
{
|
||||
cmdBuffer->fence->wait(timeout);
|
||||
cmdBuffer->refreshFence();
|
||||
}
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(RenderPass);
|
||||
DECLARE_REF(Framebuffer);
|
||||
class CmdBufferBase : public Gfx::RenderCommandBase
|
||||
{
|
||||
public:
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(RenderPass);
|
||||
DECLARE_REF(Framebuffer);
|
||||
class CmdBufferBase : public Gfx::RenderCommandBase
|
||||
{
|
||||
public:
|
||||
CmdBufferBase(PGraphics graphics, VkCommandPool cmdPool);
|
||||
virtual ~CmdBufferBase();
|
||||
inline VkCommandBuffer getHandle()
|
||||
@@ -20,17 +20,18 @@ namespace Seele
|
||||
void reset();
|
||||
VkViewport currentViewport;
|
||||
VkRect2D currentScissor;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
PGraphics graphics;
|
||||
VkCommandBuffer handle;
|
||||
VkCommandPool owner;
|
||||
};
|
||||
DEFINE_REF(CmdBufferBase);
|
||||
};
|
||||
DEFINE_REF(CmdBufferBase);
|
||||
|
||||
DECLARE_REF(SecondaryCmdBuffer);
|
||||
class CmdBuffer : public CmdBufferBase
|
||||
{
|
||||
public:
|
||||
DECLARE_REF(SecondaryCmdBuffer);
|
||||
class CmdBuffer : public CmdBufferBase
|
||||
{
|
||||
public:
|
||||
CmdBuffer(PGraphics graphics, VkCommandPool cmdPool);
|
||||
virtual ~CmdBuffer();
|
||||
void begin();
|
||||
@@ -39,6 +40,7 @@ namespace Seele
|
||||
void endRenderPass();
|
||||
void executeCommands(Array<PSecondaryCmdBuffer> secondaryCommands);
|
||||
void addWaitSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore);
|
||||
void refreshFence();
|
||||
enum State
|
||||
{
|
||||
ReadyBegin,
|
||||
@@ -48,44 +50,54 @@ namespace Seele
|
||||
Submitted,
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
PRenderPass renderPass;
|
||||
PFramebuffer framebuffer;
|
||||
PFence fence;
|
||||
uint32 subpassIndex;
|
||||
State state;
|
||||
Array<PSemaphore> waitSemaphores;
|
||||
Array<VkPipelineStageFlags> waitFlags;
|
||||
friend class SecondaryCmdBuffer;
|
||||
friend class CommandBufferManager;
|
||||
};
|
||||
DEFINE_REF(CmdBuffer);
|
||||
friend class Queue;
|
||||
};
|
||||
DEFINE_REF(CmdBuffer);
|
||||
|
||||
class SecondaryCmdBuffer : public CmdBufferBase
|
||||
{
|
||||
public:
|
||||
class SecondaryCmdBuffer : public CmdBufferBase
|
||||
{
|
||||
public:
|
||||
SecondaryCmdBuffer(PGraphics graphics, VkCommandPool cmdPool);
|
||||
virtual ~SecondaryCmdBuffer();
|
||||
void begin(PCmdBuffer parent);
|
||||
void end();
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(SecondaryCmdBuffer);
|
||||
|
||||
class CommandBufferManager
|
||||
{
|
||||
public:
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(SecondaryCmdBuffer);
|
||||
|
||||
class CommandBufferManager
|
||||
{
|
||||
public:
|
||||
CommandBufferManager(PGraphics graphics, PQueue queue);
|
||||
virtual ~CommandBufferManager();
|
||||
inline PQueue getQueue() const
|
||||
{
|
||||
return queue;
|
||||
}
|
||||
PCmdBuffer getCommands();
|
||||
PSecondaryCmdBuffer createSecondaryCmdBuffer();
|
||||
void submitCommands(PSemaphore signalSemaphore = nullptr);
|
||||
void waitForCommands(PCmdBuffer cmdBuffer, float timeToWait = 1.0f);
|
||||
private:
|
||||
void waitForCommands(PCmdBuffer cmdBuffer, uint32 timeToWait = 1000000u);
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
VkCommandPool commandPool;
|
||||
PQueue queue;
|
||||
uint32 queueFamilyIndex;
|
||||
PCmdBuffer activeCmdBuffer;
|
||||
Array<PCmdBuffer> allocatedBuffers;
|
||||
};
|
||||
DEFINE_REF(CommandBufferManager);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(CommandBufferManager);
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "VulkanGraphicsEnums.h"
|
||||
#include "VulkanGraphics.h"
|
||||
#include "VulkanInitializer.h"
|
||||
#include "VulkanDescriptorSets.h"
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
@@ -23,8 +24,8 @@ void DescriptorLayout::create()
|
||||
bindings.resize(descriptorBindings.size());
|
||||
for (size_t i = 0; i < descriptorBindings.size(); ++i)
|
||||
{
|
||||
VkDescriptorSetLayoutBinding& binding = bindings[i];
|
||||
const Gfx::DescriptorBinding& rhiBinding = descriptorBindings[i];
|
||||
VkDescriptorSetLayoutBinding &binding = bindings[i];
|
||||
const Gfx::DescriptorBinding &rhiBinding = descriptorBindings[i];
|
||||
binding.binding = rhiBinding.binding;
|
||||
binding.descriptorCount = rhiBinding.descriptorCount;
|
||||
binding.descriptorType = cast(rhiBinding.descriptorType);
|
||||
@@ -78,8 +79,8 @@ DescriptorSet::~DescriptorSet()
|
||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
|
||||
{
|
||||
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
||||
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
|
||||
// bufferInfos.add(bufferInfo);
|
||||
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
|
||||
// bufferInfos.add(bufferInfo);
|
||||
|
||||
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back());
|
||||
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)
|
||||
{
|
||||
PStructuredBuffer vulkanBuffer = uniformBuffer.cast<StructuredBuffer>();
|
||||
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
|
||||
// bufferInfos.add(bufferInfo);
|
||||
// VkDescriptorBufferInfo bufferInfo = init::DescriptorBufferInfo(vulkanBuffer->getHandle(), vulkanBuffer->getOffset(), vulkanBuffer->getSize());
|
||||
// bufferInfos.add(bufferInfo);
|
||||
|
||||
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, binding, &bufferInfos.back());
|
||||
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)
|
||||
{
|
||||
// VulkanTextureBase* vulkanTexture = VulkanTextureBase::cast(texture);
|
||||
PTextureHandle vulkanTexture = TextureBase::cast(texture);
|
||||
//It is assumed that the image is in the correct layout
|
||||
// VkDescriptorImageInfo imageInfo =
|
||||
// init::DescriptorImageInfo(
|
||||
// VK_NULL_HANDLE,
|
||||
// vulkanTexture->defaultView.view,
|
||||
// graphics->getRHIDevice().findLayout(vulkanTexture->surface.image));
|
||||
VkDescriptorImageInfo imageInfo =
|
||||
init::DescriptorImageInfo(
|
||||
VK_NULL_HANDLE,
|
||||
vulkanTexture->getView(),
|
||||
vulkanTexture->getLayout());
|
||||
if (samplerState != nullptr)
|
||||
{
|
||||
// PVulkanSamplerState vulkanSampler = samplerState.cast<VulkanSamplerState>();
|
||||
// imageInfo.sampler = vulkanSampler->sampler;
|
||||
PSamplerState vulkanSampler = samplerState.cast<SamplerState>();
|
||||
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());
|
||||
// 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);
|
||||
}
|
||||
@@ -149,20 +150,19 @@ void DescriptorSet::writeChanges()
|
||||
}
|
||||
}
|
||||
|
||||
DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout& layout)
|
||||
: layout(layout)
|
||||
, graphics(graphics)
|
||||
DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout &layout)
|
||||
: layout(layout), graphics(graphics)
|
||||
{
|
||||
uint32 perTypeSizes[VK_DESCRIPTOR_TYPE_END_RANGE];
|
||||
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;
|
||||
perTypeSizes[typeIndex] += 256;
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -179,9 +179,10 @@ DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout& l
|
||||
DescriptorAllocator::~DescriptorAllocator()
|
||||
{
|
||||
vkDestroyDescriptorPool(graphics->getDevice(), poolHandle, nullptr);
|
||||
graphics = nullptr;
|
||||
}
|
||||
|
||||
void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet& descriptorSet)
|
||||
void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet &descriptorSet)
|
||||
{
|
||||
descriptorSet = new DescriptorSet(graphics, this);
|
||||
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)
|
||||
, renderPass(renderPass)
|
||||
{
|
||||
FramebufferDescription description;
|
||||
std::memset(&description, 0, sizeof(FramebufferDescription));
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
description.depthAttachment = vkDepthAttachment->getView();
|
||||
}
|
||||
|
||||
VkFramebufferCreateInfo createInfo =
|
||||
init::FramebufferCreateInfo(
|
||||
renderPass->getHandle(),
|
||||
@@ -36,9 +40,10 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
|
||||
attachments.data(),
|
||||
renderPass->getRenderArea().extent.width,
|
||||
renderPass->getRenderArea().extent.height,
|
||||
1
|
||||
);
|
||||
1);
|
||||
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
|
||||
|
||||
hash = memCrc32(&description, sizeof(FramebufferDescription));
|
||||
}
|
||||
|
||||
Framebuffer::~Framebuffer()
|
||||
|
||||
@@ -3,24 +3,37 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(RenderPass);
|
||||
class Framebuffer
|
||||
{
|
||||
public:
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(RenderPass);
|
||||
struct FramebufferDescription
|
||||
{
|
||||
VkImageView inputAttachments[16];
|
||||
VkImageView colorAttachments[16];
|
||||
VkImageView depthAttachment;
|
||||
uint32 numInputAttachments;
|
||||
uint32 numColorAttachments;
|
||||
};
|
||||
class Framebuffer
|
||||
{
|
||||
public:
|
||||
Framebuffer(PGraphics graphics, PRenderPass renderpass, Gfx::PRenderTargetLayout renderTargetLayout);
|
||||
virtual ~Framebuffer();
|
||||
inline VkFramebuffer getHandle() const
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
private:
|
||||
inline uint32 getHash() const
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
private:
|
||||
uint32 hash;
|
||||
PGraphics graphics;
|
||||
VkFramebuffer handle;
|
||||
Gfx::PRenderTargetLayout layout;
|
||||
PRenderPass renderPass;
|
||||
};
|
||||
DEFINE_REF(Framebuffer);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(Framebuffer);
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
@@ -1,26 +1,33 @@
|
||||
#include "Containers/Array.h"
|
||||
#include "VulkanGraphics.h"
|
||||
#include "VulkanAllocator.h"
|
||||
#include "VulkanQueue.h"
|
||||
#include "Containers/Array.h"
|
||||
#include "VulkanInitializer.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;
|
||||
|
||||
Graphics::Graphics()
|
||||
: 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()
|
||||
{
|
||||
allocator = nullptr;
|
||||
stagingManager = nullptr;
|
||||
graphicsCommands = nullptr;
|
||||
computeCommands = nullptr;
|
||||
transferCommands = nullptr;
|
||||
dedicatedTransferCommands = nullptr;
|
||||
viewports.clear();
|
||||
vkDestroyDevice(handle, nullptr);
|
||||
DestroyDebugReportCallbackEXT(instance, nullptr, callback);
|
||||
vkDestroyInstance(instance, nullptr);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
void Graphics::init(GraphicsInitializer initInfo)
|
||||
@@ -30,27 +37,86 @@ void Graphics::init(GraphicsInitializer initInfo)
|
||||
pickPhysicalDevice();
|
||||
createDevice(initInfo);
|
||||
allocator = new Allocator(this);
|
||||
stagingManager = new StagingManager(this, allocator);
|
||||
graphicsCommands = new CommandBufferManager(this, graphicsQueue);
|
||||
computeCommands = new CommandBufferManager(this, computeQueue);
|
||||
transferCommands = new CommandBufferManager(this, transferQueue);
|
||||
dedicatedTransferCommands = new CommandBufferManager(this, dedicatedTransferQueue);
|
||||
}
|
||||
|
||||
void Graphics::beginFrame(void *windowHandle)
|
||||
Gfx::PWindow Graphics::createWindow(const WindowCreateInfo &createInfo)
|
||||
{
|
||||
GLFWwindow *window = static_cast<GLFWwindow *>(windowHandle);
|
||||
glfwPollEvents();
|
||||
PWindow result = new Window(this, createInfo);
|
||||
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);
|
||||
return window;
|
||||
graphicsCommands->getCommands()->endRenderPass();
|
||||
}
|
||||
|
||||
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
|
||||
@@ -84,6 +150,11 @@ PAllocator Graphics::getAllocator()
|
||||
return allocator;
|
||||
}
|
||||
|
||||
PStagingManager Graphics::getStagingManager()
|
||||
{
|
||||
return stagingManager;
|
||||
}
|
||||
|
||||
Array<const char *> Graphics::getRequiredExtensions()
|
||||
{
|
||||
Array<const char *> extensions;
|
||||
@@ -143,13 +214,13 @@ void Graphics::pickPhysicalDevice()
|
||||
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr);
|
||||
Array<VkPhysicalDevice> physicalDevices(physicalDeviceCount);
|
||||
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data());
|
||||
VkPhysicalDevice bestDevice;
|
||||
VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
|
||||
uint32 deviceRating = 0;
|
||||
for (auto physicalDevice : physicalDevices)
|
||||
for (auto dev : physicalDevices)
|
||||
{
|
||||
uint32 currentRating = 0;
|
||||
vkGetPhysicalDeviceProperties(physicalDevice, &props);
|
||||
vkGetPhysicalDeviceFeatures(physicalDevice, &features);
|
||||
vkGetPhysicalDeviceProperties(dev, &props);
|
||||
vkGetPhysicalDeviceFeatures(dev, &features);
|
||||
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
|
||||
{
|
||||
currentRating += 100;
|
||||
@@ -161,10 +232,12 @@ void Graphics::pickPhysicalDevice()
|
||||
if (currentRating > deviceRating)
|
||||
{
|
||||
deviceRating = currentRating;
|
||||
bestDevice = physicalDevice;
|
||||
bestDevice = dev;
|
||||
}
|
||||
}
|
||||
this->physicalDevice = bestDevice;
|
||||
physicalDevice = bestDevice;
|
||||
vkGetPhysicalDeviceProperties(physicalDevice, &props);
|
||||
vkGetPhysicalDeviceFeatures(physicalDevice, &features);
|
||||
}
|
||||
|
||||
void Graphics::createDevice(GraphicsInitializer initializer)
|
||||
@@ -180,11 +253,12 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
||||
int32_t dedicatedTransferQueueFamilyIndex = -1;
|
||||
int32_t computeQueueFamilyIndex = -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;
|
||||
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;
|
||||
if ((currProps.queueFlags & VK_QUEUE_GRAPHICS_BIT) == VK_QUEUE_GRAPHICS_BIT)
|
||||
{
|
||||
@@ -204,7 +278,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
||||
{
|
||||
if (asyncComputeFamilyIndex == -1)
|
||||
{
|
||||
if (familyIndex == graphicsQueueFamilyIndex)
|
||||
if (familyIndex == (uint32)graphicsQueueFamilyIndex)
|
||||
{
|
||||
if (currProps.queueCount > 1)
|
||||
{
|
||||
@@ -232,13 +306,27 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
||||
numQueuesForFamily++;
|
||||
}
|
||||
}
|
||||
if(numQueuesForFamily > 0)
|
||||
if (numQueuesForFamily > 0)
|
||||
{
|
||||
VkDeviceQueueCreateInfo info =
|
||||
init::DeviceQueueCreateInfo(familyIndex, numQueuesForFamily);
|
||||
numPriorities += numQueuesForFamily;
|
||||
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(
|
||||
queueInfos.data(),
|
||||
(uint32)queueInfos.size(),
|
||||
@@ -250,28 +338,32 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
||||
|
||||
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 (asyncComputeFamilyIndex == graphicsQueueFamilyIndex)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
// Different family
|
||||
computeQueue = new Queue(this, QueueType::COMPUTE, asyncComputeFamilyIndex, 0);
|
||||
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeFamilyIndex, 0);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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.computeFamily = computeQueue->getFamilyIndex();
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
#pragma once
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "VulkanGraphicsResources.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(Allocator);
|
||||
DECLARE_REF(CommandBufferManager);
|
||||
DECLARE_REF(Queue);
|
||||
class Graphics : public Gfx::Graphics
|
||||
{
|
||||
public:
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(Allocator);
|
||||
DECLARE_REF(StagingManager);
|
||||
DECLARE_REF(CommandBufferManager);
|
||||
DECLARE_REF(Queue);
|
||||
DECLARE_REF(Framebuffer);
|
||||
class Graphics : public Gfx::Graphics
|
||||
{
|
||||
public:
|
||||
Graphics();
|
||||
virtual ~Graphics();
|
||||
VkInstance getInstance() const;
|
||||
VkDevice getDevice() const;
|
||||
VkPhysicalDevice getPhysicalDevice() const;
|
||||
|
||||
@@ -22,15 +25,31 @@ namespace Seele
|
||||
PCommandBufferManager getTransferCommands();
|
||||
PCommandBufferManager getDedicatedTransferCommands();
|
||||
|
||||
const QueueFamilyMapping getFamilyMapping() const
|
||||
{
|
||||
return queueMapping;
|
||||
}
|
||||
|
||||
PAllocator getAllocator();
|
||||
PStagingManager getStagingManager();
|
||||
|
||||
// Inherited via Graphics
|
||||
virtual void init(GraphicsInitializer initializer) override;
|
||||
virtual void beginFrame(void* windowHandle) override;
|
||||
virtual void endFrame(void* windowHandle) override;
|
||||
virtual void* createWindow(const WindowCreateInfo& createInfo) override;
|
||||
protected:
|
||||
Array<const char*> getRequiredExtensions();
|
||||
virtual Gfx::PWindow createWindow(const WindowCreateInfo &createInfo) override;
|
||||
virtual Gfx::PViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo &createInfo) override;
|
||||
|
||||
virtual Gfx::PRenderPass createRenderPass(Gfx::PRenderTargetLayout layout) override;
|
||||
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 setupDebugCallback();
|
||||
void pickPhysicalDevice();
|
||||
@@ -53,10 +72,12 @@ namespace Seele
|
||||
VkPhysicalDeviceFeatures features;
|
||||
VkDebugReportCallbackEXT callback;
|
||||
Array<PViewport> viewports;
|
||||
Map<uint32, PFramebuffer> allocatedFramebuffers;
|
||||
PAllocator allocator;
|
||||
PStagingManager stagingManager;
|
||||
|
||||
friend class Window;
|
||||
};
|
||||
DEFINE_REF(Graphics);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(Graphics);
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
@@ -3,7 +3,7 @@
|
||||
using namespace Seele::Vulkan;
|
||||
using namespace Seele::Gfx;
|
||||
|
||||
VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType& descriptorType)
|
||||
VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType &descriptorType)
|
||||
{
|
||||
switch (descriptorType)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ VkDescriptorType Seele::Vulkan::cast(const Seele::Gfx::SeDescriptorType& descrip
|
||||
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)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ Seele::Gfx::SeDescriptorType Seele::Vulkan::cast(const VkDescriptorType& descrip
|
||||
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)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ VkShaderStageFlagBits Seele::Vulkan::cast(const Seele::Gfx::SeShaderStageFlagBit
|
||||
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)
|
||||
{
|
||||
@@ -169,7 +169,7 @@ Seele::Gfx::SeShaderStageFlagBits Seele::Vulkan::cast(const VkShaderStageFlagBit
|
||||
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)
|
||||
{
|
||||
@@ -631,7 +631,7 @@ VkFormat Seele::Vulkan::cast(const Seele::Gfx::SeFormat& format)
|
||||
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)
|
||||
{
|
||||
@@ -1093,3 +1093,55 @@ Seele::Gfx::SeFormat Seele::Vulkan::cast(const VkFormat& format)
|
||||
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>
|
||||
|
||||
#define VK_CHECK(f) \
|
||||
{ \
|
||||
{ \
|
||||
VkResult res = (f); \
|
||||
if (res != VK_SUCCESS) \
|
||||
{ \
|
||||
std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \
|
||||
assert(res == VK_SUCCESS); \
|
||||
} \
|
||||
}
|
||||
}
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
VkDescriptorType cast(const Gfx::SeDescriptorType& descriptorType);
|
||||
Gfx::SeDescriptorType cast(const VkDescriptorType& descriptorType);
|
||||
VkShaderStageFlagBits cast(const Gfx::SeShaderStageFlagBits& stage);
|
||||
Gfx::SeShaderStageFlagBits cast(const VkShaderStageFlagBits& stage);
|
||||
VkFormat cast(const Gfx::SeFormat& format);
|
||||
Gfx::SeFormat cast(const VkFormat& format);
|
||||
}
|
||||
}
|
||||
namespace Vulkan
|
||||
{
|
||||
VkDescriptorType cast(const Gfx::SeDescriptorType &descriptorType);
|
||||
Gfx::SeDescriptorType cast(const VkDescriptorType &descriptorType);
|
||||
VkShaderStageFlagBits cast(const Gfx::SeShaderStageFlagBits &stage);
|
||||
Gfx::SeShaderStageFlagBits cast(const VkShaderStageFlagBits &stage);
|
||||
VkFormat cast(const Gfx::SeFormat &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 "VulkanGraphics.h"
|
||||
#include "VulkanGraphicsEnums.h"
|
||||
#include "VulkanCommandBuffer.h"
|
||||
|
||||
using namespace Seele;
|
||||
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)
|
||||
: graphics(graphics)
|
||||
{
|
||||
@@ -16,5 +58,65 @@ Semaphore::Semaphore(PGraphics graphics)
|
||||
|
||||
Semaphore::~Semaphore()
|
||||
{
|
||||
graphics = 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(CommandBufferManager);
|
||||
DECLARE_REF(Graphics);
|
||||
DECLARE_REF(SubAllocation);
|
||||
class Semaphore
|
||||
{
|
||||
public:
|
||||
@@ -19,116 +20,32 @@ public:
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
private:
|
||||
VkSemaphore handle;
|
||||
PGraphics graphics;
|
||||
};
|
||||
DEFINE_REF(Semaphore);
|
||||
|
||||
class DescriptorLayout : public Gfx::DescriptorLayout
|
||||
class Fence
|
||||
{
|
||||
public:
|
||||
DescriptorLayout(PGraphics graphics)
|
||||
: graphics(graphics), layoutHandle(VK_NULL_HANDLE)
|
||||
Fence(PGraphics graphics);
|
||||
~Fence();
|
||||
bool isSignaled();
|
||||
void reset();
|
||||
inline VkFence getHandle() const
|
||||
{
|
||||
return fence;
|
||||
}
|
||||
virtual ~DescriptorLayout();
|
||||
virtual void create();
|
||||
inline VkDescriptorSetLayout getHandle() const
|
||||
{
|
||||
return layoutHandle;
|
||||
}
|
||||
void wait(uint32 timeout);
|
||||
|
||||
private:
|
||||
bool signaled;
|
||||
VkFence fence;
|
||||
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
|
||||
{
|
||||
@@ -136,23 +53,23 @@ struct QueueFamilyMapping
|
||||
uint32 computeFamily;
|
||||
uint32 transferFamily;
|
||||
uint32 dedicatedTransferFamily;
|
||||
uint32 getQueueTypeFamilyIndex(QueueType type)
|
||||
uint32 getQueueTypeFamilyIndex(Gfx::QueueType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case QueueType::GRAPHICS:
|
||||
case Gfx::QueueType::GRAPHICS:
|
||||
return graphicsFamily;
|
||||
case QueueType::COMPUTE:
|
||||
case Gfx::QueueType::COMPUTE:
|
||||
return computeFamily;
|
||||
case QueueType::TRANSFER:
|
||||
case Gfx::QueueType::TRANSFER:
|
||||
return transferFamily;
|
||||
case QueueType::DEDICATED_TRANSFER:
|
||||
case Gfx::QueueType::DEDICATED_TRANSFER:
|
||||
return dedicatedTransferFamily;
|
||||
default:
|
||||
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 dstIndex = getQueueTypeFamilyIndex(dst);
|
||||
@@ -162,71 +79,179 @@ struct QueueFamilyMapping
|
||||
class QueueOwnedResource
|
||||
{
|
||||
public:
|
||||
QueueOwnedResource(PGraphics graphics, QueueType startQueueType);
|
||||
~QueueOwnedResource();
|
||||
QueueOwnedResource(PGraphics graphics, Gfx::QueueType startQueueType);
|
||||
virtual ~QueueOwnedResource();
|
||||
PCommandBufferManager getCommands();
|
||||
//Preliminary checks to see if the barrier should be executed at all
|
||||
void transferOwnership(QueueType newOwner);
|
||||
void transferOwnership(Gfx::QueueType newOwner);
|
||||
|
||||
protected:
|
||||
virtual void executeOwnershipBarrier(QueueType newOwner) = 0;
|
||||
QueueType currentOwner;
|
||||
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) = 0;
|
||||
Gfx::QueueType currentOwner;
|
||||
PGraphics graphics;
|
||||
CommandBufferManager *cachedCmdBufferManager;
|
||||
PCommandBufferManager cachedCmdBufferManager;
|
||||
};
|
||||
DEFINE_REF(QueueOwnedResource);
|
||||
|
||||
class Buffer : public QueueOwnedResource
|
||||
{
|
||||
public:
|
||||
Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, QueueType queueType = QueueType::GRAPHICS);
|
||||
Buffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType);
|
||||
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 getDestAccessMask() = 0;
|
||||
// Inherited via QueueOwnedResource
|
||||
virtual void executeOwnershipBarrier(QueueType newOwner);
|
||||
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
|
||||
};
|
||||
DEFINE_REF(Buffer);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
class TextureBase
|
||||
class VertexBuffer : public Buffer, public Gfx::VertexBuffer
|
||||
{
|
||||
public:
|
||||
TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ,
|
||||
bool bArray, uint32 arraySize, uint32 mipLevels, Gfx::SeFormat format,
|
||||
uint32 samples, Gfx::SeImageUsageFlags usage);
|
||||
virtual ~TextureBase();
|
||||
VertexBuffer(PGraphics graphics, const BulkResourceData &resourceData);
|
||||
virtual ~VertexBuffer();
|
||||
|
||||
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;
|
||||
PSubAllocation allocation;
|
||||
uint32 sizeX;
|
||||
uint32 sizeY;
|
||||
uint32 sizeZ;
|
||||
uint32 arrayCount;
|
||||
uint32 mipLevels;
|
||||
uint32 samples;
|
||||
Gfx::SeFormat format;
|
||||
Gfx::SeImageUsageFlags usage;
|
||||
VkImage image;
|
||||
VkImageView defaultView;
|
||||
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);
|
||||
|
||||
class Texture2D : public Gfx::Texture2D
|
||||
class Texture2D : public TextureBase, public Gfx::Texture2D
|
||||
{
|
||||
public:
|
||||
Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY,
|
||||
bool bArray, uint32 arraySize, uint32 mipLevels,
|
||||
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage);
|
||||
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 ~Texture2D();
|
||||
inline uint32 getSizeX() const
|
||||
{
|
||||
@@ -248,8 +273,12 @@ public:
|
||||
{
|
||||
return textureHandle->defaultView;
|
||||
}
|
||||
inline bool isDepthStencil() const
|
||||
{
|
||||
return textureHandle->isDepthStencil();
|
||||
}
|
||||
|
||||
private:
|
||||
PTextureBase textureHandle;
|
||||
};
|
||||
DEFINE_REF(Texture2D);
|
||||
|
||||
@@ -260,16 +289,54 @@ public:
|
||||
};
|
||||
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
|
||||
{
|
||||
public:
|
||||
Viewport(PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
||||
virtual ~Viewport();
|
||||
|
||||
protected:
|
||||
private:
|
||||
uint32 sizeX;
|
||||
uint32 sizeY;
|
||||
uint32 offsetX;
|
||||
uint32 offsetY;
|
||||
VkSwapchainKHR swapchain;
|
||||
void *windowHandle;
|
||||
PGraphics graphics;
|
||||
friend class Graphics;
|
||||
};
|
||||
DECLARE_REF(Viewport);
|
||||
} // namespace Vulkan
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
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 = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
@@ -11,10 +11,11 @@ VkApplicationInfo init::ApplicationInfo(const char* appName, uint32_t appVersion
|
||||
info.applicationVersion = appVersion;
|
||||
info.pEngineName = engineName;
|
||||
info.engineVersion = engineVersion;
|
||||
info.apiVersion = apiVersion;
|
||||
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 = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
@@ -41,7 +42,7 @@ VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int qu
|
||||
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 = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
@@ -51,7 +52,7 @@ VkDeviceQueueCreateInfo init::DeviceQueueCreateInfo(int queueFamilyIndex, int qu
|
||||
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);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ VkSwapchainCreateInfoKHR init::SwapchainCreateInfo(VkSurfaceKHR surface, uint32_
|
||||
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 = {};
|
||||
frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
@@ -121,16 +122,26 @@ VkAttachmentDescription init::AttachmentDescription(VkFormat format, VkSampleCou
|
||||
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 = {};
|
||||
desc.pipelineBindPoint = bindPoint;
|
||||
desc.colorAttachmentCount = colorAttachmentCount;
|
||||
desc.pColorAttachments = colorReference;
|
||||
desc.inputAttachmentCount = inputAttachmentCount;
|
||||
desc.pInputAttachments = inputReference;
|
||||
desc.pResolveAttachments = resolveReference;
|
||||
desc.preserveAttachmentCount = preserveAttachmentCount;
|
||||
desc.pPreserveAttachments = preserveReference;
|
||||
desc.pDepthStencilAttachment = depthReference;
|
||||
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 = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
@@ -143,7 +154,7 @@ VkRenderPassCreateInfo init::RenderPassCreateInfo(uint32_t attachmentCount, cons
|
||||
|
||||
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 = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
@@ -160,6 +171,8 @@ VkDeviceCreateInfo init::DeviceCreateInfo(VkDeviceQueueCreateInfo* queueInfos, u
|
||||
createInfo.ppEnabledLayerNames = layers;
|
||||
#else
|
||||
createInfo.enabledLayerCount = 0;
|
||||
layerCount = 0;
|
||||
layers = nullptr;
|
||||
#endif // ENABLE_VALIDATION
|
||||
|
||||
return createInfo;
|
||||
@@ -230,33 +243,40 @@ VkImageMemoryBarrier init::ImageMemoryBarrier(VkImage image, VkImageLayout oldLa
|
||||
barrier.srcQueueFamilyIndex = srcQueue;
|
||||
barrier.dstQueueFamilyIndex = dstQueue;
|
||||
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;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
}
|
||||
barrier.subresourceRange.baseMipLevel = 0;
|
||||
barrier.subresourceRange.levelCount = 1;
|
||||
barrier.subresourceRange.baseArrayLayer = 0;
|
||||
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.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.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.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.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.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
}
|
||||
@@ -422,7 +442,7 @@ VkBufferCreateInfo init::BufferCreateInfo(
|
||||
|
||||
VkDescriptorPoolCreateInfo init::DescriptorPoolCreateInfo(
|
||||
uint32_t poolSizeCount,
|
||||
VkDescriptorPoolSize* pPoolSizes,
|
||||
VkDescriptorPoolSize *pPoolSizes,
|
||||
uint32_t maxSets)
|
||||
{
|
||||
VkDescriptorPoolCreateInfo descriptorPoolInfo = {};
|
||||
@@ -459,7 +479,7 @@ VkDescriptorSetLayoutBinding init::DescriptorSetLayoutBinding(
|
||||
}
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo init::DescriptorSetLayoutCreateInfo(
|
||||
const VkDescriptorSetLayoutBinding* pBindings,
|
||||
const VkDescriptorSetLayoutBinding *pBindings,
|
||||
uint32_t bindingCount)
|
||||
{
|
||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {};
|
||||
@@ -471,7 +491,7 @@ VkDescriptorSetLayoutCreateInfo init::DescriptorSetLayoutCreateInfo(
|
||||
}
|
||||
|
||||
VkPipelineLayoutCreateInfo init::PipelineLayoutCreateInfo(
|
||||
const VkDescriptorSetLayout* pSetLayouts,
|
||||
const VkDescriptorSetLayout *pSetLayouts,
|
||||
uint32_t setLayoutCount)
|
||||
{
|
||||
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {};
|
||||
@@ -484,7 +504,7 @@ VkPipelineLayoutCreateInfo init::PipelineLayoutCreateInfo(
|
||||
|
||||
VkDescriptorSetAllocateInfo init::DescriptorSetAllocateInfo(
|
||||
VkDescriptorPool descriptorPool,
|
||||
const VkDescriptorSetLayout* pSetLayouts,
|
||||
const VkDescriptorSetLayout *pSetLayouts,
|
||||
uint32_t descriptorSetCount)
|
||||
{
|
||||
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {};
|
||||
@@ -522,7 +542,7 @@ VkWriteDescriptorSet init::WriteDescriptorSet(
|
||||
VkDescriptorSet dstSet,
|
||||
VkDescriptorType type,
|
||||
uint32_t binding,
|
||||
VkDescriptorBufferInfo* bufferInfo)
|
||||
VkDescriptorBufferInfo *bufferInfo)
|
||||
{
|
||||
VkWriteDescriptorSet writeDescriptorSet = {};
|
||||
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
@@ -540,7 +560,7 @@ VkWriteDescriptorSet init::WriteDescriptorSet(
|
||||
VkDescriptorSet dstSet,
|
||||
VkDescriptorType type,
|
||||
uint32_t binding,
|
||||
VkDescriptorImageInfo* bufferInfo)
|
||||
VkDescriptorImageInfo *bufferInfo)
|
||||
{
|
||||
VkWriteDescriptorSet writeDescriptorSet = {};
|
||||
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
@@ -630,7 +650,7 @@ VkPipelineColorBlendAttachmentState init::PipelineColorBlendAttachmentState(
|
||||
|
||||
VkPipelineColorBlendStateCreateInfo init::PipelineColorBlendStateCreateInfo(
|
||||
uint32_t attachmentCount,
|
||||
const VkPipelineColorBlendAttachmentState* pAttachments)
|
||||
const VkPipelineColorBlendAttachmentState *pAttachments)
|
||||
{
|
||||
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo = {};
|
||||
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
@@ -674,17 +694,19 @@ VkPipelineMultisampleStateCreateInfo init::PipelineMultisampleStateCreateInfo(
|
||||
{
|
||||
VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo = {};
|
||||
pipelineMultisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
pipelineMultisampleStateCreateInfo.flags = flags;
|
||||
pipelineMultisampleStateCreateInfo.rasterizationSamples = rasterizationSamples;
|
||||
return pipelineMultisampleStateCreateInfo;
|
||||
}
|
||||
|
||||
VkPipelineDynamicStateCreateInfo init::PipelineDynamicStateCreateInfo(
|
||||
const VkDynamicState* pDynamicStates,
|
||||
const VkDynamicState *pDynamicStates,
|
||||
uint32_t dynamicStateCount,
|
||||
VkPipelineDynamicStateCreateFlags flags)
|
||||
{
|
||||
VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {};
|
||||
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||
pipelineDynamicStateCreateInfo.flags = flags;
|
||||
pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates;
|
||||
pipelineDynamicStateCreateInfo.dynamicStateCount = dynamicStateCount;
|
||||
return pipelineDynamicStateCreateInfo;
|
||||
@@ -733,7 +755,7 @@ VkPushConstantRange init::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 = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
@@ -743,25 +765,31 @@ VkPipelineShaderStageCreateInfo init::PipelineShaderStageCreateInfo(VkShaderStag
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
#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)
|
||||
{
|
||||
std::cerr << layerPrefix << ": " << msg << std::endl;
|
||||
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");
|
||||
if (func != nullptr) {
|
||||
if (func != nullptr)
|
||||
{
|
||||
return func(instance, pCreateInfo, pAllocator, pCallback);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
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");
|
||||
if (func != nullptr) {
|
||||
if (func != nullptr)
|
||||
{
|
||||
func(instance, pCallback, pAllocator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,54 +4,54 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback);
|
||||
void DestroyDebugReportCallbackEXT(VkInstance instance, 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);
|
||||
|
||||
namespace init
|
||||
{
|
||||
VkApplicationInfo ApplicationInfo(
|
||||
const char* appName,
|
||||
namespace init
|
||||
{
|
||||
VkApplicationInfo ApplicationInfo(
|
||||
const char *appName,
|
||||
uint32_t appVersion,
|
||||
const char* engineName,
|
||||
const char *engineName,
|
||||
uint32_t engineVersion,
|
||||
uint32_t apiVersion);
|
||||
|
||||
VkInstanceCreateInfo InstanceCreateInfo(
|
||||
VkApplicationInfo* appInfo,
|
||||
const Array<const char*>& extensions,
|
||||
const Array<const char*>& layers);
|
||||
VkInstanceCreateInfo InstanceCreateInfo(
|
||||
VkApplicationInfo *appInfo,
|
||||
const Array<const char *> &extensions,
|
||||
const Array<const char *> &layers);
|
||||
|
||||
VkDebugReportCallbackCreateInfoEXT DebugReportCallbackCreateInfo(
|
||||
VkDebugReportCallbackCreateInfoEXT DebugReportCallbackCreateInfo(
|
||||
VkDebugReportFlagsEXT flags);
|
||||
|
||||
VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
|
||||
VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
|
||||
int queueFamilyIndex,
|
||||
int queueCount);
|
||||
|
||||
VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
|
||||
VkDeviceQueueCreateInfo DeviceQueueCreateInfo(
|
||||
int queueFamilyIndex,
|
||||
int queueCount,
|
||||
float* queuePriority);
|
||||
float *queuePriority);
|
||||
|
||||
VkDeviceCreateInfo DeviceCreateInfo(
|
||||
VkDeviceQueueCreateInfo* queueInfos,
|
||||
VkDeviceCreateInfo DeviceCreateInfo(
|
||||
VkDeviceQueueCreateInfo *queueInfos,
|
||||
uint32_t queueCount,
|
||||
VkPhysicalDeviceFeatures* features,
|
||||
const char* const* deviceExtensions,
|
||||
VkPhysicalDeviceFeatures *features,
|
||||
const char *const *deviceExtensions,
|
||||
uint32_t deviceExtensionCount,
|
||||
const char* const* layers,
|
||||
const char *const *layers,
|
||||
uint32_t layerCount);
|
||||
|
||||
VkDeviceCreateInfo DeviceCreateInfo(
|
||||
VkDeviceQueueCreateInfo* queueInfos,
|
||||
VkDeviceCreateInfo DeviceCreateInfo(
|
||||
VkDeviceQueueCreateInfo *queueInfos,
|
||||
uint32_t queueCount,
|
||||
VkPhysicalDeviceFeatures* features);
|
||||
VkPhysicalDeviceFeatures *features);
|
||||
|
||||
VkSwapchainCreateInfoKHR SwapchainCreateInfo(
|
||||
VkSwapchainCreateInfoKHR SwapchainCreateInfo(
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t minImageCount,
|
||||
VkFormat imageFormat,
|
||||
@@ -64,7 +64,7 @@ namespace Seele
|
||||
VkPresentModeKHR presentMode,
|
||||
VkBool32 clipped);
|
||||
|
||||
VkSwapchainCreateInfoKHR SwapchainCreateInfo(
|
||||
VkSwapchainCreateInfoKHR SwapchainCreateInfo(
|
||||
VkSurfaceKHR surface,
|
||||
uint32_t minImageCount,
|
||||
VkFormat imageFormat,
|
||||
@@ -78,15 +78,15 @@ namespace Seele
|
||||
VkPresentModeKHR presentMode,
|
||||
VkBool32 clipped);
|
||||
|
||||
VkFramebufferCreateInfo FramebufferCreateInfo(
|
||||
VkFramebufferCreateInfo FramebufferCreateInfo(
|
||||
VkRenderPass renderPass,
|
||||
uint32_t attachmentCount,
|
||||
VkImageView* attachments,
|
||||
VkImageView *attachments,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t layers);
|
||||
|
||||
VkAttachmentDescription AttachmentDescription(
|
||||
VkAttachmentDescription AttachmentDescription(
|
||||
VkFormat format,
|
||||
VkSampleCountFlagBits sample,
|
||||
VkAttachmentLoadOp loadOp,
|
||||
@@ -96,210 +96,207 @@ namespace Seele
|
||||
VkImageLayout imageLayout,
|
||||
VkImageLayout finalLayout);
|
||||
|
||||
VkSubpassDescription SubpassDescription(
|
||||
VkSubpassDescription SubpassDescription(
|
||||
VkPipelineBindPoint bindPoint,
|
||||
uint32_t colorAttachmentCount,
|
||||
VkAttachmentReference* colorReference,
|
||||
uint32_t depthAttachmentCount = 0,
|
||||
VkAttachmentReference* depthReference = nullptr,
|
||||
VkAttachmentReference *colorReference,
|
||||
VkAttachmentReference *depthReference = nullptr,
|
||||
uint32_t inputAttachmentCount = 0,
|
||||
VkAttachmentReference* inputReference = nullptr,
|
||||
uint32_t resolveAttachmentCount = 0,
|
||||
VkAttachmentReference* resolveReference = nullptr,
|
||||
VkAttachmentReference *inputReference = nullptr,
|
||||
VkAttachmentReference *resolveReference = nullptr,
|
||||
uint32_t preserveAttachmentCount = 0,
|
||||
VkAttachmentReference* preserveReference = nullptr);
|
||||
uint32_t *preserveReference = nullptr);
|
||||
|
||||
VkRenderPassCreateInfo RenderPassCreateInfo(
|
||||
VkRenderPassCreateInfo RenderPassCreateInfo(
|
||||
uint32_t attachmentCount,
|
||||
const VkAttachmentDescription* attachments,
|
||||
const VkAttachmentDescription *attachments,
|
||||
uint32_t subpassCount,
|
||||
const VkSubpassDescription* subpasses,
|
||||
const VkSubpassDescription *subpasses,
|
||||
uint32_t dependencyCount,
|
||||
const VkSubpassDependency* subpassDependencies);
|
||||
const VkSubpassDependency *subpassDependencies);
|
||||
|
||||
VkMemoryAllocateInfo MemoryAllocateInfo();
|
||||
VkMemoryAllocateInfo MemoryAllocateInfo();
|
||||
|
||||
VkCommandBufferAllocateInfo CommandBufferAllocateInfo(
|
||||
VkCommandBufferAllocateInfo CommandBufferAllocateInfo(
|
||||
VkCommandPool cmdPool,
|
||||
VkCommandBufferLevel level,
|
||||
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();
|
||||
VkImageMemoryBarrier ImageMemoryBarrier(VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t srcQueue = VK_QUEUE_FAMILY_IGNORED, uint32_t dstQueue = VK_QUEUE_FAMILY_IGNORED);
|
||||
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);
|
||||
|
||||
VkEventCreateInfo EventCreateInfo();
|
||||
VkEventCreateInfo EventCreateInfo();
|
||||
|
||||
VkSubmitInfo SubmitInfo();
|
||||
VkSubmitInfo SubmitInfo();
|
||||
|
||||
VkImageSubresourceRange ImageSubresourceRange(
|
||||
VkImageSubresourceRange ImageSubresourceRange(
|
||||
VkImageAspectFlags aspect = VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
uint32_t startMip = 0);
|
||||
|
||||
VkViewport Viewport(
|
||||
VkViewport Viewport(
|
||||
float width,
|
||||
float height,
|
||||
float minDepth,
|
||||
float maxDepth);
|
||||
|
||||
VkRect2D Rect2D(
|
||||
VkRect2D Rect2D(
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t offsetX,
|
||||
int32_t offsetY);
|
||||
|
||||
VkBufferCreateInfo BufferCreateInfo();
|
||||
VkBufferCreateInfo BufferCreateInfo();
|
||||
|
||||
VkBufferCreateInfo BufferCreateInfo(
|
||||
VkBufferCreateInfo BufferCreateInfo(
|
||||
VkBufferUsageFlags usage,
|
||||
VkDeviceSize size);
|
||||
|
||||
VkDescriptorPoolCreateInfo DescriptorPoolCreateInfo(
|
||||
VkDescriptorPoolCreateInfo DescriptorPoolCreateInfo(
|
||||
uint32_t poolSizeCount,
|
||||
VkDescriptorPoolSize* pPoolSizes,
|
||||
VkDescriptorPoolSize *pPoolSizes,
|
||||
uint32_t maxSets);
|
||||
|
||||
VkDescriptorPoolSize DescriptorPoolSize(
|
||||
VkDescriptorPoolSize DescriptorPoolSize(
|
||||
VkDescriptorType type,
|
||||
uint32_t descriptorCount);
|
||||
|
||||
VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding(
|
||||
VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding(
|
||||
VkDescriptorType type,
|
||||
VkShaderStageFlags stageFlags,
|
||||
uint32_t binding,
|
||||
uint32_t count);
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo DescriptorSetLayoutCreateInfo(
|
||||
const VkDescriptorSetLayoutBinding* pBindings,
|
||||
VkDescriptorSetLayoutCreateInfo DescriptorSetLayoutCreateInfo(
|
||||
const VkDescriptorSetLayoutBinding *pBindings,
|
||||
uint32_t bindingCount);
|
||||
|
||||
VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo(
|
||||
const VkDescriptorSetLayout* pSetLayouts,
|
||||
VkPipelineLayoutCreateInfo PipelineLayoutCreateInfo(
|
||||
const VkDescriptorSetLayout *pSetLayouts,
|
||||
uint32_t setLayoutCount);
|
||||
|
||||
VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo(
|
||||
VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo(
|
||||
VkDescriptorPool descriptorPool,
|
||||
const VkDescriptorSetLayout* pSetLayouts,
|
||||
const VkDescriptorSetLayout *pSetLayouts,
|
||||
uint32_t descriptorSetCount);
|
||||
|
||||
VkDescriptorBufferInfo DescriptorBufferInfo(
|
||||
VkDescriptorBufferInfo DescriptorBufferInfo(
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize range);
|
||||
VkDescriptorImageInfo DescriptorImageInfo(
|
||||
VkDescriptorImageInfo DescriptorImageInfo(
|
||||
VkSampler sampler,
|
||||
VkImageView imageView,
|
||||
VkImageLayout imageLayout);
|
||||
|
||||
VkWriteDescriptorSet WriteDescriptorSet(
|
||||
VkWriteDescriptorSet WriteDescriptorSet(
|
||||
VkDescriptorSet dstSet,
|
||||
VkDescriptorType type,
|
||||
uint32_t binding,
|
||||
VkDescriptorBufferInfo* bufferInfo);
|
||||
VkDescriptorBufferInfo *bufferInfo);
|
||||
|
||||
VkWriteDescriptorSet WriteDescriptorSet(
|
||||
VkWriteDescriptorSet WriteDescriptorSet(
|
||||
VkDescriptorSet dstSet,
|
||||
VkDescriptorType type,
|
||||
uint32_t binding,
|
||||
VkDescriptorImageInfo* bufferInfo);
|
||||
VkDescriptorImageInfo *bufferInfo);
|
||||
|
||||
|
||||
VkVertexInputBindingDescription VertexInputBindingDescription(
|
||||
VkVertexInputBindingDescription VertexInputBindingDescription(
|
||||
uint32_t binding,
|
||||
uint32_t stride,
|
||||
VkVertexInputRate inputRate);
|
||||
|
||||
VkVertexInputAttributeDescription VertexInputAttributeDescription(
|
||||
VkVertexInputAttributeDescription VertexInputAttributeDescription(
|
||||
uint32_t binding,
|
||||
uint32_t location,
|
||||
VkFormat format,
|
||||
uint32_t offset);
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo();
|
||||
VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo();
|
||||
|
||||
VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo(
|
||||
VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo(
|
||||
VkPrimitiveTopology topology,
|
||||
VkPipelineInputAssemblyStateCreateFlags flags,
|
||||
VkBool32 primitiveRestartEnable);
|
||||
|
||||
VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo(
|
||||
VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo(
|
||||
VkPolygonMode polygonMode,
|
||||
VkCullModeFlags cullMode,
|
||||
VkFrontFace frontFace,
|
||||
VkPipelineRasterizationStateCreateFlags flags);
|
||||
|
||||
VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState(
|
||||
VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState(
|
||||
VkColorComponentFlags colorWriteMask,
|
||||
VkBool32 blendEnable);
|
||||
|
||||
VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo(
|
||||
VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo(
|
||||
uint32_t attachmentCount,
|
||||
const VkPipelineColorBlendAttachmentState* pAttachments);
|
||||
const VkPipelineColorBlendAttachmentState *pAttachments);
|
||||
|
||||
VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo(
|
||||
VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo(
|
||||
VkBool32 depthTestEnable,
|
||||
VkBool32 depthWriteEnable,
|
||||
VkCompareOp depthCompareOp);
|
||||
|
||||
VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo(
|
||||
VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo(
|
||||
uint32_t viewportCount,
|
||||
uint32_t scissorCount,
|
||||
VkPipelineViewportStateCreateFlags flags);
|
||||
|
||||
VkPipelineMultisampleStateCreateInfo PipelineMultisampleStateCreateInfo(
|
||||
VkPipelineMultisampleStateCreateInfo PipelineMultisampleStateCreateInfo(
|
||||
VkSampleCountFlagBits rasterizationSamples,
|
||||
VkPipelineMultisampleStateCreateFlags flags);
|
||||
|
||||
VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo(
|
||||
const VkDynamicState* pDynamicStates,
|
||||
VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo(
|
||||
const VkDynamicState *pDynamicStates,
|
||||
uint32_t dynamicStateCount,
|
||||
VkPipelineDynamicStateCreateFlags flags);
|
||||
|
||||
VkPipelineTessellationStateCreateInfo PipelineTessellationStateCreateInfo(
|
||||
VkPipelineTessellationStateCreateInfo PipelineTessellationStateCreateInfo(
|
||||
uint32_t patchControlPoints);
|
||||
|
||||
VkGraphicsPipelineCreateInfo PipelineCreateInfo(
|
||||
VkGraphicsPipelineCreateInfo PipelineCreateInfo(
|
||||
VkPipelineLayout layout,
|
||||
VkRenderPass renderPass,
|
||||
VkPipelineCreateFlags flags);
|
||||
|
||||
VkComputePipelineCreateInfo ComputePipelineCreateInfo(
|
||||
VkComputePipelineCreateInfo ComputePipelineCreateInfo(
|
||||
VkPipelineLayout layout,
|
||||
VkPipelineCreateFlags flags);
|
||||
|
||||
VkPushConstantRange PushConstantRange(
|
||||
VkPushConstantRange PushConstantRange(
|
||||
VkShaderStageFlags stageFlags,
|
||||
uint32_t size,
|
||||
uint32_t offset);
|
||||
|
||||
VkPipelineShaderStageCreateInfo PipelineShaderStageCreateInfo(
|
||||
VkPipelineShaderStageCreateInfo PipelineShaderStageCreateInfo(
|
||||
VkShaderStageFlagBits stage,
|
||||
VkShaderModule module,
|
||||
const char* entryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
const char *entryName);
|
||||
} // namespace init
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
@@ -1,11 +1,14 @@
|
||||
#include "VulkanQueue.h"
|
||||
#include "VulkanInitializer.h"
|
||||
#include "VulkanGraphics.h"
|
||||
#include "VulkanAllocator.h"
|
||||
#include "VulkanCommandBuffer.h"
|
||||
#include "VulkanGraphicsEnums.h"
|
||||
|
||||
using namespace Seele;
|
||||
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)
|
||||
, graphics(graphics)
|
||||
, 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();
|
||||
}
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(CmdBuffer);
|
||||
DECLARE_REF(Graphics);
|
||||
class Queue
|
||||
{
|
||||
public:
|
||||
Queue(PGraphics graphics, QueueType queueType, uint32 familyIndex, uint32 queueIndex);
|
||||
namespace Vulkan
|
||||
{
|
||||
DECLARE_REF(CmdBuffer);
|
||||
DECLARE_REF(Graphics);
|
||||
class Queue
|
||||
{
|
||||
public:
|
||||
Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex);
|
||||
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)
|
||||
{
|
||||
submitCommandBuffer(cmdBuffer, 1, &signalSemaphore);
|
||||
@@ -25,12 +25,13 @@ namespace Seele
|
||||
{
|
||||
return queue;
|
||||
}
|
||||
private:
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
VkQueue queue;
|
||||
uint32 familyIndex;
|
||||
QueueType queueType;
|
||||
};
|
||||
DEFINE_REF(Queue)
|
||||
}
|
||||
}
|
||||
Gfx::QueueType queueType;
|
||||
};
|
||||
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));
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
namespace Vulkan
|
||||
{
|
||||
class RenderPass
|
||||
{
|
||||
public:
|
||||
RenderPass();
|
||||
namespace Vulkan
|
||||
{
|
||||
class RenderPass : public Gfx::RenderPass
|
||||
{
|
||||
public:
|
||||
RenderPass(PGraphics graphics, Gfx::PRenderTargetLayout layout);
|
||||
virtual ~RenderPass();
|
||||
uint32 getFramebufferHash();
|
||||
inline VkRenderPass getHandle() const
|
||||
{
|
||||
return renderPass;
|
||||
@@ -17,7 +18,7 @@ namespace Seele
|
||||
{
|
||||
return clearValues.size();
|
||||
}
|
||||
inline VkClearValue* getClearValues() const
|
||||
inline VkClearValue *getClearValues() const
|
||||
{
|
||||
return clearValues.data();
|
||||
}
|
||||
@@ -29,12 +30,18 @@ namespace Seele
|
||||
{
|
||||
return subpassContents;
|
||||
}
|
||||
private:
|
||||
inline Gfx::PRenderTargetLayout getLayout()
|
||||
{
|
||||
return layout;
|
||||
}
|
||||
private:
|
||||
PGraphics graphics;
|
||||
Gfx::PRenderTargetLayout layout;
|
||||
VkRenderPass renderPass;
|
||||
Array<VkClearValue> clearValues;
|
||||
VkRect2D renderArea;
|
||||
VkSubpassContents subpassContents;
|
||||
};
|
||||
DEFINE_REF(RenderPass);
|
||||
}
|
||||
}
|
||||
};
|
||||
DEFINE_REF(RenderPass);
|
||||
} // namespace Vulkan
|
||||
} // namespace Seele
|
||||
@@ -2,22 +2,40 @@
|
||||
#include "VulkanGraphics.h"
|
||||
#include "VulkanInitializer.h"
|
||||
#include "VulkanGraphicsEnums.h"
|
||||
#include "VulkanAllocator.h"
|
||||
#include "VulkanCommandBuffer.h"
|
||||
#include <math.h>
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 sizeX, uint32 sizeY, uint32 sizeZ,
|
||||
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)
|
||||
VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format)
|
||||
{
|
||||
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();
|
||||
VkImageCreateInfo info =
|
||||
init::ImageCreateInfo();
|
||||
@@ -27,11 +45,6 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
|
||||
info.arrayLayers = arraySize;
|
||||
info.format = cast(format);
|
||||
|
||||
VkImageViewCreateInfo viewInfo =
|
||||
init::ImageViewCreateInfo();
|
||||
viewInfo.subresourceRange = init::ImageSubresourceRange(aspect);
|
||||
viewInfo.viewType = viewType;
|
||||
|
||||
uint32 layerCount = 1;
|
||||
switch (viewType)
|
||||
{
|
||||
@@ -47,6 +60,7 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
|
||||
info.imageType = VK_IMAGE_TYPE_3D;
|
||||
break;
|
||||
case VK_IMAGE_VIEW_TYPE_CUBE:
|
||||
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
|
||||
info.imageType = VK_IMAGE_TYPE_2D;
|
||||
layerCount = 6 * arrayCount;
|
||||
break;
|
||||
@@ -62,30 +76,122 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType, uint32 si
|
||||
info.usage = usage;
|
||||
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.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;
|
||||
|
||||
VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView));
|
||||
}
|
||||
|
||||
TextureBase::~TextureBase()
|
||||
TextureHandle::~TextureHandle()
|
||||
{
|
||||
vkDestroyImageView(graphics->getDevice(), defaultView, nullptr);
|
||||
vkDestroyImage(graphics->getDevice(), image, nullptr);
|
||||
}
|
||||
|
||||
Texture2D::Texture2D(PGraphics graphics, uint32 sizeX, uint32 sizeY,
|
||||
bool bArray, uint32 arraySize, uint32 mipLevels,
|
||||
Gfx::SeFormat format, uint32 samples, Gfx::SeImageUsageFlags usage)
|
||||
void TextureHandle::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||
{
|
||||
textureHandle = new TextureBase(graphics, bArray ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D,
|
||||
sizeX, sizeY, 1, bArray, arraySize, mipLevels, format, samples, usage);
|
||||
VkImageMemoryBarrier imageBarrier =
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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 *)¤tImageIndex;
|
||||
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()
|
||||
{
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -6,15 +6,27 @@ Seele::WindowManager::WindowManager()
|
||||
graphics = new Vulkan::Graphics();
|
||||
GraphicsInitializer 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()
|
||||
{
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
#pragma once
|
||||
#include "GraphicsResources.h"
|
||||
#include "Window.h"
|
||||
#include "Graphics.h"
|
||||
#include "Containers/Array.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class WindowManager
|
||||
{
|
||||
public:
|
||||
class WindowManager
|
||||
{
|
||||
public:
|
||||
WindowManager();
|
||||
~WindowManager();
|
||||
void addWindow(const WindowCreateInfo& createInfo);
|
||||
void addWindow(const WindowCreateInfo &createInfo);
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
inline bool isActive() const
|
||||
{
|
||||
return windows.size();
|
||||
}
|
||||
private:
|
||||
Array<PWindow> windows;
|
||||
|
||||
private:
|
||||
Array<Gfx::PWindow> windows;
|
||||
Gfx::PGraphics graphics;
|
||||
};
|
||||
DEFINE_REF(WindowManager);
|
||||
}
|
||||
};
|
||||
DEFINE_REF(WindowManager);
|
||||
} // namespace Seele
|
||||
+16
-16
@@ -3,30 +3,30 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
struct Rect
|
||||
{
|
||||
struct Rect
|
||||
{
|
||||
Rect()
|
||||
: size(0, 0)
|
||||
, offset(0, 0)
|
||||
{}
|
||||
: size(0, 0), offset(0, 0)
|
||||
{
|
||||
}
|
||||
Rect(float sizeX, float sizeY, float offsetX, float offsetY)
|
||||
: size(sizeX, sizeY)
|
||||
, offset(offsetX, offsetY)
|
||||
{}
|
||||
: size(sizeX, sizeY), offset(offsetX, offsetY)
|
||||
{
|
||||
}
|
||||
Rect(Vector2 size, Vector2 offset)
|
||||
: size(size)
|
||||
, offset(offset)
|
||||
{}
|
||||
: size(size), offset(offset)
|
||||
{
|
||||
}
|
||||
bool isEmpty() const
|
||||
{
|
||||
return size.x == 0 || size.y == 0;
|
||||
}
|
||||
Vector2 size;
|
||||
Vector2 offset;
|
||||
};
|
||||
struct Rect3D
|
||||
{
|
||||
};
|
||||
struct Rect3D
|
||||
{
|
||||
Vector3 size;
|
||||
Vector3 offset;
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -3,8 +3,9 @@
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
namespace Seele {
|
||||
typedef glm::mat2 Matrix2;
|
||||
typedef glm::mat3 Matrix3;
|
||||
typedef glm::mat4 Matrix4;
|
||||
}
|
||||
namespace Seele
|
||||
{
|
||||
typedef glm::mat2 Matrix2;
|
||||
typedef glm::mat3 Matrix3;
|
||||
typedef glm::mat4 Matrix4;
|
||||
} // namespace Seele
|
||||
+27
-44
@@ -2,9 +2,8 @@
|
||||
#include <stdint.h>
|
||||
namespace Seele
|
||||
{
|
||||
static uint32_t CRCTablesSB8[8][256] = {
|
||||
{
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||
static uint32_t CRCTablesSB8[8][256] = {
|
||||
{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,
|
||||
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,
|
||||
@@ -19,10 +18,8 @@ namespace Seele
|
||||
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,
|
||||
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
|
||||
},
|
||||
{
|
||||
0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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>
|
||||
inline constexpr T align(const T ptr, int64_t alignment)
|
||||
{
|
||||
template <typename T>
|
||||
inline constexpr T align(const T ptr, int64_t alignment)
|
||||
{
|
||||
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:
|
||||
// http://slicing-by-8.sourceforge.net/
|
||||
|
||||
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
|
||||
int32_t InitBytes = (int32_t)(align(Data, 4) - Data);
|
||||
@@ -176,7 +159,7 @@ namespace Seele
|
||||
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)
|
||||
{
|
||||
uint32_t V1 = *Data4++ ^ CRC;
|
||||
@@ -191,7 +174,7 @@ namespace Seele
|
||||
CRCTablesSB8[1][(V2 >> 16) & 0xFF] ^
|
||||
CRCTablesSB8[0][V2 >> 24];
|
||||
}
|
||||
Data = (const uint8_t*)Data4;
|
||||
Data = (const uint8_t *)Data4;
|
||||
|
||||
Length %= 8;
|
||||
}
|
||||
@@ -202,5 +185,5 @@ namespace Seele
|
||||
}
|
||||
|
||||
return ~CRC;
|
||||
}
|
||||
}
|
||||
} // namespace Seele
|
||||
+12
-11
@@ -2,16 +2,17 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
namespace Seele {
|
||||
typedef glm::vec2 Vector2;
|
||||
typedef glm::vec3 Vector3;
|
||||
typedef glm::vec4 Vector4;
|
||||
namespace Seele
|
||||
{
|
||||
typedef glm::vec2 Vector2;
|
||||
typedef glm::vec3 Vector3;
|
||||
typedef glm::vec4 Vector4;
|
||||
|
||||
typedef glm::uvec2 UVector2;
|
||||
typedef glm::uvec3 UVector3;
|
||||
typedef glm::uvec4 UVector4;
|
||||
typedef glm::uvec2 UVector2;
|
||||
typedef glm::uvec3 UVector3;
|
||||
typedef glm::uvec4 UVector4;
|
||||
|
||||
typedef glm::ivec2 IVector2;
|
||||
typedef glm::ivec3 IVector3;
|
||||
typedef glm::ivec4 IVector4;
|
||||
}
|
||||
typedef glm::ivec2 IVector2;
|
||||
typedef glm::ivec3 IVector3;
|
||||
typedef glm::ivec4 IVector4;
|
||||
} // namespace Seele
|
||||
@@ -35,15 +35,43 @@ namespace Seele
|
||||
, refCount(rhs.refCount)
|
||||
{
|
||||
}
|
||||
RefObject(RefObject&& rhs)
|
||||
: handle(std::move(rhs.handle))
|
||||
, refCount(std::move(rhs.refCount))
|
||||
{}
|
||||
~RefObject()
|
||||
{
|
||||
registeredObjects.erase(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
|
||||
{
|
||||
return handle == other.handle;
|
||||
}
|
||||
bool operator!=(const RefObject& other) const
|
||||
{
|
||||
return handle != other.handle;
|
||||
}
|
||||
bool operator<(const RefObject& other) const
|
||||
{
|
||||
return handle < other.handle;
|
||||
@@ -55,7 +83,7 @@ namespace Seele
|
||||
void removeRef()
|
||||
{
|
||||
refCount--;
|
||||
if (refCount.load() <= 0)
|
||||
if (refCount.load() == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
@@ -101,14 +129,23 @@ namespace Seele
|
||||
}
|
||||
RefPtr(const RefPtr& other)
|
||||
: object(other.object)
|
||||
{
|
||||
if(object != nullptr)
|
||||
{
|
||||
object->addRef();
|
||||
}
|
||||
}
|
||||
RefPtr(RefPtr&& rhs)
|
||||
: object(std::move(rhs.object))
|
||||
{
|
||||
rhs.object = nullptr;
|
||||
//Dont change references, they stay the same
|
||||
}
|
||||
template<typename F>
|
||||
RefPtr(const RefPtr<F>& other)
|
||||
{
|
||||
F* f = other.getObject()->getHandle();
|
||||
T* t = static_cast<T*>(f);
|
||||
static_cast<T*>(f);
|
||||
object = (RefObject<T>*)other.getObject();
|
||||
object->addRef();
|
||||
}
|
||||
@@ -123,27 +160,58 @@ namespace Seele
|
||||
return nullptr;
|
||||
}
|
||||
RefObject<F>* newObject = (RefObject<F>*)object;
|
||||
RefPtr<F> result(newObject);
|
||||
return result;
|
||||
return RefPtr<F>(newObject);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (this != &other)
|
||||
if (*this != other)
|
||||
{
|
||||
if (object != nullptr)
|
||||
{
|
||||
object->removeRef();
|
||||
}
|
||||
object = other.object;
|
||||
if(object != nullptr)
|
||||
{
|
||||
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;
|
||||
}
|
||||
~RefPtr()
|
||||
{
|
||||
if(object != nullptr)
|
||||
{
|
||||
object->removeRef();
|
||||
}
|
||||
}
|
||||
bool operator==(const RefPtr& other) const
|
||||
{
|
||||
return object == other.object;
|
||||
@@ -166,6 +234,14 @@ namespace Seele
|
||||
{
|
||||
return object;
|
||||
}
|
||||
T* getHandle()
|
||||
{
|
||||
return object->getHandle();
|
||||
}
|
||||
const T* getHandle() const
|
||||
{
|
||||
return object->getHandle();
|
||||
}
|
||||
private:
|
||||
RefObject<T>* object;
|
||||
};
|
||||
|
||||
@@ -54,6 +54,8 @@ BOOST_AUTO_TEST_CASE(inheritance_cast)
|
||||
Seele::RefPtr<TestStruct> base = derived;
|
||||
BOOST_REQUIRE_EQUAL(base->data, 10);
|
||||
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->data2, 20);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "EngineTest.h"
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include "Graphics/Vulkan/VulkanGraphics.h"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user