chromium/third_party/blink/renderer/modules/webgpu/gpu_device.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_device.h"

#include "gpu/command_buffer/client/webgpu_interface.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_compute_pipeline_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_device_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_error_filter.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_feature_name.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_query_set_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_pipeline_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_uncaptured_error_event_init.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_command_encoder.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_external_texture.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_internal_error.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_out_of_memory_error.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_error.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_queue.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_sampler.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_supported_features.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_supported_limits.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_texture.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_validation_error.h"
#include "third_party/blink/renderer/modules/webgpu/string_utils.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"

namespace blink {

namespace {

std::optional<V8GPUFeatureName::Enum> RequiredFeatureForTextureFormat(
    V8GPUTextureFormat::Enum format) {}

std::optional<V8GPUFeatureName::Enum> RequiredFeatureForBlendFactor(
    V8GPUBlendFactor::Enum blend_factor) {}

}  // anonymous namespace

GPUDevice::GPUDevice(ExecutionContext* execution_context,
                     scoped_refptr<DawnControlClientHolder> dawn_control_client,
                     GPUAdapter* adapter,
                     wgpu::Device dawn_device,
                     const GPUDeviceDescriptor* descriptor,
                     GPUDeviceLostInfo* lost_info)
    :{}

GPUDevice::~GPUDevice() {}

void GPUDevice::InjectError(wgpu::ErrorType type, const char* message) {}

void GPUDevice::AddConsoleWarning(const char* message) {}

void GPUDevice::AddConsoleWarning(const String& message) {}

void GPUDevice::AddSingletonWarning(GPUSingletonWarning type) {}

// Validates that any features required for the given texture format are enabled
// for this device. If not, throw a TypeError to ensure consistency with
// browsers that haven't yet implemented the feature.
bool GPUDevice::ValidateTextureFormatUsage(V8GPUTextureFormat format,
                                           ExceptionState& exception_state) {}

std::string GPUDevice::formattedLabel() const {}

// Validates that any features required for the given blend factor are enabled
// for this device. If not, throw a TypeError to ensure consistency with
// browsers that haven't yet implemented the feature.
bool GPUDevice::ValidateBlendFactor(V8GPUBlendFactor blend_factor,
                                    ExceptionState& exception_state) {}

void GPUDevice::OnUncapturedError(WGPUErrorType cErrorType,
                                  const char* message) {}

void GPUDevice::OnLogging(WGPULoggingType cLoggingType, const char* message) {}

void GPUDevice::OnDeviceLostError(WGPUDeviceLostReason cReason,
                                  const char* message) {}

void GPUDevice::OnCreateRenderPipelineAsyncCallback(
    const String& label,
    ScriptPromiseResolver<GPURenderPipeline>* resolver,
    wgpu::CreatePipelineAsyncStatus status,
    wgpu::RenderPipeline render_pipeline,
    const char* message) {}

void GPUDevice::OnCreateComputePipelineAsyncCallback(
    const String& label,
    ScriptPromiseResolver<GPUComputePipeline>* resolver,
    wgpu::CreatePipelineAsyncStatus status,
    wgpu::ComputePipeline compute_pipeline,
    const char* message) {}

GPUAdapter* GPUDevice::adapter() const {}

GPUSupportedFeatures* GPUDevice::features() const {}

ScriptPromise<GPUDeviceLostInfo> GPUDevice::lost(ScriptState* script_state) {}

GPUQueue* GPUDevice::queue() {}

bool GPUDevice::destroyed() const {}

void GPUDevice::destroy(v8::Isolate* isolate) {}

GPUBuffer* GPUDevice::createBuffer(const GPUBufferDescriptor* descriptor,
                                   ExceptionState& exception_state) {}

GPUTexture* GPUDevice::createTexture(const GPUTextureDescriptor* descriptor,
                                     ExceptionState& exception_state) {}

GPUSampler* GPUDevice::createSampler(const GPUSamplerDescriptor* descriptor) {}

GPUExternalTexture* GPUDevice::importExternalTexture(
    const GPUExternalTextureDescriptor* descriptor,
    ExceptionState& exception_state) {}

GPUBindGroup* GPUDevice::createBindGroup(
    const GPUBindGroupDescriptor* descriptor,
    ExceptionState& exception_state) {}

GPUBindGroupLayout* GPUDevice::createBindGroupLayout(
    const GPUBindGroupLayoutDescriptor* descriptor,
    ExceptionState& exception_state) {}

GPUPipelineLayout* GPUDevice::createPipelineLayout(
    const GPUPipelineLayoutDescriptor* descriptor) {}

GPUShaderModule* GPUDevice::createShaderModule(
    const GPUShaderModuleDescriptor* descriptor,
    ExceptionState& exception_state) {}

GPURenderPipeline* GPUDevice::createRenderPipeline(
    ScriptState* script_state,
    const GPURenderPipelineDescriptor* descriptor) {}

GPUComputePipeline* GPUDevice::createComputePipeline(
    const GPUComputePipelineDescriptor* descriptor,
    ExceptionState& exception_state) {}

ScriptPromise<GPURenderPipeline> GPUDevice::createRenderPipelineAsync(
    ScriptState* script_state,
    const GPURenderPipelineDescriptor* descriptor,
    ExceptionState& exception_state) {}

ScriptPromise<GPUComputePipeline> GPUDevice::createComputePipelineAsync(
    ScriptState* script_state,
    const GPUComputePipelineDescriptor* descriptor) {}

GPUCommandEncoder* GPUDevice::createCommandEncoder(
    const GPUCommandEncoderDescriptor* descriptor) {}

GPURenderBundleEncoder* GPUDevice::createRenderBundleEncoder(
    const GPURenderBundleEncoderDescriptor* descriptor,
    ExceptionState& exception_state) {}

GPUQuerySet* GPUDevice::createQuerySet(const GPUQuerySetDescriptor* descriptor,
                                       ExceptionState& exception_state) {}

void GPUDevice::pushErrorScope(const V8GPUErrorFilter& filter) {}

ScriptPromise<IDLNullable<GPUError>> GPUDevice::popErrorScope(
    ScriptState* script_state) {}

void GPUDevice::OnPopErrorScopeCallback(
    ScriptPromiseResolver<IDLNullable<GPUError>>* resolver,
    wgpu::PopErrorScopeStatus status,
    wgpu::ErrorType type,
    const char* message) {}

ExecutionContext* GPUDevice::GetExecutionContext() const {}

const AtomicString& GPUDevice::InterfaceName() const {}

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

void GPUDevice::Dispose() {}

void GPUDevice::DissociateMailboxes() {}

void GPUDevice::UnmapAllMappableBuffers(v8::Isolate* isolate) {}

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

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

void GPUDevice::TrackTextureWithMailbox(GPUTexture* texture) {}

void GPUDevice::UntrackTextureWithMailbox(GPUTexture* texture) {}

}  // namespace blink