Merge remote-tracking branch 'origin/master' into walldriving

This commit is contained in:
Benau 2016-09-16 09:23:18 +08:00
commit fff0bab42a
21 changed files with 171 additions and 44 deletions

Binary file not shown.

View File

@ -12,6 +12,8 @@ mode_tt, released under Creative-Commons BY-SA 3, incorporatings artwork from ye
mode_easter, mode_ftl, mode_soccer, mode_normal, race_giveup: by Totoplus62, released under CC-BY-SA 3.0
soccer balls released under CC-BY-SA 3.0 by Néd J. Édoire
tutorial.png by Totoplus62, released under CC-BY-SA 3.0
Logo and Logo_slim : under CC-BY-SA 3.0+ by 'rastapax'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,8 +1,13 @@
uniform sampler2D ntex;
uniform sampler2D dtex;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/getPosFromUVDepth.frag"

View File

@ -1,7 +1,12 @@
uniform sampler2D ntex;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/getPosFromUVDepth.frag"

View File

@ -6,8 +6,13 @@ flat in float energy;
flat in vec3 col;
flat in float radius;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/SpecularBRDF.frag"

View File

@ -1,8 +1,13 @@
uniform sampler2D ntex;
uniform sampler2D dtex;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/SpecularBRDF.frag"

View File

@ -9,8 +9,13 @@ uniform float splitmax;
uniform float shadow_res;
in vec2 uv;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/SpecularBRDF.frag"

View File

@ -8,8 +8,13 @@ uniform float split2;
uniform float splitmax;
in vec2 uv;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/SpecularBRDF.frag"

View File

@ -49,6 +49,10 @@ void CentralVideoSettings::init()
hasUBO = false;
hasExplicitAttribLocation = false;
hasGS = false;
#if defined(USE_GLES2)
hasBGRA = false;
#endif
m_GI_has_artifact = false;
m_need_rh_workaround = false;
@ -218,6 +222,15 @@ void CentralVideoSettings::init()
hasAtomics = true;
hasSSBO = true;
}
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_TEXTURE_FORMAT_BGRA8888) &&
(hasGLExtension("GL_IMG_texture_format_BGRA8888") ||
hasGLExtension("GL_EXT_texture_format_BGRA8888")))
{
hasBGRA = true;
Log::info("GLDriver", "EXT texture format BGRA8888 Present");
}
#endif
}
}
@ -337,6 +350,13 @@ bool CentralVideoSettings::isARBMultiDrawIndirectUsable() const
return hasMultiDrawIndirect;
}
#if defined(USE_GLES2)
bool CentralVideoSettings::isEXTTextureFormatBGRA8888Usable() const
{
return hasBGRA;
}
#endif
bool CentralVideoSettings::supportsShadows() const
{
return isARBGeometryShadersUsable() && isARBUniformBufferObjectUsable() && isARBExplicitAttribLocationUsable();

View File

@ -42,6 +42,10 @@ private:
bool hasSSBO;
bool hasImageLoadStore;
bool hasMultiDrawIndirect;
#if defined(USE_GLES2)
bool hasBGRA;
#endif
bool m_need_rh_workaround;
bool m_need_srgb_workaround;
@ -75,6 +79,10 @@ public:
bool isARBImageLoadStoreUsable() const;
bool isARBMultiDrawIndirectUsable() const;
bool isARBExplicitAttribLocationUsable() const;
#if defined(USE_GLES2)
bool isEXTTextureFormatBGRA8888Usable() const;
#endif
// Are all required extensions available for feature support

View File

@ -57,6 +57,9 @@ namespace GraphicsRestrictions
"TextureCompressionS3TC",
"AMDVertexShaderLayer",
"ExplicitAttribLocation",
#if defined(USE_GLES2)
"TextureFormatBGRA8888",
#endif
"DriverRecentEnough",
"HighDefinitionTextures",
"AdvancedPipeline",

View File

@ -51,6 +51,9 @@ namespace GraphicsRestrictions
GR_EXT_TEXTURE_COMPRESSION_S3TC,
GR_AMD_VERTEX_SHADER_LAYER,
GR_EXPLICIT_ATTRIB_LOCATION,
#if defined(USE_GLES2)
GR_TEXTURE_FORMAT_BGRA8888,
#endif
GR_DRIVER_RECENT_ENOUGH,
GR_HIGHDEFINITION_TEXTURES,
GR_ADVANCED_PIPELINE,

View File

@ -102,7 +102,9 @@ enum TypeFBO
FBO_EIGHTH2,
FBO_DISPLACE,
FBO_BLOOM_1024,
#if !defined(USE_GLES2)
FBO_SCALAR_1024,
#endif
FBO_BLOOM_512,
FBO_TMP_512,
FBO_LENS_512,
@ -164,7 +166,9 @@ enum TypeRTT
RTT_MLAA_TMP,
RTT_BLOOM_1024,
#if !defined(USE_GLES2)
RTT_SCALAR_1024,
#endif
RTT_BLOOM_512,
RTT_TMP_512,
RTT_LENS_512,

View File

@ -431,8 +431,10 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
{
PROFILER_PUSH_CPU_MARKER("- SSAO", 0xFF, 0xFF, 0x00);
ScopedGPUTimer Timer(getGPUTimer(Q_SSAO));
#if !defined(USE_GLES2)
if (UserConfigParams::m_ssao)
renderSSAO();
#endif
PROFILER_POP_CPU_MARKER();
}

View File

@ -78,45 +78,67 @@ RTT::RTT(size_t width, size_t height)
// All RTTs are currently RGBA16F mostly with stencil. The four tmp RTTs are the same size
// as the screen, for use in post-processing.
#if !defined(USE_GLES2)
GLint rgba_internal_format = GL_RGBA16F;
GLint rgba_format = GL_BGRA;
GLint red_internal_format = GL_R16F;
GLint red32_internal_format = GL_R32F;
GLint red_format = GL_RED;
GLint rgb_format = GL_BGR;
GLint diffuse_specular_internal_format = GL_R11F_G11F_B10F;
GLint type = GL_FLOAT;
#else
GLint rgba_internal_format = GL_RGBA8;
GLint rgba_format = GL_RGBA;
GLint red_internal_format = GL_R8;
GLint red32_internal_format = GL_R8;
GLint red_format = GL_RED;
GLint rgb_format = GL_RGB;
GLint diffuse_specular_internal_format = GL_RGBA8;
GLint type = GL_UNSIGNED_BYTE;
#endif
RenderTargetTextures[RTT_TMP1] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP2] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP3] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_TMP4] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, GL_R32F, GL_RED, GL_FLOAT, linear_depth_mip_levels);
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, GL_RGBA16F, GL_RGBA, GL_FLOAT);
RenderTargetTextures[RTT_COLOR] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_TMP] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_BLEND] = generateRTT(res, GL_SRGB8_ALPHA8, GL_BGR, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_SSAO] = generateRTT(res, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_DIFFUSE] = generateRTT(res, GL_R11F_G11F_B10F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_SPECULAR] = generateRTT(res, GL_R11F_G11F_B10F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP1] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_TMP2] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_TMP3] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_TMP4] = generateRTT(res, red_internal_format, red_format, type);
RenderTargetTextures[RTT_LINEAR_DEPTH] = generateRTT(res, red32_internal_format, red_format, type, linear_depth_mip_levels);
RenderTargetTextures[RTT_NORMAL_AND_DEPTH] = generateRTT(res, rgba_internal_format, GL_RGBA, type);
RenderTargetTextures[RTT_COLOR] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_MLAA_COLORS] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_TMP] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_MLAA_BLEND] = generateRTT(res, GL_SRGB8_ALPHA8, rgb_format, GL_UNSIGNED_BYTE);
RenderTargetTextures[RTT_SSAO] = generateRTT(res, red_internal_format, red_format, type);
RenderTargetTextures[RTT_DISPLACE] = generateRTT(res, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_DIFFUSE] = generateRTT(res, diffuse_specular_internal_format, rgb_format, type);
RenderTargetTextures[RTT_SPECULAR] = generateRTT(res, diffuse_specular_internal_format, rgb_format, type);
RenderTargetTextures[RTT_HALF1] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_QUARTER1] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_EIGHTH1] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF1_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_HALF1] = generateRTT(half, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_QUARTER1] = generateRTT(quarter, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_EIGHTH1] = generateRTT(eighth, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_HALF1_R] = generateRTT(half, red_internal_format, red_format, type);
RenderTargetTextures[RTT_HALF2] = generateRTT(half, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, GL_RGBA16F, GL_BGRA, GL_FLOAT);
RenderTargetTextures[RTT_HALF2_R] = generateRTT(half, GL_R16F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_HALF2] = generateRTT(half, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_QUARTER2] = generateRTT(quarter, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_EIGHTH2] = generateRTT(eighth, rgba_internal_format, rgba_format, type);
RenderTargetTextures[RTT_HALF2_R] = generateRTT(half, red_internal_format, red_format, type);
RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_SCALAR_1024] = generateRTT(shadowsize0, GL_R32F, GL_RED, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_LENS_512] = generateRTT(shadowsize1, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_1024] = generateRTT(shadowsize0, rgba_internal_format, rgb_format, type);
#if !defined(USE_GLES2)
RenderTargetTextures[RTT_SCALAR_1024] = generateRTT(shadowsize0, red32_internal_format, red_format, type);
#endif
RenderTargetTextures[RTT_BLOOM_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_TMP_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_LENS_512] = generateRTT(shadowsize1, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_BLOOM_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_LENS_256] = generateRTT(shadowsize2, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_TMP_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_LENS_256] = generateRTT(shadowsize2, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_BLOOM_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_LENS_128] = generateRTT(shadowsize3, GL_RGBA16F, GL_BGR, GL_FLOAT);
RenderTargetTextures[RTT_BLOOM_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_TMP_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type);
RenderTargetTextures[RTT_LENS_128] = generateRTT(shadowsize3, rgba_internal_format, rgb_format, type);
std::vector<GLuint> somevector;
somevector.push_back(RenderTargetTextures[RTT_SSAO]);
@ -191,9 +213,11 @@ RTT::RTT(size_t width, size_t height)
somevector.push_back(RenderTargetTextures[RTT_BLOOM_1024]);
FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height));
somevector.clear();
#if !defined(USE_GLES2)
somevector.push_back(RenderTargetTextures[RTT_SCALAR_1024]);
FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize0.Width, shadowsize0.Height));
somevector.clear();
#endif
somevector.push_back(RenderTargetTextures[RTT_BLOOM_512]);
FrameBuffers.push_back(new FrameBuffer(somevector, shadowsize1.Width, shadowsize1.Height));

View File

@ -107,11 +107,17 @@ GLuint ShaderBase::loadShader(const std::string &file, unsigned type)
if (CVS->needsRGBBindlessWorkaround())
code << "#define SRGBBindlessFix\n";
#if !defined(USE_GLES2)
//shader compilation fails with some drivers if there is no precision qualifier
if (type == GL_FRAGMENT_SHADER)
code << "precision mediump float;\n";
#if defined(USE_GLES2)
else if (type == GL_VERTEX_SHADER)
#else
int range[2], precision;
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, range, &precision);
if (precision > 0)
code << "precision highp float;\n";
else
code << "precision mediump float;\n";
#endif

View File

@ -170,6 +170,15 @@ void Skybox::generateCubeMapFromTextures()
image->copyToScaling(rgba[i], size, size);
image->drop();
#if defined(USE_GLES2)
for (unsigned int j = 0; j < size * size; j++)
{
char tmp_val = rgba[i][j*4];
rgba[i][j*4] = rgba[i][j*4 + 2];
rgba[i][j*4 + 2] = tmp_val;
}
#endif
if (i == 2 || i == 3)
{
char *tmp = new char[size * size * 4];
@ -188,15 +197,14 @@ void Skybox::generateCubeMapFromTextures()
#if !defined(USE_GLES2)
GLint internal_format = CVS->isTextureCompressionEnabled() ?
GL_COMPRESSED_SRGB_ALPHA : GL_SRGB_ALPHA;
GLint format = GL_BGRA;
#else
// The GL_SRGB_ALPHA_EXT and GL_SRGB8_ALPHA8 formats are available in
// OpenGL ES, but they produce black texture for some reason.
// The basic GL_RGBA format works fine though.
GLint internal_format = GL_RGBA;
GLint internal_format = GL_RGBA8;
GLint format = GL_RGBA;
#endif
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
internal_format, size, size, 0, GL_BGRA,
internal_format, size, size, 0, format,
GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
}
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
@ -213,8 +221,13 @@ void Skybox::generateSpecularCubemap()
size_t cubemap_size = 256;
for (int i = 0; i < 6; i++)
{
#if !defined(USE_GLES2)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA16F,
cubemap_size, cubemap_size, 0, GL_BGRA, GL_FLOAT, 0);
#else
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA8,
cubemap_size, cubemap_size, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
#endif
}
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

View File

@ -34,6 +34,8 @@
GLuint getTextureGLuint(irr::video::ITexture *tex)
{
if (tex == NULL)
return 0;
#if defined(USE_GLES2)
return static_cast<irr::video::COGLES2Texture*>(tex)->getOpenGLTextureName();
#else
@ -87,10 +89,20 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
memcpy(data, tex->lock(), w * h * 4);
tex->unlock();
unsigned internalFormat, Format;
if (tex->hasAlpha())
Format = GL_BGRA;
else
Format = GL_BGR;
Format = tex->hasAlpha() ? GL_BGRA : GL_BGR;
#if defined(USE_GLES2)
if (!CVS->isEXTTextureFormatBGRA8888Usable())
{
Format = tex->hasAlpha() ? GL_RGBA : GL_RGB;
for (unsigned int i = 0; i < w * h; i++)
{
char tmp_val = data[i*4];
data[i*4] = data[i*4 + 2];
data[i*4 + 2] = tmp_val;
}
}
#endif
if (premul_alpha)
{