blob: 4c9db1de29338e5fd41fd1616aab189134e12e41 [file] [log] [blame]
/*
* Copyright 2015, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* THIS FILE WAS GENERATED BY apic. DO NOT EDIT.
*/
#include "abort_exception.h"
#include "core_imports.h"
#include "core_types.h"
#include "core_spy.h"
#include <gapic/log.h>
#include <gapic/coder/memory.h>
#include <gapic/coder/atom.h>
#include <gapic/coder/core.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <stdint.h>
#include <memory>
#include <string>
namespace gapii {
void CoreSpy::switchThread(CallObserver* observer, ThreadID threadID) {
GAPID_DEBUG("switchThread(%" PRIu64 ")", threadID);
bool called = false;
auto call = [this, observer, &called, threadID] {
called = true;
observer->observeReads();
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
dynamic_cast<GlesSpy*>(this)->CurrentThread = (ThreadID)(threadID);
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::core::SwitchThread coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< uint64_t >(threadID, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
} // namespace gapii