summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-05-17 19:24:54 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-05-17 19:24:54 +0300
commit33c961060dabce543c3db8c45cdc23ea256daca9 (patch)
tree171c6aba3bbdcd18fe01a91ff9c628d680609663
parent99f090b955e03ee2e477eeb84878ae9c225d30c3 (diff)
downloadqtlocation-mapboxgl-upstream/tmpsantos-binary_shader_removal.tar.gz
-rw-r--r--src/core-files.json1
-rw-r--r--src/mbgl/gl/context.cpp58
-rw-r--r--src/mbgl/gl/features.hpp8
-rw-r--r--src/mbgl/gl/program.hpp44
-rw-r--r--src/mbgl/gl/program_binary_extension.hpp44
5 files changed, 0 insertions, 155 deletions
diff --git a/src/core-files.json b/src/core-files.json
index a52797acd7..7fbba77500 100644
--- a/src/core-files.json
+++ b/src/core-files.json
@@ -541,7 +541,6 @@
"mbgl/gl/draw_scope_resource.hpp": "src/mbgl/gl/draw_scope_resource.hpp",
"mbgl/gl/enum.hpp": "src/mbgl/gl/enum.hpp",
"mbgl/gl/extension.hpp": "src/mbgl/gl/extension.hpp",
- "mbgl/gl/features.hpp": "src/mbgl/gl/features.hpp",
"mbgl/gl/framebuffer.hpp": "src/mbgl/gl/framebuffer.hpp",
"mbgl/gl/index_buffer_resource.hpp": "src/mbgl/gl/index_buffer_resource.hpp",
"mbgl/gl/object.hpp": "src/mbgl/gl/object.hpp",
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index f1288dc7ed..cedb0b57a9 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -107,10 +107,6 @@ void Context::initializeExtensions(const std::function<gl::ProcAddress(const cha
vertexArray = std::make_unique<extension::VertexArray>(fn);
}
-#if MBGL_HAS_BINARY_PROGRAMS
- programBinary = std::make_unique<extension::ProgramBinary>(fn);
-#endif
-
#if MBGL_USE_GLES2
constexpr const char* halfFloatExtensionName = "OES_texture_half_float";
constexpr const char* halfFloatColorBufferExtensionName = "EXT_color_buffer_half_float";
@@ -180,22 +176,9 @@ UniqueProgram Context::createProgram(ShaderID vertexShader, ShaderID fragmentSha
return result;
}
-#if MBGL_HAS_BINARY_PROGRAMS
-UniqueProgram Context::createProgram(BinaryProgramFormat binaryFormat,
- const std::string& binaryProgram) {
- assert(supportsProgramBinaries());
- UniqueProgram result{ MBGL_CHECK_ERROR(glCreateProgram()), { this } };
- MBGL_CHECK_ERROR(programBinary->programBinary(result, static_cast<GLenum>(binaryFormat),
- binaryProgram.data(),
- static_cast<GLint>(binaryProgram.size())));
- verifyProgramLinkage(result);
- return result;
-}
-#else
UniqueProgram Context::createProgram(BinaryProgramFormat, const std::string&) {
throw std::runtime_error("binary programs are not supported");
}
-#endif
void Context::linkProgram(ProgramID program_) {
MBGL_CHECK_ERROR(glLinkProgram(program_));
@@ -238,50 +221,9 @@ bool Context::supportsVertexArrays() const {
vertexArray->deleteVertexArrays;
}
-#if MBGL_HAS_BINARY_PROGRAMS
-bool Context::supportsProgramBinaries() const {
- if (!programBinary || !programBinary->programBinary || !programBinary->getProgramBinary) {
- return false;
- }
-
- // Blacklist Adreno 3xx, 4xx, and 5xx GPUs due to known bugs:
- // https://bugs.chromium.org/p/chromium/issues/detail?id=510637
- // https://chromium.googlesource.com/chromium/src/gpu/+/master/config/gpu_driver_bug_list.json#2316
- // Blacklist Vivante GC4000 due to bugs when linking loaded programs:
- // https://github.com/mapbox/mapbox-gl-native/issues/10704
- const std::string renderer = reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_RENDERER)));
- if (renderer.find("Adreno (TM) 3") != std::string::npos
- || renderer.find("Adreno (TM) 4") != std::string::npos
- || renderer.find("Adreno (TM) 5") != std::string::npos
- || renderer.find("Vivante GC4000") != std::string::npos) {
- return false;
- }
-
- return true;
-}
-
-optional<std::pair<BinaryProgramFormat, std::string>>
-Context::getBinaryProgram(ProgramID program_) const {
- if (!supportsProgramBinaries()) {
- return {};
- }
- GLint binaryLength;
- MBGL_CHECK_ERROR(glGetProgramiv(program_, GL_PROGRAM_BINARY_LENGTH, &binaryLength));
- std::string binary;
- binary.resize(binaryLength);
- GLenum binaryFormat;
- MBGL_CHECK_ERROR(programBinary->getProgramBinary(
- program_, binaryLength, &binaryLength, &binaryFormat, const_cast<char*>(binary.data())));
- if (size_t(binaryLength) != binary.size()) {
- return {};
- }
- return { { binaryFormat, std::move(binary) } };
-}
-#else
optional<std::pair<BinaryProgramFormat, std::string>> Context::getBinaryProgram(ProgramID) const {
return {};
}
-#endif
VertexArray Context::createVertexArray() {
if (supportsVertexArrays()) {
diff --git a/src/mbgl/gl/features.hpp b/src/mbgl/gl/features.hpp
deleted file mode 100644
index 1da1371e45..0000000000
--- a/src/mbgl/gl/features.hpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-#if __APPLE__
- #define MBGL_HAS_BINARY_PROGRAMS 0
-#else
- // https://github.com/mapbox/mapbox-gl-native/issues/14294
- #define MBGL_HAS_BINARY_PROGRAMS 0
-#endif
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp
index 3757c442de..a136ba7a82 100644
--- a/src/mbgl/gl/program.hpp
+++ b/src/mbgl/gl/program.hpp
@@ -74,36 +74,6 @@ public:
createInstance(gl::Context& context,
const ProgramParameters& programParameters,
const std::string& additionalDefines) {
-
-
-
-#if MBGL_HAS_BINARY_PROGRAMS
- optional<std::string> cachePath =
- programParameters.cachePath(programs::gl::ShaderSource<Name>::name);
- std::string programIdentifier;
- if (cachePath && context.supportsProgramBinaries()) {
- programIdentifier = programs::gl::programIdentifier(
- programParameters.getDefines(), additionalDefines, programs::gl::preludeHash,
- programs::gl::ShaderSource<Name>::hash);
-
- try {
- if (auto cachedBinaryProgram = util::readFile(*cachePath)) {
- const BinaryProgram binaryProgram(std::move(*cachedBinaryProgram));
- if (binaryProgram.identifier() == programIdentifier) {
- return std::make_unique<Instance>(context, binaryProgram);
- } else {
- Log::Warning(Event::OpenGL,
- "Cached program %s changed. Recompilation required.",
- programs::gl::ShaderSource<Name>::name);
- }
- }
- } catch (std::runtime_error& error) {
- Log::Warning(Event::OpenGL, "Could not load cached program: %s",
- error.what());
- }
- }
-#endif
-
// Compile the shader
const std::initializer_list<const char*> vertexSource = {
programParameters.getDefines().c_str(),
@@ -119,20 +89,6 @@ public:
};
auto result = std::make_unique<Instance>(context, vertexSource, fragmentSource);
-#if MBGL_HAS_BINARY_PROGRAMS
- if (cachePath && context.supportsProgramBinaries()) {
- try {
- if (const auto binaryProgram =
- result->template get<BinaryProgram>(context, programIdentifier)) {
- util::write_file(*cachePath, binaryProgram->serialize());
- Log::Warning(Event::OpenGL, "Caching program in: %s", (*cachePath).c_str());
- }
- } catch (std::runtime_error& error) {
- Log::Warning(Event::OpenGL, "Failed to cache program: %s", error.what());
- }
- }
-#endif
-
return std::move(result);
}
diff --git a/src/mbgl/gl/program_binary_extension.hpp b/src/mbgl/gl/program_binary_extension.hpp
deleted file mode 100644
index b14876728b..0000000000
--- a/src/mbgl/gl/program_binary_extension.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/features.hpp>
-#include <mbgl/gl/extension.hpp>
-#include <mbgl/gl/defines.hpp>
-
-#if MBGL_HAS_BINARY_PROGRAMS
-
-#define GL_PROGRAM_BINARY_LENGTH 0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
-#define GL_PROGRAM_BINARY_FORMATS 0x87FF
-
-namespace mbgl {
-namespace gl {
-namespace extension {
-
-class ProgramBinary {
-public:
- template <typename Fn>
- ProgramBinary(const Fn& loadExtension)
- : getProgramBinary(loadExtension({
- { "GL_OES_get_program_binary", "glGetProgramBinaryOES" },
- { "GL_ARB_get_program_binary", "glGetProgramBinary" },
- })),
- programBinary(loadExtension({
- { "GL_OES_get_program_binary", "glProgramBinaryOES" },
- { "GL_ARB_get_program_binary", "glProgramBinary" },
- })) {
- }
-
- const ExtensionFunction<void(
- GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)>
- getProgramBinary;
-
- const ExtensionFunction<void(
- GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length)>
- programBinary;
-};
-
-} // namespace extension
-} // namespace gl
-} // namespace mbgl
-
-#endif