Replies: 1 comment 1 reply
-
Yeah, that all seems correct See https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-hal/src/gles/egl.rs#L1112-L1114 for the final blit on present. And https://github.com/gfx-rs/naga/blob/master/tests/out/glsl/quad-vert.main.Vertex.glsl#L47 for what we insert in generated GLSL vert shaders. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I've been investigating how wgpu-rs handles the conversion between the coordinate spaces of WebGPU and OpenGL, and I'd like to confirm my understanding of the implementation details. I have outlined my findings below and would appreciate any clarification or confirmation:
Screen Space Y-Axis: In WebGPU, the y-axis in screen space goes from top to bottom, whereas in OpenGL, it goes from bottom to top. My understanding is that the final step in the wgpu-rs implementation uses BlitFrameBuffer to flip the y-axis of the internal FBO. Is this correct?
Texture Coordinates Y-Axis: Similarly, in WebGPU, the y-axis for texture coordinates goes from top to bottom, while in OpenGL, it goes from bottom to top. I believe that the wgpu-rs implementation uses Naga's ADJUST_COORDINATE_SPACE to indirectly achieve this by setting gl_Position.y = -gl_Position.y in the vertex shader. Could you confirm if this is accurate?
Z-Axis Values: WebGPU uses a z-axis range of [0, 1], while OpenGL uses a range of [-1, 1]. My understanding is that ADJUST_COORDINATE_SPACE modifies the z-value in the vertex shader with the transformation gl_Position.z = 2.0 * gl_Position.z - gl_Position.w. Is this the correct implementation?
I would be grateful for any insights or corrections you could provide. Thank you for your time and consideration.
Best regards,
Moyy
Beta Was this translation helpful? Give feedback.
All reactions