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

Gpu: OpenGL 4 implementation #7

Closed
wants to merge 18 commits into from
Closed

Conversation

meyraud705
Copy link

@meyraud705 meyraud705 commented Dec 29, 2023

I wrote an OpenGL implementation and fixed some bugs in SDL_gpu.c and spinning cube test. It is working:

output

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.

@icculus icculus deleted the branch icculus:gpu-api July 19, 2024 17:01
@icculus icculus closed this Jul 19, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants