Device pixel ratio send as define instead of UBO field (#1936)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
|
||||
#include <mbgl/util/hash.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
#include <string_view>
|
||||
@@ -14,6 +15,7 @@ ProgramParameters::ProgramParameters(const float pixelRatio, const bool overdraw
|
||||
if (overdraw) {
|
||||
defines["OVERDRAW_INSPECTOR"] = std::string();
|
||||
}
|
||||
definesHash = util::hash(getDefinesString());
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withShaderSource(const ProgramSource& source) const noexcept {
|
||||
|
||||
@@ -62,9 +62,11 @@ public:
|
||||
const std::string& fragmentSource(gfx::Backend::Type backend) const;
|
||||
|
||||
bool getOverdrawInspectorEnabled() const { return overdrawInspector; }
|
||||
std::uint64_t getDefinesHash() const { return definesHash; }
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> defines;
|
||||
std::uint64_t definesHash;
|
||||
|
||||
// cached value of `defines` converted to string format
|
||||
mutable std::string definesStr;
|
||||
|
||||
@@ -42,8 +42,8 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
// Updated every frame, but shared across drawables
|
||||
const CirclePaintParamsUBO paintParamsUBO = {
|
||||
/* .camera_to_center_distance = */ parameters.state.getCameraToCenterDistance(),
|
||||
/* .device_pixel_ratio = */ parameters.pixelRatio,
|
||||
/* .padding = */ 0,
|
||||
0,
|
||||
0};
|
||||
|
||||
if (!paintParamsUniformBuffer) {
|
||||
|
||||
@@ -130,7 +130,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineUBOName, &lineUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -142,7 +142,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineGradientUBOName, &lineGradientUBO, context);
|
||||
|
||||
// properties UBO
|
||||
@@ -165,8 +165,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
/*texsize =*/{static_cast<float>(textureSize.width), static_cast<float>(textureSize.height)},
|
||||
/*units_to_pixels =*/{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio =*/1.0f / tileID.pixelsToTileUnits(1.0f, static_cast<float>(zoom)),
|
||||
/*device_pixel_ratio =*/parameters.pixelRatio,
|
||||
/*fade =*/crossfade.t,
|
||||
0,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLinePatternUBOName, &linePatternUBO, context);
|
||||
|
||||
@@ -208,12 +208,12 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
-posB.height / 2.0f},
|
||||
/* ratio = */ 1.0f /
|
||||
tileID.pixelsToTileUnits(1.0f, static_cast<float>(parameters.state.getZoom())),
|
||||
/* device_pixel_ratio = */ parameters.pixelRatio,
|
||||
/* tex_y_a = */ posA.y,
|
||||
/* tex_y_b = */ posB.y,
|
||||
/* sdfgamma = */ static_cast<float>(dashPatternTexture.getSize().width) /
|
||||
(std::min(widthA, widthB) * 256.0f * parameters.pixelRatio) / 2.0f,
|
||||
/* mix = */ crossfade.t};
|
||||
/* mix = */ crossfade.t,
|
||||
0};
|
||||
uniforms.createOrUpdate(idLineSDFUBOName, &lineSDFUBO, context);
|
||||
|
||||
// properties UBO
|
||||
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
parameters.context.emplaceOrUpdateUniformBuffer(lineUniformBuffer, &lineUBO);
|
||||
}
|
||||
uniforms.addOrReplace(idLineUBOName, lineUniformBuffer);
|
||||
|
||||
@@ -94,8 +94,8 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
|
||||
const SymbolDynamicUBO dynamicUBO = {/*.fade_change=*/parameters.symbolFadeChange,
|
||||
/*.camera_to_center_distance=*/camDist,
|
||||
/*.device_pixel_ratio=*/parameters.pixelRatio,
|
||||
/*.aspect_ratio=*/state.getSize().aspectRatio()};
|
||||
/*.aspect_ratio=*/state.getSize().aspectRatio(),
|
||||
0};
|
||||
|
||||
if (!dynamicBuffer) {
|
||||
dynamicBuffer = parameters.context.createUniformBuffer(&dynamicUBO, sizeof(dynamicUBO));
|
||||
|
||||
@@ -215,7 +215,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
/*matrix = */ util::cast<float>(matrix),
|
||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
||||
/*device_pixel_ratio = */ parameters.pixelRatio};
|
||||
0};
|
||||
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user