From 63d9affdcb8fc41c02144d493b51cfb317d72ba7 Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Fri, 11 Oct 2024 23:46:29 +0300 Subject: [PATCH] [d3d9] Add volume texture creation and locking validations --- src/d3d9/d3d9_common_texture.cpp | 8 +++++++- src/d3d9/d3d9_device.cpp | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 8bb5f99ab..4e012bab4 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -182,7 +182,13 @@ namespace dxvk { constexpr DWORD incompatibleUsages = D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL; if (pDesc->Pool != D3DPOOL_DEFAULT && (pDesc->Usage & incompatibleUsages)) return D3DERR_INVALIDCALL; - + + // Volume textures in D3DPOOL_SCRATCH must not have DYNAMIC usage + if (ResourceType == D3DRTYPE_VOLUMETEXTURE + && pDesc->Pool == D3DPOOL_SCRATCH + && (pDesc->Usage & D3DUSAGE_DYNAMIC)) + return D3DERR_INVALIDCALL; + // Use the maximum possible mip level count if the supplied // mip level count is either unspecified (0) or invalid const uint32_t maxMipLevelCount = pDesc->MultiSample <= D3DMULTISAMPLE_NONMASKABLE diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 8aed7128a..66cd17882 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -687,10 +687,10 @@ namespace dxvk { desc.IsAttachmentOnly = FALSE; // Docs: // Textures placed in the D3DPOOL_DEFAULT pool cannot be locked - // unless they are dynamic textures or they are private, FOURCC, driver formats. + // unless they are dynamic textures. Volume textures do not + // exempt private, FOURCC, driver formats from these checks. desc.IsLockable = Pool != D3DPOOL_DEFAULT - || (Usage & D3DUSAGE_DYNAMIC) - || IsVendorFormat(EnumerateFormat(Format)); + || (Usage & D3DUSAGE_DYNAMIC); if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_VOLUMETEXTURE, &desc))) return D3DERR_INVALIDCALL;