emscripten-core / emscripten-core/emscripten
glPixelStorei does not support PACK_ALIGNMENT
Nessuno ha ancora preso questa issue.
- Lingua principale
- C++
- Stelle
- 27.6k
- Fork
- 3.6k
- Merge medio
- 1g 14h
- PR unite (30g)
- 125
Descrizione
This issue originates from https://github.com/emscripten-core/emscripten/issues/21968
Calling glPixelStorei affects the memory layout of pixel data in glTexImage2D, glTexSubImage2D, and glReadPixels, thereby affecting the valid length of the pixel data. The OpenGL documentation provides a more detailed explanation:
https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glPixelStorei.xhtml
Emscripten restricts the length of pixel data through emscriptenWebGLGetTexPixelData, but this restriction may be shorter than expected after calling glPixelStorei. This results in browser errors.
Chrome and Safari:
WebGL: INVALID_OPERATION: texSubImage2D: ArrayBufferView not big enough for request
FireFox:
WebGL warning: texSubImage: Desired upload requires more bytes (20004) than are available (1440).
The problem with emscriptenWebGLGetTexPixelData is that it does not distinguish between pack and unpack, nor does it handle all possible parameters in glPixelStorei.
My simple patch is:
sed -i'.original' -e 's/return heap.subarray(toTypedArrayIndex(pixels, heap), toTypedArrayIndex(pixels + bytes, heap));/return heap.subarray(toTypedArrayIndex(pixels, heap));/g' emsdk/src/library_webgl.js
This removes the length restriction on the pixel data, since the C API only passes a pointer without data length.
The issue with this patch is that it makes it easier for the pixel data length to exceed 2GB, which in FireFox leads to a new problem:
WebGL2RenderingContext.readPixels: Argument 7 can't be an ArrayBuffer or an ArrayBufferView larger than 2 GB
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da emsdk/src/library_webgl.js, in particolare da emscriptenWebGLGetTexPixelData, e confronta il suo calcolo della lunghezza con il comportamento di pack/unpack in glPixelStorei e con il riferimento OpenGL collegato. Riproduci i casi texSubImage2D e readPixels in Chrome, Safari o Firefox; il lavoro è completo quando la dimensione del buffer è corretta senza errori del browser, incluso il limite di 2 GB di Firefox.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, wasm
- Ambito
- web-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100