Skip to content

Commit ce27d98

Browse files
Andrcraft9github-actions[bot]
authored andcommitted
Update UBO-based symbol vertex shader: Adreno bug workaround
GitOrigin-RevId: 09ce94f69fefbc4b59fc17350359d91d2e1c8801
1 parent 1a8b1dd commit ce27d98

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/shaders/symbol.vertex.glsl

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,26 @@ SymbolPropertyHeader readSymbolPropertiesHeader() {
242242
return header;
243243
}
244244

245+
/// Returns the component of a uvec4 at the given index.
246+
///
247+
/// Implemented with explicit swizzles to avoid old Adreno driver bugs with
248+
/// dynamic vector component indexing.
249+
uint uvec4At(uvec4 v, uint index) {
250+
return (index == 0u) ? v.x :
251+
(index == 1u) ? v.y :
252+
(index == 2u) ? v.z : v.w;
253+
}
254+
255+
/// Returns the component of a vec4 at the given index.
256+
///
257+
/// Implemented with explicit swizzles to avoid old Adreno driver bugs with
258+
/// dynamic vector component indexing.
259+
float vec4At(vec4 v, uint index) {
260+
return (index == 0u) ? v.x :
261+
(index == 1u) ? v.y :
262+
(index == 2u) ? v.z : v.w;
263+
}
264+
245265
vec4 readVec4(uint baseOffsetVec4, uint propertyOffsetDwords) {
246266
return u_properties[baseOffsetVec4 + propertyOffsetDwords / DWORDS_PER_VEC4];
247267
}
@@ -250,14 +270,21 @@ float readFloat(vec4 slot, uint propertyOffsetDwords) {
250270
return slot[propertyOffsetDwords % DWORDS_PER_VEC4];
251271
}
252272

273+
uint readUint(uvec4 slot, uint offset) {
274+
return slot[offset % DWORDS_PER_VEC4];
275+
}
276+
253277
vec2 readVec2(vec4 slot, uint propertyOffsetDwords) {
254-
return vec2(slot[propertyOffsetDwords % DWORDS_PER_VEC4], slot[propertyOffsetDwords % DWORDS_PER_VEC4 + 1u]);
278+
float x = vec4At(slot, propertyOffsetDwords % DWORDS_PER_VEC4);
279+
float y = vec4At(slot, propertyOffsetDwords % DWORDS_PER_VEC4 + 1u);
280+
return vec2(x, y);
255281
}
256282

257283
/// Calculate the feature's data-driven block offset in u_properties uniform buffer (vec4-indexed).
258284
uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {
259285
uint featureIndex = uint(a_feature_index);
260-
uint blockIndex = u_block_indices[featureIndex / DWORDS_PER_VEC4][featureIndex % DWORDS_PER_VEC4];
286+
uvec4 slot = u_block_indices[featureIndex / DWORDS_PER_VEC4];
287+
uint blockIndex = uvec4At(slot, featureIndex % DWORDS_PER_VEC4);
261288
return blockIndex * dataDrivenBlockSizeVec4;
262289
}
263290

0 commit comments

Comments
 (0)