зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1831120: feat(webgpu): add `GPUBuffer` attributes r=webgpu-reviewers,webidl,saschanaz,jimb
Differential Revision: https://phabricator.services.mozilla.com/D177055
This commit is contained in:
Родитель
20a147c45c
Коммит
62082f2284
|
@ -332,4 +332,17 @@ void Buffer::Destroy(JSContext* aCx, ErrorResult& aRv) {
|
|||
// examples
|
||||
}
|
||||
|
||||
dom::GPUBufferMapState Buffer::MapState() const {
|
||||
// Implementation reference:
|
||||
// <https://gpuweb.github.io/gpuweb/#dom-gpubuffer-mapstate>.
|
||||
|
||||
if (mMapped) {
|
||||
return dom::GPUBufferMapState::Mapped;
|
||||
}
|
||||
if (mMapRequest) {
|
||||
return dom::GPUBufferMapState::Pending;
|
||||
}
|
||||
return dom::GPUBufferMapState::Unmapped;
|
||||
}
|
||||
|
||||
} // namespace mozilla::webgpu
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace dom {
|
|||
struct GPUBufferDescriptor;
|
||||
template <typename T>
|
||||
class Optional;
|
||||
enum class GPUBufferMapState : uint8_t;
|
||||
} // namespace dom
|
||||
|
||||
namespace webgpu {
|
||||
|
@ -59,6 +60,10 @@ class Buffer final : public ObjectBase, public ChildOf<Device> {
|
|||
|
||||
const RawId mId;
|
||||
|
||||
uint64_t Size() const { return mSize; }
|
||||
uint32_t Usage() const { return mUsage; }
|
||||
dom::GPUBufferMapState MapState() const;
|
||||
|
||||
private:
|
||||
Buffer(Device* const aParent, RawId aId, BufferAddress aSize, uint32_t aUsage,
|
||||
ipc::WritableSharedMemoryMapping&& aShmem);
|
||||
|
|
|
@ -166,6 +166,13 @@ GPUDevice includes GPUObjectBase;
|
|||
[Pref="dom.webgpu.enabled",
|
||||
Exposed=(Window /* ,DedicatedWorker */), SecureContext]
|
||||
interface GPUBuffer {
|
||||
// TODO: s/unsigned long long/GPUSize64/: https://github.com/gpuweb/gpuweb/issues/4080
|
||||
readonly attribute unsigned long long size;
|
||||
// TODO: s/unsigned long/GPUBufferUsageFlags/: https://github.com/gpuweb/gpuweb/issues/4080
|
||||
readonly attribute unsigned long usage;
|
||||
|
||||
readonly attribute GPUBufferMapState mapState;
|
||||
|
||||
[NewObject]
|
||||
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
|
||||
[NewObject, Throws]
|
||||
|
@ -177,6 +184,12 @@ interface GPUBuffer {
|
|||
};
|
||||
GPUBuffer includes GPUObjectBase;
|
||||
|
||||
enum GPUBufferMapState {
|
||||
"unmapped",
|
||||
"pending",
|
||||
"mapped"
|
||||
};
|
||||
|
||||
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUSize64 size;
|
||||
required GPUBufferUsageFlags usage;
|
||||
|
|
Загрузка…
Ссылка в новой задаче