Skip to content

Commit

Permalink
Merge pull request #120 from floooh/storage-buffers
Browse files Browse the repository at this point in the history
Prepare sokol-shdc for storage buffer support.
  • Loading branch information
floooh authored May 9, 2024
2 parents 6362c8f + a4eae43 commit 2cac6cf
Show file tree
Hide file tree
Showing 93 changed files with 7,202 additions and 5,390 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build debug
Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: macos-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build debug
Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build debug
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
runs-on: windows-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build
run: |
python3 fips set local on
python3 fips build win64-vstudio-release
- name: upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: win64-vstudio-release
path: fips-files/deploy/sokol-tools/win64-vstudio-release/sokol-shdc.exe
Expand All @@ -24,15 +24,15 @@ jobs:
runs-on: macos-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build
run: |
python3 fips set local on
python3 fips build osx-x64-ninja-release
- name: upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-x64-ninja-release
path: fips-files/deploy/sokol-tools/osx-x64-ninja-release/sokol-shdc
Expand All @@ -41,29 +41,29 @@ jobs:
runs-on: macos-latest
steps:
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build
run: |
python3 fips set local on
python3 fips build osx-arm64-ninja-release
- name: upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: osx-arm64-ninja-release
path: fips-files/deploy/sokol-tools/osx-arm64-ninja-release/sokol-shdc
retention-days: 1
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: build
run: ./build_docker.sh
- name: upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux-ninja-release
path: sokol-shdc
Expand All @@ -72,23 +72,23 @@ jobs:
needs: [windows, mac_intel, mac_arm, linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: floooh/sokol-tools-bin
ssh-key: ${{ secrets.GHACTIONS_PUSH }}
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: win64-vstudio-release
path: bin/win32
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: osx-x64-ninja-release
path: bin/osx
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: osx-arm64-ninja-release
path: bin/osx_arm64
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: linux-ninja-release
path: bin/linux
Expand Down
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
CHANGELOG
=========

#### **07-May-2024**

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](https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object)
in shaders.

For a general overview about the new storage buffer feature and shader authoring tips,
please see [this blog post](https://floooh.github.io/2024/05/06/sokol-storage-buffers.html).

**BREAKING CHANGES**

- the target shading languages `glsl100` and `glsl330` have 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: https://github.com/floooh/sokol-tools/issues/119
- the C code generation mode `sokol_decl` has been removed


**NEW FEATURES**

- the target shading languages `glsl410` and `glsl430` have been added. `glsl430` is needed for
storage buffer support, and `glsl410` is 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: https://github.com/floooh/sokol-tools/issues/124)
- line numbers for errors and warnings are now correct again (https://github.com/floooh/sokol-tools/issues/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 `Generator` toplevel 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

#### **12-Feb-2024**

Fixed a confusing behaviour when writing conditional shader code via
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ project(sokol-tools)
get_filename_component(FIPS_ROOT_DIR "../fips" ABSOLUTE)
include("${FIPS_ROOT_DIR}/cmake/fips.cmake")

set(FIPS_EXCEPTIONS ON)
set(FIPS_RTTI ON)

fips_setup()
if (FIPS_CLANG OR FIPS_GCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ https://github.com/floooh/sokol-tools-bin
#### Tool prerequisites:
```
> python --version
2.x or 3.x
3.x
> cmake --version
3.x
# optional:
Expand Down Expand Up @@ -117,4 +117,4 @@ Many thanks to:
- https://github.com/KhronosGroup/SPIRV-Cross
- https://github.com/KhronosGroup/SPIRV-Tools.git
- https://github.com/KhronosGroup/SPIRV-Headers

- https://dawn.googlesource.com/tint
28 changes: 13 additions & 15 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ const common_flags = [_][]const u8{
"-fstrict-aliasing",
};
const common_c_flags = common_flags;
const common_cpp_flags = common_flags ++ [_][]const u8{
"-fno-rtti",
"-fno-exceptions",
};
const common_cpp_flags = common_flags;

const spvcross_public_cpp_flags = [_][]const u8{
"-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS",
};
const spvcross_public_cpp_flags = [_][]const u8{};

const tint_public_cpp_flags = [_][]const u8{
"-DTINT_BUILD_SPV_READER",
Expand All @@ -32,21 +27,24 @@ pub fn build_exe(
const dir = prefix_path ++ "src/shdc/";
const sources = [_][]const u8{
"args.cc",
"bare.cc",
"bytecode.cc",
"input.cc",
"main.cc",
"sokol.cc",
"sokolnim.cc",
"sokolodin.cc",
"sokolrust.cc",
"sokolzig.cc",
"reflection.cc",
"spirv.cc",
"spirvcross.cc",
"util.cc",
"yaml.cc",
"generators/bare.cc",
"generators/generate.cc",
"generators/generator.cc",
"generators/sokolc.cc",
"generators/sokolnim.cc",
"generators/sokolodin.cc",
"generators/sokolrust.cc",
"generators/sokolzig.cc",
"generators/yaml.cc",
};
const incl_dirs = [_][]const u8{
"src/shdc",
"ext/fmt/include",
"ext/SPIRV-Cross",
"ext/pystring",
Expand Down
Loading

0 comments on commit 2cac6cf

Please sign in to comment.