only update GL state when it actually changed

This commit is contained in:
Konstantin Käfer
2015-04-27 17:53:05 +02:00
parent 914b6f01f8
commit 72964f5bef
12 changed files with 340 additions and 83 deletions

View File

@@ -0,0 +1,87 @@
#ifndef MBGL_UTIL_GL_HELPER
#define MBGL_UTIL_GL_HELPER
#include <mbgl/platform/gl.hpp>
#include <array>
namespace {
template <typename T, T (*Create)(), void (*Destroy)(const T&)>
class Preserve {
public:
Preserve() : data(Create()) {}
~Preserve() { Destroy(data); }
private:
const T data;
};
inline bool getBlend() {
return glIsEnabled(GL_BLEND);
}
inline void setBlend(const bool& enabled) {
enabled ? MBGL_CHECK_ERROR(glEnable(GL_BLEND)) : MBGL_CHECK_ERROR(glDisable(GL_BLEND));
}
inline std::array<double, 4> getClearColor() {
std::array<double, 4> color;
MBGL_CHECK_ERROR(glGetDoublev(GL_COLOR_CLEAR_VALUE, color.data()));
return color;
}
inline void setClearColor(const std::array<double, 4>& color) {
MBGL_CHECK_ERROR(glClearColor(color[0], color[1], color[2], color[3]));
}
inline std::array<GLenum, 2> getBlendFunc() {
GLint func[2];
glGetIntegerv(GL_BLEND_SRC, &func[0]);
glGetIntegerv(GL_BLEND_DST, &func[1]);
return {{ static_cast<GLenum>(func[0]), static_cast<GLenum>(func[1]) }};
}
inline void setBlendFunc(const std::array<GLenum, 2>& func) {
MBGL_CHECK_ERROR(glBlendFunc(func[0], func[1]));
}
inline std::array<double, 2> getPixelZoom() {
std::array<double, 2> zoom;
glGetDoublev(GL_ZOOM_X, &zoom[0]);
glGetDoublev(GL_ZOOM_Y, &zoom[1]);
return zoom;
}
inline void setPixelZoom(const std::array<double, 2>& func) {
MBGL_CHECK_ERROR(glPixelZoom(func[0], func[1]));
}
inline std::array<double, 4> getRasterPos() {
std::array<double, 4> pos;
MBGL_CHECK_ERROR(glGetDoublev(GL_CURRENT_RASTER_POSITION, pos.data()));
return pos;
}
inline void setRasterPos(const std::array<double, 4>& pos) {
MBGL_CHECK_ERROR(glRasterPos4d(pos[0], pos[1], pos[2], pos[3]));
}
} // end anonymous namespace
namespace mbgl {
namespace gl {
using PreserveBlend = Preserve<bool, getBlend, setBlend>;
using PreserveClearColor = Preserve<std::array<double, 4>, getClearColor, setClearColor>;
using PreserveBlendFunc = Preserve<std::array<GLenum, 2>, getBlendFunc, setBlendFunc>;
using PreservePixelZoom = Preserve<std::array<double, 2>, getPixelZoom, setPixelZoom>;
using PreserveRasterPos = Preserve<std::array<double, 4>, getRasterPos, setRasterPos>;
}
}
#endif

View File

@@ -1,6 +1,7 @@
#include <mbgl/platform/default/glfw_view.hpp>
#include <mbgl/platform/gl.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/gl_helper.hpp>
#include <cassert>
#include <pthread.h>
@@ -333,15 +334,20 @@ void showDebugImage(std::string name, const char *data, size_t width, size_t hei
glfwGetFramebufferSize(debugWindow, &fbWidth, &fbHeight);
float scale = static_cast<float>(fbWidth) / static_cast<float>(width);
MBGL_CHECK_ERROR(glPixelZoom(scale, -scale));
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data));
{
gl::PreservePixelZoom pixelZoom;
gl::PreserveRasterPos rasterPos;
MBGL_CHECK_ERROR(glPixelZoom(scale, -scale));
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data));
}
glfwSwapBuffers(debugWindow);
glfwMakeContextCurrent(currentWindow);
}
void showColorDebugImage(std::string name, const char *data, size_t logicalWidth, size_t logicalHeight, size_t width, size_t height) {
glfwInit();
@@ -365,14 +371,22 @@ void showColorDebugImage(std::string name, const char *data, size_t logicalWidth
float xScale = static_cast<float>(fbWidth) / static_cast<float>(width);
float yScale = static_cast<float>(fbHeight) / static_cast<float>(height);
MBGL_CHECK_ERROR(glClearColor(0.8, 0.8, 0.8, 1));
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
{
gl::PreserveClearColor clearColor;
gl::PreserveBlend blend;
gl::PreserveBlendFunc blendFunc;
gl::PreservePixelZoom pixelZoom;
gl::PreserveRasterPos rasterPos;
MBGL_CHECK_ERROR(glClearColor(0.8, 0.8, 0.8, 1));
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
MBGL_CHECK_ERROR(glPixelZoom(xScale, -yScale));
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data));
}
MBGL_CHECK_ERROR(glPixelZoom(xScale, -yScale));
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data));
glfwSwapBuffers(debugWindow);
glfwMakeContextCurrent(currentWindow);

View File

@@ -0,0 +1,19 @@
#include "gl_config.hpp"
namespace mbgl {
namespace gl {
const ClearDepth::Type ClearDepth::Default = 0;
const ClearColor::Type ClearColor::Default = { 0, 0, 0, 0 };
const ClearStencil::Type ClearStencil::Default = 0;
const StencilMask::Type StencilMask::Default = ~0u;
const DepthMask::Type DepthMask::Default = GL_TRUE;
const ColorMask::Type ColorMask::Default = { false, false, false, false };
const StencilFunc::Type StencilFunc::Default = { GL_ALWAYS, 0, ~0u };
const StencilTest::Type StencilTest::Default = false;
const DepthRange::Type DepthRange::Default = { 0, 1 };
const DepthTest::Type DepthTest::Default = false;
const Blend::Type Blend::Default = false;
}
}

View File

@@ -0,0 +1,149 @@
#ifndef MBGL_RENDERER_GL_CONFIG
#define MBGL_RENDERER_GL_CONFIG
#include <cstdint>
#include <tuple>
#include <array>
#include <mbgl/platform/gl.hpp>
namespace mbgl {
namespace gl {
template <typename T>
class Value {
public:
inline void operator=(const typename T::Type& value) {
if (current != value) {
current = value;
MBGL_CHECK_ERROR(T::Set(current));
}
}
private:
typename T::Type current = T::Default;
};
struct ClearDepth {
using Type = GLfloat;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearDepth(value));
}
};
struct ClearColor {
struct Type { float r, g, b, a; };
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearColor(value.r, value.g, value.b, value.a));
}
};
inline bool operator!=(const ClearColor::Type& a, const ClearColor::Type& b) {
return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a;
}
struct ClearStencil {
using Type = GLint;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glClearStencil(value));
}
};
struct StencilMask {
using Type = GLuint;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glStencilMask(value));
}
};
struct DepthMask {
using Type = GLboolean;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glDepthMask(value));
}
};
struct ColorMask {
struct Type { bool r, g, b, a; };
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glColorMask(value.r, value.g, value.b, value.a));
}
};
inline bool operator!=(const ColorMask::Type& a, const ColorMask::Type& b) {
return a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a;
}
struct StencilFunc {
struct Type { GLenum func; GLint ref; GLuint mask; };
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glStencilFunc(value.func, value.ref, value.mask));
}
};
inline bool operator!=(const StencilFunc::Type& a, const StencilFunc::Type& b) {
return a.func != b.func || a.ref != b.ref || a.mask != b.mask;
}
struct StencilTest {
using Type = bool;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_STENCIL_TEST) : glDisable(GL_STENCIL_TEST));
}
};
struct DepthRange {
struct Type { GLfloat near, far; };
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(glDepthRange(value.near, value.far));
}
};
inline bool operator!=(const DepthRange::Type& a, const DepthRange::Type& b) {
return a.near != b.near || a.far != b.far;
}
struct DepthTest {
using Type = bool;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST));
}
};
struct Blend {
using Type = bool;
static const Type Default;
inline static void Set(const Type& value) {
MBGL_CHECK_ERROR(value ? glEnable(GL_BLEND) : glDisable(GL_BLEND));
}
};
class Config {
public:
Value<StencilFunc> stencilFunc;
Value<StencilMask> stencilMask;
Value<StencilTest> stencilTest;
Value<DepthRange> depthRange;
Value<DepthMask> depthMask;
Value<DepthTest> depthTest;
Value<Blend> blend;
Value<ColorMask> colorMask;
Value<ClearDepth> clearDepth;
Value<ClearColor> clearColor;
Value<ClearStencil> clearStencil;
};
}
}
#endif

View File

@@ -88,16 +88,15 @@ void Painter::setup() {
// We are blending new pixels on top of old pixels. Since we have depth testing
// and are drawing opaque fragments first front-to-back, then translucent
// fragments back-to-front, this shades the fewest fragments possible.
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
config.blend = true;
MBGL_CHECK_ERROR(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
// Set clear values
MBGL_CHECK_ERROR(glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
MBGL_CHECK_ERROR(glClearDepth(1.0f));
MBGL_CHECK_ERROR(glClearStencil(0x0));
config.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
config.clearDepth = 1.0f;
config.clearStencil = 0x0;
// Stencil test
MBGL_CHECK_ERROR(glEnable(GL_STENCIL_TEST));
MBGL_CHECK_ERROR(glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE));
// Depth test
@@ -145,21 +144,6 @@ void Painter::lineWidth(float line_width) {
}
}
void Painter::depthMask(bool value) {
if (gl_depthMask != value) {
MBGL_CHECK_ERROR(glDepthMask(value ? GL_TRUE : GL_FALSE));
gl_depthMask = value;
}
}
void Painter::depthRange(const float near, const float far) {
if (gl_depthRange[0] != near || gl_depthRange[1] != far) {
MBGL_CHECK_ERROR(glDepthRange(near, far));
gl_depthRange = {{ near, far }};
}
}
void Painter::changeMatrix() {
// Initialize projection matrix
matrix::ortho(projMatrix, 0, state.getWidth(), state.getHeight(), 0, 0, 1);
@@ -177,24 +161,25 @@ void Painter::changeMatrix() {
void Painter::clear() {
gl::group group("clear");
MBGL_CHECK_ERROR(glStencilMask(0xFF));
depthMask(true);
MBGL_CHECK_ERROR(glClearColor(0, 0, 0, 0));
config.stencilTest = true;
config.stencilMask = 0xFF;
config.depthTest = false;
config.depthMask = GL_TRUE;
config.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
}
void Painter::setOpaque() {
if (pass != RenderPass::Opaque) {
pass = RenderPass::Opaque;
MBGL_CHECK_ERROR(glDisable(GL_BLEND));
config.blend = false;
}
}
void Painter::setTranslucent() {
if (pass != RenderPass::Translucent) {
pass = RenderPass::Translucent;
MBGL_CHECK_ERROR(glEnable(GL_BLEND));
config.blend = true;
}
}
@@ -205,7 +190,7 @@ void Painter::setStrata(float value) {
void Painter::prepareTile(const Tile& tile) {
const GLint ref = (GLint)tile.clip.reference.to_ulong();
const GLuint mask = (GLuint)tile.clip.mask.to_ulong();
MBGL_CHECK_ERROR(glStencilFunc(GL_EQUAL, ref, mask));
config.stencilFunc = { GL_EQUAL, ref, mask };
}
void Painter::render(const Style& style, TransformState state_, TimePoint time) {
@@ -504,10 +489,10 @@ void Painter::renderBackground(const StyleLayer &layer_desc) {
backgroundArray.bind(*plainShader, backgroundBuffer, BUFFER_OFFSET(0));
}
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));
depthRange(strata + strata_epsilon, 1.0f);
config.stencilTest = false;
config.depthTest = true;
config.depthRange = { strata + strata_epsilon, 1.0f };
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
MBGL_CHECK_ERROR(glEnable(GL_STENCIL_TEST));
}
mat4 Painter::translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const TileID &id, TranslateAnchorType anchor) {

View File

@@ -9,6 +9,8 @@
#include <mbgl/geometry/vao.hpp>
#include <mbgl/geometry/static_vertex_buffer.hpp>
#include <mbgl/renderer/gl_config.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/platform/gl.hpp>
@@ -162,8 +164,6 @@ private:
public:
void useProgram(uint32_t program);
void lineWidth(float lineWidth);
void depthMask(bool value);
void depthRange(float near, float far);
public:
mat4 projMatrix;
@@ -190,11 +190,11 @@ private:
bool debug = false;
int indent = 0;
gl::Config config;
uint32_t gl_program = 0;
float gl_lineWidth = 0;
bool gl_depthMask = true;
std::array<uint16_t, 2> gl_viewport = {{ 0, 0 }};
std::array<float, 2> gl_depthRange = {{ 0, 1 }};
float strata = 0;
RenderPass pass = RenderPass::Opaque;
const float strata_epsilon = 1.0f / (1 << 16);

View File

@@ -13,10 +13,11 @@ void Painter::drawClippingMasks(const std::set<Source*>& sources) {
gl::group group("clipping masks");
useProgram(plainShader->program);
MBGL_CHECK_ERROR(glDisable(GL_DEPTH_TEST));
depthMask(false);
MBGL_CHECK_ERROR(glColorMask(false, false, false, false));
depthRange(1.0f, 1.0f);
config.stencilTest = true;
config.depthTest = true;
config.depthMask = GL_FALSE;
config.colorMask = { false, false, false, false };
config.depthRange = { 1.0f, 1.0f };
coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0));
@@ -24,10 +25,10 @@ void Painter::drawClippingMasks(const std::set<Source*>& sources) {
source->drawClippingMasks(*this);
}
MBGL_CHECK_ERROR(glEnable(GL_DEPTH_TEST));
MBGL_CHECK_ERROR(glColorMask(true, true, true, true));
depthMask(true);
MBGL_CHECK_ERROR(glStencilMask(0x0));
config.depthTest = true;
config.colorMask = { true, true, true, true };
config.depthMask = GL_TRUE;
config.stencilMask = 0x0;
}
void Painter::drawClippingMask(const mat4& matrix, const ClipID &clip) {
@@ -35,8 +36,7 @@ void Painter::drawClippingMask(const mat4& matrix, const ClipID &clip) {
const GLint ref = (GLint)(clip.reference.to_ulong());
const GLuint mask = (GLuint)(clip.mask.to_ulong());
MBGL_CHECK_ERROR(glStencilFunc(GL_ALWAYS, ref, mask));
MBGL_CHECK_ERROR(glStencilMask(mask));
config.stencilFunc = { GL_ALWAYS, ref, mask };
config.stencilMask = mask;
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
}

View File

@@ -24,7 +24,7 @@ void Painter::renderTileDebug(const Tile& tile) {
void Painter::renderDebugText(DebugBucket& bucket, const mat4 &matrix) {
gl::group group("debug text");
MBGL_CHECK_ERROR(glDisable(GL_DEPTH_TEST));
config.depthTest = false;
useProgram(plainShader->program);
plainShader->u_matrix = matrix;
@@ -45,7 +45,7 @@ void Painter::renderDebugText(DebugBucket& bucket, const mat4 &matrix) {
lineWidth(2.0f * state.getPixelRatio());
bucket.drawLines(*plainShader);
MBGL_CHECK_ERROR(glEnable(GL_DEPTH_TEST));
config.depthTest = true;
}
void Painter::renderDebugFrame(const mat4 &matrix) {
@@ -54,7 +54,8 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
// Disable depth test and don't count this towards the depth buffer,
// but *don't* disable stencil test, as we want to clip the red tile border
// to the tile viewport.
MBGL_CHECK_ERROR(glDisable(GL_DEPTH_TEST));
config.depthTest = false;
config.stencilTest = true;
useProgram(plainShader->program);
plainShader->u_matrix = matrix;
@@ -64,8 +65,6 @@ void Painter::renderDebugFrame(const mat4 &matrix) {
plainShader->u_color = {{ 1.0f, 0.0f, 0.0f, 1.0f }};
lineWidth(4.0f * state.getPixelRatio());
MBGL_CHECK_ERROR(glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)tileBorderBuffer.index()));
MBGL_CHECK_ERROR(glEnable(GL_DEPTH_TEST));
}
void Painter::renderDebugText(const std::vector<std::string> &strings) {
@@ -75,8 +74,9 @@ void Painter::renderDebugText(const std::vector<std::string> &strings) {
gl::group group("debug text");
MBGL_CHECK_ERROR(glDisable(GL_DEPTH_TEST));
MBGL_CHECK_ERROR(glStencilFunc(GL_ALWAYS, 0xFF, 0xFF));
config.depthTest = false;
config.stencilTest = true;
config.stencilFunc = { GL_ALWAYS, 0xFF, 0xFF };
useProgram(plainShader->program);
plainShader->u_matrix = nativeMatrix;
@@ -103,6 +103,4 @@ void Painter::renderDebugText(const std::vector<std::string> &strings) {
lineWidth(2.0f * state.getPixelRatio());
MBGL_CHECK_ERROR(glDrawArrays(GL_LINES, 0, (GLsizei)debugFontBuffer.index()));
}
MBGL_CHECK_ERROR(glEnable(GL_DEPTH_TEST));
}

View File

@@ -39,6 +39,9 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
bool outline = properties.antialias && !pattern && stroke_color != fill_color;
bool fringeline = properties.antialias && !pattern && stroke_color == fill_color;
config.stencilTest = true;
config.depthTest = true;
// Because we're drawing top-to-bottom, and we update the stencil mask
// befrom, we have to draw the outline first (!)
if (outline && pass == RenderPass::Translucent) {
@@ -53,7 +56,7 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
static_cast<float>(state.getFramebufferWidth()),
static_cast<float>(state.getFramebufferHeight())
}};
depthRange(strata, 1.0f);
config.depthRange = { strata, 1.0f };
bucket.drawVertices(*outlineShader);
}
@@ -92,8 +95,8 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
spriteAtlas.bind(true);
// Draw the actual triangles into the color & stencil buffer.
depthMask(true);
depthRange(strata, 1.0f);
config.depthMask = GL_TRUE;
config.depthRange = { strata, 1.0f };
bucket.drawElements(*patternShader);
}
}
@@ -109,8 +112,8 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
plainShader->u_color = fill_color;
// Draw the actual triangles into the color & stencil buffer.
depthMask(true);
depthRange(strata + strata_epsilon, 1.0f);
config.depthMask = GL_TRUE;
config.depthRange = { strata + strata_epsilon, 1.0f };
bucket.drawElements(*plainShader);
}
}
@@ -130,7 +133,7 @@ void Painter::renderFill(FillBucket& bucket, const StyleLayer &layer_desc, const
static_cast<float>(state.getFramebufferHeight())
}};
depthRange(strata + strata_epsilon + strata_epsilon, 1.0f);
config.depthRange = { strata + strata_epsilon + strata_epsilon, 1.0f };
bucket.drawVertices(*outlineShader);
}
}

View File

@@ -17,7 +17,9 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
// Abort early.
if (pass == RenderPass::Opaque) return;
depthMask(false);
config.stencilTest = true;
config.depthTest = true;
config.depthMask = GL_FALSE;
const auto &properties = layer_desc.getProperties<LineProperties>();
const auto &layout = bucket.layout;
@@ -51,7 +53,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
float ratio = state.getPixelRatio();
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
depthRange(strata, 1.0f);
config.depthRange = { strata, 1.0f };
if (properties.dash_array.from.size()) {
@@ -109,7 +111,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
MBGL_CHECK_ERROR(glActiveTexture(GL_TEXTURE0));
spriteAtlas.bind(true);
MBGL_CHECK_ERROR(glDepthRange(strata + strata_epsilon, 1.0f)); // may or may not matter
config.depthRange = { strata + strata_epsilon, 1.0f }; // may or may not matter
bucket.drawLinePatterns(*linepatternShader);

View File

@@ -23,8 +23,9 @@ void Painter::renderRaster(RasterBucket& bucket, const StyleLayer &layer_desc, c
rasterShader->u_contrast_factor = contrastFactor(properties.contrast);
rasterShader->u_spin_weights = spinWeights(properties.hue_rotate);
depthRange(strata + strata_epsilon, 1.0f);
config.stencilTest = true;
config.depthTest = true;
config.depthRange = { strata + strata_epsilon, 1.0f };
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
}
}

View File

@@ -87,7 +87,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
sdfShader.u_buffer = (haloOffset - styleProperties.halo_width / fontScale) / sdfPx;
depthRange(strata, 1.0f);
config.depthRange = { strata, 1.0f };
(bucket.*drawSDF)(sdfShader);
}
@@ -108,7 +108,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
sdfShader.u_buffer = (256.0f - 64.0f) / 256.0f;
depthRange(strata + strata_epsilon, 1.0f);
config.depthRange = { strata + strata_epsilon, 1.0f };
(bucket.*drawSDF)(sdfShader);
}
}
@@ -122,8 +122,9 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
const auto &properties = layer_desc.getProperties<SymbolProperties>();
const auto &layout = bucket.layout;
MBGL_CHECK_ERROR(glDisable(GL_STENCIL_TEST));
depthMask(false);
config.stencilTest = false;
config.depthTest = true;
config.depthMask = GL_FALSE;
if (bucket.hasIconData()) {
bool sdf = bucket.sdfIcons;
@@ -185,7 +186,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
iconShader->u_fadezoom = state.getNormalizedZoom() * 10;
iconShader->u_opacity = properties.icon.opacity;
depthRange(strata, 1.0f);
config.depthRange = { strata, 1.0f };
bucket.drawIcons(*iconShader);
}
}
@@ -203,6 +204,4 @@ void Painter::renderSymbol(SymbolBucket &bucket, const StyleLayer &layer_desc, c
*sdfGlyphShader,
&SymbolBucket::drawGlyphs);
}
MBGL_CHECK_ERROR(glEnable(GL_STENCIL_TEST));
}