Skip to content

Commit d2bfd3f

Browse files
committed
replace opengl with webgpu/dawn
1 parent beabf6a commit d2bfd3f

File tree

188 files changed

+5764
-7731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+5764
-7731
lines changed

.github/workflows/codeql.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
2323
- name: Checkout repository
2424
uses: actions/checkout@v4
25-
with:
26-
submodules: recursive
2725

2826
- name: Initialize CodeQL
2927
uses: github/codeql-action/init@v2

.github/workflows/tests.yml

Lines changed: 50 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ jobs:
3131
git --version
3232
3333
- uses: actions/checkout@v4
34-
with:
35-
submodules: recursive
3634

3735
- name: Configure
3836
shell: bash
@@ -59,17 +57,6 @@ jobs:
5957
cd build/result/${{ matrix.build-config }}
6058
./cage-asset-database
6159
62-
- name: Install
63-
shell: bash
64-
run: |
65-
cd build
66-
cmake --install . --config ${{ matrix.build-config }} --prefix "C:/cage"
67-
cd ../sources/test-install
68-
mkdir build
69-
cd build
70-
cmake -A${{ matrix.build-arch }} ${{ matrix.build-tool }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} -DCage_DIR="C:/cage/cmake" ..
71-
cmake --build . --config ${{ matrix.build-config }}
72-
7360
7461
Ubuntu:
7562
name: ubuntu-${{ matrix.os-version }}${{ matrix.build-arch }}-${{ matrix.build-config }}-${{ matrix.compiler.cc }}-${{ matrix.steam-sockets }}
@@ -84,11 +71,6 @@ jobs:
8471
build-arch: ["", "-arm"]
8572
build-config: [debug, release]
8673
compiler:
87-
- {
88-
cc: gcc-13,
89-
cxx: g++-13,
90-
install: gcc-13 g++-13
91-
}
9274
- {
9375
cc: gcc-14,
9476
cxx: g++-14,
@@ -124,8 +106,6 @@ jobs:
124106
${{ matrix.compiler.cxx }} --version
125107
126108
- uses: actions/checkout@v4
127-
with:
128-
submodules: recursive
129109

130110
- name: Configure
131111
run: |
@@ -148,23 +128,66 @@ jobs:
148128
cd build/result/${{ matrix.build-config }}
149129
./cage-asset-database
150130
151-
- name: Install
131+
- name: List dependencies
132+
run: |
133+
cd build/result/${{ matrix.build-config }}
134+
echo "cage-core:"
135+
ldd libcage-core.so
136+
echo "cage-engine:"
137+
ldd libcage-engine.so
138+
139+
140+
MacOS:
141+
name: macos-${{ matrix.os-version }}-${{ matrix.build-config }}
142+
runs-on: macos-${{ matrix.os-version }}
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
os-version: [15]
147+
build-config: [debug, release]
148+
149+
steps:
150+
- name: Install packages
151+
run: |
152+
brew install nasm
153+
154+
- name: Versions
155+
run: |
156+
cmake --version
157+
git --version
158+
clang --version
159+
clang++ --version
160+
161+
- uses: actions/checkout@v4
162+
163+
- name: Configure
152164
run: |
153-
cd build
154-
sudo cmake --install .
155-
cd ../sources/test-install
156165
mkdir build
157166
cd build
158167
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} ..
159-
cmake --build . -- -j$(( `nproc` + 1 ))
168+
169+
- name: Build
170+
run: |
171+
cd build
172+
cmake --build . -- -j$(( `sysctl -n hw.ncpu` + 1 ))
173+
174+
- name: Tests
175+
run: |
176+
cd build/result/${{ matrix.build-config }}
177+
./cage-test-core
178+
179+
- name: Assets
180+
run: |
181+
cd build/result/${{ matrix.build-config }}
182+
./cage-asset-database
160183
161184
- name: List dependencies
162185
run: |
163186
cd build/result/${{ matrix.build-config }}
164187
echo "cage-core:"
165-
ldd libcage-core.so
188+
otool -L libcage-core.dylib
166189
echo "cage-engine:"
167-
ldd libcage-engine.so
190+
otool -L libcage-engine.dylib
168191
169192
170193
NoProfiler:
@@ -184,8 +207,6 @@ jobs:
184207
sudo apt-get install -y xorg-dev libwayland-dev libxkbcommon-dev libpulse-dev libasound2-dev nasm libssl-dev
185208
186209
- uses: actions/checkout@v4
187-
with:
188-
submodules: recursive
189210

190211
- name: Configure
191212
run: |
@@ -246,8 +267,6 @@ jobs:
246267
clang++ --version
247268
248269
- uses: actions/checkout@v4
249-
with:
250-
submodules: recursive
251270

252271
- name: Configure
253272
run: |
@@ -265,53 +284,3 @@ jobs:
265284
run: |
266285
cd build/result/${{ matrix.build-config }}
267286
./cage-test-core
268-
269-
270-
MacOS:
271-
name: macos-${{ matrix.os-version }}-${{ matrix.build-config }}
272-
runs-on: macos-${{ matrix.os-version }}
273-
strategy:
274-
fail-fast: false
275-
matrix:
276-
os-version: [14, 15]
277-
build-config: [debug, release]
278-
279-
steps:
280-
- name: Install packages
281-
run: |
282-
brew install nasm
283-
284-
- name: Versions
285-
run: |
286-
cmake --version
287-
git --version
288-
clang --version
289-
clang++ --version
290-
291-
- uses: actions/checkout@v4
292-
with:
293-
submodules: recursive
294-
295-
- name: Configure
296-
run: |
297-
mkdir build
298-
cd build
299-
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} ..
300-
301-
- name: Build
302-
run: |
303-
cd build
304-
cmake --build . -- -j$(( `sysctl -n hw.ncpu` + 1 ))
305-
306-
- name: Tests
307-
run: |
308-
cd build/result/${{ matrix.build-config }}
309-
./cage-test-core
310-
311-
- name: List dependencies
312-
run: |
313-
cd build/result/${{ matrix.build-config }}
314-
echo "cage-core:"
315-
otool -L libcage-core.dylib
316-
echo "cage-engine:"
317-
otool -L libcage-engine.dylib

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ CMakeLists.txt.user
77
CMakeSettings.json
88
*~
99
*.TMP
10+
.DS_Store

.gitmodules

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
[submodule "externals/freetype/freetype"]
1414
path = externals/freetype/freetype
1515
url = https://github.com/ucpu/freetype.git
16-
[submodule "externals/glad/glad"]
17-
path = externals/glad/glad
18-
url = https://github.com/ucpu/glad.git
1916
[submodule "externals/glm/glm"]
2017
path = externals/glm/glm
2118
url = https://github.com/g-truc/glm.git
@@ -91,9 +88,6 @@
9188
[submodule "externals/gamenetworkingsockets/GameNetworkingSockets"]
9289
path = externals/gamenetworkingsockets/GameNetworkingSockets
9390
url = https://github.com/ValveSoftware/GameNetworkingSockets.git
94-
[submodule "externals/protobuf/protobuf"]
95-
path = externals/protobuf/protobuf
96-
url = https://github.com/protocolbuffers/protobuf.git
9791
[submodule "externals/quickhull/quickhull"]
9892
path = externals/quickhull/quickhull
9993
url = https://github.com/akuukka/quickhull.git
@@ -121,3 +115,12 @@
121115
[submodule "externals/wamr/zydis"]
122116
path = externals/wamr/zydis
123117
url = https://github.com/zyantific/zydis.git
118+
[submodule "externals/dawn/dawn"]
119+
path = externals/dawn/dawn
120+
url = https://dawn.googlesource.com/dawn
121+
[submodule "externals/glslang/glslang"]
122+
path = externals/glslang/glslang
123+
url = https://github.com/KhronosGroup/glslang.git
124+
[submodule "externals/svector/svector"]
125+
path = externals/svector/svector
126+
url = https://github.com/martinus/svector.git

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ if(WIN32)
1515
message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
1616
endif()
1717

18+
execute_process(COMMAND "bash" "${CMAKE_CURRENT_LIST_DIR}/submodules.sh" WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)
19+
1820
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1921
include(cage_all)
2022

cmake/cage_assets.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function(cage_assets_init)
4747
endif()
4848
cage_assets_add_schemes_path("${cage_assets_current_list_dir}/../schemes")
4949
cage_assets_add_data_path("${cage_assets_current_list_dir}/../data")
50-
configure_file("${cage_assets_current_list_dir}/../sources/include/cage-engine/shaderConventions.h" "${cage_assets_intermediate_path}/data/cage/shaders/" COPYONLY)
5150
cage_assets_generate_config()
5251
endfunction(cage_assets_init)
5352

cmake/cage_build_configuration.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ macro(cage_build_configuration)
1313
set(CMAKE_C_STANDARD_REQUIRED ON)
1414
set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
16+
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
1617

1718
# default visibility hidden
1819
set(CMAKE_C_VISIBILITY_PRESET hidden)
@@ -29,7 +30,7 @@ macro(cage_build_configuration)
2930
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
3031
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
3132

32-
if(WIN32)
33+
if(MSVC)
3334
# enable UTF-8
3435
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
3536
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")

cmake/cage_copy_redist.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ function(cage_copy_redist_license sourcePath targetName)
77
endfunction(cage_copy_redist_license)
88

99
function(cage_copy_redist)
10+
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../LICENSE" "cage" COPYONLY)
1011
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/assimp/assimp/LICENSE" "assimp" COPYONLY)
1112
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/avir/avir/LICENSE" "avir" COPYONLY)
1213
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/bc7enc_rdo/bc7enc_rdo/LICENSE" "bc7enc_rdo" COPYONLY)
1314
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/cpr/cpr/LICENSE" "cpr" COPYONLY)
1415
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/cubeb/cubeb/LICENSE" "cubeb" COPYONLY)
1516
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/curl/curl/COPYING" "curl" COPYONLY)
17+
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/dawn/dawn/LICENSE" "dawn" COPYONLY)
1618
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/dr_libs/dr_libs/README.md" "dr_libs" COPYONLY)
1719
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/dualmc/dualmc/LICENSE" "dualmc" COPYONLY)
1820
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/fastnoise/fastnoise/LICENSE" "fastnoise" COPYONLY)
@@ -34,7 +36,6 @@ function(cage_copy_redist)
3436
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/pmp/pmp/LICENSE.txt" "pmp" COPYONLY)
3537
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/pmp/pmp/external/eigen-3.4.0/COPYING.MPL2" "pmp_eigen" COPYONLY)
3638
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/png/png/LICENSE" "png" COPYONLY)
37-
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/protobuf/protobuf/LICENSE" "protobuf" COPYONLY)
3839
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/quickhull/quickhull/README.md" "quickhull" COPYONLY)
3940
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/samplerate/libsamplerate/COPYING" "samplerate" COPYONLY)
4041
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/simplefilewatcher/simplefilewatcher/License.txt" "simplefilewatcher" COPYONLY)
@@ -48,5 +49,4 @@ function(cage_copy_redist)
4849
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/xatlas/xatlas/LICENSE" "xatlas" COPYONLY)
4950
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/zlib-ng/zlib-ng/LICENSE.md" "zlib-ng" COPYONLY)
5051
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../externals/zstd/zstd/LICENSE" "zstd" COPYONLY)
51-
cage_copy_redist_license("${cage_copy_redist_current_list_dir}/../LICENSE" "cage" COPYONLY)
5252
endfunction(cage_copy_redist)
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11

2-
$include ../shaderConventions.h
3-
42
$include vertex.glsl
53

64
$define shader fragment
75

8-
layout(binding = 0) uniform sampler2D texColor;
9-
layout(binding = 1) uniform sampler2D texBloom;
6+
layout(std140, set = 2, binding = 0) uniform Params
7+
{
8+
vec4 uniBloomParams; // threshold, blur passes
9+
};
1010

11-
layout(location = 0) uniform int uniLodLevel;
11+
layout(set = 2, binding = 1) uniform sampler2D texColor;
12+
layout(set = 2, binding = 3) uniform sampler2D texBloom;
1213

13-
out vec4 outColor;
14+
layout(location = 0) out vec4 outColor;
1415

1516
void main()
1617
{
18+
int levels = int(uniBloomParams.y);
1719
vec3 color = texelFetch(texColor, ivec2(gl_FragCoord), 0).rgb;
1820
vec3 bloom = vec3(0);
19-
vec2 uv = vec2(gl_FragCoord) / textureSize(texColor, 0).xy;
20-
for (int i = 0; i < uniLodLevel; i++)
21+
vec2 uv = vec2(gl_FragCoord) / vec2(textureSize(texColor, 0));
22+
for (int i = 0; i < levels; i++)
2123
bloom += textureLod(texBloom, uv, i).rgb;
22-
outColor = vec4(color + bloom / uniLodLevel, 1); // additive mixing
24+
outColor = vec4(color + bloom / levels, 1); // additive mixing
2325
}

data/cage/shaders/effects/bloomGenerate.glsl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11

2-
$include ../shaderConventions.h
3-
42
$include vertex.glsl
53

64
$define shader fragment
75

8-
layout(location = 0) uniform vec4 uniBloomParams; // threshold
6+
layout(std140, set = 2, binding = 0) uniform Params
7+
{
8+
vec4 uniBloomParams; // threshold, blur passes
9+
};
910

10-
layout(binding = 0) uniform sampler2D texColor;
11+
layout(set = 2, binding = 1) uniform sampler2D texColor;
1112

12-
out vec4 outBloom;
13+
layout(location = 0) out vec4 outBloom;
1314

1415
const int downscale = 3;
1516

@@ -24,7 +25,7 @@ void main()
2425
vec3 c = texelFetch(texColor, ivec2(gl_FragCoord) * downscale + ivec2(x, y) - downscale / 2, 0).rgb;
2526
//float l = dot(c, vec3(0.2126, 0.7152, 0.0722)); // todo make the "grayscale factor" configurable
2627
float l = dot(c, vec3(0.3333));
27-
if (isnan(l))
28+
if (!(l >= 0.0 || l < 0.0)) // if (isnan(l))
2829
continue; // prevent spreading a NaN to other pixels
2930
int m = int(l > uniBloomParams[0]);
3031
acc += float(m) * c;

0 commit comments

Comments
 (0)