Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2018-09-06 10:57:09 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2018-09-25 12:33:08 +0300
commitc2e13ae8d6d39ef659dad657828bde165e31ea78 (patch)
treecf8501d7c186162c6c28225e0b9657aeec59da9f
parentd1074729e0d0c63ab887efb866903bc99181f919 (diff)
[drape][metal] Added params setting up.
-rw-r--r--drape/mesh_object.cpp5
-rw-r--r--drape/mesh_object.hpp11
-rw-r--r--drape/metal/metal_mesh_object_impl.mm11
-rw-r--r--drape/metal/render_state_metal.mm20
-rw-r--r--drape/render_state.cpp1
-rw-r--r--drape/texture_manager.cpp4
-rw-r--r--drape_frontend/drape_api_renderer.cpp4
-rw-r--r--drape_frontend/gps_track_renderer.cpp2
-rw-r--r--drape_frontend/gui/shape.cpp2
-rwxr-xr-xdrape_frontend/render_group.cpp8
-rw-r--r--drape_frontend/render_node.hpp2
-rw-r--r--drape_frontend/route_renderer.cpp8
-rw-r--r--drape_frontend/traffic_renderer.cpp6
-rw-r--r--drape_frontend/transit_scheme_renderer.cpp12
-rw-r--r--iphone/Maps/Classes/MapViewController.mm4
-rw-r--r--shaders/gl_program_params.cpp60
-rw-r--r--shaders/gl_program_params.hpp30
-rw-r--r--shaders/metal_program_params.hpp30
-rw-r--r--shaders/metal_program_params.mm78
-rw-r--r--shaders/metal_program_pool.mm8
-rw-r--r--shaders/program_manager.hpp2
-rw-r--r--shaders/program_params.hpp31
22 files changed, 243 insertions, 96 deletions
diff --git a/drape/mesh_object.cpp b/drape/mesh_object.cpp
index edd92a7266..fa76639193 100644
--- a/drape/mesh_object.cpp
+++ b/drape/mesh_object.cpp
@@ -6,7 +6,6 @@
#include "drape/gl_functions.hpp"
#include "drape/glsl_func.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/gpu_program.hpp"
#include "drape/texture_manager.hpp"
namespace
@@ -126,7 +125,7 @@ public:
}
}
- void Unbind(ref_ptr<dp::GpuProgram> program) override
+ void Unbind() override
{
if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject))
GLFunctions::glBindVertexArray(0);
@@ -261,7 +260,7 @@ void MeshObject::Unbind(ref_ptr<dp::GpuProgram> program)
program->Unbind();
CHECK(m_impl != nullptr, ());
- m_impl->Unbind(program);
+ m_impl->Unbind();
}
// static
diff --git a/drape/mesh_object.hpp b/drape/mesh_object.hpp
index d8660ed81f..06e1d1c65c 100644
--- a/drape/mesh_object.hpp
+++ b/drape/mesh_object.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "drape/graphics_context.hpp"
-#include "drape/render_state.hpp"
#include "drape/pointers.hpp"
+#include "drape/render_state.hpp"
#include <functional>
#include <string>
@@ -13,12 +13,13 @@ namespace dp
class GpuProgram;
class GraphicsContext;
class MeshObjectImpl;
+
namespace metal
{
class MetalMeshObjectImpl;
} // namespace metal
-// This class implement simple mesh object which does not use an index buffer.
+// This class implements a simple mesh object which does not use an index buffer.
// Use this class only for simple geometry.
class MeshObject
{
@@ -50,7 +51,7 @@ public:
Bind(context, program);
ApplyState(context, program, state);
- paramsSetter->Apply(program, params);
+ paramsSetter->Apply(context, program, params);
DrawPrimitives(context);
@@ -98,7 +99,7 @@ private:
};
void InitForOpenGL();
- // Definition of this method is in separate .mm-file.
+ // Definition of this method is in a .mm-file.
void InitForMetal();
void Bind(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program);
@@ -120,7 +121,7 @@ public:
virtual void Reset() = 0;
virtual void UpdateBuffer(uint32_t bufferInd) = 0;
virtual void Bind(ref_ptr<dp::GpuProgram> program) = 0;
- virtual void Unbind(ref_ptr<dp::GpuProgram> program) = 0;
+ virtual void Unbind() = 0;
virtual void DrawPrimitives(ref_ptr<dp::GraphicsContext> context, uint32_t verticesCount) = 0;
};
} // namespace dp
diff --git a/drape/metal/metal_mesh_object_impl.mm b/drape/metal/metal_mesh_object_impl.mm
index 0a42af2e9a..f1f8645795 100644
--- a/drape/metal/metal_mesh_object_impl.mm
+++ b/drape/metal/metal_mesh_object_impl.mm
@@ -80,14 +80,17 @@ public:
void Bind(ref_ptr<dp::GpuProgram> program) override {}
- void Unbind(ref_ptr<dp::GpuProgram> program) override {}
+ void Unbind() override {}
void DrawPrimitives(ref_ptr<dp::GraphicsContext> context, uint32_t verticesCount) override
{
ref_ptr<dp::metal::MetalBaseContext> metalContext = context;
- [metalContext->GetCommandEncoder() drawPrimitives:GetPrimitiveType(m_mesh->m_drawPrimitive)
- vertexStart:0
- vertexCount:verticesCount];
+ id<MTLRenderCommandEncoder> encoder = metalContext->GetCommandEncoder();
+ for (size_t i = 0; i < m_geometryBuffers.size(); i++)
+ [encoder setVertexBuffer:m_geometryBuffers[i] offset:0 atIndex:i];
+
+ [encoder drawPrimitives:GetPrimitiveType(m_mesh->m_drawPrimitive) vertexStart:0
+ vertexCount:verticesCount];
}
private:
diff --git a/drape/metal/render_state_metal.mm b/drape/metal/render_state_metal.mm
index 1498a09591..c3a2a06ea6 100644
--- a/drape/metal/render_state_metal.mm
+++ b/drape/metal/render_state_metal.mm
@@ -2,6 +2,7 @@
#include "drape/metal/metal_base_context.hpp"
#include "drape/metal/metal_gpu_program.hpp"
+#include "drape/metal/metal_texture.hpp"
#include "drape/pointers.hpp"
#include "drape/render_state.hpp"
@@ -30,6 +31,23 @@ void ApplyTexturesForMetal(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram>
RenderState const & state)
{
ref_ptr<dp::metal::MetalBaseContext> metalContext = context;
- //TODO(@rokuz,@darina)
+ ref_ptr<dp::metal::MetalGpuProgram> p = program;
+ id<MTLRenderCommandEncoder> encoder = metalContext->GetCommandEncoder();
+ for (auto const & texture : state.GetTextures())
+ {
+ auto const & bindingInfo = p->GetTextureBindingInfo(texture.first);
+ ref_ptr<dp::metal::MetalTexture> t = texture.second->GetHardwareTexture();
+ if (t != nullptr && bindingInfo.m_textureBindingIndex >= 0)
+ {
+ [encoder setFragmentTexture:t->GetTexture() atIndex:bindingInfo.m_textureBindingIndex];
+ if (bindingInfo.m_samplerBindingIndex >= 0)
+ {
+ dp::HWTexture::Params const & params = t->GetParams();
+ id<MTLSamplerState> samplerState = metalContext->GetSamplerState(params.m_filter, params.m_wrapSMode,
+ params.m_wrapTMode);
+ [encoder setFragmentSamplerState:samplerState atIndex:bindingInfo.m_samplerBindingIndex];
+ }
+ }
+ }
}
} // namespace dp
diff --git a/drape/render_state.cpp b/drape/render_state.cpp
index a9b409080c..9765486922 100644
--- a/drape/render_state.cpp
+++ b/drape/render_state.cpp
@@ -13,6 +13,7 @@ std::string const kMaskTextureName = "u_maskTex";
} // namespace
#if defined(OMIM_OS_IPHONE)
+// Definitions of these methods are in a .mm-file.
extern void ApplyDepthStencilStateForMetal(ref_ptr<GraphicsContext> context);
extern void ApplyPipelineStateForMetal(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program,
bool blendingEnabled);
diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp
index e8f1f68934..9e77acbd83 100644
--- a/drape/texture_manager.cpp
+++ b/drape/texture_manager.cpp
@@ -522,7 +522,7 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
});
m_stipplePenTexture = make_unique_dp<StipplePenTexture>(StipplePenTextureSize(patterns.size(), m_maxTextureSize),
make_ref(m_textureAllocator));
- LOG(LDEBUG, ("Patterns texture size = ", m_stipplePenTexture->GetWidth(), m_stipplePenTexture->GetHeight()));
+ LOG(LDEBUG, ("Patterns texture size =", m_stipplePenTexture->GetWidth(), m_stipplePenTexture->GetHeight()));
ref_ptr<StipplePenTexture> stipplePenTextureTex = make_ref(m_stipplePenTexture);
for (auto it = patterns.begin(); it != patterns.end(); ++it)
@@ -536,7 +536,7 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
});
m_colorTexture = make_unique_dp<ColorTexture>(ColorTextureSize(colors.size(), m_maxTextureSize),
make_ref(m_textureAllocator));
- LOG(LDEBUG, ("Colors texture size = ", m_colorTexture->GetWidth(), m_colorTexture->GetHeight()));
+ LOG(LDEBUG, ("Colors texture size =", m_colorTexture->GetWidth(), m_colorTexture->GetHeight()));
ref_ptr<ColorTexture> colorTex = make_ref(m_colorTexture);
for (auto it = colors.begin(); it != colors.end(); ++it)
diff --git a/drape_frontend/drape_api_renderer.cpp b/drape_frontend/drape_api_renderer.cpp
index 9688ebf823..a44fc4d9d2 100644
--- a/drape_frontend/drape_api_renderer.cpp
+++ b/drape_frontend/drape_api_renderer.cpp
@@ -64,14 +64,14 @@ void DrapeApiRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu:
params.m_modelView = glsl::make_mat4(mv.m_data);
params.m_contrastGamma = glsl::vec2(glyphParams.m_guiContrast, glyphParams.m_guiGamma);
params.m_isOutlinePass = 0.0f;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
}
else
{
gpu::MapProgramParams params;
frameValues.SetTo(params);
params.m_modelView = glsl::make_mat4(mv.m_data);
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
}
bucket.second->Render(bucket.first.GetDrawAsLine());
diff --git a/drape_frontend/gps_track_renderer.cpp b/drape_frontend/gps_track_renderer.cpp
index dd37e53480..db549a972f 100644
--- a/drape_frontend/gps_track_renderer.cpp
+++ b/drape_frontend/gps_track_renderer.cpp
@@ -309,7 +309,7 @@ void GpsTrackRenderer::RenderTrack(ref_ptr<dp::GraphicsContext> context, ref_ptr
ASSERT_GREATER(m_renderData.size(), 0, ());
dp::RenderState const & state = m_renderData.front()->m_state;
dp::ApplyState(context, program, state);
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
for (size_t i = 0; i < m_renderData.size(); i++)
{
diff --git a/drape_frontend/gui/shape.cpp b/drape_frontend/gui/shape.cpp
index a2e3b06fb2..ef5538abf5 100644
--- a/drape_frontend/gui/shape.cpp
+++ b/drape_frontend/gui/shape.cpp
@@ -110,7 +110,7 @@ void ShapeRenderer::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Pr
auto params = info.m_handle->GetParams();
params.m_projection = projection;
- mng->GetParamsSetter()->Apply(prg, params);
+ mng->GetParamsSetter()->Apply(context, prg, params);
if (info.m_handle->HasDynamicAttributes())
{
diff --git a/drape_frontend/render_group.cpp b/drape_frontend/render_group.cpp
index c7723d1716..7049adb2af 100755
--- a/drape_frontend/render_group.cpp
+++ b/drape_frontend/render_group.cpp
@@ -100,14 +100,14 @@ void RenderGroup::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Prog
m_params.m_contrastGamma = glsl::vec2(glyphParams.m_outlineContrast, glyphParams.m_outlineGamma);
m_params.m_isOutlinePass = 1.0f;
- mng->GetParamsSetter()->Apply(programPtr, m_params);
+ mng->GetParamsSetter()->Apply(context, programPtr, m_params);
for(auto & renderBucket : m_renderBuckets)
renderBucket->Render(m_state.GetDrawAsLine());
m_params.m_contrastGamma = glsl::vec2(glyphParams.m_contrast, glyphParams.m_gamma);
m_params.m_isOutlinePass = 0.0f;
- mng->GetParamsSetter()->Apply(programPtr, m_params);
+ mng->GetParamsSetter()->Apply(context, programPtr, m_params);
for(auto & renderBucket : m_renderBuckets)
renderBucket->Render(m_state.GetDrawAsLine());
}
@@ -115,13 +115,13 @@ void RenderGroup::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Prog
{
m_params.m_contrastGamma = glsl::vec2(glyphParams.m_contrast, glyphParams.m_gamma);
- mng->GetParamsSetter()->Apply(programPtr, m_params);
+ mng->GetParamsSetter()->Apply(context, programPtr, m_params);
for(auto & renderBucket : m_renderBuckets)
renderBucket->Render(m_state.GetDrawAsLine());
}
else
{
- mng->GetParamsSetter()->Apply(programPtr, m_params);
+ mng->GetParamsSetter()->Apply(context, programPtr, m_params);
for(drape_ptr<dp::RenderBucket> & renderBucket : m_renderBuckets)
renderBucket->Render(m_state.GetDrawAsLine());
}
diff --git a/drape_frontend/render_node.hpp b/drape_frontend/render_node.hpp
index 4416e6a1cb..04473d1607 100644
--- a/drape_frontend/render_node.hpp
+++ b/drape_frontend/render_node.hpp
@@ -46,7 +46,7 @@ private:
}
dp::ApplyState(context, prg, m_state);
- mng->GetParamsSetter()->Apply(prg, params);
+ mng->GetParamsSetter()->Apply(context, prg, params);
}
dp::RenderState m_state;
diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp
index 9b0225ba73..b51cd7e856 100644
--- a/drape_frontend/route_renderer.cpp
+++ b/drape_frontend/route_renderer.cpp
@@ -431,7 +431,7 @@ void RouteRenderer::RenderSubroute(ref_ptr<dp::GraphicsContext> context, ref_ptr
gpu::Program::RouteDash : gpu::Program::Route);
prg->Bind();
dp::ApplyState(context, prg, state);
- mng->GetParamsSetter()->Apply(prg, params);
+ mng->GetParamsSetter()->Apply(context, prg, params);
// Render buckets.
for (auto const & bucket : subrouteData->m_renderProperty.m_buckets)
@@ -468,7 +468,7 @@ void RouteRenderer::RenderSubrouteArrows(ref_ptr<dp::GraphicsContext> context, r
ref_ptr<dp::GpuProgram> prg = mng->GetProgram(gpu::Program::RouteArrow);
prg->Bind();
dp::ApplyState(context, prg, state);
- mng->GetParamsSetter()->Apply(prg, params);
+ mng->GetParamsSetter()->Apply(context, prg, params);
for (auto const & bucket : subrouteInfo.m_arrowsData->m_renderProperty.m_buckets)
bucket->Render(state.GetDrawAsLine());
}
@@ -508,7 +508,7 @@ void RouteRenderer::RenderSubrouteMarkers(ref_ptr<dp::GraphicsContext> context,
ref_ptr<dp::GpuProgram> prg = mng->GetProgram(gpu::Program::RouteMarker);
prg->Bind();
dp::ApplyState(context, prg, state);
- mng->GetParamsSetter()->Apply(prg, params);
+ mng->GetParamsSetter()->Apply(context, prg, params);
for (auto const & bucket : subrouteInfo.m_markersData->m_renderProperty.m_buckets)
bucket->Render(state.GetDrawAsLine());
}
@@ -528,7 +528,7 @@ void RouteRenderer::RenderPreviewData(ref_ptr<dp::GraphicsContext> context, ref_
dp::RenderState const & state = m_previewRenderData.front()->m_state;
dp::ApplyState(context, program, state);
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
ASSERT_EQUAL(m_previewRenderData.size(), m_previewHandlesCache.size(), ());
for (size_t i = 0; i < m_previewRenderData.size(); i++)
diff --git a/drape_frontend/traffic_renderer.cpp b/drape_frontend/traffic_renderer.cpp
index 51dc400a02..3be08a3133 100644
--- a/drape_frontend/traffic_renderer.cpp
+++ b/drape_frontend/traffic_renderer.cpp
@@ -158,7 +158,7 @@ void TrafficRenderer::RenderTraffic(ref_ptr<dp::GraphicsContext> context, ref_pt
math::Matrix<float, 4, 4> const mv = renderData.m_tileKey.GetTileBasedModelView(screen);
params.m_modelView = glsl::make_mat4(mv.m_data);
params.m_opacity = opacity;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(true /* draw as line */);
}
else
@@ -182,7 +182,7 @@ void TrafficRenderer::RenderTraffic(ref_ptr<dp::GraphicsContext> context, ref_pt
params.m_darkArrowColor = glsl::vec3(CalculateHalfWidth(screen, RoadClass::Class0, false /* left */),
CalculateHalfWidth(screen, RoadClass::Class1, false /* left */),
CalculateHalfWidth(screen, RoadClass::Class2, false /* left */));
- mng->GetParamsSetter()->Apply(programPtr, params);
+ mng->GetParamsSetter()->Apply(context, programPtr, params);
renderData.m_bucket->Render(false /* draw as line */);
continue;
@@ -234,7 +234,7 @@ void TrafficRenderer::RenderTraffic(ref_ptr<dp::GraphicsContext> context, ref_pt
params.m_outlineColor = glsl::ToVec3(outlineColor);
params.m_trafficParams = glsl::vec4(leftPixelHalfWidth, rightPixelHalfWidth, invLeftPixelLength,
zoomLevel >= minVisibleArrowZoomLevel ? 1.0f : 0.0f);
- mng->GetParamsSetter()->Apply(programPtr, params);
+ mng->GetParamsSetter()->Apply(context, programPtr, params);
renderData.m_bucket->Render(false /* draw as line */);
}
diff --git a/drape_frontend/transit_scheme_renderer.cpp b/drape_frontend/transit_scheme_renderer.cpp
index a97f4be48e..f57676dd9e 100644
--- a/drape_frontend/transit_scheme_renderer.cpp
+++ b/drape_frontend/transit_scheme_renderer.cpp
@@ -191,7 +191,7 @@ void TransitSchemeRenderer::RenderLinesCaps(ref_ptr<dp::GraphicsContext> context
params.m_modelView = glsl::make_mat4(mv.m_data);
params.m_lineHalfWidth = pixelHalfWidth;
params.m_maxRadius = kTransitLineHalfWidth;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
}
@@ -212,7 +212,7 @@ void TransitSchemeRenderer::RenderLines(ref_ptr<dp::GraphicsContext> context, re
math::Matrix<float, 4, 4> mv = screen.GetModelView(renderData.m_pivot, kShapeCoordScalar);
params.m_modelView = glsl::make_mat4(mv.m_data);
params.m_lineHalfWidth = pixelHalfWidth;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
}
@@ -236,7 +236,7 @@ void TransitSchemeRenderer::RenderMarkers(ref_ptr<dp::GraphicsContext> context,
params.m_params = glsl::vec3(static_cast<float>(cos(screen.GetAngle())),
static_cast<float>(sin(screen.GetAngle())),
pixelHalfWidth);
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
}
@@ -259,13 +259,13 @@ void TransitSchemeRenderer::RenderText(ref_ptr<dp::GraphicsContext> context, ref
params.m_modelView = glsl::make_mat4(mv.m_data);
params.m_contrastGamma = glsl::vec2(glyphParams.m_outlineContrast, glyphParams.m_outlineGamma);
params.m_isOutlinePass = 1.0f;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
params.m_contrastGamma = glsl::vec2(glyphParams.m_contrast, glyphParams.m_gamma);
params.m_isOutlinePass = 0.0f;
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
@@ -287,7 +287,7 @@ void TransitSchemeRenderer::RenderStubs(ref_ptr<dp::GraphicsContext> context, re
frameValues.SetTo(params);
math::Matrix<float, 4, 4> mv = screen.GetModelView(renderData.m_pivot, kShapeCoordScalar);
params.m_modelView = glsl::make_mat4(mv.m_data);
- mng->GetParamsSetter()->Apply(program, params);
+ mng->GetParamsSetter()->Apply(context, program, params);
renderData.m_bucket->Render(false /* draw as line */);
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index f657c340d4..e3c374f71d 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -274,7 +274,9 @@ BOOL gIsFirstMyPositionMode = YES;
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
- [(EAGLView *)self.view createDrapeEngine];
+ EAGLView * renderingView = (EAGLView *)self.view;
+ if (!renderingView.drapeEngineCreated)
+ [renderingView createDrapeEngine];
}
- (void)mwm_refreshUI
diff --git a/shaders/gl_program_params.cpp b/shaders/gl_program_params.cpp
index a8109bdfc9..50309f667a 100644
--- a/shaders/gl_program_params.cpp
+++ b/shaders/gl_program_params.cpp
@@ -4,6 +4,7 @@
#include "drape/uniform_value.hpp"
#include "base/assert.hpp"
+#include "base/macros.hpp"
#include <string>
@@ -25,7 +26,8 @@ struct UniformsGuard
~UniformsGuard()
{
auto const uniformsCount = m_program->GetNumericUniformsCount();
- CHECK_EQUAL(m_counter, uniformsCount, ("Not all numeric uniforms are set up", m_program->GetName(), m_paramsName));
+ CHECK_EQUAL(m_counter, uniformsCount, ("Not all numeric uniforms are set up",
+ m_program->GetName(), m_paramsName));
}
ref_ptr<dp::GLGpuProgram> m_program;
@@ -56,7 +58,8 @@ class Parameter
{
public:
template<typename ParamType>
- static void CheckApply(UniformsGuard & guard, std::string const & name, ParamType const & t)
+ static void CheckApply(UniformsGuard & guard, std::string const & name,
+ ParamType const & t)
{
if (Apply<ParamType>(guard.m_program, name, t))
guard.m_counter++;
@@ -64,7 +67,8 @@ public:
private:
template<typename ParamType>
- static bool Apply(ref_ptr<dp::GLGpuProgram> program, std::string const & name, ParamType const & p)
+ static bool Apply(ref_ptr<dp::GLGpuProgram> program, std::string const & name,
+ ParamType const & p)
{
auto const location = program->GetUniformLocation(name);
if (location < 0)
@@ -77,8 +81,11 @@ private:
};
} // namespace
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, MapProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ MapProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -91,8 +98,11 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, MapProgramPar
Parameter::CheckApply(guard, "u_contrastGamma", params.m_contrastGamma);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ RouteProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -108,8 +118,11 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, RouteProgramP
Parameter::CheckApply(guard, "u_opacity", params.m_opacity);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ TrafficProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -123,8 +136,11 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TrafficProgra
Parameter::CheckApply(guard, "u_darkArrowColor", params.m_darkArrowColor);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ TransitProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -135,8 +151,11 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TransitProgra
Parameter::CheckApply(guard, "u_maxRadius", params.m_maxRadius);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ GuiProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -148,8 +167,11 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, GuiProgramPar
Parameter::CheckApply(guard, "u_length", params.m_length);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ ShapesProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_modelView", params.m_modelView);
@@ -162,30 +184,42 @@ void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, ShapesProgram
Parameter::CheckApply(guard, "u_azimut", params.m_azimut);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ Arrow3dProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_transform", params.m_transform);
Parameter::CheckApply(guard, "u_color", params.m_color);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ DebugRectProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_color", params.m_color);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ ScreenQuadProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_opacity", params.m_opacity);
}
-void GLProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params)
+void GLProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ SMAAProgramParams const & params)
{
+ UNUSED_VALUE(context);
UniformsGuard guard(program, params);
Parameter::CheckApply(guard, "u_framebufferMetrics", params.m_framebufferMetrics);
diff --git a/shaders/gl_program_params.hpp b/shaders/gl_program_params.hpp
index 175541f73b..2ce8fe028d 100644
--- a/shaders/gl_program_params.hpp
+++ b/shaders/gl_program_params.hpp
@@ -9,15 +9,25 @@ namespace gpu
class GLProgramParamsSetter : public ProgramParamsSetter
{
public:
- void Apply(ref_ptr<dp::GpuProgram> program, MapProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, MapProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) override;
};
} // namespace gpu
diff --git a/shaders/metal_program_params.hpp b/shaders/metal_program_params.hpp
index f051ead1b3..4134e770b0 100644
--- a/shaders/metal_program_params.hpp
+++ b/shaders/metal_program_params.hpp
@@ -11,16 +11,26 @@ namespace metal
class MetalProgramParamsSetter : public ProgramParamsSetter
{
public:
- void Apply(ref_ptr<dp::GpuProgram> program, MapProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) override;
- void Apply(ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ MapProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ RouteProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ TrafficProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ TransitProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ GuiProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ ShapesProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ Arrow3dProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ DebugRectProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ ScreenQuadProgramParams const & params) override;
+ void Apply(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ SMAAProgramParams const & params) override;
};
} // namespace metal
} // namespace gpu
diff --git a/shaders/metal_program_params.mm b/shaders/metal_program_params.mm
index c39b8b7247..d5da8217d7 100644
--- a/shaders/metal_program_params.mm
+++ b/shaders/metal_program_params.mm
@@ -1,47 +1,105 @@
#include "shaders/metal_program_params.hpp"
+#include "drape/metal/metal_base_context.hpp"
+
namespace gpu
{
namespace metal
{
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, MapProgramParams const & params)
+namespace
+{
+template<typename T>
+void ApplyBytes(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::GpuProgram> program,
+ T const & params)
+{
+ ref_ptr<dp::metal::MetalGpuProgram> p = program;
+ ref_ptr<dp::metal::MetalBaseContext> metalContext = context;
+ id<MTLRenderCommandEncoder> encoder = metalContext->GetCommandEncoder();
+
+ auto const vsBindingIndex = p->GetVertexShaderUniformsBindingIndex();
+ if (vsBindingIndex >= 0)
+ {
+ [encoder setVertexBytes:(void const *)&params length:sizeof(params)
+ atIndex:vsBindingIndex];
+ }
+
+ auto const fsBindingIndex = p->GetFragmentShaderUniformsBindingIndex();
+ if (fsBindingIndex >= 0)
+ {
+ [encoder setFragmentBytes:(void const *)&params length:sizeof(params)
+ atIndex:fsBindingIndex];
+ }
+}
+} // namespace
+
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ MapProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ RouteProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ TrafficProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ TransitProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ GuiProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ ShapesProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ Arrow3dProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ DebugRectProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ ScreenQuadProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
-void MetalProgramParamsSetter::Apply(ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params)
+void MetalProgramParamsSetter::Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program,
+ SMAAProgramParams const & params)
{
+ ApplyBytes(context, program, params);
}
} // namespace metal
} // namespace gpu
diff --git a/shaders/metal_program_pool.mm b/shaders/metal_program_pool.mm
index 23f3cd712d..2c038094fb 100644
--- a/shaders/metal_program_pool.mm
+++ b/shaders/metal_program_pool.mm
@@ -113,10 +113,10 @@ drape_ptr<dp::GpuProgram> MetalProgramPool::Get(Program program)
NSError * error = nil;
MTLRenderPipelineReflection * reflectionObj = nil;
MTLPipelineOption option = MTLPipelineOptionBufferTypeInfo | MTLPipelineOptionArgumentInfo;
- id <MTLRenderPipelineState> pso = [m_device newRenderPipelineStateWithDescriptor:desc
- options:option
- reflection:&reflectionObj
- error:&error];
+ id<MTLRenderPipelineState> pso = [m_device newRenderPipelineStateWithDescriptor:desc
+ options:option
+ reflection:&reflectionObj
+ error:&error];
if (error != nil || pso == nil)
{
NSLog(@"%@", error);
diff --git a/shaders/program_manager.hpp b/shaders/program_manager.hpp
index f4b988496d..00a8980669 100644
--- a/shaders/program_manager.hpp
+++ b/shaders/program_manager.hpp
@@ -27,7 +27,7 @@ public:
private:
void InitForOpenGL(ref_ptr<dp::GraphicsContext> context);
- // Definition of this method is in separate .mm-file.
+ // Definition of this method is in a .mm-file.
void InitForMetal(ref_ptr<dp::GraphicsContext> context);
using Programs = std::array<drape_ptr<dp::GpuProgram>,
diff --git a/shaders/program_params.hpp b/shaders/program_params.hpp
index 3ea1478c90..7264708170 100644
--- a/shaders/program_params.hpp
+++ b/shaders/program_params.hpp
@@ -3,6 +3,7 @@
#include "shaders/programs.hpp"
#include "drape/glsl_types.hpp"
+#include "drape/graphics_context.hpp"
#include "drape/gpu_program.hpp"
#include "drape/pointers.hpp"
@@ -208,15 +209,25 @@ class ProgramParamsSetter
{
public:
virtual ~ProgramParamsSetter() = default;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, MapProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) = 0;
- virtual void Apply(ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, MapProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, RouteProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, TrafficProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, TransitProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, GuiProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, ShapesProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, Arrow3dProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, DebugRectProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, ScreenQuadProgramParams const & params) = 0;
+ virtual void Apply(ref_ptr<dp::GraphicsContext> context,
+ ref_ptr<dp::GpuProgram> program, SMAAProgramParams const & params) = 0;
};
} // namespace gpu