mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 07:24:47 +00:00
Bug 1622846 - Update WebGPU TextureDescriptor API r=jgilbert,webidl,smaug
Differential Revision: https://phabricator.services.mozilla.com/D70762 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ebe2702267
commit
15435c2bf5
@ -213,7 +213,6 @@ already_AddRefed<Texture> Device::InitSwapChain(
|
|||||||
desc.mDimension = dom::GPUTextureDimension::_2d;
|
desc.mDimension = dom::GPUTextureDimension::_2d;
|
||||||
desc.mSize.SetAsGPUExtent3DDict() = aExtent3D;
|
desc.mSize.SetAsGPUExtent3DDict() = aExtent3D;
|
||||||
desc.mFormat = aDesc.mFormat;
|
desc.mFormat = aDesc.mFormat;
|
||||||
desc.mArrayLayerCount = 1;
|
|
||||||
desc.mMipLevelCount = 1;
|
desc.mMipLevelCount = 1;
|
||||||
desc.mSampleCount = 1;
|
desc.mSampleCount = 1;
|
||||||
desc.mUsage = aDesc.mUsage | dom::GPUTextureUsage_Binding::COPY_SRC;
|
desc.mUsage = aDesc.mUsage | dom::GPUTextureUsage_Binding::COPY_SRC;
|
||||||
|
@ -92,7 +92,6 @@ UniquePtr<ffi::WGPUTextureViewDescriptor> WebGPUChild::GetDefaultViewDescriptor(
|
|||||||
MOZ_CRASH("Unexpected texture dimension");
|
MOZ_CRASH("Unexpected texture dimension");
|
||||||
}
|
}
|
||||||
desc.level_count = aDesc.mMipLevelCount;
|
desc.level_count = aDesc.mMipLevelCount;
|
||||||
desc.array_layer_count = aDesc.mArrayLayerCount;
|
|
||||||
return UniquePtr<ffi::WGPUTextureViewDescriptor>(
|
return UniquePtr<ffi::WGPUTextureViewDescriptor>(
|
||||||
new ffi::WGPUTextureViewDescriptor(desc));
|
new ffi::WGPUTextureViewDescriptor(desc));
|
||||||
}
|
}
|
||||||
@ -113,7 +112,6 @@ RawId WebGPUChild::DeviceCreateTexture(RawId aSelfId,
|
|||||||
} else {
|
} else {
|
||||||
MOZ_CRASH("Unexpected union");
|
MOZ_CRASH("Unexpected union");
|
||||||
}
|
}
|
||||||
desc.mArrayLayerCount = aDesc.mArrayLayerCount;
|
|
||||||
desc.mMipLevelCount = aDesc.mMipLevelCount;
|
desc.mMipLevelCount = aDesc.mMipLevelCount;
|
||||||
desc.mSampleCount = aDesc.mSampleCount;
|
desc.mSampleCount = aDesc.mSampleCount;
|
||||||
desc.mDimension = ffi::WGPUTextureDimension(aDesc.mDimension);
|
desc.mDimension = ffi::WGPUTextureDimension(aDesc.mDimension);
|
||||||
|
@ -254,7 +254,6 @@ ipc::IPCResult WebGPUParent::RecvDeviceCreateTexture(
|
|||||||
RawId aSelfId, const SerialTextureDescriptor& aDesc, RawId aNewId) {
|
RawId aSelfId, const SerialTextureDescriptor& aDesc, RawId aNewId) {
|
||||||
ffi::WGPUTextureDescriptor desc = {};
|
ffi::WGPUTextureDescriptor desc = {};
|
||||||
desc.size = aDesc.mSize;
|
desc.size = aDesc.mSize;
|
||||||
desc.array_layer_count = aDesc.mArrayLayerCount;
|
|
||||||
desc.mip_level_count = aDesc.mMipLevelCount;
|
desc.mip_level_count = aDesc.mMipLevelCount;
|
||||||
desc.sample_count = aDesc.mSampleCount;
|
desc.sample_count = aDesc.mSampleCount;
|
||||||
desc.dimension = aDesc.mDimension;
|
desc.dimension = aDesc.mDimension;
|
||||||
|
@ -292,7 +292,6 @@ interface GPUTextureUsage {
|
|||||||
|
|
||||||
dictionary GPUTextureDescriptor {
|
dictionary GPUTextureDescriptor {
|
||||||
required GPUExtent3D size;
|
required GPUExtent3D size;
|
||||||
u32 arrayLayerCount = 1;
|
|
||||||
u32 mipLevelCount = 1;
|
u32 mipLevelCount = 1;
|
||||||
u32 sampleCount = 1;
|
u32 sampleCount = 1;
|
||||||
GPUTextureDimension dimension = "2d";
|
GPUTextureDimension dimension = "2d";
|
||||||
|
@ -683,7 +683,6 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
const char *label;
|
const char *label;
|
||||||
WGPUExtent3d size;
|
WGPUExtent3d size;
|
||||||
uint32_t array_layer_count;
|
|
||||||
uint32_t mip_level_count;
|
uint32_t mip_level_count;
|
||||||
uint32_t sample_count;
|
uint32_t sample_count;
|
||||||
WGPUTextureDimension dimension;
|
WGPUTextureDimension dimension;
|
||||||
|
@ -436,6 +436,10 @@ fn checked_u32_as_u16(value: u32) -> u16 {
|
|||||||
value as u16
|
value as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_power_or_two(val: u32) -> bool {
|
||||||
|
val != 0 && (val & (val - 1)) == 0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn map_texture_dimension_size(
|
pub fn map_texture_dimension_size(
|
||||||
dimension: wgt::TextureDimension,
|
dimension: wgt::TextureDimension,
|
||||||
Extent3d {
|
Extent3d {
|
||||||
@ -443,7 +447,6 @@ pub fn map_texture_dimension_size(
|
|||||||
height,
|
height,
|
||||||
depth,
|
depth,
|
||||||
}: Extent3d,
|
}: Extent3d,
|
||||||
array_size: u32,
|
|
||||||
sample_size: u32,
|
sample_size: u32,
|
||||||
) -> hal::image::Kind {
|
) -> hal::image::Kind {
|
||||||
use hal::image::Kind as H;
|
use hal::image::Kind as H;
|
||||||
@ -451,31 +454,18 @@ pub fn map_texture_dimension_size(
|
|||||||
match dimension {
|
match dimension {
|
||||||
D1 => {
|
D1 => {
|
||||||
assert_eq!(height, 1);
|
assert_eq!(height, 1);
|
||||||
assert_eq!(depth, 1);
|
|
||||||
assert_eq!(sample_size, 1);
|
assert_eq!(sample_size, 1);
|
||||||
H::D1(width, checked_u32_as_u16(array_size))
|
H::D1(width, checked_u32_as_u16(depth))
|
||||||
}
|
}
|
||||||
D2 => {
|
D2 => {
|
||||||
assert_eq!(depth, 1);
|
|
||||||
assert!(
|
assert!(
|
||||||
sample_size == 1
|
sample_size <= 32 && is_power_or_two(sample_size),
|
||||||
|| sample_size == 2
|
|
||||||
|| sample_size == 4
|
|
||||||
|| sample_size == 8
|
|
||||||
|| sample_size == 16
|
|
||||||
|| sample_size == 32,
|
|
||||||
"Invalid sample_count of {}",
|
"Invalid sample_count of {}",
|
||||||
sample_size
|
sample_size
|
||||||
);
|
);
|
||||||
H::D2(
|
H::D2(width, height, checked_u32_as_u16(depth), sample_size as u8)
|
||||||
width,
|
|
||||||
height,
|
|
||||||
checked_u32_as_u16(array_size),
|
|
||||||
sample_size as u8,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
D3 => {
|
D3 => {
|
||||||
assert_eq!(array_size, 1);
|
|
||||||
assert_eq!(sample_size, 1);
|
assert_eq!(sample_size, 1);
|
||||||
H::D3(width, height, depth)
|
H::D3(width, height, depth)
|
||||||
}
|
}
|
||||||
|
@ -365,12 +365,7 @@ impl<B: GfxBackend> Device<B> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind = conv::map_texture_dimension_size(
|
let kind = conv::map_texture_dimension_size(desc.dimension, desc.size, desc.sample_count);
|
||||||
desc.dimension,
|
|
||||||
desc.size,
|
|
||||||
desc.array_layer_count,
|
|
||||||
desc.sample_count,
|
|
||||||
);
|
|
||||||
let format = conv::map_texture_format(desc.format, self.features);
|
let format = conv::map_texture_format(desc.format, self.features);
|
||||||
let aspects = format.surface_desc().aspects;
|
let aspects = format.surface_desc().aspects;
|
||||||
let usage = conv::map_texture_usage(desc.usage, aspects);
|
let usage = conv::map_texture_usage(desc.usage, aspects);
|
||||||
@ -380,7 +375,7 @@ impl<B: GfxBackend> Device<B> {
|
|||||||
|
|
||||||
// 2D textures with array layer counts that are multiples of 6 could be cubemaps
|
// 2D textures with array layer counts that are multiples of 6 could be cubemaps
|
||||||
// Following gpuweb/gpuweb#68 always add the hint in that case
|
// Following gpuweb/gpuweb#68 always add the hint in that case
|
||||||
if desc.dimension == TextureDimension::D2 && desc.array_layer_count % 6 == 0 {
|
if desc.dimension == TextureDimension::D2 && desc.size.depth % 6 == 0 {
|
||||||
view_capabilities |= hal::image::ViewCapabilities::KIND_CUBE;
|
view_capabilities |= hal::image::ViewCapabilities::KIND_CUBE;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -437,7 +432,7 @@ impl<B: GfxBackend> Device<B> {
|
|||||||
full_range: hal::image::SubresourceRange {
|
full_range: hal::image::SubresourceRange {
|
||||||
aspects,
|
aspects,
|
||||||
levels: 0..desc.mip_level_count as hal::image::Level,
|
levels: 0..desc.mip_level_count as hal::image::Level,
|
||||||
layers: 0..desc.array_layer_count as hal::image::Layer,
|
layers: 0..kind.num_layers(),
|
||||||
},
|
},
|
||||||
memory,
|
memory,
|
||||||
life_guard: LifeGuard::new(),
|
life_guard: LifeGuard::new(),
|
||||||
|
@ -752,7 +752,6 @@ pub struct Extent3d {
|
|||||||
pub struct TextureDescriptor {
|
pub struct TextureDescriptor {
|
||||||
pub label: *const std::os::raw::c_char,
|
pub label: *const std::os::raw::c_char,
|
||||||
pub size: Extent3d,
|
pub size: Extent3d,
|
||||||
pub array_layer_count: u32,
|
|
||||||
pub mip_level_count: u32,
|
pub mip_level_count: u32,
|
||||||
pub sample_count: u32,
|
pub sample_count: u32,
|
||||||
pub dimension: TextureDimension,
|
pub dimension: TextureDimension,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user