Skip to content

Commit 115cb85

Browse files
committed
Query extensions at runtime
Don't run extensions unless they're available. This includes querying for descriptor indexing, and running one of two versions of kernel4 depending on whether it's enabled. Part of the support needed for #78
1 parent 5db427c commit 115cb85

File tree

13 files changed

+246
-132
lines changed

13 files changed

+246
-132
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

piet-gpu-derive/src/glsl.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ fn gen_enum_read(
157157
writeln!(r, "{}Tag {}_tag({}Ref ref) {{", name, name, name).unwrap();
158158
writeln!(r, " uint tag_and_flags = {}[ref.offset >> 2];", bufname).unwrap();
159159
}
160-
writeln!(r, " return {}Tag(tag_and_flags & 0xffff, tag_and_flags >> 16);", name).unwrap();
160+
writeln!(
161+
r,
162+
" return {}Tag(tag_and_flags & 0xffff, tag_and_flags >> 16);",
163+
name
164+
)
165+
.unwrap();
161166
writeln!(r, "}}\n").unwrap();
162167
for (var_name, payload) in variants {
163168
let payload_ix = if payload.len() == 1 {
@@ -564,7 +569,9 @@ fn gen_enum_write(
564569
}
565570
writeln!(r, "}}\n").unwrap();
566571
}
567-
} else if payload.len() == 2 && matches!(payload[0].1.ty, GpuType::Scalar(GpuScalar::TagFlags)) {
572+
} else if payload.len() == 2
573+
&& matches!(payload[0].1.ty, GpuType::Scalar(GpuScalar::TagFlags))
574+
{
568575
if let GpuType::InlineStruct(structname) = &payload[1].1.ty {
569576
if is_mem {
570577
writeln!(

piet-gpu-hal/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ edition = "2018"
88

99
[dependencies]
1010
ash = "0.31"
11-
once_cell = "1.3.1"
1211
ash-window = "0.5"
1312
raw-window-handle = "0.3"

piet-gpu-hal/src/hub.rs

+7
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ impl Session {
209209
pub unsafe fn create_sampler(&self, params: SamplerParams) -> Result<Sampler, Error> {
210210
self.0.device.create_sampler(params)
211211
}
212+
213+
/// Report whether the device supports descriptor indexing.
214+
///
215+
/// As we have more queries, we might replace this with a capabilities structure.
216+
pub fn has_descriptor_indexing(&self) -> bool {
217+
self.0.device.has_descriptor_indexing
218+
}
212219
}
213220

214221
impl CmdBuf {

0 commit comments

Comments
 (0)