GPU/HW: Make texture filtering a fragment shadergen parameter

This commit is contained in:
Stenzek 2024-06-16 17:51:00 +10:00
parent 5be2e68ab9
commit 1582b2ae5d
No known key found for this signature in database
4 changed files with 21 additions and 22 deletions

View File

@ -780,7 +780,7 @@ bool GPU_HW::CompilePipelines()
m_allow_shader_blend = (features.feedback_loops && (m_pgxp_depth_buffer || !needs_depth_buffer));
GPU_HW_ShaderGen shadergen(g_gpu_device->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,
m_true_color, m_scaled_dithering, m_texture_filtering, m_clamp_uvs, write_mask_as_depth,
m_true_color, m_scaled_dithering, m_clamp_uvs, write_mask_as_depth,
m_disable_color_perspective, m_supports_dual_source_blend, m_supports_framebuffer_fetch,
m_debanding);
@ -837,7 +837,7 @@ bool GPU_HW::CompilePipelines()
(m_supports_framebuffer_fetch && (render_mode == static_cast<u8>(BatchRenderMode::OnlyOpaque) ||
render_mode == static_cast<u8>(BatchRenderMode::OnlyTransparent))))
{
progress.Increment(4 * 2 * 2 * 2);
progress.Increment(active_texture_modes * 2 * 2 * 2);
continue;
}
@ -858,7 +858,7 @@ bool GPU_HW::CompilePipelines()
{
const std::string fs = shadergen.GenerateBatchFragmentShader(
static_cast<BatchRenderMode>(render_mode), static_cast<GPUTransparencyMode>(transparency_mode),
static_cast<GPUTextureMode>(texture_mode), ConvertToBoolUnchecked(dithering),
static_cast<GPUTextureMode>(texture_mode), m_texture_filtering, ConvertToBoolUnchecked(dithering),
ConvertToBoolUnchecked(interlacing), ConvertToBoolUnchecked(check_mask));
if (!(batch_fragment_shaders[render_mode][transparency_mode][texture_mode][check_mask][dithering]

View File

@ -287,5 +287,5 @@ private:
u32 m_downsample_scale_or_levels = 0;
// [depth_test][transparency_mode][render_mode][texture_mode][dithering][interlacing][check_mask]
DimensionalArray<std::unique_ptr<GPUPipeline>, 2, 2, 2, 9, 5, 5, 2> m_batch_pipelines{};
DimensionalArray<std::unique_ptr<GPUPipeline>, 2, 2, 2, NUM_TEXTURE_MODES, 5, 5, 2> m_batch_pipelines{};
};

View File

@ -6,15 +6,14 @@
#include <cstdio>
GPU_HW_ShaderGen::GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples,
bool per_sample_shading, bool true_color, bool scaled_dithering,
GPUTextureFilter texture_filtering, bool uv_limits, bool write_mask_as_depth,
bool disable_color_perspective, bool supports_dual_source_blend,
bool supports_framebuffer_fetch, bool debanding)
bool per_sample_shading, bool true_color, bool scaled_dithering, bool uv_limits,
bool write_mask_as_depth, bool disable_color_perspective,
bool supports_dual_source_blend, bool supports_framebuffer_fetch, bool debanding)
: ShaderGen(render_api, GetShaderLanguageForAPI(render_api), supports_dual_source_blend, supports_framebuffer_fetch),
m_resolution_scale(resolution_scale), m_multisamples(multisamples), m_per_sample_shading(per_sample_shading),
m_true_color(true_color), m_scaled_dithering(scaled_dithering), m_texture_filter(texture_filtering),
m_uv_limits(uv_limits), m_write_mask_as_depth(write_mask_as_depth),
m_disable_color_perspective(disable_color_perspective), m_debanding(debanding)
m_true_color(true_color), m_scaled_dithering(scaled_dithering), m_uv_limits(uv_limits),
m_write_mask_as_depth(write_mask_as_depth), m_disable_color_perspective(disable_color_perspective),
m_debanding(debanding)
{
}
@ -633,7 +632,8 @@ void FilteredSampleFromVRAM(uint4 texpage, float2 coords, float4 uv_limits,
std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode,
GPUTransparencyMode transparency, GPUTextureMode texture_mode,
bool dithering, bool interlacing, bool check_mask)
GPUTextureFilter texture_filtering, bool dithering,
bool interlacing, bool check_mask)
{
// TODO: don't write depth for shader blend
DebugAssert(transparency == GPUTransparencyMode::Disabled || render_mode == GPU_HW::BatchRenderMode::ShaderBlend);
@ -644,7 +644,7 @@ std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(GPU_HW::BatchRenderMod
const bool use_dual_source = (!shader_blending && m_supports_dual_source_blend &&
((render_mode != GPU_HW::BatchRenderMode::TransparencyDisabled &&
render_mode != GPU_HW::BatchRenderMode::OnlyOpaque) ||
m_texture_filter != GPUTextureFilter::Nearest));
texture_filtering != GPUTextureFilter::Nearest));
std::stringstream ss;
WriteHeader(ss);
@ -665,7 +665,7 @@ std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(GPU_HW::BatchRenderMod
DefineMacro(ss, "DEBANDING", m_true_color && m_debanding);
DefineMacro(ss, "INTERLACING", interlacing);
DefineMacro(ss, "TRUE_COLOR", m_true_color);
DefineMacro(ss, "TEXTURE_FILTERING", m_texture_filter != GPUTextureFilter::Nearest);
DefineMacro(ss, "TEXTURE_FILTERING", texture_filtering != GPUTextureFilter::Nearest);
DefineMacro(ss, "UV_LIMITS", m_uv_limits);
DefineMacro(ss, "USE_DUAL_SOURCE", use_dual_source);
DefineMacro(ss, "WRITE_MASK_AS_DEPTH", m_write_mask_as_depth);
@ -792,8 +792,8 @@ float3 ApplyDebanding(float2 frag_coord)
if (textured)
{
if (m_texture_filter != GPUTextureFilter::Nearest)
WriteBatchTextureFilter(ss, m_texture_filter);
if (texture_filtering != GPUTextureFilter::Nearest)
WriteBatchTextureFilter(ss, texture_filtering);
if (m_uv_limits)
{

View File

@ -9,15 +9,15 @@ class GPU_HW_ShaderGen : public ShaderGen
{
public:
GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples, bool per_sample_shading,
bool true_color, bool scaled_dithering, GPUTextureFilter texture_filtering, bool uv_limits,
bool write_mask_as_depth, bool disable_color_perspective, bool supports_dual_source_blend,
bool supports_framebuffer_fetch, bool debanding);
bool true_color, bool scaled_dithering, bool uv_limits, bool write_mask_as_depth,
bool disable_color_perspective, bool supports_dual_source_blend, bool supports_framebuffer_fetch,
bool debanding);
~GPU_HW_ShaderGen();
std::string GenerateBatchVertexShader(bool textured, bool pgxp_depth);
std::string GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode, GPUTransparencyMode transparency,
GPUTextureMode texture_mode, bool dithering, bool interlacing,
bool check_mask);
GPUTextureMode texture_mode, GPUTextureFilter texture_filtering,
bool dithering, bool interlacing, bool check_mask);
std::string GenerateWireframeGeometryShader();
std::string GenerateWireframeFragmentShader();
std::string GenerateVRAMReadFragmentShader();
@ -47,7 +47,6 @@ private:
bool m_per_sample_shading;
bool m_true_color;
bool m_scaled_dithering;
GPUTextureFilter m_texture_filter;
bool m_uv_limits;
bool m_write_mask_as_depth;
bool m_disable_color_perspective;