remove Xe From engine class names
This commit is contained in:
parent
4ab67b4793
commit
f81d611f0e
33 changed files with 344 additions and 343 deletions
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
VkDeviceSize XeBuffer::getAlignment(VkDeviceSize instanceSize, VkDeviceSize minOffsetAlignment) {
|
VkDeviceSize Buffer::getAlignment(VkDeviceSize instanceSize, VkDeviceSize minOffsetAlignment) {
|
||||||
if (minOffsetAlignment > 0) {
|
if (minOffsetAlignment > 0) {
|
||||||
return (instanceSize + minOffsetAlignment - 1) & ~(minOffsetAlignment - 1);
|
return (instanceSize + minOffsetAlignment - 1) & ~(minOffsetAlignment - 1);
|
||||||
}
|
}
|
||||||
return instanceSize;
|
return instanceSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
XeBuffer::XeBuffer(
|
Buffer::Buffer(
|
||||||
XeDevice &device,
|
Device &device,
|
||||||
VkDeviceSize instanceSize,
|
VkDeviceSize instanceSize,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
VkBufferUsageFlags usageFlags,
|
VkBufferUsageFlags usageFlags,
|
||||||
|
@ -29,25 +29,25 @@ XeBuffer::XeBuffer(
|
||||||
device.createBuffer(bufferSize, usageFlags, memoryPropertyFlags, buffer, memory);
|
device.createBuffer(bufferSize, usageFlags, memoryPropertyFlags, buffer, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeBuffer::~XeBuffer() {
|
Buffer::~Buffer() {
|
||||||
unmap();
|
unmap();
|
||||||
vkDestroyBuffer(xeDevice.device(), buffer, nullptr);
|
vkDestroyBuffer(xeDevice.device(), buffer, nullptr);
|
||||||
vkFreeMemory(xeDevice.device(), memory, nullptr);
|
vkFreeMemory(xeDevice.device(), memory, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeBuffer::map(VkDeviceSize size, VkDeviceSize offset) {
|
VkResult Buffer::map(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
assert(buffer && memory && "Called map on buffer before create");
|
assert(buffer && memory && "Called map on buffer before create");
|
||||||
return vkMapMemory(xeDevice.device(), memory, offset, size, 0, &mapped);
|
return vkMapMemory(xeDevice.device(), memory, offset, size, 0, &mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeBuffer::unmap() {
|
void Buffer::unmap() {
|
||||||
if (mapped) {
|
if (mapped) {
|
||||||
vkUnmapMemory(xeDevice.device(), memory);
|
vkUnmapMemory(xeDevice.device(), memory);
|
||||||
mapped = nullptr;
|
mapped = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeBuffer::writeToBuffer(void *data, VkDeviceSize size, VkDeviceSize offset) {
|
void Buffer::writeToBuffer(void *data, VkDeviceSize size, VkDeviceSize offset) {
|
||||||
assert(mapped && "Cannot copy to unmapped buffer");
|
assert(mapped && "Cannot copy to unmapped buffer");
|
||||||
|
|
||||||
if (size == VK_WHOLE_SIZE) {
|
if (size == VK_WHOLE_SIZE) {
|
||||||
|
@ -59,7 +59,7 @@ void XeBuffer::writeToBuffer(void *data, VkDeviceSize size, VkDeviceSize offset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeBuffer::flush(VkDeviceSize size, VkDeviceSize offset) {
|
VkResult Buffer::flush(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
VkMappedMemoryRange mappedRange = {};
|
VkMappedMemoryRange mappedRange = {};
|
||||||
mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||||
mappedRange.memory = memory;
|
mappedRange.memory = memory;
|
||||||
|
@ -68,7 +68,7 @@ VkResult XeBuffer::flush(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
return vkFlushMappedMemoryRanges(xeDevice.device(), 1, &mappedRange);
|
return vkFlushMappedMemoryRanges(xeDevice.device(), 1, &mappedRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeBuffer::invalidate(VkDeviceSize size, VkDeviceSize offset) {
|
VkResult Buffer::invalidate(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
VkMappedMemoryRange mappedRange = {};
|
VkMappedMemoryRange mappedRange = {};
|
||||||
mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||||
mappedRange.memory = memory;
|
mappedRange.memory = memory;
|
||||||
|
@ -77,7 +77,7 @@ VkResult XeBuffer::invalidate(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
return vkInvalidateMappedMemoryRanges(xeDevice.device(), 1, &mappedRange);
|
return vkInvalidateMappedMemoryRanges(xeDevice.device(), 1, &mappedRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorBufferInfo XeBuffer::descriptorInfo(VkDeviceSize size, VkDeviceSize offset) {
|
VkDescriptorBufferInfo Buffer::descriptorInfo(VkDeviceSize size, VkDeviceSize offset) {
|
||||||
return VkDescriptorBufferInfo{
|
return VkDescriptorBufferInfo{
|
||||||
buffer,
|
buffer,
|
||||||
offset,
|
offset,
|
||||||
|
@ -85,17 +85,17 @@ VkDescriptorBufferInfo XeBuffer::descriptorInfo(VkDeviceSize size, VkDeviceSize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeBuffer::writeToIndex(void *data, int index) {
|
void Buffer::writeToIndex(void *data, int index) {
|
||||||
writeToBuffer(data, instanceSize, index * alignmentSize);
|
writeToBuffer(data, instanceSize, index * alignmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeBuffer::flushIndex(int index) { return flush(alignmentSize, index * alignmentSize); }
|
VkResult Buffer::flushIndex(int index) { return flush(alignmentSize, index * alignmentSize); }
|
||||||
|
|
||||||
VkDescriptorBufferInfo XeBuffer::descriptorInfoForIndex(int index) {
|
VkDescriptorBufferInfo Buffer::descriptorInfoForIndex(int index) {
|
||||||
return descriptorInfo(alignmentSize, index * alignmentSize);
|
return descriptorInfo(alignmentSize, index * alignmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeBuffer::invalidateIndex(int index) {
|
VkResult Buffer::invalidateIndex(int index) {
|
||||||
return invalidate(alignmentSize, index * alignmentSize);
|
return invalidate(alignmentSize, index * alignmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeBuffer {
|
class Buffer {
|
||||||
public:
|
public:
|
||||||
XeBuffer(
|
Buffer(
|
||||||
XeDevice& device,
|
Device& device,
|
||||||
VkDeviceSize instanceSize,
|
VkDeviceSize instanceSize,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
VkBufferUsageFlags usageFlags,
|
VkBufferUsageFlags usageFlags,
|
||||||
VkMemoryPropertyFlags memoryPropertyFlags,
|
VkMemoryPropertyFlags memoryPropertyFlags,
|
||||||
VkDeviceSize minOffsetAlignment = 1);
|
VkDeviceSize minOffsetAlignment = 1);
|
||||||
~XeBuffer();
|
~Buffer();
|
||||||
|
|
||||||
XeBuffer(const XeBuffer&) = delete;
|
Buffer(const Buffer&) = delete;
|
||||||
XeBuffer& operator=(const XeBuffer&) = delete;
|
Buffer& operator=(const Buffer&) = delete;
|
||||||
|
|
||||||
VkResult map(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0);
|
VkResult map(VkDeviceSize size = VK_WHOLE_SIZE, VkDeviceSize offset = 0);
|
||||||
void unmap();
|
void unmap();
|
||||||
|
@ -43,7 +43,7 @@ class XeBuffer {
|
||||||
private:
|
private:
|
||||||
static VkDeviceSize getAlignment(VkDeviceSize instanceSize, VkDeviceSize minOffsetAlignment);
|
static VkDeviceSize getAlignment(VkDeviceSize instanceSize, VkDeviceSize minOffsetAlignment);
|
||||||
|
|
||||||
XeDevice& xeDevice;
|
Device& xeDevice;
|
||||||
void* mapped = nullptr;
|
void* mapped = nullptr;
|
||||||
VkBuffer buffer = VK_NULL_HANDLE;
|
VkBuffer buffer = VK_NULL_HANDLE;
|
||||||
VkDeviceMemory memory = VK_NULL_HANDLE;
|
VkDeviceMemory memory = VK_NULL_HANDLE;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
void XeCamera::setOrthographicProjection(
|
void Camera::setOrthographicProjection(
|
||||||
float left, float right, float top, float bottom, float near, float far) {
|
float left, float right, float top, float bottom, float near, float far) {
|
||||||
projectionMatrix = glm::mat4{1.0f};
|
projectionMatrix = glm::mat4{1.0f};
|
||||||
projectionMatrix[0][0] = 2.f / (right - left);
|
projectionMatrix[0][0] = 2.f / (right - left);
|
||||||
|
@ -16,7 +16,7 @@ void XeCamera::setOrthographicProjection(
|
||||||
projectionMatrix[3][2] = -near / (far - near);
|
projectionMatrix[3][2] = -near / (far - near);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeCamera::setPerspectiveProjection(float fovy, float aspect, float near, float far) {
|
void Camera::setPerspectiveProjection(float fovy, float aspect, float near, float far) {
|
||||||
assert(glm::abs(aspect - std::numeric_limits<float>::epsilon()) > 0.0f);
|
assert(glm::abs(aspect - std::numeric_limits<float>::epsilon()) > 0.0f);
|
||||||
const float tanHalfFovy = tan(fovy / 2.f);
|
const float tanHalfFovy = tan(fovy / 2.f);
|
||||||
projectionMatrix = glm::mat4{0.0f};
|
projectionMatrix = glm::mat4{0.0f};
|
||||||
|
@ -27,7 +27,7 @@ void XeCamera::setPerspectiveProjection(float fovy, float aspect, float near, fl
|
||||||
projectionMatrix[3][2] = -(far * near) / (far - near);
|
projectionMatrix[3][2] = -(far * near) / (far - near);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeCamera::setViewDirection(glm::vec3 position, glm::vec3 direction, glm::vec3 up) {
|
void Camera::setViewDirection(glm::vec3 position, glm::vec3 direction, glm::vec3 up) {
|
||||||
const glm::vec3 w{glm::normalize(direction)};
|
const glm::vec3 w{glm::normalize(direction)};
|
||||||
const glm::vec3 u{glm::normalize(glm::cross(w, up))};
|
const glm::vec3 u{glm::normalize(glm::cross(w, up))};
|
||||||
const glm::vec3 v{glm::cross(w, u)};
|
const glm::vec3 v{glm::cross(w, u)};
|
||||||
|
@ -47,11 +47,11 @@ void XeCamera::setViewDirection(glm::vec3 position, glm::vec3 direction, glm::ve
|
||||||
viewMatrix[3][2] = -glm::dot(w, position);
|
viewMatrix[3][2] = -glm::dot(w, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeCamera::setViewTarget(glm::vec3 position, glm::vec3 target, glm::vec3 up) {
|
void Camera::setViewTarget(glm::vec3 position, glm::vec3 target, glm::vec3 up) {
|
||||||
setViewDirection(position, target - position, up);
|
setViewDirection(position, target - position, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeCamera::setViewYXZ(glm::vec3 position, glm::vec3 rotation) {
|
void Camera::setViewYXZ(glm::vec3 position, glm::vec3 rotation) {
|
||||||
const float c3 = glm::cos(rotation.z);
|
const float c3 = glm::cos(rotation.z);
|
||||||
const float s3 = glm::sin(rotation.z);
|
const float s3 = glm::sin(rotation.z);
|
||||||
const float c2 = glm::cos(rotation.x);
|
const float c2 = glm::cos(rotation.x);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeCamera {
|
class Camera {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setOrthographicProjection(
|
void setOrthographicProjection(
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeDescriptorSetLayout::Builder &XeDescriptorSetLayout::Builder::addBinding(
|
DescriptorSetLayout::Builder &DescriptorSetLayout::Builder::addBinding(
|
||||||
uint32_t binding,
|
uint32_t binding,
|
||||||
VkDescriptorType descriptorType,
|
VkDescriptorType descriptorType,
|
||||||
VkShaderStageFlags stageFlags,
|
VkShaderStageFlags stageFlags,
|
||||||
|
@ -22,12 +22,12 @@ XeDescriptorSetLayout::Builder &XeDescriptorSetLayout::Builder::addBinding(
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<XeDescriptorSetLayout> XeDescriptorSetLayout::Builder::build() const {
|
std::unique_ptr<DescriptorSetLayout> DescriptorSetLayout::Builder::build() const {
|
||||||
return std::make_unique<XeDescriptorSetLayout>(xeDevice, bindings);
|
return std::make_unique<DescriptorSetLayout>(xeDevice, bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorSetLayout::XeDescriptorSetLayout(
|
DescriptorSetLayout::DescriptorSetLayout(
|
||||||
XeDevice &xeDevice, std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings)
|
Device &xeDevice, std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings)
|
||||||
: xeDevice{xeDevice}, bindings{bindings} {
|
: xeDevice{xeDevice}, bindings{bindings} {
|
||||||
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings{};
|
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings{};
|
||||||
for (auto kv : bindings) {
|
for (auto kv : bindings) {
|
||||||
|
@ -48,32 +48,32 @@ XeDescriptorSetLayout::XeDescriptorSetLayout(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorSetLayout::~XeDescriptorSetLayout() {
|
DescriptorSetLayout::~DescriptorSetLayout() {
|
||||||
vkDestroyDescriptorSetLayout(xeDevice.device(), descriptorSetLayout, nullptr);
|
vkDestroyDescriptorSetLayout(xeDevice.device(), descriptorSetLayout, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorPool::Builder &XeDescriptorPool::Builder::addPoolSize(
|
DescriptorPool::Builder &DescriptorPool::Builder::addPoolSize(
|
||||||
VkDescriptorType descriptorType, uint32_t count) {
|
VkDescriptorType descriptorType, uint32_t count) {
|
||||||
poolSizes.push_back({descriptorType, count});
|
poolSizes.push_back({descriptorType, count});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorPool::Builder &XeDescriptorPool::Builder::setPoolFlags(
|
DescriptorPool::Builder &DescriptorPool::Builder::setPoolFlags(
|
||||||
VkDescriptorPoolCreateFlags flags) {
|
VkDescriptorPoolCreateFlags flags) {
|
||||||
poolFlags = flags;
|
poolFlags = flags;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
XeDescriptorPool::Builder &XeDescriptorPool::Builder::setMaxSets(uint32_t count) {
|
DescriptorPool::Builder &DescriptorPool::Builder::setMaxSets(uint32_t count) {
|
||||||
maxSets = count;
|
maxSets = count;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<XeDescriptorPool> XeDescriptorPool::Builder::build() const {
|
std::unique_ptr<DescriptorPool> DescriptorPool::Builder::build() const {
|
||||||
return std::make_unique<XeDescriptorPool>(xeDevice, maxSets, poolFlags, poolSizes);
|
return std::make_unique<DescriptorPool>(xeDevice, maxSets, poolFlags, poolSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorPool::XeDescriptorPool(
|
DescriptorPool::DescriptorPool(
|
||||||
XeDevice &xeDevice,
|
Device &xeDevice,
|
||||||
uint32_t maxSets,
|
uint32_t maxSets,
|
||||||
VkDescriptorPoolCreateFlags poolFlags,
|
VkDescriptorPoolCreateFlags poolFlags,
|
||||||
const std::vector<VkDescriptorPoolSize> &poolSizes)
|
const std::vector<VkDescriptorPoolSize> &poolSizes)
|
||||||
|
@ -91,11 +91,11 @@ XeDescriptorPool::XeDescriptorPool(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorPool::~XeDescriptorPool() {
|
DescriptorPool::~DescriptorPool() {
|
||||||
vkDestroyDescriptorPool(xeDevice.device(), descriptorPool, nullptr);
|
vkDestroyDescriptorPool(xeDevice.device(), descriptorPool, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XeDescriptorPool::allocateDescriptor(
|
bool DescriptorPool::allocateDescriptor(
|
||||||
const VkDescriptorSetLayout descriptorSetLayout, VkDescriptorSet &descriptor) const {
|
const VkDescriptorSetLayout descriptorSetLayout, VkDescriptorSet &descriptor) const {
|
||||||
VkDescriptorSetAllocateInfo allocInfo{};
|
VkDescriptorSetAllocateInfo allocInfo{};
|
||||||
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
|
@ -109,7 +109,7 @@ bool XeDescriptorPool::allocateDescriptor(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDescriptorPool::freeDescriptors(std::vector<VkDescriptorSet> &descriptors) const {
|
void DescriptorPool::freeDescriptors(std::vector<VkDescriptorSet> &descriptors) const {
|
||||||
vkFreeDescriptorSets(
|
vkFreeDescriptorSets(
|
||||||
xeDevice.device(),
|
xeDevice.device(),
|
||||||
descriptorPool,
|
descriptorPool,
|
||||||
|
@ -117,14 +117,14 @@ void XeDescriptorPool::freeDescriptors(std::vector<VkDescriptorSet> &descriptors
|
||||||
descriptors.data());
|
descriptors.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDescriptorPool::resetPool() {
|
void DescriptorPool::resetPool() {
|
||||||
vkResetDescriptorPool(xeDevice.device(), descriptorPool, 0);
|
vkResetDescriptorPool(xeDevice.device(), descriptorPool, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorWriter::XeDescriptorWriter(XeDescriptorSetLayout &setLayout, XeDescriptorPool &pool)
|
DescriptorWriter::DescriptorWriter(DescriptorSetLayout &setLayout, DescriptorPool &pool)
|
||||||
: setLayout{setLayout}, pool{pool} {}
|
: setLayout{setLayout}, pool{pool} {}
|
||||||
|
|
||||||
XeDescriptorWriter &XeDescriptorWriter::writeBuffer(
|
DescriptorWriter &DescriptorWriter::writeBuffer(
|
||||||
uint32_t binding, VkDescriptorBufferInfo *bufferInfo) {
|
uint32_t binding, VkDescriptorBufferInfo *bufferInfo) {
|
||||||
assert(setLayout.bindings.count(binding) == 1 && "Layout does not contain specified binding");
|
assert(setLayout.bindings.count(binding) == 1 && "Layout does not contain specified binding");
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ XeDescriptorWriter &XeDescriptorWriter::writeBuffer(
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDescriptorWriter &XeDescriptorWriter::writeImage(
|
DescriptorWriter &DescriptorWriter::writeImage(
|
||||||
uint32_t binding, VkDescriptorImageInfo *imageInfo) {
|
uint32_t binding, VkDescriptorImageInfo *imageInfo) {
|
||||||
assert(setLayout.bindings.count(binding) == 1 && "Layout does not contain specified binding");
|
assert(setLayout.bindings.count(binding) == 1 && "Layout does not contain specified binding");
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ XeDescriptorWriter &XeDescriptorWriter::writeImage(
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XeDescriptorWriter::build(VkDescriptorSet &set) {
|
bool DescriptorWriter::build(VkDescriptorSet &set) {
|
||||||
bool success = pool.allocateDescriptor(setLayout.getDescriptorSetLayout(), set);
|
bool success = pool.allocateDescriptor(setLayout.getDescriptorSetLayout(), set);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -175,7 +175,7 @@ bool XeDescriptorWriter::build(VkDescriptorSet &set) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDescriptorWriter::overwrite(VkDescriptorSet &set) {
|
void DescriptorWriter::overwrite(VkDescriptorSet &set) {
|
||||||
for (auto &write : writes) {
|
for (auto &write : writes) {
|
||||||
write.dstSet = set;
|
write.dstSet = set;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,66 +9,66 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeDescriptorSetLayout {
|
class DescriptorSetLayout {
|
||||||
public:
|
public:
|
||||||
class Builder {
|
class Builder {
|
||||||
public:
|
public:
|
||||||
Builder(XeDevice &xeDevice) : xeDevice{xeDevice} {}
|
Builder(Device &xeDevice) : xeDevice{xeDevice} {}
|
||||||
|
|
||||||
Builder &addBinding(
|
Builder &addBinding(
|
||||||
uint32_t binding,
|
uint32_t binding,
|
||||||
VkDescriptorType descriptorType,
|
VkDescriptorType descriptorType,
|
||||||
VkShaderStageFlags stageFlags,
|
VkShaderStageFlags stageFlags,
|
||||||
VkSampler *sampler);
|
VkSampler *sampler);
|
||||||
std::unique_ptr<XeDescriptorSetLayout> build() const;
|
std::unique_ptr<DescriptorSetLayout> build() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings{};
|
std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings{};
|
||||||
};
|
};
|
||||||
|
|
||||||
XeDescriptorSetLayout(
|
DescriptorSetLayout(
|
||||||
XeDevice &xeDevice, std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings);
|
Device &xeDevice, std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings);
|
||||||
~XeDescriptorSetLayout();
|
~DescriptorSetLayout();
|
||||||
XeDescriptorSetLayout(const XeDescriptorSetLayout &) = delete;
|
DescriptorSetLayout(const DescriptorSetLayout &) = delete;
|
||||||
XeDescriptorSetLayout &operator=(const XeDescriptorSetLayout &) = delete;
|
DescriptorSetLayout &operator=(const DescriptorSetLayout &) = delete;
|
||||||
|
|
||||||
VkDescriptorSetLayout getDescriptorSetLayout() const { return descriptorSetLayout; }
|
VkDescriptorSetLayout getDescriptorSetLayout() const { return descriptorSetLayout; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
VkDescriptorSetLayout descriptorSetLayout;
|
VkDescriptorSetLayout descriptorSetLayout;
|
||||||
std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings;
|
std::unordered_map<uint32_t, VkDescriptorSetLayoutBinding> bindings;
|
||||||
|
|
||||||
friend class XeDescriptorWriter;
|
friend class DescriptorWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XeDescriptorPool {
|
class DescriptorPool {
|
||||||
public:
|
public:
|
||||||
class Builder {
|
class Builder {
|
||||||
public:
|
public:
|
||||||
Builder(XeDevice &xeDevice) : xeDevice{xeDevice} {}
|
Builder(Device &xeDevice) : xeDevice{xeDevice} {}
|
||||||
|
|
||||||
Builder &addPoolSize(VkDescriptorType descriptorType, uint32_t count);
|
Builder &addPoolSize(VkDescriptorType descriptorType, uint32_t count);
|
||||||
Builder &setPoolFlags(VkDescriptorPoolCreateFlags flags);
|
Builder &setPoolFlags(VkDescriptorPoolCreateFlags flags);
|
||||||
Builder &setMaxSets(uint32_t count);
|
Builder &setMaxSets(uint32_t count);
|
||||||
std::unique_ptr<XeDescriptorPool> build() const;
|
std::unique_ptr<DescriptorPool> build() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
std::vector<VkDescriptorPoolSize> poolSizes{};
|
std::vector<VkDescriptorPoolSize> poolSizes{};
|
||||||
uint32_t maxSets = 1000;
|
uint32_t maxSets = 1000;
|
||||||
VkDescriptorPoolCreateFlags poolFlags = 0;
|
VkDescriptorPoolCreateFlags poolFlags = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
XeDescriptorPool(
|
DescriptorPool(
|
||||||
XeDevice &xeDevice,
|
Device &xeDevice,
|
||||||
uint32_t maxSets,
|
uint32_t maxSets,
|
||||||
VkDescriptorPoolCreateFlags poolFlags,
|
VkDescriptorPoolCreateFlags poolFlags,
|
||||||
const std::vector<VkDescriptorPoolSize> &poolSizes);
|
const std::vector<VkDescriptorPoolSize> &poolSizes);
|
||||||
~XeDescriptorPool();
|
~DescriptorPool();
|
||||||
XeDescriptorPool(const XeDescriptorPool &) = delete;
|
DescriptorPool(const DescriptorPool &) = delete;
|
||||||
XeDescriptorPool &operator=(const XeDescriptorPool &) = delete;
|
DescriptorPool &operator=(const DescriptorPool &) = delete;
|
||||||
|
|
||||||
bool allocateDescriptor(
|
bool allocateDescriptor(
|
||||||
const VkDescriptorSetLayout descriptorSetLayout, VkDescriptorSet &descriptor) const;
|
const VkDescriptorSetLayout descriptorSetLayout, VkDescriptorSet &descriptor) const;
|
||||||
|
@ -78,25 +78,25 @@ class XeDescriptorPool {
|
||||||
void resetPool();
|
void resetPool();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
VkDescriptorPool descriptorPool;
|
VkDescriptorPool descriptorPool;
|
||||||
|
|
||||||
friend class XeDescriptorWriter;
|
friend class DescriptorWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XeDescriptorWriter {
|
class DescriptorWriter {
|
||||||
public:
|
public:
|
||||||
XeDescriptorWriter(XeDescriptorSetLayout &setLayout, XeDescriptorPool &pool);
|
DescriptorWriter(DescriptorSetLayout &setLayout, DescriptorPool &pool);
|
||||||
|
|
||||||
XeDescriptorWriter &writeBuffer(uint32_t binding, VkDescriptorBufferInfo *bufferInfo);
|
DescriptorWriter &writeBuffer(uint32_t binding, VkDescriptorBufferInfo *bufferInfo);
|
||||||
XeDescriptorWriter &writeImage(uint32_t binding, VkDescriptorImageInfo *imageInfo);
|
DescriptorWriter &writeImage(uint32_t binding, VkDescriptorImageInfo *imageInfo);
|
||||||
|
|
||||||
bool build(VkDescriptorSet &set);
|
bool build(VkDescriptorSet &set);
|
||||||
void overwrite(VkDescriptorSet &set);
|
void overwrite(VkDescriptorSet &set);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeDescriptorSetLayout &setLayout;
|
DescriptorSetLayout &setLayout;
|
||||||
XeDescriptorPool &pool;
|
DescriptorPool &pool;
|
||||||
std::vector<VkWriteDescriptorSet> writes;
|
std::vector<VkWriteDescriptorSet> writes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void DestroyDebugUtilsMessengerEXT(
|
||||||
}
|
}
|
||||||
|
|
||||||
// class member functions
|
// class member functions
|
||||||
XeDevice::XeDevice(XeWindow &window) : window{window} {
|
Device::Device(Window &window) : window{window} {
|
||||||
createInstance();
|
createInstance();
|
||||||
setupDebugMessenger();
|
setupDebugMessenger();
|
||||||
createSurface();
|
createSurface();
|
||||||
|
@ -56,7 +56,7 @@ XeDevice::XeDevice(XeWindow &window) : window{window} {
|
||||||
createCommandPool();
|
createCommandPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
XeDevice::~XeDevice() {
|
Device::~Device() {
|
||||||
vkDestroyCommandPool(device_, commandPool, nullptr);
|
vkDestroyCommandPool(device_, commandPool, nullptr);
|
||||||
vkDestroyDevice(device_, nullptr);
|
vkDestroyDevice(device_, nullptr);
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ XeDevice::~XeDevice() {
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createInstance() {
|
void Device::createInstance() {
|
||||||
if (enableValidationLayers && !checkValidationLayerSupport()) {
|
if (enableValidationLayers && !checkValidationLayerSupport()) {
|
||||||
throw std::runtime_error("validation layers requested, but not available!");
|
throw std::runtime_error("validation layers requested, but not available!");
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ void XeDevice::createInstance() {
|
||||||
hasGflwRequiredInstanceExtensions();
|
hasGflwRequiredInstanceExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::pickPhysicalDevice() {
|
void Device::pickPhysicalDevice() {
|
||||||
uint32_t deviceCount = 0;
|
uint32_t deviceCount = 0;
|
||||||
vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);
|
vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);
|
||||||
if (deviceCount == 0) {
|
if (deviceCount == 0) {
|
||||||
|
@ -133,7 +133,7 @@ void XeDevice::pickPhysicalDevice() {
|
||||||
std::cout << "Physical device: " << properties.deviceName << std::endl;
|
std::cout << "Physical device: " << properties.deviceName << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createLogicalDevice() {
|
void Device::createLogicalDevice() {
|
||||||
QueueFamilyIndices indices = findQueueFamilies(physicalDevice);
|
QueueFamilyIndices indices = findQueueFamilies(physicalDevice);
|
||||||
|
|
||||||
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
||||||
|
@ -179,7 +179,7 @@ void XeDevice::createLogicalDevice() {
|
||||||
vkGetDeviceQueue(device_, indices.presentFamily, 0, &presentQueue_);
|
vkGetDeviceQueue(device_, indices.presentFamily, 0, &presentQueue_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createCommandPool() {
|
void Device::createCommandPool() {
|
||||||
QueueFamilyIndices queueFamilyIndices = findPhysicalQueueFamilies();
|
QueueFamilyIndices queueFamilyIndices = findPhysicalQueueFamilies();
|
||||||
|
|
||||||
VkCommandPoolCreateInfo poolInfo = {};
|
VkCommandPoolCreateInfo poolInfo = {};
|
||||||
|
@ -193,9 +193,9 @@ void XeDevice::createCommandPool() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createSurface() { window.createWindowSurface(instance, &surface_); }
|
void Device::createSurface() { window.createWindowSurface(instance, &surface_); }
|
||||||
|
|
||||||
bool XeDevice::isDeviceSuitable(VkPhysicalDevice device) {
|
bool Device::isDeviceSuitable(VkPhysicalDevice device) {
|
||||||
QueueFamilyIndices indices = findQueueFamilies(device);
|
QueueFamilyIndices indices = findQueueFamilies(device);
|
||||||
|
|
||||||
bool extensionsSupported = checkDeviceExtensionSupport(device);
|
bool extensionsSupported = checkDeviceExtensionSupport(device);
|
||||||
|
@ -213,7 +213,7 @@ bool XeDevice::isDeviceSuitable(VkPhysicalDevice device) {
|
||||||
supportedFeatures.samplerAnisotropy;
|
supportedFeatures.samplerAnisotropy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::populateDebugMessengerCreateInfo(
|
void Device::populateDebugMessengerCreateInfo(
|
||||||
VkDebugUtilsMessengerCreateInfoEXT &createInfo) {
|
VkDebugUtilsMessengerCreateInfoEXT &createInfo) {
|
||||||
createInfo = {};
|
createInfo = {};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
||||||
|
@ -226,7 +226,7 @@ void XeDevice::populateDebugMessengerCreateInfo(
|
||||||
createInfo.pUserData = nullptr; // Optional
|
createInfo.pUserData = nullptr; // Optional
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::setupDebugMessenger() {
|
void Device::setupDebugMessenger() {
|
||||||
if (!enableValidationLayers) return;
|
if (!enableValidationLayers) return;
|
||||||
VkDebugUtilsMessengerCreateInfoEXT createInfo;
|
VkDebugUtilsMessengerCreateInfoEXT createInfo;
|
||||||
populateDebugMessengerCreateInfo(createInfo);
|
populateDebugMessengerCreateInfo(createInfo);
|
||||||
|
@ -235,7 +235,7 @@ void XeDevice::setupDebugMessenger() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XeDevice::checkValidationLayerSupport() {
|
bool Device::checkValidationLayerSupport() {
|
||||||
uint32_t layerCount;
|
uint32_t layerCount;
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ bool XeDevice::checkValidationLayerSupport() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char *> XeDevice::getRequiredExtensions() {
|
std::vector<const char *> Device::getRequiredExtensions() {
|
||||||
uint32_t glfwExtensionCount = 0;
|
uint32_t glfwExtensionCount = 0;
|
||||||
const char **glfwExtensions;
|
const char **glfwExtensions;
|
||||||
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
||||||
|
@ -274,7 +274,7 @@ std::vector<const char *> XeDevice::getRequiredExtensions() {
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::hasGflwRequiredInstanceExtensions() {
|
void Device::hasGflwRequiredInstanceExtensions() {
|
||||||
uint32_t extensionCount = 0;
|
uint32_t extensionCount = 0;
|
||||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||||
std::vector<VkExtensionProperties> extensions(extensionCount);
|
std::vector<VkExtensionProperties> extensions(extensionCount);
|
||||||
|
@ -297,7 +297,7 @@ void XeDevice::hasGflwRequiredInstanceExtensions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XeDevice::checkDeviceExtensionSupport(VkPhysicalDevice device) {
|
bool Device::checkDeviceExtensionSupport(VkPhysicalDevice device) {
|
||||||
uint32_t extensionCount;
|
uint32_t extensionCount;
|
||||||
vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionCount, nullptr);
|
vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionCount, nullptr);
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ bool XeDevice::checkDeviceExtensionSupport(VkPhysicalDevice device) {
|
||||||
return requiredExtensions.empty();
|
return requiredExtensions.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueFamilyIndices XeDevice::findQueueFamilies(VkPhysicalDevice device) {
|
QueueFamilyIndices Device::findQueueFamilies(VkPhysicalDevice device) {
|
||||||
QueueFamilyIndices indices;
|
QueueFamilyIndices indices;
|
||||||
|
|
||||||
uint32_t queueFamilyCount = 0;
|
uint32_t queueFamilyCount = 0;
|
||||||
|
@ -348,7 +348,7 @@ QueueFamilyIndices XeDevice::findQueueFamilies(VkPhysicalDevice device) {
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChainSupportDetails XeDevice::querySwapChainSupport(VkPhysicalDevice device) {
|
SwapChainSupportDetails Device::querySwapChainSupport(VkPhysicalDevice device) {
|
||||||
SwapChainSupportDetails details;
|
SwapChainSupportDetails details;
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface_, &details.capabilities);
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface_, &details.capabilities);
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ SwapChainSupportDetails XeDevice::querySwapChainSupport(VkPhysicalDevice device)
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat XeDevice::findSupportedFormat(
|
VkFormat Device::findSupportedFormat(
|
||||||
const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) {
|
const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) {
|
||||||
for (VkFormat format : candidates) {
|
for (VkFormat format : candidates) {
|
||||||
VkFormatProperties props;
|
VkFormatProperties props;
|
||||||
|
@ -390,7 +390,7 @@ VkFormat XeDevice::findSupportedFormat(
|
||||||
throw std::runtime_error("failed to find supported format!");
|
throw std::runtime_error("failed to find supported format!");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t XeDevice::findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) {
|
uint32_t Device::findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) {
|
||||||
VkPhysicalDeviceMemoryProperties memProperties;
|
VkPhysicalDeviceMemoryProperties memProperties;
|
||||||
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties);
|
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties);
|
||||||
for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
|
for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
|
||||||
|
@ -403,7 +403,7 @@ uint32_t XeDevice::findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags pro
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createBuffer(
|
void Device::createBuffer(
|
||||||
VkDeviceSize size,
|
VkDeviceSize size,
|
||||||
VkBufferUsageFlags usage,
|
VkBufferUsageFlags usage,
|
||||||
VkMemoryPropertyFlags properties,
|
VkMemoryPropertyFlags properties,
|
||||||
|
@ -434,7 +434,7 @@ void XeDevice::createBuffer(
|
||||||
vkBindBufferMemory(device_, buffer, bufferMemory, 0);
|
vkBindBufferMemory(device_, buffer, bufferMemory, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkCommandBuffer XeDevice::beginSingleTimeCommands() {
|
VkCommandBuffer Device::beginSingleTimeCommands() {
|
||||||
VkCommandBufferAllocateInfo allocInfo{};
|
VkCommandBufferAllocateInfo allocInfo{};
|
||||||
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||||
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||||
|
@ -452,7 +452,7 @@ VkCommandBuffer XeDevice::beginSingleTimeCommands() {
|
||||||
return commandBuffer;
|
return commandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::endSingleTimeCommands(VkCommandBuffer commandBuffer) {
|
void Device::endSingleTimeCommands(VkCommandBuffer commandBuffer) {
|
||||||
vkEndCommandBuffer(commandBuffer);
|
vkEndCommandBuffer(commandBuffer);
|
||||||
|
|
||||||
VkSubmitInfo submitInfo{};
|
VkSubmitInfo submitInfo{};
|
||||||
|
@ -466,7 +466,7 @@ void XeDevice::endSingleTimeCommands(VkCommandBuffer commandBuffer) {
|
||||||
vkFreeCommandBuffers(device_, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device_, commandPool, 1, &commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size) {
|
void Device::copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size) {
|
||||||
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
|
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
|
||||||
|
|
||||||
VkBufferCopy copyRegion{};
|
VkBufferCopy copyRegion{};
|
||||||
|
@ -478,7 +478,7 @@ void XeDevice::copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize s
|
||||||
endSingleTimeCommands(commandBuffer);
|
endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::copyBufferToImage(
|
void Device::copyBufferToImage(
|
||||||
VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t layerCount) {
|
VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t layerCount) {
|
||||||
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
|
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ void XeDevice::copyBufferToImage(
|
||||||
endSingleTimeCommands(commandBuffer);
|
endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeDevice::createImageWithInfo(
|
void Device::createImageWithInfo(
|
||||||
const VkImageCreateInfo &imageInfo,
|
const VkImageCreateInfo &imageInfo,
|
||||||
VkMemoryPropertyFlags properties,
|
VkMemoryPropertyFlags properties,
|
||||||
VkImage &image,
|
VkImage &image,
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct QueueFamilyIndices {
|
||||||
bool isComplete() { return graphicsFamilyHasValue && presentFamilyHasValue; }
|
bool isComplete() { return graphicsFamilyHasValue && presentFamilyHasValue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class XeDevice {
|
class Device {
|
||||||
public:
|
public:
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
const bool enableValidationLayers = false;
|
const bool enableValidationLayers = false;
|
||||||
|
@ -29,13 +29,13 @@ class XeDevice {
|
||||||
const bool enableValidationLayers = true;
|
const bool enableValidationLayers = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XeDevice(XeWindow &window);
|
Device(Window &window);
|
||||||
~XeDevice();
|
~Device();
|
||||||
|
|
||||||
XeDevice(const XeDevice &) = delete;
|
Device(const Device &) = delete;
|
||||||
void operator=(const XeDevice &) = delete;
|
void operator=(const Device &) = delete;
|
||||||
XeDevice(XeDevice &&) = delete;
|
Device(Device &&) = delete;
|
||||||
XeDevice &operator=(XeDevice &&) = delete;
|
Device &operator=(Device &&) = delete;
|
||||||
|
|
||||||
VkCommandPool getCommandPool() { return commandPool; }
|
VkCommandPool getCommandPool() { return commandPool; }
|
||||||
VkDevice device() { return device_; }
|
VkDevice device() { return device_; }
|
||||||
|
@ -90,7 +90,7 @@ class XeDevice {
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkDebugUtilsMessengerEXT debugMessenger;
|
VkDebugUtilsMessengerEXT debugMessenger;
|
||||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||||
XeWindow &window;
|
Window &window;
|
||||||
VkCommandPool commandPool;
|
VkCommandPool commandPool;
|
||||||
|
|
||||||
VkDevice device_;
|
VkDevice device_;
|
||||||
|
|
|
@ -8,46 +8,47 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeEngine::XeEngine(int width, int height, std::string name) : xeWindow{width, height, name},
|
Engine::Engine(int width, int height, std::string name) : xeWindow{width, height, name},
|
||||||
xeDevice{xeWindow},
|
xeDevice{xeWindow},
|
||||||
xeRenderer{xeWindow, xeDevice},
|
xeRenderer{xeWindow, xeDevice},
|
||||||
xeCamera{} {
|
xeCamera{} {
|
||||||
loadDescriptorPool();
|
loadDescriptorPool();
|
||||||
alutInit(0, NULL);
|
alutInit(0, NULL);
|
||||||
|
|
||||||
std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n";
|
std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
XeEngine::~XeEngine() {
|
Engine::~Engine() {
|
||||||
alutExit();
|
alutExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeEngine::loadDescriptorPool() {
|
void Engine::loadDescriptorPool() {
|
||||||
xeDescriptorPool = XeDescriptorPool::Builder(xeDevice)
|
xeDescriptorPool = DescriptorPool::Builder(xeDevice)
|
||||||
.setMaxSets(XeSwapChain::MAX_FRAMES_IN_FLIGHT)
|
.setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT)
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
|
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT)
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
|
.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT)
|
||||||
.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, XeSwapChain::MAX_FRAMES_IN_FLIGHT)
|
.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, SwapChain::MAX_FRAMES_IN_FLIGHT)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<XeModel> XeEngine::loadModelFromFile(const std::string &filename) {
|
std::shared_ptr<Model> Engine::loadModelFromFile(const std::string &filename) {
|
||||||
return XeModel::createModelFromFile(xeDevice, filename);
|
return Model::createModelFromFile(xeDevice, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<XeModel> XeEngine::loadModelFromData(std::vector<XeModel::Vertex> vertices, std::vector<uint32_t> indices) {
|
std::shared_ptr<Model> Engine::loadModelFromData(std::vector<Model::Vertex> vertices, std::vector<uint32_t> indices) {
|
||||||
XeModel::Builder builder{};
|
Model::Builder builder{};
|
||||||
builder.vertices = vertices;
|
builder.vertices = vertices;
|
||||||
if(indices.size() > 0) {
|
if(indices.size() > 0) {
|
||||||
builder.indices = indices;
|
builder.indices = indices;
|
||||||
}
|
}
|
||||||
return std::make_shared<XeModel>(xeDevice, builder);
|
return std::make_shared<Model>(xeDevice, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<XeImage> XeEngine::loadImage(const std::string &filename) {
|
std::shared_ptr<Image> Engine::loadImage(const std::string &filename) {
|
||||||
return std::make_shared<XeImage>(xeDevice, filename);
|
return std::make_shared<Image>(xeDevice, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XeEngine::poll() {
|
bool Engine::poll() {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
auto newTime = std::chrono::high_resolution_clock::now();
|
auto newTime = std::chrono::high_resolution_clock::now();
|
||||||
frameTime = std::chrono::duration<float, std::chrono::seconds::period>(newTime - currentTime).count();
|
frameTime = std::chrono::duration<float, std::chrono::seconds::period>(newTime - currentTime).count();
|
||||||
|
|
|
@ -11,23 +11,23 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeEngine {
|
class Engine {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XeEngine(int width, int height, std::string name);
|
Engine(int width, int height, std::string name);
|
||||||
|
|
||||||
~XeEngine();
|
~Engine();
|
||||||
|
|
||||||
XeEngine(const XeEngine&) = delete;
|
Engine(const Engine&) = delete;
|
||||||
XeEngine operator=(const XeEngine&) = delete;
|
Engine operator=(const Engine&) = delete;
|
||||||
|
|
||||||
XeWindow& getWindow() {return xeWindow;}
|
Window& getWindow() {return xeWindow;}
|
||||||
XeCamera& getCamera() {return xeCamera;}
|
Camera& getCamera() {return xeCamera;}
|
||||||
|
|
||||||
std::shared_ptr<XeModel> loadModelFromFile(const std::string &filename);
|
std::shared_ptr<Model> loadModelFromFile(const std::string &filename);
|
||||||
std::shared_ptr<XeModel> loadModelFromData(std::vector<XeModel::Vertex> vertices, std::vector<uint32_t> indices);
|
std::shared_ptr<Model> loadModelFromData(std::vector<Model::Vertex> vertices, std::vector<uint32_t> indices);
|
||||||
std::shared_ptr<XeImage> loadImage(const std::string &filename);
|
std::shared_ptr<Image> loadImage(const std::string &filename);
|
||||||
|
|
||||||
bool beginFrame() { return xeRenderer.beginFrame(); }
|
bool beginFrame() { return xeRenderer.beginFrame(); }
|
||||||
void endFrame() { xeRenderer.endFrame(); }
|
void endFrame() { xeRenderer.endFrame(); }
|
||||||
|
@ -40,19 +40,19 @@ class XeEngine {
|
||||||
|
|
||||||
void loadDescriptorPool();
|
void loadDescriptorPool();
|
||||||
|
|
||||||
XeWindow xeWindow;
|
Window xeWindow;
|
||||||
XeDevice xeDevice;
|
Device xeDevice;
|
||||||
XeRenderer xeRenderer;
|
Renderer xeRenderer;
|
||||||
XeCamera xeCamera;
|
Camera xeCamera;
|
||||||
|
|
||||||
std::chrono::_V2::system_clock::time_point currentTime;
|
std::chrono::_V2::system_clock::time_point currentTime;
|
||||||
float frameTime;
|
float frameTime;
|
||||||
|
|
||||||
float FOV = 50.f;
|
float FOV = 50.f;
|
||||||
|
|
||||||
std::unique_ptr<XeDescriptorPool> xeDescriptorPool;
|
std::unique_ptr<DescriptorPool> xeDescriptorPool;
|
||||||
|
|
||||||
friend class XeRenderSystem;
|
friend class RenderSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,28 +21,28 @@ struct TransformComponent {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class XeGameObject {
|
class GameObject {
|
||||||
public:
|
public:
|
||||||
using id_t = unsigned int;
|
using id_t = unsigned int;
|
||||||
|
|
||||||
static XeGameObject createGameObject() {
|
static GameObject createGameObject() {
|
||||||
static id_t currentId = 0;
|
static id_t currentId = 0;
|
||||||
return XeGameObject(currentId++);
|
return GameObject(currentId++);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeGameObject(const XeGameObject &) = delete;
|
GameObject(const GameObject &) = delete;
|
||||||
XeGameObject &operator=(const XeGameObject &) = delete;
|
GameObject &operator=(const GameObject &) = delete;
|
||||||
XeGameObject(XeGameObject&&) = default;
|
GameObject(GameObject&&) = default;
|
||||||
XeGameObject &operator=(XeGameObject &&) = default;
|
GameObject &operator=(GameObject &&) = default;
|
||||||
|
|
||||||
id_t getId() { return id; }
|
id_t getId() { return id; }
|
||||||
|
|
||||||
std::shared_ptr<XeModel> model{};
|
std::shared_ptr<Model> model{};
|
||||||
glm::vec3 color{};
|
glm::vec3 color{};
|
||||||
TransformComponent transform;
|
TransformComponent transform;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XeGameObject(id_t objId) : id{objId} {}
|
GameObject(id_t objId) : id{objId} {}
|
||||||
|
|
||||||
id_t id;
|
id_t id;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,18 +10,18 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeImage::XeImage(XeDevice &xeDevice, const std::string &filename) : xeDevice{xeDevice} {
|
Image::Image(Device &xeDevice, const std::string &filename) : xeDevice{xeDevice} {
|
||||||
createTextureImage(filename);
|
createTextureImage(filename);
|
||||||
createTextureImageView();
|
createTextureImageView();
|
||||||
}
|
}
|
||||||
|
|
||||||
XeImage::~XeImage() {
|
Image::~Image() {
|
||||||
vkDestroyImage(xeDevice.device(), textureImage, nullptr);
|
vkDestroyImage(xeDevice.device(), textureImage, nullptr);
|
||||||
vkFreeMemory(xeDevice.device(), textureImageMemory, nullptr);
|
vkFreeMemory(xeDevice.device(), textureImageMemory, nullptr);
|
||||||
vkDestroyImageView(xeDevice.device(), textureImageView, nullptr);
|
vkDestroyImageView(xeDevice.device(), textureImageView, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeImage::createTextureImage(const std::string &filename) {
|
void Image::createTextureImage(const std::string &filename) {
|
||||||
int texWidth, texHeight, texChannels;
|
int texWidth, texHeight, texChannels;
|
||||||
stbi_uc* pixels = stbi_load(filename.c_str(), &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
|
stbi_uc* pixels = stbi_load(filename.c_str(), &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
|
||||||
VkDeviceSize imageSize = texWidth * texHeight * 4;
|
VkDeviceSize imageSize = texWidth * texHeight * 4;
|
||||||
|
@ -59,7 +59,7 @@ void XeImage::createTextureImage(const std::string &filename) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeImage::createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory) {
|
void Image::createImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory) {
|
||||||
|
|
||||||
VkImageCreateInfo imageInfo{};
|
VkImageCreateInfo imageInfo{};
|
||||||
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||||
|
@ -95,7 +95,7 @@ void XeImage::createImage(uint32_t width, uint32_t height, VkFormat format, VkIm
|
||||||
vkBindImageMemory(xeDevice.device(), image, imageMemory, 0);
|
vkBindImageMemory(xeDevice.device(), image, imageMemory, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeImage::transitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout) {
|
void Image::transitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout) {
|
||||||
VkCommandBuffer commandBuffer = xeDevice.beginSingleTimeCommands();
|
VkCommandBuffer commandBuffer = xeDevice.beginSingleTimeCommands();
|
||||||
|
|
||||||
VkImageMemoryBarrier barrier{};
|
VkImageMemoryBarrier barrier{};
|
||||||
|
@ -142,7 +142,7 @@ void XeImage::transitionImageLayout(VkImage image, VkFormat format, VkImageLayou
|
||||||
xeDevice.endSingleTimeCommands(commandBuffer);
|
xeDevice.endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeImage::copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height) {
|
void Image::copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height) {
|
||||||
VkCommandBuffer commandBuffer = xeDevice.beginSingleTimeCommands();
|
VkCommandBuffer commandBuffer = xeDevice.beginSingleTimeCommands();
|
||||||
|
|
||||||
VkBufferImageCopy region{};
|
VkBufferImageCopy region{};
|
||||||
|
@ -165,7 +165,7 @@ void XeImage::copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width,
|
||||||
xeDevice.endSingleTimeCommands(commandBuffer);
|
xeDevice.endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeImage::createTextureImageView() {
|
void Image::createTextureImageView() {
|
||||||
VkImageViewCreateInfo viewInfo{};
|
VkImageViewCreateInfo viewInfo{};
|
||||||
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||||
viewInfo.image = textureImage;
|
viewInfo.image = textureImage;
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeImage {
|
class Image {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XeImage(XeDevice &xeDevice, const std::string &filename);
|
Image(Device &xeDevice, const std::string &filename);
|
||||||
~XeImage();
|
~Image();
|
||||||
|
|
||||||
XeImage(const XeImage&) = delete;
|
Image(const Image&) = delete;
|
||||||
XeImage operator=(const XeImage&) = delete;
|
Image operator=(const Image&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -24,13 +24,13 @@ class XeImage {
|
||||||
void copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height);
|
void copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height);
|
||||||
void createTextureImageView();
|
void createTextureImageView();
|
||||||
|
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
|
|
||||||
VkImage textureImage;
|
VkImage textureImage;
|
||||||
VkImageView textureImageView;
|
VkImageView textureImageView;
|
||||||
VkDeviceMemory textureImageMemory;
|
VkDeviceMemory textureImageMemory;
|
||||||
|
|
||||||
friend class XeRenderSystem;
|
friend class RenderSystem;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template<>
|
template<>
|
||||||
struct hash<xe::XeModel::Vertex> {
|
struct hash<xe::Model::Vertex> {
|
||||||
size_t operator()(xe::XeModel::Vertex const &vertex) const {
|
size_t operator()(xe::Model::Vertex const &vertex) const {
|
||||||
size_t seed = 0;
|
size_t seed = 0;
|
||||||
xe::hashCombine(seed, vertex.position, vertex.normal, vertex.uv);
|
xe::hashCombine(seed, vertex.position, vertex.normal, vertex.uv);
|
||||||
return seed;
|
return seed;
|
||||||
|
@ -24,26 +24,26 @@ struct hash<xe::XeModel::Vertex> {
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeModel::XeModel(XeDevice &device, const XeModel::Builder &builder) : xeDevice{device} {
|
Model::Model(Device &device, const Model::Builder &builder) : xeDevice{device} {
|
||||||
createVertexBuffers(builder.vertices);
|
createVertexBuffers(builder.vertices);
|
||||||
createIndexBuffers(builder.indices);
|
createIndexBuffers(builder.indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
XeModel::~XeModel() {}
|
Model::~Model() {}
|
||||||
|
|
||||||
std::unique_ptr<XeModel> XeModel::createModelFromFile(XeDevice &device, const std::string &filepath) {
|
std::unique_ptr<Model> Model::createModelFromFile(Device &device, const std::string &filepath) {
|
||||||
Builder builder{};
|
Builder builder{};
|
||||||
builder.loadModel(filepath);
|
builder.loadModel(filepath);
|
||||||
return std::make_unique<XeModel>(device, builder);
|
return std::make_unique<Model>(device, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeModel::createVertexBuffers(const std::vector<Vertex> &vertices) {
|
void Model::createVertexBuffers(const std::vector<Vertex> &vertices) {
|
||||||
vertexCount = static_cast<uint32_t>(vertices.size());
|
vertexCount = static_cast<uint32_t>(vertices.size());
|
||||||
assert(vertexCount >= 3 && "Vertex count must be atleast 3");
|
assert(vertexCount >= 3 && "Vertex count must be atleast 3");
|
||||||
VkDeviceSize bufferSize = sizeof(vertices[0]) * vertexCount;
|
VkDeviceSize bufferSize = sizeof(vertices[0]) * vertexCount;
|
||||||
uint32_t vertexSize = sizeof(vertices[0]);
|
uint32_t vertexSize = sizeof(vertices[0]);
|
||||||
|
|
||||||
XeBuffer stagingBuffer {
|
Buffer stagingBuffer {
|
||||||
xeDevice,
|
xeDevice,
|
||||||
vertexSize,
|
vertexSize,
|
||||||
vertexCount,
|
vertexCount,
|
||||||
|
@ -54,7 +54,7 @@ void XeModel::createVertexBuffers(const std::vector<Vertex> &vertices) {
|
||||||
stagingBuffer.map();
|
stagingBuffer.map();
|
||||||
stagingBuffer.writeToBuffer((void *)vertices.data());
|
stagingBuffer.writeToBuffer((void *)vertices.data());
|
||||||
|
|
||||||
vertexBuffer = std::make_unique<XeBuffer>(
|
vertexBuffer = std::make_unique<Buffer>(
|
||||||
xeDevice,
|
xeDevice,
|
||||||
vertexSize,
|
vertexSize,
|
||||||
vertexCount,
|
vertexCount,
|
||||||
|
@ -65,7 +65,7 @@ void XeModel::createVertexBuffers(const std::vector<Vertex> &vertices) {
|
||||||
xeDevice.copyBuffer(stagingBuffer.getBuffer(), vertexBuffer->getBuffer(), bufferSize);
|
xeDevice.copyBuffer(stagingBuffer.getBuffer(), vertexBuffer->getBuffer(), bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeModel::createIndexBuffers(const std::vector<uint32_t> &indices) {
|
void Model::createIndexBuffers(const std::vector<uint32_t> &indices) {
|
||||||
indexCount = static_cast<uint32_t>(indices.size());
|
indexCount = static_cast<uint32_t>(indices.size());
|
||||||
hasIndexBuffer = indexCount > 0;
|
hasIndexBuffer = indexCount > 0;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ void XeModel::createIndexBuffers(const std::vector<uint32_t> &indices) {
|
||||||
VkDeviceSize bufferSize = sizeof(indices[0]) * indexCount;
|
VkDeviceSize bufferSize = sizeof(indices[0]) * indexCount;
|
||||||
uint32_t indexSize = sizeof(indices[0]);
|
uint32_t indexSize = sizeof(indices[0]);
|
||||||
|
|
||||||
XeBuffer stagingBuffer {
|
Buffer stagingBuffer {
|
||||||
xeDevice,
|
xeDevice,
|
||||||
indexSize,
|
indexSize,
|
||||||
indexCount,
|
indexCount,
|
||||||
|
@ -87,7 +87,7 @@ void XeModel::createIndexBuffers(const std::vector<uint32_t> &indices) {
|
||||||
stagingBuffer.map();
|
stagingBuffer.map();
|
||||||
stagingBuffer.writeToBuffer((void *)indices.data());
|
stagingBuffer.writeToBuffer((void *)indices.data());
|
||||||
|
|
||||||
indexBuffer = std::make_unique<XeBuffer>(
|
indexBuffer = std::make_unique<Buffer>(
|
||||||
xeDevice,
|
xeDevice,
|
||||||
indexSize,
|
indexSize,
|
||||||
indexCount,
|
indexCount,
|
||||||
|
@ -98,7 +98,7 @@ void XeModel::createIndexBuffers(const std::vector<uint32_t> &indices) {
|
||||||
xeDevice.copyBuffer(stagingBuffer.getBuffer(), indexBuffer->getBuffer(), bufferSize);
|
xeDevice.copyBuffer(stagingBuffer.getBuffer(), indexBuffer->getBuffer(), bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeModel::bind(VkCommandBuffer commandBuffer) {
|
void Model::bind(VkCommandBuffer commandBuffer) {
|
||||||
VkBuffer buffers[] = {vertexBuffer->getBuffer()};
|
VkBuffer buffers[] = {vertexBuffer->getBuffer()};
|
||||||
VkDeviceSize offsets[] = {0};
|
VkDeviceSize offsets[] = {0};
|
||||||
vkCmdBindVertexBuffers(commandBuffer, 0, 1, buffers, offsets);
|
vkCmdBindVertexBuffers(commandBuffer, 0, 1, buffers, offsets);
|
||||||
|
@ -108,7 +108,7 @@ void XeModel::bind(VkCommandBuffer commandBuffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeModel::draw(VkCommandBuffer commandBuffer) {
|
void Model::draw(VkCommandBuffer commandBuffer) {
|
||||||
if (hasIndexBuffer) {
|
if (hasIndexBuffer) {
|
||||||
vkCmdDrawIndexed(commandBuffer, indexCount, 1, 0, 0, 0);
|
vkCmdDrawIndexed(commandBuffer, indexCount, 1, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,7 +116,7 @@ void XeModel::draw(VkCommandBuffer commandBuffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkVertexInputBindingDescription> XeModel::Vertex::getBindingDescriptions() {
|
std::vector<VkVertexInputBindingDescription> Model::Vertex::getBindingDescriptions() {
|
||||||
std::vector<VkVertexInputBindingDescription> bindingDescriptions(1);
|
std::vector<VkVertexInputBindingDescription> bindingDescriptions(1);
|
||||||
bindingDescriptions[0].binding = 0;
|
bindingDescriptions[0].binding = 0;
|
||||||
bindingDescriptions[0].stride = sizeof(Vertex);
|
bindingDescriptions[0].stride = sizeof(Vertex);
|
||||||
|
@ -124,7 +124,7 @@ std::vector<VkVertexInputBindingDescription> XeModel::Vertex::getBindingDescript
|
||||||
return bindingDescriptions;
|
return bindingDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkVertexInputAttributeDescription> XeModel::Vertex::getAttributeDescriptions() {
|
std::vector<VkVertexInputAttributeDescription> Model::Vertex::getAttributeDescriptions() {
|
||||||
std::vector<VkVertexInputAttributeDescription> attributeDescptions{};
|
std::vector<VkVertexInputAttributeDescription> attributeDescptions{};
|
||||||
|
|
||||||
attributeDescptions.push_back({0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, position)});
|
attributeDescptions.push_back({0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(Vertex, position)});
|
||||||
|
@ -135,7 +135,7 @@ std::vector<VkVertexInputAttributeDescription> XeModel::Vertex::getAttributeDesc
|
||||||
return attributeDescptions;
|
return attributeDescptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeModel::Builder::loadModel(const std::string &filepath) {
|
void Model::Builder::loadModel(const std::string &filepath) {
|
||||||
tinyobj::attrib_t attrib;
|
tinyobj::attrib_t attrib;
|
||||||
std::vector<tinyobj::shape_t> shapes;
|
std::vector<tinyobj::shape_t> shapes;
|
||||||
std::vector<tinyobj::material_t> materials;
|
std::vector<tinyobj::material_t> materials;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeModel {
|
class Model {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
|
@ -35,13 +35,13 @@ class XeModel {
|
||||||
void loadModel(const std::string &filepath);
|
void loadModel(const std::string &filepath);
|
||||||
};
|
};
|
||||||
|
|
||||||
XeModel(XeDevice &device, const XeModel::Builder &builder);
|
Model(Device &device, const Model::Builder &builder);
|
||||||
~XeModel();
|
~Model();
|
||||||
|
|
||||||
XeModel(const XeModel &) = delete;
|
Model(const Model &) = delete;
|
||||||
XeModel operator=(const XeModel &) = delete;
|
Model operator=(const Model &) = delete;
|
||||||
|
|
||||||
static std::unique_ptr<XeModel> createModelFromFile(XeDevice &device, const std::string &filepath);
|
static std::unique_ptr<Model> createModelFromFile(Device &device, const std::string &filepath);
|
||||||
|
|
||||||
void bind(VkCommandBuffer commandBuffer);
|
void bind(VkCommandBuffer commandBuffer);
|
||||||
void draw(VkCommandBuffer commandBuffer);
|
void draw(VkCommandBuffer commandBuffer);
|
||||||
|
@ -50,13 +50,13 @@ class XeModel {
|
||||||
void createVertexBuffers(const std::vector<Vertex> &vertices);
|
void createVertexBuffers(const std::vector<Vertex> &vertices);
|
||||||
void createIndexBuffers(const std::vector<uint32_t> &indices);
|
void createIndexBuffers(const std::vector<uint32_t> &indices);
|
||||||
|
|
||||||
XeDevice &xeDevice;
|
Device &xeDevice;
|
||||||
|
|
||||||
std::unique_ptr<XeBuffer> vertexBuffer;
|
std::unique_ptr<Buffer> vertexBuffer;
|
||||||
uint32_t vertexCount;
|
uint32_t vertexCount;
|
||||||
|
|
||||||
bool hasIndexBuffer = false;
|
bool hasIndexBuffer = false;
|
||||||
std::unique_ptr<XeBuffer> indexBuffer;
|
std::unique_ptr<Buffer> indexBuffer;
|
||||||
uint32_t indexCount;
|
uint32_t indexCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XePipeline::XePipeline(
|
Pipeline::Pipeline(
|
||||||
XeDevice &device,
|
Device &device,
|
||||||
const std::string& vertFilepath,
|
const std::string& vertFilepath,
|
||||||
const std::string& fragFilepath,
|
const std::string& fragFilepath,
|
||||||
const PipelineConfigInfo& configInfo)
|
const PipelineConfigInfo& configInfo)
|
||||||
|
@ -21,13 +21,13 @@ namespace xe {
|
||||||
createGraphicsPipeline(vertFilepath, fragFilepath, configInfo);
|
createGraphicsPipeline(vertFilepath, fragFilepath, configInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
XePipeline::~XePipeline() {
|
Pipeline::~Pipeline() {
|
||||||
vkDestroyShaderModule(xeDevice.device(), vertShaderModule, nullptr);
|
vkDestroyShaderModule(xeDevice.device(), vertShaderModule, nullptr);
|
||||||
vkDestroyShaderModule(xeDevice.device(), fragShaderModule, nullptr);
|
vkDestroyShaderModule(xeDevice.device(), fragShaderModule, nullptr);
|
||||||
vkDestroyPipeline(xeDevice.device(), graphicsPipeline, nullptr);
|
vkDestroyPipeline(xeDevice.device(), graphicsPipeline, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> XePipeline::readFile(const std::string& filepath) {
|
std::vector<char> Pipeline::readFile(const std::string& filepath) {
|
||||||
|
|
||||||
std::ifstream file{filepath, std::ios::ate | std::ios::binary};
|
std::ifstream file{filepath, std::ios::ate | std::ios::binary};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace xe {
|
||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
void XePipeline::createGraphicsPipeline(
|
void Pipeline::createGraphicsPipeline(
|
||||||
const std::string& vertFilePath,
|
const std::string& vertFilePath,
|
||||||
const std::string& fragFilepath,
|
const std::string& fragFilepath,
|
||||||
const PipelineConfigInfo& configInfo) {
|
const PipelineConfigInfo& configInfo) {
|
||||||
|
@ -78,8 +78,8 @@ namespace xe {
|
||||||
shaderStages[1].pNext = nullptr;
|
shaderStages[1].pNext = nullptr;
|
||||||
shaderStages[1].pSpecializationInfo = nullptr;
|
shaderStages[1].pSpecializationInfo = nullptr;
|
||||||
|
|
||||||
auto bindingDescriptions = XeModel::Vertex::getBindingDescriptions();
|
auto bindingDescriptions = Model::Vertex::getBindingDescriptions();
|
||||||
auto attributeDescptions = XeModel::Vertex::getAttributeDescriptions();
|
auto attributeDescptions = Model::Vertex::getAttributeDescriptions();
|
||||||
VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
|
VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
|
||||||
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||||
vertexInputInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attributeDescptions.size());
|
vertexInputInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(attributeDescptions.size());
|
||||||
|
@ -112,7 +112,7 @@ namespace xe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XePipeline::createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule) {
|
void Pipeline::createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule) {
|
||||||
VkShaderModuleCreateInfo createInfo{};
|
VkShaderModuleCreateInfo createInfo{};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
createInfo.codeSize = code.size();
|
createInfo.codeSize = code.size();
|
||||||
|
@ -124,11 +124,11 @@ namespace xe {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XePipeline::bind(VkCommandBuffer commandBuffer) {
|
void Pipeline::bind(VkCommandBuffer commandBuffer) {
|
||||||
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
|
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XePipeline::defaultPipelineConfigInfo(PipelineConfigInfo& configInfo) {
|
void Pipeline::defaultPipelineConfigInfo(PipelineConfigInfo& configInfo) {
|
||||||
|
|
||||||
configInfo.inputAssemblyInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
configInfo.inputAssemblyInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||||
configInfo.inputAssemblyInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
configInfo.inputAssemblyInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
|
|
|
@ -27,17 +27,17 @@ struct PipelineConfigInfo {
|
||||||
uint32_t subpass = 0;
|
uint32_t subpass = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XePipeline {
|
class Pipeline {
|
||||||
public:
|
public:
|
||||||
XePipeline(
|
Pipeline(
|
||||||
XeDevice &device,
|
Device &device,
|
||||||
const std::string& vertFilepath,
|
const std::string& vertFilepath,
|
||||||
const std::string& fragFilepath,
|
const std::string& fragFilepath,
|
||||||
const PipelineConfigInfo& configInfo);
|
const PipelineConfigInfo& configInfo);
|
||||||
~XePipeline();
|
~Pipeline();
|
||||||
|
|
||||||
XePipeline(const XePipeline&) = delete;
|
Pipeline(const Pipeline&) = delete;
|
||||||
XePipeline operator=(const XePipeline&) = delete;
|
Pipeline operator=(const Pipeline&) = delete;
|
||||||
|
|
||||||
void bind(VkCommandBuffer commandBuffer);
|
void bind(VkCommandBuffer commandBuffer);
|
||||||
static void defaultPipelineConfigInfo(PipelineConfigInfo& configInfo);
|
static void defaultPipelineConfigInfo(PipelineConfigInfo& configInfo);
|
||||||
|
@ -52,7 +52,7 @@ class XePipeline {
|
||||||
|
|
||||||
void createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule);
|
void createShaderModule(const std::vector<char>& code, VkShaderModule* shaderModule);
|
||||||
|
|
||||||
XeDevice& xeDevice;
|
Device& xeDevice;
|
||||||
VkPipeline graphicsPipeline;
|
VkPipeline graphicsPipeline;
|
||||||
VkShaderModule vertShaderModule;
|
VkShaderModule vertShaderModule;
|
||||||
VkShaderModule fragShaderModule;
|
VkShaderModule fragShaderModule;
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeRenderSystem::XeRenderSystem(
|
RenderSystem::RenderSystem(
|
||||||
XeEngine &xeEngine,
|
Engine &xeEngine,
|
||||||
std::string vert,
|
std::string vert,
|
||||||
std::string frag,
|
std::string frag,
|
||||||
std::map<uint32_t, uint32_t> uniformBindings,
|
std::map<uint32_t, uint32_t> uniformBindings,
|
||||||
std::map<uint32_t, XeImage*> imageBindings,
|
std::map<uint32_t, Image*> imageBindings,
|
||||||
uint32_t pushCunstantDataSize,
|
uint32_t pushCunstantDataSize,
|
||||||
bool cullingEnabled
|
bool cullingEnabled
|
||||||
) : xeDevice{xeEngine.xeDevice},
|
) : xeDevice{xeEngine.xeDevice},
|
||||||
|
@ -39,12 +39,12 @@ XeRenderSystem::XeRenderSystem(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XeRenderSystem::~XeRenderSystem() {
|
RenderSystem::~RenderSystem() {
|
||||||
vkDestroyPipelineLayout(xeDevice.device(), pipelineLayout, nullptr);
|
vkDestroyPipelineLayout(xeDevice.device(), pipelineLayout, nullptr);
|
||||||
vkDestroySampler(xeDevice.device(), textureSampler, nullptr);
|
vkDestroySampler(xeDevice.device(), textureSampler, nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeRenderSystem::createTextureSampler() {
|
void RenderSystem::createTextureSampler() {
|
||||||
VkSamplerCreateInfo samplerInfo{};
|
VkSamplerCreateInfo samplerInfo{};
|
||||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||||
|
@ -67,8 +67,8 @@ void XeRenderSystem::createTextureSampler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::createDescriptorSetLayout() {
|
void RenderSystem::createDescriptorSetLayout() {
|
||||||
XeDescriptorSetLayout::Builder builder{xeDevice};
|
DescriptorSetLayout::Builder builder{xeDevice};
|
||||||
|
|
||||||
for ( const auto &[binding, size]: uniformBindings) {
|
for ( const auto &[binding, size]: uniformBindings) {
|
||||||
builder.addBinding(binding, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, nullptr);
|
builder.addBinding(binding, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, nullptr);
|
||||||
|
@ -81,14 +81,14 @@ void XeRenderSystem::createDescriptorSetLayout() {
|
||||||
xeDescriptorSetLayout = builder.build();
|
xeDescriptorSetLayout = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::createUniformBuffers() {
|
void RenderSystem::createUniformBuffers() {
|
||||||
for ( const auto &[binding, bufferSize]: uniformBindings) {
|
for ( const auto &[binding, bufferSize]: uniformBindings) {
|
||||||
uboBuffers[binding] = std::vector<std::unique_ptr<XeBuffer>>(XeSwapChain::MAX_FRAMES_IN_FLIGHT);
|
uboBuffers[binding] = std::vector<std::unique_ptr<Buffer>>(SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
for (int i = 0; i < uboBuffers[binding].size(); i++) {
|
for (int i = 0; i < uboBuffers[binding].size(); i++) {
|
||||||
uboBuffers[binding][i] = std::make_unique<XeBuffer>(
|
uboBuffers[binding][i] = std::make_unique<Buffer>(
|
||||||
xeDevice,
|
xeDevice,
|
||||||
bufferSize,
|
bufferSize,
|
||||||
XeSwapChain::MAX_FRAMES_IN_FLIGHT,
|
SwapChain::MAX_FRAMES_IN_FLIGHT,
|
||||||
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||||
uboBuffers[binding][i]->map();
|
uboBuffers[binding][i]->map();
|
||||||
|
@ -96,18 +96,18 @@ void XeRenderSystem::createUniformBuffers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::createDescriptorSets() {
|
void RenderSystem::createDescriptorSets() {
|
||||||
|
|
||||||
descriptorSets = std::vector<VkDescriptorSet>(XeSwapChain::MAX_FRAMES_IN_FLIGHT);
|
descriptorSets = std::vector<VkDescriptorSet>(SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
for (int i = 0; i < descriptorSets.size(); i++) {
|
for (int i = 0; i < descriptorSets.size(); i++) {
|
||||||
updateDescriptorSet(i, true);
|
updateDescriptorSet(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::updateDescriptorSet(int frameIndex, bool allocate) {
|
void RenderSystem::updateDescriptorSet(int frameIndex, bool allocate) {
|
||||||
|
|
||||||
XeDescriptorWriter writer{*xeDescriptorSetLayout, *xeDescriptorPool};
|
DescriptorWriter writer{*xeDescriptorSetLayout, *xeDescriptorPool};
|
||||||
|
|
||||||
std::vector<VkDescriptorBufferInfo> bufferInfos{};
|
std::vector<VkDescriptorBufferInfo> bufferInfos{};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void XeRenderSystem::updateDescriptorSet(int frameIndex, bool allocate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XeRenderSystem::createPipelineLayout() {
|
void RenderSystem::createPipelineLayout() {
|
||||||
|
|
||||||
VkPushConstantRange pushConstantRange;
|
VkPushConstantRange pushConstantRange;
|
||||||
pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
@ -164,17 +164,17 @@ void XeRenderSystem::createPipelineLayout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XeRenderSystem::createPipeline(VkRenderPass renderPass, std::string vert, std::string frag, bool cullingEnabled) {
|
void RenderSystem::createPipeline(VkRenderPass renderPass, std::string vert, std::string frag, bool cullingEnabled) {
|
||||||
assert(pipelineLayout != nullptr && "Cannot create pipeline before pipeline layout");
|
assert(pipelineLayout != nullptr && "Cannot create pipeline before pipeline layout");
|
||||||
|
|
||||||
PipelineConfigInfo pipelineConfig{};
|
PipelineConfigInfo pipelineConfig{};
|
||||||
XePipeline::defaultPipelineConfigInfo(pipelineConfig);
|
Pipeline::defaultPipelineConfigInfo(pipelineConfig);
|
||||||
if (cullingEnabled) {
|
if (cullingEnabled) {
|
||||||
pipelineConfig.rasterizationInfo.cullMode = VK_CULL_MODE_BACK_BIT;
|
pipelineConfig.rasterizationInfo.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||||
}
|
}
|
||||||
pipelineConfig.renderPass = renderPass;
|
pipelineConfig.renderPass = renderPass;
|
||||||
pipelineConfig.pipelineLayout = pipelineLayout;
|
pipelineConfig.pipelineLayout = pipelineLayout;
|
||||||
xePipeline = std::make_unique<XePipeline>(
|
xePipeline = std::make_unique<Pipeline>(
|
||||||
xeDevice,
|
xeDevice,
|
||||||
vert,
|
vert,
|
||||||
frag,
|
frag,
|
||||||
|
@ -182,7 +182,7 @@ void XeRenderSystem::createPipeline(VkRenderPass renderPass, std::string vert, s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::start() {
|
void RenderSystem::start() {
|
||||||
xeRenderer.beginSwapChainRenderPass(xeRenderer.getCurrentCommandBuffer());
|
xeRenderer.beginSwapChainRenderPass(xeRenderer.getCurrentCommandBuffer());
|
||||||
xePipeline->bind(xeRenderer.getCurrentCommandBuffer());
|
xePipeline->bind(xeRenderer.getCurrentCommandBuffer());
|
||||||
if(descriptorSets.size() > 0) {
|
if(descriptorSets.size() > 0) {
|
||||||
|
@ -200,7 +200,7 @@ void XeRenderSystem::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::loadPushConstant(void *pushConstantData) {
|
void RenderSystem::loadPushConstant(void *pushConstantData) {
|
||||||
vkCmdPushConstants(
|
vkCmdPushConstants(
|
||||||
xeRenderer.getCurrentCommandBuffer(),
|
xeRenderer.getCurrentCommandBuffer(),
|
||||||
pipelineLayout,
|
pipelineLayout,
|
||||||
|
@ -210,23 +210,23 @@ void XeRenderSystem::loadPushConstant(void *pushConstantData) {
|
||||||
pushConstantData);
|
pushConstantData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::loadUniformObject(uint32_t binding, void *uniformBufferData) {
|
void RenderSystem::loadUniformObject(uint32_t binding, void *uniformBufferData) {
|
||||||
uboBuffers[binding][xeRenderer.getFrameIndex()]->writeToBuffer(uniformBufferData);
|
uboBuffers[binding][xeRenderer.getFrameIndex()]->writeToBuffer(uniformBufferData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::loadTexture(uint32_t binding, XeImage *image) {
|
void RenderSystem::loadTexture(uint32_t binding, Image *image) {
|
||||||
imageBindings[binding] = image;
|
imageBindings[binding] = image;
|
||||||
updateDescriptorSet(xeRenderer.getFrameIndex(), false);
|
updateDescriptorSet(xeRenderer.getFrameIndex(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::render(XeGameObject &gameObject) {
|
void RenderSystem::render(GameObject &gameObject) {
|
||||||
|
|
||||||
gameObject.model->bind(xeRenderer.getCurrentCommandBuffer());
|
gameObject.model->bind(xeRenderer.getCurrentCommandBuffer());
|
||||||
gameObject.model->draw(xeRenderer.getCurrentCommandBuffer());
|
gameObject.model->draw(xeRenderer.getCurrentCommandBuffer());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderSystem::stop() {
|
void RenderSystem::stop() {
|
||||||
xeRenderer.endSwapChainRenderPass(xeRenderer.getCurrentCommandBuffer());
|
xeRenderer.endSwapChainRenderPass(xeRenderer.getCurrentCommandBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeRenderSystem {
|
class RenderSystem {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Builder {
|
class Builder {
|
||||||
public:
|
public:
|
||||||
Builder(XeEngine &xeEngine, std::string vert, std::string frag) : xeEngine{xeEngine}, vert{vert}, frag{frag} {}
|
Builder(Engine &xeEngine, std::string vert, std::string frag) : xeEngine{xeEngine}, vert{vert}, frag{frag} {}
|
||||||
|
|
||||||
Builder& addPushConstant(uint32_t size) {
|
Builder& addPushConstant(uint32_t size) {
|
||||||
pushCunstantDataSize = size;
|
pushCunstantDataSize = size;
|
||||||
|
@ -31,7 +31,7 @@ class XeRenderSystem {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder& addTextureBinding(uint32_t binding, XeImage* image) {
|
Builder& addTextureBinding(uint32_t binding, Image* image) {
|
||||||
imageBindings[binding] = image;
|
imageBindings[binding] = image;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,14 @@ class XeRenderSystem {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<XeRenderSystem> build() {
|
std::unique_ptr<RenderSystem> build() {
|
||||||
return std::make_unique<XeRenderSystem>(xeEngine, std::move(vert), std::move(frag), std::move(uniformBindings), std::move(imageBindings), std::move(pushCunstantDataSize), std::move(cullingEnabled));
|
return std::make_unique<RenderSystem>(xeEngine, std::move(vert), std::move(frag), std::move(uniformBindings), std::move(imageBindings), std::move(pushCunstantDataSize), std::move(cullingEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<uint32_t, uint32_t> uniformBindings{};
|
std::map<uint32_t, uint32_t> uniformBindings{};
|
||||||
std::map<uint32_t, XeImage*> imageBindings{};
|
std::map<uint32_t, Image*> imageBindings{};
|
||||||
uint32_t pushCunstantDataSize{0};
|
uint32_t pushCunstantDataSize{0};
|
||||||
|
|
||||||
std::string vert;
|
std::string vert;
|
||||||
|
@ -56,29 +56,29 @@ class XeRenderSystem {
|
||||||
|
|
||||||
bool cullingEnabled{false};
|
bool cullingEnabled{false};
|
||||||
|
|
||||||
XeEngine &xeEngine;
|
Engine &xeEngine;
|
||||||
};
|
};
|
||||||
|
|
||||||
XeRenderSystem(
|
RenderSystem(
|
||||||
XeEngine &xeEngine,
|
Engine &xeEngine,
|
||||||
std::string vert,
|
std::string vert,
|
||||||
std::string frag,
|
std::string frag,
|
||||||
std::map<uint32_t, uint32_t> uniformBindings,
|
std::map<uint32_t, uint32_t> uniformBindings,
|
||||||
std::map<uint32_t, XeImage*> imageBindings,
|
std::map<uint32_t, Image*> imageBindings,
|
||||||
uint32_t pushCunstantDataSize,
|
uint32_t pushCunstantDataSize,
|
||||||
bool cullingEnabled
|
bool cullingEnabled
|
||||||
);
|
);
|
||||||
|
|
||||||
~XeRenderSystem();
|
~RenderSystem();
|
||||||
|
|
||||||
XeRenderSystem(const XeRenderSystem &) = delete;
|
RenderSystem(const RenderSystem &) = delete;
|
||||||
XeRenderSystem operator=(const XeRenderSystem &) = delete;
|
RenderSystem operator=(const RenderSystem &) = delete;
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void loadPushConstant(void *pushConstantData);
|
void loadPushConstant(void *pushConstantData);
|
||||||
void loadUniformObject(uint32_t binding, void *uniformBufferData);
|
void loadUniformObject(uint32_t binding, void *uniformBufferData);
|
||||||
void loadTexture(uint32_t binding, XeImage *image);
|
void loadTexture(uint32_t binding, Image *image);
|
||||||
void render(XeGameObject &gameObject);
|
void render(GameObject &gameObject);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -95,12 +95,12 @@ class XeRenderSystem {
|
||||||
bool boundDescriptor{false};
|
bool boundDescriptor{false};
|
||||||
|
|
||||||
|
|
||||||
XeDevice& xeDevice;
|
Device& xeDevice;
|
||||||
XeRenderer& xeRenderer;
|
Renderer& xeRenderer;
|
||||||
|
|
||||||
std::map<uint32_t, std::vector<std::unique_ptr<XeBuffer>>> uboBuffers{};
|
std::map<uint32_t, std::vector<std::unique_ptr<Buffer>>> uboBuffers{};
|
||||||
std::map<uint32_t, uint32_t> uniformBindings;
|
std::map<uint32_t, uint32_t> uniformBindings;
|
||||||
std::map<uint32_t, XeImage*> imageBindings;
|
std::map<uint32_t, Image*> imageBindings;
|
||||||
std::vector<VkDescriptorSet> descriptorSets;
|
std::vector<VkDescriptorSet> descriptorSets;
|
||||||
|
|
||||||
uint32_t pushCunstantDataSize;
|
uint32_t pushCunstantDataSize;
|
||||||
|
@ -108,9 +108,9 @@ class XeRenderSystem {
|
||||||
VkSampler textureSampler;
|
VkSampler textureSampler;
|
||||||
|
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
std::unique_ptr<XePipeline> xePipeline;
|
std::unique_ptr<Pipeline> xePipeline;
|
||||||
std::unique_ptr<XeDescriptorPool> &xeDescriptorPool;
|
std::unique_ptr<DescriptorPool> &xeDescriptorPool;
|
||||||
std::unique_ptr<XeDescriptorSetLayout> xeDescriptorSetLayout;
|
std::unique_ptr<DescriptorSetLayout> xeDescriptorSetLayout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeRenderer::XeRenderer(XeWindow& window, XeDevice& device) : xeWindow{window}, xeDevice{device} {
|
Renderer::Renderer(Window& window, Device& device) : xeWindow{window}, xeDevice{device} {
|
||||||
recreateSwapChain();
|
recreateSwapChain();
|
||||||
createCommandBuffers();
|
createCommandBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
XeRenderer::~XeRenderer() { freeCommandBuffers(); }
|
Renderer::~Renderer() { freeCommandBuffers(); }
|
||||||
|
|
||||||
void XeRenderer::recreateSwapChain() {
|
void Renderer::recreateSwapChain() {
|
||||||
auto extent = xeWindow.getExtent();
|
auto extent = xeWindow.getExtent();
|
||||||
while (extent.width == 0 || extent.height == 0) {
|
while (extent.width == 0 || extent.height == 0) {
|
||||||
extent = xeWindow.getExtent();
|
extent = xeWindow.getExtent();
|
||||||
|
@ -31,10 +31,10 @@ void XeRenderer::recreateSwapChain() {
|
||||||
vkDeviceWaitIdle(xeDevice.device());
|
vkDeviceWaitIdle(xeDevice.device());
|
||||||
|
|
||||||
if(xeSwapChain == nullptr) {
|
if(xeSwapChain == nullptr) {
|
||||||
xeSwapChain = std::make_unique<XeSwapChain>(xeDevice, extent);
|
xeSwapChain = std::make_unique<SwapChain>(xeDevice, extent);
|
||||||
} else {
|
} else {
|
||||||
std::shared_ptr<XeSwapChain> oldSwapChain = std::move(xeSwapChain);
|
std::shared_ptr<SwapChain> oldSwapChain = std::move(xeSwapChain);
|
||||||
xeSwapChain = std::make_unique<XeSwapChain>(xeDevice, extent, oldSwapChain);
|
xeSwapChain = std::make_unique<SwapChain>(xeDevice, extent, oldSwapChain);
|
||||||
|
|
||||||
if(!oldSwapChain->compareSwapFormats(*xeSwapChain.get())) {
|
if(!oldSwapChain->compareSwapFormats(*xeSwapChain.get())) {
|
||||||
throw std::runtime_error("Swap chain image (or depth) format has changed");
|
throw std::runtime_error("Swap chain image (or depth) format has changed");
|
||||||
|
@ -45,9 +45,9 @@ void XeRenderer::recreateSwapChain() {
|
||||||
// we'll come back to this in just a moment
|
// we'll come back to this in just a moment
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderer::createCommandBuffers() {
|
void Renderer::createCommandBuffers() {
|
||||||
|
|
||||||
commandBuffers.resize(XeSwapChain::MAX_FRAMES_IN_FLIGHT);
|
commandBuffers.resize(SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||||
|
|
||||||
VkCommandBufferAllocateInfo allocInfo{};
|
VkCommandBufferAllocateInfo allocInfo{};
|
||||||
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||||
|
@ -61,7 +61,7 @@ void XeRenderer::createCommandBuffers() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderer::freeCommandBuffers() {
|
void Renderer::freeCommandBuffers() {
|
||||||
vkFreeCommandBuffers(
|
vkFreeCommandBuffers(
|
||||||
xeDevice.device(),
|
xeDevice.device(),
|
||||||
xeDevice.getCommandPool(),
|
xeDevice.getCommandPool(),
|
||||||
|
@ -70,7 +70,7 @@ void XeRenderer::freeCommandBuffers() {
|
||||||
commandBuffers.clear();
|
commandBuffers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
VkCommandBuffer XeRenderer::beginFrame() {
|
VkCommandBuffer Renderer::beginFrame() {
|
||||||
assert(!isFrameStarted && "Can't acll beingFrame while already in progress");
|
assert(!isFrameStarted && "Can't acll beingFrame while already in progress");
|
||||||
|
|
||||||
auto result = xeSwapChain->acquireNextImage(¤tImageIndex);
|
auto result = xeSwapChain->acquireNextImage(¤tImageIndex);
|
||||||
|
@ -97,7 +97,7 @@ VkCommandBuffer XeRenderer::beginFrame() {
|
||||||
return commandBuffer;
|
return commandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderer::endFrame() {
|
void Renderer::endFrame() {
|
||||||
assert(isFrameStarted && "Can't call endFrame while frame is not in progress");
|
assert(isFrameStarted && "Can't call endFrame while frame is not in progress");
|
||||||
auto commandBuffer = getCurrentCommandBuffer();
|
auto commandBuffer = getCurrentCommandBuffer();
|
||||||
if(vkEndCommandBuffer(commandBuffer) != VK_SUCCESS) {
|
if(vkEndCommandBuffer(commandBuffer) != VK_SUCCESS) {
|
||||||
|
@ -111,10 +111,10 @@ void XeRenderer::endFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
isFrameStarted = false;
|
isFrameStarted = false;
|
||||||
currentFrameIndex = (currentFrameIndex + 1) % XeSwapChain::MAX_FRAMES_IN_FLIGHT;
|
currentFrameIndex = (currentFrameIndex + 1) % SwapChain::MAX_FRAMES_IN_FLIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderer::beginSwapChainRenderPass(VkCommandBuffer commandBuffer){
|
void Renderer::beginSwapChainRenderPass(VkCommandBuffer commandBuffer){
|
||||||
assert(isFrameStarted && "Can't call beginSwapChainRenderPass while frame is not in progress");
|
assert(isFrameStarted && "Can't call beginSwapChainRenderPass while frame is not in progress");
|
||||||
assert(commandBuffer == getCurrentCommandBuffer() && "Can't begin render pass on command buffer from a different frame");
|
assert(commandBuffer == getCurrentCommandBuffer() && "Can't begin render pass on command buffer from a different frame");
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ void XeRenderer::beginSwapChainRenderPass(VkCommandBuffer commandBuffer){
|
||||||
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
|
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeRenderer::endSwapChainRenderPass(VkCommandBuffer commandBuffer){
|
void Renderer::endSwapChainRenderPass(VkCommandBuffer commandBuffer){
|
||||||
assert(isFrameStarted && "Can't call endSwapChainRenderPass while frame is not in progress");
|
assert(isFrameStarted && "Can't call endSwapChainRenderPass while frame is not in progress");
|
||||||
assert(commandBuffer == getCurrentCommandBuffer() && "Can't end render pass on command buffer from a different frame");
|
assert(commandBuffer == getCurrentCommandBuffer() && "Can't end render pass on command buffer from a different frame");
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
class XeRenderer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XeRenderer(XeWindow &window, XeDevice &device);
|
Renderer(Window &window, Device &device);
|
||||||
~XeRenderer();
|
~Renderer();
|
||||||
|
|
||||||
XeRenderer(const XeRenderer &) = delete;
|
Renderer(const Renderer &) = delete;
|
||||||
XeRenderer operator=(const XeRenderer &) = delete;
|
Renderer operator=(const Renderer &) = delete;
|
||||||
|
|
||||||
VkRenderPass getSwapChainRenderPass() const { return xeSwapChain->getRenderPass(); }
|
VkRenderPass getSwapChainRenderPass() const { return xeSwapChain->getRenderPass(); }
|
||||||
float getAspectRatio() const { return xeSwapChain->extentAspectRatio(); }
|
float getAspectRatio() const { return xeSwapChain->extentAspectRatio(); }
|
||||||
|
@ -43,9 +43,9 @@ class XeRenderer {
|
||||||
void freeCommandBuffers();
|
void freeCommandBuffers();
|
||||||
void recreateSwapChain();
|
void recreateSwapChain();
|
||||||
|
|
||||||
XeWindow& xeWindow;
|
Window& xeWindow;
|
||||||
XeDevice& xeDevice;
|
Device& xeDevice;
|
||||||
std::unique_ptr<XeSwapChain> xeSwapChain;
|
std::unique_ptr<SwapChain> xeSwapChain;
|
||||||
std::vector<VkCommandBuffer> commandBuffers;
|
std::vector<VkCommandBuffer> commandBuffers;
|
||||||
|
|
||||||
uint32_t currentImageIndex;
|
uint32_t currentImageIndex;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeSound::XeSound(const std::string& filename) {
|
Sound::Sound(const std::string& filename) {
|
||||||
|
|
||||||
buffer = alutCreateBufferFromFile(filename.c_str());
|
buffer = alutCreateBufferFromFile(filename.c_str());
|
||||||
|
|
||||||
|
@ -21,43 +21,43 @@ XeSound::XeSound(const std::string& filename) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XeSound::~XeSound() {
|
Sound::~Sound() {
|
||||||
alDeleteSources(1, &source);
|
alDeleteSources(1, &source);
|
||||||
alDeleteBuffers(1, &buffer);
|
alDeleteBuffers(1, &buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSound::play() {
|
void Sound::play() {
|
||||||
stop();
|
stop();
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::stop() {
|
void Sound::stop() {
|
||||||
alSourceStop(source);
|
alSourceStop(source);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::pause() {
|
void Sound::pause() {
|
||||||
alSourcePause(source);
|
alSourcePause(source);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::resume() {
|
void Sound::resume() {
|
||||||
alSourcePlay(source);
|
alSourcePlay(source);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool XeSound::isPlaying() {
|
bool Sound::isPlaying() {
|
||||||
ALint playing;
|
ALint playing;
|
||||||
alGetSourcei(source, AL_SOURCE_STATE, &playing);
|
alGetSourcei(source, AL_SOURCE_STATE, &playing);
|
||||||
return playing == AL_PLAYING;
|
return playing == AL_PLAYING;
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::setPosition(glm::vec3 position) {
|
void Sound::setPosition(glm::vec3 position) {
|
||||||
alSource3f(source, AL_POSITION, position.x, position.y, position.z);
|
alSource3f(source, AL_POSITION, position.x, position.y, position.z);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::setLooping(bool looping) {
|
void Sound::setLooping(bool looping) {
|
||||||
alSourcei(source, AL_LOOPING, looping ? 1 : 0);
|
alSourcei(source, AL_LOOPING, looping ? 1 : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
void XeSound::setVolume(float volume) {
|
void Sound::setVolume(float volume) {
|
||||||
alSourcef(source, AL_GAIN, volume);
|
alSourcef(source, AL_GAIN, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeSound {
|
class Sound {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XeSound(const std::string& filename);
|
Sound(const std::string& filename);
|
||||||
~XeSound();
|
~Sound();
|
||||||
|
|
||||||
void play();
|
void play();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
|
@ -11,21 +11,21 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
bool XeSwapChain::initialSwapChainCreated = false;
|
bool SwapChain::initialSwapChainCreated = false;
|
||||||
|
|
||||||
XeSwapChain::XeSwapChain(XeDevice &deviceRef, VkExtent2D extent)
|
SwapChain::SwapChain(Device &deviceRef, VkExtent2D extent)
|
||||||
: device{deviceRef}, windowExtent{extent} {
|
: device{deviceRef}, windowExtent{extent} {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
XeSwapChain::XeSwapChain(XeDevice &deviceRef, VkExtent2D extent, std::shared_ptr<XeSwapChain> previous)
|
SwapChain::SwapChain(Device &deviceRef, VkExtent2D extent, std::shared_ptr<SwapChain> previous)
|
||||||
: device{deviceRef}, windowExtent{extent}, oldSwapChain{previous} {
|
: device{deviceRef}, windowExtent{extent}, oldSwapChain{previous} {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
oldSwapChain = nullptr;
|
oldSwapChain = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::init() {
|
void SwapChain::init() {
|
||||||
createSwapChain();
|
createSwapChain();
|
||||||
createImageViews();
|
createImageViews();
|
||||||
createRenderPass();
|
createRenderPass();
|
||||||
|
@ -35,7 +35,7 @@ void XeSwapChain::init() {
|
||||||
initialSwapChainCreated = true;
|
initialSwapChainCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XeSwapChain::~XeSwapChain() {
|
SwapChain::~SwapChain() {
|
||||||
for (auto imageView : swapChainImageViews) {
|
for (auto imageView : swapChainImageViews) {
|
||||||
vkDestroyImageView(device.device(), imageView, nullptr);
|
vkDestroyImageView(device.device(), imageView, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ XeSwapChain::~XeSwapChain() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeSwapChain::acquireNextImage(uint32_t *imageIndex) {
|
VkResult SwapChain::acquireNextImage(uint32_t *imageIndex) {
|
||||||
vkWaitForFences(
|
vkWaitForFences(
|
||||||
device.device(),
|
device.device(),
|
||||||
1,
|
1,
|
||||||
|
@ -84,7 +84,7 @@ VkResult XeSwapChain::acquireNextImage(uint32_t *imageIndex) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult XeSwapChain::submitCommandBuffers(
|
VkResult SwapChain::submitCommandBuffers(
|
||||||
const VkCommandBuffer *buffers, uint32_t *imageIndex) {
|
const VkCommandBuffer *buffers, uint32_t *imageIndex) {
|
||||||
if (imagesInFlight[*imageIndex] != VK_NULL_HANDLE) {
|
if (imagesInFlight[*imageIndex] != VK_NULL_HANDLE) {
|
||||||
vkWaitForFences(device.device(), 1, &imagesInFlight[*imageIndex], VK_TRUE, UINT64_MAX);
|
vkWaitForFences(device.device(), 1, &imagesInFlight[*imageIndex], VK_TRUE, UINT64_MAX);
|
||||||
|
@ -132,7 +132,7 @@ VkResult XeSwapChain::submitCommandBuffers(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createSwapChain() {
|
void SwapChain::createSwapChain() {
|
||||||
SwapChainSupportDetails swapChainSupport = device.getSwapChainSupport();
|
SwapChainSupportDetails swapChainSupport = device.getSwapChainSupport();
|
||||||
|
|
||||||
VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(swapChainSupport.formats);
|
VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(swapChainSupport.formats);
|
||||||
|
@ -189,7 +189,7 @@ void XeSwapChain::createSwapChain() {
|
||||||
swapChainExtent = extent;
|
swapChainExtent = extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createImageViews() {
|
void SwapChain::createImageViews() {
|
||||||
swapChainImageViews.resize(swapChainImages.size());
|
swapChainImageViews.resize(swapChainImages.size());
|
||||||
for (size_t i = 0; i < swapChainImages.size(); i++) {
|
for (size_t i = 0; i < swapChainImages.size(); i++) {
|
||||||
VkImageViewCreateInfo viewInfo{};
|
VkImageViewCreateInfo viewInfo{};
|
||||||
|
@ -210,7 +210,7 @@ void XeSwapChain::createImageViews() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createRenderPass() {
|
void SwapChain::createRenderPass() {
|
||||||
VkAttachmentDescription depthAttachment{};
|
VkAttachmentDescription depthAttachment{};
|
||||||
depthAttachment.format = findDepthFormat();
|
depthAttachment.format = findDepthFormat();
|
||||||
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
@ -271,7 +271,7 @@ void XeSwapChain::createRenderPass() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createFramebuffers() {
|
void SwapChain::createFramebuffers() {
|
||||||
swapChainFramebuffers.resize(imageCount());
|
swapChainFramebuffers.resize(imageCount());
|
||||||
for (size_t i = 0; i < imageCount(); i++) {
|
for (size_t i = 0; i < imageCount(); i++) {
|
||||||
std::array<VkImageView, 2> attachments = {swapChainImageViews[i], depthImageViews[i]};
|
std::array<VkImageView, 2> attachments = {swapChainImageViews[i], depthImageViews[i]};
|
||||||
|
@ -296,7 +296,7 @@ void XeSwapChain::createFramebuffers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createDepthResources() {
|
void SwapChain::createDepthResources() {
|
||||||
VkFormat depthFormat = findDepthFormat();
|
VkFormat depthFormat = findDepthFormat();
|
||||||
swapChainDepthFormat = depthFormat;
|
swapChainDepthFormat = depthFormat;
|
||||||
VkExtent2D swapChainExtent = getSwapChainExtent();
|
VkExtent2D swapChainExtent = getSwapChainExtent();
|
||||||
|
@ -345,7 +345,7 @@ void XeSwapChain::createDepthResources() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeSwapChain::createSyncObjects() {
|
void SwapChain::createSyncObjects() {
|
||||||
imageAvailableSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
imageAvailableSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
||||||
renderFinishedSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
renderFinishedSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
|
||||||
inFlightFences.resize(MAX_FRAMES_IN_FLIGHT);
|
inFlightFences.resize(MAX_FRAMES_IN_FLIGHT);
|
||||||
|
@ -369,7 +369,7 @@ void XeSwapChain::createSyncObjects() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSurfaceFormatKHR XeSwapChain::chooseSwapSurfaceFormat(
|
VkSurfaceFormatKHR SwapChain::chooseSwapSurfaceFormat(
|
||||||
const std::vector<VkSurfaceFormatKHR> &availableFormats) {
|
const std::vector<VkSurfaceFormatKHR> &availableFormats) {
|
||||||
for (const auto &availableFormat : availableFormats) {
|
for (const auto &availableFormat : availableFormats) {
|
||||||
if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM &&
|
if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM &&
|
||||||
|
@ -381,7 +381,7 @@ VkSurfaceFormatKHR XeSwapChain::chooseSwapSurfaceFormat(
|
||||||
return availableFormats[0];
|
return availableFormats[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPresentModeKHR XeSwapChain::chooseSwapPresentMode(
|
VkPresentModeKHR SwapChain::chooseSwapPresentMode(
|
||||||
const std::vector<VkPresentModeKHR> &availablePresentModes) {
|
const std::vector<VkPresentModeKHR> &availablePresentModes) {
|
||||||
for (const auto &availablePresentMode : availablePresentModes) {
|
for (const auto &availablePresentMode : availablePresentModes) {
|
||||||
if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR) {
|
if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR) {
|
||||||
|
@ -404,7 +404,7 @@ VkPresentModeKHR XeSwapChain::chooseSwapPresentMode(
|
||||||
return VK_PRESENT_MODE_FIFO_KHR;
|
return VK_PRESENT_MODE_FIFO_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D XeSwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities) {
|
VkExtent2D SwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities) {
|
||||||
if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max()) {
|
if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max()) {
|
||||||
return capabilities.currentExtent;
|
return capabilities.currentExtent;
|
||||||
} else {
|
} else {
|
||||||
|
@ -420,7 +420,7 @@ VkExtent2D XeSwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat XeSwapChain::findDepthFormat() {
|
VkFormat SwapChain::findDepthFormat() {
|
||||||
return device.findSupportedFormat(
|
return device.findSupportedFormat(
|
||||||
{VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT},
|
{VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT},
|
||||||
VK_IMAGE_TILING_OPTIMAL,
|
VK_IMAGE_TILING_OPTIMAL,
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeSwapChain {
|
class SwapChain {
|
||||||
public:
|
public:
|
||||||
static constexpr int MAX_FRAMES_IN_FLIGHT = 2;
|
static constexpr int MAX_FRAMES_IN_FLIGHT = 2;
|
||||||
|
|
||||||
XeSwapChain(XeDevice &deviceRef, VkExtent2D windowExtent);
|
SwapChain(Device &deviceRef, VkExtent2D windowExtent);
|
||||||
XeSwapChain(XeDevice &deviceRef, VkExtent2D windowExtent, std::shared_ptr<XeSwapChain> previous);
|
SwapChain(Device &deviceRef, VkExtent2D windowExtent, std::shared_ptr<SwapChain> previous);
|
||||||
~XeSwapChain();
|
~SwapChain();
|
||||||
|
|
||||||
XeSwapChain(const XeSwapChain &) = delete;
|
SwapChain(const SwapChain &) = delete;
|
||||||
XeSwapChain operator=(const XeSwapChain &) = delete;
|
SwapChain operator=(const SwapChain &) = delete;
|
||||||
|
|
||||||
VkFramebuffer getFrameBuffer(int index) { return swapChainFramebuffers[index]; }
|
VkFramebuffer getFrameBuffer(int index) { return swapChainFramebuffers[index]; }
|
||||||
VkRenderPass getRenderPass() { return renderPass; }
|
VkRenderPass getRenderPass() { return renderPass; }
|
||||||
|
@ -39,7 +39,7 @@ class XeSwapChain {
|
||||||
VkResult acquireNextImage(uint32_t *imageIndex);
|
VkResult acquireNextImage(uint32_t *imageIndex);
|
||||||
VkResult submitCommandBuffers(const VkCommandBuffer *buffers, uint32_t *imageIndex);
|
VkResult submitCommandBuffers(const VkCommandBuffer *buffers, uint32_t *imageIndex);
|
||||||
|
|
||||||
bool compareSwapFormats(const XeSwapChain& swapChain) const {
|
bool compareSwapFormats(const SwapChain& swapChain) const {
|
||||||
return swapChain.swapChainDepthFormat == swapChainDepthFormat &&
|
return swapChain.swapChainDepthFormat == swapChainDepthFormat &&
|
||||||
swapChain.swapChainImageFormat == swapChainImageFormat;
|
swapChain.swapChainImageFormat == swapChainImageFormat;
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ class XeSwapChain {
|
||||||
std::vector<VkImage> swapChainImages;
|
std::vector<VkImage> swapChainImages;
|
||||||
std::vector<VkImageView> swapChainImageViews;
|
std::vector<VkImageView> swapChainImageViews;
|
||||||
|
|
||||||
XeDevice &device;
|
Device &device;
|
||||||
VkExtent2D windowExtent;
|
VkExtent2D windowExtent;
|
||||||
|
|
||||||
VkSwapchainKHR swapChain;
|
VkSwapchainKHR swapChain;
|
||||||
std::shared_ptr<XeSwapChain> oldSwapChain;
|
std::shared_ptr<SwapChain> oldSwapChain;
|
||||||
|
|
||||||
std::vector<VkSemaphore> imageAvailableSemaphores;
|
std::vector<VkSemaphore> imageAvailableSemaphores;
|
||||||
std::vector<VkSemaphore> renderFinishedSemaphores;
|
std::vector<VkSemaphore> renderFinishedSemaphores;
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
XeWindow::XeWindow(int w, int h, std::string name) : width{w}, height{h}, windowName{name} {
|
Window::Window(int w, int h, std::string name) : width{w}, height{h}, windowName{name} {
|
||||||
initWindow();
|
initWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
XeWindow::~XeWindow() {
|
Window::~Window() {
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeWindow::initWindow() {
|
void Window::initWindow() {
|
||||||
glfwInit();
|
glfwInit();
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||||
|
@ -25,14 +25,14 @@ namespace xe {
|
||||||
glfwSetFramebufferSizeCallback(window, framebufferResizeCallback);
|
glfwSetFramebufferSizeCallback(window, framebufferResizeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeWindow::createWindowSurface(VkInstance instance, VkSurfaceKHR *surface){
|
void Window::createWindowSurface(VkInstance instance, VkSurfaceKHR *surface){
|
||||||
if (glfwCreateWindowSurface(instance, window, nullptr, surface) != VK_SUCCESS) {
|
if (glfwCreateWindowSurface(instance, window, nullptr, surface) != VK_SUCCESS) {
|
||||||
throw std::runtime_error("failed to create window surface");
|
throw std::runtime_error("failed to create window surface");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XeWindow::framebufferResizeCallback(GLFWwindow *window, int width, int height){
|
void Window::framebufferResizeCallback(GLFWwindow *window, int width, int height){
|
||||||
auto xeWindow = reinterpret_cast<XeWindow *>(glfwGetWindowUserPointer(window));
|
auto xeWindow = reinterpret_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||||
xeWindow->frameBufferResized = true;
|
xeWindow->frameBufferResized = true;
|
||||||
xeWindow->width = width;
|
xeWindow->width = width;
|
||||||
xeWindow->height = height;
|
xeWindow->height = height;
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
|
||||||
class XeWindow {
|
class Window {
|
||||||
public:
|
public:
|
||||||
XeWindow(int w, int h, std::string name);
|
Window(int w, int h, std::string name);
|
||||||
~XeWindow();
|
~Window();
|
||||||
|
|
||||||
XeWindow(const XeWindow &) = delete;
|
Window(const Window &) = delete;
|
||||||
XeWindow &operator=(const XeWindow &);
|
Window &operator=(const Window &);
|
||||||
|
|
||||||
bool shouldClose() { return glfwWindowShouldClose(window); }
|
bool shouldClose() { return glfwWindowShouldClose(window); }
|
||||||
VkExtent2D getExtent() { return { static_cast<uint32_t>(width), static_cast<uint32_t>(height)}; }
|
VkExtent2D getExtent() { return { static_cast<uint32_t>(width), static_cast<uint32_t>(height)}; }
|
||||||
|
|
|
@ -27,16 +27,16 @@ FirstApp::~FirstApp() {}
|
||||||
|
|
||||||
void FirstApp::run() {
|
void FirstApp::run() {
|
||||||
|
|
||||||
std::shared_ptr<xe::XeImage> image = xeEngine.loadImage("res/image/texture.png");
|
std::shared_ptr<xe::Image> image = xeEngine.loadImage("res/image/texture.png");
|
||||||
std::shared_ptr<xe::XeImage> image2 = xeEngine.loadImage("res/image/scaly.png");
|
std::shared_ptr<xe::Image> image2 = xeEngine.loadImage("res/image/ltt.");
|
||||||
|
|
||||||
SimpleRenderer renderer{xeEngine, image.get()};
|
SimpleRenderer renderer{xeEngine, image.get()};
|
||||||
|
|
||||||
xe::XeSound sound{"res/sound/when_the_world_ends.wav"};
|
xe::Sound sound{"res/sound/when_the_world_ends.wav"};
|
||||||
sound.setLooping(true);
|
sound.setLooping(true);
|
||||||
sound.play();
|
sound.play();
|
||||||
|
|
||||||
auto viewerObject = xe::XeGameObject::createGameObject();
|
auto viewerObject = xe::GameObject::createGameObject();
|
||||||
viewerObject.transform.translation = {-7.f, 3.f, -7.f};
|
viewerObject.transform.translation = {-7.f, 3.f, -7.f};
|
||||||
viewerObject.transform.rotation.y = glm::radians(45.f);
|
viewerObject.transform.rotation.y = glm::radians(45.f);
|
||||||
KeyboardMovementController cameraController{};
|
KeyboardMovementController cameraController{};
|
||||||
|
@ -60,15 +60,15 @@ void FirstApp::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirstApp::loadGameObjects() {
|
void FirstApp::loadGameObjects() {
|
||||||
std::shared_ptr<xe::XeModel> xeModel = xeEngine.loadModelFromFile("res/models/stanford-dragon.obj");
|
std::shared_ptr<xe::Model> xeModel = xeEngine.loadModelFromFile("res/models/stanford-dragon.obj");
|
||||||
|
|
||||||
auto dragon = xe::XeGameObject::createGameObject();
|
auto dragon = xe::GameObject::createGameObject();
|
||||||
dragon.model = xeModel;
|
dragon.model = xeModel;
|
||||||
dragon.transform.translation = {.0f, .0f, 2.5f};
|
dragon.transform.translation = {.0f, .0f, 2.5f};
|
||||||
dragon.transform.scale = {.5f, .5f, .5f};
|
dragon.transform.scale = {.5f, .5f, .5f};
|
||||||
gameObjects.push_back(std::move(dragon));
|
gameObjects.push_back(std::move(dragon));
|
||||||
|
|
||||||
auto dragon2 = xe::XeGameObject::createGameObject();
|
auto dragon2 = xe::GameObject::createGameObject();
|
||||||
dragon2.model = xeModel;
|
dragon2.model = xeModel;
|
||||||
dragon2.transform.translation = {5.0f, .0f, -1.5f};
|
dragon2.transform.translation = {5.0f, .0f, -1.5f};
|
||||||
dragon2.transform.rotation.y = glm::radians(90.f);
|
dragon2.transform.rotation.y = glm::radians(90.f);
|
||||||
|
|
|
@ -26,8 +26,8 @@ class FirstApp {
|
||||||
|
|
||||||
void loadGameObjects();
|
void loadGameObjects();
|
||||||
|
|
||||||
xe::XeEngine xeEngine;
|
xe::Engine xeEngine;
|
||||||
|
|
||||||
std::vector<xe::XeGameObject> gameObjects;
|
std::vector<xe::GameObject> gameObjects;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
void KeyboardMovementController::moveInPlaneXZ(GLFWwindow* window, float dt, xe::XeGameObject& gameObject) {
|
void KeyboardMovementController::moveInPlaneXZ(GLFWwindow* window, float dt, xe::GameObject& gameObject) {
|
||||||
glm::vec3 rotate{0};
|
glm::vec3 rotate{0};
|
||||||
if(glfwGetKey(window, keys.lookRight) == GLFW_PRESS) rotate.y += 1.f;
|
if(glfwGetKey(window, keys.lookRight) == GLFW_PRESS) rotate.y += 1.f;
|
||||||
if(glfwGetKey(window, keys.lookLeft) == GLFW_PRESS) rotate.y -= 1.f;
|
if(glfwGetKey(window, keys.lookLeft) == GLFW_PRESS) rotate.y -= 1.f;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace app {
|
||||||
int lookDown = GLFW_KEY_DOWN;
|
int lookDown = GLFW_KEY_DOWN;
|
||||||
};
|
};
|
||||||
|
|
||||||
void moveInPlaneXZ(GLFWwindow* window, float dt, xe::XeGameObject& gameObject);
|
void moveInPlaneXZ(GLFWwindow* window, float dt, xe::GameObject& gameObject);
|
||||||
|
|
||||||
KeyMappings keys{};
|
KeyMappings keys{};
|
||||||
float moveSpeed{3.f};
|
float moveSpeed{3.f};
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
SimpleRenderer::SimpleRenderer(xe::XeEngine &xeEngine, xe::XeImage *xeImage) {
|
SimpleRenderer::SimpleRenderer(xe::Engine &xeEngine, xe::Image *xeImage) {
|
||||||
xeRenderSystem = xe::XeRenderSystem::Builder(xeEngine, "res/shaders/simple_shader.vert.spv", "res/shaders/simple_shader.frag.spv")
|
xeRenderSystem = xe::RenderSystem::Builder(xeEngine, "res/shaders/simple_shader.vert.spv", "res/shaders/simple_shader.frag.spv")
|
||||||
.addPushConstant(sizeof(PushConstant))
|
.addPushConstant(sizeof(PushConstant))
|
||||||
.addUniformBinding(0, sizeof(UniformBuffer))
|
.addUniformBinding(0, sizeof(UniformBuffer))
|
||||||
.addTextureBinding(1, xeImage)
|
.addTextureBinding(1, xeImage)
|
||||||
|
@ -14,7 +14,7 @@ SimpleRenderer::SimpleRenderer(xe::XeEngine &xeEngine, xe::XeImage *xeImage) {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRenderer::render(std::vector<xe::XeGameObject> &gameObjects, xe::XeCamera &xeCamera, xe::XeImage *xeImage) {
|
void SimpleRenderer::render(std::vector<xe::GameObject> &gameObjects, xe::Camera &xeCamera, xe::Image *xeImage) {
|
||||||
|
|
||||||
xeRenderSystem->loadTexture(1, xeImage);
|
xeRenderSystem->loadTexture(1, xeImage);
|
||||||
|
|
||||||
|
|
|
@ -19,17 +19,17 @@ class SimpleRenderer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SimpleRenderer(xe::XeEngine &xeEngine, xe::XeImage *xeImage);
|
SimpleRenderer(xe::Engine &xeEngine, xe::Image *xeImage);
|
||||||
|
|
||||||
~SimpleRenderer() {};
|
~SimpleRenderer() {};
|
||||||
|
|
||||||
SimpleRenderer(const SimpleRenderer&) = delete;
|
SimpleRenderer(const SimpleRenderer&) = delete;
|
||||||
SimpleRenderer operator=(const SimpleRenderer&) = delete;
|
SimpleRenderer operator=(const SimpleRenderer&) = delete;
|
||||||
|
|
||||||
void render(std::vector<xe::XeGameObject> &gameObjects, xe::XeCamera &xeCamera, xe::XeImage *xeImage);
|
void render(std::vector<xe::GameObject> &gameObjects, xe::Camera &xeCamera, xe::Image *xeImage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<xe::XeRenderSystem> xeRenderSystem;
|
std::unique_ptr<xe::RenderSystem> xeRenderSystem;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue