[core] Adjust mapbox-gl-native for the updated debug shader semantics
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class DebugProgram : public Program<
|
||||
DebugProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
TypeList<
|
||||
attributes::pos>,
|
||||
TypeList<
|
||||
uniforms::matrix,
|
||||
uniforms::color>,
|
||||
TypeList<>,
|
||||
style::Properties<>>
|
||||
{
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, overlay_scale);
|
||||
}
|
||||
class DebugProgram : public Program<DebugProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
TypeList<attributes::pos>,
|
||||
TypeList<uniforms::matrix, uniforms::color, uniforms::overlay_scale>,
|
||||
TypeList<textures::overlay>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ MBGL_DEFINE_TEXTURE(image1);
|
||||
MBGL_DEFINE_TEXTURE(color_ramp);
|
||||
MBGL_DEFINE_TEXTURE(texture);
|
||||
MBGL_DEFINE_TEXTURE(texture_icon);
|
||||
MBGL_DEFINE_TEXTURE(overlay);
|
||||
|
||||
} // namespace textures
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -76,6 +76,11 @@ void DebugBucket::upload(gfx::UploadPass& uploadPass) {
|
||||
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
|
||||
indexBuffer = uploadPass.createIndexBuffer(std::move(indices));
|
||||
}
|
||||
if (!texture) {
|
||||
std::array<uint8_t, 4> data{{0, 0, 0, 0}};
|
||||
static const PremultipliedImage emptyImage{Size(1, 1), data.data(), data.size()};
|
||||
texture = uploadPass.createTexture(emptyImage);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
SegmentVector<DebugAttributes> tileBorderSegments;
|
||||
optional<gfx::VertexBuffer<DebugLayoutVertex>> vertexBuffer;
|
||||
optional<gfx::IndexBuffer> indexBuffer;
|
||||
optional<gfx::Texture> texture;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -155,12 +155,13 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
program.computeAllUniformValues(DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::white())},
|
||||
uniforms::color::Value(Color::white()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
parameters.state.getZoom()),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{},
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text-outline");
|
||||
|
||||
program.draw(
|
||||
@@ -174,12 +175,13 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
program.computeAllUniformValues(DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::black())},
|
||||
uniforms::color::Value(Color::black()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
parameters.state.getZoom()),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{},
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text");
|
||||
}
|
||||
|
||||
@@ -199,13 +201,14 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
*parameters.staticData.tileBorderIndexBuffer,
|
||||
debugBucket->tileBorderSegments,
|
||||
program.computeAllUniformValues(DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red())},
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
parameters.state.getZoom()),
|
||||
program.computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{},
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"border");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,19 @@ void ImageSourceRenderData::upload(gfx::UploadPass& uploadPass) const {
|
||||
if (bucket && bucket->needsUpload()) {
|
||||
bucket->upload(uploadPass);
|
||||
}
|
||||
|
||||
if (!debugTexture) {
|
||||
std::array<uint8_t, 4> data{{0, 0, 0, 0}};
|
||||
static const PremultipliedImage emptyImage{Size(1, 1), data.data(), data.size()};
|
||||
debugTexture = uploadPass.createTexture(emptyImage);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageSourceRenderData::render(PaintParameters& parameters) const {
|
||||
if (!bucket || !(parameters.debugOptions & MapDebugOptions::TileBorders)) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(debugTexture);
|
||||
static const style::Properties<>::PossiblyEvaluated properties {};
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
@@ -47,13 +53,14 @@ void ImageSourceRenderData::render(PaintParameters& parameters) const {
|
||||
parameters.staticData.tileBorderSegments(),
|
||||
programInstance.computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red())},
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
parameters.state.getZoom()),
|
||||
programInstance.computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{},
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugTexture->getResource()}},
|
||||
"image");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ private:
|
||||
void render(PaintParameters&) const override;
|
||||
bool hasRenderPass(RenderPass) const override { return false; }
|
||||
const std::string& getName() const override { return name; }
|
||||
|
||||
std::string name;
|
||||
mutable optional<gfx::Texture> debugTexture;
|
||||
};
|
||||
|
||||
class RenderImageSource final : public RenderSource {
|
||||
|
||||
@@ -284,7 +284,7 @@ void CollisionIndex::insertFeature(const CollisionFeature& feature, const std::v
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (!projectedBoxes.empty()) {
|
||||
assert(projectedBoxes.size() == 1);
|
||||
auto& box = projectedBoxes[0];
|
||||
assert(box.isBox());
|
||||
|
||||
Reference in New Issue
Block a user