[D3D12] Fix 4D5307DF fur textures

- Fixes issue https://github.com/xenia-canary/game-compatibility/issues/6
- Implements a copy texture logic
This commit is contained in:
Raffaele
2025-12-19 23:47:32 +01:00
committed by Herman S.
parent bc54720559
commit 26824edcfa
2 changed files with 191 additions and 38 deletions

View File

@@ -551,6 +551,7 @@ class D3D12TextureCache final : public TextureCache {
struct {
uint32_t is_signed : 1;
uint32_t host_swizzle : 12;
uint32_t dimension : 2;
};
SRVDescriptorKey() : key(0) { static_assert_size(*this, sizeof(key)); }
@@ -568,6 +569,8 @@ class D3D12TextureCache final : public TextureCache {
}
};
ID3D12Resource* GetOrCreate3DAs2DResource(D3D12_RESOURCE_STATES end_state);
explicit D3D12Texture(D3D12TextureCache& texture_cache,
const TextureKey& key, ID3D12Resource* resource,
D3D12_RESOURCE_STATES resource_state);
@@ -595,6 +598,10 @@ class D3D12TextureCache final : public TextureCache {
Microsoft::WRL::ComPtr<ID3D12Resource> resource_;
D3D12_RESOURCE_STATES resource_state_;
Microsoft::WRL::ComPtr<ID3D12Resource> resource_3d_as_2d_;
D3D12_RESOURCE_STATES resource_3d_as_2d_state_ =
D3D12_RESOURCE_STATE_COMMON;
// For bindful - indices in the non-shader-visible descriptor cache for
// copying to the shader-visible heap (much faster than recreating, which,
// according to profiling, was often a bottleneck in many games).
@@ -717,7 +724,8 @@ class D3D12TextureCache final : public TextureCache {
case xenos::FetchOpDimension::k1D:
case xenos::FetchOpDimension::k2D:
return resource_dimension == xenos::DataDimension::k1D ||
resource_dimension == xenos::DataDimension::k2DOrStacked;
resource_dimension == xenos::DataDimension::k2DOrStacked ||
resource_dimension == xenos::DataDimension::k3D;
case xenos::FetchOpDimension::k3DOrStacked:
return resource_dimension == xenos::DataDimension::k3D;
case xenos::FetchOpDimension::kCube:
@@ -730,8 +738,9 @@ class D3D12TextureCache final : public TextureCache {
// Returns the index of an existing of a newly created non-shader-visible
// cached (for bindful) or a shader-visible global (for bindless) descriptor,
// or UINT32_MAX if failed to create.
uint32_t FindOrCreateTextureDescriptor(D3D12Texture& texture, bool is_signed,
uint32_t host_swizzle);
uint32_t FindOrCreateTextureDescriptor(D3D12Texture& texture,
xenos::DataDimension dimension,
bool is_signed, uint32_t host_swizzle);
void ReleaseTextureDescriptor(uint32_t descriptor_index);
D3D12_CPU_DESCRIPTOR_HANDLE GetTextureDescriptorCPUHandle(
uint32_t descriptor_index) const;