From 1582b2ae5d6032bea3695af777dbd98e383f9578 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 16 Jun 2024 17:51:00 +1000 Subject: [PATCH] GPU/HW: Make texture filtering a fragment shadergen parameter --- src/core/gpu_hw.cpp | 6 +++--- src/core/gpu_hw.h | 2 +- src/core/gpu_hw_shadergen.cpp | 24 ++++++++++++------------ src/core/gpu_hw_shadergen.h | 11 +++++------ 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 8352af4e5..14ebaa717 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -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(BatchRenderMode::OnlyOpaque) || render_mode == static_cast(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(render_mode), static_cast(transparency_mode), - static_cast(texture_mode), ConvertToBoolUnchecked(dithering), + static_cast(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] diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 9bd0db0f3..70f53d843 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -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, 2, 2, 2, 9, 5, 5, 2> m_batch_pipelines{}; + DimensionalArray, 2, 2, 2, NUM_TEXTURE_MODES, 5, 5, 2> m_batch_pipelines{}; }; diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index ff715029b..3a0f153b1 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -6,15 +6,14 @@ #include 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) { diff --git a/src/core/gpu_hw_shadergen.h b/src/core/gpu_hw_shadergen.h index 94c938b51..ad06954fe 100644 --- a/src/core/gpu_hw_shadergen.h +++ b/src/core/gpu_hw_shadergen.h @@ -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;