diff --git a/src/d3d9/d3d9_adapter.cpp b/src/d3d9/d3d9_adapter.cpp index aa14c90aa..d320dc6b2 100644 --- a/src/d3d9/d3d9_adapter.cpp +++ b/src/d3d9/d3d9_adapter.cpp @@ -162,6 +162,9 @@ namespace dxvk { if (mapping.FormatSrgb == VK_FORMAT_UNDEFINED && srgb) return D3DERR_NOTAVAILABLE; + if (RType == D3DRTYPE_CUBETEXTURE && mapping.Aspect != VK_IMAGE_ASPECT_COLOR_BIT) + return D3DERR_NOTAVAILABLE; + if (RType == D3DRTYPE_VERTEXBUFFER || RType == D3DRTYPE_INDEXBUFFER) return D3D_OK; diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 1f66a626a..ba8a3140a 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -118,6 +118,7 @@ namespace dxvk { HRESULT D3D9CommonTexture::NormalizeTextureProperties( D3D9DeviceEx* pDevice, + D3DRESOURCETYPE ResourceType, D3D9_COMMON_TEXTURE_DESC* pDesc) { auto* options = pDevice->GetOptions(); @@ -131,6 +132,11 @@ namespace dxvk { options->disableA8RT) return D3DERR_INVALIDCALL; + // Cube textures with depth formats are not supported on any native + // driver, and allowing them triggers a broken code path in Gothic 3. + if (ResourceType == D3DRTYPE_CUBETEXTURE && mapping.Aspect != VK_IMAGE_ASPECT_COLOR_BIT) + return D3DERR_INVALIDCALL; + // If the mapping is invalid then lets return invalid // Some edge cases: // NULL format does not map to anything, but should succeed diff --git a/src/d3d9/d3d9_common_texture.h b/src/d3d9/d3d9_common_texture.h index 37b5bc3ae..a83b14ac4 100644 --- a/src/d3d9/d3d9_common_texture.h +++ b/src/d3d9/d3d9_common_texture.h @@ -179,11 +179,14 @@ namespace dxvk { * Fills in undefined values and validates the texture * parameters. Any error returned by this method should * be forwarded to the application. + * \param [in] pDevice D3D9 device + * \param [in] ResourceType Resource type * \param [in,out] pDesc Texture description * \returns \c S_OK if the parameters are valid */ static HRESULT NormalizeTextureProperties( D3D9DeviceEx* pDevice, + D3DRESOURCETYPE ResourceType, D3D9_COMMON_TEXTURE_DESC* pDesc); /** diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index e99ad3837..87d39eeb7 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -594,7 +594,7 @@ namespace dxvk { || (Usage & D3DUSAGE_DYNAMIC) || IsVendorFormat(EnumerateFormat(Format)); - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_TEXTURE, &desc))) return D3DERR_INVALIDCALL; try { @@ -664,7 +664,7 @@ namespace dxvk { || (Usage & D3DUSAGE_DYNAMIC) || IsVendorFormat(EnumerateFormat(Format)); - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_VOLUMETEXTURE, &desc))) return D3DERR_INVALIDCALL; try { @@ -721,7 +721,7 @@ namespace dxvk { || (Usage & D3DUSAGE_DYNAMIC) || IsVendorFormat(EnumerateFormat(Format)); - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_CUBETEXTURE, &desc))) return D3DERR_INVALIDCALL; try { @@ -3798,7 +3798,7 @@ namespace dxvk { desc.IsAttachmentOnly = TRUE; desc.IsLockable = Lockable; - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_TEXTURE, &desc))) return D3DERR_INVALIDCALL; try { @@ -3846,7 +3846,7 @@ namespace dxvk { // Docs: Off-screen plain surfaces are always lockable, regardless of their pool types. desc.IsLockable = TRUE; - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_TEXTURE, &desc))) return D3DERR_INVALIDCALL; if (pSharedHandle != nullptr && Pool != D3DPOOL_DEFAULT) @@ -3901,7 +3901,7 @@ namespace dxvk { // Docs don't say anything, so just assume it's lockable. desc.IsLockable = TRUE; - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_TEXTURE, &desc))) return D3DERR_INVALIDCALL; try { @@ -7891,7 +7891,7 @@ namespace dxvk { // Docs: Also note that - unlike textures - swap chain back buffers, render targets [..] can be locked desc.IsLockable = TRUE; - if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc))) + if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, D3DRTYPE_TEXTURE, &desc))) return D3DERR_NOTAVAILABLE; m_autoDepthStencil = new D3D9Surface(this, &desc, nullptr, nullptr);