Symbol improve UBO (#1893)

This commit is contained in:
Alex Cristici
2023-11-28 08:16:11 +02:00
committed by GitHub
parent 178454bdba
commit db2e95a59b
16 changed files with 61 additions and 109 deletions

View File

@@ -101,9 +101,12 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
propertiesUpdated = false;
}
const auto camDist = state.getCameraToCenterDistance();
const SymbolDynamicUBO dynamicUBO = {/*.fade_change=*/parameters.symbolFadeChange,
/*.pad1=*/0,
/*.pad2=*/{0, 0}};
/*.camera_to_center_distance=*/camDist,
/*.device_pixel_ratio=*/parameters.pixelRatio,
/*.aspect_ratio=*/state.getSize().aspectRatio()};
if (!dynamicBuffer) {
dynamicBuffer = parameters.context.createUniformBuffer(&dynamicUBO, sizeof(dynamicUBO));
@@ -153,7 +156,6 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
const mat4 glCoordMatrix = getGlCoordMatrix(matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
const auto camDist = state.getCameraToCenterDistance();
const float gammaScale = (symbolData.pitchAlignment == AlignmentType::Map
? static_cast<float>(std::cos(state.getPitch())) * camDist
: 1.0f);
@@ -172,12 +174,7 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
/*.texsize_icon=*/toArray(getTexSize(drawable, idTexIconUniformName)),
/*.gamma_scale=*/gammaScale,
/*.device_pixel_ratio=*/parameters.pixelRatio,
/*.camera_to_center_distance=*/camDist,
/*.pitch=*/static_cast<float>(state.getPitch()),
/*.rotate_symbol=*/rotateInShader,
/*.aspect_ratio=*/state.getSize().aspectRatio(),
/*.pad=*/{0},
};

View File

@@ -22,7 +22,7 @@ const std::array<AttributeInfo, 10> ShaderSource<BuiltIn::SymbolSDFIconShader, g
const std::array<UniformBlockInfo, 7> ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal>::uniforms =
{
UniformBlockInfo{10, true, true, sizeof(SymbolDrawableUBO), "SymbolDrawableUBO"},
UniformBlockInfo{11, true, false, sizeof(SymbolDynamicUBO), "SymbolDynamicUBO"},
UniformBlockInfo{11, true, true, sizeof(SymbolDynamicUBO), "SymbolDynamicUBO"},
UniformBlockInfo{12, true, false, sizeof(SymbolDrawablePaintUBO), "SymbolDrawablePaintUBO"},
UniformBlockInfo{13, true, true, sizeof(SymbolDrawableTilePropsUBO), "SymbolDrawableTilePropsUBO"},
UniformBlockInfo{14, true, false, sizeof(SymbolDrawableInterpolateUBO), "SymbolDrawableInterpolateUBO"},

View File

@@ -21,7 +21,7 @@ const std::array<AttributeInfo, 9>
const std::array<UniformBlockInfo, 7>
ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{9, true, true, sizeof(SymbolDrawableUBO), "SymbolDrawableUBO"},
UniformBlockInfo{10, true, false, sizeof(SymbolDynamicUBO), "SymbolDynamicUBO"},
UniformBlockInfo{10, true, true, sizeof(SymbolDynamicUBO), "SymbolDynamicUBO"},
UniformBlockInfo{11, true, false, sizeof(SymbolDrawablePaintUBO), "SymbolDrawablePaintUBO"},
UniformBlockInfo{12, true, true, sizeof(SymbolDrawableTilePropsUBO), "SymbolDrawableTilePropsUBO"},
UniformBlockInfo{13, true, false, sizeof(SymbolDrawableInterpolateUBO), "SymbolDrawableInterpolateUBO"},