diff options
| author | Mai <mai.iam2048@gmail.com> | 2023-12-17 14:40:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-17 14:40:39 -0500 |
| commit | f589c04aa7684e72f9866d1d85e9cb32b3d281ca (patch) | |
| tree | d5cf7a22f818ad48ee5c6f4e333772058b9660ab /Source/Core/VideoBackends/Vulkan | |
| parent | e6c85bf8f09c54297bc71fd37432d7daa7f22bcc (diff) | |
| parent | 12dd15c8ddb587e2f76351b59e0097940061485b (diff) | |
Merge pull request #12372 from iwubcode/texture_usage_flag
VideoBackends / VideoCommon: add type enum to dictate how the texture is used; support texture 2d
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/StateTracker.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VKTexture.cpp | 27 |
3 files changed, 31 insertions, 9 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp index 4afd627614..332cd41cbf 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp @@ -60,15 +60,17 @@ void StateTracker::DestroyInstance() bool StateTracker::Initialize() { // Create a dummy texture which can be used in place of a real binding. - m_dummy_texture = - VKTexture::Create(TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0), ""); + m_dummy_texture = VKTexture::Create(TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0, + AbstractTextureType::Texture_2DArray), + ""); if (!m_dummy_texture) return false; m_dummy_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentInitCommandBuffer(), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); // Create a dummy compute texture which can be used in place of a real binding m_dummy_compute_texture = VKTexture::Create( - TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_ComputeImage), + TextureConfig(1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_ComputeImage, + AbstractTextureType::Texture_2DArray), ""); if (!m_dummy_compute_texture) return false; diff --git a/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp b/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp index 48102df64d..58e2e439e8 100644 --- a/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKSwapChain.cpp @@ -428,8 +428,9 @@ bool SwapChain::SetupSwapChainImages() images.data()); ASSERT(res == VK_SUCCESS); - const TextureConfig texture_config(TextureConfig( - m_width, m_height, 1, m_layers, 1, m_texture_format, AbstractTextureFlag_RenderTarget)); + const TextureConfig texture_config( + TextureConfig(m_width, m_height, 1, m_layers, 1, m_texture_format, + AbstractTextureFlag_RenderTarget, AbstractTextureType::Texture_2DArray)); const VkRenderPass load_render_pass = g_object_cache->GetRenderPass( m_surface_format.format, VK_FORMAT_UNDEFINED, 1, VK_ATTACHMENT_LOAD_OP_LOAD); const VkRenderPass clear_render_pass = g_object_cache->GetRenderPass( diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index e80ce4f2f7..6756305d1e 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -70,8 +70,9 @@ std::unique_ptr<VKTexture> VKTexture::Create(const TextureConfig& tex_config, st VkImageCreateInfo image_info = {VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, nullptr, - tex_config.IsCubeMap() ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : - static_cast<VkImageCreateFlags>(0), + tex_config.type == AbstractTextureType::Texture_CubeMap ? + VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : + static_cast<VkImageCreateFlags>(0), VK_IMAGE_TYPE_2D, GetVkFormatForHostTextureFormat(tex_config.format), {tex_config.width, tex_config.height, 1}, @@ -107,8 +108,26 @@ std::unique_ptr<VKTexture> VKTexture::Create(const TextureConfig& tex_config, st std::unique_ptr<VKTexture> texture = std::make_unique<VKTexture>( tex_config, alloc, image, name, VK_IMAGE_LAYOUT_UNDEFINED, ComputeImageLayout::Undefined); - if (!texture->CreateView(tex_config.IsCubeMap() ? VK_IMAGE_VIEW_TYPE_CUBE : - VK_IMAGE_VIEW_TYPE_2D_ARRAY)) + + VkImageViewType image_view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + if (tex_config.type == AbstractTextureType::Texture_CubeMap) + { + image_view_type = VK_IMAGE_VIEW_TYPE_CUBE; + } + else if (tex_config.type == AbstractTextureType::Texture_2D) + { + image_view_type = VK_IMAGE_VIEW_TYPE_2D; + } + else if (tex_config.type == AbstractTextureType::Texture_2DArray) + { + image_view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + } + else + { + PanicAlertFmt("Unhandled texture type."); + return nullptr; + } + if (!texture->CreateView(image_view_type)) return nullptr; return texture; |
