#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_device_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_request_adapter_options.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/webgpu/dawn_enum_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter_info.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_memory_heap_info.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/string_utils.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
namespace blink {
namespace {
std::optional<V8GPUFeatureName::Enum> ToV8FeatureNameEnum(wgpu::FeatureName f) { … }
}
namespace {
GPUSupportedFeatures* MakeFeatureNameSet(wgpu::Adapter adapter,
ExecutionContext* execution_context) { … }
}
GPUAdapter::GPUAdapter(
GPU* gpu,
wgpu::Adapter handle,
scoped_refptr<DawnControlClientHolder> dawn_control_client,
const GPURequestAdapterOptions* options)
: … { … }
void GPUAdapter::AddConsoleWarning(ExecutionContext* execution_context,
const char* message) { … }
GPUSupportedFeatures* GPUAdapter::features() const { … }
GPUAdapterInfo* GPUAdapter::info() const { … }
bool GPUAdapter::isFallbackAdapter() const { … }
wgpu::BackendType GPUAdapter::backendType() const { … }
bool GPUAdapter::SupportsMultiPlanarFormats() const { … }
bool GPUAdapter::isCompatibilityMode() const { … }
void GPUAdapter::OnRequestDeviceCallback(
ScriptState* script_state,
const GPUDeviceDescriptor* descriptor,
ScriptPromiseResolver<GPUDevice>* resolver,
wgpu::RequestDeviceStatus status,
wgpu::Device dawn_device,
const char* error_message) { … }
ScriptPromise<GPUDevice> GPUAdapter::requestDevice(
ScriptState* script_state,
GPUDeviceDescriptor* descriptor) { … }
ScriptPromise<GPUAdapterInfo> GPUAdapter::requestAdapterInfo(
ScriptState* script_state) { … }
void GPUAdapter::Trace(Visitor* visitor) const { … }
}