Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ glam = { version = "0.30", features = ["mint"] }
gltf = { version = "1.1", default-features = false }
log = "0.4"
mint = "0.5"
naga = { version = "27.0", features = ["wgsl-in", "termcolor"] }
naga = { git = "https://github.com/gfx-rs/wgpu", rev = "760032a20d6d742d1df28136f36a673ab2584929", features = ["wgsl-in", "termcolor"] }
profiling = "1"
slab = "0.4"
strum = { version = "0.27", features = ["derive"] }
Expand Down
3 changes: 3 additions & 0 deletions blade-graphics/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ impl<'a, const N: ResourceIndex> HasShaderBinding for &'a super::TextureArray<N>
impl HasShaderBinding for super::AccelerationStructure {
const TYPE: ShaderBinding = ShaderBinding::AccelerationStructure;
}
impl<'a, const N: ResourceIndex> HasShaderBinding for &'a super::AccelerationStructureArray<N> {
const TYPE: ShaderBinding = ShaderBinding::AccelerationStructureArray { count: N };
}

pub trait HasVertexAttribute {
const FORMAT: VertexFormat;
Expand Down
7 changes: 7 additions & 0 deletions blade-graphics/src/gles/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
}
}
}
impl<'a, const N: crate::ResourceIndex> crate::ShaderBindable
for &'a crate::AccelerationStructureArray<N>
{
fn bind_to(&self, _ctx: &mut super::PipelineContext, _index: u32) {
unimplemented!()
}
}

impl super::CommandEncoder {
fn begin_pass(&mut self, label: &str) {
Expand Down Expand Up @@ -310,7 +317,7 @@
.push(super::Command::SetViewport(viewport.clone()));
}

fn set_stencil_reference(&mut self, reference: u32) {

Check warning on line 320 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `reference`

Check warning on line 320 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `reference`
unimplemented!()
}
}
Expand Down Expand Up @@ -474,7 +481,7 @@
.push(super::Command::SetViewport(viewport.clone()));
}

fn set_stencil_reference(&mut self, reference: u32) {

Check warning on line 484 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `reference`

Check warning on line 484 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `reference`
unimplemented!()
}
}
Expand Down Expand Up @@ -833,10 +840,10 @@
gl.bind_buffer(glow::PIXEL_UNPACK_BUFFER, None);
}
Self::CopyTextureToBuffer {
ref src,

Check warning on line 843 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `src`

Check warning on line 843 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `src`
ref dst,

Check warning on line 844 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `dst`

Check warning on line 844 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `dst`
bytes_per_row,

Check warning on line 845 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `bytes_per_row`

Check warning on line 845 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `bytes_per_row`
ref size,

Check warning on line 846 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `size`

Check warning on line 846 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `size`
} => unimplemented!(),
Self::ResetFramebuffer => {
for &attachment in COLOR_ATTACHMENTS.iter() {
Expand Down Expand Up @@ -1060,9 +1067,9 @@
gl.scissor(rect.x, rect.y, rect.w as i32, rect.h as i32);
}
Self::SetStencilFunc {
face,

Check warning on line 1070 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `face`

Check warning on line 1070 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `face`
function,

Check warning on line 1071 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `function`

Check warning on line 1071 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `function`
reference,

Check warning on line 1072 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Web, ubuntu-latest, wasm32-unknown-unknown, false)

unused variable: `reference`

Check warning on line 1072 in blade-graphics/src/gles/command.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu, true)

unused variable: `reference`
read_mask,
} => unimplemented!(),
Self::SetStencilOps {
Expand Down
1 change: 1 addition & 0 deletions blade-graphics/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ struct ExecutionContext {
impl Context {
pub fn capabilities(&self) -> crate::Capabilities {
crate::Capabilities {
binding_array: false,
ray_query: crate::ShaderVisibility::empty(),
sample_count_mask: 0x1 | 0x4, //TODO: accurate info
dual_source_blending: false,
Expand Down
8 changes: 6 additions & 2 deletions blade-graphics/src/gles/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ impl super::Context {
}
crate::ShaderBinding::TextureArray { .. }
| crate::ShaderBinding::BufferArray { .. }
| crate::ShaderBinding::AccelerationStructure => unimplemented!(),
| crate::ShaderBinding::AccelerationStructure
| crate::ShaderBinding::AccelerationStructureArray { .. } => {
unimplemented!()
}
crate::ShaderBinding::Plain { .. } => {
num_buffers += 1;
num_buffers - 1
Expand Down Expand Up @@ -248,7 +251,8 @@ impl super::Context {
}
crate::ShaderBinding::TextureArray { .. }
| crate::ShaderBinding::BufferArray { .. }
| crate::ShaderBinding::AccelerationStructure => {
| crate::ShaderBinding::AccelerationStructure
| crate::ShaderBinding::AccelerationStructureArray { .. } => {
unimplemented!()
}
crate::ShaderBinding::Plain { size } => {
Expand Down
7 changes: 6 additions & 1 deletion blade-graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ impl From<PlatformError> for NotSupportedError {

#[derive(Clone, Debug, Default, PartialEq)]
pub struct Capabilities {
/// Which shader stages support ray queries
/// Support binding arrays of handles.
pub binding_array: bool,
/// Which shader stages support ray queries.
pub ray_query: ShaderVisibility,
/// Bit mask of supported MSAA sample counts.
pub sample_count_mask: u32,
Expand Down Expand Up @@ -281,6 +283,8 @@ impl<T, const N: ResourceIndex> std::ops::IndexMut<ResourceIndex> for ResourceAr
}
pub type BufferArray<const N: ResourceIndex> = ResourceArray<BufferPiece, N>;
pub type TextureArray<const N: ResourceIndex> = ResourceArray<TextureView, N>;
pub type AccelerationStructureArray<const N: ResourceIndex> =
ResourceArray<AccelerationStructure, N>;

#[derive(Clone, Copy, Debug)]
pub struct TexturePiece {
Expand Down Expand Up @@ -644,6 +648,7 @@ pub enum ShaderBinding {
Buffer,
BufferArray { count: u32 },
AccelerationStructure,
AccelerationStructureArray { count: u32 },
Plain { size: u32 },
}

Expand Down
7 changes: 7 additions & 0 deletions blade-graphics/src/metal/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
}
}
}
impl<'a, const N: crate::ResourceIndex> crate::ShaderBindable
for &'a crate::AccelerationStructureArray<N>
{
fn bind_to(&self, _ctx: &mut super::PipelineContext, _index: u32) {
unimplemented!()
}
}

impl super::TimingData {
fn add(&mut self, label: &str) -> usize {
Expand Down Expand Up @@ -224,7 +231,7 @@
targets: crate::RenderTargetSet,
) -> super::RenderCommandEncoder<'_> {
let raw = objc2::rc::autoreleasepool(|_| {
let descriptor = unsafe { metal::MTLRenderPassDescriptor::new() };

Check warning on line 234 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 234 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 234 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 234 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

for (i, rt) in targets.colors.iter().enumerate() {
let at_descriptor =
Expand Down Expand Up @@ -362,7 +369,7 @@
}

let queue = self.queue.lock().unwrap();
self.raw = Some(objc2::rc::autoreleasepool(|_| unsafe {

Check warning on line 372 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 372 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 372 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 372 in blade-graphics/src/metal/command.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block
use metal::MTLCommandQueue as _;
let cmd_buf = queue.commandBufferWithUnretainedReferences().unwrap();
if !self.name.is_empty() {
Expand Down
1 change: 1 addition & 0 deletions blade-graphics/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
let device = self.device.lock().unwrap();

crate::Capabilities {
binding_array: false,
ray_query: if device.supportsFamily(metal::MTLGPUFamily::Apple6) {
crate::ShaderVisibility::all()
} else if device.supportsFamily(metal::MTLGPUFamily::Mac2)
Expand Down Expand Up @@ -566,7 +567,7 @@
};
for i in 0..desc.buffer_count {
let label = format!("{}/counter{}", desc.name, i);
let sample_buffer = unsafe {

Check warning on line 570 in blade-graphics/src/metal/mod.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 570 in blade-graphics/src/metal/mod.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 570 in blade-graphics/src/metal/mod.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 570 in blade-graphics/src/metal/mod.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block
csb_desc.setLabel(&objc2_foundation::NSString::from_str(&label));
self.device
.lock()
Expand Down
6 changes: 4 additions & 2 deletions blade-graphics/src/metal/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
read_mask: u32,
write_mask: u32,
) -> Retained<metal::MTLStencilDescriptor> {
let desc = unsafe { metal::MTLStencilDescriptor::new() };

Check warning on line 79 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 79 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 79 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 79 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block
desc.setStencilCompareFunction(super::map_compare_function(face.compare));
desc.setReadMask(read_mask);
desc.setWriteMask(write_mask);
Expand All @@ -89,7 +89,7 @@
fn create_depth_stencil_desc(
state: &crate::DepthStencilState,
) -> Retained<metal::MTLDepthStencilDescriptor> {
let desc = unsafe { metal::MTLDepthStencilDescriptor::new() };

Check warning on line 92 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 92 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 92 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 92 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block
desc.setDepthCompareFunction(super::map_compare_function(state.depth_compare));
desc.setDepthWriteEnabled(state.depth_write_enabled);

Expand Down Expand Up @@ -157,7 +157,8 @@
num_buffers - 1
}
crate::ShaderBinding::TextureArray { .. }
| crate::ShaderBinding::BufferArray { .. } => unimplemented!(),
| crate::ShaderBinding::BufferArray { .. }
| crate::ShaderBinding::AccelerationStructureArray { .. } => unimplemented!(),
crate::ShaderBinding::AccelerationStructure => {
num_buffers += 1;
num_buffers - 1
Expand Down Expand Up @@ -268,7 +269,8 @@
..Default::default()
},
crate::ShaderBinding::TextureArray { .. }
| crate::ShaderBinding::BufferArray { .. } => todo!(),
| crate::ShaderBinding::BufferArray { .. }
| crate::ShaderBinding::AccelerationStructureArray { .. } => todo!(),
};
naga_resources.resources.insert(res_binding, bind_target);
}
Expand Down Expand Up @@ -446,7 +448,7 @@
None
};

let vertex_descriptor = unsafe { metal::MTLVertexDescriptor::new() };

Check warning on line 451 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (iOS, macos-latest, aarch64-apple-ios, false)

unnecessary `unsafe` block

Check warning on line 451 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 451 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block

Check warning on line 451 in blade-graphics/src/metal/pipeline.rs

View workflow job for this annotation

GitHub Actions / build (macOS, macos-latest, aarch64-apple-darwin, true)

unnecessary `unsafe` block
for (i, vf) in desc.vertex_fetches.iter().enumerate() {
unsafe {
let buffer_desc = vertex_descriptor.layouts().objectAtIndexedSubscript(i);
Expand Down
16 changes: 15 additions & 1 deletion blade-graphics/src/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ impl super::Context {
let flags = naga::valid::ValidationFlags::all() ^ naga::valid::ValidationFlags::BINDINGS;
let mut caps = naga::valid::Capabilities::empty();
caps.set(
naga::valid::Capabilities::RAY_QUERY | naga::valid::Capabilities::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
naga::valid::Capabilities::STORAGE_BUFFER_BINDING_ARRAY
| naga::valid::Capabilities::TEXTURE_AND_SAMPLER_BINDING_ARRAY
| naga::valid::Capabilities::TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING
| naga::valid::Capabilities::STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING,
device_caps.binding_array,
);
caps.set(
naga::valid::Capabilities::RAY_QUERY
| naga::valid::Capabilities::ACCELERATION_STRUCTURE_BINDING_ARRAY,
!device_caps.ray_query.is_empty(),
);
caps.set(
Expand Down Expand Up @@ -170,6 +178,7 @@ impl super::Shader {
let count = match proto_binding {
crate::ShaderBinding::TextureArray { count } => count,
crate::ShaderBinding::BufferArray { count } => count,
crate::ShaderBinding::AccelerationStructureArray { count } => count,
_ => 0,
};
let proto = match module.types[base].inner {
Expand All @@ -179,6 +188,9 @@ impl super::Shader {
naga::TypeInner::Struct { .. } => {
crate::ShaderBinding::BufferArray { count }
}
naga::TypeInner::AccelerationStructure { .. } => {
crate::ShaderBinding::AccelerationStructureArray { count }
}
ref other => panic!("Unsupported binding array for {:?}", other),
};
(proto, var_access)
Expand Down Expand Up @@ -275,6 +287,7 @@ impl super::Shader {
interpolation: None,
sampling: None,
blend_src: None,
per_primitive: false,
};
for (buffer_index, vertex_fetch) in fetch_states.iter().enumerate() {
for (attribute_index, &(at_name, _)) in
Expand Down Expand Up @@ -307,6 +320,7 @@ impl super::Shader {
interpolation: None,
sampling: None,
blend_src: None,
per_primitive: false,
});
location += 1;
}
Expand Down
15 changes: 15 additions & 0 deletions blade-graphics/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,21 @@ impl crate::ShaderBindable for super::AccelerationStructure {
ctx.write(index, self.raw);
}
}
impl<'a, const N: crate::ResourceIndex> crate::ShaderBindable
for &'a crate::AccelerationStructureArray<N>
{
fn bind_to(&self, ctx: &mut super::PipelineContext, index: u32) {
assert!(self.data.len() <= N as usize);
ctx.write_array(
index,
self.data
.iter()
.map(|accel| accel.raw)
.cycle()
.take(N as usize),
);
}
}

impl crate::TexturePiece {
fn subresource_layers(&self) -> vk::ImageSubresourceLayers {
Expand Down
24 changes: 21 additions & 3 deletions blade-graphics/src/vulkan/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct AdapterCapabilities {
device_information: crate::DeviceInformation,
queue_family_index: u32,
layered: bool,
binding_array: bool,
ray_tracing: Option<RayTracingCapabilities>,
buffer_marker: bool,
shader_info: bool,
Expand Down Expand Up @@ -209,6 +210,14 @@ unsafe fn inspect_adapter(
true
};

let supports_descriptor_indexing = api_version >= vk::API_VERSION_1_2
|| supported_extensions.contains(&vk::EXT_DESCRIPTOR_INDEXING_NAME);
let binding_array = supports_descriptor_indexing
&& descriptor_indexing_features.descriptor_binding_partially_bound == vk::TRUE
&& descriptor_indexing_features.shader_storage_buffer_array_non_uniform_indexing
== vk::TRUE
&& descriptor_indexing_features.shader_sampled_image_array_non_uniform_indexing == vk::TRUE;

let ray_tracing = if !supported_extensions.contains(&vk::KHR_ACCELERATION_STRUCTURE_NAME)
|| !supported_extensions.contains(&vk::KHR_RAY_QUERY_NAME)
{
Expand Down Expand Up @@ -277,6 +286,7 @@ unsafe fn inspect_adapter(
device_information,
queue_family_index,
layered: portability_subset_properties.min_vertex_input_binding_stride_alignment != 0,
binding_array,
ray_tracing,
buffer_marker,
shader_info,
Expand Down Expand Up @@ -457,9 +467,13 @@ impl super::Context {
log::info!("Enabling Vulkan Portability");
device_extensions.push(vk::KHR_PORTABILITY_SUBSET_NAME);
}
let needs_descriptor_indexing =
capabilities.binding_array || capabilities.ray_tracing.is_some();
if needs_descriptor_indexing && capabilities.api_version < vk::API_VERSION_1_2 {
device_extensions.push(vk::EXT_DESCRIPTOR_INDEXING_NAME);
}
if capabilities.ray_tracing.is_some() {
if capabilities.api_version < vk::API_VERSION_1_2 {
device_extensions.push(vk::EXT_DESCRIPTOR_INDEXING_NAME);
device_extensions.push(vk::KHR_BUFFER_DEVICE_ADDRESS_NAME);
device_extensions.push(vk::KHR_SHADER_FLOAT_CONTROLS_NAME);
device_extensions.push(vk::KHR_SPIRV_1_4_NAME);
Expand Down Expand Up @@ -514,13 +528,16 @@ impl super::Context {
let mut khr_buffer_device_address;
let mut khr_acceleration_structure;
let mut khr_ray_query;
if capabilities.ray_tracing.is_some() {
if needs_descriptor_indexing {
ext_descriptor_indexing = vk::PhysicalDeviceDescriptorIndexingFeaturesEXT {
shader_storage_buffer_array_non_uniform_indexing: vk::TRUE,
shader_sampled_image_array_non_uniform_indexing: vk::TRUE,
descriptor_binding_partially_bound: vk::TRUE,
..Default::default()
};
device_create_info = device_create_info.push_next(&mut ext_descriptor_indexing);
}
if capabilities.ray_tracing.is_some() {
khr_buffer_device_address = vk::PhysicalDeviceBufferDeviceAddressFeaturesKHR {
buffer_device_address: vk::TRUE,
..Default::default()
Expand All @@ -534,7 +551,6 @@ impl super::Context {
..Default::default()
};
device_create_info = device_create_info
.push_next(&mut ext_descriptor_indexing)
.push_next(&mut khr_buffer_device_address)
.push_next(&mut khr_acceleration_structure)
.push_next(&mut khr_ray_query);
Expand Down Expand Up @@ -747,6 +763,7 @@ impl super::Context {
.limits
.framebuffer_depth_sample_counts,
dual_source_blending: capabilities.dual_source_blending,
binding_array: capabilities.binding_array,
instance,
entry,
})
Expand All @@ -766,6 +783,7 @@ impl super::Context {

pub fn capabilities(&self) -> crate::Capabilities {
crate::Capabilities {
binding_array: self.binding_array,
ray_query: match self.device.ray_tracing {
Some(_) => crate::ShaderVisibility::all(),
None => crate::ShaderVisibility::empty(),
Expand Down
1 change: 1 addition & 0 deletions blade-graphics/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub struct Context {
min_buffer_alignment: u64,
sample_count_flags: vk::SampleCountFlags,
dual_source_blending: bool,
binding_array: bool,
instance: Instance,
entry: ash::Entry,
}
Expand Down
10 changes: 9 additions & 1 deletion blade-graphics/src/vulkan/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ impl super::Context {
for (binding_index, &(_, binding)) in layout.bindings.iter().enumerate() {
let binding_array_size = match binding {
crate::ShaderBinding::TextureArray { count }
| crate::ShaderBinding::BufferArray { count } => Some(count),
| crate::ShaderBinding::BufferArray { count }
| crate::ShaderBinding::AccelerationStructureArray { count } => Some(count),
_ => None,
};
let rb = naga::ResourceBinding {
Expand Down Expand Up @@ -51,6 +52,7 @@ impl super::Context {
bounds_check_policies: naga::proc::BoundsCheckPolicies::default(),
zero_initialize_workgroup_memory: spv::ZeroInitializeWorkgroupMemoryMode::None,
force_loop_bounding: false,
ray_query_initialization_tracking: true,
use_storage_input_output_16: false,
debug_info: None,
}
Expand Down Expand Up @@ -241,6 +243,12 @@ impl super::Context {
1u32,
vk::DescriptorBindingFlags::empty(),
),
crate::ShaderBinding::AccelerationStructureArray { count } => (
vk::DescriptorType::ACCELERATION_STRUCTURE_KHR,
mem::size_of::<vk::AccelerationStructureKHR>(),
count,
vk::DescriptorBindingFlags::PARTIALLY_BOUND,
),
crate::ShaderBinding::Plain { size } => (
vk::DescriptorType::INLINE_UNIFORM_BLOCK_EXT,
1,
Expand Down
1 change: 1 addition & 0 deletions blade-render/code/fill-gbuf.wgsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
enable wgpu_ray_query;
#include "quaternion.inc.wgsl"
#include "camera.inc.wgsl"
#include "debug.inc.wgsl"
Expand Down
1 change: 1 addition & 0 deletions blade-render/code/ray-trace.wgsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
enable wgpu_ray_query;
#include "quaternion.inc.wgsl"
#include "random.inc.wgsl"
#include "env-importance.inc.wgsl"
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog for *Blade* project

## blade-graphics-0.8 (TBD)
- graphics
- separate `Capabilities` flag for binding arrays, including TLAS arrays

## blade-graphics-0.7 (27 Sep 2025)

- graphics
Expand Down
1 change: 1 addition & 0 deletions examples/ray-query/shader.wgsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
enable wgpu_ray_query;
const MAX_BOUNCES: i32 = 3;

struct Parameters {
Expand Down
Loading