mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 08:05:41 +00:00
GPU: Fix MSAA in OpenGL ES
This commit is contained in:
parent
4c08624ce5
commit
b5b1c725c1
|
@ -181,9 +181,12 @@ void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display)
|
||||||
m_max_resolution_scale = static_cast<u32>(max_texture_size / VRAM_WIDTH);
|
m_max_resolution_scale = static_cast<u32>(max_texture_size / VRAM_WIDTH);
|
||||||
|
|
||||||
m_max_multisamples = 1;
|
m_max_multisamples = 1;
|
||||||
|
if (GLAD_GL_ARB_texture_storage || GLAD_GL_ES_VERSION_3_1)
|
||||||
|
{
|
||||||
glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<GLint*>(&m_max_multisamples));
|
glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<GLint*>(&m_max_multisamples));
|
||||||
if (m_max_multisamples == 0)
|
if (m_max_multisamples == 0)
|
||||||
m_max_multisamples = 1;
|
m_max_multisamples = 1;
|
||||||
|
}
|
||||||
|
|
||||||
m_supports_per_sample_shading = GLAD_GL_ARB_sample_shading;
|
m_supports_per_sample_shading = GLAD_GL_ARB_sample_shading;
|
||||||
Log_InfoPrintf("Per-sample shading: %s", m_supports_per_sample_shading ? "supported" : "not supported");
|
Log_InfoPrintf("Per-sample shading: %s", m_supports_per_sample_shading ? "supported" : "not supported");
|
||||||
|
|
|
@ -119,6 +119,9 @@ void ShaderGen::WriteHeader(std::stringstream& ss)
|
||||||
ss << "precision highp int;\n";
|
ss << "precision highp int;\n";
|
||||||
ss << "precision highp sampler2D;\n";
|
ss << "precision highp sampler2D;\n";
|
||||||
|
|
||||||
|
if (GLAD_GL_ES_VERSION_3_1)
|
||||||
|
ss << "precision highp sampler2DMS;\n";
|
||||||
|
|
||||||
if (GLAD_GL_ES_VERSION_3_2)
|
if (GLAD_GL_ES_VERSION_3_2)
|
||||||
ss << "precision highp usamplerBuffer;\n";
|
ss << "precision highp usamplerBuffer;\n";
|
||||||
|
|
||||||
|
@ -270,14 +273,19 @@ void ShaderGen::DeclareTextureBuffer(std::stringstream& ss, const char* name, u3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetInterpolationQualifier(bool glsl, bool vulkan, bool interface_block, bool centroid_interpolation,
|
const char* ShaderGen::GetInterpolationQualifier(bool interface_block, bool centroid_interpolation,
|
||||||
bool sample_interpolation)
|
bool sample_interpolation, bool is_out) const
|
||||||
{
|
{
|
||||||
if (glsl && interface_block && (!vulkan && !GLAD_GL_ARB_shading_language_420pack))
|
if (m_glsl && interface_block && (!IsVulkan() && !GLAD_GL_ARB_shading_language_420pack))
|
||||||
return (sample_interpolation ? "sample out " : (centroid_interpolation ? "centroid out " : ""));
|
{
|
||||||
|
return (sample_interpolation ? (is_out ? "sample out " : "sample in ") :
|
||||||
|
(centroid_interpolation ? (is_out ? "centroid out " : "centroid in ") : ""));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return (sample_interpolation ? "sample " : (centroid_interpolation ? "centroid " : ""));
|
return (sample_interpolation ? "sample " : (centroid_interpolation ? "centroid " : ""));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderGen::DeclareVertexEntryPoint(
|
void ShaderGen::DeclareVertexEntryPoint(
|
||||||
std::stringstream& ss, const std::initializer_list<const char*>& attributes, u32 num_color_outputs,
|
std::stringstream& ss, const std::initializer_list<const char*>& attributes, u32 num_color_outputs,
|
||||||
|
@ -304,8 +312,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
||||||
|
|
||||||
if (m_use_glsl_interface_blocks)
|
if (m_use_glsl_interface_blocks)
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(true, centroid_interpolation, sample_interpolation, true);
|
||||||
GetInterpolationQualifier(m_glsl, IsVulkan(), true, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
if (IsVulkan())
|
if (IsVulkan())
|
||||||
ss << "layout(location = 0) ";
|
ss << "layout(location = 0) ";
|
||||||
|
@ -326,8 +333,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, true);
|
||||||
GetInterpolationQualifier(m_glsl, IsVulkan(), false, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
for (u32 i = 0; i < num_color_outputs; i++)
|
for (u32 i = 0; i < num_color_outputs; i++)
|
||||||
ss << qualifier << "out float4 v_col" << i << ";\n";
|
ss << qualifier << "out float4 v_col" << i << ";\n";
|
||||||
|
@ -356,8 +362,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, true);
|
||||||
GetInterpolationQualifier(false, false, false, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
ss << "void main(\n";
|
ss << "void main(\n";
|
||||||
|
|
||||||
|
@ -400,8 +405,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
||||||
{
|
{
|
||||||
if (m_use_glsl_interface_blocks)
|
if (m_use_glsl_interface_blocks)
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(true, centroid_interpolation, sample_interpolation, false);
|
||||||
GetInterpolationQualifier(m_glsl, IsVulkan(), true, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
if (IsVulkan())
|
if (IsVulkan())
|
||||||
ss << "layout(location = 0) ";
|
ss << "layout(location = 0) ";
|
||||||
|
@ -422,8 +426,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, false);
|
||||||
GetInterpolationQualifier(m_glsl, IsVulkan(), false, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
for (u32 i = 0; i < num_color_inputs; i++)
|
for (u32 i = 0; i < num_color_inputs; i++)
|
||||||
ss << qualifier << "in float4 v_col" << i << ";\n";
|
ss << qualifier << "in float4 v_col" << i << ";\n";
|
||||||
|
@ -473,8 +476,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* qualifier =
|
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, false);
|
||||||
GetInterpolationQualifier(false, false, false, centroid_interpolation, sample_interpolation);
|
|
||||||
|
|
||||||
ss << "void main(\n";
|
ss << "void main(\n";
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
ALWAYS_INLINE bool IsVulkan() const { return (m_render_api == HostDisplay::RenderAPI::Vulkan); }
|
ALWAYS_INLINE bool IsVulkan() const { return (m_render_api == HostDisplay::RenderAPI::Vulkan); }
|
||||||
|
|
||||||
|
const char* GetInterpolationQualifier(bool interface_block, bool centroid_interpolation, bool sample_interpolation,
|
||||||
|
bool is_out) const;
|
||||||
|
|
||||||
void SetGLSLVersionString();
|
void SetGLSLVersionString();
|
||||||
void DefineMacro(std::stringstream& ss, const char* name, bool enabled);
|
void DefineMacro(std::stringstream& ss, const char* name, bool enabled);
|
||||||
void WriteHeader(std::stringstream& ss);
|
void WriteHeader(std::stringstream& ss);
|
||||||
|
|
Loading…
Reference in a new issue