492: Encode render targets into the render pass blob r=grovesNL a=kvark

Fixes #454

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot] 2020-02-11 12:58:14 +00:00 committed by GitHub
commit a048f5e5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 155 deletions

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Generated with cbindgen:0.12.2 */
/* Generated with cbindgen:0.13.1 */
/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen.
* To generate this file:
@ -311,6 +311,8 @@ typedef uint64_t WGPUId_TextureView_Dummy;
typedef WGPUId_TextureView_Dummy WGPUTextureViewId;
typedef const WGPUTextureViewId *WGPUOptionRef_TextureViewId;
typedef struct {
double r;
double g;
@ -326,13 +328,13 @@ typedef struct {
typedef struct {
WGPUTextureViewId attachment;
WGPUTextureViewId resolve_target;
WGPUOptionRef_TextureViewId resolve_target;
WGPULoadOp load_op;
WGPUStoreOp store_op;
WGPUColor clear_color;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId;
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__TextureViewId WGPURawRenderPassColorAttachmentDescriptor;
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId WGPURenderPassColorAttachmentDescriptor;
typedef struct {
WGPUTextureViewId attachment;
@ -346,28 +348,6 @@ typedef struct {
typedef WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor;
typedef struct {
WGPURawRenderPassColorAttachmentDescriptor colors[WGPUMAX_COLOR_TARGETS];
WGPURenderPassDepthStencilAttachmentDescriptor depth_stencil;
} WGPURawRenderTargets;
typedef struct {
WGPURawPass raw;
WGPURawRenderTargets targets;
} WGPURawRenderPass;
typedef const WGPUTextureViewId *WGPUOptionRef_TextureViewId;
typedef struct {
WGPUTextureViewId attachment;
WGPUOptionRef_TextureViewId resolve_target;
WGPULoadOp load_op;
WGPUStoreOp store_op;
WGPUColor clear_color;
} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId;
typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId__OptionRef_TextureViewId WGPURenderPassColorAttachmentDescriptor;
typedef struct {
const WGPURenderPassColorAttachmentDescriptor *color_attachments;
uintptr_t color_attachments_length;
@ -680,7 +660,7 @@ typedef struct {
typedef WGPUDeviceId WGPUQueueId;
typedef WGPURawRenderPass *WGPURenderPassId;
typedef WGPURawPass *WGPURenderPassId;
typedef uint64_t WGPUId_RenderBundle_Dummy;
@ -750,8 +730,8 @@ WGPURawPass *wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encode
* (`RenderPassDescriptor::color_attachments`) is valid for
* `RenderPassDescriptor::color_attachments_length` elements.
*/
WGPURawRenderPass *wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
const WGPURenderPassDescriptor *desc);
WGPURawPass *wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id,
const WGPURenderPassDescriptor *desc);
void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id,
WGPUBufferId source,
@ -882,26 +862,26 @@ void wgpu_queue_submit(WGPUQueueId queue_id,
const WGPUCommandBufferId *command_buffers,
uintptr_t command_buffers_length);
void wgpu_render_pass_destroy(WGPURawRenderPass *pass);
void wgpu_render_pass_destroy(WGPURawPass *pass);
void wgpu_render_pass_draw(WGPURawRenderPass *pass,
void wgpu_render_pass_draw(WGPURawPass *pass,
uint32_t vertex_count,
uint32_t instance_count,
uint32_t first_vertex,
uint32_t first_instance);
void wgpu_render_pass_draw_indexed(WGPURawRenderPass *pass,
void wgpu_render_pass_draw_indexed(WGPURawPass *pass,
uint32_t index_count,
uint32_t instance_count,
uint32_t first_index,
int32_t base_vertex,
uint32_t first_instance);
void wgpu_render_pass_draw_indexed_indirect(WGPURawRenderPass *pass,
void wgpu_render_pass_draw_indexed_indirect(WGPURawPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);
void wgpu_render_pass_draw_indirect(WGPURawRenderPass *pass,
void wgpu_render_pass_draw_indirect(WGPURawPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);
@ -914,17 +894,17 @@ void wgpu_render_pass_draw_indirect(WGPURawRenderPass *pass,
*/
void wgpu_render_pass_end_pass(WGPURenderPassId pass_id);
void wgpu_render_pass_execute_bundles(WGPURawRenderPass *_pass,
void wgpu_render_pass_execute_bundles(WGPURawPass *_pass,
const WGPURenderBundleId *_bundles,
uintptr_t _bundles_length);
const uint8_t *wgpu_render_pass_finish(WGPURawRenderPass *pass, uintptr_t *length);
const uint8_t *wgpu_render_pass_finish(WGPURawPass *pass, uintptr_t *length);
void wgpu_render_pass_insert_debug_marker(WGPURawRenderPass *_pass, WGPURawString _label);
void wgpu_render_pass_insert_debug_marker(WGPURawPass *_pass, WGPURawString _label);
void wgpu_render_pass_pop_debug_group(WGPURawRenderPass *_pass);
void wgpu_render_pass_pop_debug_group(WGPURawPass *_pass);
void wgpu_render_pass_push_debug_group(WGPURawRenderPass *_pass, WGPURawString _label);
void wgpu_render_pass_push_debug_group(WGPURawPass *_pass, WGPURawString _label);
/**
* # Safety
@ -932,27 +912,27 @@ void wgpu_render_pass_push_debug_group(WGPURawRenderPass *_pass, WGPURawString _
* This function is unsafe as there is no guarantee that the given pointer is
* valid for `offset_length` elements.
*/
void wgpu_render_pass_set_bind_group(WGPURawRenderPass *pass,
void wgpu_render_pass_set_bind_group(WGPURawPass *pass,
uint32_t index,
WGPUBindGroupId bind_group_id,
const WGPUDynamicOffset *offsets,
uintptr_t offset_length);
void wgpu_render_pass_set_blend_color(WGPURawRenderPass *pass, const WGPUColor *color);
void wgpu_render_pass_set_blend_color(WGPURawPass *pass, const WGPUColor *color);
void wgpu_render_pass_set_index_buffer(WGPURawRenderPass *pass,
void wgpu_render_pass_set_index_buffer(WGPURawPass *pass,
WGPUBufferId buffer_id,
WGPUBufferAddress offset);
void wgpu_render_pass_set_pipeline(WGPURawRenderPass *pass, WGPURenderPipelineId pipeline_id);
void wgpu_render_pass_set_pipeline(WGPURawPass *pass, WGPURenderPipelineId pipeline_id);
void wgpu_render_pass_set_scissor_rect(WGPURawRenderPass *pass,
void wgpu_render_pass_set_scissor_rect(WGPURawPass *pass,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h);
void wgpu_render_pass_set_stencil_reference(WGPURawRenderPass *pass, uint32_t value);
void wgpu_render_pass_set_stencil_reference(WGPURawPass *pass, uint32_t value);
/**
* # Safety
@ -960,13 +940,13 @@ void wgpu_render_pass_set_stencil_reference(WGPURawRenderPass *pass, uint32_t va
* This function is unsafe as there is no guarantee that the given pointers
* (`buffer_ids` and `offsets`) are valid for `length` elements.
*/
void wgpu_render_pass_set_vertex_buffers(WGPURawRenderPass *pass,
void wgpu_render_pass_set_vertex_buffers(WGPURawPass *pass,
uint32_t start_slot,
const WGPUBufferId *buffer_ids,
const WGPUBufferAddress *offsets,
uintptr_t length);
void wgpu_render_pass_set_viewport(WGPURawRenderPass *pass,
void wgpu_render_pass_set_viewport(WGPURawPass *pass,
float x,
float y,
float w,

View File

@ -208,21 +208,16 @@ pub struct CommandBufferDescriptor {
pub todo: u32,
}
type RawRenderPassColorAttachmentDescriptor =
pub type RawRenderPassColorAttachmentDescriptor =
RenderPassColorAttachmentDescriptorBase<id::TextureViewId, id::TextureViewId>;
#[repr(C)]
#[derive(peek_poke::PeekCopy, peek_poke::Poke)]
pub struct RawRenderTargets {
pub colors: [RawRenderPassColorAttachmentDescriptor; MAX_COLOR_TARGETS],
pub depth_stencil: RenderPassDepthStencilAttachmentDescriptor,
}
#[repr(C)]
pub struct RawRenderPass {
raw: RawPass,
targets: RawRenderTargets,
}
/// # Safety
///
/// This function is unsafe as there is no guarantee that the given pointer
@ -232,9 +227,14 @@ pub struct RawRenderPass {
pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass(
encoder_id: id::CommandEncoderId,
desc: &RenderPassDescriptor,
) -> *mut RawRenderPass {
let mut colors: [RawRenderPassColorAttachmentDescriptor; MAX_COLOR_TARGETS] = mem::zeroed();
for (color, at) in colors
) -> *mut RawPass {
let mut targets = RawRenderTargets {
depth_stencil: desc.depth_stencil_attachment
.cloned()
.unwrap_or_else(|| mem::zeroed()),
colors: mem::zeroed(),
};
for (color, at) in targets.colors
.iter_mut()
.zip(slice::from_raw_parts(desc.color_attachments, desc.color_attachments_length))
{
@ -246,15 +246,9 @@ pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass(
clear_color: at.clear_color,
};
}
let pass = RawRenderPass {
raw: RawPass::new_render(encoder_id),
targets: RawRenderTargets {
colors,
depth_stencil: desc.depth_stencil_attachment
.cloned()
.unwrap_or_else(|| mem::zeroed()),
},
};
let mut pass = RawPass::new_render(encoder_id);
pass.encode(&targets);
Box::into_raw(Box::new(pass))
}

View File

@ -37,26 +37,27 @@ use std::{
collections::hash_map::Entry,
iter,
marker::PhantomData,
mem,
ops::Range,
};
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PeekCopy, Poke)]
pub enum LoadOp {
Clear = 0,
Load = 1,
}
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PeekCopy, Poke)]
pub enum StoreOp {
Clear = 0,
Store = 1,
}
#[repr(C)]
#[derive(Debug)]
#[derive(Debug, PeekCopy, Poke)]
pub struct RenderPassColorAttachmentDescriptorBase<T, R> {
pub attachment: T,
pub resolve_target: R,
@ -66,7 +67,7 @@ pub struct RenderPassColorAttachmentDescriptorBase<T, R> {
}
#[repr(C)]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PeekCopy, Poke)]
pub struct RenderPassDepthStencilAttachmentDescriptorBase<T> {
pub attachment: T,
pub depth_load_op: LoadOp,
@ -157,13 +158,11 @@ impl super::RawPass {
pub fn new_render(parent_id: id::CommandEncoderId) -> Self {
Self::from_vec(Vec::<RenderCommand>::with_capacity(1), parent_id)
}
}
impl super::RawRenderPass {
pub unsafe fn finish_render(mut self) -> (Vec<u8>, id::CommandEncoderId, RawRenderTargets) {
self.raw.finish(RenderCommand::End);
let (vec, parent_id) = self.raw.into_vec();
(vec, parent_id, self.targets)
pub unsafe fn finish_render(mut self) -> (Vec<u8>, id::CommandEncoderId) {
self.finish(RenderCommand::End);
let (vec, parent_id) = self.into_vec();
(vec, parent_id)
}
}
@ -289,8 +288,6 @@ impl<F> Global<F> {
pub fn command_encoder_run_render_pass<B: GfxBackend>(
&self,
encoder_id: id::CommandEncoderId,
color_attachments: &[RenderPassColorAttachmentDescriptor],
depth_stencil_attachment: Option<&RenderPassDepthStencilAttachmentDescriptor>,
raw_data: &[u8],
) {
let hub = B::hub(self);
@ -316,6 +313,38 @@ impl<F> Global<F> {
let (texture_guard, mut token) = hub.textures.read(&mut token);
let (view_guard, _) = hub.texture_views.read(&mut token);
let mut peeker = raw_data.as_ptr();
let raw_data_end = unsafe {
raw_data.as_ptr().add(raw_data.len())
};
let mut targets: RawRenderTargets = unsafe { mem::zeroed() };
assert!(unsafe { peeker.add(RawRenderTargets::max_size()) <= raw_data_end });
peeker = unsafe { targets.peek_from(peeker) };
let color_attachments = targets.colors
.iter()
.take_while(|at| at.attachment != id::TextureViewId::ERROR)
.map(|at| {
RenderPassColorAttachmentDescriptor {
attachment: at.attachment,
resolve_target: if at.resolve_target == id::TextureViewId::ERROR {
None
} else {
Some(&at.resolve_target)
},
load_op: at.load_op,
store_op: at.store_op,
clear_color: at.clear_color,
}
})
.collect::<arrayvec::ArrayVec<[_; MAX_COLOR_TARGETS]>>();
let depth_stencil_attachment = if targets.depth_stencil.attachment == id::TextureViewId::ERROR {
None
} else {
Some(&targets.depth_stencil)
};
let (context, sample_count) = {
use hal::{adapter::PhysicalDevice as _, device::Device as _};
@ -401,7 +430,7 @@ impl<F> Global<F> {
let mut colors = ArrayVec::new();
let mut resolves = ArrayVec::new();
for at in color_attachments {
for at in &color_attachments {
let view = &view_guard[at.attachment];
if let Some(ex) = extent {
assert_eq!(ex, view.extent);
@ -770,10 +799,6 @@ impl<F> Global<F> {
},
};
let mut peeker = raw_data.as_ptr();
let raw_data_end = unsafe {
raw_data.as_ptr().add(raw_data.len())
};
let mut command = RenderCommand::Draw {
vertex_count: 0,
instance_count: 0,
@ -1113,7 +1138,7 @@ impl<F> Global<F> {
pub mod render_ffi {
use super::{
RenderCommand,
super::{PhantomSlice, RawRenderPass, Rect},
super::{PhantomSlice, RawPass, Rect},
};
use crate::{
id,
@ -1132,38 +1157,38 @@ pub mod render_ffi {
// `RawPass::encode` and `RawPass::encode_slice`.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_bind_group(
pass: &mut RawRenderPass,
pass: &mut RawPass,
index: u32,
bind_group_id: id::BindGroupId,
offsets: *const DynamicOffset,
offset_length: usize,
) {
pass.raw.encode(&RenderCommand::SetBindGroup {
pass.encode(&RenderCommand::SetBindGroup {
index: index.try_into().unwrap(),
num_dynamic_offsets: offset_length.try_into().unwrap(),
bind_group_id,
phantom_offsets: PhantomSlice::new(),
});
pass.raw.encode_slice(
pass.encode_slice(
slice::from_raw_parts(offsets, offset_length),
);
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_pipeline(
pass: &mut RawRenderPass,
pass: &mut RawPass,
pipeline_id: id::RenderPipelineId,
) {
pass.raw.encode(&RenderCommand::SetPipeline(pipeline_id));
pass.encode(&RenderCommand::SetPipeline(pipeline_id));
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_index_buffer(
pass: &mut RawRenderPass,
pass: &mut RawPass,
buffer_id: id::BufferId,
offset: BufferAddress,
) {
pass.raw.encode(&RenderCommand::SetIndexBuffer {
pass.encode(&RenderCommand::SetIndexBuffer {
buffer_id,
offset,
});
@ -1177,45 +1202,45 @@ pub mod render_ffi {
// `RawPass::encode` and `RawPass::encode_slice`.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_vertex_buffers(
pass: &mut RawRenderPass,
pass: &mut RawPass,
start_slot: u32,
buffer_ids: *const id::BufferId,
offsets: *const BufferAddress,
length: usize,
) {
pass.raw.encode(&RenderCommand::SetVertexBuffers {
pass.encode(&RenderCommand::SetVertexBuffers {
start_index: start_slot.try_into().unwrap(),
count: length.try_into().unwrap(),
phantom_buffer_ids: PhantomSlice::new(),
phantom_offsets: PhantomSlice::new(),
});
pass.raw.encode_slice(
pass.encode_slice(
slice::from_raw_parts(buffer_ids, length),
);
pass.raw.encode_slice(
pass.encode_slice(
slice::from_raw_parts(offsets, length),
);
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_blend_color(
pass: &mut RawRenderPass,
pass: &mut RawPass,
color: &Color,
) {
pass.raw.encode(&RenderCommand::SetBlendColor(*color));
pass.encode(&RenderCommand::SetBlendColor(*color));
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_stencil_reference(
pass: &mut RawRenderPass,
pass: &mut RawPass,
value: u32,
) {
pass.raw.encode(&RenderCommand::SetStencilReference(value));
pass.encode(&RenderCommand::SetStencilReference(value));
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_viewport(
pass: &mut RawRenderPass,
pass: &mut RawPass,
x: f32,
y: f32,
w: f32,
@ -1223,7 +1248,7 @@ pub mod render_ffi {
depth_min: f32,
depth_max: f32,
) {
pass.raw.encode(&RenderCommand::SetViewport {
pass.encode(&RenderCommand::SetViewport {
rect: Rect { x, y, w, h },
depth_min,
depth_max,
@ -1232,24 +1257,24 @@ pub mod render_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_set_scissor_rect(
pass: &mut RawRenderPass,
pass: &mut RawPass,
x: u32,
y: u32,
w: u32,
h: u32,
) {
pass.raw.encode(&RenderCommand::SetScissor(Rect { x, y, w, h }));
pass.encode(&RenderCommand::SetScissor(Rect { x, y, w, h }));
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_draw(
pass: &mut RawRenderPass,
pass: &mut RawPass,
vertex_count: u32,
instance_count: u32,
first_vertex: u32,
first_instance: u32,
) {
pass.raw.encode(&RenderCommand::Draw {
pass.encode(&RenderCommand::Draw {
vertex_count,
instance_count,
first_vertex,
@ -1259,14 +1284,14 @@ pub mod render_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_draw_indexed(
pass: &mut RawRenderPass,
pass: &mut RawPass,
index_count: u32,
instance_count: u32,
first_index: u32,
base_vertex: i32,
first_instance: u32,
) {
pass.raw.encode(&RenderCommand::DrawIndexed {
pass.encode(&RenderCommand::DrawIndexed {
index_count,
instance_count,
first_index,
@ -1277,11 +1302,11 @@ pub mod render_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_draw_indirect(
pass: &mut RawRenderPass,
pass: &mut RawPass,
buffer_id: id::BufferId,
offset: BufferAddress,
) {
pass.raw.encode(&RenderCommand::DrawIndirect {
pass.encode(&RenderCommand::DrawIndirect {
buffer_id,
offset,
});
@ -1289,11 +1314,11 @@ pub mod render_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_draw_indexed_indirect(
pass: &mut RawRenderPass,
pass: &mut RawPass,
buffer_id: id::BufferId,
offset: BufferAddress,
) {
pass.raw.encode(&RenderCommand::DrawIndexedIndirect {
pass.encode(&RenderCommand::DrawIndexedIndirect {
buffer_id,
offset,
});
@ -1301,7 +1326,7 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_execute_bundles(
_pass: &mut RawRenderPass,
_pass: &mut RawPass,
_bundles: *const id::RenderBundleId,
_bundles_length: usize,
) {
@ -1310,7 +1335,7 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_push_debug_group(
_pass: &mut RawRenderPass,
_pass: &mut RawPass,
_label: RawString,
) {
//TODO
@ -1318,14 +1343,14 @@ pub mod render_ffi {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_pop_debug_group(
_pass: &mut RawRenderPass,
_pass: &mut RawPass,
) {
//TODO
}
#[no_mangle]
pub extern "C" fn wgpu_render_pass_insert_debug_marker(
_pass: &mut RawRenderPass,
_pass: &mut RawPass,
_label: RawString,
) {
//TODO
@ -1333,17 +1358,16 @@ pub mod render_ffi {
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_finish(
pass: &mut RawRenderPass,
pass: &mut RawPass,
length: &mut usize,
) -> *const u8 {
//TODO: put target information into the byte stream
pass.raw.finish(RenderCommand::End);
*length = pass.raw.size();
pass.raw.base
pass.finish(RenderCommand::End);
*length = pass.size();
pass.base
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut RawRenderPass) {
let _ = Box::from_raw(pass).raw.into_vec();
pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut RawPass) {
let _ = Box::from_raw(pass).into_vec();
}
}

View File

@ -115,7 +115,7 @@ pub type ComputePipelineId = Id<crate::pipeline::ComputePipeline<Dummy>>;
// Command
pub type CommandBufferId = Id<crate::command::CommandBuffer<Dummy>>;
pub type CommandEncoderId = CommandBufferId;
pub type RenderPassId = *mut crate::command::RawRenderPass;
pub type RenderPassId = *mut crate::command::RawPass;
pub type ComputePassId = *mut crate::command::RawPass;
pub type RenderBundleId = Id<crate::command::RenderBundle<Dummy>>;
// Swap chain

View File

@ -89,33 +89,8 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
/// twice on the same raw pointer.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_end_pass(pass_id: id::RenderPassId) {
let (pass_data, encoder_id, targets) = Box::from_raw(pass_id).finish_render();
let color_attachments: arrayvec::ArrayVec<[_; core::device::MAX_COLOR_TARGETS]> = targets.colors
.iter()
.flat_map(|at| {
if at.attachment == id::TextureViewId::ERROR {
None
} else {
Some(core::command::RenderPassColorAttachmentDescriptor {
attachment: at.attachment,
resolve_target: if at.resolve_target == id::TextureViewId::ERROR {
None
} else {
Some(&at.resolve_target)
},
load_op: at.load_op,
store_op: at.store_op,
clear_color: at.clear_color,
})
}
})
.collect();
let depth_stencil_attachment = if targets.depth_stencil.attachment == id::TextureViewId::ERROR {
None
} else {
Some(&targets.depth_stencil)
};
gfx_select!(encoder_id => GLOBAL.command_encoder_run_render_pass(encoder_id, &color_attachments, depth_stencil_attachment, &pass_data))
let (pass_data, encoder_id) = Box::from_raw(pass_id).finish_render();
gfx_select!(encoder_id => GLOBAL.command_encoder_run_render_pass(encoder_id, &pass_data))
}
/// # Safety

View File

@ -210,15 +210,11 @@ pub unsafe extern "C" fn wgpu_server_encode_compute_pass(
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 u8,
command_length: usize,
) {
let color_attachments = slice::from_raw_parts(color_attachments, color_attachment_length);
let raw_pass = slice::from_raw_parts(commands, command_length);
gfx_select!(self_id => global.command_encoder_run_render_pass(self_id, color_attachments, depth_stencil_attachment, raw_pass));
gfx_select!(self_id => global.command_encoder_run_render_pass(self_id, raw_pass));
}
/// # Safety