mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 09:34:09 +01:00
DynDevice create/destroy pipeline layout
This commit is contained in:
1 parent
1da319f804
commit
33f57e2305
7 files changed
+42
-12
No files matched your search
@@ -776,7 +776,7 @@ impl crate::Device for super::Device {
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::Api>,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::BindGroupLayout>,
|
||||
) -> Result<super::PipelineLayout, DeviceError> {
|
||||
use naga::back::hlsl;
|
||||
// Pipeline layouts are implemented as RootSignature for D3D12.
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
use crate::{
|
||||
Api, BindGroupLayoutDescriptor, BufferDescriptor, BufferMapping, CommandEncoderDescriptor,
|
||||
Device, DeviceError, DynBuffer, DynResource, MemoryRange, SamplerDescriptor, TextureDescriptor,
|
||||
TextureViewDescriptor,
|
||||
Device, DeviceError, DynBuffer, DynResource, MemoryRange, PipelineLayoutDescriptor,
|
||||
SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||
};
|
||||
|
||||
use super::{
|
||||
DynBindGroupLayout, DynCommandEncoder, DynQueue, DynResourceExt as _, DynSampler, DynTexture,
|
||||
DynTextureView,
|
||||
DynBindGroupLayout, DynCommandEncoder, DynPipelineLayout, DynQueue, DynResourceExt as _,
|
||||
DynSampler, DynTexture, DynTextureView,
|
||||
};
|
||||
|
||||
pub trait DynDevice: DynResource {
|
||||
@@ -59,6 +59,12 @@ pub trait DynDevice: DynResource {
|
||||
desc: &BindGroupLayoutDescriptor,
|
||||
) -> Result<Box<dyn DynBindGroupLayout>, DeviceError>;
|
||||
unsafe fn destroy_bind_group_layout(&self, bg_layout: Box<dyn DynBindGroupLayout>);
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &PipelineLayoutDescriptor<dyn DynBindGroupLayout>,
|
||||
) -> Result<Box<dyn DynPipelineLayout>, DeviceError>;
|
||||
unsafe fn destroy_pipeline_layout(&self, pipeline_layout: Box<dyn DynPipelineLayout>);
|
||||
}
|
||||
|
||||
impl<D: Device + DynResource> DynDevice for D {
|
||||
@@ -171,4 +177,28 @@ impl<D: Device + DynResource> DynDevice for D {
|
||||
unsafe fn destroy_bind_group_layout(&self, bg_layout: Box<dyn DynBindGroupLayout>) {
|
||||
unsafe { D::destroy_bind_group_layout(self, bg_layout.unbox()) };
|
||||
}
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &PipelineLayoutDescriptor<dyn DynBindGroupLayout>,
|
||||
) -> Result<Box<dyn DynPipelineLayout>, DeviceError> {
|
||||
let bind_group_layouts: Vec<_> = desc
|
||||
.bind_group_layouts
|
||||
.iter()
|
||||
.map(|bgl| bgl.expect_downcast_ref())
|
||||
.collect();
|
||||
let desc = PipelineLayoutDescriptor {
|
||||
label: desc.label,
|
||||
bind_group_layouts: &bind_group_layouts,
|
||||
push_constant_ranges: desc.push_constant_ranges,
|
||||
flags: desc.flags,
|
||||
};
|
||||
|
||||
unsafe { D::create_pipeline_layout(self, &desc) }
|
||||
.map(|b| Box::new(b) as Box<dyn DynPipelineLayout>)
|
||||
}
|
||||
|
||||
unsafe fn destroy_pipeline_layout(&self, pipeline_layout: Box<dyn DynPipelineLayout>) {
|
||||
unsafe { D::destroy_pipeline_layout(self, pipeline_layout.unbox()) };
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ impl crate::Device for Context {
|
||||
unsafe fn destroy_bind_group_layout(&self, bg_layout: Resource) {}
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<Api>,
|
||||
desc: &crate::PipelineLayoutDescriptor<Resource>,
|
||||
) -> DeviceResult<Resource> {
|
||||
Ok(Resource)
|
||||
}
|
||||
|
||||
@@ -1140,7 +1140,7 @@ impl crate::Device for super::Device {
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::Api>,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::BindGroupLayout>,
|
||||
) -> Result<super::PipelineLayout, crate::DeviceError> {
|
||||
use naga::back::glsl;
|
||||
|
||||
|
||||
+3
-3
@@ -801,7 +801,7 @@ pub trait Device: WasmNotSendSync {
|
||||
unsafe fn destroy_bind_group_layout(&self, bg_layout: <Self::A as Api>::BindGroupLayout);
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &PipelineLayoutDescriptor<Self::A>,
|
||||
desc: &PipelineLayoutDescriptor<<Self::A as Api>::BindGroupLayout>,
|
||||
) -> Result<<Self::A as Api>::PipelineLayout, DeviceError>;
|
||||
unsafe fn destroy_pipeline_layout(&self, pipeline_layout: <Self::A as Api>::PipelineLayout);
|
||||
unsafe fn create_bind_group(
|
||||
@@ -1743,10 +1743,10 @@ pub struct BindGroupLayoutDescriptor<'a> {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PipelineLayoutDescriptor<'a, A: Api> {
|
||||
pub struct PipelineLayoutDescriptor<'a, B: DynBindGroupLayout + ?Sized> {
|
||||
pub label: Label<'a>,
|
||||
pub flags: PipelineLayoutFlags,
|
||||
pub bind_group_layouts: &'a [&'a A::BindGroupLayout],
|
||||
pub bind_group_layouts: &'a [&'a B],
|
||||
pub push_constant_ranges: &'a [wgt::PushConstantRange],
|
||||
}
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ impl crate::Device for super::Device {
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::Api>,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::BindGroupLayout>,
|
||||
) -> DeviceResult<super::PipelineLayout> {
|
||||
#[derive(Debug)]
|
||||
struct StageInfo {
|
||||
|
||||
@@ -1387,7 +1387,7 @@ impl crate::Device for super::Device {
|
||||
|
||||
unsafe fn create_pipeline_layout(
|
||||
&self,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::Api>,
|
||||
desc: &crate::PipelineLayoutDescriptor<super::BindGroupLayout>,
|
||||
) -> Result<super::PipelineLayout, crate::DeviceError> {
|
||||
//Note: not bothering with on stack array here as it's low frequency
|
||||
let vk_set_layouts = desc
|
||||
|
||||
Reference in new issue
Block a user