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: finalize wgpu backend #865

Merged
merged 99 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
858f612
sokol_gfx.h: wgpu update wip
floooh Jul 30, 2023
2083a4b
sokol_gfx.h: wgpu update wip
floooh Jul 30, 2023
fee8b6f
sokol_gfx.h: wgpu update wip
floooh Jul 31, 2023
d551b7a
sokol_gfx.h: wgpu update wip
floooh Aug 1, 2023
ff67fdb
sokol_gfx wgpu: implement create/discard buffer
floooh Aug 2, 2023
a05f17f
sokol_gfx wgpu: initialize limits from actual wgpu limits
floooh Aug 2, 2023
30824cc
sokol_gfx wgpu: create shader module and bind group
floooh Aug 3, 2023
ab45253
sokol_gfx wgpu: create/destroy render pipeline
floooh Aug 7, 2023
3634c90
sokol_gfx wgpu: implement sg_apply_bindings()
floooh Aug 12, 2023
893ba7b
sokol_gfx.h wgpu: code cleanup and remove uniform buffer conveyor belt
floooh Aug 13, 2023
fbdae16
sokol_gfx.h wgpu: implement sg_apply_uniforms()
floooh Aug 13, 2023
96c6911
sokol_gfx.h wgpu: implement image create/destroy
floooh Aug 14, 2023
dc250eb
sokol_gfx.h wgpu: implement sampler create/destroy
floooh Aug 14, 2023
233f688
sokol_gfx.h wgpu: implement pass create/destroy
floooh Aug 15, 2023
7906e70
sokol_gfx.h wgpu: fix pipeline desc linked struct lifetimes doh
floooh Aug 15, 2023
0341168
sokol_gfx.h wgpu: implement sg_update_buffer
floooh Aug 17, 2023
97fafac
sokol_gfx.h wgpu: implement sg_update_image
floooh Aug 19, 2023
61d36f2
sokol_gfx.h wgpu: implement sg_append_buffer
floooh Aug 20, 2023
3f00bf3
sokol_gfx.h wgpu: fix buffer updates for sizes not multiple of 4
floooh Aug 21, 2023
d2d6d47
sokol_gfx.h wgpu: fix injected samplers, expose some wgpu objects in …
floooh Aug 21, 2023
6a7a6b3
sokol_gfx.h wgpu: rewrite image/sampler binding use single bindgroup …
floooh Aug 25, 2023
4a2e174
sokol_gfx.h wgpu: minor cleanup
floooh Aug 26, 2023
8d7460c
sokol_gfx.h metal: remove redundant frame_index in _sg_mtl_backend_t
floooh Aug 27, 2023
692a389
sokol_gfx.h wgpu: workaround missing return value of Emscripten's wgp…
floooh Aug 27, 2023
7e4c532
sokol_gfx.h wgpu: change SG_PIXELFORMAT_DEPTH_STENCIL to WGPUTextureF…
floooh Aug 28, 2023
fb3b4ef
sokol_gfx.h: fix wgpu initialization and frame loop
floooh Aug 28, 2023
e4bf816
sokol_gfx.h wgpu: fix wrong SG_VERTEXFORMAT_USHORT2N mapping
floooh Aug 28, 2023
f750e22
sokol_app.h emsc: revert _sapp.html5_canvas_selector => _sapp.emsc.ca…
floooh Aug 28, 2023
76fcf8d
Merge branch 'master' into sgfx-wgpu
floooh Aug 28, 2023
e453b77
sokol_gfx.h: harmonize sg_sampler_type names with webgpu
floooh Aug 30, 2023
eeb975c
sg_sampler_type renaming fixes
floooh Aug 31, 2023
f697ca3
sokol_debugtext.h: fix embedded wgsl shader
floooh Sep 2, 2023
9d18ccc
sokol_gfx.h wgpu: fix 3d texture view arrayLayerCount
floooh Sep 2, 2023
08e258a
sokol_app.h, sokol_gfx.h wgpu: support bc and etc2 compressed texture…
floooh Sep 2, 2023
7008ca1
sokol_gfx.h wgpu: in _sg_wgpu_copy_image_data() round up mip width/he…
floooh Sep 2, 2023
465a795
sokol_gl.h: fix embedded wgsl shader
floooh Sep 2, 2023
c703ece
sokol_fontstash.h wgpu: fix embedded shader
floooh Sep 3, 2023
561eec0
sokol_imgui.h wgpu: fix embedded shader
floooh Sep 3, 2023
21b4cb1
sokol_gfx_imgui.h: fix missing sokol-gfx wgpu backend string
floooh Sep 3, 2023
915214d
sokol_gfx.h wgpu: fix memory clearing bug in bind group layout setup
floooh Sep 3, 2023
bd96188
sokol_nuklear.h: fix embedded wgsl shaders
floooh Sep 3, 2023
7fdfefe
sokol_spine.h: fix embedded wgsl shader
floooh Sep 3, 2023
38eee79
sokol_gfx.h wgpu: fix pixel format caps
floooh Sep 4, 2023
8b49fa7
sokol_gfx.h: new sg_sampler_desc validation: max_anistropy > 1 requir…
floooh Sep 4, 2023
6474978
sokol_gfx tests: add sampler-desc validation tests
floooh Sep 4, 2023
6fe8f03
sokol_gfx.h: validate image sample type vs sampler type in sg_shader_…
floooh Sep 5, 2023
e5f5d95
sokol_gfx.h: image sample type and sampler type validation in sg_appl…
floooh Sep 5, 2023
b6ab80f
fix sokol-gfx tests
floooh Sep 6, 2023
2d9e4bf
sokoL_imgui.h: allow unfilterable user images
floooh Sep 7, 2023
7f275df
Merge branch 'master' into sgfx-wgpu
floooh Sep 9, 2023
c98be28
sokol_gfx.h: fix cubemap creation
floooh Sep 9, 2023
681eb78
sokol_gfx.h wgpu: add a fixme comment in _sg_wgpu_apply_uniforms()
floooh Sep 11, 2023
f6bdb52
sokol_gfx.h wgpu: call wgpuBufferDestroy and wgpuTextureDestroy befor…
floooh Sep 12, 2023
dd4c3cf
sokol_gfx.h wgpu: don't issue redundant vertex- and index-buffer bind…
floooh Sep 12, 2023
f6a2bfd
sokol_gfx.h wgpu: only do one writeBuffer per frame for uniform data
floooh Sep 16, 2023
e0e8880
sokol_gfx.h wgpu: better naming for the intermediate uniform staging …
floooh Sep 16, 2023
573c566
sokol_gfx.h wgpu: bindgroup cache wip
floooh Sep 26, 2023
fff648f
sokol_gfx.h wgpu: bindgroup cache wip
floooh Sep 27, 2023
daf519e
sokol_gfx.h wgpu: implement internal bindgroup resource pool
floooh Sep 30, 2023
59bf444
sokol_gfx.h: simplify bindings code across all backends
floooh Sep 30, 2023
60cb9f4
sokol_gfx.h d3d11: fix compile errors
floooh Sep 30, 2023
7e15e72
sokol_gfx.h wgpu: implement bindgroups cache
floooh Sep 30, 2023
1b9f90b
sokol_gfx.h wgpu: fix C++ compile problem, and a memory corruption in…
floooh Sep 30, 2023
fcfda2e
sokol_gfx.h: start implementing frame stats tracking
floooh Oct 1, 2023
c2a5d97
sokol_gfx.h wgpu: webgpu specific frame stats
floooh Oct 1, 2023
79f70be
sokol_gfx.h: fix msvc errors
floooh Oct 1, 2023
2754f96
sokol_gfx_imgui.h: add helper function sg_imgui_draw_menu()
floooh Oct 2, 2023
4331539
sokol_gfx_imgui.h: tweak function call colors
floooh Oct 2, 2023
4f41feb
sokol_gfx.h: code cleanup
floooh Oct 2, 2023
94321b2
sokol_gfx_imgui.h: add frame stats window
floooh Oct 2, 2023
1043989
sokol_gfx.h: frame stats code cleanup
floooh Oct 2, 2023
66abd12
sokol_gfx_imgui.h: allow to ignore sokol_imgui.h frame stats
floooh Oct 2, 2023
776dfbd
sokol_gfx.h metal: add frame stats counters
floooh Oct 2, 2023
f9e62ce
sokol_gfx.h wgpu: stats tracking cleanup
floooh Oct 2, 2023
b2db2d5
sokol_gfx_imgui.h: stats tracking panel cleanup
floooh Oct 2, 2023
4418399
sokol_gfx.h gl: add frame stats
floooh Oct 2, 2023
43be6e7
sokol_gfx_imgui.h: add gl stats to frame stats panel
floooh Oct 2, 2023
a61ae2d
sokol_gfx.h d3d11: add d3d11 specific frame stats
floooh Oct 3, 2023
df394f8
sokol_gfx_imgui.h: add d3d11 frame stats to stats panel
floooh Oct 3, 2023
9a1421d
Merge branch 'master' into sgfx-wgpu
floooh Oct 3, 2023
639c202
add webgpu compilation tests
floooh Oct 3, 2023
e81a05e
sokol_app.h: fix comment typo
floooh Oct 3, 2023
88d03f5
sokol_gfx.h gl: enable GL_TEXTURE_CUBE_MAP_SEAMLESS (see #910)
floooh Oct 4, 2023
ca02b4a
sokol_gfx.h metal, wgpu: unify scissor rect clipping, wgpu: add viewp…
floooh Oct 5, 2023
dff7059
sokol_gfx.h wgpu: fix 3d texture view creation, use aspect DepthOnly …
floooh Oct 8, 2023
61675b5
sokol_gfx.h wgpu: fix ETC2 texture compression support
floooh Oct 8, 2023
be548e5
sokol_gfx.h wgpu: fix array texture creation
floooh Oct 8, 2023
06ea82c
sokol_gfx.h wgpu: cleanup comments and wgpu bindings cache code
floooh Oct 9, 2023
d5e986c
sokol_gfx_imgui.h: fixes for sokol_gfx.h stats member renames
floooh Oct 9, 2023
4e0d7ce
sokol_gfx.h wgpu: fix wgpu sampler not being released when destroyed
floooh Oct 9, 2023
f2ca0cf
sokol_gfx.h wgpu: fix empty image-sampler bindings behaviour
floooh Oct 9, 2023
1378711
sokol_gfx.h wgpu: support SRGB8A8 and RGB9E5 pixel formats
floooh Oct 16, 2023
9a4cd05
sokol_gfx.h wgpu: start adding WebGPU backend details to the document…
floooh Oct 19, 2023
ed51699
sokol_gfx.h: add a WEBGPU CAVEATS documentation section
floooh Oct 21, 2023
eaa6075
sokol_gfx.h: add details to sg_image_sample_type and sg_sampler_type …
floooh Oct 21, 2023
e05c848
sokol_gfx.h: more documentation updates
floooh Oct 21, 2023
0f71047
update changelog
floooh Oct 21, 2023
61c40b7
update readme and changelog
floooh Oct 21, 2023
cf0df6b
Merge branch 'master' into sgfx-wgpu
floooh Oct 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,102 @@
## Updates

#### 21-Oct-2023

The major topic of this update is the 'finalized' WebGPU support in sokol_gfx.h and sokol_app.h.

- WebGPU samples are hosted here:

https://floooh.github.io/sokol-webgpu/

- WebGL2 samples remain hosted here:

https://floooh.github.io/sokol-html5/

- Please read the following blog post as introduction:

https://floooh.github.io/2023/10/16/sokol-webgpu.html

- ...and the changelog and updated documentation in the sokol-shdc repository:

https://github.com/floooh/sokol-tools

- You'll also need to update the sokol-shdc binaries:

https://github.com/floooh/sokol-tools-bin

- Please also read the following new or updated sections in the embedded sokol_gfx.h header documentation:

- `ON SHADER CREATION`
- `ON SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT AND SG_SAMPLERTYPE_NONFILTERING`
- `WEBGPU CAVEATS`

Please do this especially when using any of the following texture pixel formats, as you will most likely encounter new validation layer errors:

- `SG_PIXELFORMAT_R32F`
- `SG_PIXELFORMAT_RG32F`
- `SG_PIXELFORMAT_RGBA32F`

- There is a tiny breaking change in the sokol_gfx.h API (only requires action when not using sokol-shdc):

- the following `sg_sampler_type` enum items have been renamed to better match their WebGPU counterparts:
- SG_SAMPLERTYPE_SAMPLE => SG_SAMPLERTYPE_FILTERING
- SG_SAMPLERTYPE_COMPARE => SG_SAMPLERTYPE_COMPARISON

- the enum `sg_image_sample_type` gained a new item:
- SG_IMAGESAMPLETYPE_UNFILTERABLE_FLOAT

- the enum `sg_sampler_type` gained a new item:
- SG_SAMPLERTYPE_NONFILTERING

- The sokol_gfx.h struct `sg_desc` has two new items:
- `.wgpu_bindgroups_cache_size` - must be power-of-2, default: 1024
- `.wgpu_disable_bindgroups_cache` - default: false

- sokol_gfx.h gained the following new public API functions to query per-frame information:
- `sg_frame_stats sg_query_frame_stats()`
- `void sg_enable_frame_stats(void)`
- `void sg_disable_frame_stats(void)`
- `bool sg_frame_stats_enabled(void)`

Frame statistics gathering is enabled after startup, but can be temporarily
disabled and enabled again via `sg_disable_frame_stats()` and `sg_enable_frame_stats`.

- The sokol_gfx.h validation layer has new validation checks in `sg_make_shader()`
regarding image/sampler pair compatibility (WebGPU is particularly strict about
this stuff).

- In sokol_app.h, the old wip WebGPU device and swapchain setup code is now implemented
in pure C code (previously this was a mix of Javascript and C).

- Also note that sokol_app.h currently only supports WebGPU in the Emscripten backend.
If you want to use sokol_gfx.h with the WebGPU backend in a native scenario, you'll have
to use a different window system glue library (like GLFW). The sokol-samples directory
has a handful of examples for using sokol_gfx.h + Dawn + GLFW.

- The following headers have been made compatible with the sokol_gfx.h WebGPU backend
(mainly by embedding WGSL shader code):
- sokol_debugtext.h
- sokol_fontstash.h
- sokol_gl.h
- sokol_spine.h
- sokol_imgui.h (also required some more changes for embedding `unfilterable-float`
textures, since these now require separate shader and pipeline objects)
- sokol_nuklear.h (works in WebGPU, but doesn't contain the work from sokol_imgui.h
to support `unfilterable-float` user textures)

- sokol_gfx_imgui.h gained a new function `sg_imgui_draw_menu()` which renders a
menu panel to show/hide all debug windows. Previously this had to be done
outside the header.

- sokol_gfx_imgui.h gained a new 'frame stats' window, which allows to peak into
sokol_gfx.h frame-rendering internals. This basically visualizes the struct
`sg_frame_stats` returned by the new sokol_gfx.h function `sg_query_frame_stats()`.

- The sokol-samples repository gained 3 new samples:
- cubemap-jpeg-sapp.c (load a cubemap from seperate JPEG files)
- cubemaprt-sapp.c (render into cubemap faces - this demo actually existed a while but wasn't "official" so far)
- drawcallperf-sapp.c (a sample to explore the performance overhead of sg_apply_bindings, sg_apply_uniforms and sg_draw)

#### 03-Oct-2023

- sokol_app.h win/gl: PR https://github.com/floooh/sokol/pull/886 has been merged, this makes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Simple
[STB-style](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt)
cross-platform libraries for C and C++, written in C.

[**See what's new**](https://github.com/floooh/sokol/blob/master/CHANGELOG.md) (**25-Sep-2023** POTENTIALLY BREAKING: allocator callbacks have been renamed)
[**See what's new**](https://github.com/floooh/sokol/blob/master/CHANGELOG.md) (**21-Oct-2023** WebGPU!)

[![Build](/../../actions/workflows/main.yml/badge.svg)](/../../actions/workflows/main.yml) [![Bindings](/../../actions/workflows/gen_bindings.yml/badge.svg)](/../../actions/workflows/gen_bindings.yml) [![build](https://github.com/floooh/sokol-zig/actions/workflows/main.yml/badge.svg)](https://github.com/floooh/sokol-zig/actions/workflows/main.yml) [![build](https://github.com/floooh/sokol-nim/actions/workflows/main.yml/badge.svg)](https://github.com/floooh/sokol-nim/actions/workflows/main.yml) [![Odin](https://github.com/floooh/sokol-odin/actions/workflows/main.yml/badge.svg)](https://github.com/floooh/sokol-odin/actions/workflows/main.yml)[![Rust](https://github.com/floooh/sokol-rust/actions/workflows/main.yml/badge.svg)](https://github.com/floooh/sokol-rust/actions/workflows/main.yml)

Expand Down
Loading
Loading