From c8cfdb1ced822711e772dfcc8f708b1a7a68b5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 15 Mar 2019 20:31:12 +0100 Subject: Merge pull request #14126 from mapbox/gfx-refactor-4 Graphics refactor #4 --- src/mbgl/programs/collision_box_program.hpp | 82 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 42 deletions(-) (limited to 'src/mbgl/programs/collision_box_program.hpp') diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp index cd7f0bfd68..7b81752a94 100644 --- a/src/mbgl/programs/collision_box_program.hpp +++ b/src/mbgl/programs/collision_box_program.hpp @@ -3,8 +3,6 @@ #include #include #include -#include -#include #include #include @@ -21,8 +19,8 @@ using CollisionBoxLayoutAttributes = TypeList< using CollisionBoxDynamicAttributes = TypeList; class CollisionBoxProgram : public Program< - shaders::collision_box, - gfx::Line, + CollisionBoxProgram, + gfx::PrimitiveType::Line, TypeListConcat, TypeList< uniforms::u_matrix, @@ -62,48 +60,48 @@ public: } template - void draw(gl::Context& context, - DrawMode drawMode, - gfx::DepthMode depthMode, - gfx::StencilMode stencilMode, - gfx::ColorMode colorMode, - gfx::CullFaceMode cullFaceMode, - const UniformValues& uniformValues, + void draw(gfx::Context& context, + const DrawMode& drawMode, + const gfx::DepthMode& depthMode, + const gfx::StencilMode& stencilMode, + const gfx::ColorMode& colorMode, + const gfx::CullFaceMode& cullFaceMode, + const LayoutUniformValues& layoutUniformValues, const gfx::VertexBuffer>& layoutVertexBuffer, const gfx::VertexBuffer>& dynamicVertexBuffer, const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, + const SegmentVector& segments, const Binders& paintPropertyBinders, const typename PaintProperties::PossiblyEvaluated& currentProperties, const TextureBindings& textureBindings, float currentZoom, const std::string& layerID) { - typename AllUniforms::Values allUniformValues = uniformValues + UniformValues uniformValues = layoutUniformValues .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - typename Attributes::Bindings allAttributeBindings = gl::Attributes::bindings(layoutVertexBuffer) - .concat(gl::Attributes::bindings(dynamicVertexBuffer)) + AttributeBindings allAttributeBindings = gfx::AttributeBindings(layoutVertexBuffer) + .concat(gfx::AttributeBindings(dynamicVertexBuffer)) .concat(paintPropertyBinders.attributeBindings(currentProperties)); assert(layoutVertexBuffer.elements == dynamicVertexBuffer.elements); for (auto& segment : segments) { - auto vertexArrayIt = segment.vertexArrays.find(layerID); + auto drawScopeIt = segment.drawScopes.find(layerID); - if (vertexArrayIt == segment.vertexArrays.end()) { - vertexArrayIt = segment.vertexArrays.emplace(layerID, context.createVertexArray()).first; + if (drawScopeIt == segment.drawScopes.end()) { + drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first; } - program.draw( + program->draw( context, std::move(drawMode), std::move(depthMode), std::move(stencilMode), std::move(colorMode), std::move(cullFaceMode), - allUniformValues, - vertexArrayIt->second, - Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset), + uniformValues, + drawScopeIt->second, + allAttributeBindings.offset(segment.vertexOffset), textureBindings, indexBuffer, segment.indexOffset, @@ -114,8 +112,8 @@ public: class CollisionCircleProgram : public Program< - shaders::collision_circle, - gfx::Triangle, + CollisionCircleProgram, + gfx::PrimitiveType::Triangle, TypeListConcat, TypeList< uniforms::u_matrix, @@ -150,46 +148,46 @@ public: } template - void draw(gl::Context& context, - DrawMode drawMode, - gfx::DepthMode depthMode, - gfx::StencilMode stencilMode, - gfx::ColorMode colorMode, - gfx::CullFaceMode cullFaceMode, - const UniformValues& uniformValues, + void draw(gfx::Context& context, + const DrawMode& drawMode, + const gfx::DepthMode& depthMode, + const gfx::StencilMode& stencilMode, + const gfx::ColorMode& colorMode, + const gfx::CullFaceMode& cullFaceMode, + const LayoutUniformValues& layoutUniformValues, const gfx::VertexBuffer>& layoutVertexBuffer, const gfx::VertexBuffer>& dynamicVertexBuffer, const gfx::IndexBuffer& indexBuffer, - const SegmentVector& segments, + const SegmentVector& segments, const Binders& paintPropertyBinders, const typename PaintProperties::PossiblyEvaluated& currentProperties, const TextureBindings& textureBindings, float currentZoom, const std::string& layerID) { - typename AllUniforms::Values allUniformValues = uniformValues + UniformValues uniformValues = layoutUniformValues .concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties)); - typename Attributes::Bindings allAttributeBindings = gl::Attributes::bindings(layoutVertexBuffer) - .concat(gl::Attributes::bindings(dynamicVertexBuffer)) + AttributeBindings allAttributeBindings = gfx::AttributeBindings(layoutVertexBuffer) + .concat(gfx::AttributeBindings(dynamicVertexBuffer)) .concat(paintPropertyBinders.attributeBindings(currentProperties)); for (auto& segment : segments) { - auto vertexArrayIt = segment.vertexArrays.find(layerID); + auto drawScopeIt = segment.drawScopes.find(layerID); - if (vertexArrayIt == segment.vertexArrays.end()) { - vertexArrayIt = segment.vertexArrays.emplace(layerID, context.createVertexArray()).first; + if (drawScopeIt == segment.drawScopes.end()) { + drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first; } - program.draw( + program->draw( context, std::move(drawMode), std::move(depthMode), std::move(stencilMode), std::move(colorMode), std::move(cullFaceMode), - allUniformValues, - vertexArrayIt->second, - Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset), + uniformValues, + drawScopeIt->second, + allAttributeBindings.offset(segment.vertexOffset), textureBindings, indexBuffer, segment.indexOffset, -- cgit v1.2.1