Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten_UpdateWindowFramebuffer fails if pixel data is higher than 2gb in address space #9052

Open
sbc100 opened this issue Feb 12, 2024 · 6 comments
Assignees
Milestone

Comments

@sbc100
Copy link
Contributor

sbc100 commented Feb 12, 2024

Specifically the line var src = pixels >> 2 needs updating.

It should probably be:

#if __wasm64__
   var src = pixels  / 4;
#else
   var src = pixels >>> 0; 
#endif 

(I can work look into uploading a PR for this)

@icculus
Copy link
Collaborator

icculus commented Feb 15, 2024

Yes, please send a PR when you get a chance; this feels like something I'll get wrong if I try to do it myself. :)

@slouken slouken added this to the 3.2.0 milestone Mar 3, 2024
@sbc100 sbc100 removed their assignment Mar 8, 2024
@ericoporto
Copy link
Contributor

Trying to understand the issuepixels is a void* (I guess of size either 4 or 8 depending on it being a wasm64) and HEAP32 sees the memory like a sequence of 32-bit int. The SDL_Surface->pixels is allocated using SDL_SIMDAlloc which takes the size in bytes.

>>> 0 is a trick to cast to 32-bit int, it's a weird change assuming the current >> 2 is working (this is the same as / 4 here?)

@sbc100
Copy link
Contributor Author

sbc100 commented Mar 11, 2024

Sorry I meant to write >>> 2. The triple right shift is an unsigned shift (which is want) and the double right shift is a signed shift (which don't work for 32-bit addresses in the upper half of the range).

@sbc100
Copy link
Contributor Author

sbc100 commented Mar 11, 2024

If this is not in performance critical code you could just use a divide by 4 operation in all cases and keep the code simple.

@icculus icculus self-assigned this May 22, 2024
@icculus
Copy link
Collaborator

icculus commented May 22, 2024

Just coming back to this, do we just need that one var src = pixels >> 2; line fixed? I'll put that in revision control today if so!

@sbc100
Copy link
Contributor Author

sbc100 commented May 22, 2024

Any place >> or >>> is used on a pointer value would need to be fixed. I don't know if var src = pixels >> 2 is the only one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants