| Index: gpu/ipc/service/gpu_command_buffer_stub.cc
|
| diff --git a/gpu/ipc/service/gpu_command_buffer_stub.cc b/gpu/ipc/service/gpu_command_buffer_stub.cc
|
| index 6d305cf9ab99b670e9d8c743e9ad21c6cbd1161d..9dc66b7908d55eada1cdc8f273f6a05280a75535 100644
|
| --- a/gpu/ipc/service/gpu_command_buffer_stub.cc
|
| +++ b/gpu/ipc/service/gpu_command_buffer_stub.cc
|
| @@ -117,10 +117,8 @@ class GpuCommandBufferMemoryTracker : public gles2::MemoryTracker {
|
| &GpuCommandBufferMemoryTracker::LogMemoryStatsPeriodic);
|
| }
|
|
|
| - void TrackMemoryAllocatedChange(
|
| - size_t old_size, size_t new_size) override {
|
| - tracking_group_->TrackMemoryAllocatedChange(
|
| - old_size, new_size);
|
| + void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) override {
|
| + tracking_group_->TrackMemoryAllocatedChange(old_size, new_size);
|
| }
|
|
|
| bool EnsureGPUMemoryAvailable(size_t size_needed) override {
|
| @@ -213,21 +211,20 @@ DevToolsChannelData::CreateForChannel(GpuChannel* channel) {
|
| return base::WrapUnique(new DevToolsChannelData(res.release()));
|
| }
|
|
|
| -CommandBufferId GetCommandBufferID(int channel_id, int32_t route_id) {
|
| - return CommandBufferId::FromUnsafeValue(
|
| - (static_cast<uint64_t>(channel_id) << 32) | route_id);
|
| -}
|
| -
|
| } // namespace
|
|
|
| std::unique_ptr<GpuCommandBufferStub> GpuCommandBufferStub::Create(
|
| GpuChannel* channel,
|
| GpuCommandBufferStub* share_command_buffer_stub,
|
| const GPUCreateCommandBufferConfig& init_params,
|
| + CommandBufferId command_buffer_id,
|
| + SequenceId sequence_id,
|
| + int32_t stream_id,
|
| int32_t route_id,
|
| std::unique_ptr<base::SharedMemory> shared_state_shm) {
|
| std::unique_ptr<GpuCommandBufferStub> stub(
|
| - new GpuCommandBufferStub(channel, init_params, route_id));
|
| + new GpuCommandBufferStub(channel, init_params, command_buffer_id,
|
| + sequence_id, stream_id, route_id));
|
| if (!stub->Initialize(share_command_buffer_stub, init_params,
|
| std::move(shared_state_shm)))
|
| return nullptr;
|
| @@ -237,13 +234,17 @@ std::unique_ptr<GpuCommandBufferStub> GpuCommandBufferStub::Create(
|
| GpuCommandBufferStub::GpuCommandBufferStub(
|
| GpuChannel* channel,
|
| const GPUCreateCommandBufferConfig& init_params,
|
| + CommandBufferId command_buffer_id,
|
| + SequenceId sequence_id,
|
| + int32_t stream_id,
|
| int32_t route_id)
|
| : channel_(channel),
|
| initialized_(false),
|
| surface_handle_(init_params.surface_handle),
|
| use_virtualized_gl_context_(false),
|
| - command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)),
|
| - stream_id_(init_params.stream_id),
|
| + command_buffer_id_(command_buffer_id),
|
| + sequence_id_(sequence_id),
|
| + stream_id_(stream_id),
|
| route_id_(route_id),
|
| last_flush_count_(0),
|
| waiting_for_sync_point_(false),
|
| @@ -256,14 +257,12 @@ GpuCommandBufferStub::~GpuCommandBufferStub() {
|
| }
|
|
|
| GpuMemoryManager* GpuCommandBufferStub::GetMemoryManager() const {
|
| - return channel()->gpu_channel_manager()->gpu_memory_manager();
|
| + return channel()->gpu_channel_manager()->gpu_memory_manager();
|
| }
|
|
|
| bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
|
| - TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
|
| - "GPUTask",
|
| - "data",
|
| - DevToolsChannelData::CreateForChannel(channel()));
|
| + TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GPUTask",
|
| + "data", DevToolsChannelData::CreateForChannel(channel()));
|
| FastSetActiveURL(active_url_, active_url_hash_, channel_);
|
|
|
| bool have_context = false;
|
| @@ -303,12 +302,9 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
|
| OnRegisterTransferBuffer);
|
| IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
|
| OnDestroyTransferBuffer);
|
| - IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_WaitSyncToken,
|
| - OnWaitSyncToken)
|
| - IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken,
|
| - OnSignalSyncToken)
|
| - IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery,
|
| - OnSignalQuery)
|
| + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_WaitSyncToken, OnWaitSyncToken)
|
| + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncToken, OnSignalSyncToken)
|
| + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, OnSignalQuery)
|
| IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateImage, OnCreateImage);
|
| IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyImage, OnDestroyImage);
|
| IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
|
| @@ -414,7 +410,7 @@ void GpuCommandBufferStub::PerformWork() {
|
|
|
| if (executor_) {
|
| uint32_t current_unprocessed_num =
|
| - channel()->gpu_channel_manager()->GetUnprocessedOrderNum();
|
| + channel()->sync_point_manager()->GetUnprocessedOrderNum();
|
| // We're idle when no messages were processed or scheduled.
|
| bool is_idle = (previous_processed_num_ == current_unprocessed_num);
|
| if (!is_idle && !last_idle_time_.is_null()) {
|
| @@ -445,7 +441,7 @@ bool GpuCommandBufferStub::HasUnprocessedCommands() {
|
| if (command_buffer_) {
|
| CommandBuffer::State state = command_buffer_->GetLastState();
|
| return command_buffer_->GetPutOffset() != state.get_offset &&
|
| - !error::IsError(state.error);
|
| + !error::IsError(state.error);
|
| }
|
| return false;
|
| }
|
| @@ -470,7 +466,7 @@ void GpuCommandBufferStub::ScheduleDelayedWork(base::TimeDelta delay) {
|
| // Idle when no messages are processed between now and when
|
| // PollWork is called.
|
| previous_processed_num_ =
|
| - channel()->gpu_channel_manager()->GetProcessedOrderNum();
|
| + channel()->sync_point_manager()->GetProcessedOrderNum();
|
| if (last_idle_time_.is_null())
|
| last_idle_time_ = current_time;
|
|
|
| @@ -517,8 +513,9 @@ void GpuCommandBufferStub::Destroy() {
|
| // (exit_on_context_lost workaround), then don't tell the browser about
|
| // offscreen context destruction here since it's not client-invoked, and
|
| // might bypass the 3D API blocking logic.
|
| - if ((surface_handle_ == gpu::kNullSurfaceHandle) && !active_url_.is_empty()
|
| - && !gpu_channel_manager->is_exiting_for_lost_context()) {
|
| + if ((surface_handle_ == gpu::kNullSurfaceHandle) &&
|
| + !active_url_.is_empty() &&
|
| + !gpu_channel_manager->is_exiting_for_lost_context()) {
|
| gpu_channel_manager->delegate()->DidDestroyOffscreenContext(active_url_);
|
| }
|
| }
|
| @@ -530,7 +527,10 @@ void GpuCommandBufferStub::Destroy() {
|
| // destroy it before those.
|
| executor_.reset();
|
|
|
| - sync_point_client_.reset();
|
| + if (sync_point_client_state_) {
|
| + sync_point_client_state_->Destroy();
|
| + sync_point_client_state_ = nullptr;
|
| + }
|
|
|
| bool have_context = false;
|
| if (decoder_ && decoder_->GetGLContext()) {
|
| @@ -639,16 +639,16 @@ bool GpuCommandBufferStub::Initialize(
|
| use_virtualized_gl_context_ = false;
|
| #endif
|
|
|
| - command_buffer_.reset(new CommandBufferService(
|
| - context_group_->transfer_buffer_manager()));
|
| + command_buffer_.reset(
|
| + new CommandBufferService(context_group_->transfer_buffer_manager()));
|
|
|
| decoder_.reset(gles2::GLES2Decoder::Create(context_group_.get()));
|
| executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(),
|
| decoder_.get()));
|
| - sync_point_client_ = base::MakeUnique<SyncPointClient>(
|
| - channel_->sync_point_manager(),
|
| - channel_->GetSyncPointOrderData(stream_id_),
|
| - CommandBufferNamespace::GPU_IO, command_buffer_id_);
|
| +
|
| + sync_point_client_state_ =
|
| + channel_->sync_point_manager()->CreateSyncPointClientState(
|
| + CommandBufferNamespace::GPU_IO, command_buffer_id_, sequence_id_);
|
|
|
| executor_->SetPreemptByFlag(channel_->preempted_flag());
|
|
|
| @@ -758,8 +758,7 @@ bool GpuCommandBufferStub::Initialize(
|
| }
|
|
|
| if (!context->GetGLStateRestorer()) {
|
| - context->SetGLStateRestorer(
|
| - new GLStateRestorerImpl(decoder_->AsWeakPtr()));
|
| + context->SetGLStateRestorer(new GLStateRestorerImpl(decoder_->AsWeakPtr()));
|
| }
|
|
|
| if (!context_group_->has_program_cache() &&
|
| @@ -779,12 +778,10 @@ bool GpuCommandBufferStub::Initialize(
|
| decoder_->set_log_commands(true);
|
| }
|
|
|
| - decoder_->GetLogger()->SetMsgCallback(
|
| - base::Bind(&GpuCommandBufferStub::SendConsoleMessage,
|
| - base::Unretained(this)));
|
| - decoder_->SetShaderCacheCallback(
|
| - base::Bind(&GpuCommandBufferStub::SendCachedShader,
|
| - base::Unretained(this)));
|
| + decoder_->GetLogger()->SetMsgCallback(base::Bind(
|
| + &GpuCommandBufferStub::SendConsoleMessage, base::Unretained(this)));
|
| + decoder_->SetShaderCacheCallback(base::Bind(
|
| + &GpuCommandBufferStub::SendCachedShader, base::Unretained(this)));
|
| decoder_->SetFenceSyncReleaseCallback(base::Bind(
|
| &GpuCommandBufferStub::OnFenceSyncRelease, base::Unretained(this)));
|
| decoder_->SetWaitSyncTokenCallback(base::Bind(
|
| @@ -909,8 +906,8 @@ void GpuCommandBufferStub::CheckCompleteWaits() {
|
| if (wait_for_token_ || wait_for_get_offset_) {
|
| CommandBuffer::State state = command_buffer_->GetLastState();
|
| if (wait_for_token_ &&
|
| - (CommandBuffer::InRange(
|
| - wait_for_token_->start, wait_for_token_->end, state.token) ||
|
| + (CommandBuffer::InRange(wait_for_token_->start, wait_for_token_->end,
|
| + state.token) ||
|
| state.error != error::kNoError)) {
|
| ReportState();
|
| GpuCommandBufferMsg_WaitForTokenInRange::WriteReplyParams(
|
| @@ -920,8 +917,7 @@ void GpuCommandBufferStub::CheckCompleteWaits() {
|
| }
|
| if (wait_for_get_offset_ &&
|
| (CommandBuffer::InRange(wait_for_get_offset_->start,
|
| - wait_for_get_offset_->end,
|
| - state.get_offset) ||
|
| + wait_for_get_offset_->end, state.get_offset) ||
|
| state.error != error::kNoError)) {
|
| ReportState();
|
| GpuCommandBufferMsg_WaitForGetOffsetInRange::WriteReplyParams(
|
| @@ -1000,7 +996,9 @@ void GpuCommandBufferStub::OnCommandProcessed() {
|
| channel_->watchdog()->CheckArmed();
|
| }
|
|
|
| -void GpuCommandBufferStub::ReportState() { command_buffer_->UpdateState(); }
|
| +void GpuCommandBufferStub::ReportState() {
|
| + command_buffer_->UpdateState();
|
| +}
|
|
|
| void GpuCommandBufferStub::PutChanged() {
|
| FastSetActiveURL(active_url_, active_url_hash_, channel_);
|
| @@ -1009,7 +1007,7 @@ void GpuCommandBufferStub::PutChanged() {
|
|
|
| void GpuCommandBufferStub::OnSignalSyncToken(const SyncToken& sync_token,
|
| uint32_t id) {
|
| - if (!sync_point_client_->WaitNonThreadSafe(
|
| + if (!sync_point_client_state_->WaitNonThreadSafe(
|
| sync_token, channel_->task_runner(),
|
| base::Bind(&GpuCommandBufferStub::OnSignalAck, this->AsWeakPtr(),
|
| id))) {
|
| @@ -1025,13 +1023,10 @@ void GpuCommandBufferStub::OnSignalQuery(uint32_t query_id, uint32_t id) {
|
| if (decoder_) {
|
| gles2::QueryManager* query_manager = decoder_->GetQueryManager();
|
| if (query_manager) {
|
| - gles2::QueryManager::Query* query =
|
| - query_manager->GetQuery(query_id);
|
| + gles2::QueryManager::Query* query = query_manager->GetQuery(query_id);
|
| if (query) {
|
| - query->AddCallback(
|
| - base::Bind(&GpuCommandBufferStub::OnSignalAck,
|
| - this->AsWeakPtr(),
|
| - id));
|
| + query->AddCallback(base::Bind(&GpuCommandBufferStub::OnSignalAck,
|
| + this->AsWeakPtr(), id));
|
| return;
|
| }
|
| }
|
| @@ -1048,7 +1043,7 @@ void GpuCommandBufferStub::OnFenceSyncRelease(uint64_t release) {
|
| mailbox_manager->PushTextureUpdates(sync_token);
|
|
|
| command_buffer_->SetReleaseCount(release);
|
| - sync_point_client_->ReleaseFenceSync(release);
|
| + sync_point_client_state_->ReleaseFenceSync(release);
|
| }
|
|
|
| void GpuCommandBufferStub::OnDescheduleUntilFinished() {
|
| @@ -1056,14 +1051,14 @@ void GpuCommandBufferStub::OnDescheduleUntilFinished() {
|
| DCHECK(executor_->HasPollingWork());
|
|
|
| executor_->SetScheduled(false);
|
| - channel_->OnStreamRescheduled(stream_id_, false);
|
| + channel_->OnCommandBufferDescheduled(this);
|
| }
|
|
|
| void GpuCommandBufferStub::OnRescheduleAfterFinished() {
|
| DCHECK(!executor_->scheduled());
|
|
|
| executor_->SetScheduled(true);
|
| - channel_->OnStreamRescheduled(stream_id_, true);
|
| + channel_->OnCommandBufferScheduled(this);
|
| }
|
|
|
| bool GpuCommandBufferStub::OnWaitSyncToken(const SyncToken& sync_token) {
|
| @@ -1072,14 +1067,14 @@ bool GpuCommandBufferStub::OnWaitSyncToken(const SyncToken& sync_token) {
|
| TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitSyncToken", this, "GpuCommandBufferStub",
|
| this);
|
|
|
| - waiting_for_sync_point_ = sync_point_client_->WaitNonThreadSafe(
|
| + waiting_for_sync_point_ = sync_point_client_state_->WaitNonThreadSafe(
|
| sync_token, channel_->task_runner(),
|
| base::Bind(&GpuCommandBufferStub::OnWaitSyncTokenCompleted, AsWeakPtr(),
|
| sync_token));
|
|
|
| if (waiting_for_sync_point_) {
|
| executor_->SetScheduled(false);
|
| - channel_->OnStreamRescheduled(stream_id_, false);
|
| + channel_->OnCommandBufferDescheduled(this);
|
| return true;
|
| }
|
|
|
| @@ -1099,7 +1094,7 @@ void GpuCommandBufferStub::OnWaitSyncTokenCompleted(
|
| // again and call PullTextureUpdates once this command buffer gets scheduled.
|
| waiting_for_sync_point_ = false;
|
| executor_->SetScheduled(true);
|
| - channel_->OnStreamRescheduled(stream_id_, true);
|
| + channel_->OnCommandBufferScheduled(this);
|
| }
|
|
|
| void GpuCommandBufferStub::OnCreateImage(
|
| @@ -1146,7 +1141,7 @@ void GpuCommandBufferStub::OnCreateImage(
|
|
|
| image_manager->AddImage(image.get(), id);
|
| if (image_release_count)
|
| - sync_point_client_->ReleaseFenceSync(image_release_count);
|
| + sync_point_client_state_->ReleaseFenceSync(image_release_count);
|
| }
|
|
|
| void GpuCommandBufferStub::OnDestroyImage(int32_t id) {
|
|
|