зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
ebe2702267
Коммит
15435c2bf5
|
@ -213,7 +213,6 @@ already_AddRefed<Texture> Device::InitSwapChain(
|
|||
desc.mDimension = dom::GPUTextureDimension::_2d;
|
||||
desc.mSize.SetAsGPUExtent3DDict() = aExtent3D;
|
||||
desc.mFormat = aDesc.mFormat;
|
||||
desc.mArrayLayerCount = 1;
|
||||
desc.mMipLevelCount = 1;
|
||||
desc.mSampleCount = 1;
|
||||
desc.mUsage = aDesc.mUsage | dom::GPUTextureUsage_Binding::COPY_SRC;
|
||||
|
|
|
@ -92,7 +92,6 @@ UniquePtr<ffi::WGPUTextureViewDescriptor> WebGPUChild::GetDefaultViewDescriptor(
|
|||
MOZ_CRASH("Unexpected texture dimension");
|
||||
}
|
||||
desc.level_count = aDesc.mMipLevelCount;
|
||||
desc.array_layer_count = aDesc.mArrayLayerCount;
|
||||
return UniquePtr<ffi::WGPUTextureViewDescriptor>(
|
||||
new ffi::WGPUTextureViewDescriptor(desc));
|
||||
}
|
||||
|
@ -113,7 +112,6 @@ RawId WebGPUChild::DeviceCreateTexture(RawId aSelfId,
|
|||
} else {
|
||||
MOZ_CRASH("Unexpected union");
|
||||
}
|
||||
desc.mArrayLayerCount = aDesc.mArrayLayerCount;
|
||||
desc.mMipLevelCount = aDesc.mMipLevelCount;
|
||||
desc.mSampleCount = aDesc.mSampleCount;
|
||||
desc.mDimension = ffi::WGPUTextureDimension(aDesc.mDimension);
|
||||
|
|
|
@ -254,7 +254,6 @@ ipc::IPCResult WebGPUParent::RecvDeviceCreateTexture(
|
|||
RawId aSelfId, const SerialTextureDescriptor& aDesc, RawId aNewId) {
|
||||
ffi::WGPUTextureDescriptor desc = {};
|
||||
desc.size = aDesc.mSize;
|
||||
desc.array_layer_count = aDesc.mArrayLayerCount;
|
||||
desc.mip_level_count = aDesc.mMipLevelCount;
|
||||
desc.sample_count = aDesc.mSampleCount;
|
||||
desc.dimension = aDesc.mDimension;
|
||||
|
|
|
@ -292,7 +292,6 @@ interface GPUTextureUsage {
|
|||
|
||||
dictionary GPUTextureDescriptor {
|
||||
required GPUExtent3D size;
|
||||
u32 arrayLayerCount = 1;
|
||||
u32 mipLevelCount = 1;
|
||||
u32 sampleCount = 1;
|
||||
GPUTextureDimension dimension = "2d";
|
||||
|
|
|
@ -683,7 +683,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
const char *label;
|
||||
WGPUExtent3d size;
|
||||
uint32_t array_layer_count;
|
||||
uint32_t mip_level_count;
|
||||
uint32_t sample_count;
|
||||
WGPUTextureDimension dimension;
|
||||
|
|
|
@ -436,6 +436,10 @@ fn checked_u32_as_u16(value: u32) -> u16 {
|
|||
value as u16
|
||||
}
|
||||
|
||||
fn is_power_or_two(val: u32) -> bool {
|
||||
val != 0 && (val & (val - 1)) == 0
|
||||
}
|
||||
|
||||
pub fn map_texture_dimension_size(
|
||||
dimension: wgt::TextureDimension,
|
||||
Extent3d {
|
||||
|
@ -443,7 +447,6 @@ pub fn map_texture_dimension_size(
|
|||
height,
|
||||
depth,
|
||||
}: Extent3d,
|
||||
array_size: u32,
|
||||
sample_size: u32,
|
||||
) -> hal::image::Kind {
|
||||
use hal::image::Kind as H;
|
||||
|
@ -451,31 +454,18 @@ pub fn map_texture_dimension_size(
|
|||
match dimension {
|
||||
D1 => {
|
||||
assert_eq!(height, 1);
|
||||
assert_eq!(depth, 1);
|
||||
assert_eq!(sample_size, 1);
|
||||
H::D1(width, checked_u32_as_u16(array_size))
|
||||
H::D1(width, checked_u32_as_u16(depth))
|
||||
}
|
||||
D2 => {
|
||||
assert_eq!(depth, 1);
|
||||
assert!(
|
||||
sample_size == 1
|
||||
|| sample_size == 2
|
||||
|| sample_size == 4
|
||||
|| sample_size == 8
|
||||
|| sample_size == 16
|
||||
|| sample_size == 32,
|
||||
sample_size <= 32 && is_power_or_two(sample_size),
|
||||
"Invalid sample_count of {}",
|
||||
sample_size
|
||||
);
|
||||
H::D2(
|
||||
width,
|
||||
height,
|
||||
checked_u32_as_u16(array_size),
|
||||
sample_size as u8,
|
||||
)
|
||||
H::D2(width, height, checked_u32_as_u16(depth), sample_size as u8)
|
||||
}
|
||||
D3 => {
|
||||
assert_eq!(array_size, 1);
|
||||
assert_eq!(sample_size, 1);
|
||||
H::D3(width, height, depth)
|
||||
}
|
||||
|
|
|
@ -365,12 +365,7 @@ impl<B: GfxBackend> Device<B> {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
let kind = conv::map_texture_dimension_size(
|
||||
desc.dimension,
|
||||
desc.size,
|
||||
desc.array_layer_count,
|
||||
desc.sample_count,
|
||||
);
|
||||
let kind = conv::map_texture_dimension_size(desc.dimension, desc.size, desc.sample_count);
|
||||
let format = conv::map_texture_format(desc.format, self.features);
|
||||
let aspects = format.surface_desc().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
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
@ -437,7 +432,7 @@ impl<B: GfxBackend> Device<B> {
|
|||
full_range: hal::image::SubresourceRange {
|
||||
aspects,
|
||||
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,
|
||||
life_guard: LifeGuard::new(),
|
||||
|
|
|
@ -752,7 +752,6 @@ pub struct Extent3d {
|
|||
pub struct TextureDescriptor {
|
||||
pub label: *const std::os::raw::c_char,
|
||||
pub size: Extent3d,
|
||||
pub array_layer_count: u32,
|
||||
pub mip_level_count: u32,
|
||||
pub sample_count: u32,
|
||||
pub dimension: TextureDimension,
|
||||
|
|
Загрузка…
Ссылка в новой задаче