Added VkImages

This commit is contained in:
antopilo
2024-12-07 13:28:01 -05:00
parent 39a0273595
commit cd2e603733
4 changed files with 43 additions and 38 deletions

View File

@@ -42,6 +42,12 @@ VulkanImage::VulkanImage(ImageFormat inFormat, Vector2 inSize) :
VK_CALL(vkCreateImageView(VkRenderer::Get().GetDevice(), &imageViewCreateInfo, nullptr, &ImageView));
}
VulkanImage::VulkanImage(void* inData, ImageFormat inFormat, Vector2 inSize)
{
size_t data_size = inSize.x * inSize.y * 4;
}
VkDescriptorSet& VulkanImage::GetImGuiDescriptorSet()
{
if (!ImGuiDescriptorSetGenerated)

View File

@@ -41,6 +41,7 @@ namespace Nuake
public:
VulkanImage(ImageFormat format, Vector2 size);
VulkanImage(void* data, ImageFormat format, Vector2 size);
~VulkanImage() = default;
Vector2 GetSize() const { return Vector2(Extent.x, Extent.y); }

View File

@@ -21,7 +21,7 @@
using namespace Nuake;
bool NKUseValidationLayer = false;
bool NKUseValidationLayer = true;
VkRenderer::~VkRenderer()
{
@@ -528,6 +528,7 @@ void VkRenderer::Draw()
return;
}
VK_CALL(vkResetFences(Device, 1, &GetCurrentFrame().RenderFence));
// Note: this will be the meat of the engine that should be here.
@@ -557,18 +558,19 @@ void VkRenderer::Draw()
//VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
// Execute a copy from the rendering image into the swapchain
//VulkanUtil::CopyImageToImage(cmd, DrawImage->GetImage(), SwapchainImages[swapchainImageIndex], DrawExtent, SwapchainExtent);
VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
{
}
//draw imgui into the swapchain image
DrawImgui(cmd, SwapchainImageViews[swapchainImageIndex]);
// set swapchain image layout to Attachment Optimal so we can draw it
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
// set swapchain image layout to Present so we can draw it
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
// Transition the swapchain image to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR for presentation
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
@@ -659,9 +661,6 @@ void VkRenderer::ImmediateSubmit(std::function<void(VkCommandBuffer cmd)>&& func
VK_CALL(vkWaitForFences(Device, 1, &ImguiFence, true, 9999999999));
}
void DescriptorLayoutBuilder::AddBinding(uint32_t binding, VkDescriptorType type)
{
VkDescriptorSetLayoutBinding newbind{};