// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file contains the command buffer helper class. #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ #include <stddef.h> #include <stdint.h> #include <string.h> #include "base/check_op.h" #include "base/functional/function_ref.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "base/trace_event/memory_dump_provider.h" #include "build/build_config.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/context_result.h" #include "gpu/gpu_export.h" namespace gpu { class Buffer; #if !BUILDFLAG(IS_ANDROID) #define CMD_HELPER_PERIODIC_FLUSH_CHECK const int kCommandsPerFlushCheck = …; const int kPeriodicFlushDelayInMicroseconds = …; #endif const int kAutoFlushSmall = …; // 1/16 of the buffer const int kAutoFlushBig = …; // 1/2 of the buffer // Command buffer helper class. This class simplifies ring buffer management: // it will allocate the buffer, give it to the buffer interface, and let the // user add commands to it, while taking care of the synchronization (put and // get). It also provides a way to ensure commands have been executed, through // the token mechanism: // // helper.AddCommand(...); // helper.AddCommand(...); // int32_t token = helper.InsertToken(); // helper.AddCommand(...); // helper.AddCommand(...); // [...] // // helper.WaitForToken(token); // this doesn't return until the first two // // commands have been executed. class GPU_EXPORT CommandBufferHelper { … }; } // namespace gpu #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_