Drawable Renderer (#1570), Add renderable size uniform for fill layer
This commit is contained in:
committed by
Bart Louwers
parent
353d96b5bf
commit
b5abc33c4b
@@ -174,6 +174,8 @@ private:
|
||||
|
||||
struct alignas(16) DrawableUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> world;
|
||||
std::array<float, 2> padding;
|
||||
};
|
||||
static_assert(sizeof(DrawableUBO) % 16 == 0);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (std140) uniform DrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
};
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -14,6 +14,8 @@ struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::OpenGL> {
|
||||
|
||||
layout (std140) uniform DrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
|
||||
@@ -12,8 +12,11 @@ struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlineShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
layout (std140) uniform DrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
};
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
|
||||
@@ -464,7 +464,10 @@ bool Context::setupDraw(const PaintParameters& parameters, const gfx::Drawable&
|
||||
program = value::Program::Default;
|
||||
}
|
||||
|
||||
setDepthMode(parameters.depthModeForSublayer(0, drawable.getDepthType()));
|
||||
setDepthMode(parameters.depthModeForSublayer(drawable.getSubLayerIndex(), drawable.getDepthType()));
|
||||
|
||||
// force disable depth test for debugging
|
||||
//setDepthMode({gfx::DepthFunctionType::Always, gfx::DepthMaskType::ReadOnly, {0,1}});
|
||||
|
||||
if (auto tileID = drawable.getTileID()) {
|
||||
// Doesn't work until the clipping masks are generated
|
||||
@@ -477,13 +480,10 @@ bool Context::setupDraw(const PaintParameters& parameters, const gfx::Drawable&
|
||||
setColorMode(gfx::ColorMode::alphaBlended());
|
||||
setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
|
||||
// uniformStates.bind(uniformValues);
|
||||
// textureStates.bind(context, textureBindings);
|
||||
|
||||
auto& drawableGL = static_cast<const DrawableGL&>(drawable);
|
||||
auto& vao = drawableGL.getVertexArray();
|
||||
if (vao.isValid()) {
|
||||
bindVertexArray = vao.getID(); // glBindVertexArray
|
||||
bindVertexArray = vao.getID();
|
||||
return true;
|
||||
} else {
|
||||
bindVertexArray = value::BindVertexArray::Default;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <mbgl/gl/layer_group_gl.hpp>
|
||||
|
||||
#include <mbgl/gfx/render_pass.hpp>
|
||||
#include <mbgl/gfx/renderable.hpp>
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/gl/drawable_gl.hpp>
|
||||
#include <mbgl/gl/upload_pass.hpp>
|
||||
#include <mbgl/gl/vertex_array.hpp>
|
||||
@@ -87,8 +89,11 @@ void TileLayerGroupGL::render(RenderOrchestrator&, PaintParameters& parameters)
|
||||
matrix = tileMat;
|
||||
}
|
||||
|
||||
const auto renderableSize = parameters.backend.getDefaultRenderable().getSize();
|
||||
|
||||
gfx::DrawableUBO drawableUBO;
|
||||
drawableUBO.matrix = util::cast<float>(matrix);
|
||||
drawableUBO.world = {(float)renderableSize.width, (float)renderableSize.height};
|
||||
auto uniformBuffer = context.createUniformBuffer(&drawableUBO, sizeof(drawableUBO));
|
||||
drawable.mutableUniformBuffers().addOrReplace("DrawableUBO", uniformBuffer);
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
for (auto& drawable : fillBuilder->clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
|
||||
tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
//tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user