sokol
sokol copied to clipboard
[Draft] sokol_gfx.h: introduce separate sampler objects
Add separate sampler objects, some additional renaming (more in line with WebGPU conventions).
TODO:
- [x] fix sokol-spine trying to stash an image- and sampler-id into the render_object pointer => probably need to heap allocate an image-sampler-pair struct and use the render_object to point there...
- [x] fix sokol-shdc tests
- [x] don't allow to override the sampler object in sokol_imgui.h (because ImTextureID is 32-bits on WASM)
- [x] don't allow to override the sampler object in sokol_nuklear.h (because nk_handle is 32-bits on WASM)
- [x] fix iOS Metal backend errors
- [x] extend Windows GL loader with new sampler functions
- [x] fix dummy backend
- [x] extend sokol-gfx tests for sampler objects
- [x] fix all the other tests (sokol-spine etc)
- [x] allow depth-only rendering:
- [x] _sg_validate_pass_desc()
- [x] sg_make_pipeline() => .colors[0].pixel_format = SG_PIXELFORMAT_NONE
- [x] _sg_mtl_create_pipeline()
- [x] _sg_gl_create_pipeline()
- [x] _sg_d3d11_create_pipeline()
- [x] _sg_mtl_create_pass()
- [x] _sg_gl_create_pass()
- [x] _sg_d3d11_create_pass()
- [x] sg_begin_pass() => don't take width/height from first color attachment
- [x] _sg_mtl_begin_pass()
- [x] _sg_gl_begin_pass()
- [x] _sg_d3d11_begin_pass()
- [ ] new sample which samples depth texture with a comparison sampler
- [x] macOS/Metal
- [x] macOS/GL
- [x] iOS/Metal
- [ ] iOS/GL (something unrelated seems to be broken currently with iOS/GL on the simulator)
- [x] Windows/D3D11
- [x] Windows/GL
- [x] Linux/GL
- [x] Linux/GLES3
- [x] Android/GLES3
- [x] Emscripten/GLES3
- [ ] ~~new sample which fetches samples from an MSAA texture (???)~~ (won't work on the GL backend anyway, better to wait with this after the WebGPU backend is finished)
- [ ] doc updates:
- [ ] sokol_gfx.h
- [ ] sokol-shdc
- [x] sokol_gl.h
- [x] ~~sokol_debugtext.h~~ (no public API changes)
- [x] ~~sokol_fontstash.h~~ (no public API changes)
- [x] sokol_spine.h
- [x] sokol_imgui.h
- [x] sokol_nuklear.h
- [x] sokol_shape.h
- [x] sokol_gfx_imgui.h
- [x] fix util headers (except hlsl shaders):
- [x] sokol_debugtext.h
- [x] sokol_fontstash.h
- [x] sokol_gl.h
- [x] sokol_imgui.h
- [x] sokol_nuklear.h
- [x] sokol_spine.h
- [x] sokol_shape.h
- [x] sokol_gfx_imgui.h
- [x] update hlsl shaders in:
- [x] sokol_debugtext.h
- [x] sokol_fontstash.h
- [x] sokol_gl.h
- [x] sokol_imgui.h
- [x] sokol_nuklear.h
- [x] sokol_spine.h
- [x] fix samples:
- [x] d3d11
- [x] glfw
- [x] html5
- [x] metal
- [x] sapp
- [x] fix sokol-shdc backends:
- [x] zig
- [x] odin
- [x] nim
- [x] rust
- [x] bare
- [x] ...?
- [x] fix language bindings (also special case names):
- [x] sokol-zig
- [x] sokol-odin
- [x] sokol-nim
- [x] sokol-rust
- [x] fix language bindings samples:
- [x] sokol-zig
- [x] sokol-odin
- [x] sokol-nim
- [x] sokol-rust
What's new:
- Fix: sg_begin_pass() would use the wrong attachment width/height if rendering to a mip level
- Metal backend now checks for shared vs managed resources support on macOS
- Metal backend now supports clamp-to-border-color on iOS devices if possible (depends on iOS version and GPU family)
- new
sg_desc.mtl_force_managed_storage_modeconfig boolean to force managed storage mode on macOS devices (mainly useful for debugging) - new funcs:
- sg_make_sampler()
- sg_destroy_sampler()
- sg_init_sampler()
- sg_uninit_sampler()
- sg_alloc_sampler()
- sg_dealloc_sampler()
- sg_fail_sampler()
- removed sampler state in sg_image_desc:
- .min_filter
- .mag_filter
- .wrap_u
- .wrap_v
- .wrap_w
- .border_color
- .max_anisotropy
- .min_lod
- .max_lod
- sg_filter reduced to: none, nearest, linear
- new struct: sg_sampler_desc: sampler state moved over from sg_image_desc, plus:
- .mipmap_filter
- .compare
- additional reflection state and some general cleanup in sg_shader_desc (requires new sokol-shdc version):
- new: sg_shader_image_desc.used
- new: sg_shader_image_desc.multisampled
- new: sg_sampler_type renamed to sg_image_sample_type
- removed: sg_shader_image_desc.name
- new struct: sg_shader_sampler_desc
- repurposed enum sg_sampler_type (sample vs compare)
- new struct: sg_shader_image_sampler_pair_desc
- fix sokol-shdc so that it's possible to use textureSize()
- sg_bindings:
- changed: .vs_images[] => .vs.images[]
- changed: .fs_images[] => .fs.images[]
- new: .vs.samplers[]
- new: .fs.samplers[]
- renamed some types related to sg_pipeline_desc:
- sg_buffer_layout_desc => sg_vertex_buffer_layout_state
- sg_vertex_attr_desc => sg_vertex_attr_state
- sg_layout_desc => sg_vertex_layout_state
- related fixes in
- sokol_debugtext.h (only shaders)
- sokol_fontstash.h (only shaders)
- sokol_gl.h (shaders, and sgl_texture() now takes sg_image + sg_sampler)
- sokol_imgui.h (shaders, new helper function simgui_imtextureid() to create ImTextureID handle from sg_image and sg_sampler)
- sokol_nuklear.h (shader, snk_nkhandle() helper function to wrap sg_image+sg_sampler in nk_handle => use
nk_image_handle(snk_nkhandle(img, smp))to create a Nuklear image handle! - sokol_shapes.h rename some functions to match sokol_gfx.h struct renamings
- sokol_spine.h: (shaders, user needs to create sampler via sg_init_sampler() (similar to sg_init_image))
- sokol_gfx.h: remove err_ trace hook functions (redundant with new error logging)