Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Align line vertex to 4-byte boundary #9943

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mbgl/programs/attributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inline uint16_t packUint8Pair(T a, T b) {
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset);
MBGL_DEFINE_ATTRIBUTE(int16_t, 3, a_pos_normal);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_normal);
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 3, a_normal);
MBGL_DEFINE_ATTRIBUTE(uint16_t, 1, a_edgedistance);
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/programs/line_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace mbgl {

using namespace style;

static_assert(sizeof(LineLayoutVertex) == 10, "expected LineLayoutVertex size");
static_assert(sizeof(LineLayoutVertex) == 12, "expected LineLayoutVertex size");

template <class Values, class...Args>
Values makeValues(const LinePaintProperties::Evaluated& properties,
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/programs/line_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class LineProgram : public Program<
{{
p.x,
p.y,
static_cast<int16_t>(attributes::packUint8Pair(round ? 1 : 0, up ? 1 : 0))
static_cast<int16_t>(round ? 1 : 0),
static_cast<int16_t>(up ? 1 : -1)
}},
{{
// add 128 to store a byte in an unsigned byte
Expand Down
9 changes: 3 additions & 6 deletions src/mbgl/shaders/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const char* line::vertexSource = R"MBGL_SHADER(
// #define scale 63.0
#define scale 0.015873016

attribute vec3 a_pos_normal;
attribute vec4 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -109,12 +109,9 @@ void main() {

vec2 pos = a_pos_normal.xy;

// transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// x is 1 if it's a round cap, 0 otherwise
// y is 1 if the normal points up, and -1 if it points down
mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);

mediump vec2 normal = a_pos_normal.zw;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
9 changes: 3 additions & 6 deletions src/mbgl/shaders/line_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const char* line_pattern::vertexSource = R"MBGL_SHADER(
// Retina devices need a smaller distance to avoid aliasing.
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0

attribute vec3 a_pos_normal;
attribute vec4 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -99,12 +99,9 @@ void main() {

vec2 pos = a_pos_normal.xy;

// transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// x is 1 if it's a round cap, 0 otherwise
// y is 1 if the normal points up, and -1 if it points down
mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);

mediump vec2 normal = a_pos_normal.zw;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
9 changes: 3 additions & 6 deletions src/mbgl/shaders/line_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const char* line_sdf::vertexSource = R"MBGL_SHADER(
// Retina devices need a smaller distance to avoid aliasing.
#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0

attribute vec3 a_pos_normal;
attribute vec4 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -118,12 +118,9 @@ void main() {

vec2 pos = a_pos_normal.xy;

// transform y normal so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// x is 1 if it's a round cap, 0 otherwise
// y is 1 if the normal points up, and -1 if it points down
mediump vec2 normal = unpack_float(a_pos_normal.z);
normal.y = sign(normal.y - 0.5);

mediump vec2 normal = a_pos_normal.zw;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down