Skip to content

Commit

Permalink
Update ash to 0.38
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Apr 10, 2024
1 parent 810ec59 commit c096d11
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 376 deletions.
8 changes: 4 additions & 4 deletions blade-graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hidden-trait = "0.1"
log = { workspace = true }
mint = { workspace = true }
naga = { workspace = true, features = ["clone"] }
raw-window-handle = "0.5"
raw-window-handle = "0.6"

[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
block = "0.1"
Expand All @@ -27,10 +27,10 @@ objc = "0.2.5"
naga = { workspace = true, features = ["msl-out"] }

[target.'cfg(any(vulkan, windows, target_os = "linux", target_os = "android"))'.dependencies]
ash = "0.37"
ash-window = "0.12"
ash = "0.38"
ash-window = "0.13"
gpu-alloc = "0.6"
gpu-alloc-ash = "0.6"
gpu-alloc-ash = "0.7"
naga = { workspace = true, features = ["spv-out"] }
slab = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion blade-graphics/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl Context {
Ok(Self {
wsi: Some(WindowSystemInterface {
library: wsi_library.map(Arc::new),
window_handle: window.raw_window_handle(),
window_handle: window.raw_window_handle().unwrap(),
renderbuf,
framebuf,
}),
Expand Down
2 changes: 1 addition & 1 deletion blade-graphics/src/gles/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl crate::traits::ResourceDevice for super::Context {
| glow::MAP_COHERENT_BIT
| glow::MAP_READ_BIT
| glow::MAP_WRITE_BIT;
glow::STREAM_READ
glow::DYNAMIC_DRAW //TEMP
}
crate::Memory::Upload => {
map_flags =
Expand Down
2 changes: 1 addition & 1 deletion blade-graphics/src/gles/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Context {
desc: crate::ContextDesc,
) -> Result<Self, crate::NotSupportedError> {
let webgl2 = match window.raw_window_handle() {

Check warning on line 33 in blade-graphics/src/gles/web.rs

View workflow job for this annotation

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

use of deprecated method `raw_window_handle::HasRawWindowHandle::raw_window_handle`: Use `HasWindowHandle` instead
raw_window_handle::RawWindowHandle::Web(handle) => {
Ok(raw_window_handle::RawWindowHandle::Web(handle)) => {
let canvas: web_sys::HtmlCanvasElement = web_sys::window()
.and_then(|win| win.document())
.expect("Cannot get document")
Expand Down
2 changes: 1 addition & 1 deletion blade-graphics/src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ impl Context {
) -> Result<Self, super::NotSupportedError> {
let mut context = Self::init(desc)?;

let surface = match window.raw_window_handle() {
let surface = match window.raw_window_handle().unwrap() {

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

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

use of deprecated method `raw_window_handle::HasRawWindowHandle::raw_window_handle`: Use `HasWindowHandle` instead
#[cfg(target_os = "ios")]
raw_window_handle::RawWindowHandle::UiKit(handle) => {
Surface::from_view(handle.ui_view as *mut _)
Expand Down
130 changes: 69 additions & 61 deletions blade-graphics/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ fn make_buffer_image_copy(
}
}

fn map_render_target(rt: &crate::RenderTarget) -> vk::RenderingAttachmentInfo {
let mut builder = vk::RenderingAttachmentInfo::builder()
fn map_render_target(rt: &crate::RenderTarget) -> vk::RenderingAttachmentInfo<'static> {
let mut vk_info = vk::RenderingAttachmentInfo::default()
.image_view(rt.view.raw)
.image_layout(vk::ImageLayout::GENERAL)
.load_op(vk::AttachmentLoadOp::LOAD);
Expand Down Expand Up @@ -190,39 +190,40 @@ fn map_render_target(rt: &crate::RenderTarget) -> vk::RenderingAttachmentInfo {
},
}
};
builder = builder.load_op(vk::AttachmentLoadOp::CLEAR).clear_value(cv);
vk_info.load_op = vk::AttachmentLoadOp::CLEAR;
vk_info.clear_value = cv;
}

builder.build()
vk_info
}

impl super::CommandEncoder {
pub fn mark(&mut self, marker: &str) {
if let Some(ref mut ch) = self.crash_handler {
let id = ch.add_marker(marker);
unsafe {
(self
.device
self.device
.buffer_marker
.as_ref()
.unwrap()
.cmd_write_buffer_marker_amd)(
self.buffers[0].raw,
vk::PipelineStageFlags::ALL_COMMANDS,
ch.marker_buf.raw,
0,
id,
);
.cmd_write_buffer_marker(
self.buffers[0].raw,
vk::PipelineStageFlags::ALL_COMMANDS,
ch.marker_buf.raw,
0,
id,
);
}
}
}

pub fn start(&mut self) {
self.buffers.rotate_left(1);

let vk_info = vk::CommandBufferBeginInfo::builder()
.flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT)
.build();
let vk_info = vk::CommandBufferBeginInfo {
flags: vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT,
..Default::default()
};
unsafe {
self.device
.core
Expand All @@ -248,14 +249,13 @@ impl super::CommandEncoder {

fn barrier(&mut self) {
let wa = &self.device.workarounds;
let barrier = vk::MemoryBarrier::builder()
.src_access_mask(vk::AccessFlags::MEMORY_WRITE | wa.extra_sync_src_access)
.dst_access_mask(
vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE
| wa.extra_sync_dst_access,
)
.build();
let barrier = vk::MemoryBarrier {
src_access_mask: vk::AccessFlags::MEMORY_WRITE | wa.extra_sync_src_access,
dst_access_mask: vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE
| wa.extra_sync_dst_access,
..Default::default()
};
unsafe {
self.device.core.cmd_pipeline_barrier(
self.buffers[0].raw,
Expand All @@ -270,18 +270,19 @@ impl super::CommandEncoder {
}

pub fn init_texture(&mut self, texture: super::Texture) {
let barrier = vk::ImageMemoryBarrier::builder()
.old_layout(vk::ImageLayout::UNDEFINED)
.new_layout(vk::ImageLayout::GENERAL)
.image(texture.raw)
.subresource_range(vk::ImageSubresourceRange {
let barrier = vk::ImageMemoryBarrier {
old_layout: vk::ImageLayout::UNDEFINED,
new_layout: vk::ImageLayout::GENERAL,
image: texture.raw,
subresource_range: vk::ImageSubresourceRange {
aspect_mask: super::map_aspects(texture.format.aspects()),
base_mip_level: 0,
level_count: vk::REMAINING_MIP_LEVELS,
base_array_layer: 0,
layer_count: vk::REMAINING_ARRAY_LAYERS,
})
.build();
},
..Default::default()
};
unsafe {
self.device.core.cmd_pipeline_barrier(
self.buffers[0].raw,
Expand All @@ -303,19 +304,20 @@ impl super::CommandEncoder {
acquire_semaphore: frame.acquire_semaphore,
});

let barrier = vk::ImageMemoryBarrier::builder()
.old_layout(vk::ImageLayout::GENERAL)
.new_layout(vk::ImageLayout::PRESENT_SRC_KHR)
.image(frame.image)
.subresource_range(vk::ImageSubresourceRange {
let barrier = vk::ImageMemoryBarrier {
old_layout: vk::ImageLayout::GENERAL,
new_layout: vk::ImageLayout::PRESENT_SRC_KHR,
image: frame.image,
subresource_range: vk::ImageSubresourceRange {
aspect_mask: vk::ImageAspectFlags::COLOR,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
layer_count: 1,
})
.src_access_mask(vk::AccessFlags::MEMORY_WRITE | wa.extra_sync_src_access)
.build();
},
src_access_mask: vk::AccessFlags::MEMORY_WRITE | wa.extra_sync_src_access,
..Default::default()
};
unsafe {
self.device.core.cmd_pipeline_barrier(
self.buffers[0].raw,
Expand Down Expand Up @@ -369,9 +371,10 @@ impl super::CommandEncoder {
color_attachments.push(map_render_target(rt));
}

let mut rendering_info = vk::RenderingInfoKHR::builder()
let mut rendering_info = vk::RenderingInfoKHR::default()
.layer_count(1)
.color_attachments(&color_attachments);

if let Some(rt) = targets.depth_stencil {
target_size = rt.view.target_size;
depth_stencil_attachment = map_render_target(&rt);
Expand All @@ -398,7 +401,7 @@ impl super::CommandEncoder {
min_depth: 0.0,
max_depth: 1.0,
};
rendering_info = rendering_info.render_area(render_area);
rendering_info.render_area = render_area;

let cmd_buf = self.buffers[0];
unsafe {
Expand Down Expand Up @@ -584,26 +587,29 @@ impl crate::traits::AccelerationStructureEncoder
first_vertex: 0,
transform_offset: 0,
};
let geometry = vk::AccelerationStructureGeometryKHR::builder()
.geometry_type(vk::GeometryTypeKHR::INSTANCES)
.geometry(vk::AccelerationStructureGeometryDataKHR {
instances: vk::AccelerationStructureGeometryInstancesDataKHR::builder()
.data(vk::DeviceOrHostAddressConstKHR {
let geometry = vk::AccelerationStructureGeometryKHR {
geometry_type: vk::GeometryTypeKHR::INSTANCES,
geometry: vk::AccelerationStructureGeometryDataKHR {
instances: vk::AccelerationStructureGeometryInstancesDataKHR {
data: vk::DeviceOrHostAddressConstKHR {
device_address: self.device.get_device_address(&instance_data),
})
.build(),
})
.build();
},
..Default::default()
},
},
..Default::default()
};
let geometries = [geometry];
let build_info = vk::AccelerationStructureBuildGeometryInfoKHR::builder()
.ty(vk::AccelerationStructureTypeKHR::TOP_LEVEL)
.mode(vk::BuildAccelerationStructureModeKHR::BUILD)
.geometries(&geometries)
.scratch_data(vk::DeviceOrHostAddressKHR {
let build_info = vk::AccelerationStructureBuildGeometryInfoKHR {
ty: vk::AccelerationStructureTypeKHR::TOP_LEVEL,
mode: vk::BuildAccelerationStructureModeKHR::BUILD,
scratch_data: vk::DeviceOrHostAddressKHR {
device_address: self.device.get_device_address(&scratch_data),
})
.dst_acceleration_structure(acceleration_structure.raw)
.build();
},
dst_acceleration_structure: acceleration_structure.raw,
..Default::default()
}
.geometries(&geometries);

let rt = self.device.ray_tracing.as_ref().unwrap();
unsafe {
Expand Down Expand Up @@ -699,9 +705,11 @@ impl crate::traits::PipelineEncoder for super::PipelineEncoder<'_, '_> {
});

let descriptor_set_layouts = [dsl.raw];
let descriptor_set_info = vk::DescriptorSetAllocateInfo::builder()
.descriptor_pool(self.cmd_buf.descriptor_pool)
.set_layouts(&descriptor_set_layouts);
let descriptor_set_info = vk::DescriptorSetAllocateInfo {
descriptor_pool: self.cmd_buf.descriptor_pool,
..Default::default()
}
.set_layouts(&descriptor_set_layouts);
unsafe {
let sets = self
.device
Expand Down
Loading

0 comments on commit c096d11

Please sign in to comment.