mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 23:11:01 +01:00
[remote] TextureViewDescriptor
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
f7f38ac815
commit
106c5862a9
2 files changed
+40
-3
No files matched your search
@@ -53,3 +53,31 @@ pub type QueueDescriptor<'a> = wgt::QueueDescriptor<Label<'a>>;
|
||||
pub type BufferDescriptor<'a> = wgt::BufferDescriptor<Label<'a>>;
|
||||
pub type TextureDescriptor<'a> = wgt::TextureDescriptor<Label<'a>, Vec<wgt::TextureFormat>>;
|
||||
pub type ExternalTextureDescriptor<'a> = wgt::ExternalTextureDescriptor<Label<'a>>;
|
||||
|
||||
/// Describes a `TextureView`.
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUTextureViewDescriptor`](https://gpuweb.github.io/gpuweb/#dictdef-gputextureviewdescriptor).
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct TextureViewDescriptor<'a> {
|
||||
/// Debug label of the texture view.
|
||||
///
|
||||
/// This will show up in graphics debuggers for easy identification.
|
||||
pub label: Label<'a>,
|
||||
/// Format of the texture view, or `None` for the same format as the texture
|
||||
/// itself.
|
||||
///
|
||||
/// At this time, it must be the same the underlying format of the texture.
|
||||
pub format: Option<wgt::TextureFormat>,
|
||||
/// The dimension of the texture view.
|
||||
///
|
||||
/// - For 1D textures, this must be `D1`.
|
||||
/// - For 2D textures it must be one of `D2`, `D2Array`, `Cube`, or `CubeArray`.
|
||||
/// - For 3D textures it must be `D3`.
|
||||
pub dimension: Option<wgt::TextureViewDimension>,
|
||||
/// The allowed usage(s) for the texture view. Must be a subset of the usage flags of the texture.
|
||||
/// If not provided, defaults to the full set of usage flags of the texture.
|
||||
pub usage: Option<wgt::TextureUsages>,
|
||||
/// Range within the texture that is accessible via this view.
|
||||
pub range: wgt::ImageSubresourceRange,
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
use alloc::{borrow::Cow, boxed::Box, sync::Arc, vec::Vec};
|
||||
use core::ops::Deref;
|
||||
use core::ptr::NonNull;
|
||||
use wgpu_core_remote_types::{
|
||||
encoders::RenderBundleDescriptor,
|
||||
pipelines::{ComputePipelineDescriptor, RenderPipelineDescriptor},
|
||||
BufferDescriptor, ExternalTextureDescriptor, TextureDescriptor,
|
||||
BufferDescriptor, ExternalTextureDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||
};
|
||||
|
||||
use wgpu_core::{
|
||||
@@ -322,7 +323,7 @@ impl Global {
|
||||
pub fn texture_create_view(
|
||||
&self,
|
||||
texture_id: id::TextureId,
|
||||
desc: &resource::TextureViewDescriptor,
|
||||
desc: &TextureViewDescriptor,
|
||||
id_in: id::TextureViewId,
|
||||
) -> (id::TextureViewId, Option<resource::CreateTextureViewError>) {
|
||||
let mut hub = self.hub.borrow_mut();
|
||||
@@ -334,7 +335,15 @@ impl Global {
|
||||
|
||||
let texture = textures.get(texture_id);
|
||||
|
||||
let (view, error) = texture.create_view(desc);
|
||||
let desc = resource::TextureViewDescriptor {
|
||||
label: desc.label.as_ref().map(|s| Cow::Borrowed(s.deref())),
|
||||
format: desc.format,
|
||||
dimension: desc.dimension,
|
||||
usage: desc.usage,
|
||||
range: desc.range,
|
||||
};
|
||||
|
||||
let (view, error) = texture.create_view(&desc);
|
||||
|
||||
let id = texture_views.assign(id_in, view);
|
||||
|
||||
|
||||
Reference in new issue
Block a user