Runs on MacOS, tho window size is terrible

This commit is contained in:
Dynamitos
2024-01-24 23:10:33 +01:00
parent cf4a8e9d03
commit 87417f483c
21 changed files with 119 additions and 43 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
.depthBiasConstantFactor = gfxInfo.rasterizationState.depthBiasConstantFactor,
.depthBiasClamp = gfxInfo.rasterizationState.depthBiasClamp,
.depthBiasSlopeFactor = gfxInfo.rasterizationState.depthBiasSlopeFactor,
.lineWidth = 0,
.lineWidth = gfxInfo.rasterizationState.lineWidth,
};
hash = CRC::Calculate(&rasterizationState, sizeof(rasterizationState), CRC::CRC_32(), hash);
+1 -1
View File
@@ -20,7 +20,7 @@ Semaphore::Semaphore(PGraphics graphics)
Semaphore::~Semaphore()
{
vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle);
}
Fence::Fence(PGraphics graphics)
+16 -4
View File
@@ -53,7 +53,8 @@ void glfwCloseCallback(GLFWwindow* handle)
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->close();
}
void glfwResizeCallback(GLFWwindow* handle, int width, int height)
void glfwFramebufferResizeCallback(GLFWwindow* handle, int width, int height)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->resize(width, height);
@@ -69,6 +70,8 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
GLFWwindow *handle = glfwCreateWindow(createInfo.width, createInfo.height, createInfo.title, nullptr, nullptr);
windowHandle = handle;
glfwSetWindowUserPointer(handle, this);
int w, h;
glfwGetWindowSize(handle, &w, &h);
glfwSetKeyCallback(handle, &glfwKeyCallback);
glfwSetCursorPosCallback(handle, &glfwMouseMoveCallback);
@@ -76,7 +79,8 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo)
glfwSetScrollCallback(handle, &glfwScrollCallback);
glfwSetDropCallback(handle, &glfwFileCallback);
glfwSetWindowCloseCallback(handle, &glfwCloseCallback);
glfwSetWindowSizeCallback(handle, &glfwResizeCallback);
glfwSetFramebufferSizeCallback(handle, &glfwFramebufferResizeCallback);
//glfwSetWindowSizeCallback(handle, &glfwResizeCallback);
glfwCreateWindowSurface(instance, handle, nullptr, &surface);
@@ -104,8 +108,10 @@ void Window::pollInput()
void Window::beginFrame()
{
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), VK_NULL_HANDLE, &currentImageIndex);
swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
imageAvailableFences[currentSemaphoreIndex]->wait(100000);
imageAvailableFences[currentSemaphoreIndex]->reset();
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), &currentImageIndex);
swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
}
@@ -334,6 +340,12 @@ void Window::createSwapChain()
.samples = 1,
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSFER_DST_BIT,
}, swapChainImages[i]);
if(imageAvailableFences[i] != nullptr)
{
imageAvailableFences[i]->wait(100000);
imageAvailableFences[i]->reset();
}
imageAvailableFences[i] = new Fence(graphics);
imageAvailableSemaphores[i] = new Semaphore(graphics);
renderingDoneSemaphores[i] = new Semaphore(graphics);
}
+1
View File
@@ -55,6 +55,7 @@ protected:
void *windowHandle;
StaticArray<VkImage, Gfx::numFramesBuffered> swapChainImages;
StaticArray<OTexture2D, Gfx::numFramesBuffered> swapChainTextures;
StaticArray<OFence, Gfx::numFramesBuffered> imageAvailableFences;
StaticArray<OSemaphore, Gfx::numFramesBuffered> imageAvailableSemaphores;
StaticArray<OSemaphore, Gfx::numFramesBuffered> renderingDoneSemaphores;
uint32 currentImageIndex = 0;