summaryrefslogtreecommitdiff
path: root/chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp')
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp
index c1689132c7d..65d086a8455 100644
--- a/chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/BackendGL.cpp
@@ -161,6 +161,7 @@ namespace dawn_native { namespace opengl {
mFunctions.Enable(GL_SCISSOR_TEST);
mFunctions.Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
mFunctions.Enable(GL_MULTISAMPLE);
+ mFunctions.Enable(GL_FRAMEBUFFER_SRGB);
mPCIInfo.name = reinterpret_cast<const char*>(mFunctions.GetString(GL_RENDERER));
@@ -168,6 +169,8 @@ namespace dawn_native { namespace opengl {
const char* vendor = reinterpret_cast<const char*>(mFunctions.GetString(GL_VENDOR));
mPCIInfo.vendorId = GetVendorIdFromVendors(vendor);
+ InitializeSupportedExtensions();
+
return {};
}
@@ -181,6 +184,43 @@ namespace dawn_native { namespace opengl {
// all share the same backing OpenGL context.
return {new Device(this, descriptor, mFunctions)};
}
+
+ void InitializeSupportedExtensions() {
+ // TextureCompressionBC
+ {
+ // BC1, BC2 and BC3 are not supported in OpenGL or OpenGL ES core features.
+ bool supportsS3TC =
+ mFunctions.IsGLExtensionSupported("GL_EXT_texture_compression_s3tc");
+
+ // COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT and
+ // COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT requires both GL_EXT_texture_sRGB and
+ // GL_EXT_texture_compression_s3tc on desktop OpenGL drivers.
+ // (https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB.txt)
+ bool supportsTextureSRGB = mFunctions.IsGLExtensionSupported("GL_EXT_texture_sRGB");
+
+ // GL_EXT_texture_compression_s3tc_srgb is an extension in OpenGL ES.
+ bool supportsS3TCSRGB =
+ mFunctions.IsGLExtensionSupported("GL_EXT_texture_compression_s3tc_srgb");
+
+ // BC4 and BC5
+ bool supportsRGTC =
+ mFunctions.IsAtLeastGL(3, 0) ||
+ mFunctions.IsGLExtensionSupported("GL_ARB_texture_compression_rgtc") ||
+ mFunctions.IsGLExtensionSupported("GL_EXT_texture_compression_rgtc");
+
+ // BC6 and BC7
+ bool supportsBPTC =
+ mFunctions.IsAtLeastGL(4, 2) ||
+ mFunctions.IsGLExtensionSupported("GL_ARB_texture_compression_bptc") ||
+ mFunctions.IsGLExtensionSupported("GL_EXT_texture_compression_bptc");
+
+ if (supportsS3TC && (supportsTextureSRGB || supportsS3TCSRGB) && supportsRGTC &&
+ supportsBPTC) {
+ mSupportedExtensions.EnableExtension(
+ dawn_native::Extension::TextureCompressionBC);
+ }
+ }
+ }
};
// Implementation of the OpenGL backend's BackendConnection