/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererVulkan/Resources/Implementation/RenderTargetViewVulkan.cpp
96 строк
4 KB
Sanakan8472
Copy / Readback fixes (#1963)
11 июн 2026, 18:07
Не верифицирован
11 июн 2026, 18:07
b50d6f1
Код
Авторство
О чём код?
#include <RendererVulkan/RendererVulkanPCH.h> #include <RendererVulkan/Device/DeviceVulkan.h> #include <RendererVulkan/Resources/RenderTargetViewVulkan.h> #include <RendererVulkan/Resources/TextureVulkan.h> #include <RendererVulkan/Utils/ConversionUtilsVulkan.h> ezGALRenderTargetViewVulkan::ezGALRenderTargetViewVulkan(ezGALTexture* pTexture, const ezGALRenderTargetViewCreationDescription& Description) : ezGALRenderTargetView(pTexture, Description) { } ezGALRenderTargetViewVulkan::~ezGALRenderTargetViewVulkan() = default; ezResult ezGALRenderTargetViewVulkan::InitPlatform(ezGALDevice* pDevice) { const ezGALTexture* pTexture = nullptr; if (!m_Description.m_hTexture.IsInvalidated()) pTexture = pDevice->GetTexture(m_Description.m_hTexture); if (pTexture == nullptr) { ezLog::Error("No valid texture handle given for render target view creation!"); return EZ_FAILURE; } const ezGALTextureCreationDescription& texDesc = pTexture->GetDescription(); ezGALResourceFormat::Enum viewFormat = texDesc.m_Format; if (m_Description.m_OverrideViewFormat != ezGALResourceFormat::Invalid) viewFormat = m_Description.m_OverrideViewFormat; ezGALDeviceVulkan* pVulkanDevice = static_cast<ezGALDeviceVulkan*>(pDevice); auto pTextureVulkan = static_cast<const ezGALTextureVulkan*>(pTexture->GetParentResource()); vk::Format vkViewFormat = pTextureVulkan->GetImageFormat(); const bool bIsDepthFormat = ezConversionUtilsVulkan::IsDepthFormat(vkViewFormat); if (vkViewFormat == vk::Format::eUndefined) { ezLog::Error("Couldn't get Vulkan format for view!"); return EZ_FAILURE; } vk::Image vkImage = pTextureVulkan->GetImage(); vk::ImageViewCreateInfo imageViewCreationInfo; if (bIsDepthFormat) { imageViewCreationInfo.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eDepth; if (texDesc.m_Format == ezGALResourceFormat::D24S8) { imageViewCreationInfo.subresourceRange.aspectMask |= vk::ImageAspectFlagBits::eStencil; } } else { imageViewCreationInfo.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eColor; } imageViewCreationInfo.image = vkImage; imageViewCreationInfo.format = vkViewFormat; const ezEnum<ezGALTextureType> type = m_Description.m_OverrideViewType != ezGALTextureType::Invalid ? m_Description.m_OverrideViewType : texDesc.m_Type; if (type == ezGALTextureType::Texture2DArray || type == ezGALTextureType::TextureCubeArray) { imageViewCreationInfo.viewType = vk::ImageViewType::e2DArray; imageViewCreationInfo.subresourceRange.baseMipLevel = m_Description.m_uiMipLevel; imageViewCreationInfo.subresourceRange.levelCount = 1; imageViewCreationInfo.subresourceRange.baseArrayLayer = m_Description.m_uiFirstSlice; imageViewCreationInfo.subresourceRange.layerCount = m_Description.m_uiSliceCount; } else { imageViewCreationInfo.viewType = vk::ImageViewType::e2D; imageViewCreationInfo.subresourceRange.baseMipLevel = m_Description.m_uiMipLevel; imageViewCreationInfo.subresourceRange.baseArrayLayer = m_Description.m_uiFirstSlice; imageViewCreationInfo.subresourceRange.levelCount = 1; imageViewCreationInfo.subresourceRange.layerCount = 1; } m_Range = imageViewCreationInfo.subresourceRange; m_bBfullRange = m_Range == pTextureVulkan->GetFullRange(); VK_SUCCEED_OR_RETURN_EZ_FAILURE(pVulkanDevice->GetVulkanDevice().createImageView(&imageViewCreationInfo, nullptr, &m_ImageView)); pVulkanDevice->SetDebugName("RTV", m_ImageView); return EZ_SUCCESS; } ezResult ezGALRenderTargetViewVulkan::DeInitPlatform(ezGALDevice* pDevice) { ezGALDeviceVulkan* pVulkanDevice = static_cast<ezGALDeviceVulkan*>(pDevice); pVulkanDevice->DeleteLater(m_ImageView); return EZ_SUCCESS; }