chromium/gpu/ipc/in_process_command_buffer.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "gpu/ipc/in_process_command_buffer.h"

#include <stddef.h>
#include <stdint.h>

#include <set>
#include <utility>

#include "base/atomic_sequence_num.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/sequence_checker.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/completion_event.h"
#include "components/viz/common/features.h"
#include "gpu/command_buffer/client/gpu_control_client.h"
#include "gpu/command_buffer/client/shared_image_interface.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/command_buffer_task_executor.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_context_virtual.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gpu_command_buffer_memory_tracker.h"
#include "gpu/command_buffer/service/gpu_fence_manager.h"
#include "gpu/command_buffer/service/gpu_tracer.h"
#include "gpu/command_buffer/service/gr_shader_cache.h"
#include "gpu/command_buffer/service/memory_program_cache.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/query_manager.h"
#include "gpu/command_buffer/service/raster_decoder.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/service_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image_interface_in_process.h"
#include "gpu/command_buffer/service/single_task_sequence.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/command_buffer/service/webgpu_decoder.h"
#include "gpu/config/gpu_feature_info.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/ipc/common/gpu_client_ids.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/init/create_gr_gl_interface.h"
#include "ui/gl/init/gl_factory.h"

namespace gpu {

namespace {

template <typename T>
base::OnceClosure WrapTaskWithResult(base::OnceCallback<T(void)> task,
                                     T* result,
                                     base::WaitableEvent* completion) {}

class ScopedEvent {};

}  // namespace

InProcessCommandBuffer::InProcessCommandBuffer(
    CommandBufferTaskExecutor* task_executor,
    const GURL& active_url)
    :{}

InProcessCommandBuffer::~InProcessCommandBuffer() {}

gpu::ServiceTransferCache* InProcessCommandBuffer::GetTransferCacheForTest()
    const {}

int InProcessCommandBuffer::GetRasterDecoderIdForTest() const {}

webgpu::WebGPUDecoder* InProcessCommandBuffer::GetWebGPUDecoderForTest() const {}

gpu::SharedImageInterface* InProcessCommandBuffer::GetSharedImageInterface()
    const {}

bool InProcessCommandBuffer::MakeCurrent() {}

void InProcessCommandBuffer::CreateCacheUse(
    std::optional<gles2::ProgramCache::ScopedCacheUse>& cache_use) {}

gpu::ContextResult InProcessCommandBuffer::Initialize(
    const ContextCreationAttribs& attribs,
    scoped_refptr<base::SingleThreadTaskRunner> task_runner,
    gpu::raster::GrShaderCache* gr_shader_cache,
    GpuProcessShmCount* use_shader_cache_shm_count) {}

gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
    const InitializeOnGpuThreadParams& params) {}

void InProcessCommandBuffer::Destroy() {}

bool InProcessCommandBuffer::DestroyOnGpuThread() {}

CommandBufferServiceClient::CommandBatchProcessedResult
InProcessCommandBuffer::OnCommandBatchProcessed() {}

void InProcessCommandBuffer::OnParseError() {}

void InProcessCommandBuffer::OnContextLost() {}

void InProcessCommandBuffer::RunTaskOnGpuThread(base::OnceClosure task) {}

void InProcessCommandBuffer::ScheduleGpuTask(
    base::OnceClosure task,
    std::vector<SyncToken> sync_token_fences,
    SingleTaskSequence::ReportingCallback report_callback) {}

void InProcessCommandBuffer::ContinueGpuTask(base::OnceClosure task) {}

CommandBuffer::State InProcessCommandBuffer::GetLastState() {}

void InProcessCommandBuffer::UpdateLastStateOnGpuThread() {}

bool InProcessCommandBuffer::HasUnprocessedCommandsOnGpuThread() {}

void InProcessCommandBuffer::FlushOnGpuThread(
    int32_t put_offset,
    const std::vector<SyncToken>& sync_token_fences) {}

void InProcessCommandBuffer::PerformDelayedWorkOnGpuThread() {}

void InProcessCommandBuffer::ScheduleDelayedWorkOnGpuThread() {}

void InProcessCommandBuffer::Flush(int32_t put_offset) {}

void InProcessCommandBuffer::OrderingBarrier(int32_t put_offset) {}

CommandBuffer::State InProcessCommandBuffer::WaitForTokenInRange(int32_t start,
                                                                 int32_t end) {}

CommandBuffer::State InProcessCommandBuffer::WaitForGetOffsetInRange(
    uint32_t set_get_buffer_count,
    int32_t start,
    int32_t end) {}

void InProcessCommandBuffer::SetGetBuffer(int32_t shm_id) {}

void InProcessCommandBuffer::SetGetBufferOnGpuThread(
    int32_t shm_id,
    base::WaitableEvent* completion) {}

scoped_refptr<Buffer> InProcessCommandBuffer::CreateTransferBuffer(
    uint32_t size,
    int32_t* id,
    uint32_t alignment,
    TransferBufferAllocationOption option) {}

void InProcessCommandBuffer::RegisterTransferBufferOnGpuThread(
    int32_t id,
    scoped_refptr<Buffer> buffer) {}

void InProcessCommandBuffer::DestroyTransferBuffer(int32_t id) {}

void InProcessCommandBuffer::ForceLostContext(error::ContextLostReason reason) {}

void InProcessCommandBuffer::ForceLostContextOnGpuThread(
    error::ContextLostReason reason) {}

void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32_t id) {}

void InProcessCommandBuffer::SetGpuControlClient(GpuControlClient* client) {}

const Capabilities& InProcessCommandBuffer::GetCapabilities() const {}

const GLCapabilities& InProcessCommandBuffer::GetGLCapabilities() const {}

const GpuFeatureInfo& InProcessCommandBuffer::GetGpuFeatureInfo() const {}

void InProcessCommandBuffer::OnConsoleMessage(int32_t id,
                                              const std::string& message) {}

void InProcessCommandBuffer::CacheBlob(gpu::GpuDiskCacheType type,
                                       const std::string& key,
                                       const std::string& shader) {}

void InProcessCommandBuffer::OnFenceSyncRelease(uint64_t release) {}

void InProcessCommandBuffer::OnDescheduleUntilFinished() {}

void InProcessCommandBuffer::OnRescheduleAfterFinished() {}

void InProcessCommandBuffer::OnSwapBuffers(uint64_t swap_id, uint32_t flags) {}

void InProcessCommandBuffer::ScheduleGrContextCleanup() {}

void InProcessCommandBuffer::HandleReturnData(base::span<const uint8_t> data) {}

bool InProcessCommandBuffer::ShouldYield() {}

void InProcessCommandBuffer::PostOrRunClientCallback(
    base::OnceClosure callback) {}

base::OnceClosure InProcessCommandBuffer::WrapClientCallback(
    base::OnceClosure callback) {}

void InProcessCommandBuffer::SignalSyncToken(const SyncToken& sync_token,
                                             base::OnceClosure callback) {}

void InProcessCommandBuffer::SignalSyncTokenOnGpuThread(
    const SyncToken& sync_token,
    base::OnceClosure callback) {}

void InProcessCommandBuffer::SignalQuery(unsigned query_id,
                                         base::OnceClosure callback) {}

void InProcessCommandBuffer::CancelAllQueries() {}

void InProcessCommandBuffer::SignalQueryOnGpuThread(
    unsigned query_id,
    base::OnceClosure callback) {}

void InProcessCommandBuffer::CancelAllQueriesOnGpuThread() {}

void InProcessCommandBuffer::CreateGpuFence(uint32_t gpu_fence_id,
                                            ClientGpuFence source) {}

void InProcessCommandBuffer::CreateGpuFenceOnGpuThread(
    uint32_t gpu_fence_id,
    gfx::GpuFenceHandle handle) {}

void InProcessCommandBuffer::GetGpuFence(
    uint32_t gpu_fence_id,
    base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> callback) {}

void InProcessCommandBuffer::GetGpuFenceOnGpuThread(
    uint32_t gpu_fence_id,
    base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> callback) {}

void InProcessCommandBuffer::SetLock(base::Lock*) {}

void InProcessCommandBuffer::EnsureWorkVisible() {}

CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const {}

CommandBufferId InProcessCommandBuffer::GetCommandBufferID() const {}

void InProcessCommandBuffer::FlushPendingWork() {}

uint64_t InProcessCommandBuffer::GenerateFenceSyncRelease() {}

bool InProcessCommandBuffer::IsFenceSyncReleased(uint64_t release) {}

void InProcessCommandBuffer::WaitSyncToken(const SyncToken& sync_token) {}

bool InProcessCommandBuffer::CanWaitUnverifiedSyncToken(
    const SyncToken& sync_token) {}

const gles2::FeatureInfo* InProcessCommandBuffer::GetFeatureInfo() const {}

void InProcessCommandBuffer::HandleReturnDataOnOriginThread(
    std::vector<uint8_t> data) {}

void InProcessCommandBuffer::UpdateActiveUrl() {}

}  // namespace gpu