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,
|
||||
&(WGPUBufferDescriptor){
|
||||
.label = "buffer",
|
||||
.size = size,
|
||||
.usage = WGPUBufferUsage_STORAGE | WGPUBufferUsage_MAP_READ},
|
||||
&staging_memory);
|
||||
@ -80,6 +81,7 @@ int main(
|
||||
WGPUBindGroupLayoutId bind_group_layout =
|
||||
wgpu_device_create_bind_group_layout(device,
|
||||
&(WGPUBindGroupLayoutDescriptor){
|
||||
.label = "bind group layout",
|
||||
.entries = &(WGPUBindGroupLayoutEntry){
|
||||
.binding = 0,
|
||||
.visibility = WGPUShaderStage_COMPUTE,
|
||||
@ -94,7 +96,9 @@ int main(
|
||||
.offset = 0}}};
|
||||
|
||||
WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device,
|
||||
&(WGPUBindGroupDescriptor){.layout = bind_group_layout,
|
||||
&(WGPUBindGroupDescriptor){
|
||||
.label = "bind group",
|
||||
.layout = bind_group_layout,
|
||||
.entries = &(WGPUBindGroupEntry){
|
||||
.binding = 0,
|
||||
.resource = resource},
|
||||
@ -124,7 +128,7 @@ int main(
|
||||
|
||||
WGPUCommandEncoderId encoder = wgpu_device_create_command_encoder(
|
||||
device, &(WGPUCommandEncoderDescriptor){
|
||||
.todo = 0
|
||||
.label = "command encoder",
|
||||
});
|
||||
|
||||
WGPUComputePassId command_pass =
|
||||
|
||||
@ -79,12 +79,14 @@ int main() {
|
||||
WGPUBindGroupLayoutId bind_group_layout =
|
||||
wgpu_device_create_bind_group_layout(device,
|
||||
&(WGPUBindGroupLayoutDescriptor){
|
||||
.label = "bind group layout",
|
||||
.entries = NULL,
|
||||
.entries_length = 0,
|
||||
});
|
||||
WGPUBindGroupId bind_group =
|
||||
wgpu_device_create_bind_group(device,
|
||||
&(WGPUBindGroupDescriptor){
|
||||
.label = "bind group",
|
||||
.layout = bind_group_layout,
|
||||
.entries = NULL,
|
||||
.entries_length = 0,
|
||||
@ -237,7 +239,7 @@ int main() {
|
||||
}
|
||||
|
||||
WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder(
|
||||
device, &(WGPUCommandEncoderDescriptor){.todo = 0});
|
||||
device, &(WGPUCommandEncoderDescriptor){.label = "command encoder"});
|
||||
|
||||
WGPURenderPassColorAttachmentDescriptor
|
||||
color_attachments[ATTACHMENTS_LENGTH] = {
|
||||
|
||||
@ -470,6 +470,7 @@ typedef struct {
|
||||
} WGPUBindGroupEntry;
|
||||
|
||||
typedef struct {
|
||||
const char *label;
|
||||
WGPUBindGroupLayoutId layout;
|
||||
const WGPUBindGroupEntry *entries;
|
||||
uintptr_t entries_length;
|
||||
@ -493,6 +494,7 @@ typedef struct {
|
||||
} WGPUBindGroupLayoutEntry;
|
||||
|
||||
typedef struct {
|
||||
const char *label;
|
||||
const WGPUBindGroupLayoutEntry *entries;
|
||||
uintptr_t entries_length;
|
||||
} WGPUBindGroupLayoutDescriptor;
|
||||
@ -511,12 +513,13 @@ typedef uint32_t WGPUBufferUsage;
|
||||
#define WGPUBufferUsage_NONE 0
|
||||
|
||||
typedef struct {
|
||||
const char *label;
|
||||
WGPUBufferAddress size;
|
||||
WGPUBufferUsage usage;
|
||||
} WGPUBufferDescriptor;
|
||||
|
||||
typedef struct {
|
||||
uint32_t todo;
|
||||
const char *label;
|
||||
} WGPUCommandEncoderDescriptor;
|
||||
|
||||
typedef uint64_t WGPUId_PipelineLayout_Dummy;
|
||||
@ -671,6 +674,7 @@ typedef struct {
|
||||
} WGPUSwapChainDescriptor;
|
||||
|
||||
typedef struct {
|
||||
const char *label;
|
||||
WGPUExtent3d size;
|
||||
uint32_t array_layer_count;
|
||||
uint32_t mip_level_count;
|
||||
|
||||
@ -59,6 +59,7 @@ pub struct BindGroupLayoutEntry {
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct BindGroupLayoutDescriptor {
|
||||
pub label: *const std::os::raw::c_char,
|
||||
pub entries: *const BindGroupLayoutEntry,
|
||||
pub entries_length: usize,
|
||||
}
|
||||
@ -115,6 +116,7 @@ pub struct BindGroupEntry {
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct BindGroupDescriptor {
|
||||
pub label: *const std::os::raw::c_char,
|
||||
pub layout: BindGroupLayoutId,
|
||||
pub entries: *const BindGroupEntry,
|
||||
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() };
|
||||
if let Some(label) = desc.label {
|
||||
unsafe { self.raw.set_buffer_name(&mut buffer, label) };
|
||||
if !desc.label.is_null() {
|
||||
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 memory = self
|
||||
@ -398,16 +401,20 @@ impl<B: GfxBackend> Device<B> {
|
||||
// TODO: 2D arrays, cubemap arrays
|
||||
|
||||
let mut image = unsafe {
|
||||
self.raw.create_image(
|
||||
let mut image = self.raw.create_image(
|
||||
kind,
|
||||
desc.mip_level_count as hal::image::Level,
|
||||
format,
|
||||
hal::image::Tiling::Optimal,
|
||||
usage,
|
||||
view_capabilities,
|
||||
)
|
||||
}
|
||||
.unwrap();
|
||||
).unwrap();
|
||||
if !desc.label.is_null() {
|
||||
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 memory = self
|
||||
@ -907,10 +914,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let device = &device_guard[device_id];
|
||||
let raw = unsafe {
|
||||
device
|
||||
let mut raw_layout = device
|
||||
.raw
|
||||
.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 {
|
||||
@ -1009,7 +1021,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
unsafe { slice::from_raw_parts(desc.entries, desc.entries_length as usize) };
|
||||
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();
|
||||
device
|
||||
.desc_allocator
|
||||
@ -1025,6 +1037,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
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
|
||||
let mut used = TrackerSet::new(B::VARIANT);
|
||||
{
|
||||
@ -1246,7 +1265,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
pub fn device_create_command_encoder<B: GfxBackend>(
|
||||
&self,
|
||||
device_id: id::DeviceId,
|
||||
_desc: &wgt::CommandEncoderDescriptor,
|
||||
desc: &wgt::CommandEncoderDescriptor,
|
||||
id_in: Input<G, id::CommandEncoderId>,
|
||||
) -> id::CommandEncoderId {
|
||||
let hub = B::hub(self);
|
||||
@ -1264,17 +1283,22 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.lock_life(&mut token)
|
||||
.lowest_active_submission();
|
||||
|
||||
let mut comb = device
|
||||
let mut command_buffer = device
|
||||
.com_allocator
|
||||
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
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>(
|
||||
|
||||
@ -536,20 +536,26 @@ bitflags::bitflags! {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct BufferDescriptor<'a> {
|
||||
pub label: Option<&'a str>,
|
||||
pub struct BufferDescriptor {
|
||||
pub label: *const std::os::raw::c_char,
|
||||
pub size: BufferAddress,
|
||||
pub usage: BufferUsage,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct CommandEncoderDescriptor {
|
||||
// MSVC doesn't allow zero-sized structs
|
||||
// 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;
|
||||
@ -735,6 +741,7 @@ pub struct Extent3d {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct TextureDescriptor {
|
||||
pub label: *const std::os::raw::c_char,
|
||||
pub size: Extent3d,
|
||||
pub array_layer_count: u32,
|
||||
pub mip_level_count: u32,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user