Fixed metal circle render tests (#1854)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Cristici
2023-11-10 00:10:47 +02:00
committed by GitHub
parent 9faa155546
commit 028bec0f69
5 changed files with 22 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal> {
struct VertexStage {
short2 position [[attribute(0)]];
float2 color [[attribute(1)]];
float4 color [[attribute(1)]];
float2 radius [[attribute(2)]];
float2 blur [[attribute(3)]];
float2 opacity [[attribute(4)]];
@@ -98,7 +98,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
device const CirclePermutationUBO& permutation [[buffer(12)]],
device const ExpressionInputsUBO& expr [[buffer(13)]]) {
const auto color = colorFor(permutation.color, props.color, vertx.color, expr);
const auto color = colorFor(permutation.color, props.color, vertx.color, interp.color_t, expr);
const auto radius = valueFor(permutation.radius, props.radius, vertx.radius, interp.radius_t, expr);
const auto blur = valueFor(permutation.blur, props.blur, vertx.blur, interp.blur_t, expr);
const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr);
@@ -107,7 +107,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
const auto stroke_opacity = valueFor(permutation.stroke_opacity, props.stroke_opacity, vertx.stroke_opacity, interp.stroke_opacity_t, expr);
// unencode the extrusion vector that we snuck into the a_pos vector
const float2 extrude = fmod(float2(vertx.position), 2.0) * 2.0 - 1.0;
const float2 extrude = glMod(float2(vertx.position), 2.0) * 2.0 - 1.0;
const float2 scaled_extrude = extrude * drawable.extrude_scale;
// multiply a_pos by 0.5, since we had it * 2 in order to sneak in extrusion data

View File

@@ -87,6 +87,12 @@ void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters)
#if MLN_DRAWABLE_RENDERER
if (layerGroup) {
auto newTweaker = std::make_shared<CircleLayerTweaker>(getID(), evaluatedProperties);
// propertiesAsUniforms isn't recalculated every update, so carry it over
if (layerTweaker) {
newTweaker->setPropertiesAsUniforms(layerTweaker->getPropertiesAsUniforms());
}
replaceTweaker(layerTweaker, std::move(newTweaker), {layerGroup});
}
#endif // MLN_DRAWABLE_RENDERER

View File

@@ -77,6 +77,12 @@ void RenderFillExtrusionLayer::evaluate(const PropertyEvaluationParameters& para
#if MLN_DRAWABLE_RENDERER
if (layerGroup) {
auto newTweaker = std::make_shared<FillExtrusionLayerTweaker>(getID(), evaluatedProperties);
// propertiesAsUniforms isn't recalculated every update, so carry it over
if (layerTweaker) {
newTweaker->setPropertiesAsUniforms(layerTweaker->getPropertiesAsUniforms());
}
replaceTweaker(layerTweaker, std::move(newTweaker), {layerGroup});
}
#endif // MLN_DRAWABLE_RENDERER

View File

@@ -71,6 +71,12 @@ void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters
if (renderTarget) {
if (auto tileLayerGroup = renderTarget->getLayerGroup(0)) {
auto newTweaker = std::make_shared<HeatmapLayerTweaker>(getID(), evaluatedProperties);
// propertiesAsUniforms isn't recalculated every update, so carry it over
if (layerTweaker) {
newTweaker->setPropertiesAsUniforms(layerTweaker->getPropertiesAsUniforms());
}
replaceTweaker(layerTweaker, std::move(newTweaker), {std::move(tileLayerGroup)});
}
}

View File

@@ -5,7 +5,7 @@ namespace shaders {
const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::attributes = {
AttributeInfo{0, gfx::AttributeDataType::Short2, 1, "a_pos"},
AttributeInfo{1, gfx::AttributeDataType::Float2, 1, "a_color"},
AttributeInfo{1, gfx::AttributeDataType::Float4, 1, "a_color"},
AttributeInfo{2, gfx::AttributeDataType::Float2, 1, "a_radius"},
AttributeInfo{3, gfx::AttributeDataType::Float2, 1, "a_blur"},
AttributeInfo{4, gfx::AttributeDataType::Float2, 1, "a_opacity"},