Skip to content

Study fix synch #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/first_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ void FirstApp::run() {
.count();

currentTime = newTime;

frameTime = glm::min(frameTime, MAX_FRAME_TIME);

cameraController.moveInPlaneXZ(lveWindow.getGLFWwindow(), frameTime,
Expand Down
30 changes: 20 additions & 10 deletions src/lve_swap_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,15 @@ VkResult LveSwapChain::acquireNextImage(uint32_t *imageIndex) {
imageAvailableSemaphores[currentFrame], // must be a not signaled
// semaphore
VK_NULL_HANDLE, imageIndex);
// std::cout << "frame: " << currentFrame << " SwapChain image: " <<
// *imageIndex
// << " Result: " << result << std::endl;

return result;
}

VkResult LveSwapChain::submitCommandBuffers(const VkCommandBuffer *buffers,
uint32_t *imageIndex) {
if (imagesInFlight[*imageIndex] != VK_NULL_HANDLE) {
vkWaitForFences(device.device(), 1, &imagesInFlight[*imageIndex], VK_TRUE,
UINT64_MAX);
}
imagesInFlight[*imageIndex] = inFlightFences[currentFrame];

VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;

Expand Down Expand Up @@ -143,6 +140,11 @@ void LveSwapChain::createSwapChain() {
imageCount > swapChainSupport.capabilities.maxImageCount) {
imageCount = swapChainSupport.capabilities.maxImageCount;
}
std::cout << "swapChainSupport maxImageCount: "
<< swapChainSupport.capabilities.maxImageCount << std::endl;
std::cout << "swapChainSupport minImageCount: "
<< swapChainSupport.capabilities.minImageCount << std::endl;
std::cout << "imageCount: " << imageCount << std::endl;

VkSwapchainCreateInfoKHR createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
Expand Down Expand Up @@ -188,10 +190,18 @@ void LveSwapChain::createSwapChain() {
// we'll first query the final number of images with vkGetSwapchainImagesKHR,
// then resize the container and finally call it again to retrieve the
// handles.
vkGetSwapchainImagesKHR(device.device(), swapChain, &imageCount, nullptr);
VkResult getSwapChainRes;
getSwapChainRes =
vkGetSwapchainImagesKHR(device.device(), swapChain, &imageCount, nullptr);

std::cout << "First getSwapChainImages Result: " << getSwapChainRes
<< ", imageCount: " << imageCount << std::endl;
swapChainImages.resize(imageCount);
vkGetSwapchainImagesKHR(device.device(), swapChain, &imageCount,
swapChainImages.data());

getSwapChainRes = vkGetSwapchainImagesKHR(
device.device(), swapChain, &imageCount, swapChainImages.data());
std::cout << "Second getSwapChainImages Result: " << getSwapChainRes
<< ", imageCount: " << imageCount << std::endl;

swapChainImageFormat = surfaceFormat.format;
swapChainExtent = extent;
Expand Down Expand Up @@ -336,7 +346,7 @@ void LveSwapChain::createSyncObjects() {
imageAvailableSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
renderFinishedSemaphores.resize(MAX_FRAMES_IN_FLIGHT);
inFlightFences.resize(MAX_FRAMES_IN_FLIGHT);
imagesInFlight.resize(imageCount(), VK_NULL_HANDLE);
std::cout << "image count : " << imageCount() << std::endl;

VkSemaphoreCreateInfo semaphoreInfo = {};
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
Expand Down
1 change: 0 additions & 1 deletion src/lve_swap_chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class LveSwapChain {
std::vector<VkSemaphore> imageAvailableSemaphores;
std::vector<VkSemaphore> renderFinishedSemaphores;
std::vector<VkFence> inFlightFences;
std::vector<VkFence> imagesInFlight;
size_t currentFrame = 0;
};

Expand Down