mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
GPU/HW: Make texture filtering a fragment shadergen parameter
This commit is contained in:
parent
5be2e68ab9
commit
1582b2ae5d
|
@ -780,7 +780,7 @@ bool GPU_HW::CompilePipelines()
|
||||||
m_allow_shader_blend = (features.feedback_loops && (m_pgxp_depth_buffer || !needs_depth_buffer));
|
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,
|
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_disable_color_perspective, m_supports_dual_source_blend, m_supports_framebuffer_fetch,
|
||||||
m_debanding);
|
m_debanding);
|
||||||
|
|
||||||
|
@ -837,7 +837,7 @@ bool GPU_HW::CompilePipelines()
|
||||||
(m_supports_framebuffer_fetch && (render_mode == static_cast<u8>(BatchRenderMode::OnlyOpaque) ||
|
(m_supports_framebuffer_fetch && (render_mode == static_cast<u8>(BatchRenderMode::OnlyOpaque) ||
|
||||||
render_mode == static_cast<u8>(BatchRenderMode::OnlyTransparent))))
|
render_mode == static_cast<u8>(BatchRenderMode::OnlyTransparent))))
|
||||||
{
|
{
|
||||||
progress.Increment(4 * 2 * 2 * 2);
|
progress.Increment(active_texture_modes * 2 * 2 * 2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ bool GPU_HW::CompilePipelines()
|
||||||
{
|
{
|
||||||
const std::string fs = shadergen.GenerateBatchFragmentShader(
|
const std::string fs = shadergen.GenerateBatchFragmentShader(
|
||||||
static_cast<BatchRenderMode>(render_mode), static_cast<GPUTransparencyMode>(transparency_mode),
|
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));
|
ConvertToBoolUnchecked(interlacing), ConvertToBoolUnchecked(check_mask));
|
||||||
|
|
||||||
if (!(batch_fragment_shaders[render_mode][transparency_mode][texture_mode][check_mask][dithering]
|
if (!(batch_fragment_shaders[render_mode][transparency_mode][texture_mode][check_mask][dithering]
|
||||||
|
|
|
@ -287,5 +287,5 @@ private:
|
||||||
u32 m_downsample_scale_or_levels = 0;
|
u32 m_downsample_scale_or_levels = 0;
|
||||||
|
|
||||||
// [depth_test][transparency_mode][render_mode][texture_mode][dithering][interlacing][check_mask]
|
// [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{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
GPU_HW_ShaderGen::GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples,
|
GPU_HW_ShaderGen::GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples,
|
||||||
bool per_sample_shading, bool true_color, bool scaled_dithering,
|
bool per_sample_shading, bool true_color, bool scaled_dithering, bool uv_limits,
|
||||||
GPUTextureFilter texture_filtering, bool uv_limits, bool write_mask_as_depth,
|
bool write_mask_as_depth, bool disable_color_perspective,
|
||||||
bool disable_color_perspective, bool supports_dual_source_blend,
|
bool supports_dual_source_blend, bool supports_framebuffer_fetch, bool debanding)
|
||||||
bool supports_framebuffer_fetch, bool debanding)
|
|
||||||
: ShaderGen(render_api, GetShaderLanguageForAPI(render_api), supports_dual_source_blend, supports_framebuffer_fetch),
|
: 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_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_true_color(true_color), m_scaled_dithering(scaled_dithering), m_uv_limits(uv_limits),
|
||||||
m_uv_limits(uv_limits), m_write_mask_as_depth(write_mask_as_depth),
|
m_write_mask_as_depth(write_mask_as_depth), m_disable_color_perspective(disable_color_perspective),
|
||||||
m_disable_color_perspective(disable_color_perspective), m_debanding(debanding)
|
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,
|
std::string GPU_HW_ShaderGen::GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode,
|
||||||
GPUTransparencyMode transparency, GPUTextureMode texture_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
|
// TODO: don't write depth for shader blend
|
||||||
DebugAssert(transparency == GPUTransparencyMode::Disabled || render_mode == GPU_HW::BatchRenderMode::ShaderBlend);
|
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 &&
|
const bool use_dual_source = (!shader_blending && m_supports_dual_source_blend &&
|
||||||
((render_mode != GPU_HW::BatchRenderMode::TransparencyDisabled &&
|
((render_mode != GPU_HW::BatchRenderMode::TransparencyDisabled &&
|
||||||
render_mode != GPU_HW::BatchRenderMode::OnlyOpaque) ||
|
render_mode != GPU_HW::BatchRenderMode::OnlyOpaque) ||
|
||||||
m_texture_filter != GPUTextureFilter::Nearest));
|
texture_filtering != GPUTextureFilter::Nearest));
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
WriteHeader(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, "DEBANDING", m_true_color && m_debanding);
|
||||||
DefineMacro(ss, "INTERLACING", interlacing);
|
DefineMacro(ss, "INTERLACING", interlacing);
|
||||||
DefineMacro(ss, "TRUE_COLOR", m_true_color);
|
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, "UV_LIMITS", m_uv_limits);
|
||||||
DefineMacro(ss, "USE_DUAL_SOURCE", use_dual_source);
|
DefineMacro(ss, "USE_DUAL_SOURCE", use_dual_source);
|
||||||
DefineMacro(ss, "WRITE_MASK_AS_DEPTH", m_write_mask_as_depth);
|
DefineMacro(ss, "WRITE_MASK_AS_DEPTH", m_write_mask_as_depth);
|
||||||
|
@ -792,8 +792,8 @@ float3 ApplyDebanding(float2 frag_coord)
|
||||||
|
|
||||||
if (textured)
|
if (textured)
|
||||||
{
|
{
|
||||||
if (m_texture_filter != GPUTextureFilter::Nearest)
|
if (texture_filtering != GPUTextureFilter::Nearest)
|
||||||
WriteBatchTextureFilter(ss, m_texture_filter);
|
WriteBatchTextureFilter(ss, texture_filtering);
|
||||||
|
|
||||||
if (m_uv_limits)
|
if (m_uv_limits)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,15 +9,15 @@ class GPU_HW_ShaderGen : public ShaderGen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples, bool per_sample_shading,
|
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 true_color, bool scaled_dithering, bool uv_limits, bool write_mask_as_depth,
|
||||||
bool write_mask_as_depth, bool disable_color_perspective, bool supports_dual_source_blend,
|
bool disable_color_perspective, bool supports_dual_source_blend, bool supports_framebuffer_fetch,
|
||||||
bool supports_framebuffer_fetch, bool debanding);
|
bool debanding);
|
||||||
~GPU_HW_ShaderGen();
|
~GPU_HW_ShaderGen();
|
||||||
|
|
||||||
std::string GenerateBatchVertexShader(bool textured, bool pgxp_depth);
|
std::string GenerateBatchVertexShader(bool textured, bool pgxp_depth);
|
||||||
std::string GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode, GPUTransparencyMode transparency,
|
std::string GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode, GPUTransparencyMode transparency,
|
||||||
GPUTextureMode texture_mode, bool dithering, bool interlacing,
|
GPUTextureMode texture_mode, GPUTextureFilter texture_filtering,
|
||||||
bool check_mask);
|
bool dithering, bool interlacing, bool check_mask);
|
||||||
std::string GenerateWireframeGeometryShader();
|
std::string GenerateWireframeGeometryShader();
|
||||||
std::string GenerateWireframeFragmentShader();
|
std::string GenerateWireframeFragmentShader();
|
||||||
std::string GenerateVRAMReadFragmentShader();
|
std::string GenerateVRAMReadFragmentShader();
|
||||||
|
@ -47,7 +47,6 @@ private:
|
||||||
bool m_per_sample_shading;
|
bool m_per_sample_shading;
|
||||||
bool m_true_color;
|
bool m_true_color;
|
||||||
bool m_scaled_dithering;
|
bool m_scaled_dithering;
|
||||||
GPUTextureFilter m_texture_filter;
|
|
||||||
bool m_uv_limits;
|
bool m_uv_limits;
|
||||||
bool m_write_mask_as_depth;
|
bool m_write_mask_as_depth;
|
||||||
bool m_disable_color_perspective;
|
bool m_disable_color_perspective;
|
||||||
|
|
Loading…
Reference in a new issue