Skip to content

Commit 138d351

Browse files
lasselammigithub-actions[bot]
authored andcommitted
Add a new shader define to fix a Vulkan crash (internal-9913)
GitOrigin-RevId: a484ab0270a5af72dcee897d71b8e2f3e980230a
1 parent 37c32ec commit 138d351

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/render/draw_line.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
186186
defines.push('LINE_PATTERN_TRANSITION');
187187
}
188188

189+
if (bucket.elevationGroundScaleVertexBuffer) {
190+
defines.push('ELEVATION_GROUND_SCALE');
191+
}
192+
189193
const affectedByFog = painter.isTileAffectedByFog(coord);
190194
const program = painter.getOrCreateProgram(programId, {config: programConfiguration, defines, overrideFog: affectedByFog});
191195

src/render/program/line_program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type LinePatternUniformsType = {
5454
['u_pattern_transition']: Uniform1f;
5555
};
5656

57-
export type LineDefinesType = 'RENDER_LINE_GRADIENT' | 'RENDER_LINE_DASH' | 'RENDER_LINE_TRIM_OFFSET' | 'RENDER_LINE_BORDER' | 'LINE_JOIN_NONE' | 'ELEVATED' | 'VARIABLE_LINE_WIDTH' | 'CROSS_SLOPE_VERTICAL' | 'CROSS_SLOPE_HORIZONTAL' | 'ELEVATION_REFERENCE_SEA' | 'LINE_PATTERN_TRANSITION' | 'USE_MRT1' | 'DUAL_SOURCE_BLENDING';
57+
export type LineDefinesType = 'RENDER_LINE_GRADIENT' | 'RENDER_LINE_DASH' | 'RENDER_LINE_TRIM_OFFSET' | 'RENDER_LINE_BORDER' | 'LINE_JOIN_NONE' | 'ELEVATED' | 'VARIABLE_LINE_WIDTH' | 'CROSS_SLOPE_VERTICAL' | 'CROSS_SLOPE_HORIZONTAL' | 'ELEVATION_REFERENCE_SEA' | 'ELEVATION_GROUND_SCALE' | 'LINE_PATTERN_TRANSITION' | 'USE_MRT1' | 'DUAL_SOURCE_BLENDING';
5858

5959
const lineUniforms = (context: Context): LineUniformsType => ({
6060
'u_matrix': new UniformMatrix4f(context),

src/shaders/line.vertex.glsl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ in vec4 a_data;
1515
#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)
1616
in vec3 a_z_offset_width;
1717
#endif
18-
#ifdef ELEVATED
18+
#ifdef ELEVATION_GROUND_SCALE
1919
in float a_elevation_ground_scale;
2020
#endif
2121

@@ -291,7 +291,10 @@ void main() {
291291
vec2 offsetTile = offset2 * u_pixels_to_tile_units;
292292
vec2 offset_pos = pos + offsetTile;
293293
float ele = 0.0;
294-
float scaled_z_offset = a_z_offset * mix(1.0, u_exaggeration, a_elevation_ground_scale);
294+
float scaled_z_offset = a_z_offset;
295+
#ifdef ELEVATION_GROUND_SCALE
296+
scaled_z_offset = a_z_offset * mix(1.0, u_exaggeration, a_elevation_ground_scale);
297+
#endif
295298
#ifdef CROSS_SLOPE_VERTICAL
296299
// Vertical line
297300
// The least significant bit of a_pos_normal.y hold 1 if it's on top, 0 for bottom

src/shaders/line_pattern.vertex.glsl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ in vec4 a_data;
1515
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1616
in vec3 a_z_offset_width;
1717
#endif
18-
#ifdef ELEVATED
18+
#ifdef ELEVATION_GROUND_SCALE
1919
in float a_elevation_ground_scale;
2020
#endif
2121
// Includes in order: a_uv_x, a_split_index, a_line_progress
@@ -158,7 +158,10 @@ void main() {
158158
vec2 offsetTile = offset2 * u_pixels_to_tile_units;
159159
vec2 offset_pos = pos + offsetTile;
160160
float ele = 0.0;
161-
float scaled_z_offset = a_z_offset * mix(1.0, u_exaggeration, a_elevation_ground_scale);
161+
float scaled_z_offset = a_z_offset;
162+
#ifdef ELEVATION_GROUND_SCALE
163+
scaled_z_offset = a_z_offset * mix(1.0, u_exaggeration, a_elevation_ground_scale);
164+
#endif
162165
#ifdef CROSS_SLOPE_VERTICAL
163166
// Vertical line
164167
// The least significant bit of a_pos_normal.y hold 1 if it's on top, 0 for bottom

0 commit comments

Comments
 (0)