mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #240 from Sonicadvance1/GLSLES310_binding
Add initial support for GLSL ES 3.10.
This commit is contained in:
commit
13119e6755
@ -2,6 +2,8 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
||||
@ -36,13 +38,33 @@ UidChecker<VertexShaderUid,VertexShaderCode> ProgramShaderCache::vertex_uid_chec
|
||||
|
||||
static char s_glsl_header[1024] = "";
|
||||
|
||||
std::string GetGLSLVersionString()
|
||||
{
|
||||
GLSL_VERSION v = g_ogl_config.eSupportedGLSLVersion;
|
||||
switch(v)
|
||||
{
|
||||
case GLSLES_300:
|
||||
return "#version 300 es";
|
||||
case GLSLES_310:
|
||||
return "#version 310 es";
|
||||
case GLSL_130:
|
||||
return "#version 130";
|
||||
case GLSL_140:
|
||||
return "#version 140";
|
||||
case GLSL_150:
|
||||
return "#version 150";
|
||||
}
|
||||
// Shouldn't ever hit this
|
||||
return "#version ERROR";
|
||||
}
|
||||
|
||||
void SHADER::SetProgramVariables()
|
||||
{
|
||||
// glsl shader must be bind to set samplers
|
||||
Bind();
|
||||
|
||||
// Bind UBO
|
||||
if (!g_ActiveConfig.backend_info.bSupportShadingLanguage420pack)
|
||||
if (!g_ActiveConfig.backend_info.bSupportsBindingLayout)
|
||||
{
|
||||
GLint PSBlock_id = glGetUniformBlockIndex(glprogid, "PSBlock");
|
||||
GLint VSBlock_id = glGetUniformBlockIndex(glprogid, "VSBlock");
|
||||
@ -455,7 +477,7 @@ void ProgramShaderCache::CreateHeader ( void )
|
||||
"%s\n" // early-z
|
||||
"%s\n" // 420pack
|
||||
|
||||
// Precision defines for GLSLES3
|
||||
// Precision defines for GLSL ES
|
||||
"%s\n"
|
||||
"%s\n"
|
||||
|
||||
@ -478,13 +500,13 @@ void ProgramShaderCache::CreateHeader ( void )
|
||||
"%s\n" // replace textureSize as constant
|
||||
"%s\n" // wipe out all centroid usages
|
||||
|
||||
, v==GLSLES3 ? "#version 300 es" : v==GLSL_130 ? "#version 130" : v==GLSL_140 ? "#version 140" : "#version 150"
|
||||
, GetGLSLVersionString().c_str()
|
||||
, v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
||||
, g_ActiveConfig.backend_info.bSupportsEarlyZ ? "#extension GL_ARB_shader_image_load_store : enable" : ""
|
||||
, g_ActiveConfig.backend_info.bSupportShadingLanguage420pack ? "#extension GL_ARB_shading_language_420pack : enable" : ""
|
||||
, (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GLSLES_310) ? "#extension GL_ARB_shading_language_420pack : enable" : ""
|
||||
|
||||
, v==GLSLES3 ? "precision highp float;" : ""
|
||||
, v==GLSLES3 ? "precision highp int;" : ""
|
||||
, v>=GLSLES_300 ? "precision highp float;" : ""
|
||||
, v>=GLSLES_300 ? "precision highp int;" : ""
|
||||
|
||||
, DriverDetails::HasBug(DriverDetails::BUG_BROKENTEXTURESIZE) ? "#define textureSize(x, y) ivec2(1, 1)" : ""
|
||||
, DriverDetails::HasBug(DriverDetails::BUG_BROKENCENTROID) ? "#define centroid" : ""
|
||||
|
@ -459,7 +459,10 @@ Renderer::Renderer()
|
||||
g_Config.backend_info.bSupportsPrimitiveRestart = !DriverDetails::HasBug(DriverDetails::BUG_PRIMITIVERESTART) &&
|
||||
((GLExtensions::Version() >= 310) || GLExtensions::Supports("GL_NV_primitive_restart"));
|
||||
g_Config.backend_info.bSupportsEarlyZ = GLExtensions::Supports("GL_ARB_shader_image_load_store");
|
||||
g_Config.backend_info.bSupportShadingLanguage420pack = GLExtensions::Supports("GL_ARB_shading_language_420pack");
|
||||
|
||||
// Desktop OpenGL supports the binding layout if it supports 420pack
|
||||
// OpenGL ES 3.1 supports it implicitly without an extension
|
||||
g_Config.backend_info.bSupportsBindingLayout = GLExtensions::Supports("GL_ARB_shading_language_420pack");
|
||||
|
||||
g_ogl_config.bSupportsGLSLCache = GLExtensions::Supports("GL_ARB_get_program_binary");
|
||||
g_ogl_config.bSupportsGLPinnedMemory = GLExtensions::Supports("GL_AMD_pinned_memory");
|
||||
@ -472,7 +475,17 @@ Renderer::Renderer()
|
||||
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
|
||||
|
||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3)
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSLES3;
|
||||
{
|
||||
if (strstr(g_ogl_config.glsl_version, "3.00"))
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSLES_300;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSLES_310;
|
||||
g_Config.backend_info.bSupportsBindingLayout = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strstr(g_ogl_config.glsl_version, "1.00") || strstr(g_ogl_config.glsl_version, "1.10") || strstr(g_ogl_config.glsl_version, "1.20"))
|
||||
|
@ -11,8 +11,9 @@ void ClearEFBCache();
|
||||
enum GLSL_VERSION {
|
||||
GLSL_130,
|
||||
GLSL_140,
|
||||
GLSL_150, // and above
|
||||
GLSLES3
|
||||
GLSL_150, // and above
|
||||
GLSLES_300, // GLES 3.0
|
||||
GLSLES_310, // GLES 3.1
|
||||
};
|
||||
|
||||
// ogl-only config, so not in VideoConfig.h
|
||||
|
@ -223,7 +223,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
|
||||
out.Write("\n");
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
out.Write("layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportShadingLanguage420pack ? ", binding = 1" : "");
|
||||
out.Write("layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 1" : "");
|
||||
|
||||
DeclareUniform(out, ApiType, C_COLORS, "int4", I_COLORS"[4]");
|
||||
DeclareUniform(out, ApiType, C_KCOLORS, "int4", I_KCOLORS"[4]");
|
||||
|
@ -83,7 +83,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
|
||||
// uniforms
|
||||
if (api_type == API_OPENGL)
|
||||
out.Write("layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportShadingLanguage420pack ? ", binding = 2" : "");
|
||||
out.Write("layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 2" : "");
|
||||
|
||||
DeclareUniform(out, api_type, C_POSNORMALMATRIX, "float4", I_POSNORMALMATRIX"[6]");
|
||||
DeclareUniform(out, api_type, C_PROJECTION, "float4", I_PROJECTION"[4]");
|
||||
|
@ -152,7 +152,7 @@ struct VideoConfig final
|
||||
bool bSupportsSeparateAlphaFunction;
|
||||
bool bSupportsOversizedViewports;
|
||||
bool bSupportsEarlyZ; // needed by PixelShaderGen, so must stay in VideoCommon
|
||||
bool bSupportShadingLanguage420pack; // needed by ShaderGen, so must stay in VideoCommon
|
||||
bool bSupportsBindingLayout; // Needed by ShaderGen, so must stay in VideoCommon
|
||||
} backend_info;
|
||||
|
||||
// Utility
|
||||
|
Loading…
Reference in New Issue
Block a user