Optimize CommandBufferHelper::GetSpace().
commit15691b4073e449b8ad6eeca889a40b157fe14e94
authorvmiura@chromium.org <vmiura@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 12 Feb 2014 00:56:00 +0000 (12 00:56 +0000)
committervmiura@chromium.org <vmiura@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Wed, 12 Feb 2014 00:56:00 +0000 (12 00:56 +0000)
tree342497925c6f34de48b5d895f5a3baec64e0fc27
parent1d4d65dd6c49df9ffe0a43df0cdb6777029c2342
Optimize CommandBufferHelper::GetSpace().

Previously GetSpace() did various calls:
- usable() - Check if buffer is usable.
- AllocateRingBuffer() - Allocate buffer if not already allocated.
- WaitForAvailableEntries() - Yet more checks.

This change shortcuts most calls, reducing to checks on
immediate_entry_count_ and commands_issued_ only, maintaining the old
behavior in terms of internal flushing.

immediate_entry_count_ is 0 if the buffer is unusable or unallocated,
otherwise is limited to min(immediate free space, force flush limit).

commands_issued_ is counted on non-Android platforms, and checks for
force flush condition every kCommandsPerFlushCheck commands.

BUG=340362

Review URL: https://codereview.chromium.org/141133010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250582 0039d316-1c4b-4281-b951-d872f2087c98
gpu/command_buffer/client/cmd_buffer_helper.cc
gpu/command_buffer/client/cmd_buffer_helper.h
gpu/command_buffer/client/cmd_buffer_helper_test.cc