From c6737e8df1755ce3036689cca86bee5af2ab0be1 Mon Sep 17 00:00:00 2001 From: mwilsnd <53413200+mwilsnd@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:51:18 -0400 Subject: [PATCH] Fix build/fill UBO padding on Windows (#1649) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/mbgl/gfx/uniform_block.hpp | 4 +++- include/mbgl/shaders/fill_layer_ubo.hpp | 1 + include/mbgl/shaders/gl/drawable_fill_outline.hpp | 2 ++ include/mbgl/shaders/gl/drawable_fill_pattern.hpp | 4 ++++ include/mbgl/shaders/mtl/fill.hpp | 1 + shaders/drawable.fill_pattern.fragment.glsl | 2 ++ shaders/drawable.fill_pattern.vertex.glsl | 2 ++ src/mbgl/renderer/layers/fill_layer_tweaker.cpp | 3 ++- 8 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/mbgl/gfx/uniform_block.hpp b/include/mbgl/gfx/uniform_block.hpp index ac0014af2..38c0a56a5 100644 --- a/include/mbgl/gfx/uniform_block.hpp +++ b/include/mbgl/gfx/uniform_block.hpp @@ -2,10 +2,12 @@ #include +#include +#include #include #include #include -#include + namespace mbgl { namespace gfx { diff --git a/include/mbgl/shaders/fill_layer_ubo.hpp b/include/mbgl/shaders/fill_layer_ubo.hpp index 5cf551d71..cb320afc1 100644 --- a/include/mbgl/shaders/fill_layer_ubo.hpp +++ b/include/mbgl/shaders/fill_layer_ubo.hpp @@ -43,6 +43,7 @@ static_assert(sizeof(FillPermutationUBO) == 2 * 16); struct alignas(16) FillOutlineDrawableUBO { /* 0 */ std::array matrix; // composite model-view-projection matrix /* 64 */ std::array world; + /* 72 */ float pad1, pad2; /* 80 */ }; static_assert(sizeof(FillOutlineDrawableUBO) == 5 * 16); diff --git a/include/mbgl/shaders/gl/drawable_fill_outline.hpp b/include/mbgl/shaders/gl/drawable_fill_outline.hpp index 2e90ca776..3aa6a8483 100644 --- a/include/mbgl/shaders/gl/drawable_fill_outline.hpp +++ b/include/mbgl/shaders/gl/drawable_fill_outline.hpp @@ -11,6 +11,8 @@ struct ShaderSource { static constexpr const char* vertex = R"(layout (std140) uniform FillOutlineDrawableUBO { highp mat4 u_matrix; highp vec2 u_world; + highp float pad1; + highp float pad2; }; layout (std140) uniform FillOutlineEvaluatedPropsUBO { highp vec4 u_outline_color; diff --git a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_pattern.hpp index 8594792e2..4fc5ae313 100644 --- a/include/mbgl/shaders/gl/drawable_fill_pattern.hpp +++ b/include/mbgl/shaders/gl/drawable_fill_pattern.hpp @@ -14,6 +14,8 @@ struct ShaderSource { highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; + highp float pad1; + highp float pad2; }; layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; @@ -91,6 +93,8 @@ mediump vec4 pattern_to = u_pattern_to; highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; + highp float pad1; + highp float pad2; }; layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; diff --git a/include/mbgl/shaders/mtl/fill.hpp b/include/mbgl/shaders/mtl/fill.hpp index 59989e399..472e579b0 100644 --- a/include/mbgl/shaders/mtl/fill.hpp +++ b/include/mbgl/shaders/mtl/fill.hpp @@ -139,6 +139,7 @@ struct FragmentStage { struct alignas(16) FillOutlineDrawableUBO { float4x4 matrix; float2 world; + float2 pad1; }; struct alignas(16) FillOutlineEvaluatedPropsUBO { diff --git a/shaders/drawable.fill_pattern.fragment.glsl b/shaders/drawable.fill_pattern.fragment.glsl index 3f5195795..86decc73a 100644 --- a/shaders/drawable.fill_pattern.fragment.glsl +++ b/shaders/drawable.fill_pattern.fragment.glsl @@ -4,6 +4,8 @@ layout (std140) uniform FillPatternDrawableUBO { highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; + highp float pad1; + highp float pad2; }; layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; diff --git a/shaders/drawable.fill_pattern.vertex.glsl b/shaders/drawable.fill_pattern.vertex.glsl index afff0a637..dd0a4b070 100644 --- a/shaders/drawable.fill_pattern.vertex.glsl +++ b/shaders/drawable.fill_pattern.vertex.glsl @@ -4,6 +4,8 @@ layout (std140) uniform FillPatternDrawableUBO { highp vec2 u_pixel_coord_upper; highp vec2 u_pixel_coord_lower; highp vec2 u_texsize; + highp float pad1; + highp float pad2; }; layout (std140) uniform FillPatternEvaluatedPropsUBO { highp float u_opacity; diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp index f5d5004d6..ebd33424f 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp @@ -309,7 +309,8 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const FillOutlineDrawableUBO drawableUBO = { /*.matrix=*/util::cast(matrix), /*.world=*/{(float)renderableSize.width, (float)renderableSize.height}, - }; + /* pad1 */ 0, + /* pad2 */ 0}; uniforms.createOrUpdate(idFillOutlineDrawableUBOName, &drawableUBO, context);