1
0
forked from 0ad/0ad

Creates image views for Vulkan textures only when needed.

This was SVN commit r27495.
This commit is contained in:
Vladislav Belov 2023-01-26 21:38:39 +00:00
parent 6648b1b53c
commit 840dbdd6d8
3 changed files with 15 additions and 6 deletions

View File

@ -251,6 +251,8 @@ VkDescriptorSet CDescriptorManager::GetSingleTypeDescritorSet(
{
if (!textures[index])
continue;
ENSURE(textures[index]->GetUsage() & ITexture::Usage::SAMPLED);
VkDescriptorImageInfo descriptorImageInfo{};
descriptorImageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
descriptorImageInfo.imageView = textures[index]->GetSamplerImageView();
@ -282,6 +284,7 @@ uint32_t CDescriptorManager::GetUniformSet() const
uint32_t CDescriptorManager::GetTextureDescriptor(CTexture* texture)
{
ENSURE(m_UseDescriptorIndexing);
ENSURE(texture->GetUsage() & ITexture::Usage::SAMPLED);
uint32_t binding = 0;
if (texture->GetType() == ITexture::Type::TEXTURE_2D &&

View File

@ -61,6 +61,7 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
if (colorAttachment)
{
CTexture* colorAttachmentTexture = colorAttachment->texture->As<CTexture>();
ENSURE(colorAttachmentTexture->GetUsage() & ITexture::Usage::COLOR_ATTACHMENT);
framebuffer->m_Width = colorAttachmentTexture->GetWidth();
framebuffer->m_Height = colorAttachmentTexture->GetHeight();
@ -75,6 +76,7 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
if (depthStencilAttachment)
{
CTexture* depthStencilAttachmentTexture = depthStencilAttachment->texture->As<CTexture>();
ENSURE(depthStencilAttachmentTexture->GetUsage() & ITexture::Usage::DEPTH_STENCIL_ATTACHMENT);
framebuffer->m_Width = depthStencilAttachmentTexture->GetWidth();
framebuffer->m_Height = depthStencilAttachmentTexture->GetHeight();

View File

@ -192,15 +192,19 @@ std::unique_ptr<CTexture> CTexture::Create(
imageViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
}
imageViewCreateInfo.subresourceRange.aspectMask = texture->m_AttachmentImageAspectMask;
ENSURE_VK_SUCCESS(vkCreateImageView(
device->GetVkDevice(), &imageViewCreateInfo, nullptr, &texture->m_AttachmentImageView));
imageViewCreateInfo.subresourceRange.aspectMask = texture->m_SamplerImageAspectMask;
ENSURE_VK_SUCCESS(vkCreateImageView(
device->GetVkDevice(), &imageViewCreateInfo, nullptr, &texture->m_SamplerImageView));
if ((usage & Usage::COLOR_ATTACHMENT) || (usage & Usage::DEPTH_STENCIL_ATTACHMENT))
{
imageViewCreateInfo.subresourceRange.aspectMask = texture->m_AttachmentImageAspectMask;
ENSURE_VK_SUCCESS(vkCreateImageView(
device->GetVkDevice(), &imageViewCreateInfo, nullptr, &texture->m_AttachmentImageView));
}
if (usage & Usage::SAMPLED)
{
imageViewCreateInfo.subresourceRange.aspectMask = texture->m_SamplerImageAspectMask;
ENSURE_VK_SUCCESS(vkCreateImageView(
device->GetVkDevice(), &imageViewCreateInfo, nullptr, &texture->m_SamplerImageView));
texture->m_Sampler = device->GetSamplerManager().GetOrCreateSampler(
defaultSamplerDesc);
texture->m_IsCompareEnabled = defaultSamplerDesc.compareEnabled;