Add Device and Window abstraction
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
#include "copium/sampler/DepthAttachment.h"
|
||||
|
||||
#include "copium/core/Device.h"
|
||||
#include "copium/sampler/Image.h"
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
DepthAttachment::DepthAttachment(Instance& instance, int width, int height)
|
||||
: Sampler{instance}
|
||||
DepthAttachment::DepthAttachment(Vulkan& vulkan, int width, int height)
|
||||
: Sampler{vulkan}
|
||||
{
|
||||
InitializeDepthAttachment(width, height);
|
||||
}
|
||||
|
||||
DepthAttachment::~DepthAttachment()
|
||||
{
|
||||
vkDestroyImage(instance.GetDevice(), image, nullptr);
|
||||
vkFreeMemory(instance.GetDevice(), imageMemory, nullptr);
|
||||
vkDestroyImageView(instance.GetDevice(), imageView, nullptr);
|
||||
vkDestroyImage(vulkan.GetDevice(), image, nullptr);
|
||||
vkFreeMemory(vulkan.GetDevice(), imageMemory, nullptr);
|
||||
vkDestroyImageView(vulkan.GetDevice(), imageView, nullptr);
|
||||
}
|
||||
|
||||
VkDescriptorImageInfo DepthAttachment::GetDescriptorImageInfo(int index) const
|
||||
@@ -33,8 +34,8 @@ namespace Copium
|
||||
|
||||
void DepthAttachment::InitializeDepthAttachment(int width, int height)
|
||||
{
|
||||
VkFormat depthFormat = Image::SelectDepthFormat(instance);
|
||||
Image::InitializeImage(instance, width, height, depthFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &image, &imageMemory);
|
||||
imageView = Image::InitializeImageView(instance, image, depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
VkFormat depthFormat = Image::SelectDepthFormat(vulkan);
|
||||
Image::InitializeImage(vulkan, width, height, depthFormat, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &image, &imageMemory);
|
||||
imageView = Image::InitializeImageView(vulkan, image, depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user