[core] move supportsHalfFloatTextures to gfx::Context

This commit is contained in:
Konstantin Käfer
2019-03-20 16:24:36 +01:00
parent 394e2aa717
commit 5270b2ffbd
3 changed files with 6 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ public:
const ContextType backend;
static constexpr const uint32_t minimumRequiredVertexBindingCount = 8;
const uint32_t maximumVertexBindingCount;
bool supportsHalfFloatTextures = false;
public:
Context(Context&&) = delete;

View File

@@ -166,8 +166,6 @@ public:
State<value::PixelTransferStencil> pixelTransferStencil;
#endif // MBGL_USE_GLES2
bool supportsHalfFloatTextures = false;
private:
State<value::StencilFunc> stencilFunc;
State<value::StencilMask> stencilMask;

View File

@@ -52,15 +52,12 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
return;
}
// TODO: remove cast
gl::Context& glContext = static_cast<gl::Context&>(parameters.context);
if (parameters.pass == RenderPass::Pass3D) {
const auto& viewportSize = parameters.staticData.backendSize;
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
if (!renderTexture || renderTexture->getSize() != size) {
if (glContext.supportsHalfFloatTextures) {
if (parameters.context.supportsHalfFloatTextures) {
renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::HalfFloat);
try {
@@ -68,11 +65,11 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
} catch (const std::runtime_error& ex) {
// can't render to a half-float texture; falling back to unsigned byte one
renderTexture = nullopt;
glContext.supportsHalfFloatTextures = false;
parameters.context.supportsHalfFloatTextures = false;
}
}
if (!glContext.supportsHalfFloatTextures || !renderTexture) {
if (!parameters.context.supportsHalfFloatTextures || !renderTexture) {
renderTexture = OffscreenTexture(parameters.context, size, gfx::TextureChannelDataType::UnsignedByte);
renderTexture->bind();
}
@@ -85,7 +82,8 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
colorRampTexture = parameters.context.createTexture(colorRamp, gfx::TextureChannelDataType::UnsignedByte);
}
glContext.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
// TODO: remove cast
static_cast<gl::Context&>(parameters.context).clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
for (const RenderTile& tile : renderTiles) {
auto bucket_ = tile.tile.getBucket<HeatmapBucket>(*baseImpl);