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

[core] Switch back to a more compact line attributes layout #14851

Merged
merged 2 commits into from
Jun 10, 2019
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 mapbox-gl-js
Submodule mapbox-gl-js updated 130 files
2 changes: 1 addition & 1 deletion src/mbgl/programs/attributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace attributes {
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, extrude);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, pos_offset);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, pos_normal);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, pos_normal);
MBGL_DEFINE_ATTRIBUTE(float, 3, projected_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, label_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, anchor_pos);
Expand Down
12 changes: 7 additions & 5 deletions src/mbgl/programs/gl/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LineProgram> {
static constexpr const char* name = "line";
static constexpr const uint8_t hash[8] = { 0x02, 0xe9, 0x14, 0x54, 0x14, 0xe4, 0xbc, 0x11 };
static constexpr const uint8_t hash[8] = { 0x7f, 0x8e, 0xaa, 0x53, 0x75, 0x78, 0xac, 0x2c };
static constexpr const auto vertexOffset = 30358;
static constexpr const auto fragmentOffset = 33316;
static constexpr const auto fragmentOffset = 33355;
};

constexpr const char* ShaderSource<LineProgram>::name;
Expand Down Expand Up @@ -47,7 +47,7 @@ Backend::Create<gfx::Backend::Type::OpenGL>(const ProgramParameters& programPara
// #define scale 63.0
#define scale 0.015873016

attribute vec4 a_pos_normal;
attribute vec2 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -165,11 +165,13 @@ void main() {

v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;

vec2 pos = a_pos_normal.xy;
vec2 pos = floor(a_pos_normal * 0.5);

// 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 = a_pos_normal.zw;
// We store these in the least significant bit of a_pos_normal
mediump vec2 normal = a_pos_normal - 2.0 * pos;
normal.y = normal.y * 2.0 - 1.0;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
14 changes: 8 additions & 6 deletions src/mbgl/programs/gl/line_gradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LineGradientProgram> {
static constexpr const char* name = "line_gradient";
static constexpr const uint8_t hash[8] = { 0x0f, 0xa3, 0xae, 0x1c, 0x38, 0xf2, 0x60, 0x54 };
static constexpr const auto vertexOffset = 34185;
static constexpr const auto fragmentOffset = 36938;
static constexpr const uint8_t hash[8] = { 0x3f, 0xba, 0xc6, 0x33, 0xcd, 0x86, 0xa2, 0xe8 };
static constexpr const auto vertexOffset = 34224;
static constexpr const auto fragmentOffset = 37016;
};

constexpr const char* ShaderSource<LineGradientProgram>::name;
Expand Down Expand Up @@ -51,7 +51,7 @@ Backend::Create<gfx::Backend::Type::OpenGL>(const ProgramParameters& programPara
// #define scale 63.0
#define scale 0.015873016

attribute vec4 a_pos_normal;
attribute vec2 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -153,11 +153,13 @@ void main() {

v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;

vec2 pos = a_pos_normal.xy;
vec2 pos = floor(a_pos_normal * 0.5);

// 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 = a_pos_normal.zw;
// We store these in the least significant bit of a_pos_normal
mediump vec2 normal = a_pos_normal - 2.0 * pos;
normal.y = normal.y * 2.0 - 1.0;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
14 changes: 8 additions & 6 deletions src/mbgl/programs/gl/line_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LinePatternProgram> {
static constexpr const char* name = "line_pattern";
static constexpr const uint8_t hash[8] = { 0x14, 0x72, 0xee, 0xac, 0x1f, 0xc7, 0xf6, 0x82 };
static constexpr const auto vertexOffset = 37768;
static constexpr const auto fragmentOffset = 41123;
static constexpr const uint8_t hash[8] = { 0x38, 0x9c, 0x3d, 0xde, 0xb4, 0xe0, 0xd1, 0x61 };
static constexpr const auto vertexOffset = 37846;
static constexpr const auto fragmentOffset = 41240;
};

constexpr const char* ShaderSource<LinePatternProgram>::name;
Expand Down Expand Up @@ -51,7 +51,7 @@ Backend::Create<gfx::Backend::Type::OpenGL>(const ProgramParameters& programPara
// long distances for long segments. Use this value to unscale the distance.
#define LINE_DISTANCE_SCALE 2.0

attribute vec4 a_pos_normal;
attribute vec2 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -184,11 +184,13 @@ void main() {
float a_direction = mod(a_data.z, 4.0) - 1.0;
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
// float tileRatio = u_scale.y;
vec2 pos = a_pos_normal.xy;
vec2 pos = floor(a_pos_normal * 0.5);

// 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 = a_pos_normal.zw;
// We store these in the least significant bit of a_pos_normal
mediump vec2 normal = a_pos_normal - 2.0 * pos;
normal.y = normal.y * 2.0 - 1.0;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
14 changes: 8 additions & 6 deletions src/mbgl/programs/gl/line_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ struct ShaderSource;
template <>
struct ShaderSource<LineSDFProgram> {
static constexpr const char* name = "line_sdf";
static constexpr const uint8_t hash[8] = { 0x21, 0x0f, 0x62, 0x9d, 0x31, 0x97, 0xad, 0x16 };
static constexpr const auto vertexOffset = 43478;
static constexpr const auto fragmentOffset = 47126;
static constexpr const uint8_t hash[8] = { 0x25, 0x94, 0x7f, 0xad, 0x84, 0xfe, 0x96, 0xad };
static constexpr const auto vertexOffset = 43595;
static constexpr const auto fragmentOffset = 47282;
};

constexpr const char* ShaderSource<LineSDFProgram>::name;
Expand Down Expand Up @@ -51,7 +51,7 @@ Backend::Create<gfx::Backend::Type::OpenGL>(const ProgramParameters& programPara
// long distances for long segments. Use this value to unscale the distance.
#define LINE_DISTANCE_SCALE 2.0

attribute vec4 a_pos_normal;
attribute vec2 a_pos_normal;
attribute vec4 a_data;

uniform mat4 u_matrix;
Expand Down Expand Up @@ -190,11 +190,13 @@ void main() {
float a_direction = mod(a_data.z, 4.0) - 1.0;
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;

vec2 pos = a_pos_normal.xy;
vec2 pos = floor(a_pos_normal * 0.5);

// 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 = a_pos_normal.zw;
// We store these in the least significant bit of a_pos_normal
mediump vec2 normal = a_pos_normal - 2.0 * pos;
normal.y = normal.y * 2.0 - 1.0;
v_normal = normal;

// these transformations used to be applied in the JS and native code bases.
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/programs/gl/raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ template <>
struct ShaderSource<RasterProgram> {
static constexpr const char* name = "raster";
static constexpr const uint8_t hash[8] = { 0x40, 0x3d, 0x6c, 0xf4, 0xd0, 0x41, 0x51, 0x0e };
static constexpr const auto vertexOffset = 48671;
static constexpr const auto fragmentOffset = 49020;
static constexpr const auto vertexOffset = 48827;
static constexpr const auto fragmentOffset = 49176;
};

constexpr const char* ShaderSource<RasterProgram>::name;
Expand Down
Loading