LEGACY_GL_EMULATION: generated fixed-function fragment shaders use mediump — fp16 overflow where mediump is half precision

Đang mở Phù hợp với người mới
#27,948 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@TheTomBritton đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #28062 của @TheTomBritton — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu tại src/lib/libglemu.js, ở phần ghép fsSource cho pipeline fixed-function, rồi so sánh phần tiêu đề độ chính xác của nó với tiêu đề có điều kiện được dùng cho shader do người dùng cung cấp. Xuất cùng điều kiện GL_FRAGMENT_PRECISION_HIGH cho các fragment shader được tạo. Hoàn thành khi tiêu đề được tạo chọn highp nếu được hỗ trợ và chuyển sang mediump nếu không; xác minh bằng các kiểm tra mô phỏng GL cũ có liên quan của repository.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Desktop OpenGL emulation
Version

emcc 6.0.12; verified present on main (src/lib/libglemu.js, the fixed-function fsSource assembly). Flags: -sLEGACY_GL_EMULATION.

Summary

The generated fixed-function fragment shaders begin with a plain

'precision mediump float;',

On GPUs where mediump is genuinely half precision in fragment shaders (Apple GPUs via Metal/ANGLE, many mobile GPUs), fp16 has a max finite value of 65504 and an 11-bit mantissa. GL 1.x content routinely pushes values beyond that through the fragment stage — texel-space or homogeneous texture coordinates being the common case. In our port, large polygons rendered solid black on macOS Chrome because interpolated texture coordinates overflowed fp16; the same build was pixel-perfect on desktop GPUs where mediump maps to fp32 (and on SwiftShader), which makes the failure easy to miss in CI.

Suggested fix

GLEmulation.init already patches user shaders with a guarded header:

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

The FFP generator should emit the same conditional header instead of unconditional mediump. (That is the fix we ship, via post-processing.)

Ngôn ngữ chính
C++
Star
27.8k
Fork
3.6k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
181

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của emscripten-core/emscripten

Tất cả issue của emscripten-core/emscripten

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.