mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Add inital debug labels
- bind group - bind group layout - command encoder - texture
This commit is contained in:
parent
2700d1cc15
commit
fdcf9e7067
@ -69,6 +69,7 @@ int main(
|
|||||||
|
|
||||||
WGPUBufferId buffer = wgpu_device_create_buffer_mapped(device,
|
WGPUBufferId buffer = wgpu_device_create_buffer_mapped(device,
|
||||||
&(WGPUBufferDescriptor){
|
&(WGPUBufferDescriptor){
|
||||||
|
.label = "buffer",
|
||||||
.size = size,
|
.size = size,
|
||||||
.usage = WGPUBufferUsage_STORAGE | WGPUBufferUsage_MAP_READ},
|
.usage = WGPUBufferUsage_STORAGE | WGPUBufferUsage_MAP_READ},
|
||||||
&staging_memory);
|
&staging_memory);
|
||||||
@ -80,6 +81,7 @@ int main(
|
|||||||
WGPUBindGroupLayoutId bind_group_layout =
|
WGPUBindGroupLayoutId bind_group_layout =
|
||||||
wgpu_device_create_bind_group_layout(device,
|
wgpu_device_create_bind_group_layout(device,
|
||||||
&(WGPUBindGroupLayoutDescriptor){
|
&(WGPUBindGroupLayoutDescriptor){
|
||||||
|
.label = "bind group layout",
|
||||||
.entries = &(WGPUBindGroupLayoutEntry){
|
.entries = &(WGPUBindGroupLayoutEntry){
|
||||||
.binding = 0,
|
.binding = 0,
|
||||||
.visibility = WGPUShaderStage_COMPUTE,
|
.visibility = WGPUShaderStage_COMPUTE,
|
||||||
@ -94,7 +96,9 @@ int main(
|
|||||||
.offset = 0}}};
|
.offset = 0}}};
|
||||||
|
|
||||||
WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device,
|
WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device,
|
||||||
&(WGPUBindGroupDescriptor){.layout = bind_group_layout,
|
&(WGPUBindGroupDescriptor){
|
||||||
|
.label = "bind group",
|
||||||
|
.layout = bind_group_layout,
|
||||||
.entries = &(WGPUBindGroupEntry){
|
.entries = &(WGPUBindGroupEntry){
|
||||||
.binding = 0,
|
.binding = 0,
|
||||||
.resource = resource},
|
.resource = resource},
|
||||||
@ -124,7 +128,7 @@ int main(
|
|||||||
|
|
||||||
WGPUCommandEncoderId encoder = wgpu_device_create_command_encoder(
|
WGPUCommandEncoderId encoder = wgpu_device_create_command_encoder(
|
||||||
device, &(WGPUCommandEncoderDescriptor){
|
device, &(WGPUCommandEncoderDescriptor){
|
||||||
.todo = 0
|
.label = "command encoder",
|
||||||
});
|
});
|
||||||
|
|
||||||
WGPUComputePassId command_pass =
|
WGPUComputePassId command_pass =
|
||||||
|
|||||||
@ -79,12 +79,14 @@ int main() {
|
|||||||
WGPUBindGroupLayoutId bind_group_layout =
|
WGPUBindGroupLayoutId bind_group_layout =
|
||||||
wgpu_device_create_bind_group_layout(device,
|
wgpu_device_create_bind_group_layout(device,
|
||||||
&(WGPUBindGroupLayoutDescriptor){
|
&(WGPUBindGroupLayoutDescriptor){
|
||||||
|
.label = "bind group layout",
|
||||||
.entries = NULL,
|
.entries = NULL,
|
||||||
.entries_length = 0,
|
.entries_length = 0,
|
||||||
});
|
});
|
||||||
WGPUBindGroupId bind_group =
|
WGPUBindGroupId bind_group =
|
||||||
wgpu_device_create_bind_group(device,
|
wgpu_device_create_bind_group(device,
|
||||||
&(WGPUBindGroupDescriptor){
|
&(WGPUBindGroupDescriptor){
|
||||||
|
.label = "bind group",
|
||||||
.layout = bind_group_layout,
|
.layout = bind_group_layout,
|
||||||
.entries = NULL,
|
.entries = NULL,
|
||||||
.entries_length = 0,
|
.entries_length = 0,
|
||||||
@ -237,7 +239,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder(
|
WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder(
|
||||||
device, &(WGPUCommandEncoderDescriptor){.todo = 0});
|
device, &(WGPUCommandEncoderDescriptor){.label = "command encoder"});
|
||||||
|
|
||||||
WGPURenderPassColorAttachmentDescriptor
|
WGPURenderPassColorAttachmentDescriptor
|
||||||
color_attachments[ATTACHMENTS_LENGTH] = {
|
color_attachments[ATTACHMENTS_LENGTH] = {
|
||||||
|
|||||||
@ -470,6 +470,7 @@ typedef struct {
|
|||||||
} WGPUBindGroupEntry;
|
} WGPUBindGroupEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const char *label;
|
||||||
WGPUBindGroupLayoutId layout;
|
WGPUBindGroupLayoutId layout;
|
||||||
const WGPUBindGroupEntry *entries;
|
const WGPUBindGroupEntry *entries;
|
||||||
uintptr_t entries_length;
|
uintptr_t entries_length;
|
||||||
@ -493,6 +494,7 @@ typedef struct {
|
|||||||
} WGPUBindGroupLayoutEntry;
|
} WGPUBindGroupLayoutEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const char *label;
|
||||||
const WGPUBindGroupLayoutEntry *entries;
|
const WGPUBindGroupLayoutEntry *entries;
|
||||||
uintptr_t entries_length;
|
uintptr_t entries_length;
|
||||||
} WGPUBindGroupLayoutDescriptor;
|
} WGPUBindGroupLayoutDescriptor;
|
||||||
@ -511,12 +513,13 @@ typedef uint32_t WGPUBufferUsage;
|
|||||||
#define WGPUBufferUsage_NONE 0
|
#define WGPUBufferUsage_NONE 0
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const char *label;
|
||||||
WGPUBufferAddress size;
|
WGPUBufferAddress size;
|
||||||
WGPUBufferUsage usage;
|
WGPUBufferUsage usage;
|
||||||
} WGPUBufferDescriptor;
|
} WGPUBufferDescriptor;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t todo;
|
const char *label;
|
||||||
} WGPUCommandEncoderDescriptor;
|
} WGPUCommandEncoderDescriptor;
|
||||||
|
|
||||||
typedef uint64_t WGPUId_PipelineLayout_Dummy;
|
typedef uint64_t WGPUId_PipelineLayout_Dummy;
|
||||||
@ -671,6 +674,7 @@ typedef struct {
|
|||||||
} WGPUSwapChainDescriptor;
|
} WGPUSwapChainDescriptor;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const char *label;
|
||||||
WGPUExtent3d size;
|
WGPUExtent3d size;
|
||||||
uint32_t array_layer_count;
|
uint32_t array_layer_count;
|
||||||
uint32_t mip_level_count;
|
uint32_t mip_level_count;
|
||||||
|
|||||||
@ -59,6 +59,7 @@ pub struct BindGroupLayoutEntry {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BindGroupLayoutDescriptor {
|
pub struct BindGroupLayoutDescriptor {
|
||||||
|
pub label: *const std::os::raw::c_char,
|
||||||
pub entries: *const BindGroupLayoutEntry,
|
pub entries: *const BindGroupLayoutEntry,
|
||||||
pub entries_length: usize,
|
pub entries_length: usize,
|
||||||
}
|
}
|
||||||
@ -115,6 +116,7 @@ pub struct BindGroupEntry {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BindGroupDescriptor {
|
pub struct BindGroupDescriptor {
|
||||||
|
pub label: *const std::os::raw::c_char,
|
||||||
pub layout: BindGroupLayoutId,
|
pub layout: BindGroupLayoutId,
|
||||||
pub entries: *const BindGroupEntry,
|
pub entries: *const BindGroupEntry,
|
||||||
pub entries_length: usize,
|
pub entries_length: usize,
|
||||||
|
|||||||
@ -321,8 +321,11 @@ impl<B: GfxBackend> Device<B> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut buffer = unsafe { self.raw.create_buffer(desc.size, usage).unwrap() };
|
let mut buffer = unsafe { self.raw.create_buffer(desc.size, usage).unwrap() };
|
||||||
if let Some(label) = desc.label {
|
if !desc.label.is_null() {
|
||||||
unsafe { self.raw.set_buffer_name(&mut buffer, label) };
|
unsafe {
|
||||||
|
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
|
||||||
|
self.raw.set_buffer_name(&mut buffer, &label)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
let requirements = unsafe { self.raw.get_buffer_requirements(&buffer) };
|
let requirements = unsafe { self.raw.get_buffer_requirements(&buffer) };
|
||||||
let memory = self
|
let memory = self
|
||||||
@ -398,16 +401,20 @@ impl<B: GfxBackend> Device<B> {
|
|||||||
// TODO: 2D arrays, cubemap arrays
|
// TODO: 2D arrays, cubemap arrays
|
||||||
|
|
||||||
let mut image = unsafe {
|
let mut image = unsafe {
|
||||||
self.raw.create_image(
|
let mut image = self.raw.create_image(
|
||||||
kind,
|
kind,
|
||||||
desc.mip_level_count as hal::image::Level,
|
desc.mip_level_count as hal::image::Level,
|
||||||
format,
|
format,
|
||||||
hal::image::Tiling::Optimal,
|
hal::image::Tiling::Optimal,
|
||||||
usage,
|
usage,
|
||||||
view_capabilities,
|
view_capabilities,
|
||||||
)
|
).unwrap();
|
||||||
}
|
if !desc.label.is_null() {
|
||||||
.unwrap();
|
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
|
||||||
|
self.raw.set_image_name(&mut image, &label);
|
||||||
|
}
|
||||||
|
image
|
||||||
|
};
|
||||||
let requirements = unsafe { self.raw.get_image_requirements(&image) };
|
let requirements = unsafe { self.raw.get_image_requirements(&image) };
|
||||||
|
|
||||||
let memory = self
|
let memory = self
|
||||||
@ -907,10 +914,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||||
let device = &device_guard[device_id];
|
let device = &device_guard[device_id];
|
||||||
let raw = unsafe {
|
let raw = unsafe {
|
||||||
device
|
let mut raw_layout = device
|
||||||
.raw
|
.raw
|
||||||
.create_descriptor_set_layout(&raw_bindings, &[])
|
.create_descriptor_set_layout(&raw_bindings, &[])
|
||||||
.unwrap()
|
.unwrap();
|
||||||
|
if !desc.label.is_null() {
|
||||||
|
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
|
||||||
|
device.raw.set_descriptor_set_layout_name(&mut raw_layout, &label);
|
||||||
|
}
|
||||||
|
raw_layout
|
||||||
};
|
};
|
||||||
|
|
||||||
let layout = binding_model::BindGroupLayout {
|
let layout = binding_model::BindGroupLayout {
|
||||||
@ -1009,7 +1021,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length as usize) };
|
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length as usize) };
|
||||||
assert_eq!(entries.len(), bind_group_layout.entries.len());
|
assert_eq!(entries.len(), bind_group_layout.entries.len());
|
||||||
|
|
||||||
let desc_set = unsafe {
|
let mut desc_set = unsafe {
|
||||||
let mut desc_sets = ArrayVec::<[_; 1]>::new();
|
let mut desc_sets = ArrayVec::<[_; 1]>::new();
|
||||||
device
|
device
|
||||||
.desc_allocator
|
.desc_allocator
|
||||||
@ -1025,6 +1037,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
desc_sets.pop().unwrap()
|
desc_sets.pop().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !desc.label.is_null() {
|
||||||
|
unsafe {
|
||||||
|
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
|
||||||
|
device.raw.set_descriptor_set_name(desc_set.raw_mut(), &label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fill out the descriptors
|
// fill out the descriptors
|
||||||
let mut used = TrackerSet::new(B::VARIANT);
|
let mut used = TrackerSet::new(B::VARIANT);
|
||||||
{
|
{
|
||||||
@ -1246,7 +1265,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
pub fn device_create_command_encoder<B: GfxBackend>(
|
pub fn device_create_command_encoder<B: GfxBackend>(
|
||||||
&self,
|
&self,
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
_desc: &wgt::CommandEncoderDescriptor,
|
desc: &wgt::CommandEncoderDescriptor,
|
||||||
id_in: Input<G, id::CommandEncoderId>,
|
id_in: Input<G, id::CommandEncoderId>,
|
||||||
) -> id::CommandEncoderId {
|
) -> id::CommandEncoderId {
|
||||||
let hub = B::hub(self);
|
let hub = B::hub(self);
|
||||||
@ -1264,17 +1283,22 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
|||||||
.lock_life(&mut token)
|
.lock_life(&mut token)
|
||||||
.lowest_active_submission();
|
.lowest_active_submission();
|
||||||
|
|
||||||
let mut comb = device
|
let mut command_buffer = device
|
||||||
.com_allocator
|
.com_allocator
|
||||||
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
|
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
|
||||||
unsafe {
|
unsafe {
|
||||||
comb.raw.last_mut().unwrap().begin_primary(
|
let raw_command_buffer = command_buffer.raw.last_mut().unwrap();
|
||||||
|
if !desc.label.is_null() {
|
||||||
|
let label = ffi::CStr::from_ptr(desc.label).to_string_lossy();
|
||||||
|
device.raw.set_command_buffer_name(raw_command_buffer, &label);
|
||||||
|
}
|
||||||
|
raw_command_buffer.begin_primary(
|
||||||
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hub.command_buffers
|
hub.command_buffers
|
||||||
.register_identity(id_in, comb, &mut token)
|
.register_identity(id_in, command_buffer, &mut token)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_encoder_destroy<B: GfxBackend>(
|
pub fn command_encoder_destroy<B: GfxBackend>(
|
||||||
|
|||||||
@ -536,20 +536,26 @@ bitflags::bitflags! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct BufferDescriptor<'a> {
|
pub struct BufferDescriptor {
|
||||||
pub label: Option<&'a str>,
|
pub label: *const std::os::raw::c_char,
|
||||||
pub size: BufferAddress,
|
pub size: BufferAddress,
|
||||||
pub usage: BufferUsage,
|
pub usage: BufferUsage,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct CommandEncoderDescriptor {
|
pub struct CommandEncoderDescriptor {
|
||||||
// MSVC doesn't allow zero-sized structs
|
// MSVC doesn't allow zero-sized structs
|
||||||
// We can remove this when we actually have a field
|
// We can remove this when we actually have a field
|
||||||
pub todo: u32,
|
// pub todo: u32,
|
||||||
|
pub label: *const std::os::raw::c_char,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CommandEncoderDescriptor {
|
||||||
|
fn default() -> CommandEncoderDescriptor {
|
||||||
|
unsafe { std::mem::zeroed() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type DynamicOffset = u32;
|
pub type DynamicOffset = u32;
|
||||||
@ -735,6 +741,7 @@ pub struct Extent3d {
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct TextureDescriptor {
|
pub struct TextureDescriptor {
|
||||||
|
pub label: *const std::os::raw::c_char,
|
||||||
pub size: Extent3d,
|
pub size: Extent3d,
|
||||||
pub array_layer_count: u32,
|
pub array_layer_count: u32,
|
||||||
pub mip_level_count: u32,
|
pub mip_level_count: u32,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user