edubart / sokol_gp

Minimal modern efficient cross platform 2D graphics painter in C
MIT No Attribution
456 stars 24 forks source link

Update to latest sokol_gfx #22

Closed leiradel closed 1 year ago

leiradel commented 1 year ago

sokol_gp does not compile anymore with the latest sokol_gfx. Do you have plans to update sokol_gp?

I could give it a try, but I'd rather know from you how the sokol_gp public API should look like before starting to change the code to maximize the chance of the PR being accepted.

edubart commented 1 year ago

I plan to update at some point, right now you have to use pre sampler update tag from sokol:

https://github.com/floooh/sokol/releases/tag/pre-separate-samplers

leiradel commented 1 year ago

Ok, thanks for the feedback. I was already using a previous sokol_gfx version but thanks for the link, the more recent the version, the better.

My offer stands though.

kkukshtel commented 1 year ago

Trying to do it on my end as well over the weekend, I'll submit a PR if I get it working.

CaptainKraft commented 1 year ago

Trying to do it on my end as well over the weekend, I'll submit a PR if I get it working.

Any luck?

kkukshtel commented 1 year ago

Started it a bit and then honestly just switching to sokol_gl - it seems to do most everything sokol_gp does and is by the main sokol dev, and as such maintains consistency with any sokol_gfx changes

CaptainKraft commented 1 year ago

Started it a bit and then honestly just switching to sokol_gl - it seems to do most everything sokol_gp does and is by the main sokol dev, and as such maintains consistency with any sokol_gfx changes

I wasn't aware of sokol_gl, but it seems quite limited as compared to sokol_gp.

Hopefully this repo will be updated before too long

edubart commented 1 year ago

I will update to latest sokol, just hadn't the time yet. If you want me to speed up this on my agenda, you can do an one time donation.

kkukshtel commented 1 year ago

@edubart Have you looked at sokol_gl? I'm wondering if it makes sense to combine forces there or if it makes sense for gp to still exist in parallel.

edubart commented 1 year ago

@edubart Have you looked at sokol_gl? I'm wondering if it makes sense to combine forces there or if it makes sense for gp to still exist in parallel.

Sokol GL is designed to mimic a subset if OpenGL APIs, thus designed for 3D rendering and is not optimized for 2D. If you want to do some sort of 3D rendering use it, otherwise by cutting 3D related code something more optimized and simpler to use can be created, this is the case of Sokol GP.

Makes no sense to combine forces because of different objectives.

edubart commented 1 year ago

I worked on this issue recent commits, and sokol_gp is now working again with latest Sokol, changes are already merged in master branch.

The update required me to introduce new APIs that may be require attention when migrating such as sgp_set_sampler and sgp_reset_sampler. Shaders and examples were updated accordingly and they are working.

If you want to stick with the old behavior and APIs, I created the tag https://github.com/edubart/sokol_gp/releases/tag/pre-samplers , but I am not maintaining the old way anymore.

Closing.

edubart commented 1 year ago

@kkukshtel @CaptainKraft @leiradel let me know if the update works for all of you (after you migrate your code).

kkukshtel commented 1 year ago

Just set it up and ran it. Library compiles fine but upon trying to run the sample from the readme I'm seeing a sokol_gfx error:

[ERROR][sg] SG_LOGITEM_D3D11_CREATE_INPUT_LAYOUT_FAILED C:\Users\kyle\Workspace\Dinghy\Dinghy.Bootstrapper\libs\sokol\build/../src/sokol/sokol_gfx.h Line=9646
    D3D11_CREATE_INPUT_LAYOUT_FAILED: CreateInputLayout() failed (d3d11)

Assertion failed: _sgp.init_cookie == _SGP_INIT_COOKIE, file C:\Users\kyle\Workspace\Dinghy\Dinghy.Bootstrapper\libs\sokol\build/../src/sokol_gp/sokol_gp.h, line 2172

Also, thanks for getting to this so fast! I thought you had mostly just gone to Nelua land :)

edubart commented 1 year ago

@kkukshtel Thanks for trying, indeed I got that error when testing in D3D11, I forgot to rename a value, made a fix for this in https://github.com/edubart/sokol_gp/commit/d0c64677259b5997310e4b60448c0ea702486f0d . Tested D3D11 backend here and it worked fine, let me know if it works for you.

kkukshtel commented 1 year ago

@edubart confirming it works!

image

Thank you! Will now move back to using gp instead of gl!

leiradel commented 1 year ago

@edubart I can confirm that it works with the latest sokol_gfx.h in my application. I had a regression rendering to a render target, but that's very likely me doing something wrong.

Thank you so much for this update!