Bug 1830762: populate standard attributes for `GPUTexture` r=webgpu-reviewers,webidl,saschanaz,jimb,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D176849
This commit is contained in:
Erich Gubler 2023-05-09 20:24:08 +00:00
Родитель ce980655c2
Коммит f9c7602b8b
4 изменённых файлов: 40 добавлений и 5 удалений

Просмотреть файл

@ -259,7 +259,7 @@ void Queue::CopyExternalImageToTexture(
const dom::GPUImageCopyExternalImage& aSource,
const dom::GPUImageCopyTextureTagged& aDestination,
const dom::GPUExtent3D& aCopySize, ErrorResult& aRv) {
const auto dstFormat = ToWebGLTexelFormat(aDestination.mTexture->mFormat);
const auto dstFormat = ToWebGLTexelFormat(aDestination.mTexture->Format());
if (dstFormat == WebGLTexelFormat::FormatNotSupportingAnyConversion) {
aRv.ThrowInvalidStateError("Unsupported destination format");
return;

Просмотреть файл

@ -9,7 +9,9 @@
#include "mozilla/webgpu/ffi/wgpu.h"
#include "mozilla/webgpu/CanvasContext.h"
#include "mozilla/dom/WebGPUBinding.h"
#include "mozilla/webgpu/WebGPUTypes.h"
#include "TextureView.h"
#include "Utility.h"
namespace mozilla::webgpu {
@ -91,7 +93,12 @@ Texture::Texture(Device* const aParent, RawId aId,
: ChildOf(aParent),
mId(aId),
mFormat(aDesc.mFormat),
mBytesPerBlock(GetBytesPerBlock(aDesc.mFormat)) {}
mBytesPerBlock(GetBytesPerBlock(aDesc.mFormat)),
mSize(ConvertExtent(aDesc.mSize)),
mMipLevelCount(aDesc.mMipLevelCount),
mSampleCount(aDesc.mSampleCount),
mDimension(aDesc.mDimension),
mUsage(aDesc.mUsage) {}
Texture::~Texture() { Cleanup(); }

Просмотреть файл

@ -6,22 +6,23 @@
#ifndef GPU_Texture_H_
#define GPU_Texture_H_
#include <cstdint>
#include "mozilla/WeakPtr.h"
#include "nsWrapperCache.h"
#include "ObjectModel.h"
#include "mozilla/webgpu/WebGPUTypes.h"
#include "mozilla/webgpu/ffi/wgpu.h"
namespace mozilla {
namespace dom {
struct GPUTextureDescriptor;
struct GPUTextureViewDescriptor;
enum class GPUTextureDimension : uint8_t;
enum class GPUTextureFormat : uint8_t;
enum class GPUTextureUsageFlags : uint32_t;
} // namespace dom
namespace webgpu {
namespace ffi {
struct WGPUTextureViewDescriptor;
} // namespace ffi
class CanvasContext;
class Device;
@ -45,10 +46,25 @@ class Texture final : public ObjectBase, public ChildOf<Device> {
virtual ~Texture();
void Cleanup();
const ffi::WGPUExtent3d mSize;
const uint32_t mMipLevelCount;
const uint32_t mSampleCount;
const dom::GPUTextureDimension mDimension;
const uint32_t mUsage;
public:
already_AddRefed<TextureView> CreateView(
const dom::GPUTextureViewDescriptor& aDesc);
void Destroy();
uint32_t Width() const { return mSize.width; }
uint32_t Height() const { return mSize.height; }
uint32_t DepthOrArrayLayers() const { return mSize.depth_or_array_layers; }
uint32_t MipLevelCount() const { return mMipLevelCount; }
uint32_t SampleCount() const { return mSampleCount; }
dom::GPUTextureDimension Dimension() const { return mDimension; }
dom::GPUTextureFormat Format() const { return mFormat; }
uint32_t Usage() const { return mUsage; }
};
} // namespace webgpu

Просмотреть файл

@ -234,6 +234,18 @@ interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
undefined destroy();
// TODO: s/unsigned long/GPUIntegerCoordinate: https://github.com/gpuweb/gpuweb/issues/4080
readonly attribute unsigned long width;
readonly attribute unsigned long height;
readonly attribute unsigned long depthOrArrayLayers;
readonly attribute unsigned long mipLevelCount;
// TODO: s/unsigned long/GPUSize32: https://github.com/gpuweb/gpuweb/issues/4080
readonly attribute unsigned long sampleCount;
readonly attribute GPUTextureDimension dimension;
readonly attribute GPUTextureFormat format;
// TODO: s/unsigned long/GPUSize32: https://github.com/gpuweb/gpuweb/issues/4080
readonly attribute unsigned long usage;
};
GPUTexture includes GPUObjectBase;