only set changed glDepthRange values

This commit is contained in:
Konstantin Käfer
2014-08-13 17:46:15 +02:00
parent 6ed3d67b62
commit bfd1281285
8 changed files with 21 additions and 11 deletions

View File

@@ -130,6 +130,7 @@ public:
void useProgram(uint32_t program);
void lineWidth(float lineWidth);
void depthMask(bool value);
void depthRange(float near, float far);
public:
mat4 vtxMatrix;
@@ -156,6 +157,7 @@ private:
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

@@ -118,6 +118,14 @@ void Painter::depthMask(bool value) {
}
}
void Painter::depthRange(const float near, const float far) {
if (gl_depthRange[0] != near || gl_depthRange[1] != far) {
glDepthRange(near, far);
gl_depthRange = {{ near, far }};
}
}
void Painter::changeMatrix() {
// Initialize projection matrix
matrix::ortho(projMatrix, 0, map.getState().getWidth(), map.getState().getHeight(), 0, 0, 1);

View File

@@ -13,7 +13,7 @@ void Painter::drawClippingMasks(const std::set<std::shared_ptr<StyleSource>> &so
glDisable(GL_DEPTH_TEST);
depthMask(false);
glColorMask(false, false, false, false);
glDepthRange(1.0f, 1.0f);
depthRange(1.0f, 1.0f);
glStencilMask(0xFF);
coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0));

View File

@@ -50,7 +50,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
static_cast<float>(map.getState().getFramebufferWidth()),
static_cast<float>(map.getState().getFramebufferHeight())
}});
glDepthRange(strata, 1.0f);
depthRange(strata, 1.0f);
bucket.drawVertices(*outlineShader);
} else if (fringeline) {
// // We're only drawing to the first seven bits (== support a maximum of
@@ -109,7 +109,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
spriteAtlas.bind(true);
// Draw the actual triangles into the color & stencil buffer.
glDepthRange(strata + strata_epsilon, 1.0f);
depthRange(strata + strata_epsilon, 1.0f);
bucket.drawElements(*patternShader);
} else {
// Only draw the fill when it's either opaque and we're drawing opaque
@@ -121,7 +121,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
plainShader->setColor(fill_color);
// Draw the actual triangles into the color & stencil buffer.
glDepthRange(strata + strata_epsilon, 1.0f);
depthRange(strata + strata_epsilon, 1.0f);
bucket.drawElements(*plainShader);
}
}
@@ -141,7 +141,7 @@ void Painter::renderFill(FillBucket& bucket, const FillProperties& properties, c
static_cast<float>(map.getState().getFramebufferHeight())
}});
glDepthRange(strata + strata_epsilon, 1.0f);
depthRange(strata + strata_epsilon, 1.0f);
bucket.drawVertices(*outlineShader);
}
}

View File

@@ -33,7 +33,7 @@ void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_d
const mat4 &vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
glDepthRange(strata, 1.0f);
depthRange(strata, 1.0f);
// We're only drawing end caps + round line joins if the line is > 2px. Otherwise, they aren't visible anyway.
if (bucket.hasPoints() && outset > 1.0f) {

View File

@@ -28,7 +28,7 @@ void Painter::renderPrerenderedTexture(RasterBucket &bucket, const mat4 &matrix,
rasterShader->setMatrix(matrix);
rasterShader->setOpacity(1);
glDepthRange(strata, 1.0f);
depthRange(strata, 1.0f);
glActiveTexture(GL_TEXTURE0);
rasterShader->setImage(0);

View File

@@ -71,7 +71,7 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
rasterShader->setContrast(properties.contrast);
rasterShader->setSpin(spinWeights(properties.hue_rotate));
glDepthRange(strata + strata_epsilon, 1.0f);
depthRange(strata + strata_epsilon, 1.0f);
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);

View File

@@ -143,7 +143,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> lay
textShader->setColor(properties.text.halo_color);
}
textShader->setBuffer(haloWidth);
glDepthRange(strata, 1.0f);
depthRange(strata, 1.0f);
bucket.drawGlyphs(*textShader);
}
@@ -161,7 +161,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> lay
textShader->setColor(properties.text.color);
}
textShader->setBuffer((256.0f - 64.0f) / 256.0f);
glDepthRange(strata + strata_epsilon, 1.0f);
depthRange(strata + strata_epsilon, 1.0f);
bucket.drawGlyphs(*textShader);
}
}
@@ -210,7 +210,7 @@ void Painter::renderSymbol(SymbolBucket &bucket, std::shared_ptr<StyleLayer> lay
iconShader->setFadeZoom(map.getState().getNormalizedZoom() * 10);
iconShader->setOpacity(properties.icon.opacity);
glDepthRange(strata, 1.0f);
depthRange(strata, 1.0f);
bucket.drawIcons(*iconShader);
}
}