Use explicit attrib location when the extension is available.
It allows to enable it easily in GLES renderer. And we check if this extension is available anyway because it's needed for shadows, so we can use it for other shaders too.
This commit is contained in:
parent
d124c61e3c
commit
28d85d7ba3
@ -2,7 +2,7 @@ uniform mat4 ModelViewMatrix;
|
||||
uniform vec3 Position;
|
||||
uniform vec2 Size;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec2 Corner;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
|
@ -1,7 +1,7 @@
|
||||
uniform vec2 center;
|
||||
uniform vec2 size;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec2 Position;
|
||||
#else
|
||||
in vec2 Position;
|
||||
|
@ -3,7 +3,7 @@ uniform vec2 size;
|
||||
uniform vec2 texcenter;
|
||||
uniform vec2 texsize;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location=0) in vec2 Position;
|
||||
layout(location=3) in vec2 Texcoord;
|
||||
layout(location=2) in uvec4 Color;
|
||||
|
@ -1,6 +1,6 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location=0) in vec3 Position;
|
||||
layout(location = 1) in float lifetime;
|
||||
layout(location = 2) in float size;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
|
@ -2,7 +2,7 @@ uniform vec3 windDir;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,6 +1,6 @@
|
||||
uniform vec3 windDir;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,7 +1,7 @@
|
||||
uniform int layer;
|
||||
|
||||
uniform vec3 windDir;
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,6 +1,6 @@
|
||||
uniform int layer;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,6 +1,6 @@
|
||||
uniform int layer;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec4 Data1;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
|
@ -17,7 +17,7 @@ uniform mat4 InverseModelMatrix =
|
||||
uniform vec2 texture_trans = vec2(0., 0.);
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,7 +1,7 @@
|
||||
uniform vec3 color_from;
|
||||
uniform vec3 color_to;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location=0) in vec3 Position;
|
||||
layout(location = 1) in float lifetime;
|
||||
layout(location = 2) in float size;
|
||||
|
@ -9,7 +9,7 @@ uniform float track_x_len;
|
||||
uniform float track_z_len;
|
||||
uniform samplerBuffer heightmap;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout (location = 4) in vec3 particle_position_initial;
|
||||
layout (location = 5) in float lifetime_initial;
|
||||
layout (location = 6) in vec3 particle_velocity_initial;
|
||||
|
@ -4,7 +4,7 @@ uniform mat4 sourcematrix;
|
||||
uniform int level;
|
||||
uniform float size_increase_factor;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout (location = 4) in vec3 particle_position_initial;
|
||||
layout (location = 5) in float lifetime_initial;
|
||||
layout (location = 6) in vec3 particle_velocity_initial;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -2,7 +2,7 @@ uniform mat4 ModelMatrix;
|
||||
uniform mat4 RSMMatrix;
|
||||
uniform vec2 texture_trans = vec2(0., 0.);
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec2 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
|
@ -1,7 +1,7 @@
|
||||
uniform int layer;
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
|
@ -2,7 +2,7 @@ uniform int layer;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform vec3 windDir;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
@ -18,7 +18,7 @@ uniform vec2 texture_trans = vec2(0., 0.);
|
||||
#endif
|
||||
uniform int skinning_offset;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
|
@ -2,7 +2,7 @@ uniform mat4 ModelMatrix;
|
||||
uniform int skinning_offset;
|
||||
uniform int layer;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec4 Data1;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
#else
|
||||
in vec3 Position;
|
||||
|
@ -3,7 +3,7 @@ uniform vec2 size;
|
||||
uniform vec2 texcenter;
|
||||
uniform vec2 texsize;
|
||||
|
||||
#if __VERSION__ >= 330
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location=0) in vec2 Position;
|
||||
layout(location=3) in vec2 Texcoord;
|
||||
#else
|
||||
|
@ -239,6 +239,12 @@ void CentralVideoSettings::init()
|
||||
hasTextureSwizzle = true;
|
||||
}
|
||||
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_EXPLICIT_ATTRIB_LOCATION)
|
||||
{
|
||||
Log::info("GLDriver", "Explicit Attrib Location Present");
|
||||
hasExplicitAttribLocation = true;
|
||||
}
|
||||
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_TEXTURE_FORMAT_BGRA8888) &&
|
||||
(hasGLExtension("GL_IMG_texture_format_BGRA8888") ||
|
||||
hasGLExtension("GL_EXT_texture_format_BGRA8888")))
|
||||
|
@ -42,7 +42,7 @@ int ShaderBase::loadTFBProgram(const std::string &shader_name,
|
||||
#ifdef USE_GLES2
|
||||
loadAndAttachShader(GL_FRAGMENT_SHADER, "tfb_dummy.frag");
|
||||
#endif
|
||||
if (CVS->getGLSLVersion() < 330)
|
||||
if (!CVS->isARBExplicitAttribLocationUsable())
|
||||
setAttribute(PARTICLES_SIM);
|
||||
|
||||
glTransformFeedbackVaryings(m_program, varying_count, varyings,
|
||||
|
@ -349,7 +349,7 @@ public:
|
||||
{
|
||||
m_program = glCreateProgram();
|
||||
loadAndAttachShader(args...);
|
||||
if (CVS->getGLSLVersion() < 330)
|
||||
if (!CVS->isARBExplicitAttribLocationUsable())
|
||||
setAttribute(type);
|
||||
glLinkProgram(m_program);
|
||||
|
||||
|
@ -89,7 +89,10 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
|
||||
code << "#extension GL_AMD_vertex_shader_layer : enable\n";
|
||||
|
||||
if (CVS->isARBExplicitAttribLocationUsable())
|
||||
{
|
||||
code << "#extension GL_ARB_explicit_attrib_location : enable\n";
|
||||
code << "#define Explicit_Attrib_Location_Usable\n";
|
||||
}
|
||||
|
||||
if (CVS->isAZDOEnabled())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user