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;
|
||||
@ -11,4 +11,4 @@ in vec2 Position;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position * size + center, 0., 1.);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -40,14 +40,14 @@ void main(void)
|
||||
{
|
||||
float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial;
|
||||
float coeff = dt_from_last_frame / float(dt);
|
||||
|
||||
|
||||
vec4 previous_frame_position = previous_frame_sourcematrix * vec4(particle_position_initial, 1.0);
|
||||
vec4 current_frame_position = sourcematrix * vec4(particle_position_initial, 1.0);
|
||||
|
||||
|
||||
vec4 updated_initialposition = mix(current_frame_position,
|
||||
previous_frame_position,
|
||||
coeff);
|
||||
|
||||
|
||||
vec4 updated_initial_velocity = mix(sourcematrix * vec4(particle_velocity_initial, 0.0),
|
||||
previous_frame_sourcematrix * vec4(particle_velocity_initial, 0.0),
|
||||
coeff);
|
||||
@ -56,12 +56,12 @@ void main(void)
|
||||
//But the simple formula ( (current_frame_position - previous_frame_position) / dt ) with a constant speed
|
||||
//between 2 frames creates visual artifacts when the framerate is low, and a more accurate formula would need
|
||||
//more complex computations.
|
||||
|
||||
|
||||
new_particle_position = updated_initialposition.xyz + dt_from_last_frame * updated_initial_velocity.xyz;
|
||||
new_particle_velocity = updated_initial_velocity.xyz;
|
||||
|
||||
|
||||
new_lifetime = fract(updated_lifetime);
|
||||
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
|
||||
new_size = mix(size_initial, size_initial * size_increase_factor, fract(updated_lifetime));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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
|
||||
@ -17,4 +17,4 @@ void main()
|
||||
{
|
||||
uv = Texcoord * texsize + texcenter;
|
||||
gl_Position = vec4(Position * size + center, 0., 1.);
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +238,12 @@ void CentralVideoSettings::init()
|
||||
hasTextureStorage = true;
|
||||
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") ||
|
||||
|
@ -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,
|
||||
@ -74,7 +74,7 @@ void ShaderBase::bypassUBO() const
|
||||
|
||||
GLint PM = glGetUniformLocation(m_program, "ProjectionMatrix");
|
||||
glUniformMatrix4fv(PM, 1, GL_FALSE, irr_driver->getProjMatrix().pointer());
|
||||
|
||||
|
||||
GLint PVM = glGetUniformLocation(m_program, "ProjectionViewMatrix");
|
||||
glUniformMatrix4fv(PVM, 1, GL_FALSE, irr_driver->getProjViewMatrix().pointer());
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/** A simple non-templated base class. It is used to store some enums used in
|
||||
/** A simple non-templated base class. It is used to store some enums used in
|
||||
* templates, the actual header for a shader, and a statis list of all kill
|
||||
* functions (which delete all singletons, and therefore forces a reload of all
|
||||
* shaders).
|
||||
@ -301,7 +301,7 @@ public:
|
||||
* \param index Index of the texture.
|
||||
* \param uniform Uniform name.
|
||||
*/
|
||||
template<typename... T1>
|
||||
template<typename... T1>
|
||||
void assignTextureUnit(GLuint index, const char* uniform, T1... rest)
|
||||
{
|
||||
glUseProgram(m_program);
|
||||
@ -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…
Reference in New Issue
Block a user