Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2014-08-23 09:50:39 +10:00
commit 5b633f0487
27 changed files with 393 additions and 135 deletions

View File

@ -1,5 +1,10 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D Detail;
#else
uniform sampler2D Albedo;
uniform sampler2D Detail;
#endif
#if __VERSION__ >= 130
in vec2 uv;
@ -16,6 +21,9 @@ vec3 getLightFactor(float specMapValue);
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
color.xyz = pow(color.xyz, vec3(2.2));
#endif
vec4 detail = texture(Detail, uv_bis);
color *= detail;
vec3 LightFactor = getLightFactor(1. - color.a);

View File

@ -1,6 +1,12 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D dtex;
#else
uniform sampler2D Albedo;
uniform vec3 SunDir;
uniform sampler2D dtex;
#endif
uniform vec3 SunDir;
in vec3 nor;
in vec2 uv;
@ -26,6 +32,9 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
color.xyz = pow(color.xyz, vec3(2.2));
#endif
if (color.a < 0.5) discard;
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
FragColor = vec4(color.xyz * LightFactor, 1.);

View File

@ -14,4 +14,4 @@ layout (std140) uniform MatrixesData
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
#endif

View File

@ -1,5 +1,10 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D normalMap;
layout(bindless_sampler) uniform sampler2D DiffuseForAlpha;
#else
uniform sampler2D normalMap;
uniform sampler2D DiffuseForAlpha;
#endif
in vec3 tangent;
in vec3 bitangent;

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
#else
uniform sampler2D Albedo;
#endif
in vec2 uv;
in vec4 color;
@ -8,7 +12,11 @@ vec3 getLightFactor(float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = pow(texture(Albedo, uv), vec4(2.2));
#else
vec4 col = texture(Albedo, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(col.xyz * LightFactor, 1.);

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
@ -7,6 +11,9 @@ out vec4 FragColor;
void main(void)
{
vec4 col = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
col.xyz = pow(col.xyz, vec3(2.2));
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard;
FragColor = vec4(col.xyz, 1.);

View File

@ -1,6 +1,10 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;
@ -21,6 +25,9 @@ void main() {
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
r.y = - r.y;
vec4 detail0 = texture(tex, r.xy / m + .5);
#ifdef GL_ARB_bindless_texture
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(detail0.xyz * LightFactor, 1.);

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
#else
uniform sampler2D Albedo;
#endif
in vec2 uv;
in vec4 color;
@ -9,6 +13,9 @@ vec3 getLightFactor(float specMapValue);
void main(void)
{
vec4 col = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
col.xyz = pow(col.xyz, vec3(2.2));
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
vec3 LightFactor = getLightFactor(1.);

View File

@ -1,8 +1,16 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex_layout;
layout(bindless_sampler) uniform sampler2D tex_detail0;
layout(bindless_sampler) uniform sampler2D tex_detail1;
layout(bindless_sampler) uniform sampler2D tex_detail2;
layout(bindless_sampler) uniform sampler2D tex_detail3;
#else
uniform sampler2D tex_layout;
uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1;
uniform sampler2D tex_detail2;
uniform sampler2D tex_detail3;
#endif
#if __VERSION__ >= 130
in vec2 uv;
@ -24,6 +32,12 @@ void main() {
vec4 detail2 = texture(tex_detail2, uv);
vec4 detail3 = texture(tex_detail3, uv);
vec4 detail4 = vec4(0.0);
#ifdef GL_ARB_bindless_texture
detail0.xyz = pow(detail0.xyz, vec3(2.2));
detail1.xyz = pow(detail1.xyz, vec3(2.2));
detail2.xyz = pow(detail2.xyz, vec3(2.2));
detail3.xyz = pow(detail3.xyz, vec3(2.2));
#endif
vec4 splatted = splatting.r * detail0 +
splatting.g * detail1 +

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
@ -8,6 +12,9 @@ out vec4 FragColor;
void main()
{
vec4 Color = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
Color.xyz = pow(Color.xyz, vec3(2.2));
#endif
Color.xyz *= pow(color.xyz, vec3(2.2));
Color.a *= color.a;
// Premultiply alpha

View File

@ -1,4 +1,9 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
uniform float fogmax;
uniform float startH;
@ -15,6 +20,9 @@ out vec4 FragColor;
void main()
{
vec4 diffusecolor = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
#endif
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));
diffusecolor.a *= color.a;
vec3 tmp = vec3(gl_FragCoord.xy / screen, gl_FragCoord.z);

View File

@ -1,6 +1,12 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D DiffuseMap;
layout(bindless_sampler) uniform sampler2D SpecularMap;
layout(bindless_sampler) uniform sampler2D SSAO;
#else
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
#endif
vec3 getLightFactor(float specMapValue)
{

View File

@ -464,6 +464,9 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_gi
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_gi",
&m_video_group, "Enable Global Illumination"));
PARAM_PREFIX BoolUserConfigParam m_bindless_textures
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_bindless_textures",
&m_video_group, "Enable Bindless Texture (Experimental !)"));
// ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */

View File

@ -72,6 +72,8 @@ extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glDrawElementsInstancedBaseVertexBaseInstance;
extern PFNGLMULTIDRAWELEMENTSINDIRECTPROC glMultiDrawElementsIndirect;
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
@ -80,6 +82,9 @@ extern PFNGLTEXBUFFERPROC glTexBuffer;
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
extern PFNGLMAPBUFFERPROC glMapBuffer;
extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange;
extern PFNGLMEMORYBARRIERPROC glMemoryBarrier;
extern PFNGLBUFFERSTORAGEPROC glBufferStorage;
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
extern PFNGLFENCESYNCPROC glFenceSync;
extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
@ -109,9 +114,20 @@ extern PFNGLDELETESAMPLERSPROC glDeleteSamplers;
extern PFNGLBINDSAMPLERPROC glBindSampler;
extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
extern PFNGLGETTEXTURESAMPLERHANDLEARBPROC glGetTextureSamplerHandleARB;
extern PFNGLMAKETEXTUREHANDLERESIDENTARBPROC glMakeTextureHandleResidentARB;
extern PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC glMakeTextureHandleNonResidentARB;
extern PFNGLUNIFORMHANDLEUI64ARBPROC glUniformHandleui64ARB;
extern PFNGLISTEXTUREHANDLERESIDENTARBPROC glIsTextureHandleResidentARB;
extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer;
#ifdef DEBUG
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#endif
#endif
#ifdef WIN32
#define Bindless_Texture_Support
#endif
#endif

View File

@ -52,6 +52,8 @@ PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glDrawElementsInstancedBaseVertexBaseInstance;
PFNGLMULTIDRAWELEMENTSINDIRECTPROC glMultiDrawElementsIndirect;
PFNGLDELETEBUFFERSPROC glDeleteBuffers;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
@ -60,6 +62,9 @@ PFNGLTEXBUFFERPROC glTexBuffer;
PFNGLBUFFERSUBDATAPROC glBufferSubData;
PFNGLMAPBUFFERPROC glMapBuffer;
PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange;
PFNGLMEMORYBARRIERPROC glMemoryBarrier;
PFNGLBUFFERSTORAGEPROC glBufferStorage;
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLFENCESYNCPROC glFenceSync;
PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
@ -91,6 +96,12 @@ PFNGLBINDSAMPLERPROC glBindSampler;
PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
PFNGLGETSTRINGIPROC glGetStringi;
PFNGLGETTEXTURESAMPLERHANDLEARBPROC glGetTextureSamplerHandleARB;
PFNGLMAKETEXTUREHANDLERESIDENTARBPROC glMakeTextureHandleResidentARB;
PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC glMakeTextureHandleNonResidentARB;
PFNGLUNIFORMHANDLEUI64ARBPROC glUniformHandleui64ARB;
PFNGLISTEXTUREHANDLERESIDENTARBPROC glIsTextureHandleResidentARB;
PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer;
#endif
static bool is_gl_init = false;
@ -192,6 +203,9 @@ void initGL()
glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData");
glMapBuffer = (PFNGLMAPBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glMapBuffer");
glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)IRR_OGL_LOAD_EXTENSION("glMapBufferRange");
glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)IRR_OGL_LOAD_EXTENSION("glFlushMappedBufferRange");
glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)IRR_OGL_LOAD_EXTENSION("glMemoryBarrier");
glBufferStorage = (PFNGLBUFFERSTORAGEPROC)IRR_OGL_LOAD_EXTENSION("glBufferStorage");
glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glUnmapBuffer");
glFenceSync = (PFNGLFENCESYNCPROC)IRR_OGL_LOAD_EXTENSION("glFenceSync");
glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)IRR_OGL_LOAD_EXTENSION("glClientWaitSync");
@ -229,6 +243,8 @@ void initGL()
glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)IRR_OGL_LOAD_EXTENSION("glDrawElementsBaseVertex");
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawElementsInstanced");
glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)IRR_OGL_LOAD_EXTENSION("glDrawElementsInstancedBaseVertex");
glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)IRR_OGL_LOAD_EXTENSION("glDrawElementsInstancedBaseVertexBaseInstance");
glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)IRR_OGL_LOAD_EXTENSION("glMultiDrawElementsIndirect");
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers");
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays");
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray");
@ -264,6 +280,12 @@ void initGL()
glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)IRR_OGL_LOAD_EXTENSION("glSamplerParameterf");
glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)IRR_OGL_LOAD_EXTENSION("glSamplerParameteri");
glGetStringi = (PFNGLGETSTRINGIPROC)IRR_OGL_LOAD_EXTENSION("glGetstringi");
glGetTextureSamplerHandleARB = (PFNGLGETTEXTURESAMPLERHANDLEARBPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureSamplerHandleARB");
glMakeTextureHandleResidentARB = (PFNGLMAKETEXTUREHANDLERESIDENTARBPROC)IRR_OGL_LOAD_EXTENSION("glMakeTextureHandleResidentARB");
glMakeTextureHandleNonResidentARB = (PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC)IRR_OGL_LOAD_EXTENSION("glMakeTextureHandleNonResidentARB");
glUniformHandleui64ARB = (PFNGLUNIFORMHANDLEUI64ARBPROC)IRR_OGL_LOAD_EXTENSION("glUniformHandleui64ARB");
glIsTextureHandleResidentARB = (PFNGLISTEXTUREHANDLERESIDENTARBPROC)IRR_OGL_LOAD_EXTENSION("glIsTextureHandleResidentARB");
glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribLPointer");
#ifdef DEBUG
glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB");
#endif
@ -297,6 +319,13 @@ GLuint LoadShader(const char * file, unsigned type)
char versionString[20];
sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion());
std::string Code = versionString;
if (UserConfigParams::m_bindless_textures)
Code += "#extension GL_ARB_bindless_texture : enable\n";
else
{
Code += "#extension GL_ARB_bindless_texture : disable\n";
Code += "#undef GL_ARB_bindless_texture\n";
}
std::ifstream Stream(file, std::ios::in);
Code += "//" + std::string(file) + "\n";
if (irr_driver->needUBOWorkaround())

View File

@ -123,13 +123,25 @@ void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
for (unsigned i = 0; i < meshes->size(); i++)
{
std::vector<GLuint> Textures;
std::vector<uint64_t> Handles;
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
for (unsigned j = 0; j < TexUnits.size(); j++)
{
if (!mesh.textures[j])
if (!mesh.textures[TexUnits[j].m_id])
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(mesh.textures[j], TexUnits[j].m_premul_alpha);
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
compressTexture(mesh.textures[TexUnits[j].m_id], TexUnits[j].m_premul_alpha);
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[TexUnits[j].m_id])
mesh.TextureHandles[TexUnits[j].m_id] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[TexUnits[j].m_id]), Shader::getInstance()->SamplersId[j]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]);
#endif
Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]);
}
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
}
if (mesh.VAOType != VertexType)
{
@ -138,7 +150,11 @@ void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
#endif
continue;
}
Shader::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
Shader::getInstance()->SetTextureHandles(Handles);
else
Shader::getInstance()->SetTextureUnits(Textures);
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
}
}
@ -180,6 +196,7 @@ void renderInstancedMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vec
glUseProgram(Shader::getInstance()->Program);
for (unsigned i = 0; i < meshes->size(); i++)
{
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
#ifdef DEBUG
@ -192,9 +209,23 @@ void renderInstancedMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vec
if (!mesh.textures[TexUnits[j].m_id])
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(mesh.textures[TexUnits[j].m_id], TexUnits[j].m_premul_alpha);
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[TexUnits[j].m_id])
mesh.TextureHandles[TexUnits[j].m_id] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[TexUnits[j].m_id]), Shader::getInstance()->SamplersId[j]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]);
#endif
Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]);
}
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
}
Shader::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
Shader::getInstance()->SetTextureHandles(Handles);
else
Shader::getInstance()->SetTextureUnits(Textures);
instanced_custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
}
}
@ -291,21 +322,34 @@ void IrrDriver::renderSolidFirstPass()
}
template<typename Shader, enum E_VERTEX_TYPE VertexType, int...List, typename... TupleType>
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes, const std::vector<uint64_t> &Prefilled_Handle,
const std::vector<GLuint> &Prefilled_Tex)
{
glUseProgram(Shader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType));
for (unsigned i = 0; i < meshes->size(); i++)
{
std::vector<GLuint> Textures;
std::vector<uint64_t> Handles(Prefilled_Handle);
std::vector<GLuint> Textures(Prefilled_Tex);
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
for (unsigned j = 0; j < TexUnits.size(); j++)
{
if (!mesh.textures[TexUnits[j].m_id])
mesh.textures[TexUnits[j].m_id] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(mesh.textures[TexUnits[j].m_id], TexUnits[j].m_premul_alpha);
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
if (irr_driver->getLightViz())
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[TexUnits[j].m_id])
mesh.TextureHandles[TexUnits[j].m_id] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[TexUnits[j].m_id]), Shader::getInstance()->SamplersId[Handles.size()]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]);
Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]);
#endif
}
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
/* if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
@ -314,7 +358,7 @@ void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
}*/
}
if (mesh.VAOType != VertexType)
@ -324,27 +368,44 @@ void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::
#endif
continue;
}
Shader::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
Shader::getInstance()->SetTextureHandles(Handles);
else
Shader::getInstance()->SetTextureUnits(Textures);
custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
}
}
template<typename Shader, int...List, typename... TupleType>
void renderInstancedMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
void renderInstancedMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes, const std::vector<uint64_t> &Prefilled_Handles,
const std::vector<GLuint> &Prefilled_tex)
{
glUseProgram(Shader::getInstance()->Program);
for (unsigned i = 0; i < meshes->size(); i++)
{
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
glBindVertexArray(mesh.vao);
std::vector<GLuint> Textures;
std::vector<GLuint> Textures(Prefilled_tex);
std::vector<uint64_t> Handles(Prefilled_Handles);
for (unsigned j = 0; j < TexUnits.size(); j++)
{
if (!mesh.textures[TexUnits[j].m_id])
mesh.textures[TexUnits[j].m_id] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
compressTexture(mesh.textures[TexUnits[j].m_id], TexUnits[j].m_premul_alpha);
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
if (irr_driver->getLightViz())
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[TexUnits[j].m_id])
mesh.TextureHandles[TexUnits[j].m_id] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[TexUnits[j].m_id]), Shader::getInstance()->SamplersId[Handles.size()]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]);
#endif
if (UserConfigParams::m_bindless_textures)
Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]);
else
Textures.push_back(getTextureGLuint(mesh.textures[TexUnits[j].m_id]));
/* if (irr_driver->getLightViz())
{
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
@ -353,9 +414,14 @@ void renderInstancedMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vec
{
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
}
}*/
}
Shader::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
Shader::getInstance()->SetTextureHandles(Handles);
else
Shader::getInstance()->SetTextureUnits(Textures);
instanced_custom_unroll_args<List...>::template exec(Shader::getInstance(), meshes->at(i));
}
}
@ -382,64 +448,74 @@ void IrrDriver::renderSolidSecondPass()
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
#ifdef GL_VERSION_3_3
if (irr_driver->getGLSLVersion() >= 330)
glBindSampler(0, 0);
uint64_t DiffuseHandle = 0, SpecularHandle = 0, SSAOHandle = 0, DepthHandle = 0;
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
glMakeTextureHandleResidentARB(DiffuseHandle);
SpecularHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[1]);
if (!glIsTextureHandleResidentARB(SpecularHandle))
glMakeTextureHandleResidentARB(SpecularHandle);
SSAOHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[2]);
if (!glIsTextureHandleResidentARB(SSAOHandle))
glMakeTextureHandleResidentARB(SSAOHandle);
DepthHandle = glGetTextureSamplerHandleARB(getDepthStencilTexture(), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[3]);
if (!glIsTextureHandleResidentARB(DepthHandle))
glMakeTextureHandleResidentARB(DepthHandle);
#endif
setTexture(0, m_rtts->getRenderTarget(RTT_DIFFUSE), GL_NEAREST, GL_NEAREST);
#ifdef GL_VERSION_3_3
if (irr_driver->getGLSLVersion() >= 330)
glBindSampler(1, 0);
#endif
setTexture(1, m_rtts->getRenderTarget(RTT_SPECULAR), GL_NEAREST, GL_NEAREST);
#ifdef GL_VERSION_3_3
if (irr_driver->getGLSLVersion() >= 330)
glBindSampler(2, 0);
#endif
setTexture(2, m_rtts->getRenderTarget(RTT_HALF1_R), GL_LINEAR, GL_LINEAR);
}
{
ScopedGPUTimer Timer(getGPUTimer(Q_SOLID_PASS2));
m_scene_manager->drawAll(scene::ESNRP_SOLID);
std::vector<GLuint> DiffSpecSSAOTex = createVector<GLuint>(m_rtts->getRenderTarget(RTT_DIFFUSE), m_rtts->getRenderTarget(RTT_SPECULAR), m_rtts->getRenderTarget(RTT_HALF1_R));
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 3, 1>(TexUnits(
TexUnit(0, true)
), ListMatDefault::getInstance());
), ListMatDefault::getInstance(),
createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 3, 1>(TexUnits(
TexUnit(0, true)
), AnimatedListMatDefault::getInstance());
), AnimatedListMatDefault::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 3, 1 >(TexUnits(
TexUnit(0, true)
), ListMatAlphaRef::getInstance());
), ListMatAlphaRef::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 3, 1 >(TexUnits(
TexUnit(0, true)
), AnimatedListMatAlphaRef::getInstance());
), AnimatedListMatAlphaRef::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 2, 1>(TexUnits(
TexUnit(0, true)
), ListMatSphereMap::getInstance());
), ListMatSphereMap::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 1>(TexUnits(
TexUnit(0, true),
TexUnit(1, true)
), ListMatDetails::getInstance());
), ListMatDetails::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 1>(TexUnits(
TexUnit(0, true),
TexUnit(1, true)
), AnimatedListMatDetails::getInstance());
), AnimatedListMatDetails::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 3, 1>(TexUnits(
TexUnit(0, true)
), ListMatGrass::getInstance());
), ListMatGrass::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 3, 1>(TexUnits(
TexUnit(0, true)
), ListMatUnlit::getInstance());
), ListMatUnlit::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 3, 1>(TexUnits(
TexUnit(0, true)
), AnimatedListMatUnlit::getInstance());
), AnimatedListMatUnlit::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 1>(TexUnits(
TexUnit(1, false),
@ -447,26 +523,25 @@ void IrrDriver::renderSolidSecondPass()
TexUnit(3, true),
TexUnit(4, true),
TexUnit(5, true)
), ListMatSplatting::getInstance());
), ListMatSplatting::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 3, 1>(TexUnits(
TexUnit(0, true)
), ListMatNormalMap::getInstance());
), ListMatNormalMap::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectPass2Shader>(
TexUnits(TexUnit(0, true)),
ListInstancedMatDefault::getInstance());
ListInstancedMatDefault::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectPass2Shader>(
TexUnits(TexUnit(0, true)),
ListInstancedMatNormalMap::getInstance());
ListInstancedMatNormalMap::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<MeshShader::InstancedObjectRefPass2Shader>(
TexUnits(TexUnit(0, true)),
ListInstancedMatAlphaRef::getInstance());
setTexture(4, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
ListInstancedMatAlphaRef::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
DiffSpecSSAOTex.push_back(irr_driver->getDepthStencilTexture());
renderInstancedMeshes2ndPass<MeshShader::InstancedGrassPass2Shader, 3, 2>(
TexUnits(TexUnit(0, true)),
ListInstancedMatGrass::getInstance());
ListInstancedMatGrass::getInstance(), createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle), DiffSpecSSAOTex);
}
m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
@ -504,8 +579,6 @@ void IrrDriver::renderNormalsVisualisation()
}
static video::ITexture *displaceTex = 0;
void IrrDriver::renderTransparent()
@ -531,22 +604,22 @@ void IrrDriver::renderTransparent()
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
TexUnit(0, true)
), ListBlendTransparentFog::getInstance());
), ListBlendTransparentFog::getInstance(), createVector<uint64_t>(), createVector<GLuint>());
glBlendFunc(GL_ONE, GL_ONE);
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
TexUnit(0, true)
), ListAdditiveTransparentFog::getInstance());
), ListAdditiveTransparentFog::getInstance(), createVector<uint64_t>(), createVector<GLuint>());
}
else
{
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
TexUnit(0, true)
), ListBlendTransparent::getInstance());
), ListBlendTransparent::getInstance(), createVector<uint64_t>(), createVector<GLuint>());
glBlendFunc(GL_ONE, GL_ONE);
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
TexUnit(0, true)
), ListAdditiveTransparent::getInstance());
), ListAdditiveTransparent::getInstance(), createVector<uint64_t>(), createVector<GLuint>());
}
if (!UserConfigParams::m_dynamic_lights)
@ -671,14 +744,29 @@ void renderShadow(const std::vector<GLuint> TextureUnits, const std::vector<STK:
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType));
for (unsigned i = 0; i < t->size(); i++)
{
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
const GLMesh *mesh = STK::tuple_get<0>(t->at(i));
GLMesh *mesh = STK::tuple_get<0>(t->at(i));
for (unsigned j = 0; j < TextureUnits.size(); j++)
{
compressTexture(mesh->textures[TextureUnits[j]], true);
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]]));
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh->TextureHandles[TextureUnits[j]])
mesh->TextureHandles[TextureUnits[j]] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh->textures[TextureUnits[j]]), T::getInstance()->SamplersId[j]);
if (!glIsTextureHandleResidentARB(mesh->TextureHandles[TextureUnits[j]]))
glMakeTextureHandleResidentARB(mesh->TextureHandles[TextureUnits[j]]);
#endif
Handles.push_back(mesh->TextureHandles[TextureUnits[j]]);
}
else
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]]));
}
T::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
T::getInstance()->SetTextureHandles(Handles);
else
T::getInstance()->SetTextureUnits(Textures);
shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), t->at(i));
}
}
@ -720,15 +808,30 @@ void renderInstancedShadow(const std::vector<GLuint> TextureUnits, const std::ve
glUseProgram(T::getInstance()->Program);
for (unsigned i = 0; i < t->size(); i++)
{
std::vector<uint64_t> Handles;
std::vector<GLuint> Textures;
const GLMesh *mesh = STK::tuple_get<0>(t->at(i));
GLMesh *mesh = STK::tuple_get<0>(t->at(i));
glBindVertexArray(mesh->vao_shadow_pass);
for (unsigned j = 0; j < TextureUnits.size(); j++)
{
compressTexture(mesh->textures[TextureUnits[j]], true);
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]]));
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh->TextureHandles[TextureUnits[j]])
mesh->TextureHandles[TextureUnits[j]] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh->textures[TextureUnits[j]]), T::getInstance()->SamplersId[j]);
if (!glIsTextureHandleResidentARB(mesh->TextureHandles[TextureUnits[j]]))
glMakeTextureHandleResidentARB(mesh->TextureHandles[TextureUnits[j]]);
#endif
Handles.push_back(mesh->TextureHandles[TextureUnits[j]]);
}
else
Textures.push_back(getTextureGLuint(mesh->textures[TextureUnits[j]]));
}
T::getInstance()->SetTextureUnits(Textures);
if (UserConfigParams::m_bindless_textures)
T::getInstance()->SetTextureHandles(Handles);
else
T::getInstance()->SetTextureUnits(Textures);
instanced_shadow_custom_unroll_args<List...>::template exec<T>(T::getInstance(), t->at(i));
}
}

View File

@ -884,11 +884,7 @@ namespace MeshShader
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
}
InstancedObjectPass2Shader::InstancedObjectPass2Shader()
@ -900,12 +896,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
AssignUniforms();
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -921,12 +912,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
AssignUniforms();
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -942,11 +928,7 @@ namespace MeshShader
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo", 4, "Detail");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail");
}
ObjectUnlitShader::ObjectUnlitShader()
@ -959,7 +941,7 @@ namespace MeshShader
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
AssignSamplerNames(Program, 3, "tex");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
ObjectRefPass2Shader::ObjectRefPass2Shader()
@ -973,11 +955,7 @@ namespace MeshShader
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
}
GrassPass2Shader::GrassPass2Shader()
@ -988,11 +966,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
AssignUniforms("ModelMatrix", "windDir");
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo");
}
InstancedGrassPass2Shader::InstancedGrassPass2Shader()
@ -1004,15 +978,7 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
AssignUniforms("windDir", "SunDir");
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"),
TexUnit(4, "dtex")
);
AssignSamplerNames(Program, 3, "Albedo");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo");
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
@ -1030,11 +996,7 @@ namespace MeshShader
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program, 3, "tex");
AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "tex");
}
SplattingShader::SplattingShader()
@ -1045,11 +1007,10 @@ namespace MeshShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
AssignUniforms("ModelMatrix");
AssignTextureUnit(Program,
TexUnit(0, "DiffuseMap"),
TexUnit(1, "SpecularMap"),
TexUnit(2, "SSAO"));
AssignSamplerNames(Program,
0, "DiffuseMap",
1, "SpecularMap",
2, "SSAO",
3, "tex_layout",
4, "tex_detail0",
5, "tex_detail1",

View File

@ -395,15 +395,16 @@ private:
void AssignTextureNames_impl(GLuint Program, GLuint TexUnit, const char *name, Args...args...)
{
GLuint location = glGetUniformLocation(Program, name);
TextureLocation.push_back(location);
glUniform1i(location, TexUnit);
TextureUnits.push_back(TexUnit);
AssignTextureNames_impl<N + 1>(Program, args...);
}
protected:
std::vector<GLuint> SamplersId;
std::vector<GLuint> TextureUnits;
std::vector<GLenum> TextureType;
std::vector<GLenum> TextureLocation;
template<typename...Args>
void AssignSamplerNames(GLuint Program, Args...args)
{
@ -415,6 +416,7 @@ protected:
}
public:
std::vector<GLuint> SamplersId;
void SetTextureUnits(const std::vector<GLuint> &args)
{
assert(args.size() == sizeof...(tp) && "Too much texture unit provided");
@ -434,6 +436,16 @@ public:
for (unsigned i = 0; i < SamplersId.size(); i++)
glDeleteSamplers(1, &SamplersId[i]);
}
void SetTextureHandles(const std::vector<uint64_t> &args)
{
for (unsigned i = 0; i < args.size(); i++)
{
#ifdef Bindless_Texture_Support
glUniformHandleui64ARB(TextureLocation[i], args[i]);
#endif
}
}
};
namespace MeshShader
@ -486,61 +498,61 @@ public:
InstancedNormalMapShader();
};
class ObjectPass2Shader : public ShaderHelperSingleton<ObjectPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
class ObjectPass2Shader : public ShaderHelperSingleton<ObjectPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
ObjectPass2Shader();
};
class InstancedObjectPass2Shader : public ShaderHelperSingleton<InstancedObjectPass2Shader>, public TextureRead<Trilinear_Anisotropic_Filtered>
class InstancedObjectPass2Shader : public ShaderHelperSingleton<InstancedObjectPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedObjectPass2Shader();
};
class InstancedObjectRefPass2Shader : public ShaderHelperSingleton<InstancedObjectRefPass2Shader>, public TextureRead<Trilinear_Anisotropic_Filtered>
class InstancedObjectRefPass2Shader : public ShaderHelperSingleton<InstancedObjectRefPass2Shader>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedObjectRefPass2Shader();
};
class DetailledObjectPass2Shader : public ShaderHelperSingleton<DetailledObjectPass2Shader, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
class DetailledObjectPass2Shader : public ShaderHelperSingleton<DetailledObjectPass2Shader, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
DetailledObjectPass2Shader();
};
class ObjectUnlitShader : public ShaderHelperSingleton<ObjectUnlitShader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
class ObjectUnlitShader : public ShaderHelperSingleton<ObjectUnlitShader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
ObjectUnlitShader();
};
class ObjectRefPass2Shader : public ShaderHelperSingleton<ObjectRefPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
class ObjectRefPass2Shader : public ShaderHelperSingleton<ObjectRefPass2Shader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
ObjectRefPass2Shader();
};
class GrassPass2Shader : public ShaderHelperSingleton<GrassPass2Shader, core::matrix4, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered>
class GrassPass2Shader : public ShaderHelperSingleton<GrassPass2Shader, core::matrix4, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
GrassPass2Shader();
};
class InstancedGrassPass2Shader : public ShaderHelperSingleton<InstancedGrassPass2Shader, core::vector3df, core::vector3df>, public TextureRead<Trilinear_Anisotropic_Filtered>
class InstancedGrassPass2Shader : public ShaderHelperSingleton<InstancedGrassPass2Shader, core::vector3df, core::vector3df>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Nearest_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
InstancedGrassPass2Shader();
};
class SphereMapShader : public ShaderHelperSingleton<SphereMapShader, core::matrix4, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered>
class SphereMapShader : public ShaderHelperSingleton<SphereMapShader, core::matrix4, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
SphereMapShader();
};
class SplattingShader : public ShaderHelperSingleton<SplattingShader, core::matrix4>, public TextureRead<Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
class SplattingShader : public ShaderHelperSingleton<SplattingShader, core::matrix4>, public TextureRead<Nearest_Filtered, Nearest_Filtered, Bilinear_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered, Trilinear_Anisotropic_Filtered>
{
public:
SplattingShader();

View File

@ -47,6 +47,7 @@ struct GLMesh {
size_t vaoBaseVertex;
size_t vaoOffset;
video::E_VERTEX_TYPE VAOType;
uint64_t TextureHandles[6];
};
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);

View File

@ -341,7 +341,18 @@ void STKMeshSceneNode::render()
tmpcol.getBlue() / 255.0f);
compressTexture(mesh.textures[0], true);
MeshShader::TransparentFogShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) });
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentFogShader::getInstance()->SetTextureHandles(createVector<uint64_t>(mesh.TextureHandles[0]));
#endif
}
else
MeshShader::TransparentFogShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) });
MeshShader::TransparentFogShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix, fogmax, startH, endH, start, end, col);
assert(mesh.vao);
@ -362,7 +373,18 @@ void STKMeshSceneNode::render()
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
MeshShader::TransparentShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) });
if (UserConfigParams::m_bindless_textures)
{
#ifdef Bindless_Texture_Support
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::TransparentShader::getInstance()->SetTextureHandles(createVector<uint64_t>(mesh.TextureHandles[0]));
#endif
}
else
MeshShader::TransparentShader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(mesh.textures[0]) });
MeshShader::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
assert(mesh.vao);

View File

@ -1155,8 +1155,12 @@ void askForInternetPermission()
//=============================================================================
#if defined(DEBUG) && defined(WIN32) && !defined(__CYGWIN__)
#pragma comment(linker, "/SUBSYSTEM:console")
#if defined(WIN32) && defined(_MSC_VER)
#ifdef DEBUG
#pragma comment(linker, "/SUBSYSTEM:console")
#else
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
#endif
// ----------------------------------------------------------------------------

View File

@ -190,11 +190,12 @@ void AddonsLoading::init()
} // init
// ----------------------------------------------------------------------------
void AddonsLoading::escapePressed()
bool AddonsLoading::onEscapePressed()
{
stopDownload();
ModalDialog::dismiss();
} // escapePressed
return true;
} // onEscapePressed
// ----------------------------------------------------------------------------
@ -335,7 +336,6 @@ void AddonsLoading::stopDownload()
// order to avoid a memory leak, we let network_http free
// the request.
//m_download_request->setManageMemory(true);
assert(false);
m_download_request->cancel();
};
} // startDownload

View File

@ -23,6 +23,7 @@
#include "addons/addons_manager.hpp"
#include "guiengine/widgets.hpp"
#include "guiengine/modaldialog.hpp"
#include "utils/cpp2011.hpp"
#include "utils/synchronised.hpp"
namespace Online { class HTTPRequest; }
@ -32,7 +33,6 @@ namespace Online { class HTTPRequest; }
*/
class AddonsLoading : public GUIEngine::ModalDialog
{
virtual void escapePressed();
private:
GUIEngine::LabelWidget *m_state;
GUIEngine::ProgressBarWidget *m_progress;
@ -70,6 +70,7 @@ public:
* */
void onUpdate(float delta);
void voteClicked();
virtual bool onEscapePressed() OVERRIDE;
}; // AddonsLoading

View File

@ -64,6 +64,15 @@ void ConfirmResolutionDialog::onUpdate(float dt)
}
// ----------------------------------------------------------------------------
bool ConfirmResolutionDialog::onEscapePressed()
{
ModalDialog::dismiss();
irr_driver->cancelResChange();
return true;
} // escapePressed
// ------------------------------------------------------------------------------------------------------
void ConfirmResolutionDialog::updateMessage()

View File

@ -20,6 +20,7 @@
#define HEADER_CONFIRM_RES_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
#include "utils/cpp2011.hpp"
/**
* \brief Dialog shown after a resolution switch sot he user may confirm if
@ -28,6 +29,7 @@
*/
class ConfirmResolutionDialog : public GUIEngine::ModalDialog
{
private:
/** number of seconds left before resolution is considered unplayable */
float m_remaining_time;
@ -40,6 +42,7 @@ public:
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onUpdate(float dt);
virtual bool onEscapePressed() OVERRIDE;
};