|
|
@@ -10314,11 +10314,9 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
|
|
|
#ifndef OPENGLES_1
|
|
|
case Texture::F_srgb:
|
|
|
-#ifndef OPENGLES
|
|
|
- return GL_SRGB8;
|
|
|
-#endif
|
|
|
+ return _supports_texture_srgb ? GL_SRGB8 : GL_RGB8;
|
|
|
case Texture::F_srgb_alpha:
|
|
|
- return GL_SRGB8_ALPHA8;
|
|
|
+ return _supports_texture_srgb ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
|
|
#endif
|
|
|
#ifndef OPENGLES
|
|
|
case Texture::F_sluminance:
|
|
|
@@ -12807,11 +12805,20 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
|
|
|
int num_levels = 1;
|
|
|
CPTA_uchar image = tex->get_ram_mipmap_image(mipmap_bias);
|
|
|
|
|
|
+ bool can_generate = _supports_generate_mipmap;
|
|
|
+#if defined(OPENGLES) && !defined(OPENGLES_1)
|
|
|
+ // OpenGL ES doesn't support generating mipmaps for sRGB textures, so we
|
|
|
+ // have to do this on the CPU, unless we have a special extension.
|
|
|
+ if (internal_format == GL_SRGB8 || internal_format == GL_SRGB8_ALPHA8) {
|
|
|
+ can_generate = has_extension("GL_NV_generate_mipmap_sRGB");
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
if (image.is_null()) {
|
|
|
// We don't even have a RAM image, so we have no choice but to let
|
|
|
// mipmaps be generated on the GPU.
|
|
|
if (uses_mipmaps) {
|
|
|
- if (_supports_generate_mipmap) {
|
|
|
+ if (can_generate) {
|
|
|
num_levels = tex->get_expected_num_mipmap_levels() - mipmap_bias;
|
|
|
gtc->_generate_mipmaps = true;
|
|
|
} else {
|
|
|
@@ -12827,7 +12834,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
|
|
|
|
|
|
if (num_levels <= 1) {
|
|
|
// No RAM mipmap levels available. Should we generate some?
|
|
|
- if (!_supports_generate_mipmap || !driver_generate_mipmaps ||
|
|
|
+ if (!can_generate || !driver_generate_mipmaps ||
|
|
|
image_compression != Texture::CM_off) {
|
|
|
// Yes, the GL can't or won't generate them, so we need to. Note
|
|
|
// that some drivers (nVidia) will *corrupt memory* if you ask
|
|
|
@@ -12840,7 +12847,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
|
|
|
if (num_levels <= 1) {
|
|
|
// We don't have mipmap levels in RAM. Ask the GL to generate them
|
|
|
// if it can.
|
|
|
- if (_supports_generate_mipmap) {
|
|
|
+ if (can_generate) {
|
|
|
num_levels = tex->get_expected_num_mipmap_levels() - mipmap_bias;
|
|
|
gtc->_generate_mipmaps = true;
|
|
|
} else {
|
|
|
@@ -14106,9 +14113,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|
|
|
|
|
#ifndef OPENGLES_1
|
|
|
case GL_SRGB:
|
|
|
-#ifndef OPENGLES
|
|
|
case GL_SRGB8:
|
|
|
-#endif
|
|
|
format = Texture::F_srgb;
|
|
|
break;
|
|
|
case GL_SRGB_ALPHA:
|