Added spirv_vk output option (Vulkan-flavoured SPIRV for the upcoming
sokol-gfx Vulkan backend).
PR: floooh#196
-
Fixed an issue in the sokol-zig code generator for nested structs in ssbo objects.
Issue: floooh#197 PR: floooh#198
-
Merged new C2 code generation backend (many thanks to @Angluca!) (Note that the related sokol bindgen PR is still in flight)
PR: floooh#195
Minor update for the upcoming sokol-gfx 'dynamic resource limits' update:
- the max number of resource view bindslots has been bumped from 28 to 32
- the max number of sampler bindslots has been reduced from 16 to 12
This is the update for the sokol-gfx 'resource-view-update' (see sokol-gfx PR floooh/sokol#1287 and sokol-tools PR: floooh#187).
When recompiling your existing shaders you may get errors about bindslot collisions.
This is because the formerly separate bindslot ranges for textures, storage-buffers and storage-buffers have now been merged into a common 'view bindslot range'.
The N layout(binding=N) for textures, storage-images and storage-buffers
now directly maps to the index in the sg_bindings.views[] array which
defines the resource bindings for texture-, storage-image- and storage-buffer-
bindings.
For more detailed information, see the updated sokol-shdc documentation, and this blog post.
sokol-shdc can now write a Clang/GCC style dep-file via the new command line
options --dependency-file [path]. Many thanks to @Seb-degraff for the PR
(floooh#185).
This is the update for the sokol-gfx compute-ms2 update which adds storage
image support in compute shaders (if not using compute shaders the
code generator output is compatible with older sokol-gfx versions).
Other then that a minor bugfix: when using the bare or bare_yaml targets,
the output WGSL files didn't have a the .wgsl file extension (in fact: no
file extension at all).
All dependencies have been updated to the latest versions and the Tint sources are now pulled from https://github.com/floooh/tint-extract
Added a new cmdline arg --no-log-cmdline, this is useful when the code-generated
output files are committed to version control and sokol-shdc is called
with absolute input/output paths (since those will look different on each machine)
Write the 'vertex attribute base type' as part of the reflection info
in the code-generated sg_shader_desc. Requires the sokol update:
Implemented in PR: floooh#176
Add support for compute shaders.
See PR floooh#173
Related sokol PR: floooh/sokol#1200
- a new tag
@cs [name]to start a compute shader snippet - new output target
gles310es(not very useful so far because the sokol-gfx GLES3 backend only supports GLES3.0) - all code generators updated for compute shaders and new
sg_shader_descitems - documentation updated
- also see the related blog post
Update to the Odin code generator:
- now supports runtime reflection via
--reflectioncmdline arg - symbol names are prefixed with the optional
@moduletag - visibility for the embedded shader binary blobs changed to
@(private="file")
Many thanks to @keenanwoodall for the PR (floooh#172)!
GLSL v430 output will no longer remap storage buffer bindings to the slot range 0..15 but instead only use the slot range 0..7 (this is ok because sokol_gfx.h only allows to use up to 8 storage buffer bindings anyway). This change allows sokol_gfx.h to run on min-spec GL drivers that only allow the minimal number of storage buffer bindings (see sokol issue #1193 for details).
The binary distribution repo https://github.com/floooh/sokol-tools-bin now also
has a binary for ARM64 Linux under the path bin/linux_arm64/sokol-shdc).
Many thanks to @kassane for the PR (floooh#166)
Another minor regression fix: in the C code generator, attribute and bindslot
defines now include the @module tag again, this can be used to avoid name
conflicts across shader files.
See issue floooh#160 and PR floooh#161 for details!
Important regression fix: shaders which used textures/samplers both on the vertex-
and fragment-stage didn't code-generate the correct sg_shader_desc.image_sampler_pairs[]
array which then causes validation errors in sokol_gfx.h and general breakage when
using the GL backend.
See floooh#154 for details.
This is the sokol-shdc update going with the sokol-gfx 'bindings cleanup update':
- Input shader code now require explicit
layout(binding=N)annotations on uniform blocks, textures, samplers and storage buffers. - All code generators have been updated for the new
sg_shader_descstruct interior (this also affects the yaml generator output).
Associated PR: floooh#151
See also the sokol repository changelog for more details.
The Zig code generator (-f sokol_zig) now generates runtime reflection functions
when the cmdline arg --reflection is present.
See issue floooh#117 and PR floooh#147.
Many thanks to @Interrupt for the implementation!
Merged PR floooh#146 which adds more detailed
uniform block reflection info the the bare_yaml output's YAML file.
Many thanks to @Interrupt for the PR!
Fixed a regression for an 'undocumented feature' (matrix vertex attributes).
For details see issue floooh#141 and PR floooh#142.
Many thanks to @danielchasehooper for reporting the issue!
...and fixed another regression in the YAML reflection output. See PR floooh#143 for details.
Many thanks to @allcreater for the PR!
A Jai code generator has been added courtesy of @NEO97online (see PR floooh#137).
Fix a regression from the May-2024 refactoring:
Linking the same vertex shader in different programs would generate duplicate vertex attribute slot defines/constants. While this isn't a problem in C/C++, other languages would error on the duplicate constants.
With the fix, vertex attribute slot constants are now unique. There's also
a more tight validation in this new vertex attribute merge step which leads
to an error if a conflict is detected between two vertex attributes that should
be identical. This validation should never fail though, if it does, it would
point to an internal bug (the associated error message is conflicting vertex shader attributes found for '[snippet_name]/[attr_name]).
For more details see PR https://github.com/floooh/sokol-tools/pull/134/files and issue floooh#133.
- Minor fix in the Odin code generator (see: floooh#132)
- Merged PR floooh#130, this prints error messages to stderr instead of stdout.
- Fixed floooh#131, error message parsing was confused by the extra colon of absolute Windows path names.
Merged bugfix PR floooh#129, this fixes the discrepancy between a 'max storage buffers per shader stage' constant in sokol-shdc and sokol_gfx.h. Many thanks to @jdah for the fix!
A new code generator for the D language bindings via -f sokol_d. Note that the actual D bindings are
still WIP and haven't been released yet. Many thanks to @kassane for the initial D code generator!
A minor regression in the YAML output has been fixed (wrong indentation after storage blocks), see floooh#127 for details.
This sokol-shdc update goes along with the sokol_gfx.h 'storage buffer update'. It's now possible to access readonly Shader Storage Buffer Objects in shaders.
For a general overview about the new storage buffer feature and shader authoring tips, please see this blog post.
BREAKING CHANGES
- the target shading languages
glsl100andglsl330have been removed (glsl100 was overdue because GLES2 support was dropped quite a while ago in sokol_gfx.h, and it turned out that feeding glsl100 shaders into WebGL2 may cause some weird bugs: floooh#119 - the C code generation mode
sokol_declhas been removed
NEW FEATURES
- the target shading languages
glsl410andglsl430have been added.glsl430is needed for storage buffer support, andglsl410is needed as fallback on the macOS GL backend - it's now possible to declare and access (readonly) shader storage buffer objects in shaders
- ...along with code generation which exposes the interface block struct to the C side
BUG FIXES
- SPIRVCross errors are now properly surfaced by enabling C++ exceptions, catching them and converting them into proper errors and warnings. Previously when SPIRVCross emitted an error, sokol-shdc appeared to have crashed (see for instance: floooh#124)
- line numbers for errors and warnings are now correct again (floooh#103)
- a couple of smaller code generation bugs in the CPU language generators have been fixed
OTHER CHANGES
A massive refactoring which touches almost all code, for the following reasons:
- extracting reflection information now gets the proper 'code focus' it deserves, and hopefully adding new reflection features will become easier in the future
- CPU language code generators have been entirely restructured. Those are now subclasses
of a
Generatortoplevel class which calls smaller-scale virtual methods in subclasses, while I'm usually not a big fan of such an OOP style approach, it gives a better idea what code needs to be written for adding a new output language, and it also saves a couple hundred lines per code generator. - the code which decorates matrices as column-major has been removed, this seems to be a no-op (tbh I don't remember why this code existed in the first place, it might have been required in a very old SPIRVCross versions, or simply a brainfart on my part)
Unfortunately such a big refactoring might also have introduced new bugs and regressions.
In that case, please don't hesitate to write tickets: https://github.com/floooh/sokol-tools/issues
Fixed a confusing behaviour when writing conditional shader code via
#if vs #ifdef. Previously, when a shader is compiled it would get
an implicit definition block at the start looking like this:
#define SOKOL_GLSL (1)
#define SOKOL_HLSL (0)
#define SOKOL_MSL (0)
#define SOKOL_WGSL (0)
...meaning an #ifdef would always trigger and only #if had worked.
Now only the define for the current output language is present, so that
both #if and #ifdef works.
Fix a reflection parsing regression that was introduced in the last update (see: floooh#109).
The fix avoids having to deal with 'dummy samplers' when parsing reflection information for HLSL, WGSL and MSL by using a common GLSL output for parsing reflection data instead of using the HLSL, WGSL and MSL output.
PR: floooh#110
NOTE: this update is required for WebGPU backend update of sokol-gfx!
This update officially introduces WGSL output for the sokol-gfx WebGPU backend
via -f wgsl.
Two new 'meta-tags' have been added to provide texture- and sampler-hints for WebGPU which can't be inferred from the shader code:
@image_sample_type [tex] [type]: provides an image-sample-type hint for the
texture named tex, corresponds with the sokol_gfx.h type
sg_image_sample_type and the WebGPU type WGPUTextureSampleType. Valid
values for [type] are: float, unfilterable_float, sint, uint and
depth.
@sampler_type [smp] [type]: provides a sampler-type hint for the
sample named smp, corresponds with the sokol_gfx.h type sg_sampler_type
and the WebGPU type WGPUSamplerBindingType. Valid values for [type] are:
filtering, nonfiltering and comparison.
Those tags are only needed for unfilterable_float / nonfiltering texture/sampler
combinations (this is the only combination that can't be inferred from the shader
code). Unfilterable textures commonly have a floating point pixel format.
For instance in the ozz-skin-sapp sampler shader code, the skinning matrix texture and sampler need the following annoations:
@image_sample_type joint_tex unfilterable_float
@sampler_type smp nonfiltering
uniform texture2D joint_tex;
uniform sampler smp;Addition changes:
- Some type-to-string conversion result strings have changed for consistency,
this may leak into the
bare_yamloutput files. - A lot of the bind slot allocation and the 'reflection parsing' code has changed, and this area also has unfortunately become more complex, which result in more brittleness. This may result in new errors with non-trivial shader code. Please report any issues you encounter (https://github.com/floooh/sokol-tools/issues)
NOTE: this update is required for the image/sampler object split in sokol-gfx, and in turn it doesn't work with older sokol-gfx versions (use the git tag
pre-separate-samplersif you need to stick to the older version)
-
input shader source code must now be written in Vulkan-GLSL-style with separate texture and sampler uniforms, this means that old code like this:
uniform sampler2D tex; void main() { frag_color = texture(tex, uv); }
...needs to be rewritten to look like this:
uniform texture2D tex; uniform sampler smp; void main() { frag_color = texture(sampler2D(tex, smp), uv); }
-
the code-generation has been updated for the new 'separate image and sampler objects' sokol-gfx update
-
sokol-shdc will now emit an error if it encounters 'old' OpenGL-GLSL-style code with combined image samplers
-
the Google Tint library has been integrated to convert the SPIRV output from
glslangto WGSL source code -
the output language option
wgpuhas been renamed towgsl -
preliminary support for WGSL output has been added
-
output for GLSL100 (GLES2) is still supported but has been deprecated
- set CMAKE_OSX_DEPLOYMENT_TARGET to allow running sokol-shdc on older macOS versions
- Nim backend: write addr() instead of deprecated unsafeAddr()
- add a --save-intermediate-spirv cmdline option
- update all Khronos dependencies to 1.3.246.1
- disable line directives for good
- add a --nolinedirectives cmdline option which omits the #line debug mapping statements
- update external dependencies to latest versions
- bump ios-metal version to 1.1 (1.0 is deprecated and doesn't fma() which is now emitted by SPIRVCross)
- added a Rust backend (many thank to @ErikWDev!)
...
-
30-Jul-2022:
- BREAKING CHANGE: renamed the
@cimporttag to@header, and change behaviour so that it inserts the literal text after@headerbefore the generated code (e.g. no more target-language specific behaviour) - Added an Odin code generator for the official Odin bindings (https://github.com/floooh/sokol-odin)
- BREAKING CHANGE: renamed the
-
14-Jun-2022:
- initial Nim support for use with the sokol-nim bindings
- new tag:
@cimportto pull in C headers, or Zig and Nim modules
-
07-Jan-2022:
- support for additional uniform types:
- int => SG_UNIFORMTYPE_INT
- ivec2 => SG_UNIFORMTYPE_INT2
- ivec3 => SG_UNIFORMTYPE_INT3
- ivec4 => SG_UNIFORMTYPE_INT4
- add support for mixed-type uniform blocks, those will not be flattened for the output GLSL dialects
- stricter checks for allowed types in uniform blocks (e.g. arrays are only allowed for vec4, ivec4 and mat4)
- support for additional uniform types:
-
01-Jul-2021:
- A new command line option
--reflectionwhich adds a small set of runtime introspection functions to the generated code (currently only in the C code generator) - A new command line option
--definesto pass a combination of preprocessor defines to the GLSL compilation pass, this can be used to stamp out different 'variations' from the same GLSL source file - A new command line option
--modulewhich allows to define or override the@modulename from the command line. This is useful in combination with the new--definesoption to make type- and function-names generated from the same source file unique.
- A new command line option
-
10-Feb-2021:
- the C code generator has been updated for the latest API-breaking-changes in sokol_gfx.h
- the generated function which returns an initialized sg_shader_desc struct
now takes an input parameter to select the backend-specific code instead
of calling the
sg_query_backend()function - a code generator for the sokol-zig bindings has been
added, used with
--format sokol_zig
-
03-Oct-2020: The command line option
--noifdefis now obsolete (but still accepted) and has been replaced with--ifdef. The default behaviour is now to not wrap the generated platform specific code with ifdefs. If you rely on that behaviour, call sokol-shdc with the new--ifdefflag.