Nuklear
Nuklear copied to clipboard
SDL_gpu API example
Hi, now that SDL_gpu new API is out, I was wondering if there will be a new example (in the examples folder) implementing this new API.
Thanks!
I doubt it, but PR are welcome ;-)
Hi, thanks! I will definitely take a look at this when I get some time and try to make that PR
Any news on this?
IHMO, this would be way too much for Nuklear demo/example, hear me out.
SDL_gpu expects that you pass your own shaders in binary form, which is different per platform/backend. You can read more about this problem here: https://moonside.games/posts/layers-all-the-way-down/
So in order to implement SDL_gpu demo/example, we would have to provide multiple binary blobs (or embed them into source code with xxd) or create dependency on something like SDL_shadercross, which is extremely complex IMO.
Don't get me wrong, I'm not saying "no", I just feel like this would cause more harm than actually help anyone. A lot of people does not seem to understand the real implications of this new API, it's nothing like SDL_renderer, not a silver bullet like some may think.
For anyone who wants to implement this: you can take a look at how imgui solved it, here: https://github.com/ocornut/imgui/pull/8163 Per these instructions, they used HLSL for human-readable shader code, then compiled it into SPIRV blobs, then recompiled the blobs yet again for appropriate platform, then packed the blobs into headers with xxd-like utility. So the end-user does not have to do this on its own, but there is no way to easily change the shaders, which in my opinion breaks the idea of example that is expected to be easy to modify.
IHMO, this would be way too much for Nuklear demo/example, hear me out.
SDL_gpu expects that you pass your own shaders in binary form, which is different per platform/backend. You can read more about this problem here: https://moonside.games/posts/layers-all-the-way-down/
So in order to implement SDL_gpu demo/example, we would have to provide multiple binary blobs (or embed them into source code with
xxd) or create dependency on something like SDL_shadercross, which is extremely complex IMO.Don't get me wrong, I'm not saying "no", I just feel like this would cause more harm than actually help anyone. A lot of people does not seem to understand the real implications of this new API, it's nothing like SDL_renderer, not a silver bullet like some may think.
For anyone who wants to implement this: you can take a look at how imgui solved it, here: ocornut/imgui#8163 Per these instructions, they used HLSL for human-readable shader code, then compiled it into SPIRV blobs, then recompiled the blobs yet again for appropriate platform, then packed the blobs into headers with
xxd-like utility. So the end-user does not have to do this on its own, but there is no way to easily change the shaders, which in my opinion breaks the idea of example that is expected to be easy to modify.
for the people interested in using sdl_gpu with nuklear is way worse to have them write their own backend from scratch compared to going through the hoops of building shaders.
also please consider that anyone developing with sdl_gpu has already jumped through all the hoops of building the shaders.
for the people interested in using sdl_gpu with nuklear is way worse to have them write their own backend from scratch compared to going through the hoops of building shaders.
I know this may not be exactly what you want here, but for people who just want to get Nuklear running in SDL_gpu'based project: you can try using demo/sdl3_renderer and create an off-screen Renderer with SDL_CreateGPURenderer. This should give you SDL_gpu'compatible Texture that you could apply to your main Window backbuffer. I haven't tested this approach yet but it seems possible. Ofcourse this is not great because dedicated nk_sdl3_gpu demo would be more optimized and straight forward to use, but I hope you get my point.
If anyone here already tried it, please let me know how it went.
I might take a look into implementing nk_sdl3_gpu demo someday.