chromium/third_party/blink/renderer/modules/webgpu/gpu.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/webgpu/gpu.h"

#include <utility>

#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/synchronization/waitable_event.h"
#include "gpu/command_buffer/client/webgpu_interface.h"
#include "gpu/config/gpu_finch_features.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_token_builder.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/gpu/gpu.mojom-blink.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-shared.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_request_adapter_options.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/execution_context/navigator_base.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_enum_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_supported_features.h"
#include "third_party/blink/renderer/modules/webgpu/string_utils.h"
#include "third_party/blink/renderer/modules/webgpu/wgsl_language_features.h"
#include "third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_callback.h"
#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_provider_util.h"
#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"

namespace blink {

namespace {

[[maybe_unused]] void AddConsoleWarning(ExecutionContext* execution_context,
                                        const char* message) {}

wgpu::PowerPreference AsDawnType(V8GPUPowerPreference power_preference) {}

wgpu::RequestAdapterOptions AsDawnType(
    const GPURequestAdapterOptions* webgpu_options) {}

// Returns the execution context token given the context. Currently returning
// the WebGPU specific execution context token.
// TODO(dawn:549) Might be able to use ExecutionContextToken instead of WebGPU
//     specific execution context token if/when DocumentToken becomes a part of
//     ExecutionContextToken.
WebGPUExecutionContextToken GetExecutionContextToken(
    const ExecutionContext* execution_context) {}

}  // anonymous namespace

// static
const char GPU::kSupplementName[] =;

// static
GPU* GPU::gpu(NavigatorBase& navigator) {}

GPU::GPU(NavigatorBase& navigator)
    :{}

GPU::~GPU() = default;

WGSLLanguageFeatures* GPU::wgslLanguageFeatures() const {}

void GPU::Trace(Visitor* visitor) const {}

void GPU::ContextDestroyed() {}

void GPU::OnRequestAdapterCallback(
    ScriptState* script_state,
    const GPURequestAdapterOptions* options,
    ScriptPromiseResolver<IDLNullable<GPUAdapter>>* resolver,
    wgpu::RequestAdapterStatus status,
    wgpu::Adapter adapter,
    const char* error_message) {}

void GPU::RecordAdapterForIdentifiability(
    ScriptState* script_state,
    const GPURequestAdapterOptions* options,
    GPUAdapter* adapter) const {}

std::unique_ptr<WebGraphicsContext3DProvider> CheckContextProvider(
    const KURL& url,
    std::unique_ptr<WebGraphicsContext3DProvider> context_provider) {}

void GPU::RequestAdapterImpl(
    ScriptState* script_state,
    const GPURequestAdapterOptions* options,
    ScriptPromiseResolver<IDLNullable<GPUAdapter>>* resolver) {}

ScriptPromise<IDLNullable<GPUAdapter>> GPU::requestAdapter(
    ScriptState* script_state,
    const GPURequestAdapterOptions* options) {}

String GPU::getPreferredCanvasFormat() {}

wgpu::TextureFormat GPU::preferred_canvas_format() {}

void GPU::TrackMappableBuffer(GPUBuffer* buffer) {}

void GPU::UntrackMappableBuffer(GPUBuffer* buffer) {}

void BoxedMappableWGPUBufferHandles::ClearAndDestroyAll() {}

void GPU::SetDawnControlClientHolderForTesting(
    scoped_refptr<DawnControlClientHolder> dawn_control_client) {}

}  // namespace blink