[GPU] Fix RT view and pipeline sRGB mismatch

This commit is contained in:
Triang3l
2021-06-14 17:30:56 +03:00
parent f15e3d07e7
commit 357aa1cdd3
5 changed files with 66 additions and 79 deletions

View File

@@ -181,8 +181,10 @@ class RenderTargetCache {
// Returns bits where 0 is whether a depth render target is currently bound on
// the host and 1... are whether the same applies to color render targets, and
// "host-relevant" formats of each.
// formats (resource formats, but if needed, with gamma taken into account) of
// each.
uint32_t GetLastUpdateBoundRenderTargets(
bool distinguish_gamma_formats,
uint32_t* depth_and_color_formats_out = nullptr) const;
protected:
@@ -223,11 +225,8 @@ class RenderTargetCache {
uint32_t pitch_tiles_at_32bpp : 8; // 19
xenos::MsaaSamples msaa_samples : xenos::kMsaaSamplesBits; // 21
uint32_t is_depth : 1; // 22
// Not always the original format - blending precision ignored, formats
// handled through the same render targets on the host are normalized, and
// with pixel shader interlock, replaced with some single 32bpp or 64bpp
// format because it's only needed for addressing.
uint32_t host_relevant_format : xenos::kRenderTargetFormatBits; // 26
// Ignoring the blending precision and sRGB.
uint32_t resource_format : xenos::kRenderTargetFormatBits; // 26
};
uint32_t key = 0;
struct Hasher {
@@ -250,11 +249,11 @@ class RenderTargetCache {
xenos::ColorRenderTargetFormat GetColorFormat() const {
assert_false(is_depth);
return xenos::ColorRenderTargetFormat(host_relevant_format);
return xenos::ColorRenderTargetFormat(resource_format);
}
xenos::DepthRenderTargetFormat GetDepthFormat() const {
assert_true(is_depth);
return xenos::DepthRenderTargetFormat(host_relevant_format);
return xenos::DepthRenderTargetFormat(resource_format);
}
bool Is64bpp() const {
if (is_depth) {
@@ -436,15 +435,6 @@ class RenderTargetCache {
uint32_t GetRenderTargetHeight(uint32_t pitch_tiles_at_32bpp,
xenos::MsaaSamples msaa_samples) const;
// Normalizes the format if it's fine to use the same render target textures
// for the provided and the returned guest formats.
// xenos::GetStorageColorFormat is supposed to be done before calling, so
// redoing what it does in the implementations is not needed.
virtual xenos::ColorRenderTargetFormat GetHostRelevantColorFormat(
xenos::ColorRenderTargetFormat format) const {
return format;
}
virtual RenderTarget* CreateRenderTarget(RenderTargetKey key) = 0;
// Whether depth buffer is encoded differently on the host, thus after
@@ -567,7 +557,7 @@ class RenderTargetCache {
return false;
}
if (host_depth_encoding_different && !key.is_depth &&
host_depth_render_targets[key.host_relevant_format] != key) {
host_depth_render_targets[key.resource_format] != key) {
// Depth encoding is the same, but different addressing is needed.
return false;
}
@@ -582,6 +572,16 @@ class RenderTargetCache {
}
};
static constexpr xenos::ColorRenderTargetFormat GetColorResourceFormat(
xenos::ColorRenderTargetFormat format) {
// sRGB, if used on the host, is a view property or global state - linear
// and sRGB host render targets can share data directly without transfers.
if (format == xenos::ColorRenderTargetFormat::k_8_8_8_8_GAMMA) {
return xenos::ColorRenderTargetFormat::k_8_8_8_8;
}
return xenos::GetStorageColorFormat(format);
}
RenderTarget* GetOrCreateRenderTarget(RenderTargetKey key);
// Checks if changing ownership of the range to the specified render target