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

sokol_gfx.h: introduce separate sampler objects #842

Merged
merged 92 commits into from
Jul 17, 2023
Merged

Conversation

floooh
Copy link
Owner

@floooh floooh commented Jun 19, 2023

Add separate sampler objects, some additional renaming (more in line with WebGPU conventions).

TODO:

  • sokol-zig:
    • merge zig-0.11.0 branch into master, required to make the if (@available(...)) stuff work with Zig
    • sokol bindgen: merge the bindgen-sokol-zig-0.11.0 into sgfx-samplers-bindings
  • fix samples webpage
  • create tags pre-separate-samplers in:
    • sokol
    • sokol-tools
    • sokol-tools-bin
    • sokol-samples
    • sokol-zig
    • sokol-nim
    • sokol-odin
    • sokol-rust
  • changelog updates
    • sokol-shdc
    • sokol
    • blog post?
  • 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...
  • fix sokol-shdc tests
  • don't allow to override the sampler object in sokol_imgui.h (because ImTextureID is 32-bits on WASM)
  • don't allow to override the sampler object in sokol_nuklear.h (because nk_handle is 32-bits on WASM)
  • fix iOS Metal backend errors
  • extend Windows GL loader with new sampler functions
  • fix dummy backend
  • extend sokol-gfx tests for sampler objects
  • fix all the other tests (sokol-spine etc)
  • allow depth-only rendering:
    • _sg_validate_pass_desc()
    • sg_make_pipeline() => .colors[0].pixel_format = SG_PIXELFORMAT_NONE
    • _sg_mtl_create_pipeline()
    • _sg_gl_create_pipeline()
    • _sg_d3d11_create_pipeline()
    • _sg_mtl_create_pass()
    • _sg_gl_create_pass()
    • _sg_d3d11_create_pass()
    • sg_begin_pass() => don't take width/height from first color attachment
    • _sg_mtl_begin_pass()
    • _sg_gl_begin_pass()
    • _sg_d3d11_begin_pass()
  • new sample which samples depth texture with a comparison sampler
    • macOS/Metal
    • macOS/GL
    • iOS/Metal
    • iOS/GL (something unrelated seems to be broken currently with iOS/GL on the simulator)
    • Windows/D3D11
    • Windows/GL
    • Linux/GL
    • Linux/GLES3
    • Android/GLES3
    • 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
    • sokol_gl.h
    • sokol_debugtext.h (no public API changes)
    • sokol_fontstash.h (no public API changes)
    • sokol_spine.h
    • sokol_imgui.h
    • sokol_nuklear.h
    • sokol_shape.h
    • sokol_gfx_imgui.h
  • fix util headers (except hlsl shaders):
    • sokol_debugtext.h
    • sokol_fontstash.h
    • sokol_gl.h
    • sokol_imgui.h
    • sokol_nuklear.h
    • sokol_spine.h
    • sokol_shape.h
    • sokol_gfx_imgui.h
  • update hlsl shaders in:
    • sokol_debugtext.h
    • sokol_fontstash.h
    • sokol_gl.h
    • sokol_imgui.h
    • sokol_nuklear.h
    • sokol_spine.h
  • fix samples:
    • d3d11
    • glfw
    • html5
    • metal
    • sapp
  • fix sokol-shdc backends:
    • zig
    • odin
    • nim
    • rust
    • bare
    • ...?
  • fix language bindings (also special case names):
    • sokol-zig
    • sokol-odin
    • sokol-nim
    • sokol-rust
  • fix language bindings samples:
    • sokol-zig
    • sokol-odin
    • sokol-nim
    • 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_mode config 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)

floooh added 30 commits May 29, 2023 11:19
@floooh floooh mentioned this pull request Jul 10, 2023
@floooh floooh marked this pull request as ready for review July 17, 2023 17:46
@floooh floooh changed the title [Draft] sokol_gfx.h: introduce separate sampler objects sokol_gfx.h: introduce separate sampler objects Jul 17, 2023
@floooh floooh merged commit 8bed164 into master Jul 17, 2023
18 checks passed
@floooh floooh deleted the sgfx-samplers-bindings branch July 17, 2023 18:12
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.

3 participants