1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

rsx: Preserve the texcoord transform around destructive modifications

This commit is contained in:
kd-11 2023-07-11 00:47:56 +03:00 committed by kd-11
parent 4b12c9a9fc
commit c325017675
5 changed files with 46 additions and 18 deletions

View File

@ -1,10 +1,11 @@
#pragma once #pragma once
#include "io_buffer.h"
#include "../RSXTexture.h" #include "../RSXTexture.h"
#include <span> #include <span>
#include <stack>
#include <vector> #include <vector>
#include "io_buffer.h"
namespace rsx namespace rsx
{ {
@ -123,9 +124,39 @@ namespace rsx
using namespace format_class_; using namespace format_class_;
//Sampled image descriptor // Sampled image descriptor
struct sampled_image_descriptor_base class sampled_image_descriptor_base
{ {
#pragma pack(push, 1)
struct texcoord_xform_t
{
f32 scale[3];
f32 bias[3];
f32 clamp_min[2];
f32 clamp_max[2];
bool clamp = false;
};
#pragma pack(pop)
// Texure matrix stack
std::stack<texcoord_xform_t> m_texcoord_xform_stack;
public:
virtual ~sampled_image_descriptor_base() = default;
virtual u32 encoded_component_map() const = 0;
void push_texcoord_xform()
{
m_texcoord_xform_stack.push(texcoord_xform);
}
void pop_texcoord_xform()
{
ensure(!m_texcoord_xform_stack.empty());
std::memcpy(&texcoord_xform, &m_texcoord_xform_stack.top(), sizeof(texcoord_xform_t));
m_texcoord_xform_stack.pop();
}
texture_upload_context upload_context = texture_upload_context::shader_read; texture_upload_context upload_context = texture_upload_context::shader_read;
rsx::texture_dimension_extended image_type = texture_dimension_extended::texture_dimension_2d; rsx::texture_dimension_extended image_type = texture_dimension_extended::texture_dimension_2d;
rsx::format_class format_class = RSX_FORMAT_CLASS_UNDEFINED; rsx::format_class format_class = RSX_FORMAT_CLASS_UNDEFINED;
@ -134,19 +165,7 @@ namespace rsx
u32 ref_address = 0; u32 ref_address = 0;
u64 surface_cache_tag = 0; u64 surface_cache_tag = 0;
#pragma pack(push, 1) texcoord_xform_t texcoord_xform;
struct
{
f32 scale[3];
f32 bias[3];
f32 clamp_min[2];
f32 clamp_max[2];
bool clamp = false;
} texcoord_xform;
#pragma pack(pop)
virtual ~sampled_image_descriptor_base() = default;
virtual u32 encoded_component_map() const = 0;
}; };
struct typeless_xfer struct typeless_xfer

View File

@ -2416,6 +2416,12 @@ namespace rsx
result.external_subresource_desc = { 0, deferred_request_command::mipmap_gather, attributes, {}, tex.decoded_remap() }; result.external_subresource_desc = { 0, deferred_request_command::mipmap_gather, attributes, {}, tex.decoded_remap() };
result.format_class = rsx::classify_format(attributes.gcm_format); result.format_class = rsx::classify_format(attributes.gcm_format);
if (result.texcoord_xform.clamp)
{
// Revert clamp configuration
result.pop_texcoord_xform();
}
if (use_upscaling) if (use_upscaling)
{ {
// Grab the correct image dimensions from the base mipmap level // Grab the correct image dimensions from the base mipmap level

View File

@ -514,6 +514,9 @@ namespace rsx
const size2i& desired_dimensions, const size2i& desired_dimensions,
const size2i& actual_dimensions) const size2i& actual_dimensions)
{ {
// Back up the transformation before we destructively modify it.
desc.push_texcoord_xform();
desc.texcoord_xform.scale[0] *= f32(desired_dimensions.width) / actual_dimensions.width; desc.texcoord_xform.scale[0] *= f32(desired_dimensions.width) / actual_dimensions.width;
desc.texcoord_xform.scale[1] *= f32(desired_dimensions.height) / actual_dimensions.height; desc.texcoord_xform.scale[1] *= f32(desired_dimensions.height) / actual_dimensions.height;
desc.texcoord_xform.bias[0] += f32(offset.x) / actual_dimensions.width; desc.texcoord_xform.bias[0] += f32(offset.x) / actual_dimensions.width;

View File

@ -6,7 +6,7 @@ namespace rsx
{ {
class fragment_texture; class fragment_texture;
class vertex_texture; class vertex_texture;
struct sampled_image_descriptor_base; class sampled_image_descriptor_base;
} }
namespace gl namespace gl

View File

@ -138,7 +138,7 @@ namespace rsx
bool supports_normalized_barycentrics; // Basically all GPUs except NVIDIA have properly normalized barycentrics bool supports_normalized_barycentrics; // Basically all GPUs except NVIDIA have properly normalized barycentrics
}; };
struct sampled_image_descriptor_base; class sampled_image_descriptor_base;
struct desync_fifo_cmd_info struct desync_fifo_cmd_info
{ {