Skip to content

Commit 199cdd2

Browse files
committed
Upgrade BGFX
1 parent 91b0dd7 commit 199cdd2

1,235 files changed

Lines changed: 233474 additions & 32361 deletions

File tree

Some content is hidden

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

.github/workflows/test.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
pull_request:
88
branches:
99
- main
10-
- unstable
1110
paths:
1211
- ".github/workflows/**"
1312
- "src/**"
@@ -18,8 +17,6 @@ on:
1817
- "build.zig.zon"
1918

2019
push:
21-
branches:
22-
- main
2320
paths:
2421
- ".github/workflows/**"
2522
- "src/**"

build.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub fn build(b: *std.Build) !void {
264264
shaderc.addIncludePath(b.path("libs/bimg/include"));
265265
shaderc.addIncludePath(b.path(bgfx_path ++ "include"));
266266
shaderc.addIncludePath(b.path(bgfx_path ++ "src"));
267-
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/dxsdk/include"));
267+
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/directx-headers/include/directx"));
268268
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/fcpp"));
269269
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/glslang/glslang/Public"));
270270
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/glslang/glslang/Include"));
@@ -275,6 +275,12 @@ pub fn build(b: *std.Build) !void {
275275
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/spirv-tools/include"));
276276
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/webgpu/include"));
277277

278+
if (target.result.os.tag == .linux or target.result.os.tag.isDarwin()) {
279+
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/d3d4linux/include"));
280+
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/directx-headers/include"));
281+
shaderc.addIncludePath(b.path(bgfx_path ++ "3rdparty/directx-headers/include/wsl/stubs"));
282+
}
283+
278284
shaderc.addCSourceFiles(.{
279285
.files = &.{
280286
bgfx_path ++ "src/shader.cpp",
@@ -283,10 +289,12 @@ pub fn build(b: *std.Build) !void {
283289
bgfx_path ++ "src/vertexlayout.cpp",
284290
bgfx_path ++ "tools/shaderc/shaderc.cpp",
285291
bgfx_path ++ "tools/shaderc/shaderc_glsl.cpp",
292+
bgfx_path ++ "tools/shaderc/shaderc_dxil.cpp",
286293
bgfx_path ++ "tools/shaderc/shaderc_hlsl.cpp",
287294
bgfx_path ++ "tools/shaderc/shaderc_metal.cpp",
288295
bgfx_path ++ "tools/shaderc/shaderc_pssl.cpp",
289296
bgfx_path ++ "tools/shaderc/shaderc_spirv.cpp",
297+
bgfx_path ++ "tools/shaderc/shaderc_wgsl.cpp",
290298
},
291299
.flags = &cxx_options,
292300
});
@@ -1081,4 +1089,5 @@ const spirv_opt_files = .{
10811089
spirv_opt_path ++ "source/val/validate_invalid_type.cpp",
10821090
spirv_opt_path ++ "source/val/validate_graph.cpp",
10831091
spirv_opt_path ++ "source/val/validate_logical_pointers.cpp",
1092+
spirv_opt_path ++ "source/val/validate_group.cpp",
10841093
};

examples/00-minimal/src/main.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,15 @@ pub fn main() anyerror!u8 {
128128
//
129129
switch (builtin.target.os.tag) {
130130
.linux => {
131-
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Default;
132-
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
133-
bgfx_init.platformData.ndt = zglfw.getX11Display();
131+
if (zglfw.getPlatform() == .wayland) {
132+
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Wayland;
133+
bgfx_init.platformData.nwh = zglfw.getWaylandWindow(window);
134+
bgfx_init.platformData.ndt = zglfw.getWaylandDisplay();
135+
} else {
136+
bgfx_init.platformData.type = .Default;
137+
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
138+
bgfx_init.platformData.ndt = zglfw.getX11Display();
139+
}
134140
},
135141
.windows => {
136142
bgfx_init.platformData.nwh = zglfw.getWin32Window(window);
@@ -299,7 +305,7 @@ pub fn main() anyerror!u8 {
299305
}
300306

301307
// Render Frame
302-
_ = bgfx.frame(false);
308+
_ = bgfx.frame(0);
303309
}
304310

305311
return 0;

examples/01-zgui/src/main.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ pub fn main() anyerror!u8 {
7070
//
7171
switch (builtin.target.os.tag) {
7272
.linux => {
73-
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Default;
74-
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
75-
bgfx_init.platformData.ndt = zglfw.getX11Display();
73+
if (zglfw.getPlatform() == .wayland) {
74+
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Wayland;
75+
bgfx_init.platformData.nwh = zglfw.getWaylandWindow(window);
76+
bgfx_init.platformData.ndt = zglfw.getWaylandDisplay();
77+
} else {
78+
bgfx_init.platformData.type = .Default;
79+
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
80+
bgfx_init.platformData.ndt = zglfw.getX11Display();
81+
}
7682
},
7783
.windows => {
7884
bgfx_init.platformData.nwh = zglfw.getWin32Window(window);
@@ -200,7 +206,7 @@ pub fn main() anyerror!u8 {
200206
backend_glfw_bgfx.draw();
201207

202208
// Render Frame
203-
_ = bgfx.frame(false);
209+
_ = bgfx.frame(0);
204210
}
205211

206212
return 0;

examples/02-runtime-shaderc/src/main.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,15 @@ pub fn main() anyerror!u8 {
171171
//
172172
switch (builtin.target.os.tag) {
173173
.linux => {
174-
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Default;
175-
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
176-
bgfx_init.platformData.ndt = zglfw.getX11Display();
174+
if (zglfw.getPlatform() == .wayland) {
175+
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Wayland;
176+
bgfx_init.platformData.nwh = zglfw.getWaylandWindow(window);
177+
bgfx_init.platformData.ndt = zglfw.getWaylandDisplay();
178+
} else {
179+
bgfx_init.platformData.type = .Default;
180+
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
181+
bgfx_init.platformData.ndt = zglfw.getX11Display();
182+
}
177183
},
178184
.windows => {
179185
bgfx_init.platformData.nwh = zglfw.getWin32Window(window);
@@ -360,7 +366,7 @@ pub fn main() anyerror!u8 {
360366
}
361367

362368
// Render Frame
363-
_ = bgfx.frame(false);
369+
_ = bgfx.frame(0);
364370
}
365371

366372
return 0;

examples/03-debugdraw/src/main.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,15 @@ pub fn main() anyerror!u8 {
6666
//
6767
switch (builtin.target.os.tag) {
6868
.linux => {
69-
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Default;
70-
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
71-
bgfx_init.platformData.ndt = zglfw.getX11Display();
69+
if (zglfw.getPlatform() == .wayland) {
70+
bgfx_init.platformData.type = bgfx.NativeWindowHandleType.Wayland;
71+
bgfx_init.platformData.nwh = zglfw.getWaylandWindow(window);
72+
bgfx_init.platformData.ndt = zglfw.getWaylandDisplay();
73+
} else {
74+
bgfx_init.platformData.type = .Default;
75+
bgfx_init.platformData.nwh = @ptrFromInt(zglfw.getX11Window(window));
76+
bgfx_init.platformData.ndt = zglfw.getX11Display();
77+
}
7278
},
7379
.windows => {
7480
bgfx_init.platformData.nwh = zglfw.getWin32Window(window);
@@ -243,7 +249,7 @@ pub fn main() anyerror!u8 {
243249
}
244250

245251
// Render Frame
246-
_ = bgfx.frame(false);
252+
_ = bgfx.frame(0);
247253
}
248254

249255
return 0;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BINARIES = ../../tools/bin/windows/d3d4linux.exe
2+
3+
INCLUDE = include/d3d4linux.h \
4+
include/d3d4linux_common.h \
5+
include/d3d4linux_enums.h \
6+
include/d3d4linux_impl.h \
7+
include/d3d4linux_types.h
8+
9+
CXXFLAGS += -O2 -Wall -I./include -std=c++11
10+
11+
ifeq ($(OS), Windows_NT)
12+
CXX := x86_64-w64-mingw32-c++
13+
LDFLAGS = -s -static-libgcc -static-libstdc++ -ldxguid -static -ld3dcompiler -static -lpthread
14+
else
15+
LDFLAGS = -g
16+
endif
17+
18+
all: $(BINARIES)
19+
20+
../../tools/bin/windows/d3d4linux.exe: d3d4linux.cpp $(INCLUDE) Makefile
21+
x86_64-w64-mingw32-c++ $(CXXFLAGS) $(filter %.cpp, $^) -static -o $@ -ldxguid
22+
23+
clean:
24+
rm -f $(BINARIES)

0 commit comments

Comments
 (0)