mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Standalone render passes
This commit is contained in:
parent
7808a4d4cd
commit
20cd803d67
10
ffi/wgpu.h
10
ffi/wgpu.h
@ -319,7 +319,9 @@ typedef struct {
|
||||
WGPULoadOp load_op;
|
||||
WGPUStoreOp store_op;
|
||||
WGPUColor clear_color;
|
||||
} WGPURenderPassColorAttachmentDescriptor;
|
||||
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId;
|
||||
|
||||
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId WGPURenderPassColorAttachmentDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId attachment;
|
||||
@ -329,12 +331,14 @@ typedef struct {
|
||||
WGPULoadOp stencil_load_op;
|
||||
WGPUStoreOp stencil_store_op;
|
||||
uint32_t clear_stencil;
|
||||
} WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId;
|
||||
} WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId;
|
||||
|
||||
typedef WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor;
|
||||
|
||||
typedef struct {
|
||||
const WGPURenderPassColorAttachmentDescriptor *color_attachments;
|
||||
uintptr_t color_attachments_length;
|
||||
const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment;
|
||||
const WGPURenderPassDepthStencilAttachmentDescriptor *depth_stencil_attachment;
|
||||
} WGPURenderPassDescriptor;
|
||||
|
||||
typedef struct {
|
||||
|
@ -44,6 +44,12 @@ pub struct StandaloneComputePass<'a> {
|
||||
pub offsets: &'a [BufferAddress],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct ComputePassDescriptor {
|
||||
pub todo: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ComputePass<B: hal::Backend> {
|
||||
raw: B::CommandBuffer,
|
||||
|
@ -35,7 +35,6 @@ use crate::{
|
||||
},
|
||||
resource::{Buffer, Texture, TextureUsage, TextureViewInner},
|
||||
track::TrackerSet,
|
||||
Color,
|
||||
Features,
|
||||
LifeGuard,
|
||||
Stored,
|
||||
@ -61,56 +60,6 @@ pub struct RenderBundle<B: hal::Backend> {
|
||||
_raw: B::CommandBuffer,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum LoadOp {
|
||||
Clear = 0,
|
||||
Load = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum StoreOp {
|
||||
Clear = 0,
|
||||
Store = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct RenderPassColorAttachmentDescriptor {
|
||||
pub attachment: TextureViewId,
|
||||
pub resolve_target: *const TextureViewId,
|
||||
pub load_op: LoadOp,
|
||||
pub store_op: StoreOp,
|
||||
pub clear_color: Color,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct RenderPassDepthStencilAttachmentDescriptor<T> {
|
||||
pub attachment: T,
|
||||
pub depth_load_op: LoadOp,
|
||||
pub depth_store_op: StoreOp,
|
||||
pub clear_depth: f32,
|
||||
pub stencil_load_op: LoadOp,
|
||||
pub stencil_store_op: StoreOp,
|
||||
pub clear_stencil: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct RenderPassDescriptor {
|
||||
pub color_attachments: *const RenderPassColorAttachmentDescriptor,
|
||||
pub color_attachments_length: usize,
|
||||
pub depth_stencil_attachment: *const RenderPassDepthStencilAttachmentDescriptor<TextureViewId>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct ComputePassDescriptor {
|
||||
pub todo: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CommandBuffer<B: hal::Backend> {
|
||||
pub(crate) raw: Vec<B::CommandBuffer>,
|
||||
@ -377,7 +326,7 @@ impl<F: IdentityFilter<RenderPassId>> Global<F> {
|
||||
|
||||
for &resolve_target in color_attachments
|
||||
.iter()
|
||||
.flat_map(|at| unsafe { at.resolve_target.as_ref() })
|
||||
.flat_map(|at| at.resolve_target)
|
||||
{
|
||||
let view = &view_guard[resolve_target];
|
||||
assert_eq!(extent, Some(view.extent));
|
||||
@ -485,10 +434,10 @@ impl<F: IdentityFilter<RenderPassId>> Global<F> {
|
||||
let mut attachment_index = color_attachments.len();
|
||||
if color_attachments
|
||||
.iter()
|
||||
.any(|at| !at.resolve_target.is_null())
|
||||
.any(|at| at.resolve_target.is_some())
|
||||
{
|
||||
for (i, at) in color_attachments.iter().enumerate() {
|
||||
if at.resolve_target.is_null() {
|
||||
if at.resolve_target.is_none() {
|
||||
resolve_ids.push((
|
||||
hal::pass::ATTACHMENT_UNUSED,
|
||||
hal::image::Layout::ColorAttachmentOptimal,
|
||||
@ -534,7 +483,8 @@ impl<F: IdentityFilter<RenderPassId>> Global<F> {
|
||||
colors: color_attachments.iter().map(|at| at.attachment).collect(),
|
||||
resolves: color_attachments
|
||||
.iter()
|
||||
.filter_map(|at| unsafe { at.resolve_target.as_ref() }.cloned())
|
||||
.filter_map(|at| at.resolve_target)
|
||||
.cloned()
|
||||
.collect(),
|
||||
depth_stencil: depth_stencil_attachment.map(|at| at.attachment),
|
||||
};
|
||||
@ -665,7 +615,7 @@ impl<F: IdentityFilter<RenderPassId>> Global<F> {
|
||||
.collect(),
|
||||
resolves: color_attachments
|
||||
.iter()
|
||||
.filter_map(|at| unsafe { at.resolve_target.as_ref() })
|
||||
.filter_map(|at| at.resolve_target)
|
||||
.map(|resolve| view_guard[*resolve].format)
|
||||
.collect(),
|
||||
depth_stencil: depth_stencil_attachment.map(|at| view_guard[at.attachment].format),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -139,6 +139,27 @@ pub unsafe extern "C" fn wgpu_server_encode_compute_pass(
|
||||
gfx_select!(self_id => global.command_encoder_run_compute_pass(self_id, pass));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wgpu_server_encode_render_pass(
|
||||
global: &Global,
|
||||
self_id: id::CommandEncoderId,
|
||||
color_attachments: *const core::command::RenderPassColorAttachmentDescriptor,
|
||||
color_attachment_length: usize,
|
||||
depth_stencil_attachment: Option<&core::command::RenderPassDepthStencilAttachmentDescriptor>,
|
||||
commands: *const core::command::RenderCommand,
|
||||
command_length: usize,
|
||||
offsets: *const core::BufferAddress,
|
||||
offset_length: usize,
|
||||
) {
|
||||
let pass = core::command::StandaloneRenderPass {
|
||||
color_attachments: slice::from_raw_parts(color_attachments, color_attachment_length),
|
||||
depth_stencil_attachment,
|
||||
commands: slice::from_raw_parts(commands, command_length),
|
||||
offsets: slice::from_raw_parts(offsets, offset_length),
|
||||
};
|
||||
gfx_select!(self_id => global.command_encoder_run_render_pass(self_id, pass));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wgpu_server_queue_submit(
|
||||
global: &Global,
|
||||
|
Loading…
Reference in New Issue
Block a user