summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D12/DX12Texture.cpp
diff options
context:
space:
mode:
authorMai <mai.iam2048@gmail.com>2023-12-17 14:40:39 -0500
committerGitHub <noreply@github.com>2023-12-17 14:40:39 -0500
commitf589c04aa7684e72f9866d1d85e9cb32b3d281ca (patch)
treed5cf7a22f818ad48ee5c6f4e333772058b9660ab /Source/Core/VideoBackends/D3D12/DX12Texture.cpp
parente6c85bf8f09c54297bc71fd37432d7daa7f22bcc (diff)
parent12dd15c8ddb587e2f76351b59e0097940061485b (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/D3D12/DX12Texture.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D12/DX12Texture.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp
index 400867d458..4a1faf6f97 100644
--- a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp
+++ b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp
@@ -140,7 +140,8 @@ std::unique_ptr<DXTexture> DXTexture::CreateAdopted(ID3D12Resource* resource)
}
TextureConfig config(static_cast<u32>(desc.Width), desc.Height, desc.MipLevels,
- desc.DepthOrArraySize, desc.SampleDesc.Count, format, 0);
+ desc.DepthOrArraySize, desc.SampleDesc.Count, format, 0,
+ AbstractTextureType::Texture_2DArray);
if (desc.Flags &
(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL))
{
@@ -165,14 +166,34 @@ bool DXTexture::CreateSRVDescriptor()
return false;
}
- D3D12_SHADER_RESOURCE_VIEW_DESC desc = {
- D3DCommon::GetSRVFormatForAbstractFormat(m_config.format),
- m_config.IsCubeMap() ? D3D12_SRV_DIMENSION_TEXTURECUBE :
- m_config.IsMultisampled() ? D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY :
- D3D12_SRV_DIMENSION_TEXTURE2DARRAY,
- D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING};
+ D3D12_SRV_DIMENSION dimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
+ if (m_config.type == AbstractTextureType::Texture_2DArray)
+ {
+ if (m_config.IsMultisampled())
+ dimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY;
+ else
+ dimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
+ }
+ else if (m_config.type == AbstractTextureType::Texture_2D)
+ {
+ if (m_config.IsMultisampled())
+ dimension = D3D12_SRV_DIMENSION_TEXTURE2DMS;
+ else
+ dimension = D3D12_SRV_DIMENSION_TEXTURE2D;
+ }
+ else if (m_config.type == AbstractTextureType::Texture_CubeMap)
+ {
+ dimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
+ }
+ else
+ {
+ PanicAlertFmt("Failed to allocate SRV - unhandled type");
+ return false;
+ }
+ D3D12_SHADER_RESOURCE_VIEW_DESC desc = {D3DCommon::GetSRVFormatForAbstractFormat(m_config.format),
+ dimension, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING};
- if (m_config.IsCubeMap())
+ if (m_config.type == AbstractTextureType::Texture_CubeMap)
{
desc.TextureCube.MostDetailedMip = 0;
desc.TextureCube.MipLevels = m_config.levels;