2019-11-03 03:36:54 +00:00
|
|
|
#pragma once
|
2019-11-03 05:18:51 +00:00
|
|
|
#include "gpu_hw.h"
|
2019-11-05 15:33:09 +00:00
|
|
|
#include "host_display.h"
|
2019-11-03 03:36:54 +00:00
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class GPU_HW_ShaderGen
|
|
|
|
{
|
|
|
|
public:
|
2020-02-29 14:05:31 +00:00
|
|
|
GPU_HW_ShaderGen(HostDisplay::RenderAPI render_api, u32 resolution_scale, bool true_color, bool scaled_dithering,
|
2020-04-16 11:29:11 +00:00
|
|
|
bool texture_filtering, bool supports_dual_source_blend);
|
2019-11-03 03:36:54 +00:00
|
|
|
~GPU_HW_ShaderGen();
|
|
|
|
|
|
|
|
std::string GenerateBatchVertexShader(bool textured);
|
2019-11-03 05:18:51 +00:00
|
|
|
std::string GenerateBatchFragmentShader(GPU_HW::BatchRenderMode transparency, GPU::TextureMode texture_mode,
|
2020-04-03 14:11:33 +00:00
|
|
|
bool dithering, bool interlacing);
|
2019-11-04 14:27:22 +00:00
|
|
|
std::string GenerateBatchLineExpandGeometryShader();
|
2019-11-03 03:36:54 +00:00
|
|
|
std::string GenerateScreenQuadVertexShader();
|
|
|
|
std::string GenerateFillFragmentShader();
|
2020-04-03 14:11:39 +00:00
|
|
|
std::string GenerateInterlacedFillFragmentShader();
|
2019-11-03 14:39:48 +00:00
|
|
|
std::string GenerateCopyFragmentShader();
|
2019-11-03 03:36:54 +00:00
|
|
|
std::string GenerateDisplayFragmentShader(bool depth_24bit, bool interlaced);
|
2019-11-14 06:58:27 +00:00
|
|
|
std::string GenerateVRAMReadFragmentShader();
|
2019-11-03 03:36:54 +00:00
|
|
|
std::string GenerateVRAMWriteFragmentShader();
|
|
|
|
|
2019-11-05 15:33:09 +00:00
|
|
|
HostDisplay::RenderAPI m_render_api;
|
2019-11-03 03:36:54 +00:00
|
|
|
u32 m_resolution_scale;
|
|
|
|
bool m_true_color;
|
2020-02-29 14:05:31 +00:00
|
|
|
bool m_scaled_dithering;
|
2019-12-07 07:03:54 +00:00
|
|
|
bool m_texture_filering;
|
2019-11-03 05:18:51 +00:00
|
|
|
bool m_glsl;
|
2019-11-24 13:23:33 +00:00
|
|
|
bool m_supports_dual_source_blend;
|
2020-04-16 11:29:11 +00:00
|
|
|
bool m_use_glsl_interface_blocks;
|
2019-11-03 03:36:54 +00:00
|
|
|
|
2019-11-24 14:17:15 +00:00
|
|
|
std::string m_glsl_version_string;
|
|
|
|
|
2019-11-03 03:36:54 +00:00
|
|
|
private:
|
2019-11-24 14:17:15 +00:00
|
|
|
void SetGLSLVersionString();
|
2019-11-03 05:18:51 +00:00
|
|
|
void WriteHeader(std::stringstream& ss);
|
|
|
|
void DeclareUniformBuffer(std::stringstream& ss, const std::initializer_list<const char*>& members);
|
|
|
|
void DeclareTexture(std::stringstream& ss, const char* name, u32 index);
|
|
|
|
void DeclareTextureBuffer(std::stringstream& ss, const char* name, u32 index, bool is_int, bool is_unsigned);
|
|
|
|
void DeclareVertexEntryPoint(std::stringstream& ss, const std::initializer_list<const char*>& attributes,
|
|
|
|
u32 num_color_outputs, u32 num_texcoord_outputs,
|
2020-04-16 11:29:11 +00:00
|
|
|
const std::initializer_list<std::pair<const char*, const char*>>& additional_outputs,
|
2019-11-03 14:39:48 +00:00
|
|
|
bool declare_vertex_id = false);
|
2019-11-03 05:18:51 +00:00
|
|
|
void DeclareFragmentEntryPoint(std::stringstream& ss, u32 num_color_inputs, u32 num_texcoord_inputs,
|
2020-04-16 11:29:11 +00:00
|
|
|
const std::initializer_list<std::pair<const char*, const char*>>& additional_inputs,
|
2019-11-03 05:18:51 +00:00
|
|
|
bool declare_fragcoord = false, bool dual_color_output = false);
|
|
|
|
|
|
|
|
void WriteCommonFunctions(std::stringstream& ss);
|
|
|
|
void WriteBatchUniformBuffer(std::stringstream& ss);
|
2019-11-03 03:36:54 +00:00
|
|
|
};
|