Skip to content

Commit 0bf85d0

Browse files
committed
sokol: upgrade to latest version, fix all related issues
1 parent 7560753 commit 0bf85d0

File tree

36 files changed

+8214
-8006
lines changed

36 files changed

+8214
-8006
lines changed

.github/workflows/other_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101

102102
- name: Shader examples can be build
103103
run: |
104-
wget https://github.com/floooh/sokol-tools-bin/raw/33d2e4cc26088c6c28eaef5467990f8940d15aab/bin/linux/sokol-shdc
104+
wget https://github.com/floooh/sokol-tools-bin/raw/6040b18d39649d56dbae2ae1aed59fb755b26369/bin/linux/sokol-shdc
105105
chmod +x ./sokol-shdc
106106
for f in examples/sokol/02_cubes_glsl/cube_glsl \
107107
examples/sokol/03_march_tracing_glsl/rt_glsl \

cmd/tools/vshader.v

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
// The shader language used is, as described on the overview page linked above, an 'annotated GLSL'
1414
// and 'modern GLSL' (v450) shader language format.
1515
import os
16+
import time
1617
import io.util
1718
import flag
1819
import net.http
1920

2021
const (
21-
shdc_full_hash = '33d2e4cc26088c6c28eaef5467990f8940d15aab'
22-
tool_version = '0.0.1'
22+
shdc_full_hash = '6040b18d39649d56dbae2ae1aed59fb755b26369'
23+
tool_version = '0.0.2'
2324
tool_description = "Compile shaders in sokol's annotated GLSL format to C headers for use with sokol based apps"
2425
tool_name = os.file_name(os.executable())
2526
cache_dir = os.join_path(os.cache_dir(), 'v', tool_name)
@@ -29,15 +30,15 @@ const (
2930
const (
3031
supported_hosts = ['linux', 'macos', 'windows']
3132
supported_slangs = [
32-
'glsl330', // desktop GL
33-
'glsl100', // GLES2 / WebGL
34-
'glsl300es', // GLES3 / WebGL2
35-
'hlsl4', // D3D11
36-
'hlsl5', // D3D11
37-
'metal_macos', // Metal on macOS
38-
'metal_ios', // Metal on iOS device
39-
'metal_sim', // Metal on iOS simulator
40-
'wgpu', // WebGPU
33+
'glsl330', // desktop OpenGL backend (SOKOL_GLCORE33)
34+
'glsl100', // OpenGLES2 and WebGL (SOKOL_GLES3)
35+
'glsl300es', // OpenGLES3 and WebGL2 (SOKOL_GLES3)
36+
'hlsl4', // Direct3D11 with HLSL4 (SOKOL_D3D11)
37+
'hlsl5', // Direct3D11 with HLSL5 (SOKOL_D3D11)
38+
'metal_macos', // Metal on macOS (SOKOL_METAL)
39+
'metal_ios', // Metal on iOS devices (SOKOL_METAL)
40+
'metal_sim', // Metal on iOS simulator (SOKOL_METAL)
41+
'wgsl', // WebGPU (SOKOL_WGPU)
4142
]
4243
default_slangs = [
4344
'glsl330',
@@ -48,14 +49,15 @@ const (
4849
'metal_macos',
4950
'metal_ios',
5051
'metal_sim',
51-
'wgpu',
52+
'wgsl',
5253
]
5354

5455
shdc_version = shdc_full_hash[0..8]
5556
shdc_urls = {
5657
'windows': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/win32/sokol-shdc.exe'
5758
'macos': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx/sokol-shdc'
5859
'linux': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/linux/sokol-shdc'
60+
'osx_a64': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx_arm64/sokol-shdc'
5961
}
6062
shdc_version_file = os.join_path(cache_dir, 'sokol-shdc.version')
6163
shdc = shdc_exe()
@@ -242,11 +244,20 @@ fn ensure_external_tools(opt Options) ! {
242244

243245
is_shdc_available := os.is_file(shdc)
244246
is_shdc_executable := os.is_executable(shdc)
245-
if is_shdc_available && is_shdc_executable {
246-
if opt.verbose {
247-
version := os.read_file(shdc_version_file) or { 'unknown' }
248-
eprintln('${tool_name} using sokol-shdc version ${version} at "${shdc}"')
247+
if opt.verbose {
248+
eprintln('reading version from ${shdc_version_file} ...')
249+
version := os.read_file(shdc_version_file) or { 'unknown' }
250+
eprintln('${tool_name} using sokol-shdc version ${version} at "${shdc}"')
251+
eprintln('executable: ${is_shdc_executable}')
252+
eprintln(' available: ${is_shdc_available}')
253+
if is_shdc_available {
254+
eprintln(' file path: ${shdc}')
255+
eprintln(' file size: ${os.file_size(shdc)}')
256+
eprintln(' file time: ${time.unix_microsecond(os.file_last_mod_unix(shdc),
257+
0)}')
249258
}
259+
}
260+
if is_shdc_available && is_shdc_executable {
250261
return
251262
}
252263

@@ -263,15 +274,24 @@ fn shdc_exe() string {
263274
// download_shdc downloads the `sokol-shdc` tool to an OS specific cache directory.
264275
fn download_shdc(opt Options) ! {
265276
// We want to use the same, runtime, OS type as this tool is invoked on.
266-
download_url := shdc_urls[runtime_os] or { '' }
277+
mut download_url := shdc_urls[runtime_os] or { '' }
278+
$if arm64 && macos {
279+
download_url = shdc_urls['osx_a64']
280+
}
267281
if download_url == '' {
268282
return error('${tool_name} failed to download an external dependency "sokol-shdc" for ${runtime_os}.\nThe supported host platforms for shader compilation is ${supported_hosts}')
269283
}
284+
if opt.verbose {
285+
eprintln('> reading version from ${shdc_version_file} ...')
286+
}
270287
update_to_shdc_version := os.read_file(shdc_version_file) or { shdc_version }
288+
if opt.verbose {
289+
eprintln('> update_to_shdc_version: ${update_to_shdc_version} | shdc_version: ${shdc_version}')
290+
}
271291
file := shdc_exe()
272292
if opt.verbose {
273293
if shdc_version != update_to_shdc_version && os.exists(file) {
274-
eprintln('${tool_name} updating sokol-shdc to version ${update_to_shdc_version} ...')
294+
eprintln('${tool_name} updating sokol-shdc to version ${shdc_version} ...')
275295
} else {
276296
eprintln('${tool_name} installing sokol-shdc version ${update_to_shdc_version} ...')
277297
}
@@ -298,5 +318,5 @@ fn download_shdc(opt Options) ! {
298318
os.mv(file, shdc)!
299319
}
300320
// Update internal version file
301-
os.write_file(shdc_version_file, update_to_shdc_version)!
321+
os.write_file(shdc_version_file, shdc_version)!
302322
}

examples/sokol/01_cubes/cube.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ fn create_texture(w int, h int, buf &u8) gfx.Image {
4545
width: w
4646
height: h
4747
num_mipmaps: 0
48-
min_filter: .linear
49-
mag_filter: .linear
48+
// min_filter: .linear
49+
// mag_filter: .linear
5050
// usage: .dynamic
51-
wrap_u: .clamp_to_edge
52-
wrap_v: .clamp_to_edge
51+
// wrap_u: .clamp_to_edge
52+
// wrap_v: .clamp_to_edge
5353
label: &u8(0)
5454
d3d11_texture: 0
5555
}

examples/sokol/02_cubes_glsl/cube_glsl.v

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
6161
width: w
6262
height: h
6363
num_mipmaps: 0
64-
min_filter: .linear
65-
mag_filter: .linear
64+
// min_filter: .linear
65+
// mag_filter: .linear
6666
// usage: .dynamic
67-
wrap_u: .clamp_to_edge
68-
wrap_v: .clamp_to_edge
67+
// wrap_u: .clamp_to_edge
68+
// wrap_v: .clamp_to_edge
6969
label: &u8(0)
7070
d3d11_texture: 0
7171
}
@@ -361,7 +361,7 @@ fn init_cube_glsl(mut app App) {
361361

362362
app.cube_bind.vertex_buffers[0] = vbuf
363363
app.cube_bind.index_buffer = ibuf
364-
app.cube_bind.fs_images[C.SLOT_tex] = app.texture
364+
app.cube_bind.fs.images[C.SLOT_tex] = app.texture
365365
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
366366
println('GLSL init DONE!')
367367
}
@@ -374,8 +374,8 @@ fn draw_cube_glsl(app App) {
374374
// clear
375375
ws := gg.window_size_real_pixels()
376376
mut color_action := gfx.ColorAttachmentAction{
377-
action: unsafe { gfx.Action(C.SG_ACTION_DONTCARE) } // C.SG_ACTION_CLEAR)
378-
value: gfx.Color{
377+
load_action: unsafe { gfx.Action(C.SG_LOADACTION_DONTCARE) } // C.SG_ACTION_CLEAR)
378+
clear_value: gfx.Color{
379379
r: 1.0
380380
g: 1.0
381381
b: 1.0

examples/sokol/03_march_tracing_glsl/rt_glsl.v

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ fn create_texture(w int, h int, buf &byte) gfx.Image {
6060
width: w
6161
height: h
6262
num_mipmaps: 0
63-
min_filter: .linear
64-
mag_filter: .linear
63+
// min_filter: .linear
64+
// mag_filter: .linear
6565
// usage: .dynamic
66-
wrap_u: .clamp_to_edge
67-
wrap_v: .clamp_to_edge
66+
// wrap_u: .clamp_to_edge
67+
// wrap_v: .clamp_to_edge
6868
label: &u8(0)
6969
d3d11_texture: 0
7070
}
@@ -223,7 +223,7 @@ fn init_cube_glsl(mut app App) {
223223

224224
app.cube_bind.vertex_buffers[0] = vbuf
225225
app.cube_bind.index_buffer = ibuf
226-
app.cube_bind.fs_images[C.SLOT_tex] = app.texture
226+
app.cube_bind.fs.images[C.SLOT_tex] = app.texture
227227
app.cube_pip_glsl = gfx.make_pipeline(&pipdesc)
228228
println('GLSL init DONE!')
229229
}
@@ -312,8 +312,8 @@ fn frame(mut app App) {
312312

313313
// clear
314314
mut color_action := gfx.ColorAttachmentAction{
315-
action: .clear
316-
value: gfx.Color{
315+
load_action: .clear
316+
clear_value: gfx.Color{
317317
r: 0.0
318318
g: 0.0
319319
b: 0.0

examples/sokol/04_multi_shader_glsl/rt_glsl.v

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image {
6363
width: w
6464
height: h
6565
num_mipmaps: 0
66-
min_filter: .linear
67-
mag_filter: .linear
66+
// min_filter: .linear
67+
// mag_filter: .linear
6868
// usage: .dynamic
69-
wrap_u: .clamp_to_edge
70-
wrap_v: .clamp_to_edge
69+
// wrap_u: .clamp_to_edge
70+
// wrap_v: .clamp_to_edge
7171
label: &u8(0)
7272
d3d11_texture: 0
7373
}
@@ -227,7 +227,7 @@ fn init_cube_glsl_m(mut app App) {
227227
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
228228
bind.vertex_buffers[0] = vbuf
229229
bind.index_buffer = ibuf
230-
bind.fs_images[C.SLOT_tex] = app.texture
230+
bind.fs.images[C.SLOT_tex] = app.texture
231231
app.bind['march'] = bind
232232

233233
app.pipe['march'] = gfx.make_pipeline(&pipdesc)
@@ -342,7 +342,7 @@ fn init_cube_glsl_p(mut app App) {
342342
unsafe { vmemset(&bind, 0, int(sizeof(bind))) }
343343
bind.vertex_buffers[0] = vbuf
344344
bind.index_buffer = ibuf
345-
bind.fs_images[C.SLOT_tex] = app.texture
345+
bind.fs.images[C.SLOT_tex] = app.texture
346346
app.bind['puppy'] = bind
347347

348348
app.pipe['puppy'] = gfx.make_pipeline(&pipdesc)
@@ -501,8 +501,8 @@ fn frame(mut app App) {
501501

502502
// clear
503503
mut color_action := gfx.ColorAttachmentAction{
504-
action: .clear
505-
value: gfx.Color{
504+
load_action: .clear
505+
clear_value: gfx.Color{
506506
r: 0.0
507507
g: 0.0
508508
b: 0.0

examples/sokol/05_instancing_glsl/rt_glsl.v

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ fn create_texture(w int, h int, buf byteptr) gfx.Image {
7171
width: w
7272
height: h
7373
num_mipmaps: 0
74-
min_filter: .linear
75-
mag_filter: .linear
74+
// min_filter: .linear
75+
// mag_filter: .linear
7676
//usage: .dynamic
77-
wrap_u: .clamp_to_edge
78-
wrap_v: .clamp_to_edge
77+
// wrap_u: .clamp_to_edge
78+
// wrap_v: .clamp_to_edge
7979
label: &u8(0)
8080
d3d11_texture: 0
8181
}
@@ -257,7 +257,7 @@ fn init_cube_glsl_i(mut app App) {
257257
bind.vertex_buffers[0] = vbuf // vertex buffer
258258
bind.vertex_buffers[1] = inst_buf // instance buffer
259259
bind.index_buffer = ibuf
260-
bind.fs_images[C.SLOT_tex] = app.texture
260+
bind.fs.images[C.SLOT_tex] = app.texture
261261
app.bind['inst'] = bind
262262
app.pipe['inst'] = gfx.make_pipeline(&pipdesc)
263263

@@ -384,8 +384,8 @@ fn frame(mut app App) {
384384

385385
// clear
386386
mut color_action := gfx.ColorAttachmentAction{
387-
action: .clear
388-
value: gfx.Color{
387+
load_action: .clear
388+
clear_value: gfx.Color{
389389
r: 0.0
390390
g: 0.0
391391
b: 0.0

examples/sokol/06_obj_viewer/modules/obj/rend.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ pub fn create_texture(w int, h int, buf &u8) gfx.Image {
2424
width: w
2525
height: h
2626
num_mipmaps: 0
27-
min_filter: .linear
28-
mag_filter: .linear
27+
// min_filter: .linear
28+
// mag_filter: .linear
2929
// usage: .dynamic
30-
wrap_u: .clamp_to_edge
31-
wrap_v: .clamp_to_edge
30+
// wrap_u: .clamp_to_edge
31+
// wrap_v: .clamp_to_edge
3232
label: &u8(0)
3333
d3d11_texture: 0
3434
}
@@ -133,7 +133,7 @@ pub fn (mut obj_part ObjPart) create_pipeline(in_part []int, shader gfx.Shader,
133133

134134
res.bind.vertex_buffers[0] = vbuf
135135
res.bind.index_buffer = ibuf
136-
res.bind.fs_images[C.SLOT_tex] = texture
136+
res.bind.fs.images[C.SLOT_tex] = texture
137137
res.pipeline = gfx.make_pipeline(&pipdesc)
138138
// println('Buffers part [$in_part] init done!')
139139

examples/sokol/06_obj_viewer/show_obj.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ fn frame(mut app App) {
150150

151151
// clear
152152
mut color_action := gfx.ColorAttachmentAction{
153-
action: .clear
154-
value: gfx.Color{
153+
load_action: .clear
154+
clear_value: gfx.Color{
155155
r: 0.0
156156
g: 0.0
157157
b: 0.0

examples/sokol/fonts.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ mut:
1515

1616
fn main() {
1717
mut color_action := gfx.ColorAttachmentAction{
18-
action: .clear
19-
value: gfx.Color{
18+
load_action: .clear
19+
clear_value: gfx.Color{
2020
r: 0.3
2121
g: 0.3
2222
b: 0.32

0 commit comments

Comments
 (0)