|
|
@ -46,23 +46,27 @@ ComputeAndGraphics::ComputeAndGraphics() |
|
|
|
|
|
|
|
void ComputeAndGraphics::run() |
|
|
|
{ |
|
|
|
initWindow(); |
|
|
|
// initWindow();
|
|
|
|
|
|
|
|
initVulkan(); |
|
|
|
mainLoop(); |
|
|
|
cleanup(); |
|
|
|
// cleanup();
|
|
|
|
} |
|
|
|
|
|
|
|
void ComputeAndGraphics::initWindow() |
|
|
|
void ComputeAndGraphics::initWindow(VulkanWindow* window) |
|
|
|
{ |
|
|
|
glfwInit(); |
|
|
|
// glfwInit();
|
|
|
|
|
|
|
|
// glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
|
|
|
|
|
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); |
|
|
|
// _window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr);
|
|
|
|
|
|
|
|
_window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); |
|
|
|
// glfwSetWindowUserPointer(_window, this);
|
|
|
|
// glfwSetFramebufferSizeCallback(_window, framebufferResizeCallback);
|
|
|
|
|
|
|
|
// window =
|
|
|
|
// VulkanWindow window;
|
|
|
|
window->resize(800, 600); |
|
|
|
_windowQt = window; |
|
|
|
} |
|
|
|
|
|
|
|
//void ComputeAndGraphics::framebufferResizeCallback(GLFWwindow* window, int /*width*/, int /*height*/) {
|
|
|
@ -236,9 +240,11 @@ void ComputeAndGraphics::setupDebugMessenger() { |
|
|
|
|
|
|
|
void ComputeAndGraphics::createSurface() |
|
|
|
{ |
|
|
|
if (glfwCreateWindowSurface(_instance, _window, nullptr, &_surface) != VK_SUCCESS) { |
|
|
|
throw std::runtime_error("failed to create window surface!"); |
|
|
|
} |
|
|
|
// if (glfwCreateWindowSurface(_instance, _window, nullptr, &_surface) != VK_SUCCESS) {
|
|
|
|
// throw std::runtime_error("failed to create window surface!");
|
|
|
|
// }
|
|
|
|
|
|
|
|
_windowQt->createVulkanSurface(_instance, _surface); |
|
|
|
} |
|
|
|
|
|
|
|
void ComputeAndGraphics::pickPhysicalDevice() { |
|
|
@ -569,7 +575,9 @@ VkExtent2D ComputeAndGraphics::chooseSwapExtent(const VkSurfaceCapabilitiesKHR& |
|
|
|
return capabilities.currentExtent; |
|
|
|
} else { |
|
|
|
int width, height; |
|
|
|
glfwGetFramebufferSize(_window, &width, &height); |
|
|
|
// glfwGetFramebufferSize(_window, &width, &height);
|
|
|
|
width = 800; |
|
|
|
height = 600; |
|
|
|
|
|
|
|
VkExtent2D actualExtent = { |
|
|
|
static_cast<uint32_t>(width), |
|
|
@ -1874,11 +1882,16 @@ void ComputeAndGraphics::createSyncObjects() { |
|
|
|
|
|
|
|
void ComputeAndGraphics::mainLoop() |
|
|
|
{ |
|
|
|
while (!glfwWindowShouldClose(_window)) { |
|
|
|
glfwPollEvents(); |
|
|
|
// while (!glfwWindowShouldClose(_window)) {
|
|
|
|
// glfwPollEvents();
|
|
|
|
// drawFrame();
|
|
|
|
// }
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
drawFrame(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vkDeviceWaitIdle(_device); |
|
|
|
} |
|
|
|
|
|
|
@ -2151,12 +2164,12 @@ void ComputeAndGraphics::updateComputeUniformBuffer(uint32_t currentImage) |
|
|
|
} |
|
|
|
|
|
|
|
void ComputeAndGraphics::recreateSwapChain() { |
|
|
|
int width = 0, height = 0; |
|
|
|
glfwGetFramebufferSize(_window, &width, &height); |
|
|
|
while (width == 0 || height == 0) { |
|
|
|
glfwGetFramebufferSize(_window, &width, &height); |
|
|
|
glfwWaitEvents(); |
|
|
|
} |
|
|
|
int width = 800, height = 600; |
|
|
|
// glfwGetFramebufferSize(_window, &width, &height);
|
|
|
|
// while (width == 0 || height == 0) {
|
|
|
|
// glfwGetFramebufferSize(_window, &width, &height);
|
|
|
|
// glfwWaitEvents();
|
|
|
|
// }
|
|
|
|
|
|
|
|
vkDeviceWaitIdle(_device); |
|
|
|
|
|
|
@ -2248,9 +2261,9 @@ void ComputeAndGraphics::cleanBase() |
|
|
|
|
|
|
|
vkDestroyInstance(_instance, nullptr); |
|
|
|
|
|
|
|
glfwDestroyWindow(_window); |
|
|
|
// glfwDestroyWindow(_window);
|
|
|
|
|
|
|
|
glfwTerminate(); |
|
|
|
// glfwTerminate();
|
|
|
|
} |
|
|
|
|
|
|
|
void ComputeAndGraphics::cleanDescriptors() |
|
|
|