diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-19 14:02:10 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-20 15:40:47 +0100 |
commit | 1e30fdac36233c0fd0662e2b285b0424907bc81d (patch) | |
tree | eb61b156b5445639939eab47f5ded9a385b25fd9 | |
parent | 53ab65d81165daf4e23ce28fa0e42861724ea687 (diff) | |
download | qtlocation-mapboxgl-1e30fdac36233c0fd0662e2b285b0424907bc81d.tar.gz |
[core] move ProgramMap to within the gl::Program object
53 files changed, 819 insertions, 327 deletions
diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js index 4f58608e20..fc9088fd21 100755 --- a/scripts/generate-shaders.js +++ b/scripts/generate-shaders.js @@ -5,6 +5,7 @@ require('flow-remove-types/register'); const path = require('path'); const outputPath = 'src/mbgl/programs/gl'; const zlib = require('zlib'); +const crypto = require('crypto'); var shaders = require('../mapbox-gl-js/src/shaders'); @@ -28,18 +29,23 @@ for (const key in shaders) { // https://github.com/mapbox/mapbox-gl-native/issues/13984 shaders[key].vertexSource = shaders[key].vertexSource.replace(/\ba_(\w+)_t\b/mg, 'u_$1_t'); + const hash = crypto.createHash('sha1'); + const vertex = concatenated.length; - concatenated += basicMinify(shaders[key].vertexSource); - concatenated += '\n\0'; + const vertexSource = basicMinify(shaders[key].vertexSource) + '\n\0'; + hash.update(vertexSource); + concatenated += vertexSource; const fragment = concatenated.length; - concatenated += basicMinify(shaders[key].fragmentSource); - concatenated += '\n\0'; + const fragmentSource = basicMinify(shaders[key].fragmentSource) + '\n\0'; + hash.update(fragmentSource); + concatenated += fragmentSource; offsets[key] = { vertex, fragment, originalKey: key, + hash: hash.digest('hex').substring(0, 16).match(/.{1,2}/g).map(n => `0x${n}`).join(', '), shaderName: key.replace(/[A-Z]+/g, (match) => `_${match.toLowerCase()}`), ShaderName: key.replace(/^[a-z]/g, (match) => match.toUpperCase()) }; @@ -49,6 +55,7 @@ for (const key in shaders) { offsets.symbolSDFIcon = { vertex: offsets.symbolSDF.vertex, fragment: offsets.symbolSDF.fragment, + hash: offsets.symbolSDF.hash, originalKey: 'symbolSDF', shaderName: 'symbol_sdf_icon', ShaderName: 'SymbolSDFIcon', @@ -57,6 +64,7 @@ offsets.symbolSDFIcon = { offsets.symbolSDFText = { vertex: offsets.symbolSDF.vertex, fragment: offsets.symbolSDF.fragment, + hash: offsets.symbolSDF.hash, originalKey: 'symbolSDF', shaderName: 'symbol_sdf_text', ShaderName: 'SymbolSDFText', @@ -71,10 +79,6 @@ const compressed = zlib.deflateSync(concatenated, {level: zlib.Z_BEST_COMPRESSIO .join(',\n ') .trim(); -function sourceOffset(key, type) { - return `programs::gl::shaderSource() + ${offsets[key][type]}` -} - writeIfModified(path.join(outputPath, 'shader_source.hpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #pragma once @@ -85,6 +89,9 @@ namespace gl { const char* shaderSource(); +template <typename> +struct ShaderSource; + } // namespace gl } // namespace programs } // namespace mbgl @@ -119,29 +126,15 @@ writeIfModified(path.join(outputPath, 'preludes.hpp'), `// NOTE: DO NOT CHANGE T #pragma once -namespace mbgl { -namespace programs { -namespace gl { - -extern const char* vertexShaderPrelude; -extern const char* fragmentShaderPrelude; - -} // namespace gl -} // namespace programs -} // namespace mbgl -`); - -writeIfModified(path.join(outputPath, 'preludes.cpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#include <mbgl/programs/gl/preludes.hpp> -#include <mbgl/programs/gl/shader_source.hpp> +#include <cstdint> namespace mbgl { namespace programs { namespace gl { -const char* vertexShaderPrelude = ${sourceOffset('prelude', 'vertex')}; -const char* fragmentShaderPrelude = ${sourceOffset('prelude', 'fragment')}; +constexpr const uint8_t preludeHash[8] = { ${offsets['prelude'].hash} }; +constexpr const auto vertexPreludeOffset = ${offsets['prelude'].vertex}; +constexpr const auto fragmentPreludeOffset = ${offsets['prelude'].fragment}; } // namespace gl } // namespace programs @@ -157,18 +150,37 @@ for (const key in offsets) { writeIfModified(path.join(outputPath, `${shaderName}.cpp`), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/${shaderName}_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<${ShaderName}Program> { + static constexpr const char* name = "${shaderName}"; + static constexpr const uint8_t hash[8] = { ${offsets[key].hash} }; + static constexpr const auto vertexOffset = ${offsets[key].vertex}; + static constexpr const auto fragmentOffset = ${offsets[key].fragment}; +}; + +constexpr const char* ShaderSource<${ShaderName}Program>::name; +constexpr const uint8_t ShaderSource<${ShaderName}Program>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<${ShaderName}Program>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<${ShaderName}Program>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "${shaderName}", - ${sourceOffset(key, 'vertex')}, ${sourceOffset(key, 'fragment')}); + return std::make_unique<gl::Program<${ShaderName}Program>>(programParameters); } } // namespace gfx diff --git a/src/core-files.json b/src/core-files.json index 153a965567..e78f6232c3 100644 --- a/src/core-files.json +++ b/src/core-files.json @@ -82,7 +82,6 @@ "src/mbgl/programs/gl/line_gradient.cpp", "src/mbgl/programs/gl/line_pattern.cpp", "src/mbgl/programs/gl/line_sdf.cpp", - "src/mbgl/programs/gl/preludes.cpp", "src/mbgl/programs/gl/raster.cpp", "src/mbgl/programs/gl/shader_source.cpp", "src/mbgl/programs/gl/shaders.cpp", diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index 62c89178cd..c7f9ba3fd4 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -95,5 +95,36 @@ public: } }; +template <class> +class AttributeKey; + +constexpr auto attributeDefinePrefix() { + return "#define HAS_UNIFORM_u_"; +} + +template <class... As> +class AttributeKey<TypeList<As...>> final { +public: + static_assert(sizeof...(As) <= 32, "attribute count exceeds 32"); + + static uint32_t compute(const gfx::AttributeBindings<TypeList<As...>>& bindings) { + uint32_t value = 0; + util::ignore( + { (bindings.template get<As>() ? (void)(value |= 1 << TypeIndex<As, As...>::value) + : (void)0, + 0)... }); + return value; + } + + static std::string defines(const gfx::AttributeBindings<TypeList<As...>>& bindings) { + std::string result; + util::ignore({ (!bindings.template get<As>() + ? (void)(result += concat_literals<&attributeDefinePrefix, &As::name, &string_literal<'\n'>::value>::value()) + : (void)0, + 0)... }); + return result; + } +}; + } // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 1f780331c2..eff3c2160c 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -160,12 +160,10 @@ void Context::enableDebugging() { MBGL_CHECK_ERROR(debugging->debugMessageCallback(extension::Debugging::DebugCallback, nullptr)); } -UniqueShader Context::createShader(ShaderType type, const std::string& source) { +UniqueShader Context::createShader(ShaderType type, const std::initializer_list<const char*>& sources) { UniqueShader result { MBGL_CHECK_ERROR(glCreateShader(static_cast<GLenum>(type))), { this } }; - const GLchar* sources = source.data(); - const auto lengths = static_cast<GLsizei>(source.length()); - MBGL_CHECK_ERROR(glShaderSource(result, 1, &sources, &lengths)); + MBGL_CHECK_ERROR(glShaderSource(result, static_cast<GLsizei>(sources.size()), sources.begin(), nullptr)); MBGL_CHECK_ERROR(glCompileShader(result)); GLint status = 0; diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 754b29c03e..8a67213628 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -46,7 +46,7 @@ public: void enableDebugging(); - UniqueShader createShader(ShaderType type, const std::string& source); + UniqueShader createShader(ShaderType type, const std::initializer_list<const char*>& sources); UniqueProgram createProgram(ShaderID vertexShader, ShaderID fragmentShader); UniqueProgram createProgram(BinaryProgramFormat binaryFormat, const std::string& binaryProgram); void verifyProgramLinkage(ProgramID); diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index 9028ffdf53..1cec7671a1 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -18,6 +18,7 @@ #include <mbgl/util/logging.hpp> #include <mbgl/programs/program_parameters.hpp> +#include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/programs/gl/shaders.hpp> #include <string> @@ -31,93 +32,128 @@ public: using AttributeList = typename Name::AttributeList; using UniformList = typename Name::UniformList; using TextureList = typename Name::TextureList; - - Program(Context& context, const std::string& vertexSource, const std::string& fragmentSource) - : program( - context.createProgram(context.createShader(ShaderType::Vertex, vertexSource), - context.createShader(ShaderType::Fragment, fragmentSource))), - attributeLocations(context, program) { - // Re-link program after manually binding only active attributes in Attributes::queryLocations - context.linkProgram(program); - - // We have to re-initialize the uniforms state from the bindings as the uniform locations - // get shifted on some implementations - uniformStates.queryLocations(program); - - // Texture units are specified via uniforms as well, so we need query their locations - textureStates.queryLocations(program); - } - template <class BinaryProgram> - Program(Context& context, const BinaryProgram& binaryProgram) - : program(context.createProgram(binaryProgram.format(), binaryProgram.code())), - attributeLocations(binaryProgram) { - uniformStates.loadNamedLocations(binaryProgram); - textureStates.loadNamedLocations(binaryProgram); + Program(ProgramParameters programParameters_) + : programParameters(std::move(programParameters_)) { } - static std::unique_ptr<Program> createProgram(gl::Context& context, - const ProgramParameters& programParameters, - const char* name, - const char* vertexSource_, - const char* fragmentSource_) { - const std::string vertexSource = programs::gl::vertexSource(programParameters, vertexSource_); - const std::string fragmentSource = programs::gl::fragmentSource(programParameters, fragmentSource_); + const ProgramParameters programParameters; + + static constexpr const auto vertexOffset = programs::gl::ShaderSource<Name>::vertexOffset; + static constexpr const auto fragmentOffset = programs::gl::ShaderSource<Name>::fragmentOffset; + + class Instance { + public: + Instance(Context& context, + const std::initializer_list<const char*>& vertexSource, + const std::initializer_list<const char*>& fragmentSource) + : program(context.createProgram( + context.createShader(ShaderType::Vertex, vertexSource), + context.createShader(ShaderType::Fragment, fragmentSource))), + attributeLocations(context, program) { + // Re-link program after manually binding only active attributes in Attributes::queryLocations + context.linkProgram(program); + + // We have to re-initialize the uniforms state from the bindings as the uniform locations + // get shifted on some implementations + uniformStates.queryLocations(program); + + // Texture units are specified via uniforms as well, so we need query their locations + 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(name); - if (cachePath && context.supportsProgramBinaries()) { - const std::string identifier = programs::gl::programIdentifier(vertexSource, fragmentSource); - - try { - if (auto cachedBinaryProgram = util::readFile(*cachePath)) { - const BinaryProgram binaryProgram(std::move(*cachedBinaryProgram)); - if (binaryProgram.identifier() == identifier) { - return std::make_unique<Program>(context, binaryProgram); - } else { - Log::Warning(Event::OpenGL, - "Cached program %s changed. Recompilation required.", - name); + 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()); } - } catch (std::runtime_error& error) { - Log::Warning(Event::OpenGL, "Could not load cached program: %s", - error.what()); } +#endif // Compile the shader - auto result = std::make_unique<Program>(context, vertexSource, fragmentSource); + const std::initializer_list<const char*> vertexSource = { + programParameters.getDefines().c_str(), + additionalDefines.c_str(), + (programs::gl::shaderSource() + programs::gl::vertexPreludeOffset), + (programs::gl::shaderSource() + vertexOffset) + }; + const std::initializer_list<const char*> fragmentSource = { + programParameters.getDefines().c_str(), + additionalDefines.c_str(), + (programs::gl::shaderSource() + programs::gl::fragmentPreludeOffset), + (programs::gl::shaderSource() + fragmentOffset) + }; + auto result = std::make_unique<Instance>(context, vertexSource, fragmentSource); - try { - if (const auto binaryProgram = - result->template get<BinaryProgram>(context, identifier)) { - util::write_file(*cachePath, binaryProgram->serialize()); - Log::Warning(Event::OpenGL, "Caching program in: %s", (*cachePath).c_str()); +#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()); } - } catch (std::runtime_error& error) { - Log::Warning(Event::OpenGL, "Failed to cache program: %s", error.what()); } - +#endif + return std::move(result); } -#endif - (void)name; - return std::make_unique<Program>(context, vertexSource, fragmentSource); - } - - 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() }; + 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 {}; } - return {}; - } + + UniqueProgram program; + gl::AttributeLocations<AttributeList> attributeLocations; + gl::UniformStates<UniformList> uniformStates; + gl::TextureStates<TextureList> textureStates; + }; void draw(gfx::Context& genericContext, const gfx::DrawMode& drawMode, @@ -139,16 +175,29 @@ public: context.setColorMode(colorMode); context.setCullFaceMode(cullFaceMode); - context.program = program; + const uint32_t key = gl::AttributeKey<AttributeList>::compute(attributeBindings); + auto it = instances.find(key); + if (it == instances.end()) { + it = instances + .emplace(key, + Instance::createInstance( + context, + programParameters, + gl::AttributeKey<AttributeList>::defines(attributeBindings))) + .first; + } - uniformStates.bind(uniformValues); + auto& instance = *it->second; + context.program = instance.program; - textureStates.bind(context, textureBindings); + instance.uniformStates.bind(uniformValues); + + instance.textureStates.bind(context, textureBindings); auto& vertexArray = reinterpret_cast<gl::DrawScopeResource&>(*drawScope.resource).vertexArray; vertexArray.bind(context, indexBuffer, - attributeLocations.toBindingArray(attributeBindings)); + instance.attributeLocations.toBindingArray(attributeBindings)); context.draw(drawMode, indexOffset, @@ -156,11 +205,7 @@ public: } private: - UniqueProgram program; - - gl::AttributeLocations<AttributeList> attributeLocations; - gl::UniformStates<UniformList> uniformStates; - gl::TextureStates<TextureList> textureStates; + std::map<uint32_t, std::unique_ptr<Instance>> instances; }; } // namespace gl diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp index b108a43da3..2b218d1768 100644 --- a/src/mbgl/programs/circle_program.hpp +++ b/src/mbgl/programs/circle_program.hpp @@ -52,7 +52,7 @@ class CircleLayerPrograms final : public LayerTypePrograms { public: CircleLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) : circle(context, programParameters) {} - ProgramMap<CircleProgram> circle; + CircleProgram circle; }; } // namespace mbgl diff --git a/src/mbgl/programs/fill_extrusion_program.hpp b/src/mbgl/programs/fill_extrusion_program.hpp index ca696230b4..85e2ff3caf 100644 --- a/src/mbgl/programs/fill_extrusion_program.hpp +++ b/src/mbgl/programs/fill_extrusion_program.hpp @@ -117,8 +117,8 @@ public: : fillExtrusion(context, programParameters), fillExtrusionPattern(context, programParameters), extrusionTexture(context, programParameters) {} - ProgramMap<FillExtrusionProgram> fillExtrusion; - ProgramMap<FillExtrusionPatternProgram> fillExtrusionPattern; + FillExtrusionProgram fillExtrusion; + FillExtrusionPatternProgram fillExtrusionPattern; ExtrusionTextureProgram extrusionTexture; }; diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp index 4684a84f54..99314c51b0 100644 --- a/src/mbgl/programs/fill_program.hpp +++ b/src/mbgl/programs/fill_program.hpp @@ -110,10 +110,10 @@ public: fillPattern(context, programParameters), fillOutline(context, programParameters), fillOutlinePattern(context, programParameters) {} - ProgramMap<FillProgram> fill; - ProgramMap<FillPatternProgram> fillPattern; - ProgramMap<FillOutlineProgram> fillOutline; - ProgramMap<FillOutlinePatternProgram> fillOutlinePattern; + FillProgram fill; + FillPatternProgram fillPattern; + FillOutlineProgram fillOutline; + FillOutlinePatternProgram fillOutlinePattern; }; } // namespace mbgl diff --git a/src/mbgl/programs/gl/background.cpp b/src/mbgl/programs/gl/background.cpp index da5ea25410..78074d670f 100644 --- a/src/mbgl/programs/gl/background.cpp +++ b/src/mbgl/programs/gl/background.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/background_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<BackgroundProgram> { + static constexpr const char* name = "background"; + static constexpr const uint8_t hash[8] = { 0x2d, 0xef, 0x97, 0xa2, 0xec, 0xb5, 0x67, 0xef }; + static constexpr const auto vertexOffset = 1429; + static constexpr const auto fragmentOffset = 1525; +}; + +constexpr const char* ShaderSource<BackgroundProgram>::name; +constexpr const uint8_t ShaderSource<BackgroundProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<BackgroundProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<BackgroundProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "background", - programs::gl::shaderSource() + 1429, programs::gl::shaderSource() + 1525); + return std::make_unique<gl::Program<BackgroundProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/background_pattern.cpp b/src/mbgl/programs/gl/background_pattern.cpp index af5d87129e..04111c7abd 100644 --- a/src/mbgl/programs/gl/background_pattern.cpp +++ b/src/mbgl/programs/gl/background_pattern.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/background_pattern_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<BackgroundPatternProgram> { + static constexpr const char* name = "background_pattern"; + static constexpr const uint8_t hash[8] = { 0x70, 0x13, 0xc8, 0x7e, 0xba, 0x18, 0xf5, 0x19 }; + static constexpr const auto vertexOffset = 1675; + static constexpr const auto fragmentOffset = 2266; +}; + +constexpr const char* ShaderSource<BackgroundPatternProgram>::name; +constexpr const uint8_t ShaderSource<BackgroundPatternProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<BackgroundPatternProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<BackgroundPatternProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "background_pattern", - programs::gl::shaderSource() + 1675, programs::gl::shaderSource() + 2266); + return std::make_unique<gl::Program<BackgroundPatternProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/circle.cpp b/src/mbgl/programs/gl/circle.cpp index ae2b65c20f..d1f1e29d33 100644 --- a/src/mbgl/programs/gl/circle.cpp +++ b/src/mbgl/programs/gl/circle.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/circle_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<CircleProgram> { + static constexpr const char* name = "circle"; + static constexpr const uint8_t hash[8] = { 0xf0, 0x3e, 0x18, 0xb7, 0x75, 0xb2, 0xde, 0xa9 }; + static constexpr const auto vertexOffset = 2927; + static constexpr const auto fragmentOffset = 6093; +}; + +constexpr const char* ShaderSource<CircleProgram>::name; +constexpr const uint8_t ShaderSource<CircleProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<CircleProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<CircleProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "circle", - programs::gl::shaderSource() + 2927, programs::gl::shaderSource() + 6093); + return std::make_unique<gl::Program<CircleProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/clipping_mask.cpp b/src/mbgl/programs/gl/clipping_mask.cpp index 311877f065..3179ab0c13 100644 --- a/src/mbgl/programs/gl/clipping_mask.cpp +++ b/src/mbgl/programs/gl/clipping_mask.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/clipping_mask_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<ClippingMaskProgram> { + static constexpr const char* name = "clipping_mask"; + static constexpr const uint8_t hash[8] = { 0x3e, 0x17, 0xc2, 0x3a, 0x1f, 0xf0, 0xa8, 0xa3 }; + static constexpr const auto vertexOffset = 7848; + static constexpr const auto fragmentOffset = 7944; +}; + +constexpr const char* ShaderSource<ClippingMaskProgram>::name; +constexpr const uint8_t ShaderSource<ClippingMaskProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<ClippingMaskProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<ClippingMaskProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "clipping_mask", - programs::gl::shaderSource() + 7848, programs::gl::shaderSource() + 7944); + return std::make_unique<gl::Program<ClippingMaskProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/collision_box.cpp b/src/mbgl/programs/gl/collision_box.cpp index 9af67f7981..f7ac4d4d67 100644 --- a/src/mbgl/programs/gl/collision_box.cpp +++ b/src/mbgl/programs/gl/collision_box.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/collision_box_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<CollisionBoxProgram> { + static constexpr const char* name = "collision_box"; + static constexpr const uint8_t hash[8] = { 0xcb, 0x6a, 0x9b, 0xd1, 0x1f, 0x31, 0xf8, 0x5b }; + static constexpr const auto vertexOffset = 9956; + static constexpr const auto fragmentOffset = 10635; +}; + +constexpr const char* ShaderSource<CollisionBoxProgram>::name; +constexpr const uint8_t ShaderSource<CollisionBoxProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<CollisionBoxProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<CollisionBoxProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "collision_box", - programs::gl::shaderSource() + 9956, programs::gl::shaderSource() + 10635); + return std::make_unique<gl::Program<CollisionBoxProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/collision_circle.cpp b/src/mbgl/programs/gl/collision_circle.cpp index 843f9161bb..8f1b5726fe 100644 --- a/src/mbgl/programs/gl/collision_circle.cpp +++ b/src/mbgl/programs/gl/collision_circle.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/collision_circle_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<CollisionCircleProgram> { + static constexpr const char* name = "collision_circle"; + static constexpr const uint8_t hash[8] = { 0x99, 0x2e, 0xad, 0x8c, 0xd3, 0x88, 0xae, 0x82 }; + static constexpr const auto vertexOffset = 10858; + static constexpr const auto fragmentOffset = 11774; +}; + +constexpr const char* ShaderSource<CollisionCircleProgram>::name; +constexpr const uint8_t ShaderSource<CollisionCircleProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<CollisionCircleProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<CollisionCircleProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "collision_circle", - programs::gl::shaderSource() + 10858, programs::gl::shaderSource() + 11774); + return std::make_unique<gl::Program<CollisionCircleProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/debug.cpp b/src/mbgl/programs/gl/debug.cpp index 8b7aee5a0b..ad23f420ab 100644 --- a/src/mbgl/programs/gl/debug.cpp +++ b/src/mbgl/programs/gl/debug.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/debug_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<DebugProgram> { + static constexpr const char* name = "debug"; + static constexpr const uint8_t hash[8] = { 0xa8, 0x7d, 0x87, 0x6e, 0x36, 0xa8, 0x81, 0xe3 }; + static constexpr const auto vertexOffset = 12450; + static constexpr const auto fragmentOffset = 12546; +}; + +constexpr const char* ShaderSource<DebugProgram>::name; +constexpr const uint8_t ShaderSource<DebugProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<DebugProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<DebugProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "debug", - programs::gl::shaderSource() + 12450, programs::gl::shaderSource() + 12546); + return std::make_unique<gl::Program<DebugProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/extrusion_texture.cpp b/src/mbgl/programs/gl/extrusion_texture.cpp index bd320d52cf..bca533a788 100644 --- a/src/mbgl/programs/gl/extrusion_texture.cpp +++ b/src/mbgl/programs/gl/extrusion_texture.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/extrusion_texture_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<ExtrusionTextureProgram> { + static constexpr const char* name = "extrusion_texture"; + static constexpr const uint8_t hash[8] = { 0xd9, 0x77, 0x11, 0xd2, 0x03, 0xc7, 0x27, 0xcb }; + static constexpr const auto vertexOffset = 27554; + static constexpr const auto fragmentOffset = 27734; +}; + +constexpr const char* ShaderSource<ExtrusionTextureProgram>::name; +constexpr const uint8_t ShaderSource<ExtrusionTextureProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<ExtrusionTextureProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<ExtrusionTextureProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "extrusion_texture", - programs::gl::shaderSource() + 27554, programs::gl::shaderSource() + 27734); + return std::make_unique<gl::Program<ExtrusionTextureProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill.cpp b/src/mbgl/programs/gl/fill.cpp index 44ab40949c..a699f82609 100644 --- a/src/mbgl/programs/gl/fill.cpp +++ b/src/mbgl/programs/gl/fill.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillProgram> { + static constexpr const char* name = "fill"; + static constexpr const uint8_t hash[8] = { 0x87, 0xea, 0x65, 0x7f, 0x0c, 0x9b, 0x97, 0x5d }; + static constexpr const auto vertexOffset = 12610; + static constexpr const auto fragmentOffset = 13254; +}; + +constexpr const char* ShaderSource<FillProgram>::name; +constexpr const uint8_t ShaderSource<FillProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill", - programs::gl::shaderSource() + 12610, programs::gl::shaderSource() + 13254); + return std::make_unique<gl::Program<FillProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill_extrusion.cpp b/src/mbgl/programs/gl/fill_extrusion.cpp index bd26d7afde..83a8eadee6 100644 --- a/src/mbgl/programs/gl/fill_extrusion.cpp +++ b/src/mbgl/programs/gl/fill_extrusion.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_extrusion_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillExtrusionProgram> { + static constexpr const char* name = "fill_extrusion"; + static constexpr const uint8_t hash[8] = { 0x49, 0x8a, 0xa2, 0x8b, 0x21, 0x74, 0x27, 0x93 }; + static constexpr const auto vertexOffset = 21238; + static constexpr const auto fragmentOffset = 23121; +}; + +constexpr const char* ShaderSource<FillExtrusionProgram>::name; +constexpr const uint8_t ShaderSource<FillExtrusionProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillExtrusionProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillExtrusionProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill_extrusion", - programs::gl::shaderSource() + 21238, programs::gl::shaderSource() + 23121); + return std::make_unique<gl::Program<FillExtrusionProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp b/src/mbgl/programs/gl/fill_extrusion_pattern.cpp index 94a663947a..45068d84b8 100644 --- a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp +++ b/src/mbgl/programs/gl/fill_extrusion_pattern.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_extrusion_pattern_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillExtrusionPatternProgram> { + static constexpr const char* name = "fill_extrusion_pattern"; + static constexpr const uint8_t hash[8] = { 0x93, 0x2b, 0xd1, 0xab, 0xa3, 0xf2, 0x24, 0x63 }; + static constexpr const auto vertexOffset = 23237; + static constexpr const auto fragmentOffset = 26157; +}; + +constexpr const char* ShaderSource<FillExtrusionPatternProgram>::name; +constexpr const uint8_t ShaderSource<FillExtrusionPatternProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillExtrusionPatternProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillExtrusionPatternProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill_extrusion_pattern", - programs::gl::shaderSource() + 23237, programs::gl::shaderSource() + 26157); + return std::make_unique<gl::Program<FillExtrusionPatternProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill_outline.cpp b/src/mbgl/programs/gl/fill_outline.cpp index 6186db4c9a..e7644468a5 100644 --- a/src/mbgl/programs/gl/fill_outline.cpp +++ b/src/mbgl/programs/gl/fill_outline.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_outline_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillOutlineProgram> { + static constexpr const char* name = "fill_outline"; + static constexpr const uint8_t hash[8] = { 0x56, 0x65, 0x69, 0x4b, 0x70, 0x2d, 0x3d, 0xc4 }; + static constexpr const auto vertexOffset = 13678; + static constexpr const auto fragmentOffset = 14503; +}; + +constexpr const char* ShaderSource<FillOutlineProgram>::name; +constexpr const uint8_t ShaderSource<FillOutlineProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillOutlineProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillOutlineProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill_outline", - programs::gl::shaderSource() + 13678, programs::gl::shaderSource() + 14503); + return std::make_unique<gl::Program<FillOutlineProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill_outline_pattern.cpp b/src/mbgl/programs/gl/fill_outline_pattern.cpp index 9989c4076a..40aa5ea2de 100644 --- a/src/mbgl/programs/gl/fill_outline_pattern.cpp +++ b/src/mbgl/programs/gl/fill_outline_pattern.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_outline_pattern_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillOutlinePatternProgram> { + static constexpr const char* name = "fill_outline_pattern"; + static constexpr const uint8_t hash[8] = { 0x56, 0x9c, 0x2f, 0x58, 0x6b, 0x31, 0xff, 0x84 }; + static constexpr const auto vertexOffset = 15092; + static constexpr const auto fragmentOffset = 16952; +}; + +constexpr const char* ShaderSource<FillOutlinePatternProgram>::name; +constexpr const uint8_t ShaderSource<FillOutlinePatternProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillOutlinePatternProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillOutlinePatternProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill_outline_pattern", - programs::gl::shaderSource() + 15092, programs::gl::shaderSource() + 16952); + return std::make_unique<gl::Program<FillOutlinePatternProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/fill_pattern.cpp b/src/mbgl/programs/gl/fill_pattern.cpp index 10d6c6ab85..fd16d8bfc9 100644 --- a/src/mbgl/programs/gl/fill_pattern.cpp +++ b/src/mbgl/programs/gl/fill_pattern.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/fill_pattern_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<FillPatternProgram> { + static constexpr const char* name = "fill_pattern"; + static constexpr const uint8_t hash[8] = { 0x74, 0xa9, 0x97, 0x01, 0x96, 0xbd, 0x87, 0x36 }; + static constexpr const auto vertexOffset = 18259; + static constexpr const auto fragmentOffset = 20038; +}; + +constexpr const char* ShaderSource<FillPatternProgram>::name; +constexpr const uint8_t ShaderSource<FillPatternProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<FillPatternProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<FillPatternProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "fill_pattern", - programs::gl::shaderSource() + 18259, programs::gl::shaderSource() + 20038); + return std::make_unique<gl::Program<FillPatternProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/heatmap.cpp b/src/mbgl/programs/gl/heatmap.cpp index 836fd52b07..3b960f1bda 100644 --- a/src/mbgl/programs/gl/heatmap.cpp +++ b/src/mbgl/programs/gl/heatmap.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/heatmap_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<HeatmapProgram> { + static constexpr const char* name = "heatmap"; + static constexpr const uint8_t hash[8] = { 0xab, 0x97, 0x81, 0x5c, 0xa2, 0x88, 0xaa, 0x7e }; + static constexpr const auto vertexOffset = 7983; + static constexpr const auto fragmentOffset = 9030; +}; + +constexpr const char* ShaderSource<HeatmapProgram>::name; +constexpr const uint8_t ShaderSource<HeatmapProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<HeatmapProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<HeatmapProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "heatmap", - programs::gl::shaderSource() + 7983, programs::gl::shaderSource() + 9030); + return std::make_unique<gl::Program<HeatmapProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/heatmap_texture.cpp b/src/mbgl/programs/gl/heatmap_texture.cpp index 530e9fa18b..57b033d55c 100644 --- a/src/mbgl/programs/gl/heatmap_texture.cpp +++ b/src/mbgl/programs/gl/heatmap_texture.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/heatmap_texture_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<HeatmapTextureProgram> { + static constexpr const char* name = "heatmap_texture"; + static constexpr const uint8_t hash[8] = { 0x9f, 0xc7, 0x56, 0xb2, 0x9e, 0x8f, 0x15, 0xff }; + static constexpr const auto vertexOffset = 9491; + static constexpr const auto fragmentOffset = 9671; +}; + +constexpr const char* ShaderSource<HeatmapTextureProgram>::name; +constexpr const uint8_t ShaderSource<HeatmapTextureProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<HeatmapTextureProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<HeatmapTextureProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "heatmap_texture", - programs::gl::shaderSource() + 9491, programs::gl::shaderSource() + 9671); + return std::make_unique<gl::Program<HeatmapTextureProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/hillshade.cpp b/src/mbgl/programs/gl/hillshade.cpp index dcf90f1149..a33ddb4326 100644 --- a/src/mbgl/programs/gl/hillshade.cpp +++ b/src/mbgl/programs/gl/hillshade.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/hillshade_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<HillshadeProgram> { + static constexpr const char* name = "hillshade"; + static constexpr const uint8_t hash[8] = { 0x8a, 0x11, 0x29, 0x18, 0x52, 0x7f, 0x3b, 0xbb }; + static constexpr const auto vertexOffset = 29340; + static constexpr const auto fragmentOffset = 29511; +}; + +constexpr const char* ShaderSource<HillshadeProgram>::name; +constexpr const uint8_t ShaderSource<HillshadeProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<HillshadeProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<HillshadeProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "hillshade", - programs::gl::shaderSource() + 29340, programs::gl::shaderSource() + 29511); + return std::make_unique<gl::Program<HillshadeProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/hillshade_prepare.cpp b/src/mbgl/programs/gl/hillshade_prepare.cpp index b445713530..a302db5feb 100644 --- a/src/mbgl/programs/gl/hillshade_prepare.cpp +++ b/src/mbgl/programs/gl/hillshade_prepare.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/hillshade_prepare_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<HillshadePrepareProgram> { + static constexpr const char* name = "hillshade_prepare"; + static constexpr const uint8_t hash[8] = { 0xe6, 0x01, 0xf2, 0xbb, 0xa0, 0x77, 0x1d, 0xeb }; + static constexpr const auto vertexOffset = 27925; + static constexpr const auto fragmentOffset = 28218; +}; + +constexpr const char* ShaderSource<HillshadePrepareProgram>::name; +constexpr const uint8_t ShaderSource<HillshadePrepareProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<HillshadePrepareProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<HillshadePrepareProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "hillshade_prepare", - programs::gl::shaderSource() + 27925, programs::gl::shaderSource() + 28218); + return std::make_unique<gl::Program<HillshadePrepareProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/line.cpp b/src/mbgl/programs/gl/line.cpp index 1f96b74a9c..e59cb07cb9 100644 --- a/src/mbgl/programs/gl/line.cpp +++ b/src/mbgl/programs/gl/line.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/line_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<LineProgram> { + static constexpr const char* name = "line"; + static constexpr const uint8_t hash[8] = { 0x44, 0x46, 0x9e, 0x59, 0x02, 0xbb, 0xaa, 0xae }; + static constexpr const auto vertexOffset = 30585; + static constexpr const auto fragmentOffset = 33509; +}; + +constexpr const char* ShaderSource<LineProgram>::name; +constexpr const uint8_t ShaderSource<LineProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<LineProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<LineProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "line", - programs::gl::shaderSource() + 30585, programs::gl::shaderSource() + 33509); + return std::make_unique<gl::Program<LineProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/line_gradient.cpp b/src/mbgl/programs/gl/line_gradient.cpp index 493fc850d1..f5325f84ba 100644 --- a/src/mbgl/programs/gl/line_gradient.cpp +++ b/src/mbgl/programs/gl/line_gradient.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/line_gradient_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<LineGradientProgram> { + static constexpr const char* name = "line_gradient"; + static constexpr const uint8_t hash[8] = { 0xee, 0xdd, 0x10, 0x3d, 0x1a, 0x21, 0x26, 0x25 }; + static constexpr const auto vertexOffset = 34335; + static constexpr const auto fragmentOffset = 37054; +}; + +constexpr const char* ShaderSource<LineGradientProgram>::name; +constexpr const uint8_t ShaderSource<LineGradientProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<LineGradientProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<LineGradientProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "line_gradient", - programs::gl::shaderSource() + 34335, programs::gl::shaderSource() + 37054); + return std::make_unique<gl::Program<LineGradientProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/line_pattern.cpp b/src/mbgl/programs/gl/line_pattern.cpp index 747b2bd197..e323b16785 100644 --- a/src/mbgl/programs/gl/line_pattern.cpp +++ b/src/mbgl/programs/gl/line_pattern.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/line_pattern_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<LinePatternProgram> { + static constexpr const char* name = "line_pattern"; + static constexpr const uint8_t hash[8] = { 0x73, 0xa0, 0x59, 0x46, 0x57, 0xa5, 0x60, 0x25 }; + static constexpr const auto vertexOffset = 37841; + static constexpr const auto fragmentOffset = 41162; +}; + +constexpr const char* ShaderSource<LinePatternProgram>::name; +constexpr const uint8_t ShaderSource<LinePatternProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<LinePatternProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<LinePatternProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "line_pattern", - programs::gl::shaderSource() + 37841, programs::gl::shaderSource() + 41162); + return std::make_unique<gl::Program<LinePatternProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/line_sdf.cpp b/src/mbgl/programs/gl/line_sdf.cpp index 12fb5b61fd..a7b4e7e3b7 100644 --- a/src/mbgl/programs/gl/line_sdf.cpp +++ b/src/mbgl/programs/gl/line_sdf.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/line_sdf_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<LineSDFProgram> { + static constexpr const char* name = "line_sdf"; + static constexpr const uint8_t hash[8] = { 0x66, 0x20, 0x75, 0x4e, 0xbe, 0x02, 0x9e, 0x67 }; + static constexpr const auto vertexOffset = 43475; + static constexpr const auto fragmentOffset = 47089; +}; + +constexpr const char* ShaderSource<LineSDFProgram>::name; +constexpr const uint8_t ShaderSource<LineSDFProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<LineSDFProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<LineSDFProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "line_sdf", - programs::gl::shaderSource() + 43475, programs::gl::shaderSource() + 47089); + return std::make_unique<gl::Program<LineSDFProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/preludes.cpp b/src/mbgl/programs/gl/preludes.cpp deleted file mode 100644 index 6c895c0d36..0000000000 --- a/src/mbgl/programs/gl/preludes.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#include <mbgl/programs/gl/preludes.hpp> -#include <mbgl/programs/gl/shader_source.hpp> - -namespace mbgl { -namespace programs { -namespace gl { - -const char* vertexShaderPrelude = programs::gl::shaderSource() + 0; -const char* fragmentShaderPrelude = programs::gl::shaderSource() + 1252; - -} // namespace gl -} // namespace programs -} // namespace mbgl diff --git a/src/mbgl/programs/gl/preludes.hpp b/src/mbgl/programs/gl/preludes.hpp index 6d86ee45c5..e796f1655b 100644 --- a/src/mbgl/programs/gl/preludes.hpp +++ b/src/mbgl/programs/gl/preludes.hpp @@ -2,12 +2,15 @@ #pragma once +#include <cstdint> + namespace mbgl { namespace programs { namespace gl { -extern const char* vertexShaderPrelude; -extern const char* fragmentShaderPrelude; +constexpr const uint8_t preludeHash[8] = { 0x24, 0x91, 0x82, 0x37, 0x02, 0xad, 0x98, 0x0a }; +constexpr const auto vertexPreludeOffset = 0; +constexpr const auto fragmentPreludeOffset = 1252; } // namespace gl } // namespace programs diff --git a/src/mbgl/programs/gl/raster.cpp b/src/mbgl/programs/gl/raster.cpp index 512dc81a30..1867a48f1c 100644 --- a/src/mbgl/programs/gl/raster.cpp +++ b/src/mbgl/programs/gl/raster.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/raster_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<RasterProgram> { + static constexpr const char* name = "raster"; + static constexpr const uint8_t hash[8] = { 0x40, 0x3d, 0x6c, 0xf4, 0xd0, 0x41, 0x51, 0x0e }; + static constexpr const auto vertexOffset = 48592; + static constexpr const auto fragmentOffset = 48941; +}; + +constexpr const char* ShaderSource<RasterProgram>::name; +constexpr const uint8_t ShaderSource<RasterProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<RasterProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<RasterProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "raster", - programs::gl::shaderSource() + 48592, programs::gl::shaderSource() + 48941); + return std::make_unique<gl::Program<RasterProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/shader_source.hpp b/src/mbgl/programs/gl/shader_source.hpp index f6de8a56cc..1a5fbddae3 100644 --- a/src/mbgl/programs/gl/shader_source.hpp +++ b/src/mbgl/programs/gl/shader_source.hpp @@ -8,6 +8,9 @@ namespace gl { const char* shaderSource(); +template <typename> +struct ShaderSource; + } // namespace gl } // namespace programs } // namespace mbgl diff --git a/src/mbgl/programs/gl/shaders.cpp b/src/mbgl/programs/gl/shaders.cpp index 3cc33992de..6fb4d70db9 100644 --- a/src/mbgl/programs/gl/shaders.cpp +++ b/src/mbgl/programs/gl/shaders.cpp @@ -1,4 +1,5 @@ #include <mbgl/programs/gl/shaders.hpp> +#include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/program_parameters.hpp> #include <mbgl/util/string.hpp> @@ -9,20 +10,17 @@ namespace mbgl { namespace programs { namespace gl { -std::string fragmentSource(const ProgramParameters& parameters, const char* fragmentSource) { - return parameters.getDefines() + fragmentShaderPrelude + fragmentSource; -} - -std::string vertexSource(const ProgramParameters& parameters, const char* vertexSource) { - return parameters.getDefines() + vertexShaderPrelude + vertexSource; -} - -std::string programIdentifier(const std::string& vertexSource, const std::string& fragmentSource) { +std::string programIdentifier(const std::string& defines1, + const std::string& defines2, + const uint8_t hash1[8], + const uint8_t hash2[8]) { std::string result; - result.reserve((sizeof(size_t) * 2) * 2 + 2); // 2 size_t hex values + "v2" - result += util::toHex(std::hash<std::string>()(vertexSource)); - result += util::toHex(std::hash<std::string>()(fragmentSource)); - result += "v3"; + result.reserve(8 + 8 + (sizeof(size_t) * 2) * 2 + 2); + result.append(util::toHex(std::hash<std::string>()(defines1))); + result.append(util::toHex(std::hash<std::string>()(defines2))); + result.append(hash1, hash2 + 8); + result.append(hash2, hash2 + 8); + result.append("v3"); return result; } diff --git a/src/mbgl/programs/gl/shaders.hpp b/src/mbgl/programs/gl/shaders.hpp index 5278ea54da..46a87f4af8 100644 --- a/src/mbgl/programs/gl/shaders.hpp +++ b/src/mbgl/programs/gl/shaders.hpp @@ -9,9 +9,10 @@ class ProgramParameters; namespace programs { namespace gl { -std::string fragmentSource(const ProgramParameters&, const char* fragmentSource); -std::string vertexSource(const ProgramParameters&, const char* vertexSource); -std::string programIdentifier(const std::string& vertexSource, const std::string& fragmentSource); +std::string programIdentifier(const std::string& defines1, + const std::string& defines2, + const uint8_t hash1[8], + const uint8_t hash2[8]); } // namespace gl } // namespace programs diff --git a/src/mbgl/programs/gl/symbol_icon.cpp b/src/mbgl/programs/gl/symbol_icon.cpp index 1cf2090ba3..6cb2b88543 100644 --- a/src/mbgl/programs/gl/symbol_icon.cpp +++ b/src/mbgl/programs/gl/symbol_icon.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/symbol_icon_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<SymbolIconProgram> { + static constexpr const char* name = "symbol_icon"; + static constexpr const uint8_t hash[8] = { 0x96, 0x0c, 0xef, 0xec, 0x37, 0x23, 0xf9, 0xb1 }; + static constexpr const auto vertexOffset = 50000; + static constexpr const auto fragmentOffset = 52654; +}; + +constexpr const char* ShaderSource<SymbolIconProgram>::name; +constexpr const uint8_t ShaderSource<SymbolIconProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<SymbolIconProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<SymbolIconProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "symbol_icon", - programs::gl::shaderSource() + 50000, programs::gl::shaderSource() + 52654); + return std::make_unique<gl::Program<SymbolIconProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/symbol_sdf_icon.cpp b/src/mbgl/programs/gl/symbol_sdf_icon.cpp index ccb213bcfd..d98554099f 100644 --- a/src/mbgl/programs/gl/symbol_sdf_icon.cpp +++ b/src/mbgl/programs/gl/symbol_sdf_icon.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/symbol_sdf_icon_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<SymbolSDFIconProgram> { + static constexpr const char* name = "symbol_sdf_icon"; + static constexpr const uint8_t hash[8] = { 0x13, 0xfc, 0x05, 0x2a, 0xd1, 0x93, 0xfb, 0x7d }; + static constexpr const auto vertexOffset = 53059; + static constexpr const auto fragmentOffset = 57099; +}; + +constexpr const char* ShaderSource<SymbolSDFIconProgram>::name; +constexpr const uint8_t ShaderSource<SymbolSDFIconProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<SymbolSDFIconProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<SymbolSDFIconProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "symbol_sdf_icon", - programs::gl::shaderSource() + 53059, programs::gl::shaderSource() + 57099); + return std::make_unique<gl::Program<SymbolSDFIconProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/gl/symbol_sdf_text.cpp b/src/mbgl/programs/gl/symbol_sdf_text.cpp index 0d08a64dee..81f3729d92 100644 --- a/src/mbgl/programs/gl/symbol_sdf_text.cpp +++ b/src/mbgl/programs/gl/symbol_sdf_text.cpp @@ -1,18 +1,37 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/programs/symbol_sdf_text_program.hpp> +#include <mbgl/programs/gl/preludes.hpp> #include <mbgl/programs/gl/shader_source.hpp> #include <mbgl/gl/program.hpp> namespace mbgl { +namespace programs { +namespace gl { + +template <typename> +struct ShaderSource; + +template <> +struct ShaderSource<SymbolSDFTextProgram> { + static constexpr const char* name = "symbol_sdf_text"; + static constexpr const uint8_t hash[8] = { 0x13, 0xfc, 0x05, 0x2a, 0xd1, 0x93, 0xfb, 0x7d }; + static constexpr const auto vertexOffset = 53059; + static constexpr const auto fragmentOffset = 57099; +}; + +constexpr const char* ShaderSource<SymbolSDFTextProgram>::name; +constexpr const uint8_t ShaderSource<SymbolSDFTextProgram>::hash[8]; + +} // namespace gl +} // namespace programs + namespace gfx { template <> std::unique_ptr<Program<SymbolSDFTextProgram>> Context::createProgram<gl::Context>(const ProgramParameters& programParameters) { - return gl::Program<SymbolSDFTextProgram>::createProgram( - reinterpret_cast<gl::Context&>(*this), programParameters, "symbol_sdf_text", - programs::gl::shaderSource() + 53059, programs::gl::shaderSource() + 57099); + return std::make_unique<gl::Program<SymbolSDFTextProgram>>(programParameters); } } // namespace gfx diff --git a/src/mbgl/programs/heatmap_program.hpp b/src/mbgl/programs/heatmap_program.hpp index 89ba655105..537a9e9565 100644 --- a/src/mbgl/programs/heatmap_program.hpp +++ b/src/mbgl/programs/heatmap_program.hpp @@ -52,7 +52,7 @@ public: HeatmapLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) : heatmap(context, programParameters), heatmapTexture(context, programParameters) {} - ProgramMap<HeatmapProgram> heatmap; + HeatmapProgram heatmap; HeatmapTextureProgram heatmapTexture; }; diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp index 9ec01bd3ac..26f630a5eb 100644 --- a/src/mbgl/programs/line_program.hpp +++ b/src/mbgl/programs/line_program.hpp @@ -189,10 +189,10 @@ public: lineGradient(context, programParameters), lineSDF(context, programParameters), linePattern(context, programParameters) {} - ProgramMap<LineProgram> line; - ProgramMap<LineGradientProgram> lineGradient; - ProgramMap<LineSDFProgram> lineSDF; - ProgramMap<LinePatternProgram> linePattern; + LineProgram line; + LineGradientProgram lineGradient; + LineSDFProgram lineSDF; + LinePatternProgram linePattern; }; } // namespace mbgl diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index 240da22b4f..e4d2af95f8 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -109,36 +109,6 @@ public: } }; -template <class Program> -class ProgramMap { -public: - using PaintProperties = typename Program::PaintProperties; - using Binders = typename Program::Binders; - using Bitset = typename Binders::Bitset; - - ProgramMap(gfx::Context& context_, ProgramParameters parameters_) - : context(context_), - parameters(std::move(parameters_)) { - } - - Program& get(const typename PaintProperties::PossiblyEvaluated& currentProperties) { - Bitset bits = Binders::constants(currentProperties); - auto it = programs.find(bits); - if (it != programs.end()) { - return it->second; - } - return programs.emplace(std::piecewise_construct, - std::forward_as_tuple(bits), - std::forward_as_tuple(context, - parameters.withAdditionalDefines(Binders::defines(currentProperties)))).first->second; - } - -private: - gfx::Context& context; - ProgramParameters parameters; - std::unordered_map<Bitset, Program> programs; -}; - class LayerTypePrograms { public: virtual ~LayerTypePrograms() = default; diff --git a/src/mbgl/programs/program_parameters.cpp b/src/mbgl/programs/program_parameters.cpp index 6b6c2bb2fe..e692b74e0e 100644 --- a/src/mbgl/programs/program_parameters.cpp +++ b/src/mbgl/programs/program_parameters.cpp @@ -40,13 +40,4 @@ optional<std::string> ProgramParameters::cachePath(const char* name) const { } } -ProgramParameters ProgramParameters::withAdditionalDefines(const std::vector<std::string>& additionalDefines) const { - ProgramParameters result(*this); - for (const auto& define : additionalDefines) { - result.defines += define; - result.defines += "\n"; - } - return result; -} - } // namespace mbgl diff --git a/src/mbgl/programs/program_parameters.hpp b/src/mbgl/programs/program_parameters.hpp index e94e61c217..71ad454399 100644 --- a/src/mbgl/programs/program_parameters.hpp +++ b/src/mbgl/programs/program_parameters.hpp @@ -3,7 +3,6 @@ #include <mbgl/util/optional.hpp> #include <string> -#include <vector> namespace mbgl { @@ -14,8 +13,6 @@ public: const std::string& getDefines() const; optional<std::string> cachePath(const char* name) const; - ProgramParameters withAdditionalDefines(const std::vector<std::string>& defines) const; - private: std::string defines; optional<std::string> cacheDir; diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 66e53647ef..9c00caef84 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -468,9 +468,9 @@ public: symbolGlyph(context, programParameters), collisionBox(context, programParameters), collisionCircle(context, programParameters) {} - ProgramMap<SymbolIconProgram> symbolIcon; - ProgramMap<SymbolSDFIconProgram> symbolIconSDF; - ProgramMap<SymbolSDFTextProgram> symbolGlyph; + SymbolIconProgram symbolIcon; + SymbolSDFIconProgram symbolIconSDF; + SymbolSDFTextProgram symbolGlyph; CollisionBoxProgram collisionBox; CollisionCircleProgram collisionCircle; }; diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 9b463e6a6f..1c13a6152b 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -65,7 +65,7 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) { const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); - auto& programInstance = parameters.programs.getCircleLayerPrograms().circle.get(evaluated); + auto& programInstance = parameters.programs.getCircleLayerPrograms().circle; const auto allUniformValues = programInstance.computeAllUniformValues( CircleProgram::LayoutUniformValues { diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 0d0c9034e1..13ef84f169 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -119,7 +119,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* FillExtrusionBucket& bucket = *bucket_; draw( - parameters.programs.getFillExtrusionLayerPrograms().fillExtrusion.get(evaluated), + parameters.programs.getFillExtrusionLayerPrograms().fillExtrusion, bucket, FillExtrusionProgram::layoutUniformValues( tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), @@ -146,7 +146,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* FillExtrusionBucket& bucket = *bucket_; draw( - parameters.programs.getFillExtrusionLayerPrograms().fillExtrusionPattern.get(evaluated), + parameters.programs.getFillExtrusionLayerPrograms().fillExtrusionPattern, bucket, FillExtrusionPatternProgram::layoutUniformValues( tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 2c6f1127f2..205a38e380 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -74,14 +74,12 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { } FillBucket& bucket = *bucket_; - auto draw = [&] (auto& program, + auto draw = [&] (auto& programInstance, const auto& drawMode, const auto& depthMode, const auto& indexBuffer, const auto& segments, auto&& textureBindings) { - auto& programInstance = program.get(evaluated); - const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); const auto allUniformValues = programInstance.computeAllUniformValues( @@ -162,14 +160,12 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { } FillBucket& bucket = *bucket_; - auto draw = [&] (auto& program, + auto draw = [&] (auto& programInstance, const auto& drawMode, const auto& depthMode, const auto& indexBuffer, const auto& segments, auto&& textureBindings) { - auto& programInstance = program.get(evaluated); - const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade); diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index a8d25df818..f8ba68965e 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -102,7 +102,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) { const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); - auto& programInstance = parameters.programs.getHeatmapLayerPrograms().heatmap.get(evaluated); + auto& programInstance = parameters.programs.getHeatmapLayerPrograms().heatmap; const auto allUniformValues = programInstance.computeAllUniformValues( HeatmapProgram::LayoutUniformValues { diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 60c487c205..a023bc6254 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -65,11 +65,10 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) { } LineBucket& bucket = *bucket_; - auto draw = [&](auto& program, auto&& uniformValues, + auto draw = [&](auto& programInstance, + auto&& uniformValues, const optional<ImagePosition>& patternPositionA, const optional<ImagePosition>& patternPositionB, auto&& textureBindings) { - auto& programInstance = program.get(evaluated); - const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade); diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 5fbc81663c..72c641e95a 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -88,17 +88,14 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) { const auto& evaluated_ = bucketPaintProperties.evaluated; const auto& layout = bucket.layout; - auto draw = [&] (auto& program, + auto draw = [&] (auto& programInstance, auto&& uniformValues, const auto& buffers, const auto& symbolSizeBinder, const SymbolPropertyValues& values_, const auto& binders, const auto& paintProperties, - auto&& textureBindings) - { - auto& programInstance = program.get(paintProperties); - + auto&& textureBindings) { const auto allUniformValues = programInstance.computeAllUniformValues( std::move(uniformValues), *symbolSizeBinder, diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index d233e6f2e0..60866832c6 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -545,33 +545,6 @@ public: return result; } - template <class> - struct UniformDefines; - - template <class... Us> - struct UniformDefines<TypeList<Us...>> { - static constexpr auto define() { - return "#define HAS_UNIFORM_u_"; - } - - static void appendDefines(std::vector<std::string>& defines) { - util::ignore({ - (defines.push_back(concat_literals<&define, &Us::name, &string_literal<'\n'>::value>::value()), 0)... - }); - } - }; - - template <class EvaluatedProperties> - static std::vector<std::string> defines(const EvaluatedProperties& currentProperties) { - std::vector<std::string> result; - util::ignore({ - (currentProperties.template get<Ps>().isConstant() - ? UniformDefines<typename Ps::UniformList>::appendDefines(result) - : (void) 0, 0)... - }); - return result; - } - private: Binders binders; }; |