gpu_hw_shadergen.h (2721B)
1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) 3 4 #pragma once 5 6 #include "gpu_hw.h" 7 8 #include "util/shadergen.h" 9 10 class GPU_HW_ShaderGen : public ShaderGen 11 { 12 public: 13 GPU_HW_ShaderGen(RenderAPI render_api, u32 resolution_scale, u32 multisamples, bool per_sample_shading, 14 bool true_color, bool scaled_dithering, bool write_mask_as_depth, bool disable_color_perspective, 15 bool supports_dual_source_blend, bool supports_framebuffer_fetch, bool debanding); 16 ~GPU_HW_ShaderGen(); 17 18 std::string GenerateBatchVertexShader(bool textured, bool palette, bool uv_limits, bool force_round_texcoords, 19 bool pgxp_depth); 20 std::string GenerateBatchFragmentShader(GPU_HW::BatchRenderMode render_mode, GPUTransparencyMode transparency, 21 GPU_HW::BatchTextureMode texture_mode, GPUTextureFilter texture_filtering, 22 bool uv_limits, bool force_round_texcoords, bool dithering, bool interlacing, 23 bool check_mask, bool use_rov, bool use_rov_depth, bool rov_depth_test); 24 std::string GenerateWireframeGeometryShader(); 25 std::string GenerateWireframeFragmentShader(); 26 std::string GenerateVRAMReadFragmentShader(); 27 std::string GenerateVRAMWriteFragmentShader(bool use_buffer, bool use_ssbo); 28 std::string GenerateVRAMCopyFragmentShader(); 29 std::string GenerateVRAMFillFragmentShader(bool wrapped, bool interlaced); 30 std::string GenerateVRAMUpdateDepthFragmentShader(); 31 std::string GenerateVRAMExtractFragmentShader(bool color_24bit, bool depth_buffer); 32 33 std::string GenerateAdaptiveDownsampleVertexShader(); 34 std::string GenerateAdaptiveDownsampleMipFragmentShader(bool first_pass); 35 std::string GenerateAdaptiveDownsampleBlurFragmentShader(); 36 std::string GenerateAdaptiveDownsampleCompositeFragmentShader(); 37 std::string GenerateBoxSampleDownsampleFragmentShader(u32 factor); 38 39 private: 40 ALWAYS_INLINE bool UsingMSAA() const { return m_multisamples > 1; } 41 ALWAYS_INLINE bool UsingPerSampleShading() const { return m_multisamples > 1 && m_per_sample_shading; } 42 43 void WriteCommonFunctions(std::stringstream& ss); 44 void WriteBatchUniformBuffer(std::stringstream& ss); 45 void WriteBatchTextureFilter(std::stringstream& ss, GPUTextureFilter texture_filter); 46 void WriteAdaptiveDownsampleUniformBuffer(std::stringstream& ss); 47 48 u32 m_resolution_scale; 49 u32 m_multisamples; 50 bool m_per_sample_shading; 51 bool m_true_color; 52 bool m_scaled_dithering; 53 bool m_write_mask_as_depth; 54 bool m_disable_color_perspective; 55 bool m_debanding; 56 };