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_multisamples = 1;
|
||||
glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<GLint*>(&m_max_multisamples));
|
||||
if (m_max_multisamples == 0)
|
||||
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));
|
||||
if (m_max_multisamples == 0)
|
||||
m_max_multisamples = 1;
|
||||
}
|
||||
|
||||
m_supports_per_sample_shading = GLAD_GL_ARB_sample_shading;
|
||||
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 sampler2D;\n";
|
||||
|
||||
if (GLAD_GL_ES_VERSION_3_1)
|
||||
ss << "precision highp sampler2DMS;\n";
|
||||
|
||||
if (GLAD_GL_ES_VERSION_3_2)
|
||||
ss << "precision highp usamplerBuffer;\n";
|
||||
|
||||
|
@ -270,13 +273,18 @@ void ShaderGen::DeclareTextureBuffer(std::stringstream& ss, const char* name, u3
|
|||
}
|
||||
}
|
||||
|
||||
static const char* GetInterpolationQualifier(bool glsl, bool vulkan, bool interface_block, bool centroid_interpolation,
|
||||
bool sample_interpolation)
|
||||
const char* ShaderGen::GetInterpolationQualifier(bool interface_block, bool centroid_interpolation,
|
||||
bool sample_interpolation, bool is_out) const
|
||||
{
|
||||
if (glsl && interface_block && (!vulkan && !GLAD_GL_ARB_shading_language_420pack))
|
||||
return (sample_interpolation ? "sample out " : (centroid_interpolation ? "centroid out " : ""));
|
||||
if (m_glsl && interface_block && (!IsVulkan() && !GLAD_GL_ARB_shading_language_420pack))
|
||||
{
|
||||
return (sample_interpolation ? (is_out ? "sample out " : "sample in ") :
|
||||
(centroid_interpolation ? (is_out ? "centroid out " : "centroid in ") : ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (sample_interpolation ? "sample " : (centroid_interpolation ? "centroid " : ""));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderGen::DeclareVertexEntryPoint(
|
||||
|
@ -304,8 +312,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
|||
|
||||
if (m_use_glsl_interface_blocks)
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(m_glsl, IsVulkan(), true, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(true, centroid_interpolation, sample_interpolation, true);
|
||||
|
||||
if (IsVulkan())
|
||||
ss << "layout(location = 0) ";
|
||||
|
@ -326,8 +333,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(m_glsl, IsVulkan(), false, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, true);
|
||||
|
||||
for (u32 i = 0; i < num_color_outputs; i++)
|
||||
ss << qualifier << "out float4 v_col" << i << ";\n";
|
||||
|
@ -356,8 +362,7 @@ void ShaderGen::DeclareVertexEntryPoint(
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(false, false, false, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, true);
|
||||
|
||||
ss << "void main(\n";
|
||||
|
||||
|
@ -400,8 +405,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
|||
{
|
||||
if (m_use_glsl_interface_blocks)
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(m_glsl, IsVulkan(), true, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(true, centroid_interpolation, sample_interpolation, false);
|
||||
|
||||
if (IsVulkan())
|
||||
ss << "layout(location = 0) ";
|
||||
|
@ -422,8 +426,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(m_glsl, IsVulkan(), false, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, false);
|
||||
|
||||
for (u32 i = 0; i < num_color_inputs; i++)
|
||||
ss << qualifier << "in float4 v_col" << i << ";\n";
|
||||
|
@ -473,8 +476,7 @@ void ShaderGen::DeclareFragmentEntryPoint(
|
|||
}
|
||||
else
|
||||
{
|
||||
const char* qualifier =
|
||||
GetInterpolationQualifier(false, false, false, centroid_interpolation, sample_interpolation);
|
||||
const char* qualifier = GetInterpolationQualifier(false, centroid_interpolation, sample_interpolation, false);
|
||||
|
||||
ss << "void main(\n";
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ public:
|
|||
protected:
|
||||
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 DefineMacro(std::stringstream& ss, const char* name, bool enabled);
|
||||
void WriteHeader(std::stringstream& ss);
|
||||
|
|
Loading…
Reference in New Issue