From cfd18b89f8fc5ebddc7a29ea777c60e7fa0eb219 Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Wed, 22 Sep 2021 15:06:10 +0200 Subject: [PATCH] [GPU] GCC build fix for render target cache --- src/xenia/gpu/render_target_cache.cc | 4 ++-- src/xenia/gpu/render_target_cache.h | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/xenia/gpu/render_target_cache.cc b/src/xenia/gpu/render_target_cache.cc index 2dcf93789..5b0ba7c66 100644 --- a/src/xenia/gpu/render_target_cache.cc +++ b/src/xenia/gpu/render_target_cache.cc @@ -1342,7 +1342,7 @@ void RenderTargetCache::ChangeOwnership( nullptr, resolve_clear_cutout)) { RenderTargetKey transfer_host_depth_source = host_depth_encoding_different - ? it->second.host_depth_render_targets[dest.resource_format] + ? it->second.GetHostDepthRenderTarget(dest.GetDepthFormat()) : RenderTargetKey(); if (transfer_host_depth_source == transfer_source) { // Same render target, don't provide a separate host depth source. @@ -1387,7 +1387,7 @@ void RenderTargetCache::ChangeOwnership( // Claim the current range. it->second.render_target = dest; if (host_depth_encoding_different) { - it->second.host_depth_render_targets[dest.resource_format] = dest; + it->second.GetHostDepthRenderTarget(dest.GetDepthFormat()) = dest; } // Check if can merge with the next range after claiming. std::map::iterator it_next; diff --git a/src/xenia/gpu/render_target_cache.h b/src/xenia/gpu/render_target_cache.h index bf7c9a83e..9fe068f40 100644 --- a/src/xenia/gpu/render_target_cache.h +++ b/src/xenia/gpu/render_target_cache.h @@ -538,13 +538,8 @@ class RenderTargetCache { // float32 value to that of an unorm24 with a totally wrong value). If the // range hasn't been used yet (render_target.IsEmpty() == true), these are // empty too. - union { - struct { - RenderTargetKey host_depth_render_target_unorm24; - RenderTargetKey host_depth_render_target_float24; - }; - RenderTargetKey host_depth_render_targets[2]; - }; + RenderTargetKey host_depth_render_target_unorm24; + RenderTargetKey host_depth_render_target_float24; OwnershipRange(uint32_t end_tiles, RenderTargetKey render_target, RenderTargetKey host_depth_render_target_unorm24, RenderTargetKey host_depth_render_target_float24) @@ -552,6 +547,22 @@ class RenderTargetCache { render_target(render_target), host_depth_render_target_unorm24(host_depth_render_target_unorm24), host_depth_render_target_float24(host_depth_render_target_float24) {} + const RenderTargetKey& GetHostDepthRenderTarget( + xenos::DepthRenderTargetFormat resource_format) const { + assert_true( + resource_format == xenos::DepthRenderTargetFormat::kD24S8 || + resource_format == xenos::DepthRenderTargetFormat::kD24FS8, + "Illegal resource format"); + return resource_format == xenos::DepthRenderTargetFormat::kD24S8 + ? host_depth_render_target_unorm24 + : host_depth_render_target_float24; + } + RenderTargetKey& GetHostDepthRenderTarget( + xenos::DepthRenderTargetFormat resource_format) { + return const_cast( + const_cast(this)->GetHostDepthRenderTarget( + resource_format)); + } bool IsOwnedBy(RenderTargetKey key, bool host_depth_encoding_different) const { if (render_target != key) { @@ -561,7 +572,7 @@ class RenderTargetCache { return false; } if (host_depth_encoding_different && !key.is_depth && - host_depth_render_targets[key.resource_format] != key) { + GetHostDepthRenderTarget(key.GetDepthFormat()) != key) { // Depth encoding is the same, but different addressing is needed. return false; }