Skip to content

Commit 669568e

Browse files
committed
Update gl crate to remove unused functions from generated output + add bindings for GL_ARB_parallel_shader_compile
1 parent c837631 commit 669568e

File tree

3 files changed

+127
-6
lines changed

3 files changed

+127
-6
lines changed

gl/build.rs

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,122 @@ use std::path::Path;
77
fn main() {
88
let dest = env::var("OUT_DIR").unwrap();
99
let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
10+
11+
println!("cargo::rerun-if-changed=build.rs");
1012

11-
Registry::new(Api::Gl, (4, 5), Profile::Core, Fallbacks::All, [])
12-
.write_bindings(gl_generator::StructGenerator, &mut file)
13-
.unwrap();
13+
let mut registry = Registry::new(Api::Gl, (4, 6), Profile::Core, Fallbacks::All, &["GL_ARB_parallel_shader_compile"]);
14+
15+
registry.cmds.retain(should_keep_cmd);
16+
17+
registry.write_bindings(gl_generator::StructGenerator, &mut file).unwrap();
18+
}
19+
20+
static ALLOWED_GET_FUNCTIONS: &[&str] = &[
21+
"GetIntegerv",
22+
"GetInternalformativ",
23+
"GetObjectLabel",
24+
"GetProgramBinary",
25+
"GetProgramInfoLog",
26+
"GetProgramInterfaceiv",
27+
"GetProgramiv",
28+
"GetProgramPipelineInfoLog",
29+
"GetProgramPipelineiv",
30+
"GetProgramResourceIndex",
31+
"GetProgramResourceiv",
32+
"GetProgramResourceLocation",
33+
"GetProgramResourceLocationIndex",
34+
"GetProgramResourceName",
35+
"GetProgramStageiv",
36+
"GetQueryBufferObjecti64v",
37+
"GetQueryBufferObjectiv",
38+
"GetQueryBufferObjectui64v",
39+
"GetQueryBufferObjectuiv",
40+
"GetQueryIndexediv",
41+
"GetQueryiv",
42+
"GetQueryObjecti64v",
43+
"GetQueryObjectiv",
44+
"GetQueryObjectui64v",
45+
"GetQueryObjectuiv",
46+
"GetString",
47+
"GetStringi",
48+
"GetSynciv",
49+
"GetTextureSubImage",
50+
];
51+
52+
static BANNED_PREFIXES: &[&str] = &[
53+
"Buffer",
54+
"ClearBuffer",
55+
"ColorP",
56+
"CompressedTexImage",
57+
"CompressedTexSub",
58+
"CopyTexImage",
59+
"CopyTexSub",
60+
"Framebuffer",
61+
"MapBuffer",
62+
"MultiTexCoord",
63+
"NormalP",
64+
"SecondaryColorP",
65+
"TexBuffer",
66+
"TexCoord",
67+
"TexImage",
68+
"TexParameter",
69+
"TexStorage",
70+
"TexSub",
71+
"Uniform1",
72+
"Uniform2",
73+
"Uniform3",
74+
"Uniform4",
75+
"UniformMatrix",
76+
"VertexAttrib",
77+
"VertexP",
78+
];
79+
80+
static BANNED_FUNCTIONS: &[&str] = &[
81+
"ActiveShaderProgram",
82+
"ActiveTexture",
83+
"BindRenderbuffer",
84+
"BindTexture",
85+
"BindTextures",
86+
"BindVertexBuffer",
87+
"BindVertexBuffers",
88+
"BlitFramebuffer",
89+
"CheckFramebufferStatus",
90+
"CopyBufferSubData",
91+
"DisableVertexAttribArray",
92+
"DrawBuffer",
93+
"DrawBuffers",
94+
"EnableVertexAttribArray",
95+
"FlushMappedBufferRange",
96+
"GenBuffers",
97+
"GenerateMipmap",
98+
"GenFramebuffers",
99+
"GenProgramPipelines",
100+
"GenQueries",
101+
"GenRenderbuffers",
102+
"GenSamplers",
103+
"GenTransformFeedbacks",
104+
"GenVertexArrays",
105+
"InvalidateFramebuffer",
106+
"ReadBuffer",
107+
"RenderbufferStorage",
108+
"RenderbufferStorageMultisample",
109+
"UnmapBuffer",
110+
"VertexBindingDivisor",
111+
];
112+
113+
114+
fn should_keep_cmd(cmd: &gl_generator::Cmd) -> bool {
115+
let ident = cmd.proto.ident.as_str();
116+
117+
if ident.starts_with("Get") {
118+
return ALLOWED_GET_FUNCTIONS.contains(&ident);
119+
}
120+
121+
for prefix in BANNED_PREFIXES {
122+
if ident.starts_with(prefix) {
123+
return false
124+
}
125+
}
126+
127+
!BANNED_FUNCTIONS.contains(&ident)
14128
}

toybox-gfx/src/core/capabilities.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub struct Capabilities {
1818
pub max_samples: usize,
1919

2020
pub max_ubo_size: usize,
21+
22+
pub parallel_shader_compilation_supported: bool,
2123
}
2224

2325
impl Capabilities {
@@ -80,6 +82,7 @@ impl Capabilities {
8082
max_texture_size: max_texture_size as usize,
8183
max_samples: min_max_samples as usize,
8284
max_ubo_size: max_ubo_size as usize,
85+
parallel_shader_compilation_supported: gl.MaxShaderCompilerThreadsARB.is_loaded(),
8386
}
8487
}
8588
}

toybox-host/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn start<F, H>(settings: Settings<'_>, start_hostee: F) -> anyhow::Result<()
6767
.with_debug(true)
6868
.with_profile(GlProfile::Core)
6969
.with_robustness(Robustness::RobustLoseContextOnReset)
70-
.with_context_api(ContextApi::OpenGl(Some(Version::new(4, 5))));
70+
.with_context_api(ContextApi::OpenGl(Some(Version::new(4, 6))));
7171

7272

7373
let bootstrap_state = BootstrapState {
@@ -112,6 +112,8 @@ impl<F, H> ApplicationHandler for ApplicationHost<F, H>
112112
let mut hosted_app = start_hostee(&host)
113113
.expect("Failed to start hosted app");
114114

115+
mark_tracy_frame();
116+
115117
// Draw before making the window visisble
116118
hosted_app.draw(event_loop);
117119

@@ -121,7 +123,7 @@ impl<F, H> ApplicationHandler for ApplicationHost<F, H>
121123
mark_tracy_frame();
122124

123125
host.window.set_visible(true);
124-
host.window.request_redraw();
126+
log::info!("Window made visible");
125127

126128
*self = ApplicationHost::Hosting(host, hosted_app);
127129
}
@@ -397,6 +399,8 @@ fn init_logging() {
397399
}
398400

399401
log_builder.init();
402+
403+
log::info!("Logger initialized");
400404
}
401405

402406
#[cfg(feature="tracy")]
@@ -409,7 +413,7 @@ fn init_tracy() {
409413
tracing::subscriber::set_global_default(subscriber)
410414
.expect("set up the subscriber");
411415

412-
println!("tracy init");
416+
log::info!("Tracy initialized");
413417
}
414418

415419
fn mark_tracy_frame() {

0 commit comments

Comments
 (0)