ITADN

Gpu: OpenGL 4 implementation

#7Pull Requestmeyraud705 创建于 2023-12-29
M
meyraud705commented
I wrote an OpenGL implementation and fixed some bugs in SDL_gpu.c and spinning cube test. It is working: ![output](https://github.com/icculus/SDL/assets/70028899/f79a4a3e-bc6e-491a-a3ad-a051d3d59e20) But: - No multithreading support - ~No command buffer, every command is sent immediately to OpenGL~ - It uses GLSL shader for now - No fences yet - There are others TODO and FIXME, take a look at the source It requires OpenGL 4.6 for polygon offset clamp and uses Direct State Access from 4.5. Change I made to the API: - Added `SDL_SetGpuMesh()`: Mesh buffer is declared differently from other buffer in shader (`@input` vs `@buffer(index)`). It is the same in GLSL. We could also add a parameter to `SDL_GpuDraw*()`. `@input` should also take an index to allow more than 1 buffer as mesh buffer. Remark about the API: - Do we really need CPU buffer. I see there are implemented the same in metal and it is also the case in OpenGL. I think an usage flag on GPU buffer could work (`SDL_GPU_BUFFER_USAGE_LOCKABLE_READ`, `SDL_GPU_BUFFER_USAGE_LOCKABLE_WRITE`, ...). - `SDL_GPUSAMPADDR_CLAMPTOZERO` does not exit in OpenGL (maybe there is an extention?) - `SDL_GpuFillBuffer()`, like `memset()`, is only good to fill 0. OpenGL can convert clear value to internal format if you pass the internal buffer format. - I am not conviced about `GetBackbuffer` and `Present` too. I would simplify it a lot: user create a render texture, then call `Present()` to tell: put that texture on that window. - ~Could we make `RenderPass` persistent? OpenGL currently create a framebuffer, to store render textures, in `StartRenderPass()`. Creating a framebuffer is not a fast operation.~ We execute only 1 render pass at a time, all render passes can share the same framebuffer. - I complained about the lack of `glUniform()` equivalent in the past. I see now how you don't need it, you can forget about it.
合并状态:未合并 关闭于 2024-07-19 0 条评论