feat: reformatted code
This commit is contained in:
@@ -8,13 +8,16 @@
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cstring>
|
||||
|
||||
@@ -33,6 +36,7 @@ struct Vertex {
|
||||
};
|
||||
return bindingDescription;
|
||||
}
|
||||
|
||||
static std::array<VkVertexInputAttributeDescription, 2> getAttributeDescription() {
|
||||
std::array<VkVertexInputAttributeDescription, 2> attributeDescriptions{};
|
||||
attributeDescriptions[0].binding = 0;
|
||||
@@ -94,8 +98,10 @@ void HelloTriangleApplication::run() {
|
||||
|
||||
void HelloTriangleApplication::createSwapChain() {
|
||||
int width, height;
|
||||
uint32_t queueFamilyIndices[] = {myVkInstance->indices.graphicsFamily.value(), myVkInstance->indices.presentFamily.value()};
|
||||
SwapChainSupportDetails swapChainSupportDetails = querySwapChainSupport(myVkInstance->physicalDevice, myVkInstance->surface);
|
||||
uint32_t queueFamilyIndices[] = {myVkInstance->indices.graphicsFamily.value(),
|
||||
myVkInstance->indices.presentFamily.value()};
|
||||
SwapChainSupportDetails swapChainSupportDetails = querySwapChainSupport(myVkInstance->physicalDevice,
|
||||
myVkInstance->surface);
|
||||
|
||||
VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(swapChainSupportDetails.formats);
|
||||
VkPresentModeKHR presentMode = chooseSwapChainPresentMode(swapChainSupportDetails.presentModes);
|
||||
@@ -222,7 +228,8 @@ void HelloTriangleApplication::createDescriptorSetLayout() {
|
||||
.pBindings = &uboLayoutBinding,
|
||||
};
|
||||
|
||||
if (vkCreateDescriptorSetLayout(myVkInstance->device, &layoutCreateInfo, nullptr, &descriptorSetLayout) != VK_SUCCESS ) {
|
||||
if (vkCreateDescriptorSetLayout(myVkInstance->device, &layoutCreateInfo, nullptr, &descriptorSetLayout) !=
|
||||
VK_SUCCESS) {
|
||||
throw std::runtime_error("Failed to create descriptor set layout!");
|
||||
}
|
||||
}
|
||||
@@ -416,7 +423,8 @@ void HelloTriangleApplication::createGraphicsPipeline() {
|
||||
.pPushConstantRanges = nullptr,
|
||||
};
|
||||
|
||||
if (vkCreatePipelineLayout(myVkInstance->device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout) != VK_SUCCESS) {
|
||||
if (vkCreatePipelineLayout(myVkInstance->device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout) !=
|
||||
VK_SUCCESS) {
|
||||
throw std::runtime_error("failed to create pipeline layout");
|
||||
}
|
||||
|
||||
@@ -439,7 +447,8 @@ void HelloTriangleApplication::createGraphicsPipeline() {
|
||||
.basePipelineIndex = -1,
|
||||
};
|
||||
|
||||
if (vkCreateGraphicsPipelines(myVkInstance->device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS) {
|
||||
if (vkCreateGraphicsPipelines(myVkInstance->device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) !=
|
||||
VK_SUCCESS) {
|
||||
throw std::runtime_error("Failed to create graphics pipeline");
|
||||
}
|
||||
|
||||
@@ -462,13 +471,16 @@ void HelloTriangleApplication::createFrameBuffers() {
|
||||
.height = swapChainExtent.height,
|
||||
.layers = 1
|
||||
};
|
||||
if (vkCreateFramebuffer(myVkInstance->device, &framebufferCreateInfo, nullptr, &swapChainFrameBuffers[i]) != VK_SUCCESS) {
|
||||
if (vkCreateFramebuffer(myVkInstance->device, &framebufferCreateInfo, nullptr, &swapChainFrameBuffers[i]) !=
|
||||
VK_SUCCESS) {
|
||||
throw std::runtime_error("Failed to create frame buffer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HelloTriangleApplication::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) {
|
||||
void
|
||||
HelloTriangleApplication::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties,
|
||||
VkBuffer &buffer, VkDeviceMemory &bufferMemory) {
|
||||
VkBufferCreateInfo bufferCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.size = size,
|
||||
@@ -501,7 +513,8 @@ void HelloTriangleApplication::createVertexBuffer() {
|
||||
VkBuffer stagingBuffer;
|
||||
VkDeviceMemory stagingBufferMemory;
|
||||
createBuffer(bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory);
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer,
|
||||
stagingBufferMemory);
|
||||
|
||||
void *data;
|
||||
vkMapMemory(myVkInstance->device, stagingBufferMemory, 0, bufferSize, 0, &data);
|
||||
@@ -522,7 +535,8 @@ void HelloTriangleApplication::createIndexBuffer() {
|
||||
VkBuffer stagingBuffer;
|
||||
VkDeviceMemory stagingBufferMemory;
|
||||
createBuffer(bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer, stagingBufferMemory);
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, stagingBuffer,
|
||||
stagingBufferMemory);
|
||||
|
||||
void *data;
|
||||
vkMapMemory(myVkInstance->device, stagingBufferMemory, 0, bufferSize, 0, &data);
|
||||
@@ -587,7 +601,9 @@ void HelloTriangleApplication::createUniformBuffers() {
|
||||
uniformBuffersMemory.resize(swapChainImages.size());
|
||||
|
||||
for (size_t i = 0; i < swapChainImages.size(); ++i) {
|
||||
createBuffer(bufferSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, uniformBuffers[i], uniformBuffersMemory[i]);
|
||||
createBuffer(bufferSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, uniformBuffers[i],
|
||||
uniformBuffersMemory[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +647,8 @@ void HelloTriangleApplication::createCommandBuffers() {
|
||||
VkDeviceSize offset[] = {0};
|
||||
vkCmdBindVertexBuffers(commandBuffers[i], 0, 1, vertexBuffers, offset);
|
||||
vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i], 0, nullptr);
|
||||
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1,
|
||||
&descriptorSets[i], 0, nullptr);
|
||||
vkCmdDrawIndexed(commandBuffers[i], static_cast<uint32_t>(indices.size()), 1, 0, 0, 0);
|
||||
vkCmdEndRenderPass(commandBuffers[i]);
|
||||
if (vkEndCommandBuffer(commandBuffers[i]) != VK_SUCCESS) {
|
||||
@@ -654,8 +671,10 @@ void HelloTriangleApplication::createSyncObjects() {
|
||||
};
|
||||
|
||||
for (int i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
|
||||
if (vkCreateSemaphore(myVkInstance->device, &semaphoreCreateInfo, nullptr, &imageAvailableSemaphores[i]) != VK_SUCCESS ||
|
||||
vkCreateSemaphore(myVkInstance->device, &semaphoreCreateInfo, nullptr, &renderFinishedSemaphores[i]) != VK_SUCCESS ||
|
||||
if (vkCreateSemaphore(myVkInstance->device, &semaphoreCreateInfo, nullptr, &imageAvailableSemaphores[i]) !=
|
||||
VK_SUCCESS ||
|
||||
vkCreateSemaphore(myVkInstance->device, &semaphoreCreateInfo, nullptr, &renderFinishedSemaphores[i]) !=
|
||||
VK_SUCCESS ||
|
||||
vkCreateFence(myVkInstance->device, &fenceInfo, nullptr, &inFlightFences[i])) {
|
||||
throw std::runtime_error("failed to create semaphore");
|
||||
}
|
||||
@@ -707,7 +726,8 @@ void HelloTriangleApplication::cleanupSwapChain() {
|
||||
vkDestroyFramebuffer(myVkInstance->device, swapChainFrameBuffer, nullptr);
|
||||
}
|
||||
|
||||
vkFreeCommandBuffers(myVkInstance->device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data());
|
||||
vkFreeCommandBuffers(myVkInstance->device, commandPool, static_cast<uint32_t>(commandBuffers.size()),
|
||||
commandBuffers.data());
|
||||
|
||||
vkDestroyPipeline(myVkInstance->device, graphicsPipeline, nullptr);
|
||||
vkDestroyPipelineLayout(myVkInstance->device, pipelineLayout, nullptr);
|
||||
@@ -738,7 +758,8 @@ void HelloTriangleApplication::mainLoop() {
|
||||
void HelloTriangleApplication::drawFrame() {
|
||||
vkWaitForFences(myVkInstance->device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);
|
||||
uint32_t imageIndex;
|
||||
VkResult result = vkAcquireNextImageKHR(myVkInstance->device, swapChain, UINT64_MAX, imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
|
||||
VkResult result = vkAcquireNextImageKHR(myVkInstance->device, swapChain, UINT64_MAX,
|
||||
imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
|
||||
switch (result) {
|
||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||
recreateSwapChain();
|
||||
@@ -815,7 +836,8 @@ void HelloTriangleApplication::updateUniformBuffer(uint32_t imageIndex) {
|
||||
UniformBufferObject ubo{
|
||||
.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||
.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||
.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float) swapChainExtent.height, 0.1f, 10.f),
|
||||
.proj = glm::perspective(glm::radians(45.0f), swapChainExtent.width / (float) swapChainExtent.height, 0.1f,
|
||||
10.f),
|
||||
};
|
||||
ubo.proj[1][1] *= -1;
|
||||
void *data;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
const int MAX_FRAMES_IN_FLIGHT = 2;
|
||||
@@ -53,27 +54,44 @@ private:
|
||||
|
||||
// Vulkan initialisation
|
||||
void createSwapChain();
|
||||
|
||||
void createImageViews();
|
||||
|
||||
void createRenderPass();
|
||||
|
||||
void createDescriptorSetLayout();
|
||||
|
||||
void createDescriptorPool();
|
||||
|
||||
void createDescriptorSets();
|
||||
|
||||
void createGraphicsPipeline();
|
||||
|
||||
void createFrameBuffers();
|
||||
|
||||
void createCommandPool();
|
||||
|
||||
void createVertexBuffer();
|
||||
|
||||
void createIndexBuffer();
|
||||
|
||||
void createUniformBuffers();
|
||||
|
||||
void createCommandBuffers();
|
||||
|
||||
void createSyncObjects();
|
||||
|
||||
void initVulkan();
|
||||
|
||||
void recreateSwapChain();
|
||||
|
||||
void cleanupSwapChain();
|
||||
|
||||
// main loop
|
||||
void mainLoop();
|
||||
|
||||
void drawFrame();
|
||||
|
||||
void updateUniformBuffer(uint32_t imageIndex);
|
||||
|
||||
// clean up
|
||||
|
||||
@@ -40,7 +40,8 @@ bool isSuitableDevice(VkPhysicalDevice device, VkSurfaceKHR surface) {
|
||||
vkGetPhysicalDeviceFeatures(device, &features);
|
||||
indices = findQueueFamilies(device, surface);
|
||||
|
||||
bool extensionSupport = checkDeviceExtensionSupport(device, deviceExtensions, sizeof(deviceExtensions) / sizeof(void*));
|
||||
bool extensionSupport = checkDeviceExtensionSupport(device, deviceExtensions,
|
||||
sizeof(deviceExtensions) / sizeof(void *));
|
||||
bool swapChainAdequate = false;
|
||||
if (extensionSupport) {
|
||||
SwapChainSupportDetails swapChainSupport = querySwapChainSupport(device, surface);
|
||||
@@ -157,7 +158,8 @@ void MyVkInstance::createLogicalDevice() {
|
||||
this->indices = findQueueFamilies(physicalDevice, surface);
|
||||
|
||||
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
||||
std::set<uint32_t> uniqueQueueFamilies = {this->indices.graphicsFamily.value(), this->indices.presentFamily.value()};
|
||||
std::set<uint32_t> uniqueQueueFamilies = {this->indices.graphicsFamily.value(),
|
||||
this->indices.presentFamily.value()};
|
||||
float queuePriority = 1.0f;
|
||||
for (uint32_t queueFamily : uniqueQueueFamilies) {
|
||||
VkDeviceQueueCreateInfo queueCreateInfo{};
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
#ifndef VULKANTEST_MYVKINSTANCE_H
|
||||
#define VULKANTEST_MYVKINSTANCE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "queues.h"
|
||||
|
||||
@@ -14,6 +16,7 @@
|
||||
class MyVkInstance {
|
||||
public:
|
||||
MyVkInstance();
|
||||
|
||||
MyVkInstance(int width, int height, char *&title);
|
||||
|
||||
void init();
|
||||
@@ -21,6 +24,7 @@ public:
|
||||
void cleanup();
|
||||
|
||||
void getFrameBufferSize(int *pWidth, int *pHeight) const;
|
||||
|
||||
void registerResizeCallback(void *, void (*callback)(void *, int, int));
|
||||
|
||||
VkInstance instance{};
|
||||
@@ -42,6 +46,7 @@ private:
|
||||
int height{};
|
||||
std::string title;
|
||||
void *framebufferResizeCallbackThis;
|
||||
|
||||
void (*framebufferResizeCallback)(void *, int, int) = nullptr;
|
||||
|
||||
#ifdef WITH_VALIDATION_LAYERS
|
||||
@@ -53,9 +58,13 @@ private:
|
||||
|
||||
// init vulkan
|
||||
void initVulkan();
|
||||
|
||||
void createInstance();
|
||||
|
||||
void createSurface();
|
||||
|
||||
void pickPhysicalDevice();
|
||||
|
||||
void createLogicalDevice();
|
||||
|
||||
static void frameBufferResizeCallbackHandler(GLFWwindow *glfwWindow, int width, int height);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WITH_VALIDATION_LAYERS
|
||||
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
@@ -18,7 +19,9 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
||||
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDebugUtilsMessengerEXT *pDebugMessenger) {
|
||||
auto func = (PFN_vkCreateDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
||||
if (func != nullptr) {
|
||||
return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
|
||||
@@ -27,8 +30,10 @@ VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMes
|
||||
}
|
||||
}
|
||||
|
||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
|
||||
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger,
|
||||
const VkAllocationCallbacks *pAllocator) {
|
||||
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance,
|
||||
"vkDestroyDebugUtilsMessengerEXT");
|
||||
if (func != nullptr) {
|
||||
func(instance, debugMessenger, pAllocator);
|
||||
}
|
||||
@@ -59,8 +64,12 @@ bool checkValidationLayerSupport() {
|
||||
void setupDebugMessenger(VkInstance instance, VkDebugUtilsMessengerEXT *debugMessenger) {
|
||||
VkDebugUtilsMessengerCreateInfoEXT createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
||||
createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||
createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||
createInfo.messageSeverity =
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||
createInfo.messageType =
|
||||
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||
createInfo.pfnUserCallback = debugCallback;
|
||||
createInfo.pUserData = nullptr;
|
||||
|
||||
@@ -68,4 +77,5 @@ void setupDebugMessenger(VkInstance instance, VkDebugUtilsMessengerEXT* debugMes
|
||||
throw std::runtime_error("Failed to setup debug messenger");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef VULKANTEST_DEBUGLAYERS_H
|
||||
#define VULKANTEST_DEBUGLAYERS_H
|
||||
#ifdef WITH_VALIDATION_LAYERS
|
||||
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
@@ -17,9 +18,16 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
||||
VkDebugUtilsMessageTypeFlagsEXT messageType,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
|
||||
void *pUserData);
|
||||
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger);
|
||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator);
|
||||
|
||||
VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDebugUtilsMessengerEXT *pDebugMessenger);
|
||||
|
||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger,
|
||||
const VkAllocationCallbacks *pAllocator);
|
||||
|
||||
bool checkValidationLayerSupport();
|
||||
|
||||
void setupDebugMessenger(VkInstance instance, VkDebugUtilsMessengerEXT *debugMessenger);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -91,7 +91,9 @@ VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, uint3
|
||||
return capabilities.currentExtent;
|
||||
}
|
||||
VkExtent2D actualExtend = {width, height};
|
||||
actualExtend.width = std::max(capabilities.minImageExtent.width, std::min(capabilities.maxImageExtent.width, actualExtend.width));
|
||||
actualExtend.height = std::max(capabilities.minImageExtent.height, std::min(capabilities.maxImageExtent.height, actualExtend.height));
|
||||
actualExtend.width = std::max(capabilities.minImageExtent.width,
|
||||
std::min(capabilities.maxImageExtent.width, actualExtend.width));
|
||||
actualExtend.height = std::max(capabilities.minImageExtent.height,
|
||||
std::min(capabilities.maxImageExtent.height, actualExtend.height));
|
||||
return actualExtend;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#ifndef VULKANTEST_QUEUES_H
|
||||
#define VULKANTEST_QUEUES_H
|
||||
|
||||
#include <optional>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vector>
|
||||
@@ -24,10 +25,15 @@ struct SwapChainSupportDetails {
|
||||
};
|
||||
|
||||
bool checkDeviceExtensionSupport(VkPhysicalDevice device, const char **deviceExtensions, int size);
|
||||
|
||||
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||||
|
||||
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||||
|
||||
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR> &availableFormats);
|
||||
|
||||
VkPresentModeKHR chooseSwapChainPresentMode(const std::vector<VkPresentModeKHR> &availablePresentModes);
|
||||
|
||||
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities, uint32_t width, uint32_t height);
|
||||
|
||||
#endif //VULKANTEST_QUEUES_H
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#ifndef VULKANTEST_UTIL_H
|
||||
#define VULKANTEST_UTIL_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user