summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/program.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/program.hpp')
-rw-r--r--src/mbgl/gl/program.hpp67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp
index 8540385e97..6cfe05bf54 100644
--- a/src/mbgl/gl/program.hpp
+++ b/src/mbgl/gl/program.hpp
@@ -12,8 +12,6 @@
#include <mbgl/gl/attribute.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/gl/texture.hpp>
-#include <mbgl/gl/features.hpp>
-#include <mbgl/gl/binary_program.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/logging.hpp>
@@ -57,48 +55,10 @@ public:
textureStates.queryLocations(program);
}
- template <class BinaryProgram>
- Instance(Context& context, const BinaryProgram& binaryProgram)
- : program(context.createProgram(binaryProgram.format(), binaryProgram.code())),
- attributeLocations(binaryProgram) {
- uniformStates.loadNamedLocations(binaryProgram);
- textureStates.loadNamedLocations(binaryProgram);
- }
-
static std::unique_ptr<Instance>
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(),
@@ -114,36 +74,9 @@ 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);
}
- template <class BinaryProgram>
- optional<BinaryProgram> get(Context& context, const std::string& identifier) const {
- if (auto binaryProgram = context.getBinaryProgram(program)) {
- return BinaryProgram{ binaryProgram->first,
- std::move(binaryProgram->second),
- identifier,
- attributeLocations.getNamedLocations(),
- uniformStates.getNamedLocations(),
- textureStates.getNamedLocations() };
- }
- return {};
- }
-
UniqueProgram program;
gl::AttributeLocations<AttributeList> attributeLocations;
gl::UniformStates<UniformList> uniformStates;