summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/core-files.cmake65
-rw-r--r--cmake/shaders.cmake7
-rw-r--r--cmake/test.cmake1
-rw-r--r--include/mbgl/util/exception.hpp5
-rwxr-xr-xscripts/build-shaders.js86
-rw-r--r--src/mbgl/gl/attribute.cpp4
-rw-r--r--src/mbgl/gl/attribute.hpp10
-rw-r--r--src/mbgl/gl/context.cpp55
-rw-r--r--src/mbgl/gl/context.hpp6
-rw-r--r--src/mbgl/gl/drawable.hpp16
-rw-r--r--src/mbgl/gl/program.hpp37
-rw-r--r--src/mbgl/gl/shader.cpp113
-rw-r--r--src/mbgl/gl/shader.hpp45
-rw-r--r--src/mbgl/gl/types.hpp5
-rw-r--r--src/mbgl/gl/uniform.cpp4
-rw-r--r--src/mbgl/gl/uniform.hpp14
-rw-r--r--src/mbgl/layout/symbol_layout.cpp16
-rw-r--r--src/mbgl/programs/attributes.hpp (renamed from src/mbgl/shader/attributes.hpp)0
-rw-r--r--src/mbgl/programs/circle_program.cpp7
-rw-r--r--src/mbgl/programs/circle_program.hpp52
-rw-r--r--src/mbgl/programs/collision_box_program.cpp7
-rw-r--r--src/mbgl/programs/collision_box_program.hpp53
-rw-r--r--src/mbgl/programs/fill_program.cpp (renamed from src/mbgl/shader/fill_uniforms.cpp)4
-rw-r--r--src/mbgl/programs/fill_program.hpp (renamed from src/mbgl/shader/fill_uniforms.hpp)80
-rw-r--r--src/mbgl/programs/line_program.cpp (renamed from src/mbgl/shader/line_uniforms.cpp)52
-rw-r--r--src/mbgl/programs/line_program.hpp184
-rw-r--r--src/mbgl/programs/program.hpp31
-rw-r--r--src/mbgl/programs/programs.hpp46
-rw-r--r--src/mbgl/programs/raster_program.cpp7
-rw-r--r--src/mbgl/programs/raster_program.hpp65
-rw-r--r--src/mbgl/programs/symbol_program.cpp (renamed from src/mbgl/shader/symbol_uniforms.cpp)30
-rw-r--r--src/mbgl/programs/symbol_program.hpp134
-rw-r--r--src/mbgl/programs/uniforms.hpp (renamed from src/mbgl/shader/uniforms.hpp)0
-rw-r--r--src/mbgl/renderer/circle_bucket.cpp10
-rw-r--r--src/mbgl/renderer/circle_bucket.hpp2
-rw-r--r--src/mbgl/renderer/debug_bucket.cpp3
-rw-r--r--src/mbgl/renderer/debug_bucket.hpp2
-rw-r--r--src/mbgl/renderer/fill_bucket.cpp5
-rw-r--r--src/mbgl/renderer/fill_bucket.hpp2
-rw-r--r--src/mbgl/renderer/line_bucket.hpp2
-rw-r--r--src/mbgl/renderer/paint_parameters.hpp4
-rw-r--r--src/mbgl/renderer/painter.cpp18
-rw-r--r--src/mbgl/renderer/painter.hpp11
-rw-r--r--src/mbgl/renderer/painter_background.cpp10
-rw-r--r--src/mbgl/renderer/painter_circle.cpp8
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp8
-rw-r--r--src/mbgl/renderer/painter_debug.cpp8
-rw-r--r--src/mbgl/renderer/painter_fill.cpp24
-rw-r--r--src/mbgl/renderer/painter_line.cpp20
-rw-r--r--src/mbgl/renderer/painter_raster.cpp8
-rw-r--r--src/mbgl/renderer/painter_symbol.cpp34
-rw-r--r--src/mbgl/renderer/raster_bucket.cpp2
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp4
-rw-r--r--src/mbgl/shader/circle_attributes.hpp30
-rw-r--r--src/mbgl/shader/circle_shader.cpp16
-rw-r--r--src/mbgl/shader/circle_shader.hpp20
-rw-r--r--src/mbgl/shader/circle_uniforms.hpp23
-rw-r--r--src/mbgl/shader/collision_box_attributes.hpp36
-rw-r--r--src/mbgl/shader/collision_box_shader.cpp17
-rw-r--r--src/mbgl/shader/collision_box_shader.hpp20
-rw-r--r--src/mbgl/shader/collision_box_uniforms.hpp18
-rw-r--r--src/mbgl/shader/fill_attributes.hpp24
-rw-r--r--src/mbgl/shader/fill_outline_pattern_shader.cpp16
-rw-r--r--src/mbgl/shader/fill_outline_pattern_shader.hpp20
-rw-r--r--src/mbgl/shader/fill_outline_shader.cpp16
-rw-r--r--src/mbgl/shader/fill_outline_shader.hpp20
-rw-r--r--src/mbgl/shader/fill_pattern_shader.cpp16
-rw-r--r--src/mbgl/shader/fill_pattern_shader.hpp20
-rw-r--r--src/mbgl/shader/fill_shader.cpp16
-rw-r--r--src/mbgl/shader/fill_shader.hpp20
-rw-r--r--src/mbgl/shader/line_attributes.hpp60
-rw-r--r--src/mbgl/shader/line_pattern_shader.cpp16
-rw-r--r--src/mbgl/shader/line_pattern_shader.hpp20
-rw-r--r--src/mbgl/shader/line_sdf_shader.cpp16
-rw-r--r--src/mbgl/shader/line_sdf_shader.hpp21
-rw-r--r--src/mbgl/shader/line_shader.cpp16
-rw-r--r--src/mbgl/shader/line_shader.hpp21
-rw-r--r--src/mbgl/shader/line_uniforms.hpp109
-rw-r--r--src/mbgl/shader/raster_attributes.hpp29
-rw-r--r--src/mbgl/shader/raster_shader.cpp16
-rw-r--r--src/mbgl/shader/raster_shader.hpp20
-rw-r--r--src/mbgl/shader/raster_uniforms.hpp37
-rw-r--r--src/mbgl/shader/shaders.hpp53
-rw-r--r--src/mbgl/shader/symbol_attributes.hpp50
-rw-r--r--src/mbgl/shader/symbol_icon_shader.cpp16
-rw-r--r--src/mbgl/shader/symbol_icon_shader.hpp20
-rw-r--r--src/mbgl/shader/symbol_sdf_shader.cpp16
-rw-r--r--src/mbgl/shader/symbol_sdf_shader.hpp20
-rw-r--r--src/mbgl/shader/symbol_uniforms.hpp77
-rw-r--r--test/gl/object.test.cpp28
90 files changed, 984 insertions, 1451 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 07a11e9a9f..7a2ed33281 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -73,10 +73,9 @@ set(MBGL_CORE_FILES
src/mbgl/gl/index_buffer.hpp
src/mbgl/gl/object.cpp
src/mbgl/gl/object.hpp
+ src/mbgl/gl/program.hpp
src/mbgl/gl/renderbuffer.hpp
src/mbgl/gl/segment.hpp
- src/mbgl/gl/shader.cpp
- src/mbgl/gl/shader.hpp
src/mbgl/gl/state.hpp
src/mbgl/gl/stencil_mode.cpp
src/mbgl/gl/stencil_mode.hpp
@@ -149,6 +148,24 @@ set(MBGL_CORE_FILES
include/mbgl/platform/default/settings_json.hpp
include/mbgl/platform/default/thread_pool.hpp
+ # programs
+ src/mbgl/programs/attributes.hpp
+ src/mbgl/programs/circle_program.cpp
+ src/mbgl/programs/circle_program.hpp
+ src/mbgl/programs/collision_box_program.cpp
+ src/mbgl/programs/collision_box_program.hpp
+ src/mbgl/programs/fill_program.cpp
+ src/mbgl/programs/fill_program.hpp
+ src/mbgl/programs/line_program.cpp
+ src/mbgl/programs/line_program.hpp
+ src/mbgl/programs/program.hpp
+ src/mbgl/programs/programs.hpp
+ src/mbgl/programs/raster_program.cpp
+ src/mbgl/programs/raster_program.hpp
+ src/mbgl/programs/symbol_program.cpp
+ src/mbgl/programs/symbol_program.hpp
+ src/mbgl/programs/uniforms.hpp
+
# renderer
src/mbgl/renderer/bucket.hpp
src/mbgl/renderer/circle_bucket.cpp
@@ -181,50 +198,6 @@ set(MBGL_CORE_FILES
src/mbgl/renderer/symbol_bucket.cpp
src/mbgl/renderer/symbol_bucket.hpp
- # shader
- src/mbgl/shader/attributes.hpp
- src/mbgl/shader/circle_attributes.hpp
- src/mbgl/shader/circle_shader.cpp
- src/mbgl/shader/circle_shader.hpp
- src/mbgl/shader/circle_uniforms.hpp
- src/mbgl/shader/collision_box_attributes.hpp
- src/mbgl/shader/collision_box_shader.cpp
- src/mbgl/shader/collision_box_shader.hpp
- src/mbgl/shader/collision_box_uniforms.hpp
- src/mbgl/shader/fill_attributes.hpp
- src/mbgl/shader/fill_outline_pattern_shader.cpp
- src/mbgl/shader/fill_outline_pattern_shader.hpp
- src/mbgl/shader/fill_outline_shader.cpp
- src/mbgl/shader/fill_outline_shader.hpp
- src/mbgl/shader/fill_pattern_shader.cpp
- src/mbgl/shader/fill_pattern_shader.hpp
- src/mbgl/shader/fill_shader.cpp
- src/mbgl/shader/fill_shader.hpp
- src/mbgl/shader/fill_uniforms.cpp
- src/mbgl/shader/fill_uniforms.hpp
- src/mbgl/shader/line_attributes.hpp
- src/mbgl/shader/line_pattern_shader.cpp
- src/mbgl/shader/line_pattern_shader.hpp
- src/mbgl/shader/line_sdf_shader.cpp
- src/mbgl/shader/line_sdf_shader.hpp
- src/mbgl/shader/line_shader.cpp
- src/mbgl/shader/line_shader.hpp
- src/mbgl/shader/line_uniforms.cpp
- src/mbgl/shader/line_uniforms.hpp
- src/mbgl/shader/raster_attributes.hpp
- src/mbgl/shader/raster_shader.cpp
- src/mbgl/shader/raster_shader.hpp
- src/mbgl/shader/raster_uniforms.hpp
- src/mbgl/shader/shaders.hpp
- src/mbgl/shader/symbol_attributes.hpp
- src/mbgl/shader/symbol_icon_shader.cpp
- src/mbgl/shader/symbol_icon_shader.hpp
- src/mbgl/shader/symbol_sdf_shader.cpp
- src/mbgl/shader/symbol_sdf_shader.hpp
- src/mbgl/shader/symbol_uniforms.cpp
- src/mbgl/shader/symbol_uniforms.hpp
- src/mbgl/shader/uniforms.hpp
-
# sprite
include/mbgl/sprite/sprite_image.hpp
src/mbgl/sprite/sprite_atlas.cpp
diff --git a/cmake/shaders.cmake b/cmake/shaders.cmake
index bebf476bbf..659231fd9a 100644
--- a/cmake/shaders.cmake
+++ b/cmake/shaders.cmake
@@ -4,14 +4,13 @@ function(add_shader VAR name)
set(shader_source_prefix ${MBGL_GENERATED}/include/mbgl/shader)
add_custom_command(
- OUTPUT ${shader_source_prefix}/${name}.vertex.hpp ${shader_source_prefix}/${name}.fragment.hpp
- COMMAND ${shader_build_cmd} ${shader_file_prefix}/${name}.vertex.glsl ${shader_source_prefix}/${name}.vertex.hpp
- COMMAND ${shader_build_cmd} ${shader_file_prefix}/${name}.fragment.glsl ${shader_source_prefix}/${name}.fragment.hpp
+ OUTPUT ${shader_source_prefix}/${name}.hpp
+ COMMAND ${shader_build_cmd} ${shader_file_prefix}/${name}.vertex.glsl ${shader_file_prefix}/${name}.fragment.glsl ${shader_source_prefix}/${name}.hpp
DEPENDS ${shader_file_prefix}/${name}.vertex.glsl
DEPENDS ${shader_file_prefix}/${name}.fragment.glsl
VERBATIM
)
- set(${VAR} ${${VAR}} ${shader_source_prefix}/${name}.vertex.hpp ${shader_source_prefix}/${name}.fragment.hpp PARENT_SCOPE)
+ set(${VAR} ${${VAR}} ${shader_source_prefix}/${name}.hpp PARENT_SCOPE)
endfunction()
add_shader(MBGL_SHADER_FILES circle)
diff --git a/cmake/test.cmake b/cmake/test.cmake
index 2a83a633c0..fc7a22874c 100644
--- a/cmake/test.cmake
+++ b/cmake/test.cmake
@@ -14,6 +14,7 @@ target_include_directories(mbgl-test
PRIVATE test/include
PRIVATE test/src
PRIVATE platform/default
+ PRIVATE ${MBGL_GENERATED}/include
)
target_link_libraries(mbgl-test
diff --git a/include/mbgl/util/exception.hpp b/include/mbgl/util/exception.hpp
index 7c331636d4..46de8528c7 100644
--- a/include/mbgl/util/exception.hpp
+++ b/include/mbgl/util/exception.hpp
@@ -20,10 +20,5 @@ struct MisuseException : Exception {
MisuseException(const std::string &msg) : Exception(msg) {}
};
-struct ShaderException : Exception {
- ShaderException(const char *msg) : Exception(msg) {}
- ShaderException(const std::string &msg) : Exception(msg) {}
-};
-
} // namespace util
} // namespace mbgl
diff --git a/scripts/build-shaders.js b/scripts/build-shaders.js
index 9090f19e6d..dd2de9daf6 100755
--- a/scripts/build-shaders.js
+++ b/scripts/build-shaders.js
@@ -4,68 +4,54 @@ var path = require('path');
var fs = require('fs');
var mkdirp = require('mkdirp');
-var input_file = process.argv[2]
-var output_file = process.argv[3];
+var vertex_file = process.argv[2];
+var fragment_file = process.argv[3];
+var output_file = process.argv[4];
-if (!input_file || !output_file) {
+if (!vertex_file || !fragment_file || !output_file) {
console.warn('No input or output file given.');
- console.warn('Usage: %s [input.vertex.glsl] [output.vertex.hpp]', path.basename(process.argv[1]));
+ console.warn('Usage: %s input.vertex.glsl input.fragment.glsl output.hpp', path.basename(process.argv[1]));
process.exit(1);
}
-var components = path.basename(input_file).split('.');
-
+var components = path.basename(vertex_file).split('.');
var shader_name = components[0];
-var shader_type = components[1];
-var extension = components[2];
-
-var data = fs.readFileSync(input_file, 'utf8');
-
-// Replace uniform pragmas
var pragma_mapbox_regex = /(\s*)#pragma\s+mapbox\s*:\s+(define|initialize)\s+(low|medium|high)p\s+(float|vec(?:2|3|4))\s+(.*)/;
-var data = data.split('\n').map(function(line) {
- var params = line.match(pragma_mapbox_regex);
- if (params) {
- if (params[2] === 'define') {
- return params[1] + 'uniform ' + params[3] + 'p ' + params[4] + ' u_' + params[5] + ';';
+function source(file) {
+ return '\n' + fs.readFileSync(file, 'utf8').split('\n').map(function(line) {
+ var params = line.match(pragma_mapbox_regex);
+ if (params) {
+ if (params[2] === 'define') {
+ return params[1] + 'uniform ' + params[3] + 'p ' + params[4] + ' u_' + params[5] + ';';
+ } else {
+ return params[1] + params[3] + 'p ' + params[4] + ' ' + params[5] + ' = u_' + params[5] + ';';
+ }
} else {
- return params[1] + params[3] + 'p ' + params[4] + ' ' + params[5] + ' = u_' + params[5] + ';';
+ return line;
}
- } else {
- return line;
- }
-}).join('\n');
-
+ }).join('\n');
+}
-var content =
- '#pragma once\n' +
- '\n' +
- '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n' +
- '\n' +
- '#include <mbgl/gl/gl.hpp>\n' +
- '\n' +
- 'namespace mbgl {\n' +
- 'namespace shaders {\n' +
- 'namespace ' + shader_name + ' {\n' +
- '\n' +
- '#ifndef MBGL_SHADER_NAME_' + shader_name.toUpperCase() + '\n' +
- '#define MBGL_SHADER_NAME_' + shader_name.toUpperCase() + '\n' +
- 'constexpr const char* name = "' + shader_name + '";\n' +
- '#endif // MBGL_SHADER_NAME_' + shader_name.toUpperCase() + '\n' +
- '\n' +
- 'constexpr const char* ' + shader_type + ' =\n' +
- '#ifdef GL_ES_VERSION_2_0\n' +
- ' "precision highp float;"\n' +
- '#else\n' +
- ' "#version 120"\n' +
- '#endif\n' +
- ' R"MBGL_SHADER(\n' + data + ')MBGL_SHADER";\n' +
- '\n' +
- '} // namespace ' + shader_name + '\n' +
- '} // namespace shaders\n' +
- '} // namespace mbgl\n';
+var content = "#pragma once\n" +
+"\n" +
+"// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n" +
+"\n" +
+"#include <mbgl/gl/gl.hpp>\n" +
+"\n" +
+"namespace mbgl {\n" +
+"namespace shaders {\n" +
+"\n" +
+"class " + shader_name + " {\n" +
+"public:\n" +
+" static constexpr const char* name = \"" + shader_name + "\";" +
+" static constexpr const char* vertexSource = R\"MBGL_SHADER(" + source(vertex_file) + ")MBGL_SHADER\";\n" +
+" static constexpr const char* fragmentSource = R\"MBGL_SHADER(" + source(fragment_file) + ")MBGL_SHADER\";\n" +
+"};\n" +
+"\n" +
+"} // namespace shaders\n" +
+"} // namespace mbgl\n";
mkdirp.sync(path.dirname(output_file));
fs.writeFileSync(output_file, content);
diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp
index 81ab6ac2a5..51fdd1dd12 100644
--- a/src/mbgl/gl/attribute.cpp
+++ b/src/mbgl/gl/attribute.cpp
@@ -4,6 +4,10 @@
namespace mbgl {
namespace gl {
+AttributeLocation attributeLocation(ProgramID id, const char* name) {
+ return MBGL_CHECK_ERROR(glGetAttribLocation(id, name));
+}
+
void bindAttribute(AttributeLocation location,
std::size_t count,
DataType type,
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp
index e6ef5c7f89..126da38de5 100644
--- a/src/mbgl/gl/attribute.hpp
+++ b/src/mbgl/gl/attribute.hpp
@@ -1,7 +1,6 @@
#pragma once
#include <mbgl/gl/types.hpp>
-#include <mbgl/gl/shader.hpp>
#include <cstddef>
#include <functional>
@@ -18,9 +17,6 @@ public:
class State {
public:
- State(const char* name, const Shader& shader)
- : location(shader.getAttributeLocation(name)) {}
-
AttributeLocation location;
static constexpr std::size_t count = N;
static constexpr DataType type = DataTypeOf<T>::value;
@@ -134,6 +130,8 @@ const std::size_t Vertex<A1, A2, A3, A4, A5>::attributeOffsets[5] = {
} // namespace detail
+AttributeLocation attributeLocation(ProgramID, const char * name);
+
void bindAttribute(AttributeLocation location,
std::size_t count,
DataType type,
@@ -147,8 +145,8 @@ public:
using State = std::tuple<typename As::State...>;
using Vertex = detail::Vertex<As...>;
- static State state(const Shader& shader) {
- return State { { As::name, shader }... };
+ static State state(const ProgramID& id) {
+ return State { { attributeLocation(id, As::name) }... };
}
static std::function<void (std::size_t)> binder(const State& state) {
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index f23dfe3dbe..b12c77c1a1 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -4,12 +4,16 @@
#include <mbgl/gl/vertex_array.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/platform/log.hpp>
#include <boost/functional/hash.hpp>
namespace mbgl {
namespace gl {
+static_assert(underlying_type(ShaderType::Vertex) == GL_VERTEX_SHADER, "OpenGL type mismatch");
+static_assert(underlying_type(ShaderType::Fragment) == GL_FRAGMENT_SHADER, "OpenGL type mismatch");
+
static_assert(underlying_type(PrimitiveType::Points) == GL_POINTS, "OpenGL type mismatch");
static_assert(underlying_type(PrimitiveType::Lines) == GL_LINES, "OpenGL type mismatch");
static_assert(underlying_type(PrimitiveType::LineLoop) == GL_LINE_LOOP, "OpenGL type mismatch");
@@ -34,16 +38,53 @@ Context::~Context() {
reset();
}
-UniqueProgram Context::createProgram() {
- return UniqueProgram{ MBGL_CHECK_ERROR(glCreateProgram()), { this } };
-}
+UniqueShader Context::createShader(ShaderType type, const std::string& source) {
+ UniqueShader result { MBGL_CHECK_ERROR(glCreateShader(static_cast<GLenum>(type))), { this } };
+
+ const GLchar* sources = source.data();
+ const GLsizei lengths = static_cast<GLsizei>(source.length());
+ MBGL_CHECK_ERROR(glShaderSource(result, 1, &sources, &lengths));
+ MBGL_CHECK_ERROR(glCompileShader(result));
+
+ GLint status = 0;
+ MBGL_CHECK_ERROR(glGetShaderiv(result, GL_COMPILE_STATUS, &status));
+ if (status != 0) {
+ return result;
+ }
+
+ GLint logLength;
+ MBGL_CHECK_ERROR(glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength));
+ if (logLength > 0) {
+ const auto log = std::make_unique<GLchar[]>(logLength);
+ MBGL_CHECK_ERROR(glGetShaderInfoLog(result, logLength, &logLength, log.get()));
+ Log::Error(Event::Shader, "Shader failed to compile: %s", log.get());
+ }
-UniqueShader Context::createVertexShader() {
- return UniqueShader{ MBGL_CHECK_ERROR(glCreateShader(GL_VERTEX_SHADER)), { this } };
+ throw std::runtime_error("shader failed to compile");
}
-UniqueShader Context::createFragmentShader() {
- return UniqueShader{ MBGL_CHECK_ERROR(glCreateShader(GL_FRAGMENT_SHADER)), { this } };
+UniqueProgram Context::createProgram(ShaderID vertexShader, ShaderID fragmentShader) {
+ UniqueProgram result { MBGL_CHECK_ERROR(glCreateProgram()), { this } };
+
+ MBGL_CHECK_ERROR(glAttachShader(result, vertexShader));
+ MBGL_CHECK_ERROR(glAttachShader(result, fragmentShader));
+ MBGL_CHECK_ERROR(glLinkProgram(result));
+
+ GLint status;
+ MBGL_CHECK_ERROR(glGetProgramiv(result, GL_LINK_STATUS, &status));
+ if (status != 0) {
+ return result;
+ }
+
+ GLint logLength;
+ MBGL_CHECK_ERROR(glGetProgramiv(result, GL_INFO_LOG_LENGTH, &logLength));
+ const auto log = std::make_unique<GLchar[]>(logLength);
+ if (logLength > 0) {
+ MBGL_CHECK_ERROR(glGetProgramInfoLog(result, logLength, &logLength, log.get()));
+ Log::Error(Event::Shader, "Program failed to link: %s", log.get());
+ }
+
+ throw std::runtime_error("program failed to link");
}
UniqueBuffer Context::createVertexBuffer(const void* data, std::size_t size) {
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index 438450fe14..2a3fbea33d 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -14,6 +14,7 @@
#include <memory>
#include <vector>
#include <array>
+#include <string>
#include <unordered_map>
namespace mbgl {
@@ -28,9 +29,8 @@ class Context : private util::noncopyable {
public:
~Context();
- UniqueProgram createProgram();
- UniqueShader createVertexShader();
- UniqueShader createFragmentShader();
+ UniqueShader createShader(ShaderType type, const std::string& source);
+ UniqueProgram createProgram(ShaderID vertexShader, ShaderID fragmentShader);
UniqueTexture createTexture();
template <class V>
diff --git a/src/mbgl/gl/drawable.hpp b/src/mbgl/gl/drawable.hpp
index be6b27bb83..747d8facf0 100644
--- a/src/mbgl/gl/drawable.hpp
+++ b/src/mbgl/gl/drawable.hpp
@@ -82,28 +82,28 @@ auto Segmented(const VertexBuffer<Vertex>& vertexBuffer,
class Drawable {
public:
- template <class Shader, class Subject>
+ template <class Program, class Subject>
Drawable(DepthMode depthMode_,
StencilMode stencilMode_,
ColorMode colorMode_,
- Shader& shader,
- typename Shader::UniformsType::Values&& uniformValues,
+ Program& program_,
+ typename Program::UniformValues&& uniformValues,
const Subject& subject)
: drawMode(subject.drawMode),
depthMode(std::move(depthMode_)),
stencilMode(std::move(stencilMode_)),
colorMode(std::move(colorMode_)),
- program(shader.getID()),
+ program(program_.program),
vertexBuffer(subject.vertexBuffer),
vertexSize(subject.vertexSize),
indexBuffer(subject.indexBuffer),
primitiveSize(subject.primitiveSize),
segments(subject.segments),
- bindUniforms(Shader::UniformsType::binder(shader.uniformsState, std::move(uniformValues))),
- bindAttributes(Shader::AttributesType::binder(shader.attributesState))
+ bindUniforms(Program::Uniforms::binder(program_.uniformsState, std::move(uniformValues))),
+ bindAttributes(Program::Attributes::binder(program_.attributesState))
{
- static_assert(std::is_standard_layout<typename Subject::VertexType>::value, "vertex type must use standard layout");
- static_assert(std::is_same<typename Shader::AttributesType::Vertex, typename Subject::VertexType>::value, "vertex type mismatch");
+ static_assert(std::is_standard_layout<typename Program::Vertex>::value, "vertex type must use standard layout");
+ static_assert(std::is_same<typename Program::Vertex, typename Subject::VertexType>::value, "vertex type mismatch");
}
DrawMode drawMode;
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp
new file mode 100644
index 0000000000..ea4dbcc1df
--- /dev/null
+++ b/src/mbgl/gl/program.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <mbgl/gl/types.hpp>
+#include <mbgl/gl/object.hpp>
+#include <mbgl/gl/context.hpp>
+
+#include <string>
+
+namespace mbgl {
+namespace gl {
+
+template <class As, class Us>
+class Program {
+public:
+ using Attributes = As;
+ using Vertex = typename Attributes::Vertex;
+
+ using Uniforms = Us;
+ using UniformValues = typename Uniforms::Values;
+
+ Program(Context& context, const std::string& vertexSource, const std::string& fragmentSource)
+ : vertexShader(context.createShader(ShaderType::Vertex, vertexSource)),
+ fragmentShader(context.createShader(ShaderType::Fragment, fragmentSource)),
+ program(context.createProgram(vertexShader, fragmentShader)),
+ attributesState(Attributes::state(program)),
+ uniformsState(Uniforms::state(program)) {}
+
+ UniqueShader vertexShader;
+ UniqueShader fragmentShader;
+ UniqueProgram program;
+
+ typename Attributes::State attributesState;
+ typename Uniforms::State uniformsState;
+};
+
+} // namespace gl
+} // namespace mbgl
diff --git a/src/mbgl/gl/shader.cpp b/src/mbgl/gl/shader.cpp
deleted file mode 100644
index d8ee734567..0000000000
--- a/src/mbgl/gl/shader.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/gl/gl.hpp>
-#include <mbgl/gl/context.hpp>
-#include <mbgl/util/stopwatch.hpp>
-#include <mbgl/util/exception.hpp>
-#include <mbgl/platform/log.hpp>
-#include <mbgl/platform/platform.hpp>
-
-#include <cstring>
-#include <cassert>
-#include <iostream>
-#include <string>
-#include <fstream>
-#include <cstdio>
-#include <cassert>
-
-namespace mbgl {
-namespace gl {
-
-Shader::Shader(const char* name_,
- const char* vertexSource,
- const char* fragmentSource,
- Context& context,
- Defines defines)
- : name(name_),
- program(context.createProgram()),
- vertexShader(context.createVertexShader()),
- fragmentShader(context.createFragmentShader()) {
- util::stopwatch stopwatch("shader compilation", Event::Shader);
-
- if (!compileShader(vertexShader, vertexSource)) {
- Log::Error(Event::Shader, "Vertex shader %s failed to compile: %s", name, vertexSource);
- throw util::ShaderException(std::string { "Vertex shader " } + name + " failed to compile");
- }
-
- std::string fragment(fragmentSource);
- if (defines & Defines::Overdraw) {
- assert(fragment.find("#ifdef OVERDRAW_INSPECTOR") != std::string::npos);
- fragment.replace(fragment.find_first_of('\n'), 1, "\n#define OVERDRAW_INSPECTOR\n");
- }
-
- if (!compileShader(fragmentShader, fragment.c_str())) {
- Log::Error(Event::Shader, "Fragment shader %s failed to compile: %s", name, fragmentSource);
- throw util::ShaderException(std::string { "Fragment shader " } + name + " failed to compile");
- }
-
- // Attach shaders
- MBGL_CHECK_ERROR(glAttachShader(program.get(), vertexShader.get()));
- MBGL_CHECK_ERROR(glAttachShader(program.get(), fragmentShader.get()));
-
- // Link program
- GLint status;
- MBGL_CHECK_ERROR(glLinkProgram(program.get()));
-
- MBGL_CHECK_ERROR(glGetProgramiv(program.get(), GL_LINK_STATUS, &status));
- if (status == 0) {
- GLint logLength;
- MBGL_CHECK_ERROR(glGetProgramiv(program.get(), GL_INFO_LOG_LENGTH, &logLength));
- const auto log = std::make_unique<GLchar[]>(logLength);
- if (logLength > 0) {
- MBGL_CHECK_ERROR(glGetProgramInfoLog(program.get(), logLength, &logLength, log.get()));
- Log::Error(Event::Shader, "Program failed to link: %s", log.get());
- }
- throw util::ShaderException(std::string { "Program " } + name + " failed to link: " + log.get());
- }
-}
-
-bool Shader::compileShader(UniqueShader& shader, const GLchar *source) {
- GLint status = 0;
-
- const GLsizei lengths = static_cast<GLsizei>(std::strlen(source));
- MBGL_CHECK_ERROR(glShaderSource(shader.get(), 1, &source, &lengths));
-
- MBGL_CHECK_ERROR(glCompileShader(shader.get()));
-
- MBGL_CHECK_ERROR(glGetShaderiv(shader.get(), GL_COMPILE_STATUS, &status));
- if (status == 0) {
- GLint logLength;
- MBGL_CHECK_ERROR(glGetShaderiv(shader.get(), GL_INFO_LOG_LENGTH, &logLength));
- if (logLength > 0) {
- const auto log = std::make_unique<GLchar[]>(logLength);
- MBGL_CHECK_ERROR(glGetShaderInfoLog(shader.get(), logLength, &logLength, log.get()));
- Log::Error(Event::Shader, "Shader failed to compile: %s", log.get());
- }
- return false;
- }
-
- MBGL_CHECK_ERROR(glGetShaderiv(shader.get(), GL_COMPILE_STATUS, &status));
- if (status == GL_FALSE) {
- Log::Error(Event::Shader, "Shader %s failed to compile.", name);
- return false;
- }
-
- return true;
-}
-
-Shader::~Shader() {
- if (program.get()) {
- MBGL_CHECK_ERROR(glDetachShader(program.get(), vertexShader.get()));
- MBGL_CHECK_ERROR(glDetachShader(program.get(), fragmentShader.get()));
- }
-}
-
-UniformLocation Shader::getUniformLocation(const char* uniform) const {
- return MBGL_CHECK_ERROR(glGetUniformLocation(program.get(), uniform));
-}
-
-AttributeLocation Shader::getAttributeLocation(const char* attribute) const {
- return MBGL_CHECK_ERROR(glGetAttribLocation(program.get(), attribute));
-}
-
-} // namespace gl
-} // namespace mbgl
diff --git a/src/mbgl/gl/shader.hpp b/src/mbgl/gl/shader.hpp
deleted file mode 100644
index f88bd4f867..0000000000
--- a/src/mbgl/gl/shader.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/types.hpp>
-#include <mbgl/gl/object.hpp>
-#include <mbgl/util/noncopyable.hpp>
-
-namespace mbgl {
-namespace gl {
-
-class Context;
-
-class Shader : private util::noncopyable {
-public:
- ~Shader();
- const char* name;
-
- ProgramID getID() const {
- return program.get();
- }
-
- AttributeLocation getAttributeLocation(const char* uniform) const;
- UniformLocation getUniformLocation(const char* uniform) const;
-
- enum Defines : bool {
- None = false,
- Overdraw = true,
- };
-
-protected:
- Shader(const char* name_,
- const char* vertex,
- const char* fragment,
- Context&,
- Defines defines = Defines::None);
-
-private:
- bool compileShader(UniqueShader&, const char *source);
-
- UniqueProgram program;
- UniqueShader vertexShader;
- UniqueShader fragmentShader;
-};
-
-} // namespace gl
-} // namespace mbgl
diff --git a/src/mbgl/gl/types.hpp b/src/mbgl/gl/types.hpp
index 1697656469..577629d5d3 100644
--- a/src/mbgl/gl/types.hpp
+++ b/src/mbgl/gl/types.hpp
@@ -19,6 +19,11 @@ using AttributeLocation = int32_t;
using UniformLocation = int32_t;
using TextureUnit = uint8_t;
+enum class ShaderType : uint32_t {
+ Vertex = 0x8B31,
+ Fragment = 0x8B30
+};
+
enum class DataType : uint32_t {
Byte = 0x1400,
UnsignedByte = 0x1401,
diff --git a/src/mbgl/gl/uniform.cpp b/src/mbgl/gl/uniform.cpp
index 8018953fb5..7b674f2cde 100644
--- a/src/mbgl/gl/uniform.cpp
+++ b/src/mbgl/gl/uniform.cpp
@@ -7,6 +7,10 @@
namespace mbgl {
namespace gl {
+UniformLocation uniformLocation(ProgramID id, const char* name) {
+ return MBGL_CHECK_ERROR(glGetUniformLocation(id, name));
+}
+
template <>
void bindUniform<float>(UniformLocation location, const float& t) {
MBGL_CHECK_ERROR(glUniform1f(location, t));
diff --git a/src/mbgl/gl/uniform.hpp b/src/mbgl/gl/uniform.hpp
index 40a48d3af3..90ca16e46f 100644
--- a/src/mbgl/gl/uniform.hpp
+++ b/src/mbgl/gl/uniform.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/types.hpp>
#include <mbgl/util/optional.hpp>
#include <array>
@@ -27,9 +27,6 @@ public:
class State {
public:
- State(const char* name, const Shader& shader)
- : location(shader.getUniformLocation(name)) {}
-
void operator=(const Value& value) {
if (!current || *current != value.t) {
current = value.t;
@@ -37,9 +34,8 @@ public:
}
}
- private:
- optional<T> current;
UniformLocation location;
+ optional<T> current = {};
};
};
@@ -61,14 +57,16 @@ using UniformMatrix = Uniform<Tag, std::array<T, N*N>>;
#define MBGL_DEFINE_UNIFORM_MATRIX(type_, n_, name_) \
struct name_ : ::mbgl::gl::UniformMatrix<name_, type_, n_> { static constexpr auto name = #name_; }
+UniformLocation uniformLocation(ProgramID, const char * name);
+
template <class... Us>
class Uniforms {
public:
using State = std::tuple<typename Us::State...>;
using Values = std::tuple<typename Us::Value...>;
- static State state(const Shader& shader) {
- return State { { Us::name, shader }... };
+ static State state(const ProgramID& id) {
+ return State { { uniformLocation(id, Us::name) }... };
}
static std::function<void ()> binder(State& state, Values&& values_) {
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 3fa58e016f..c2f8426785 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -507,14 +507,14 @@ void SymbolLayout::addToDebugBuffers(CollisionTile& collisionTile, SymbolBucket&
const float maxZoom = util::clamp(zoom + util::log2(box.maxScale), util::MIN_ZOOM_F, util::MAX_ZOOM_F);
const float placementZoom = util::clamp(zoom + util::log2(box.placementScale), util::MIN_ZOOM_F, util::MAX_ZOOM_F);
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, tl, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, tr, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, tr, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, br, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, br, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, bl, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, bl, maxZoom, placementZoom));
- collisionBox.vertices.emplace_back(CollisionBoxAttributes::vertex(anchor, tl, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, tl, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, tr, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, tr, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, br, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, br, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, bl, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, bl, maxZoom, placementZoom));
+ collisionBox.vertices.emplace_back(CollisionBoxProgram::vertex(anchor, tl, maxZoom, placementZoom));
}
};
populateCollisionBox(symbolInstance.textCollisionFeature);
diff --git a/src/mbgl/shader/attributes.hpp b/src/mbgl/programs/attributes.hpp
index 38bbe89377..38bbe89377 100644
--- a/src/mbgl/shader/attributes.hpp
+++ b/src/mbgl/programs/attributes.hpp
diff --git a/src/mbgl/programs/circle_program.cpp b/src/mbgl/programs/circle_program.cpp
new file mode 100644
index 0000000000..d6bc439feb
--- /dev/null
+++ b/src/mbgl/programs/circle_program.cpp
@@ -0,0 +1,7 @@
+#include <mbgl/programs/circle_program.hpp>
+
+namespace mbgl {
+
+static_assert(sizeof(CircleProgram::Vertex) == 4, "expected CircleVertex size");
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp
new file mode 100644
index 0000000000..690608a438
--- /dev/null
+++ b/src/mbgl/programs/circle_program.hpp
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/circle.hpp>
+#include <mbgl/util/geometry.hpp>
+
+namespace mbgl {
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius);
+MBGL_DEFINE_UNIFORM_SCALAR(bool, u_scale_with_map);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_devicepixelratio);
+} // namespace uniforms
+
+class CircleProgram : public Program<
+ shaders::circle,
+ gl::Attributes<
+ attributes::a_pos>,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_color,
+ uniforms::u_radius,
+ uniforms::u_blur,
+ uniforms::u_scale_with_map,
+ uniforms::u_extrude_scale,
+ uniforms::u_devicepixelratio>>
+{
+public:
+ using Program::Program;
+
+ /*
+ * @param {number} x vertex position
+ * @param {number} y vertex position
+ * @param {number} ex extrude normal
+ * @param {number} ey extrude normal
+ */
+ static Vertex vertex(Point<int16_t> p, float ex, float ey) {
+ return Vertex {
+ {
+ static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
+ static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
+ }
+ };
+ }
+};
+
+using CircleVertex = CircleProgram::Vertex;
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/collision_box_program.cpp b/src/mbgl/programs/collision_box_program.cpp
new file mode 100644
index 0000000000..d6a36e54a1
--- /dev/null
+++ b/src/mbgl/programs/collision_box_program.cpp
@@ -0,0 +1,7 @@
+#include <mbgl/programs/collision_box_program.hpp>
+
+namespace mbgl {
+
+static_assert(sizeof(CollisionBoxProgram::Vertex) == 10, "expected CollisionBoxVertex size");
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp
new file mode 100644
index 0000000000..66b1284621
--- /dev/null
+++ b/src/mbgl/programs/collision_box_program.hpp
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/collision_box.hpp>
+#include <mbgl/util/geometry.hpp>
+
+#include <cmath>
+
+namespace mbgl {
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_maxzoom);
+} // namespace uniforms
+
+class CollisionBoxProgram : public Program<
+ shaders::collision_box,
+ gl::Attributes<
+ attributes::a_pos,
+ attributes::a_extrude,
+ attributes::a_data<2>>,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_scale,
+ uniforms::u_zoom,
+ uniforms::u_maxzoom>>
+{
+public:
+ using Program::Program;
+
+ static Vertex vertex(Point<float> a, Point<float> o, float maxzoom, float placementZoom) {
+ return Vertex {
+ {
+ static_cast<int16_t>(a.x),
+ static_cast<int16_t>(a.y)
+ },
+ {
+ static_cast<int16_t>(::round(o.x)),
+ static_cast<int16_t>(::round(o.y))
+ },
+ {
+ static_cast<uint8_t>(maxzoom * 10),
+ static_cast<uint8_t>(placementZoom * 10)
+ }
+ };
+ }
+};
+
+using CollisionBoxVertex = CollisionBoxProgram::Vertex;
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/fill_uniforms.cpp b/src/mbgl/programs/fill_program.cpp
index acd207c5d4..90c09a995c 100644
--- a/src/mbgl/shader/fill_uniforms.cpp
+++ b/src/mbgl/programs/fill_program.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/shader/fill_uniforms.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/style/property_evaluator.hpp>
#include <mbgl/tile/tile_id.hpp>
@@ -8,6 +8,8 @@ namespace mbgl {
using namespace style;
+static_assert(sizeof(FillAttributes::Vertex) == 4, "expected FillVertex size");
+
FillPatternUniforms::Values
FillPatternUniforms::values(mat4 matrix,
float opacity,
diff --git a/src/mbgl/shader/fill_uniforms.hpp b/src/mbgl/programs/fill_program.hpp
index a596da0ea9..3f738527c8 100644
--- a/src/mbgl/shader/fill_uniforms.hpp
+++ b/src/mbgl/programs/fill_program.hpp
@@ -1,6 +1,13 @@
#pragma once
-#include <mbgl/shader/uniforms.hpp>
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/fill.hpp>
+#include <mbgl/shader/fill_pattern.hpp>
+#include <mbgl/shader/fill_outline.hpp>
+#include <mbgl/shader/fill_outline_pattern.hpp>
+#include <mbgl/util/geometry.hpp>
#include <mbgl/util/mat4.hpp>
#include <mbgl/util/size.hpp>
@@ -8,6 +15,14 @@
namespace mbgl {
+class SpriteAtlasPosition;
+class UnwrappedTileID;
+class TransformState;
+
+namespace style {
+template <class> class Faded;
+} // namespace style
+
namespace uniforms {
MBGL_DEFINE_UNIFORM_SCALAR(Size, u_world);
MBGL_DEFINE_UNIFORM_SCALAR(Color, u_outline_color);
@@ -18,20 +33,28 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_pixel_coord_upper);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_pixel_coord_lower);
} // namespace uniforms
-struct FillColorUniforms : gl::Uniforms<
+struct FillAttributes : gl::Attributes<
+ attributes::a_pos>
+{
+ static Vertex vertex(Point<int16_t> p) {
+ return Vertex {
+ {
+ p.x,
+ p.y
+ }
+ };
+ }
+};
+
+using FillVertex = FillAttributes::Vertex;
+
+struct FillUniforms : gl::Uniforms<
uniforms::u_matrix,
uniforms::u_opacity,
uniforms::u_color,
uniforms::u_outline_color,
- uniforms::u_world> {};
-
-class SpriteAtlasPosition;
-class UnwrappedTileID;
-class TransformState;
-
-namespace style {
-template <class> class Faded;
-} // namespace style
+ uniforms::u_world>
+{};
struct FillPatternUniforms : gl::Uniforms<
uniforms::u_matrix,
@@ -49,7 +72,8 @@ struct FillPatternUniforms : gl::Uniforms<
uniforms::u_image,
uniforms::u_pixel_coord_upper,
uniforms::u_pixel_coord_lower,
- uniforms::u_tile_units_to_pixels> {
+ uniforms::u_tile_units_to_pixels>
+{
static Values values(mat4 matrix,
float opacity,
Size framebufferSize,
@@ -60,4 +84,36 @@ struct FillPatternUniforms : gl::Uniforms<
const TransformState&);
};
+class FillProgram : public Program<
+ shaders::fill,
+ FillAttributes,
+ FillUniforms>
+{
+ using Program::Program;
+};
+
+class FillPatternProgram : public Program<
+ shaders::fill_pattern,
+ FillAttributes,
+ FillPatternUniforms>
+{
+ using Program::Program;
+};
+
+class FillOutlineProgram : public Program<
+ shaders::fill_outline,
+ FillAttributes,
+ FillUniforms>
+{
+ using Program::Program;
+};
+
+class FillOutlinePatternProgram : public Program<
+ shaders::fill_outline_pattern,
+ FillAttributes,
+ FillPatternUniforms>
+{
+ using Program::Program;
+};
+
} // namespace mbgl
diff --git a/src/mbgl/shader/line_uniforms.cpp b/src/mbgl/programs/line_program.cpp
index 0e9e5e27f0..07af464eb3 100644
--- a/src/mbgl/shader/line_uniforms.cpp
+++ b/src/mbgl/programs/line_program.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/shader/line_uniforms.hpp>
+#include <mbgl/programs/line_program.hpp>
#include <mbgl/style/layers/line_layer_properties.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/map/transform_state.hpp>
@@ -8,6 +8,8 @@
namespace mbgl {
+static_assert(sizeof(LineAttributes::Vertex) == 8, "expected LineVertex size");
+
template <class Values, class...Args>
Values makeValues(const style::LinePaintProperties& properties,
float pixelRatio,
@@ -45,12 +47,12 @@ Values makeValues(const style::LinePaintProperties& properties,
};
}
-LineColorUniforms::Values
-LineColorUniforms::values(const style::LinePaintProperties& properties,
- float pixelRatio,
- const RenderTile& tile,
- const TransformState& state) {
- return makeValues<LineColorUniforms::Values>(
+LineProgram::UniformValues
+LineProgram::uniformValues(const style::LinePaintProperties& properties,
+ float pixelRatio,
+ const RenderTile& tile,
+ const TransformState& state) {
+ return makeValues<LineProgram::UniformValues>(
properties,
pixelRatio,
tile,
@@ -59,15 +61,15 @@ LineColorUniforms::values(const style::LinePaintProperties& properties,
);
}
-LineSDFUniforms::Values
-LineSDFUniforms::values(const style::LinePaintProperties& properties,
- float pixelRatio,
- const RenderTile& tile,
- const TransformState& state,
- const LinePatternPos& posA,
- const LinePatternPos& posB,
- float dashLineWidth,
- float atlasWidth) {
+LineSDFProgram::UniformValues
+LineSDFProgram::uniformValues(const style::LinePaintProperties& properties,
+ float pixelRatio,
+ const RenderTile& tile,
+ const TransformState& state,
+ const LinePatternPos& posA,
+ const LinePatternPos& posB,
+ float dashLineWidth,
+ float atlasWidth) {
const float widthA = posA.width * properties.lineDasharray.value.fromScale * dashLineWidth;
const float widthB = posB.width * properties.lineDasharray.value.toScale * dashLineWidth;
@@ -81,7 +83,7 @@ LineSDFUniforms::values(const style::LinePaintProperties& properties,
-posB.height / 2.0f
}};
- return makeValues<LineSDFUniforms::Values>(
+ return makeValues<LineSDFProgram::UniformValues>(
properties,
pixelRatio,
tile,
@@ -97,13 +99,13 @@ LineSDFUniforms::values(const style::LinePaintProperties& properties,
);
}
-LinePatternUniforms::Values
-LinePatternUniforms::values(const style::LinePaintProperties& properties,
- float pixelRatio,
- const RenderTile& tile,
- const TransformState& state,
- const SpriteAtlasPosition& posA,
- const SpriteAtlasPosition& posB) {
+LinePatternProgram::UniformValues
+LinePatternProgram::uniformValues(const style::LinePaintProperties& properties,
+ float pixelRatio,
+ const RenderTile& tile,
+ const TransformState& state,
+ const SpriteAtlasPosition& posA,
+ const SpriteAtlasPosition& posB) {
std::array<float, 2> sizeA {{
tile.id.pixelsToTileUnits(posA.size[0] * properties.linePattern.value.fromScale, state.getIntegerZoom()),
posA.size[1]
@@ -114,7 +116,7 @@ LinePatternUniforms::values(const style::LinePaintProperties& properties,
posB.size[1]
}};
- return makeValues<LinePatternUniforms::Values>(
+ return makeValues<LinePatternProgram::UniformValues>(
properties,
pixelRatio,
tile,
diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp
new file mode 100644
index 0000000000..960438f4cd
--- /dev/null
+++ b/src/mbgl/programs/line_program.hpp
@@ -0,0 +1,184 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/line.hpp>
+#include <mbgl/shader/line_pattern.hpp>
+#include <mbgl/shader/line_sdf.hpp>
+#include <mbgl/util/geometry.hpp>
+
+#include <cmath>
+
+namespace mbgl {
+
+namespace style {
+class LinePaintProperties;
+} // namespace style
+
+class RenderTile;
+class TransformState;
+class LinePatternPos;
+class SpriteAtlasPosition;
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_ratio);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_linewidth);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_gapwidth);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_antialiasing);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_extra);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_offset);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_tex_y_a);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_tex_y_b);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_sdfgamma);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_fade);
+MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_patternscale_a);
+MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_patternscale_b);
+MBGL_DEFINE_UNIFORM_MATRIX(double, 2, u_antialiasingmatrix);
+} // namespace uniforms
+
+struct LineAttributes : gl::Attributes<
+ attributes::a_pos,
+ attributes::a_data<4>>
+{
+ /*
+ * @param p vertex position
+ * @param e extrude normal
+ * @param t texture normal
+ * @param dir direction of the line cap (-1/0/1)
+ */
+ static Vertex vertex(Point<int16_t> p, Point<double> e, Point<bool> t, int8_t dir, int32_t linesofar = 0) {
+ return Vertex {
+ {
+ static_cast<int16_t>((p.x * 2) | t.x),
+ static_cast<int16_t>((p.y * 2) | t.y)
+ },
+ {
+ // add 128 to store an byte in an unsigned byte
+ static_cast<uint8_t>(::round(extrudeScale * e.x) + 128),
+ static_cast<uint8_t>(::round(extrudeScale * e.y) + 128),
+
+ // Encode the -1/0/1 direction value into the first two bits of .z of a_data.
+ // Combine it with the lower 6 bits of `linesofar` (shifted by 2 bites to make
+ // room for the direction value). The upper 8 bits of `linesofar` are placed in
+ // the `w` component. `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that
+ // we can store longer distances while sacrificing precision.
+
+ // Encode the -1/0/1 direction value into .zw coordinates of a_data, which is normally covered
+ // by linesofar, so we need to merge them.
+ // The z component's first bit, as well as the sign bit is reserved for the direction,
+ // so we need to shift the linesofar.
+ static_cast<uint8_t>(((dir == 0 ? 0 : (dir < 0 ? -1 : 1 )) + 1) | ((linesofar & 0x3F) << 2)),
+ static_cast<uint8_t>(linesofar >> 6)
+ }
+ };
+ }
+
+ /*
+ * Scale the extrusion vector so that the normal length is this value.
+ * Contains the "texture" normals (-1..1). This is distinct from the extrude
+ * normals for line joins, because the x-value remains 0 for the texture
+ * normal array, while the extrude normal actually moves the vertex to create
+ * the acute/bevelled line join.
+ */
+ static const int8_t extrudeScale = 63;
+};
+
+using LineVertex = LineAttributes::Vertex;
+
+class LineProgram : public Program<
+ shaders::line,
+ LineAttributes,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_linewidth,
+ uniforms::u_gapwidth,
+ uniforms::u_blur,
+ uniforms::u_offset,
+ uniforms::u_antialiasing,
+ uniforms::u_antialiasingmatrix,
+ uniforms::u_ratio,
+ uniforms::u_extra,
+ uniforms::u_color>>
+{
+public:
+ using Program::Program;
+
+ static UniformValues uniformValues(const style::LinePaintProperties&,
+ float pixelRatio,
+ const RenderTile&,
+ const TransformState&);
+};
+
+class LinePatternProgram : public Program<
+ shaders::line_pattern,
+ LineAttributes,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_linewidth,
+ uniforms::u_gapwidth,
+ uniforms::u_blur,
+ uniforms::u_offset,
+ uniforms::u_antialiasing,
+ uniforms::u_antialiasingmatrix,
+ uniforms::u_ratio,
+ uniforms::u_extra,
+ uniforms::u_pattern_tl_a,
+ uniforms::u_pattern_br_a,
+ uniforms::u_pattern_tl_b,
+ uniforms::u_pattern_br_b,
+ uniforms::u_pattern_size_a,
+ uniforms::u_pattern_size_b,
+ uniforms::u_fade,
+ uniforms::u_image>>
+{
+public:
+ using Program::Program;
+
+ static UniformValues uniformValues(const style::LinePaintProperties&,
+ float pixelRatio,
+ const RenderTile&,
+ const TransformState&,
+ const SpriteAtlasPosition& posA,
+ const SpriteAtlasPosition& posB);
+};
+
+class LineSDFProgram : public Program<
+ shaders::line_sdf,
+ LineAttributes,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_linewidth,
+ uniforms::u_gapwidth,
+ uniforms::u_blur,
+ uniforms::u_offset,
+ uniforms::u_antialiasing,
+ uniforms::u_antialiasingmatrix,
+ uniforms::u_ratio,
+ uniforms::u_extra,
+ uniforms::u_color,
+ uniforms::u_patternscale_a,
+ uniforms::u_patternscale_b,
+ uniforms::u_tex_y_a,
+ uniforms::u_tex_y_b,
+ uniforms::u_mix,
+ uniforms::u_sdfgamma,
+ uniforms::u_image>>
+{
+public:
+ using Program::Program;
+
+ static UniformValues uniformValues(const style::LinePaintProperties&,
+ float pixelRatio,
+ const RenderTile&,
+ const TransformState&,
+ const LinePatternPos& posA,
+ const LinePatternPos& posB,
+ float dashLineWidth,
+ float atlasWidth);
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
new file mode 100644
index 0000000000..9f154b051a
--- /dev/null
+++ b/src/mbgl/programs/program.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <mbgl/gl/program.hpp>
+
+#include <cassert>
+
+namespace mbgl {
+
+enum class ProgramDefines : bool {
+ None = false,
+ Overdraw = true,
+};
+
+template <class Shaders, class As, class Us>
+class Program : public gl::Program<As, Us> {
+public:
+ Program(gl::Context& context, ProgramDefines defines)
+ : gl::Program<As, Us>(context, Shaders::vertexSource, fragmentSource(defines))
+ {}
+
+ static std::string fragmentSource(ProgramDefines defines) {
+ std::string fragment = Shaders::fragmentSource;
+ if (defines == ProgramDefines::Overdraw) {
+ assert(fragment.find("#ifdef OVERDRAW_INSPECTOR") != std::string::npos);
+ fragment.replace(fragment.find_first_of('\n'), 1, "\n#define OVERDRAW_INSPECTOR\n");
+ }
+ return fragment;
+ }
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp
new file mode 100644
index 0000000000..aebafaec62
--- /dev/null
+++ b/src/mbgl/programs/programs.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <mbgl/programs/circle_program.hpp>
+#include <mbgl/programs/fill_program.hpp>
+#include <mbgl/programs/line_program.hpp>
+#include <mbgl/programs/raster_program.hpp>
+#include <mbgl/programs/symbol_program.hpp>
+#include <mbgl/programs/collision_box_program.hpp>
+
+namespace mbgl {
+
+class Programs {
+public:
+ Programs(gl::Context& context, ProgramDefines defines = ProgramDefines::None)
+ : circle(context, defines),
+ fill(context, defines),
+ fillPattern(context, defines),
+ fillOutline(context, defines),
+ fillOutlinePattern(context, defines),
+ line(context, defines),
+ lineSDF(context, defines),
+ linePattern(context, defines),
+ raster(context, defines),
+ symbolIcon(context, defines),
+ symbolIconSDF(context, defines),
+ symbolGlyph(context, defines),
+ collisionBox(context, ProgramDefines::None) {
+ }
+
+ CircleProgram circle;
+ FillProgram fill;
+ FillPatternProgram fillPattern;
+ FillOutlineProgram fillOutline;
+ FillOutlinePatternProgram fillOutlinePattern;
+ LineProgram line;
+ LineSDFProgram lineSDF;
+ LinePatternProgram linePattern;
+ RasterProgram raster;
+ SymbolIconProgram symbolIcon;
+ SymbolSDFProgram symbolIconSDF;
+ SymbolSDFProgram symbolGlyph;
+
+ CollisionBoxProgram collisionBox;
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/raster_program.cpp b/src/mbgl/programs/raster_program.cpp
new file mode 100644
index 0000000000..ebec4c68cc
--- /dev/null
+++ b/src/mbgl/programs/raster_program.cpp
@@ -0,0 +1,7 @@
+#include <mbgl/programs/raster_program.hpp>
+
+namespace mbgl {
+
+static_assert(sizeof(RasterProgram::Vertex) == 8, "expected RasterVertex size");
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/raster_program.hpp b/src/mbgl/programs/raster_program.hpp
new file mode 100644
index 0000000000..1e9a0cdb6a
--- /dev/null
+++ b/src/mbgl/programs/raster_program.hpp
@@ -0,0 +1,65 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/raster.hpp>
+#include <mbgl/util/geometry.hpp>
+
+namespace mbgl {
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image0);
+MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image1);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_opacity0);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_opacity1);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_buffer_scale);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_low);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_high);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_saturation_factor);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_contrast_factor);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_parent);
+MBGL_DEFINE_UNIFORM_VECTOR(float, 3, u_spin_weights);
+MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_tl_parent);
+} // namespace uniforms
+
+class RasterProgram : public Program<
+ shaders::raster,
+ gl::Attributes<
+ attributes::a_pos,
+ attributes::a_texture_pos>,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_image0,
+ uniforms::u_image1,
+ uniforms::u_opacity0,
+ uniforms::u_opacity1,
+ uniforms::u_brightness_low,
+ uniforms::u_brightness_high,
+ uniforms::u_saturation_factor,
+ uniforms::u_contrast_factor,
+ uniforms::u_spin_weights,
+ uniforms::u_buffer_scale,
+ uniforms::u_scale_parent,
+ uniforms::u_tl_parent>>
+{
+public:
+ using Program::Program;
+
+ static Vertex vertex(Point<int16_t> p, Point<uint16_t> t) {
+ return Vertex {
+ {
+ p.x,
+ p.y
+ },
+ {
+ t.x,
+ t.y
+ }
+ };
+ }
+};
+
+using RasterVertex = RasterProgram::Vertex;
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_uniforms.cpp b/src/mbgl/programs/symbol_program.cpp
index ec2cf26c8a..8c9c34210c 100644
--- a/src/mbgl/shader/symbol_uniforms.cpp
+++ b/src/mbgl/programs/symbol_program.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/shader/symbol_uniforms.hpp>
+#include <mbgl/programs/symbol_program.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>
@@ -7,6 +7,8 @@ namespace mbgl {
using namespace style;
+static_assert(sizeof(SymbolAttributes::Vertex) == 16, "expected SymbolVertex size");
+
template <class Values, class...Args>
Values makeValues(const style::SymbolPropertyValues& values,
const Size& texsize,
@@ -44,14 +46,14 @@ Values makeValues(const style::SymbolPropertyValues& values,
};
}
-SymbolIconUniforms::Values
-SymbolIconUniforms::values(const style::SymbolPropertyValues& values,
- const Size& texsize,
- const std::array<float, 2>& pixelsToGLUnits,
- const RenderTile& tile,
- const TransformState& state)
+SymbolIconProgram::UniformValues
+SymbolIconProgram::uniformValues(const style::SymbolPropertyValues& values,
+ const Size& texsize,
+ const std::array<float, 2>& pixelsToGLUnits,
+ const RenderTile& tile,
+ const TransformState& state)
{
- return makeValues<SymbolIconUniforms::Values>(
+ return makeValues<SymbolIconProgram::UniformValues>(
values,
texsize,
pixelsToGLUnits,
@@ -60,7 +62,7 @@ SymbolIconUniforms::values(const style::SymbolPropertyValues& values,
);
}
-static SymbolSDFUniforms::Values makeSDFValues(const style::SymbolPropertyValues& values,
+static SymbolSDFProgram::UniformValues makeSDFValues(const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const RenderTile& tile,
@@ -77,7 +79,7 @@ static SymbolSDFUniforms::Values makeSDFValues(const style::SymbolPropertyValues
? 1.0 / std::cos(state.getPitch())
: 1.0;
- return makeValues<SymbolSDFUniforms::Values>(
+ return makeValues<SymbolSDFProgram::UniformValues>(
values,
texsize,
pixelsToGLUnits,
@@ -93,8 +95,8 @@ static SymbolSDFUniforms::Values makeSDFValues(const style::SymbolPropertyValues
);
}
-SymbolSDFUniforms::Values
-SymbolSDFUniforms::haloValues(const style::SymbolPropertyValues& values,
+SymbolSDFProgram::UniformValues
+SymbolSDFProgram::haloUniformValues(const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const RenderTile& tile,
@@ -119,8 +121,8 @@ SymbolSDFUniforms::haloValues(const style::SymbolPropertyValues& values,
);
}
-SymbolSDFUniforms::Values
-SymbolSDFUniforms::foregroundValues(const style::SymbolPropertyValues& values,
+SymbolSDFProgram::UniformValues
+SymbolSDFProgram::foregroundUniformValues(const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const RenderTile& tile,
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
new file mode 100644
index 0000000000..eb8c56b326
--- /dev/null
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -0,0 +1,134 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/symbol_icon.hpp>
+#include <mbgl/shader/symbol_sdf.hpp>
+#include <mbgl/util/geometry.hpp>
+#include <mbgl/util/size.hpp>
+
+#include <cmath>
+#include <array>
+
+namespace mbgl {
+
+namespace style {
+class SymbolPropertyValues;
+} // namespace style
+
+class RenderTile;
+class TransformState;
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_texsize);
+MBGL_DEFINE_UNIFORM_SCALAR(bool, u_rotate_with_map);
+MBGL_DEFINE_UNIFORM_SCALAR(bool, u_pitch_with_map);
+MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_texture);
+MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_fadetexture);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_buffer);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_gamma);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_aspect_ratio);
+} // namespace uniforms
+
+struct SymbolAttributes : gl::Attributes<
+ attributes::a_pos,
+ attributes::a_offset,
+ attributes::a_texture_pos,
+ attributes::a_data<4>>
+{
+ static Vertex vertex(Point<float> a,
+ Point<float> o,
+ uint16_t tx,
+ uint16_t ty,
+ float minzoom,
+ float maxzoom,
+ float labelminzoom,
+ uint8_t labelangle) {
+ return Vertex {
+ {
+ static_cast<int16_t>(a.x),
+ static_cast<int16_t>(a.y)
+ },
+ {
+ static_cast<int16_t>(::round(o.x * 64)), // use 1/64 pixels for placement
+ static_cast<int16_t>(::round(o.y * 64))
+ },
+ {
+ static_cast<uint16_t>(tx / 4),
+ static_cast<uint16_t>(ty / 4)
+ },
+ {
+ static_cast<uint8_t>(labelminzoom * 10), // 1/10 zoom levels: z16 == 160
+ static_cast<uint8_t>(labelangle),
+ static_cast<uint8_t>(minzoom * 10),
+ static_cast<uint8_t>(::fmin(maxzoom, 25) * 10)
+ }
+ };
+ }
+};
+
+using SymbolVertex = SymbolAttributes::Vertex;
+
+class SymbolIconProgram : public Program<
+ shaders::symbol_icon,
+ SymbolAttributes,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_extrude_scale,
+ uniforms::u_texsize,
+ uniforms::u_zoom,
+ uniforms::u_rotate_with_map,
+ uniforms::u_texture,
+ uniforms::u_fadetexture>>
+{
+public:
+ using Program::Program;
+
+ static UniformValues uniformValues(const style::SymbolPropertyValues&,
+ const Size& texsize,
+ const std::array<float, 2>& pixelsToGLUnits,
+ const RenderTile&,
+ const TransformState&);
+};
+
+class SymbolSDFProgram : public Program<
+ shaders::symbol_sdf,
+ SymbolAttributes,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_opacity,
+ uniforms::u_extrude_scale,
+ uniforms::u_texsize,
+ uniforms::u_zoom,
+ uniforms::u_rotate_with_map,
+ uniforms::u_texture,
+ uniforms::u_fadetexture,
+ uniforms::u_color,
+ uniforms::u_buffer,
+ uniforms::u_gamma,
+ uniforms::u_pitch,
+ uniforms::u_bearing,
+ uniforms::u_aspect_ratio,
+ uniforms::u_pitch_with_map>>
+{
+public:
+ using Program::Program;
+
+ static UniformValues haloUniformValues(const style::SymbolPropertyValues&,
+ const Size& texsize,
+ const std::array<float, 2>& pixelsToGLUnits,
+ const RenderTile&,
+ const TransformState&,
+ float pixelRatio);
+
+ static UniformValues foregroundUniformValues(const style::SymbolPropertyValues&,
+ const Size& texsize,
+ const std::array<float, 2>& pixelsToGLUnits,
+ const RenderTile&,
+ const TransformState&,
+ float pixelRatio);
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/uniforms.hpp b/src/mbgl/programs/uniforms.hpp
index e0c5a0d361..e0c5a0d361 100644
--- a/src/mbgl/shader/uniforms.hpp
+++ b/src/mbgl/programs/uniforms.hpp
diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp
index 1137a3f5dc..08f2a144a1 100644
--- a/src/mbgl/renderer/circle_bucket.cpp
+++ b/src/mbgl/renderer/circle_bucket.cpp
@@ -2,7 +2,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/shader/circle_shader.hpp>
+#include <mbgl/programs/circle_program.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/util/constants.hpp>
@@ -58,10 +58,10 @@ void CircleBucket::addGeometry(const GeometryCollection& geometryCollection) {
// │ 1 2 │
// └─────────┘
//
- vertices.emplace_back(CircleAttributes::vertex(point, -1, -1)); // 1
- vertices.emplace_back(CircleAttributes::vertex(point, 1, -1)); // 2
- vertices.emplace_back(CircleAttributes::vertex(point, 1, 1)); // 3
- vertices.emplace_back(CircleAttributes::vertex(point, -1, 1)); // 4
+ vertices.emplace_back(CircleProgram::vertex(point, -1, -1)); // 1
+ vertices.emplace_back(CircleProgram::vertex(point, 1, -1)); // 2
+ vertices.emplace_back(CircleProgram::vertex(point, 1, 1)); // 3
+ vertices.emplace_back(CircleProgram::vertex(point, -1, 1)); // 4
auto& segment = segments.back();
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp
index b0ae47f523..d5df06f110 100644
--- a/src/mbgl/renderer/circle_bucket.hpp
+++ b/src/mbgl/renderer/circle_bucket.hpp
@@ -6,7 +6,7 @@
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
#include <mbgl/gl/segment.hpp>
-#include <mbgl/shader/circle_attributes.hpp>
+#include <mbgl/programs/circle_program.hpp>
namespace mbgl {
diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp
index d2d4465ab6..931d1bf30d 100644
--- a/src/mbgl/renderer/debug_bucket.cpp
+++ b/src/mbgl/renderer/debug_bucket.cpp
@@ -1,7 +1,6 @@
#include <mbgl/renderer/debug_bucket.hpp>
#include <mbgl/renderer/painter.hpp>
-#include <mbgl/shader/fill_shader.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/geometry/debug_font_data.hpp>
#include <mbgl/util/string.hpp>
diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp
index beb57fa51a..9b19e7f949 100644
--- a/src/mbgl/renderer/debug_bucket.hpp
+++ b/src/mbgl/renderer/debug_bucket.hpp
@@ -6,7 +6,7 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
+#include <mbgl/programs/fill_program.hpp>
namespace mbgl {
diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp
index 97ba5c5f9e..2eee8f2d6d 100644
--- a/src/mbgl/renderer/fill_bucket.cpp
+++ b/src/mbgl/renderer/fill_bucket.cpp
@@ -1,10 +1,7 @@
#include <mbgl/renderer/fill_bucket.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/renderer/painter.hpp>
-#include <mbgl/shader/fill_shader.hpp>
-#include <mbgl/shader/fill_pattern_shader.hpp>
-#include <mbgl/shader/fill_outline_shader.hpp>
-#include <mbgl/shader/fill_outline_pattern_shader.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/platform/log.hpp>
#include <mapbox/earcut.hpp>
diff --git a/src/mbgl/renderer/fill_bucket.hpp b/src/mbgl/renderer/fill_bucket.hpp
index c7f07b51e7..b2c549a758 100644
--- a/src/mbgl/renderer/fill_bucket.hpp
+++ b/src/mbgl/renderer/fill_bucket.hpp
@@ -5,7 +5,7 @@
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
#include <mbgl/gl/segment.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <vector>
diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp
index 1123ddadb6..4d78a80123 100644
--- a/src/mbgl/renderer/line_bucket.hpp
+++ b/src/mbgl/renderer/line_bucket.hpp
@@ -5,7 +5,7 @@
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
#include <mbgl/gl/segment.hpp>
-#include <mbgl/shader/line_attributes.hpp>
+#include <mbgl/programs/line_program.hpp>
#include <mbgl/style/layers/line_layer_properties.hpp>
#include <vector>
diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp
index bd67dc9cfd..213c01cfbd 100644
--- a/src/mbgl/renderer/paint_parameters.hpp
+++ b/src/mbgl/renderer/paint_parameters.hpp
@@ -2,12 +2,12 @@
namespace mbgl {
-class Shaders;
+class Programs;
class View;
class PaintParameters {
public:
- Shaders& shaders;
+ Programs& programs;
View& view;
};
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 6777871516..d9e7f9fd35 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -21,7 +21,7 @@
#include <mbgl/geometry/line_atlas.hpp>
#include <mbgl/text/glyph_atlas.hpp>
-#include <mbgl/shader/shaders.hpp>
+#include <mbgl/programs/programs.hpp>
#include <mbgl/algorithm/generate_clip_ids.hpp>
#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
@@ -60,18 +60,18 @@ Painter::Painter(gl::Context& context_, const TransformState& state_)
FillAttributes::vertex({ 0, 0 })
}})),
rasterVertexBuffer(context.createVertexBuffer(std::vector<RasterVertex> {{
- RasterAttributes::vertex({ 0, 0 }, { 0, 0 }),
- RasterAttributes::vertex({ util::EXTENT, 0 }, { 32767, 0 }),
- RasterAttributes::vertex({ 0, util::EXTENT }, { 0, 32767 }),
- RasterAttributes::vertex({ util::EXTENT, util::EXTENT }, { 32767, 32767 })
+ RasterProgram::vertex({ 0, 0 }, { 0, 0 }),
+ RasterProgram::vertex({ util::EXTENT, 0 }, { 32767, 0 }),
+ RasterProgram::vertex({ 0, util::EXTENT }, { 0, 32767 }),
+ RasterProgram::vertex({ util::EXTENT, util::EXTENT }, { 32767, 32767 })
}})) {
#ifndef NDEBUG
gl::debugging::enable();
#endif
- shaders = std::make_unique<Shaders>(context);
+ programs = std::make_unique<Programs>(context);
#ifndef NDEBUG
- overdrawShaders = std::make_unique<Shaders>(context, gl::Shader::Overdraw);
+ overdrawPrograms = std::make_unique<Programs>(context, ProgramDefines::Overdraw);
#endif
}
@@ -93,9 +93,9 @@ void Painter::render(const Style& style, const FrameData& frame_, View& view, Sp
PaintParameters parameters {
#ifndef NDEBUG
- paintMode() == PaintMode::Overdraw ? *overdrawShaders : *shaders,
+ paintMode() == PaintMode::Overdraw ? *overdrawPrograms : *programs,
#else
- *shaders,
+ *programs,
#endif
view
};
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index d7154397f3..53215c5033 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -9,8 +9,8 @@
#include <mbgl/renderer/bucket.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
-#include <mbgl/shader/raster_attributes.hpp>
+#include <mbgl/programs/fill_program.hpp>
+#include <mbgl/programs/raster_program.hpp>
#include <mbgl/style/style.hpp>
@@ -40,8 +40,7 @@ class CircleBucket;
class SymbolBucket;
class RasterBucket;
-class Shaders;
-class SymbolSDFShader;
+class Programs;
class PaintParameters;
struct ClipID;
@@ -152,9 +151,9 @@ private:
FrameHistory frameHistory;
- std::unique_ptr<Shaders> shaders;
+ std::unique_ptr<Programs> programs;
#ifndef NDEBUG
- std::unique_ptr<Shaders> overdrawShaders;
+ std::unique_ptr<Programs> overdrawPrograms;
#endif
gl::VertexBuffer<FillVertex> tileTriangleVertexBuffer;
diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp
index a8ebf0de05..3e2597e47c 100644
--- a/src/mbgl/renderer/painter_background.cpp
+++ b/src/mbgl/renderer/painter_background.cpp
@@ -2,8 +2,8 @@
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/background_layer_impl.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/util/tile_cover.hpp>
@@ -32,7 +32,7 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
- parameters.shaders.fillPattern,
+ parameters.programs.fillPattern,
FillPatternUniforms::values(
matrixForTile(tileID),
properties.backgroundOpacity.value,
@@ -52,8 +52,8 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
- parameters.shaders.fill,
- FillColorUniforms::Values {
+ parameters.programs.fill,
+ FillProgram::UniformValues {
uniforms::u_matrix::Value{ matrixForTile(tileID) },
uniforms::u_opacity::Value{ properties.backgroundOpacity.value },
uniforms::u_color::Value{ properties.backgroundColor.value },
diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp
index fedd1985ba..e4977b8abb 100644
--- a/src/mbgl/renderer/painter_circle.cpp
+++ b/src/mbgl/renderer/painter_circle.cpp
@@ -4,8 +4,8 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/circle_layer_impl.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/circle_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/circle_program.hpp>
#include <mbgl/gl/context.hpp>
namespace mbgl {
@@ -29,8 +29,8 @@ void Painter::renderCircle(PaintParameters& parameters,
? stencilModeForClipping(tile.clip)
: gl::StencilMode::disabled(),
colorModeForRenderPass(),
- parameters.shaders.circle,
- CircleUniforms::Values {
+ parameters.programs.circle,
+ CircleProgram::UniformValues {
uniforms::u_matrix::Value{ tile.translatedMatrix(properties.circleTranslate.value,
properties.circleTranslateAnchor.value,
state) },
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index 64558d667f..b64c5d5efc 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -1,6 +1,6 @@
#include <mbgl/renderer/painter.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/util/clip_id.hpp>
namespace mbgl {
@@ -17,8 +17,8 @@ void Painter::renderClippingMask(const UnwrappedTileID& tileID, const ClipID& cl
gl::StencilMode::Replace
},
gl::ColorMode::disabled(),
- shaders->fill,
- FillColorUniforms::Values {
+ programs->fill,
+ FillProgram::UniformValues {
uniforms::u_matrix::Value{ matrixForTile(tileID) },
uniforms::u_opacity::Value{ 0.0f },
uniforms::u_color::Value{ Color {} },
diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp
index 08877949f6..a0fc98b8c1 100644
--- a/src/mbgl/renderer/painter_debug.cpp
+++ b/src/mbgl/renderer/painter_debug.cpp
@@ -4,8 +4,8 @@
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/tile/tile.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/gl/debugging.hpp>
#include <mbgl/util/color.hpp>
@@ -23,8 +23,8 @@ void Painter::renderTileDebug(const RenderTile& renderTile) {
gl::DepthMode::disabled(),
stencilModeForClipping(renderTile.clip),
gl::ColorMode::unblended(),
- shaders->fill,
- FillColorUniforms::Values {
+ programs->fill,
+ FillProgram::UniformValues {
uniforms::u_matrix::Value{ renderTile.matrix },
uniforms::u_opacity::Value{ 1.0f },
uniforms::u_color::Value{ color },
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 5a9e7a9096..cdce181e1c 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -5,8 +5,8 @@
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/style/layers/fill_layer_impl.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/fill_program.hpp>
#include <mbgl/util/convert.hpp>
namespace mbgl {
@@ -35,12 +35,12 @@ void Painter::renderFill(PaintParameters& parameters,
spriteAtlas->bind(true, context, 0);
- auto draw = [&] (uint8_t sublayer, auto& shader, const auto& subject) {
+ auto draw = [&] (uint8_t sublayer, auto& program, const auto& subject) {
context.draw({
depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
stencilModeForClipping(tile.clip),
colorModeForRenderPass(),
- shader,
+ program,
FillPatternUniforms::values(
tile.translatedMatrix(properties.fillTranslate.value,
properties.fillTranslateAnchor.value,
@@ -58,7 +58,7 @@ void Painter::renderFill(PaintParameters& parameters,
};
draw(0,
- parameters.shaders.fillPattern,
+ parameters.programs.fillPattern,
gl::Segmented<gl::Triangles>(
*bucket.vertexBuffer,
*bucket.triangleIndexBuffer,
@@ -69,20 +69,20 @@ void Painter::renderFill(PaintParameters& parameters,
}
draw(2,
- parameters.shaders.fillOutlinePattern,
+ parameters.programs.fillOutlinePattern,
gl::Segmented<gl::Lines>(
*bucket.vertexBuffer,
*bucket.lineIndexBuffer,
bucket.lineSegments,
2.0f));
} else {
- auto draw = [&] (uint8_t sublayer, auto& shader, Color outlineColor, const auto& subject) {
+ auto draw = [&] (uint8_t sublayer, auto& program, Color outlineColor, const auto& subject) {
context.draw({
depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
stencilModeForClipping(tile.clip),
colorModeForRenderPass(),
- shader,
- FillColorUniforms::Values {
+ program,
+ FillProgram::UniformValues {
uniforms::u_matrix::Value{ tile.translatedMatrix(properties.fillTranslate.value,
properties.fillTranslateAnchor.value,
state) },
@@ -97,7 +97,7 @@ void Painter::renderFill(PaintParameters& parameters,
if (properties.fillAntialias.value && !properties.fillOutlineColor.isUndefined() && pass == RenderPass::Translucent) {
draw(2,
- parameters.shaders.fillOutline,
+ parameters.programs.fillOutline,
properties.fillOutlineColor.value,
gl::Segmented<gl::Lines>(
*bucket.vertexBuffer,
@@ -110,7 +110,7 @@ void Painter::renderFill(PaintParameters& parameters,
// or when it's translucent and we're drawing translucent fragments.
if ((properties.fillColor.value.a >= 1.0f && properties.fillOpacity.value >= 1.0f) == (pass == RenderPass::Opaque)) {
draw(1,
- parameters.shaders.fill,
+ parameters.programs.fill,
properties.fillOutlineColor.value,
gl::Segmented<gl::Triangles>(
*bucket.vertexBuffer,
@@ -120,7 +120,7 @@ void Painter::renderFill(PaintParameters& parameters,
if (properties.fillAntialias.value && properties.fillOutlineColor.isUndefined() && pass == RenderPass::Translucent) {
draw(2,
- parameters.shaders.fillOutline,
+ parameters.programs.fillOutline,
properties.fillColor.value,
gl::Segmented<gl::Lines>(
*bucket.vertexBuffer,
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index 377c956e7c..7f9556fd3f 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -4,8 +4,8 @@
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/line_layer_impl.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/line_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/line_program.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
#include <mbgl/geometry/line_atlas.hpp>
@@ -23,12 +23,12 @@ void Painter::renderLine(PaintParameters& parameters,
const auto& properties = layer.impl->paint;
- auto draw = [&] (auto& shader, auto&& uniformValues) {
+ auto draw = [&] (auto& program, auto&& uniformValues) {
context.draw({
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
stencilModeForClipping(tile.clip),
colorModeForRenderPass(),
- shader,
+ program,
std::move(uniformValues),
gl::Segmented<gl::Triangles>(
*bucket.vertexBuffer,
@@ -46,8 +46,8 @@ void Painter::renderLine(PaintParameters& parameters,
lineAtlas->bind(context, 0);
- draw(parameters.shaders.lineSDF,
- LineSDFUniforms::values(
+ draw(parameters.programs.lineSDF,
+ LineSDFProgram::uniformValues(
properties,
frame.pixelRatio,
tile,
@@ -68,8 +68,8 @@ void Painter::renderLine(PaintParameters& parameters,
spriteAtlas->bind(true, context, 0);
- draw(parameters.shaders.linePattern,
- LinePatternUniforms::values(
+ draw(parameters.programs.linePattern,
+ LinePatternProgram::uniformValues(
properties,
frame.pixelRatio,
tile,
@@ -78,8 +78,8 @@ void Painter::renderLine(PaintParameters& parameters,
*posB));
} else {
- draw(parameters.shaders.line,
- LineColorUniforms::values(
+ draw(parameters.programs.line,
+ LineProgram::uniformValues(
properties,
frame.pixelRatio,
tile,
diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp
index 6acd29eb37..c619cad2aa 100644
--- a/src/mbgl/renderer/painter_raster.cpp
+++ b/src/mbgl/renderer/painter_raster.cpp
@@ -4,8 +4,8 @@
#include <mbgl/renderer/raster_bucket.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/raster_layer_impl.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/raster_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/raster_program.hpp>
namespace mbgl {
@@ -58,8 +58,8 @@ void Painter::renderRaster(PaintParameters& parameters,
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
- parameters.shaders.raster,
- RasterUniforms::Values {
+ parameters.programs.raster,
+ RasterProgram::UniformValues {
uniforms::u_matrix::Value{ tile.matrix },
uniforms::u_image0::Value{ 0 },
uniforms::u_image1::Value{ 1 },
diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp
index cf4bb9ee86..2f94544486 100644
--- a/src/mbgl/renderer/painter_symbol.cpp
+++ b/src/mbgl/renderer/painter_symbol.cpp
@@ -6,9 +6,9 @@
#include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/text/glyph_atlas.hpp>
#include <mbgl/sprite/sprite_atlas.hpp>
-#include <mbgl/shader/shaders.hpp>
-#include <mbgl/shader/symbol_uniforms.hpp>
-#include <mbgl/shader/collision_box_uniforms.hpp>
+#include <mbgl/programs/programs.hpp>
+#include <mbgl/programs/symbol_program.hpp>
+#include <mbgl/programs/collision_box_program.hpp>
#include <mbgl/util/math.hpp>
#include <mbgl/tile/tile.hpp>
@@ -30,7 +30,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
frameHistory.bind(context, 1);
- auto draw = [&] (auto& shader,
+ auto draw = [&] (auto& program,
auto&& uniformValues,
const auto& buffers,
const SymbolPropertyValues& values_)
@@ -54,7 +54,7 @@ void Painter::renderSymbol(PaintParameters& parameters,
? gl::StencilMode::disabled()
: stencilModeForClipping(tile.clip),
colorModeForRenderPass(),
- shader,
+ program,
std::move(uniformValues),
gl::Segmented<gl::Triangles>(
*buffers.vertexBuffer,
@@ -76,21 +76,21 @@ void Painter::renderSymbol(PaintParameters& parameters,
if (bucket.sdfIcons) {
if (values.hasHalo()) {
- draw(parameters.shaders.symbolIconSDF,
- SymbolSDFUniforms::haloValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
+ draw(parameters.programs.symbolIconSDF,
+ SymbolSDFProgram::haloUniformValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
bucket.icon,
values);
}
if (values.hasForeground()) {
- draw(parameters.shaders.symbolIconSDF,
- SymbolSDFUniforms::foregroundValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
+ draw(parameters.programs.symbolIconSDF,
+ SymbolSDFProgram::foregroundUniformValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
bucket.icon,
values);
}
} else {
- draw(parameters.shaders.symbolIcon,
- SymbolIconUniforms::values(values, texsize, pixelsToGLUnits, tile, state),
+ draw(parameters.programs.symbolIcon,
+ SymbolIconProgram::uniformValues(values, texsize, pixelsToGLUnits, tile, state),
bucket.icon,
values);
}
@@ -104,15 +104,15 @@ void Painter::renderSymbol(PaintParameters& parameters,
const Size texsize = glyphAtlas->getSize();
if (values.hasHalo()) {
- draw(parameters.shaders.symbolGlyph,
- SymbolSDFUniforms::haloValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
+ draw(parameters.programs.symbolGlyph,
+ SymbolSDFProgram::haloUniformValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
bucket.text,
values);
}
if (values.hasForeground()) {
- draw(parameters.shaders.symbolGlyph,
- SymbolSDFUniforms::foregroundValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
+ draw(parameters.programs.symbolGlyph,
+ SymbolSDFProgram::foregroundUniformValues(values, texsize, pixelsToGLUnits, tile, state, frame.pixelRatio),
bucket.text,
values);
}
@@ -123,8 +123,8 @@ void Painter::renderSymbol(PaintParameters& parameters,
gl::DepthMode::disabled(),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
- shaders->collisionBox,
- CollisionBoxUniforms::Values {
+ programs->collisionBox,
+ CollisionBoxProgram::UniformValues {
uniforms::u_matrix::Value{ tile.matrix },
uniforms::u_scale::Value{ std::pow(2.0f, float(state.getZoom() - tile.tile.id.overscaledZ)) },
uniforms::u_zoom::Value{ float(state.getZoom() * 10) },
diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp
index bfe728c0b0..0355911296 100644
--- a/src/mbgl/renderer/raster_bucket.cpp
+++ b/src/mbgl/renderer/raster_bucket.cpp
@@ -1,6 +1,6 @@
#include <mbgl/renderer/raster_bucket.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
-#include <mbgl/shader/raster_shader.hpp>
+#include <mbgl/programs/raster_program.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/gl/context.hpp>
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 993d3b85d8..d33341008e 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -5,8 +5,8 @@
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/gl/index_buffer.hpp>
#include <mbgl/gl/segment.hpp>
-#include <mbgl/shader/symbol_attributes.hpp>
-#include <mbgl/shader/collision_box_attributes.hpp>
+#include <mbgl/programs/symbol_program.hpp>
+#include <mbgl/programs/collision_box_program.hpp>
#include <mbgl/text/glyph_range.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
diff --git a/src/mbgl/shader/circle_attributes.hpp b/src/mbgl/shader/circle_attributes.hpp
deleted file mode 100644
index 92f8ff1e5c..0000000000
--- a/src/mbgl/shader/circle_attributes.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-namespace mbgl {
-
-struct CircleAttributes : gl::Attributes<
- attributes::a_pos>
-{
- /*
- * @param {number} x vertex position
- * @param {number} y vertex position
- * @param {number} ex extrude normal
- * @param {number} ey extrude normal
- */
- static Vertex vertex(Point<int16_t> p, float ex, float ey) {
- return Vertex {
- {
- static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
- static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
- }
- };
- }
-};
-
-using CircleVertex = CircleAttributes::Vertex;
-static_assert(sizeof(CircleVertex) == 4, "expected CircleVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/circle_shader.cpp b/src/mbgl/shader/circle_shader.cpp
deleted file mode 100644
index f873d834f0..0000000000
--- a/src/mbgl/shader/circle_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/circle_shader.hpp>
-#include <mbgl/shader/circle.vertex.hpp>
-#include <mbgl/shader/circle.fragment.hpp>
-
-namespace mbgl {
-
-CircleShader::CircleShader(gl::Context& context, Defines defines)
- : Shader(shaders::circle::name,
- shaders::circle::vertex,
- shaders::circle::fragment,
- context, defines),
- attributesState(CircleAttributes::state(*this)),
- uniformsState(CircleUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp
deleted file mode 100644
index 35d052bf9b..0000000000
--- a/src/mbgl/shader/circle_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/circle_attributes.hpp>
-#include <mbgl/shader/circle_uniforms.hpp>
-
-namespace mbgl {
-
-class CircleShader : public gl::Shader {
-public:
- CircleShader(gl::Context&, Defines defines = None);
-
- using AttributesType = CircleAttributes;
- using UniformsType = CircleUniforms;
-
- typename CircleAttributes::State attributesState;
- typename CircleUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/circle_uniforms.hpp b/src/mbgl/shader/circle_uniforms.hpp
deleted file mode 100644
index c77c0daaba..0000000000
--- a/src/mbgl/shader/circle_uniforms.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/uniforms.hpp>
-
-namespace mbgl {
-
-namespace uniforms {
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius);
-MBGL_DEFINE_UNIFORM_SCALAR(bool, u_scale_with_map);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_devicepixelratio);
-} // namespace uniforms
-
-struct CircleUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_color,
- uniforms::u_radius,
- uniforms::u_blur,
- uniforms::u_scale_with_map,
- uniforms::u_extrude_scale,
- uniforms::u_devicepixelratio> {};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_attributes.hpp b/src/mbgl/shader/collision_box_attributes.hpp
deleted file mode 100644
index c3131d6c27..0000000000
--- a/src/mbgl/shader/collision_box_attributes.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-#include <cmath>
-
-namespace mbgl {
-
-struct CollisionBoxAttributes : gl::Attributes<
- attributes::a_pos,
- attributes::a_extrude,
- attributes::a_data<2>>
-{
- static Vertex vertex(Point<float> a, Point<float> o, float maxzoom, float placementZoom) {
- return Vertex {
- {
- static_cast<int16_t>(a.x),
- static_cast<int16_t>(a.y)
- },
- {
- static_cast<int16_t>(::round(o.x)),
- static_cast<int16_t>(::round(o.y))
- },
- {
- static_cast<uint8_t>(maxzoom * 10),
- static_cast<uint8_t>(placementZoom * 10)
- }
- };
- }
-};
-
-using CollisionBoxVertex = CollisionBoxAttributes::Vertex;
-static_assert(sizeof(CollisionBoxVertex) == 10, "expected CollisionBoxVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_shader.cpp b/src/mbgl/shader/collision_box_shader.cpp
deleted file mode 100644
index 61f6113234..0000000000
--- a/src/mbgl/shader/collision_box_shader.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <mbgl/shader/collision_box_shader.hpp>
-#include <mbgl/shader/collision_box.vertex.hpp>
-#include <mbgl/shader/collision_box.fragment.hpp>
-
-namespace mbgl {
-
-CollisionBoxShader::CollisionBoxShader(gl::Context& context)
- : Shader(shaders::collision_box::name,
- shaders::collision_box::vertex,
- shaders::collision_box::fragment,
- context),
- attributesState(CollisionBoxAttributes::state(*this)),
- uniformsState(CollisionBoxUniforms::state(*this))
-{
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_shader.hpp b/src/mbgl/shader/collision_box_shader.hpp
deleted file mode 100644
index 8995507eee..0000000000
--- a/src/mbgl/shader/collision_box_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/collision_box_uniforms.hpp>
-#include <mbgl/shader/collision_box_attributes.hpp>
-
-namespace mbgl {
-
-class CollisionBoxShader : public gl::Shader {
-public:
- CollisionBoxShader(gl::Context&);
-
- using AttributesType = CollisionBoxAttributes;
- using UniformsType = CollisionBoxUniforms;
-
- typename CollisionBoxAttributes::State attributesState;
- typename CollisionBoxUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_uniforms.hpp b/src/mbgl/shader/collision_box_uniforms.hpp
deleted file mode 100644
index f195cc9a6a..0000000000
--- a/src/mbgl/shader/collision_box_uniforms.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/uniforms.hpp>
-
-namespace mbgl {
-
-namespace uniforms {
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_maxzoom);
-} // namespace uniforms
-
-struct CollisionBoxUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_scale,
- uniforms::u_zoom,
- uniforms::u_maxzoom> {};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_attributes.hpp b/src/mbgl/shader/fill_attributes.hpp
deleted file mode 100644
index 83e4df3543..0000000000
--- a/src/mbgl/shader/fill_attributes.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-namespace mbgl {
-
-struct FillAttributes : gl::Attributes<
- attributes::a_pos> {
-
- static Vertex vertex(Point<int16_t> p) {
- return Vertex {
- {
- p.x,
- p.y
- }
- };
- }
-};
-
-using FillVertex = FillAttributes::Vertex;
-static_assert(sizeof(FillVertex) == 4, "expected FillVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_outline_pattern_shader.cpp b/src/mbgl/shader/fill_outline_pattern_shader.cpp
deleted file mode 100644
index 723366f6d0..0000000000
--- a/src/mbgl/shader/fill_outline_pattern_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/fill_outline_pattern_shader.hpp>
-#include <mbgl/shader/fill_outline_pattern.vertex.hpp>
-#include <mbgl/shader/fill_outline_pattern.fragment.hpp>
-
-namespace mbgl {
-
-FillOutlinePatternShader::FillOutlinePatternShader(gl::Context& context, Defines defines)
- : Shader(shaders::fill_outline_pattern::name,
- shaders::fill_outline_pattern::vertex,
- shaders::fill_outline_pattern::fragment,
- context, defines),
- attributesState(FillAttributes::state(*this)),
- uniformsState(FillPatternUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_outline_pattern_shader.hpp b/src/mbgl/shader/fill_outline_pattern_shader.hpp
deleted file mode 100644
index a33aa532fe..0000000000
--- a/src/mbgl/shader/fill_outline_pattern_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
-
-namespace mbgl {
-
-class FillOutlinePatternShader : public gl::Shader {
-public:
- FillOutlinePatternShader(gl::Context&, Defines defines = None);
-
- using AttributesType = FillAttributes;
- using UniformsType = FillPatternUniforms;
-
- typename FillAttributes::State attributesState;
- typename FillPatternUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_outline_shader.cpp b/src/mbgl/shader/fill_outline_shader.cpp
deleted file mode 100644
index 909b652e7f..0000000000
--- a/src/mbgl/shader/fill_outline_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/fill_outline_shader.hpp>
-#include <mbgl/shader/fill_outline.vertex.hpp>
-#include <mbgl/shader/fill_outline.fragment.hpp>
-
-namespace mbgl {
-
-FillOutlineShader::FillOutlineShader(gl::Context& context, Defines defines)
- : Shader(shaders::fill_outline::name,
- shaders::fill_outline::vertex,
- shaders::fill_outline::fragment,
- context, defines),
- attributesState(FillAttributes::state(*this)),
- uniformsState(FillColorUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_outline_shader.hpp b/src/mbgl/shader/fill_outline_shader.hpp
deleted file mode 100644
index e68861641f..0000000000
--- a/src/mbgl/shader/fill_outline_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
-
-namespace mbgl {
-
-class FillOutlineShader : public gl::Shader {
-public:
- FillOutlineShader(gl::Context&, Defines defines = None);
-
- using AttributesType = FillAttributes;
- using UniformsType = FillColorUniforms;
-
- typename FillAttributes::State attributesState;
- typename FillColorUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_pattern_shader.cpp b/src/mbgl/shader/fill_pattern_shader.cpp
deleted file mode 100644
index 60f9d74c1a..0000000000
--- a/src/mbgl/shader/fill_pattern_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/fill_pattern_shader.hpp>
-#include <mbgl/shader/fill_pattern.vertex.hpp>
-#include <mbgl/shader/fill_pattern.fragment.hpp>
-
-namespace mbgl {
-
-FillPatternShader::FillPatternShader(gl::Context& context, Defines defines)
- : Shader(shaders::fill_pattern::name,
- shaders::fill_pattern::vertex,
- shaders::fill_pattern::fragment,
- context, defines),
- attributesState(FillAttributes::state(*this)),
- uniformsState(FillPatternUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_pattern_shader.hpp b/src/mbgl/shader/fill_pattern_shader.hpp
deleted file mode 100644
index 1ea378b822..0000000000
--- a/src/mbgl/shader/fill_pattern_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
-
-namespace mbgl {
-
-class FillPatternShader : public gl::Shader {
-public:
- FillPatternShader(gl::Context&, Defines defines = None);
-
- using AttributesType = FillAttributes;
- using UniformsType = FillPatternUniforms;
-
- typename FillAttributes::State attributesState;
- typename FillPatternUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_shader.cpp b/src/mbgl/shader/fill_shader.cpp
deleted file mode 100644
index 457ecbb0ba..0000000000
--- a/src/mbgl/shader/fill_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/fill_shader.hpp>
-#include <mbgl/shader/fill.vertex.hpp>
-#include <mbgl/shader/fill.fragment.hpp>
-
-namespace mbgl {
-
-FillShader::FillShader(gl::Context& context, Defines defines)
- : Shader(shaders::fill::name,
- shaders::fill::vertex,
- shaders::fill::fragment,
- context, defines),
- attributesState(FillAttributes::state(*this)),
- uniformsState(FillColorUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/fill_shader.hpp b/src/mbgl/shader/fill_shader.hpp
deleted file mode 100644
index 4b8b4ed4f9..0000000000
--- a/src/mbgl/shader/fill_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/fill_uniforms.hpp>
-#include <mbgl/shader/fill_attributes.hpp>
-
-namespace mbgl {
-
-class FillShader : public gl::Shader {
-public:
- FillShader(gl::Context&, Defines defines = None);
-
- using AttributesType = FillAttributes;
- using UniformsType = FillColorUniforms;
-
- typename FillAttributes::State attributesState;
- typename FillColorUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_attributes.hpp b/src/mbgl/shader/line_attributes.hpp
deleted file mode 100644
index 1f7dc85201..0000000000
--- a/src/mbgl/shader/line_attributes.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-#include <cmath>
-
-namespace mbgl {
-
-struct LineAttributes : gl::Attributes<
- attributes::a_pos,
- attributes::a_data<4>> {
-
- /*
- * @param p vertex position
- * @param e extrude normal
- * @param t texture normal
- * @param dir direction of the line cap (-1/0/1)
- */
- static Vertex vertex(Point<int16_t> p, Point<double> e, Point<bool> t, int8_t dir, int32_t linesofar = 0) {
- return Vertex {
- {
- static_cast<int16_t>((p.x * 2) | t.x),
- static_cast<int16_t>((p.y * 2) | t.y)
- },
- {
- // add 128 to store an byte in an unsigned byte
- static_cast<uint8_t>(::round(extrudeScale * e.x) + 128),
- static_cast<uint8_t>(::round(extrudeScale * e.y) + 128),
-
- // Encode the -1/0/1 direction value into the first two bits of .z of a_data.
- // Combine it with the lower 6 bits of `linesofar` (shifted by 2 bites to make
- // room for the direction value). The upper 8 bits of `linesofar` are placed in
- // the `w` component. `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that
- // we can store longer distances while sacrificing precision.
-
- // Encode the -1/0/1 direction value into .zw coordinates of a_data, which is normally covered
- // by linesofar, so we need to merge them.
- // The z component's first bit, as well as the sign bit is reserved for the direction,
- // so we need to shift the linesofar.
- static_cast<uint8_t>(((dir == 0 ? 0 : (dir < 0 ? -1 : 1 )) + 1) | ((linesofar & 0x3F) << 2)),
- static_cast<uint8_t>(linesofar >> 6)
- }
- };
- }
-
- /*
- * Scale the extrusion vector so that the normal length is this value.
- * Contains the "texture" normals (-1..1). This is distinct from the extrude
- * normals for line joins, because the x-value remains 0 for the texture
- * normal array, while the extrude normal actually moves the vertex to create
- * the acute/bevelled line join.
- */
- static const int8_t extrudeScale = 63;
-};
-
-using LineVertex = LineAttributes::Vertex;
-static_assert(sizeof(LineVertex) == 8, "expected LineVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_pattern_shader.cpp b/src/mbgl/shader/line_pattern_shader.cpp
deleted file mode 100644
index 6085e033c6..0000000000
--- a/src/mbgl/shader/line_pattern_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/line_pattern_shader.hpp>
-#include <mbgl/shader/line_pattern.vertex.hpp>
-#include <mbgl/shader/line_pattern.fragment.hpp>
-
-namespace mbgl {
-
-LinePatternShader::LinePatternShader(gl::Context& context, Defines defines)
- : Shader(shaders::line_pattern::name,
- shaders::line_pattern::vertex,
- shaders::line_pattern::fragment,
- context, defines),
- attributesState(LineAttributes::state(*this)),
- uniformsState(LinePatternUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_pattern_shader.hpp b/src/mbgl/shader/line_pattern_shader.hpp
deleted file mode 100644
index d1013ce4f0..0000000000
--- a/src/mbgl/shader/line_pattern_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/line_uniforms.hpp>
-#include <mbgl/shader/line_attributes.hpp>
-
-namespace mbgl {
-
-class LinePatternShader : public gl::Shader {
-public:
- LinePatternShader(gl::Context&, Defines defines = None);
-
- using AttributesType = LineAttributes;
- using UniformsType = LinePatternUniforms;
-
- typename LineAttributes::State attributesState;
- typename LinePatternUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_sdf_shader.cpp b/src/mbgl/shader/line_sdf_shader.cpp
deleted file mode 100644
index ee36c3309f..0000000000
--- a/src/mbgl/shader/line_sdf_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/line_sdf_shader.hpp>
-#include <mbgl/shader/line_sdf.vertex.hpp>
-#include <mbgl/shader/line_sdf.fragment.hpp>
-
-namespace mbgl {
-
-LineSDFShader::LineSDFShader(gl::Context& context, Defines defines)
- : Shader(shaders::line_sdf::name,
- shaders::line_sdf::vertex,
- shaders::line_sdf::fragment,
- context, defines),
- attributesState(LineAttributes::state(*this)),
- uniformsState(LineSDFUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_sdf_shader.hpp b/src/mbgl/shader/line_sdf_shader.hpp
deleted file mode 100644
index 4f793f5609..0000000000
--- a/src/mbgl/shader/line_sdf_shader.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/line_uniforms.hpp>
-#include <mbgl/shader/line_attributes.hpp>
-
-namespace mbgl {
-
-class LineSDFShader : public gl::Shader {
-public:
- LineSDFShader(gl::Context&, Defines defines = None);
-
- using AttributesType = LineAttributes;
- using UniformsType = LineSDFUniforms;
-
- typename LineAttributes::State attributesState;
- typename LineSDFUniforms::State uniformsState;
-};
-
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_shader.cpp b/src/mbgl/shader/line_shader.cpp
deleted file mode 100644
index 4bb44de16d..0000000000
--- a/src/mbgl/shader/line_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/line_shader.hpp>
-#include <mbgl/shader/line.vertex.hpp>
-#include <mbgl/shader/line.fragment.hpp>
-
-namespace mbgl {
-
-LineShader::LineShader(gl::Context& context, Defines defines)
- : Shader(shaders::line::name,
- shaders::line::vertex,
- shaders::line::fragment,
- context, defines),
- attributesState(LineAttributes::state(*this)),
- uniformsState(LineColorUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp
deleted file mode 100644
index 91ae41e95a..0000000000
--- a/src/mbgl/shader/line_shader.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/line_uniforms.hpp>
-#include <mbgl/shader/line_attributes.hpp>
-
-namespace mbgl {
-
-class LineShader : public gl::Shader {
-public:
- LineShader(gl::Context&, Defines defines = None);
-
- using AttributesType = LineAttributes;
- using UniformsType = LineColorUniforms;
-
- typename LineAttributes::State attributesState;
- typename LineColorUniforms::State uniformsState;
-};
-
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/line_uniforms.hpp b/src/mbgl/shader/line_uniforms.hpp
deleted file mode 100644
index 8a9c5310b5..0000000000
--- a/src/mbgl/shader/line_uniforms.hpp
+++ /dev/null
@@ -1,109 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/uniforms.hpp>
-
-namespace mbgl {
-
-namespace style {
-class LinePaintProperties;
-} // namespace style
-
-class RenderTile;
-class TransformState;
-class LinePatternPos;
-class SpriteAtlasPosition;
-
-namespace uniforms {
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_ratio);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_linewidth);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_gapwidth);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_antialiasing);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_extra);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_offset);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_tex_y_a);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_tex_y_b);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_sdfgamma);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_fade);
-MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_patternscale_a);
-MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_patternscale_b);
-MBGL_DEFINE_UNIFORM_MATRIX(double, 2, u_antialiasingmatrix);
-} // namespace uniforms
-
-struct LineColorUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_linewidth,
- uniforms::u_gapwidth,
- uniforms::u_blur,
- uniforms::u_offset,
- uniforms::u_antialiasing,
- uniforms::u_antialiasingmatrix,
- uniforms::u_ratio,
- uniforms::u_extra,
- uniforms::u_color>
-{
- static Values values(const style::LinePaintProperties&,
- float pixelRatio,
- const RenderTile&,
- const TransformState&);
-};
-
-struct LineSDFUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_linewidth,
- uniforms::u_gapwidth,
- uniforms::u_blur,
- uniforms::u_offset,
- uniforms::u_antialiasing,
- uniforms::u_antialiasingmatrix,
- uniforms::u_ratio,
- uniforms::u_extra,
- uniforms::u_color,
- uniforms::u_patternscale_a,
- uniforms::u_patternscale_b,
- uniforms::u_tex_y_a,
- uniforms::u_tex_y_b,
- uniforms::u_mix,
- uniforms::u_sdfgamma,
- uniforms::u_image>
-{
- static Values values(const style::LinePaintProperties&,
- float pixelRatio,
- const RenderTile&,
- const TransformState&,
- const LinePatternPos& posA,
- const LinePatternPos& posB,
- float dashLineWidth,
- float atlasWidth);
-};
-
-struct LinePatternUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_linewidth,
- uniforms::u_gapwidth,
- uniforms::u_blur,
- uniforms::u_offset,
- uniforms::u_antialiasing,
- uniforms::u_antialiasingmatrix,
- uniforms::u_ratio,
- uniforms::u_extra,
- uniforms::u_pattern_tl_a,
- uniforms::u_pattern_br_a,
- uniforms::u_pattern_tl_b,
- uniforms::u_pattern_br_b,
- uniforms::u_pattern_size_a,
- uniforms::u_pattern_size_b,
- uniforms::u_fade,
- uniforms::u_image>
-{
- static Values values(const style::LinePaintProperties&,
- float pixelRatio,
- const RenderTile&,
- const TransformState&,
- const SpriteAtlasPosition& posA,
- const SpriteAtlasPosition& posB);
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/raster_attributes.hpp b/src/mbgl/shader/raster_attributes.hpp
deleted file mode 100644
index 88f0125754..0000000000
--- a/src/mbgl/shader/raster_attributes.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-namespace mbgl {
-
-struct RasterAttributes : gl::Attributes<
- attributes::a_pos,
- attributes::a_texture_pos>
-{
- static Vertex vertex(Point<int16_t> p, Point<uint16_t> t) {
- return Vertex {
- {
- p.x,
- p.y
- },
- {
- t.x,
- t.y
- }
- };
- }
-};
-
-using RasterVertex = RasterAttributes::Vertex;
-static_assert(sizeof(RasterVertex) == 8, "expected RasterVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/raster_shader.cpp b/src/mbgl/shader/raster_shader.cpp
deleted file mode 100644
index 4f1d873044..0000000000
--- a/src/mbgl/shader/raster_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/raster_shader.hpp>
-#include <mbgl/shader/raster.vertex.hpp>
-#include <mbgl/shader/raster.fragment.hpp>
-
-namespace mbgl {
-
-RasterShader::RasterShader(gl::Context& context, Defines defines)
- : Shader(shaders::raster::name,
- shaders::raster::vertex,
- shaders::raster::fragment,
- context, defines),
- attributesState(RasterAttributes::state(*this)),
- uniformsState(RasterUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/raster_shader.hpp b/src/mbgl/shader/raster_shader.hpp
deleted file mode 100644
index 6d85175d77..0000000000
--- a/src/mbgl/shader/raster_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/raster_uniforms.hpp>
-#include <mbgl/shader/raster_attributes.hpp>
-
-namespace mbgl {
-
-class RasterShader : public gl::Shader {
-public:
- RasterShader(gl::Context&, Defines defines = None);
-
- using AttributesType = RasterAttributes;
- using UniformsType = RasterUniforms;
-
- typename RasterAttributes::State attributesState;
- typename RasterUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/raster_uniforms.hpp b/src/mbgl/shader/raster_uniforms.hpp
deleted file mode 100644
index 0a81b95c66..0000000000
--- a/src/mbgl/shader/raster_uniforms.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/uniforms.hpp>
-
-namespace mbgl {
-
-namespace uniforms {
-MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image0);
-MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_image1);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_opacity0);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_opacity1);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_buffer_scale);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_low);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_brightness_high);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_saturation_factor);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_contrast_factor);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_parent);
-MBGL_DEFINE_UNIFORM_VECTOR(float, 3, u_spin_weights);
-MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_tl_parent);
-} // namespace uniforms
-
-struct RasterUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_image0,
- uniforms::u_image1,
- uniforms::u_opacity0,
- uniforms::u_opacity1,
- uniforms::u_brightness_low,
- uniforms::u_brightness_high,
- uniforms::u_saturation_factor,
- uniforms::u_contrast_factor,
- uniforms::u_spin_weights,
- uniforms::u_buffer_scale,
- uniforms::u_scale_parent,
- uniforms::u_tl_parent> {};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/shaders.hpp b/src/mbgl/shader/shaders.hpp
deleted file mode 100644
index 56b063ce29..0000000000
--- a/src/mbgl/shader/shaders.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/circle_shader.hpp>
-#include <mbgl/shader/fill_shader.hpp>
-#include <mbgl/shader/fill_pattern_shader.hpp>
-#include <mbgl/shader/fill_outline_shader.hpp>
-#include <mbgl/shader/fill_outline_pattern_shader.hpp>
-#include <mbgl/shader/line_shader.hpp>
-#include <mbgl/shader/line_sdf_shader.hpp>
-#include <mbgl/shader/line_pattern_shader.hpp>
-#include <mbgl/shader/raster_shader.hpp>
-#include <mbgl/shader/symbol_icon_shader.hpp>
-#include <mbgl/shader/symbol_sdf_shader.hpp>
-
-#include <mbgl/shader/collision_box_shader.hpp>
-
-namespace mbgl {
-
-class Shaders {
-public:
- Shaders(gl::Context& context, gl::Shader::Defines defines = gl::Shader::None)
- : circle(context, defines),
- fill(context, defines),
- fillPattern(context, defines),
- fillOutline(context, defines),
- fillOutlinePattern(context, defines),
- line(context, defines),
- lineSDF(context, defines),
- linePattern(context, defines),
- raster(context, defines),
- symbolIcon(context, defines),
- symbolIconSDF(context, defines),
- symbolGlyph(context, defines),
- collisionBox(context) {
- }
-
- CircleShader circle;
- FillShader fill;
- FillPatternShader fillPattern;
- FillOutlineShader fillOutline;
- FillOutlinePatternShader fillOutlinePattern;
- LineShader line;
- LineSDFShader lineSDF;
- LinePatternShader linePattern;
- RasterShader raster;
- SymbolIconShader symbolIcon;
- SymbolSDFShader symbolIconSDF;
- SymbolSDFShader symbolGlyph;
-
- CollisionBoxShader collisionBox;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_attributes.hpp b/src/mbgl/shader/symbol_attributes.hpp
deleted file mode 100644
index 32f252e49a..0000000000
--- a/src/mbgl/shader/symbol_attributes.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/attributes.hpp>
-#include <mbgl/util/geometry.hpp>
-
-#include <cmath>
-
-namespace mbgl {
-
-struct SymbolAttributes : gl::Attributes<
- attributes::a_pos,
- attributes::a_offset,
- attributes::a_texture_pos,
- attributes::a_data<4>>
-{
- static Vertex vertex(Point<float> a,
- Point<float> o,
- uint16_t tx,
- uint16_t ty,
- float minzoom,
- float maxzoom,
- float labelminzoom,
- uint8_t labelangle) {
- return Vertex {
- {
- static_cast<int16_t>(a.x),
- static_cast<int16_t>(a.y)
- },
- {
- static_cast<int16_t>(::round(o.x * 64)), // use 1/64 pixels for placement
- static_cast<int16_t>(::round(o.y * 64))
- },
- {
- static_cast<uint16_t>(tx / 4),
- static_cast<uint16_t>(ty / 4)
- },
- {
- static_cast<uint8_t>(labelminzoom * 10), // 1/10 zoom levels: z16 == 160
- static_cast<uint8_t>(labelangle),
- static_cast<uint8_t>(minzoom * 10),
- static_cast<uint8_t>(::fmin(maxzoom, 25) * 10)
- }
- };
- }
-};
-
-using SymbolVertex = SymbolAttributes::Vertex;
-static_assert(sizeof(SymbolVertex) == 16, "expected SymbolVertex size");
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_icon_shader.cpp b/src/mbgl/shader/symbol_icon_shader.cpp
deleted file mode 100644
index c6677eb38e..0000000000
--- a/src/mbgl/shader/symbol_icon_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/symbol_icon_shader.hpp>
-#include <mbgl/shader/symbol_icon.vertex.hpp>
-#include <mbgl/shader/symbol_icon.fragment.hpp>
-
-namespace mbgl {
-
-SymbolIconShader::SymbolIconShader(gl::Context& context, Defines defines)
- : Shader(shaders::symbol_icon::name,
- shaders::symbol_icon::vertex,
- shaders::symbol_icon::fragment,
- context, defines),
- attributesState(SymbolAttributes::state(*this)),
- uniformsState(SymbolIconUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_icon_shader.hpp b/src/mbgl/shader/symbol_icon_shader.hpp
deleted file mode 100644
index b04ae76d75..0000000000
--- a/src/mbgl/shader/symbol_icon_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/symbol_uniforms.hpp>
-#include <mbgl/shader/symbol_attributes.hpp>
-
-namespace mbgl {
-
-class SymbolIconShader : public gl::Shader {
-public:
- SymbolIconShader(gl::Context&, Defines defines = None);
-
- using AttributesType = SymbolAttributes;
- using UniformsType = SymbolIconUniforms;
-
- typename SymbolAttributes::State attributesState;
- typename SymbolIconUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_sdf_shader.cpp b/src/mbgl/shader/symbol_sdf_shader.cpp
deleted file mode 100644
index aeb45e1099..0000000000
--- a/src/mbgl/shader/symbol_sdf_shader.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mbgl/shader/symbol_sdf_shader.hpp>
-#include <mbgl/shader/symbol_sdf.vertex.hpp>
-#include <mbgl/shader/symbol_sdf.fragment.hpp>
-
-namespace mbgl {
-
-SymbolSDFShader::SymbolSDFShader(gl::Context& context, Defines defines)
- : Shader(shaders::symbol_sdf::name,
- shaders::symbol_sdf::vertex,
- shaders::symbol_sdf::fragment,
- context, defines),
- attributesState(SymbolAttributes::state(*this)),
- uniformsState(SymbolSDFUniforms::state(*this)) {
-}
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_sdf_shader.hpp b/src/mbgl/shader/symbol_sdf_shader.hpp
deleted file mode 100644
index 5ebfca5a43..0000000000
--- a/src/mbgl/shader/symbol_sdf_shader.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/shader.hpp>
-#include <mbgl/shader/symbol_uniforms.hpp>
-#include <mbgl/shader/symbol_attributes.hpp>
-
-namespace mbgl {
-
-class SymbolSDFShader : public gl::Shader {
-public:
- SymbolSDFShader(gl::Context&, Defines defines = None);
-
- using AttributesType = SymbolAttributes;
- using UniformsType = SymbolSDFUniforms;
-
- typename SymbolAttributes::State attributesState;
- typename SymbolSDFUniforms::State uniformsState;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/symbol_uniforms.hpp b/src/mbgl/shader/symbol_uniforms.hpp
deleted file mode 100644
index a38837c051..0000000000
--- a/src/mbgl/shader/symbol_uniforms.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#pragma once
-
-#include <mbgl/shader/uniforms.hpp>
-#include <mbgl/util/size.hpp>
-
-#include <array>
-
-namespace mbgl {
-
-namespace style {
-class SymbolPropertyValues;
-} // namespace style
-
-class RenderTile;
-class TransformState;
-
-namespace uniforms {
-MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_texsize);
-MBGL_DEFINE_UNIFORM_SCALAR(bool, u_rotate_with_map);
-MBGL_DEFINE_UNIFORM_SCALAR(bool, u_pitch_with_map);
-MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_texture);
-MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_fadetexture);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_buffer);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_gamma);
-MBGL_DEFINE_UNIFORM_SCALAR(float, u_aspect_ratio);
-} // namespace uniforms
-
-struct SymbolIconUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_extrude_scale,
- uniforms::u_texsize,
- uniforms::u_zoom,
- uniforms::u_rotate_with_map,
- uniforms::u_texture,
- uniforms::u_fadetexture>
-{
- static Values values(const style::SymbolPropertyValues&,
- const Size& texsize,
- const std::array<float, 2>& pixelsToGLUnits,
- const RenderTile&,
- const TransformState&);
-};
-
-struct SymbolSDFUniforms : gl::Uniforms<
- uniforms::u_matrix,
- uniforms::u_opacity,
- uniforms::u_extrude_scale,
- uniforms::u_texsize,
- uniforms::u_zoom,
- uniforms::u_rotate_with_map,
- uniforms::u_texture,
- uniforms::u_fadetexture,
- uniforms::u_color,
- uniforms::u_buffer,
- uniforms::u_gamma,
- uniforms::u_pitch,
- uniforms::u_bearing,
- uniforms::u_aspect_ratio,
- uniforms::u_pitch_with_map>
-{
- static Values haloValues(const style::SymbolPropertyValues&,
- const Size& texsize,
- const std::array<float, 2>& pixelsToGLUnits,
- const RenderTile&,
- const TransformState&,
- float pixelRatio);
-
- static Values foregroundValues(const style::SymbolPropertyValues&,
- const Size& texsize,
- const std::array<float, 2>& pixelsToGLUnits,
- const RenderTile&,
- const TransformState&,
- float pixelRatio);
-};
-
-} // namespace mbgl
diff --git a/test/gl/object.test.cpp b/test/gl/object.test.cpp
index 45a69b4c71..fb143c55c8 100644
--- a/test/gl/object.test.cpp
+++ b/test/gl/object.test.cpp
@@ -7,6 +7,8 @@
#include <memory>
+using namespace mbgl;
+
namespace {
static bool getFlag = false;
@@ -27,7 +29,7 @@ TEST(GLObject, PreserveState) {
getFlag = false;
setFlag = false;
- auto object = std::make_unique<mbgl::gl::PreserveState<MockGLObject>>();
+ auto object = std::make_unique<gl::PreserveState<MockGLObject>>();
EXPECT_TRUE(getFlag);
EXPECT_FALSE(setFlag);
@@ -40,7 +42,7 @@ TEST(GLObject, PreserveState) {
TEST(GLObject, Value) {
setFlag = false;
- auto object = std::make_unique<mbgl::gl::State<MockGLObject>>();
+ auto object = std::make_unique<gl::State<MockGLObject>>();
EXPECT_EQ(object->getCurrentValue(), false);
EXPECT_TRUE(object->isDirty());
EXPECT_FALSE(setFlag);
@@ -58,27 +60,13 @@ TEST(GLObject, Value) {
}
TEST(GLObject, Store) {
- mbgl::HeadlessBackend backend;
- mbgl::OffscreenView view(backend.getContext());
-
- mbgl::gl::Context context;
- EXPECT_TRUE(context.empty());
+ HeadlessBackend backend;
+ OffscreenView view(backend.getContext());
- mbgl::gl::UniqueProgram program = context.createProgram();
- EXPECT_NE(program.get(), 0u);
- program.reset();
- EXPECT_FALSE(context.empty());
- context.performCleanup();
- EXPECT_TRUE(context.empty());
-
- mbgl::gl::UniqueShader shader = context.createVertexShader();
- EXPECT_NE(shader.get(), 0u);
- shader.reset();
- EXPECT_FALSE(context.empty());
- context.performCleanup();
+ gl::Context context;
EXPECT_TRUE(context.empty());
- mbgl::gl::UniqueTexture texture = context.createTexture();
+ gl::UniqueTexture texture = context.createTexture();
EXPECT_NE(texture.get(), 0u);
texture.reset();
EXPECT_FALSE(context.empty());