From 80e194fbe16b2dd100238c0ed8de3dae44e1a77b Mon Sep 17 00:00:00 2001 From: Tim Sylvester Date: Wed, 4 Oct 2023 09:45:57 -0700 Subject: [PATCH] new static declaration style --- include/mbgl/shaders/mtl/line.hpp | 24 +++--------------------- src/mbgl/shaders/mtl/line.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/mbgl/shaders/mtl/line.hpp b/include/mbgl/shaders/mtl/line.hpp index b2d2dff09..298812252 100644 --- a/include/mbgl/shaders/mtl/line.hpp +++ b/include/mbgl/shaders/mtl/line.hpp @@ -322,27 +322,9 @@ struct ShaderSource { static constexpr auto vertexMainFunction = "vertexMain"; static constexpr auto fragmentMainFunction = "fragmentMain"; - static constexpr AttributeInfo attributes[] = { - {0, gfx::AttributeDataType::Short2, 1, "a_pos_normal"}, - {1, gfx::AttributeDataType::UByte4, 1, "a_data"}, - {2, gfx::AttributeDataType::Float4, 1, "a_color"}, - {3, gfx::AttributeDataType::Float2, 1, "a_blur"}, - {4, gfx::AttributeDataType::Float2, 1, "a_opacity"}, - {5, gfx::AttributeDataType::Float2, 1, "a_gapwidth"}, - {6, gfx::AttributeDataType::Float2, 1, "a_offset"}, - {7, gfx::AttributeDataType::Float2, 1, "a_width"}, - {8, gfx::AttributeDataType::Float2, 1, "a_floorwidth"}, - }; - static constexpr UniformBlockInfo uniforms[] = { - MLN_MTL_UNIFORM_BLOCK(9, true, true, LineSDFUBO), - MLN_MTL_UNIFORM_BLOCK(10, true, false, LineSDFPropertiesUBO), - MLN_MTL_UNIFORM_BLOCK(11, true, false, LineSDFInterpolationUBO), - MLN_MTL_UNIFORM_BLOCK(12, true, true, LinePermutationUBO), - MLN_MTL_UNIFORM_BLOCK(13, true, false, ExpressionInputsUBO), - }; - static constexpr TextureInfo textures[] = { - {0, "u_image"}, - }; + static const std::array attributes; + static const std::array uniforms; + static const std::array textures; static constexpr auto source = R"( diff --git a/src/mbgl/shaders/mtl/line.cpp b/src/mbgl/shaders/mtl/line.cpp index 514cf2f55..915781b22 100644 --- a/src/mbgl/shaders/mtl/line.cpp +++ b/src/mbgl/shaders/mtl/line.cpp @@ -45,5 +45,28 @@ const std::array ShaderSource ShaderSource::attributes= { + AttributeInfo{0, gfx::AttributeDataType::Short2, 1, "a_pos_normal"}, + AttributeInfo{1, gfx::AttributeDataType::UByte4, 1, "a_data"}, + AttributeInfo{2, gfx::AttributeDataType::Float4, 1, "a_color"}, + AttributeInfo{3, gfx::AttributeDataType::Float2, 1, "a_blur"}, + AttributeInfo{4, gfx::AttributeDataType::Float2, 1, "a_opacity"}, + AttributeInfo{5, gfx::AttributeDataType::Float2, 1, "a_gapwidth"}, + AttributeInfo{6, gfx::AttributeDataType::Float2, 1, "a_offset"}, + AttributeInfo{7, gfx::AttributeDataType::Float2, 1, "a_width"}, + AttributeInfo{8, gfx::AttributeDataType::Float2, 1, "a_floorwidth"}, +}; +const std::array ShaderSource::uniforms = { + UniformBlockInfo{9, true, true, sizeof(LineSDFUBO), "LineSDFUBO"}, + UniformBlockInfo{10, true, false, sizeof(LineSDFPropertiesUBO), "LineSDFPropertiesUBO"}, + UniformBlockInfo{11, true, false, sizeof(LineSDFInterpolationUBO), "LineSDFInterpolationUBO"}, + UniformBlockInfo{12, true, true, sizeof(LinePermutationUBO), "LinePermutationUBO"}, + UniformBlockInfo{13, true, false, sizeof(ExpressionInputsUBO), "ExpressionInputsUBO"}, +}; +const std::array ShaderSource::textures = { + TextureInfo{0, "u_image"}, +}; + } // namespace shaders } // namespace mbgl