Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Remove binary shader support
Browse files Browse the repository at this point in the history
The implementation is buggy and not worth maintaining anymore
because performance benefits are not substantial or sometimes
worse. Also, removing it saves about 150 ~ 180 KB in binary size.

Below timings are averages of minimum 5 runs.

```
Device          Init launch     Average relaunch
s10             1129.8 ms       700 ms
s10 - binary    1346.75 ms      694 ms
Pixel           1692 ms         723 ms
Pixel - binary  1883 ms         1039 ms
Kazam           17948 ms        1339 ms
Kazam - binary  19157 ms        1564 ms
Wiko            2060 ms         1278 ms
Wiko - binary   3876 ms         1136 ms
```

Fixes #14294
  • Loading branch information
tmpsantos committed May 21, 2019
1 parent f210bbb commit c2f974f
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 480 deletions.
19 changes: 0 additions & 19 deletions misc/proto/binary_program.proto

This file was deleted.

4 changes: 0 additions & 4 deletions src/core-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"src/mbgl/gfx/attribute.cpp",
"src/mbgl/gfx/renderer_backend.cpp",
"src/mbgl/gl/attribute.cpp",
"src/mbgl/gl/binary_program.cpp",
"src/mbgl/gl/command_encoder.cpp",
"src/mbgl/gl/context.cpp",
"src/mbgl/gl/debugging_extension.cpp",
Expand Down Expand Up @@ -533,21 +532,18 @@
"mbgl/gfx/vertex_buffer.hpp": "src/mbgl/gfx/vertex_buffer.hpp",
"mbgl/gfx/vertex_vector.hpp": "src/mbgl/gfx/vertex_vector.hpp",
"mbgl/gl/attribute.hpp": "src/mbgl/gl/attribute.hpp",
"mbgl/gl/binary_program.hpp": "src/mbgl/gl/binary_program.hpp",
"mbgl/gl/command_encoder.hpp": "src/mbgl/gl/command_encoder.hpp",
"mbgl/gl/context.hpp": "src/mbgl/gl/context.hpp",
"mbgl/gl/debugging_extension.hpp": "src/mbgl/gl/debugging_extension.hpp",
"mbgl/gl/defines.hpp": "src/mbgl/gl/defines.hpp",
"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",
"mbgl/gl/offscreen_texture.hpp": "src/mbgl/gl/offscreen_texture.hpp",
"mbgl/gl/program.hpp": "src/mbgl/gl/program.hpp",
"mbgl/gl/program_binary_extension.hpp": "src/mbgl/gl/program_binary_extension.hpp",
"mbgl/gl/render_pass.hpp": "src/mbgl/gl/render_pass.hpp",
"mbgl/gl/renderbuffer_resource.hpp": "src/mbgl/gl/renderbuffer_resource.hpp",
"mbgl/gl/state.hpp": "src/mbgl/gl/state.hpp",
Expand Down
6 changes: 0 additions & 6 deletions src/mbgl/gl/attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ class AttributeLocations<TypeList<As...>> final {
public:
AttributeLocations() = default;

template <class BinaryProgram>
AttributeLocations(const BinaryProgram& program)
: locations{ program.attributeLocation(
concat_literals<&string_literal<'a', '_'>::value, &As::name>::value())... } {
}

void queryLocations(const ProgramID& id) {
locations = Locations{
queryLocation(id, concat_literals<&string_literal<'a', '_'>::value, &As::name>::value())... };
Expand Down
142 changes: 0 additions & 142 deletions src/mbgl/gl/binary_program.cpp

This file was deleted.

50 changes: 0 additions & 50 deletions src/mbgl/gl/binary_program.hpp

This file was deleted.

69 changes: 0 additions & 69 deletions src/mbgl/gl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <mbgl/gl/command_encoder.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
#include <mbgl/gl/program_binary_extension.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/logging.hpp>
Expand Down Expand Up @@ -50,8 +49,6 @@ static_assert(underlying_type(UniformDataType::FloatMat4) == GL_FLOAT_MAT4, "Ope
static_assert(underlying_type(UniformDataType::Sampler2D) == GL_SAMPLER_2D, "OpenGL type mismatch");
static_assert(underlying_type(UniformDataType::SamplerCube) == GL_SAMPLER_CUBE, "OpenGL type mismatch");

static_assert(std::is_same<BinaryProgramFormat, GLenum>::value, "OpenGL type mismatch");

Context::Context(RendererBackend& backend_)
: gfx::Context(gfx::ContextType::OpenGL, [] {
GLint value;
Expand Down Expand Up @@ -107,10 +104,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";
Expand Down Expand Up @@ -186,23 +179,6 @@ 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_));
verifyProgramLinkage(program_);
Expand Down Expand Up @@ -244,51 +220,6 @@ 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()) {
VertexArrayID id = 0;
Expand Down
Loading

0 comments on commit c2f974f

Please sign in to comment.