mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1630114 - Fix default dimensionality of WebGPU texture views r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D70966 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4bd2a0b2bb
commit
fb52476b4f
@ -84,12 +84,22 @@ UniquePtr<ffi::WGPUTextureViewDescriptor> WebGPUChild::GetDefaultViewDescriptor(
|
||||
const dom::GPUTextureDescriptor& aDesc) {
|
||||
ffi::WGPUTextureViewDescriptor desc = {};
|
||||
desc.format = ffi::WGPUTextureFormat(aDesc.mFormat);
|
||||
// compute depth
|
||||
uint32_t depth = 0;
|
||||
if (aDesc.mSize.IsUnsignedLongSequence()) {
|
||||
const auto& seq = aDesc.mSize.GetAsUnsignedLongSequence();
|
||||
depth = seq.Length() > 2 ? seq[2] : 1;
|
||||
} else {
|
||||
depth = aDesc.mSize.GetAsGPUExtent3DDict().mDepth;
|
||||
}
|
||||
// compute dimension
|
||||
switch (aDesc.mDimension) {
|
||||
case dom::GPUTextureDimension::_1d:
|
||||
desc.dimension = ffi::WGPUTextureViewDimension_D1;
|
||||
break;
|
||||
case dom::GPUTextureDimension::_2d:
|
||||
desc.dimension = ffi::WGPUTextureViewDimension_D2;
|
||||
desc.dimension = depth > 1 ? ffi::WGPUTextureViewDimension_D2Array
|
||||
: ffi::WGPUTextureViewDimension_D2;
|
||||
break;
|
||||
case dom::GPUTextureDimension::_3d:
|
||||
desc.dimension = ffi::WGPUTextureViewDimension_D3;
|
||||
@ -97,6 +107,7 @@ UniquePtr<ffi::WGPUTextureViewDescriptor> WebGPUChild::GetDefaultViewDescriptor(
|
||||
default:
|
||||
MOZ_CRASH("Unexpected texture dimension");
|
||||
}
|
||||
// compute level count
|
||||
desc.level_count = aDesc.mMipLevelCount;
|
||||
return UniquePtr<ffi::WGPUTextureViewDescriptor>(
|
||||
new ffi::WGPUTextureViewDescriptor(desc));
|
||||
|
Loading…
Reference in New Issue
Block a user