Compare commits
8 Commits
717a8f1869
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c1c004d241 | |||
| 4efaebb813 | |||
| af0fc3fb54 | |||
| 8b5f4b51c2 | |||
| 1201f3d749 | |||
| 7fb01674b7 | |||
| aae54d1073 | |||
| c909a10304 |
@@ -393,7 +393,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -438,7 +438,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -451,7 +451,7 @@ class HelloTriangleApplication {
|
|||||||
// Finish recording the command buffer
|
// Finish recording the command buffer
|
||||||
commandBuffer.end();
|
commandBuffer.end();
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -491,7 +491,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -504,7 +504,7 @@ class HelloTriangleApplication {
|
|||||||
// Finish recording the command buffer
|
// Finish recording the command buffer
|
||||||
commandBuffer.end();
|
commandBuffer.end();
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -501,7 +501,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -514,7 +514,7 @@ class HelloTriangleApplication {
|
|||||||
// Finish recording the command buffer
|
// Finish recording the command buffer
|
||||||
commandBuffer.end();
|
commandBuffer.end();
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -534,7 +534,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -547,7 +547,7 @@ class HelloTriangleApplication {
|
|||||||
// Finish recording the command buffer
|
// Finish recording the command buffer
|
||||||
commandBuffer.end();
|
commandBuffer.end();
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -534,7 +534,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -579,7 +579,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -592,7 +592,7 @@ class HelloTriangleApplication {
|
|||||||
// Finish recording the command buffer
|
// Finish recording the command buffer
|
||||||
commandBuffer.end();
|
commandBuffer.end();
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -604,7 +604,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -627,7 +627,7 @@ class HelloTriangleApplication {
|
|||||||
|
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -608,7 +608,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -676,7 +676,7 @@ class HelloTriangleApplication {
|
|||||||
|
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -639,7 +639,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -707,7 +707,7 @@ class HelloTriangleApplication {
|
|||||||
|
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -695,7 +695,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -763,7 +763,7 @@ class HelloTriangleApplication {
|
|||||||
|
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -738,7 +738,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -806,7 +806,7 @@ class HelloTriangleApplication {
|
|||||||
|
|
||||||
throw std::runtime_error("failed to find suitable memory type!");
|
throw std::runtime_error("failed to find suitable memory type!");
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -759,7 +759,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -809,7 +809,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -917,7 +917,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
||||||
endSingleTimeCommands(commandBuffer);
|
endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -791,7 +791,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -841,7 +841,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -949,7 +949,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
||||||
endSingleTimeCommands(commandBuffer);
|
endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.begin({});
|
commandBuffer.begin({});
|
||||||
|
|
||||||
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eUndefined,
|
vk::ImageLayout::eUndefined,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
@@ -870,7 +870,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.endRendering();
|
commandBuffer.endRendering();
|
||||||
|
|
||||||
// After rendering, transition the swapchain image to PRESENT_SRC
|
// After rendering, transition the swapchain image to PRESENT_SRC
|
||||||
transitionSwapChainImageLayout(
|
transitionRenderingImageLayout(
|
||||||
imageIndex,
|
imageIndex,
|
||||||
vk::ImageLayout::eColorAttachmentOptimal,
|
vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
vk::ImageLayout::ePresentSrcKHR,
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
@@ -978,7 +978,7 @@ class HelloTriangleApplication {
|
|||||||
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
commandBuffer.pipelineBarrier(sourceStage, destinationStage, {}, {}, nullptr, barrier);
|
||||||
endSingleTimeCommands(commandBuffer);
|
endSingleTimeCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
void transitionSwapChainImageLayout(
|
void transitionRenderingImageLayout(
|
||||||
uint32_t imageIndex,
|
uint32_t imageIndex,
|
||||||
vk::ImageLayout oldLayout,
|
vk::ImageLayout oldLayout,
|
||||||
vk::ImageLayout newLayout,
|
vk::ImageLayout newLayout,
|
||||||
|
|||||||
1224
27_depth_buffering.cpp
Normal file
1224
27_depth_buffering.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1267
28_model_loading.cpp
Normal file
1267
28_model_loading.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1383
29_mipmapping.cpp
Normal file
1383
29_mipmapping.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1428
30_multisampling.cpp
Normal file
1428
30_multisampling.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1185
31_compute_shader.cpp
Normal file
1185
31_compute_shader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -106,7 +106,7 @@ endfunction ()
|
|||||||
function (add_slang_shader_target TARGET)
|
function (add_slang_shader_target TARGET)
|
||||||
cmake_parse_arguments ("SHADER" "" "CHAPTER_NAME" "SOURCES" ${ARGN})
|
cmake_parse_arguments ("SHADER" "" "CHAPTER_NAME" "SOURCES" ${ARGN})
|
||||||
set (SHADERS_DIR ${CHAPTER_NAME}/shaders)
|
set (SHADERS_DIR ${CHAPTER_NAME}/shaders)
|
||||||
file(GLOB HAS_COMPUTE shaders/${CHAPTER_SHADER}.comp)
|
file(GLOB HAS_COMPUTE shaders/${CHAPTER_SHADER}.comp.slang)
|
||||||
set (ENTRY_POINTS -entry vertMain -entry fragMain)
|
set (ENTRY_POINTS -entry vertMain -entry fragMain)
|
||||||
if(HAS_COMPUTE)
|
if(HAS_COMPUTE)
|
||||||
list(APPEND ENTRY_POINTS -entry compMain)
|
list(APPEND ENTRY_POINTS -entry compMain)
|
||||||
@@ -155,7 +155,7 @@ function (add_chapter CHAPTER_NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set (CHAPTER_SHADER_SLANG_TARGET ${CHAPTER_NAME}_slang_shader)
|
set (CHAPTER_SHADER_SLANG_TARGET ${CHAPTER_NAME}_slang_shader)
|
||||||
file (GLOB SHADER_SLANG_SOURCES shaders/${CHAPTER_SHADER}.slang)
|
file (GLOB SHADER_SLANG_SOURCES shaders/${CHAPTER_SHADER}*.slang)
|
||||||
if(SHADER_SLANG_SOURCES)
|
if(SHADER_SLANG_SOURCES)
|
||||||
add_slang_shader_target( ${CHAPTER_SHADER_SLANG_TARGET} CHAPTER_NAME ${CHAPTER_NAME} SOURCES ${SHADER_SLANG_SOURCES})
|
add_slang_shader_target( ${CHAPTER_SHADER_SLANG_TARGET} CHAPTER_NAME ${CHAPTER_NAME} SOURCES ${SHADER_SLANG_SOURCES})
|
||||||
add_dependencies(${CHAPTER_NAME} ${CHAPTER_SHADER_SLANG_TARGET})
|
add_dependencies(${CHAPTER_NAME} ${CHAPTER_SHADER_SLANG_TARGET})
|
||||||
@@ -252,49 +252,49 @@ add_chapter (26_texture_mapping
|
|||||||
TEXTURES images/texture.jpg
|
TEXTURES images/texture.jpg
|
||||||
LIBS glm::glm)
|
LIBS glm::glm)
|
||||||
|
|
||||||
# add_chapter (27_depth_buffering
|
add_chapter (27_depth_buffering
|
||||||
# SHADER 27_shader_depth
|
SHADER 27_shader_depth
|
||||||
# TEXTURES images/texture.jpg
|
TEXTURES images/texture.jpg
|
||||||
# LIBS glm::glm)
|
LIBS glm::glm)
|
||||||
#
|
|
||||||
# add_chapter (28_model_loading
|
add_chapter (28_model_loading
|
||||||
# SHADER 27_shader_depth
|
SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
|
||||||
# add_chapter (29_mipmapping
|
add_chapter (29_mipmapping
|
||||||
# SHADER 27_shader_depth
|
SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
|
||||||
# add_chapter (30_multisampling
|
add_chapter (30_multisampling
|
||||||
# SHADER 27_shader_depth
|
SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
|
||||||
# add_chapter (31_compute_shader
|
add_chapter (31_compute_shader
|
||||||
# SHADER 31_shader_compute
|
SHADER 31_shader_compute
|
||||||
# LIBS glm::glm)
|
LIBS glm::glm)
|
||||||
#
|
|
||||||
# add_chapter (32_ecosystem_utilities
|
# add_chapter (32_ecosystem_utilities
|
||||||
# SHADER 27_shader_depth
|
# SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
# MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
# TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
#
|
||||||
# add_chapter (33_vulkan_profiles
|
# add_chapter (33_vulkan_profiles
|
||||||
# SHADER 27_shader_depth
|
# SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
# MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
# TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
#
|
||||||
# add_chapter (34_android
|
# add_chapter (34_android
|
||||||
# SHADER 27_shader_depth
|
# SHADER 27_shader_depth
|
||||||
# MODELS viking_room.obj
|
# MODELS models/viking_room.obj
|
||||||
# TEXTURES viking_room.png
|
# TEXTURES images/viking_room.png
|
||||||
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
# LIBS glm::glm tinyobjloader::tinyobjloader)
|
||||||
#
|
#
|
||||||
# add_chapter (35_gltf_ktx
|
# add_chapter (35_gltf_ktx
|
||||||
|
|||||||
BIN
assets/images/viking_room.png
Normal file
BIN
assets/images/viking_room.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 940 KiB |
16053
assets/models/viking_room.obj
Normal file
16053
assets/models/viking_room.obj
Normal file
File diff suppressed because it is too large
Load Diff
2
build
2
build
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
CMAKE_BUILD_DIR=cmake-build
|
CMAKE_BUILD_DIR=cmake-build
|
||||||
|
|
||||||
cmake -S . -B $CMAKE_BUILD_DIR -G Ninja
|
cmake -S . -B $CMAKE_BUILD_DIR -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
cmake --build $CMAKE_BUILD_DIR
|
cmake --build $CMAKE_BUILD_DIR
|
||||||
|
|||||||
34
shaders/27_shader_depth.slang
Normal file
34
shaders/27_shader_depth.slang
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
struct VSInput {
|
||||||
|
float3 inPosition;
|
||||||
|
float3 inColor;
|
||||||
|
float2 inTexCoord;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UniformBuffer {
|
||||||
|
float4x4 model;
|
||||||
|
float4x4 view;
|
||||||
|
float4x4 proj;
|
||||||
|
};
|
||||||
|
ConstantBuffer<UniformBuffer> ubo;
|
||||||
|
|
||||||
|
struct VSOutput {
|
||||||
|
float4 pos : SV_Position;
|
||||||
|
float3 color;
|
||||||
|
float2 fragTexCoord;
|
||||||
|
};
|
||||||
|
|
||||||
|
[shader("vertex")]
|
||||||
|
VSOutput vertMain(VSInput input) {
|
||||||
|
VSOutput output;
|
||||||
|
output.color = input.inColor;
|
||||||
|
output.pos = mul(ubo.proj, mul(ubo.view, mul(ubo.model, float4(input.inPosition, 1.0))));
|
||||||
|
output.fragTexCoord = input.inTexCoord;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sampler2D texture;
|
||||||
|
|
||||||
|
[shader("fragment")]
|
||||||
|
float4 fragMain(VSOutput vertIn) : SV_Target {
|
||||||
|
return texture.Sample(vertIn.fragTexCoord);
|
||||||
|
}
|
||||||
66
shaders/31_shader_compute.comp.slang
Normal file
66
shaders/31_shader_compute.comp.slang
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
struct VSInput {
|
||||||
|
float2 inPosition;
|
||||||
|
float3 inColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VSOutput {
|
||||||
|
float4 pos : SV_Position;
|
||||||
|
float pointSize : SV_PointSize;
|
||||||
|
float3 fragColor : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PSInput {
|
||||||
|
float4 pos : SV_Position;
|
||||||
|
float3 fragColor : COLOR0;
|
||||||
|
float2 pointCoord : SV_PointCoord;
|
||||||
|
};
|
||||||
|
|
||||||
|
[shader("vertex")]
|
||||||
|
VSOutput vertMain(VSInput input) {
|
||||||
|
VSOutput output;
|
||||||
|
output.pointSize = 14.0;
|
||||||
|
output.pos = float4(input.inPosition, 1.0, 1.0);
|
||||||
|
output.fragColor = input.inColor.rgb;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
[shader("fragment")]
|
||||||
|
float4 fragMain(PSInput input) : SV_Target {
|
||||||
|
float2 coord = input.pointCoord - float2(0.5);
|
||||||
|
return float4(input.fragColor, 0.5 - length(coord));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Particle {
|
||||||
|
float2 position;
|
||||||
|
float2 velocity;
|
||||||
|
float4 color;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UniformBuffer {
|
||||||
|
float deltaTime;
|
||||||
|
};
|
||||||
|
ConstantBuffer<UniformBuffer> ubo;
|
||||||
|
|
||||||
|
struct ParticleSSBO {
|
||||||
|
Particle particles;
|
||||||
|
};
|
||||||
|
StructuredBuffer<ParticleSSBO> particlesIn;
|
||||||
|
RWStructuredBuffer<ParticleSSBO> particlesOut;
|
||||||
|
|
||||||
|
[shader("compute")]
|
||||||
|
[numthreads(256, 1, 1)]
|
||||||
|
void compMain(uint3 threadId : SV_DispatchThreadID) {
|
||||||
|
uint index = threadId.x;
|
||||||
|
|
||||||
|
particlesOut[index].particles.position = particlesIn[index].particles.position +
|
||||||
|
particlesIn[index].particles.velocity.xy * ubo.deltaTime;
|
||||||
|
particlesOut[index].particles.velocity = particlesIn[index].particles.velocity;
|
||||||
|
|
||||||
|
// Flip movement at window border
|
||||||
|
if ((particlesOut[index].particles.position.x <= -1.0) || (particlesOut[index].particles.position.x >= 1.0)) {
|
||||||
|
particlesOut[index].particles.velocity.x = -particlesOut[index].particles.velocity.x;
|
||||||
|
}
|
||||||
|
if ((particlesOut[index].particles.position.y <= -1.0) || (particlesOut[index].particles.position.y >= 1.0)) {
|
||||||
|
particlesOut[index].particles.velocity.y = -particlesOut[index].particles.velocity.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user