Skip to content

Instantly share code, notes, and snippets.

@beaufortfrancois
Created June 12, 2019 13:48
Show Gist options
  • Select an option

  • Save beaufortfrancois/b3347a063c3c0b3f51c4bce474bb7c4a to your computer and use it in GitHub Desktop.

Select an option

Save beaufortfrancois/b3347a063c3c0b3f51c4bce474bb7c4a to your computer and use it in GitHub Desktop.

Revisions

  1. beaufortfrancois created this gist Jun 12, 2019.
    42 changes: 42 additions & 0 deletions gpu-buffer.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    diff --git a/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc b/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
    index 9658796f2508..37a106c741f6 100644
    --- a/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
    +++ b/third_party/blink/renderer/modules/webgpu/gpu_buffer.cc
    @ -127,6 +131,25 @@ void GPUBuffer::OnMapAsyncCallback(ScriptPromiseResolver* resolver,
    WTF::ArrayBufferContents::SharingType::kNotShared);

    mapped_buffer_ = DOMArrayBuffer::Create(contents);
    +
    + auto* script_state = resolver->GetScriptState();
    + if (script_state->ContextIsValid()) {
    + ScriptState::Scope scope(script_state);
    +
    + v8::Isolate* isolate = script_state->GetIsolate();
    + v8::Local<v8::Object> global = script_state->GetContext()->Global();
    +
    + v8::Local<v8::Value> gpu_buffer_value = ToV8(this, global, isolate);
    + v8::Local<v8::Object> gpu_buffer_wrapper =
    + gpu_buffer_value->ToObject(script_state->GetContext())
    + .ToLocalChecked();
    +
    + v8::Local<v8::Value> mapped_buffer_wrapper =
    + ToV8(mapped_buffer_, global, isolate);
    + V8PrivateProperty::GetGPUBufferArrayBuffer(isolate).Set(
    + gpu_buffer_wrapper, mapped_buffer_wrapper);
    + }
    +
    resolver->Resolve(mapped_buffer_);
    }
    break;
    diff --git a/third_party/blink/renderer/platform/bindings/v8_private_property.h b/third_party/blink/renderer/platform/bindings/v8_private_property.h
    index 9eb1a25df1a9..0b1eb6122d44 100644
    --- a/third_party/blink/renderer/platform/bindings/v8_private_property.h
    +++ b/third_party/blink/renderer/platform/bindings/v8_private_property.h
    @@ -34,6 +34,7 @@ class ScriptWrappable;
    X(CustomElementLifecycle, DetachedCallback) \
    X(DOMException, Error) \
    X(Global, Event) \
    + X(GPUBuffer, ArrayBuffer) \
    X(IDBCursor, Request) \
    X(IntersectionObserver, Callback) \
    X(MessageChannel, Port1) \