本文整理汇总了C++中decaf_check函数的典型用法代码示例。如果您正苦于以下问题:C++ decaf_check函数的具体用法?C++ decaf_check怎么用?C++ decaf_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decaf_check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPauseInitiatorCoreId
uint32_t
getPauseInitiatorCoreId()
{
decaf_check(paused());
decaf_check(sPauseInitiatorCoreId < 3);
return sPauseInitiatorCoreId;
}
示例2: flushActiveCommandBuffer
static void
flushActiveCommandBuffer()
{
auto core = coreinit::OSGetCoreId();
auto cb = sActiveBuffer[core];
decaf_check(cb);
decaf_check(!cb->displayList);
// Lets make sure our lease is still active, and then release it.
decaf_check(sBufferPoolLeased);
sBufferPoolLeased = false;
// Release the remaining space from the buffer back to the
// pool so it can be used by the next command buffer!
returnToPool(cb->buffer, cb->curSize, cb->maxSize);
cb->maxSize = cb->curSize;
if (cb->curSize == 0) {
// There was no space taken, we can directly free this...
freeBufferObj(cb);
} else {
// Send buffer to our driver!
gpu::queueCommandBuffer(cb);
}
// This is no longer the active buffer
sActiveBuffer[core] = nullptr;
}
示例3: endUserCommandBuffer
uint32_t
endUserCommandBuffer(uint32_t *buffer)
{
auto core = coreinit::OSGetCoreId();
auto &cb = sActiveBuffer[core];
decaf_check(cb);
decaf_check(cb->displayList);
if (buffer != cb->buffer) {
// HACK: FAST Racing Neo shows this behaviour, gx2.rpl seems to not really care about what pointer
// you pass into GX2EndDisplayList, so it's possible this is perfectly valid behaviour and the error
// an application one, and not one caused by us.
gLog->warn("Display list passed to GX2EndDisplayList did not match one passed to GX2BeginDisplayList");
}
// Pad and get its size
padCommandBuffer(cb);
auto usedSize = cb->curSize;
// Release the buffer object to the pool
freeBufferObj(sActiveBuffer[core]);
sActiveBuffer[core] = nullptr;
// Allocate a new buffer!
if (core == getMainCoreId()) {
sActiveBuffer[core] = allocateCommandBuffer(0x100);
}
return usedSize;
}
示例4: OSWaitAlarm
/**
* Sleep the current thread until the alarm has been triggered or cancelled.
*
* \return Returns TRUE if alarm expired, FALSE if alarm cancelled
*/
BOOL
OSWaitAlarm(OSAlarm *alarm)
{
internal::lockScheduler();
internal::acquireIdLock(sAlarmLock, alarm);
decaf_check(alarm);
decaf_check(alarm->tag == OSAlarm::Tag);
if (alarm->state != OSAlarmState::Set) {
internal::releaseIdLock(sAlarmLock, alarm);
internal::unlockScheduler();
return FALSE;
}
OSGetCurrentThread()->alarmCancelled = false;
internal::sleepThreadNoLock(&alarm->threadQueue);
internal::releaseIdLock(sAlarmLock, alarm);
internal::rescheduleSelfNoLock();
auto cancelled = OSGetCurrentThread()->alarmCancelled;
internal::unlockScheduler();
if (cancelled) {
return FALSE;
} else {
return TRUE;
}
}
示例5: insertBlock
static void
insertBlock(virt_ptr<MEMExpHeapBlockList> list,
virt_ptr<MEMExpHeapBlock> prev,
virt_ptr<MEMExpHeapBlock> block)
{
decaf_check(!block->prev);
decaf_check(!block->next);
if (!prev) {
block->next = list->head;
block->prev = nullptr;
list->head = block;
} else {
block->next = prev->next;
block->prev = prev;
prev->next = block;
}
if (block->next) {
block->next->prev = block;
} else {
list->tail = block;
}
}
示例6: MEMGetAllocatableSizeForExpHeapEx
uint32_t
MEMGetAllocatableSizeForExpHeapEx(MEMHeapHandle handle,
int32_t alignment)
{
auto heap = virt_cast<MEMExpHeap *>(handle);
auto largestFree = 0u;
internal::HeapLock lock { virt_addrof(heap->header) };
if (alignment > 0) {
decaf_check((alignment & 0x3) == 0);
for (auto block = heap->freeList.head; block; block = block->next) {
auto alignedSize = getAlignedBlockSize(block, alignment, MEMExpHeapDirection::FromStart);
if (alignedSize > largestFree) {
largestFree = alignedSize;
}
}
} else {
alignment = -alignment;
decaf_check((alignment & 0x3) == 0);
for (auto block = heap->freeList.head; block; block = block->next) {
auto alignedSize = getAlignedBlockSize(block, alignment, MEMExpHeapDirection::FromEnd);
if (alignedSize > largestFree) {
largestFree = alignedSize;
}
}
}
return largestFree;
}
示例7: OSWaitCond
/**
* Sleep the current thread until the condition variable has been signalled.
*
* The mutex must be locked when entering this function.
* Will unlock the mutex and then sleep, reacquiring the mutex when woken.
*
* Similar to <a href="http://en.cppreference.com/w/cpp/thread/condition_variable/wait">std::condition_variable::wait</a>.
*/
void
OSWaitCond(OSCondition *condition, OSMutex *mutex)
{
auto thread = OSGetCurrentThread();
internal::lockScheduler();
decaf_check(mutex && mutex->tag == OSMutex::Tag);
decaf_check(condition && condition->tag == OSCondition::Tag);
decaf_check(mutex->owner == thread);
// Force an unlock
auto mutexCount = mutex->count;
mutex->count = 1;
unlockMutexNoLock(mutex);
internal::rescheduleOtherCoreNoLock();
// Sleep on the condition
internal::sleepThreadNoLock(&condition->queue);
internal::rescheduleSelfNoLock();
// Restore lock
lockMutexNoLock(mutex);
mutex->count = mutexCount;
internal::unlockScheduler();
}
示例8: GX2RLockSurfaceEx
virt_ptr<void>
GX2RLockSurfaceEx(virt_ptr<GX2Surface> surface,
int32_t level,
GX2RResourceFlags flags)
{
decaf_check(surface);
decaf_check(surface->resourceFlags & ~GX2RResourceFlags::Locked);
flags = surface->resourceFlags | internal::getOptionFlags(flags);
// Set Locked flag
surface->resourceFlags |= GX2RResourceFlags::Locked;
surface->resourceFlags |= flags & GX2RResourceFlags::LockedReadOnly;
// Check if we need to invalidate the surface.
if ((flags & GX2RResourceFlags::UsageGpuWrite) ||
(flags & GX2RResourceFlags::UsageDmaWrite)) {
if (!(flags & GX2RResourceFlags::DisableCpuInvalidate)) {
auto ptr = virt_ptr<void> { nullptr };
auto size = uint32_t { 0 };
internal::getSurfaceData(surface, level, &ptr, &size);
DCInvalidateRange(virt_cast<virt_addr>(ptr), size);
}
}
return surface->image;
}
示例9: decaf_check
size_t
HostFileHandle::read(uint8_t *data,
size_t size,
size_t count)
{
decaf_check(mHandle);
decaf_check((mMode & File::Read) || (mMode & File::Update));
return fread_s(data, size * count, size, count, mHandle);
}
示例10: MEMDestroyExpHeap
virt_ptr<void>
MEMDestroyExpHeap(MEMHeapHandle handle)
{
auto heap = virt_cast<MEMExpHeap *>(handle);
decaf_check(heap);
decaf_check(heap->header.tag == MEMHeapTag::ExpandedHeap);
internal::unregisterHeap(virt_addrof(heap->header));
return heap;
}
示例11: LOOP_END
static void
LOOP_END(State &state, const ControlFlowInst &cf)
{
// TODO: LOOP_END has different behaviour depending on which LOOP_START
// instruction started the loop, currently we only handle LOOP_START_DX10
auto &loopState = state.loopStack.top();
auto loopIndex = state.loopStack.size() - 1;
// Sanity check to ensure we are at the cfPC
decaf_check(state.cfPC == loopState.endPC);
decaf_check((cf.word0.ADDR - 1) == loopState.startPC);
state.loopStack.pop();
// If breakMask is set, lets break from the while
insertLineStart(state);
state.out << "if (activeMask == InactiveBreak) {";
insertLineEnd(state);
increaseIndent(state);
insertLineStart(state);
state.out << "break;";
insertLineEnd(state);
decreaseIndent(state);
insertLineStart(state);
state.out << "}";
insertLineEnd(state);
// If ContinueMask is set, lets break from the while
insertLineStart(state);
state.out << "if (activeMask == InactiveContinue) {";
insertLineEnd(state);
increaseIndent(state);
insertLineStart(state);
state.out << "activeMask = Active;";
insertLineEnd(state);
decreaseIndent(state);
insertLineStart(state);
state.out << "}";
insertLineEnd(state);
// Check the while condition but without checking loop masks
decreaseIndent(state);
insertLineStart(state);
state.out << "} while (";
insertCond(state, cf.word1.COND());
state.out << ");";
insertLineEnd(state);
insertPop(state);
condEnd(state);
}
示例12: getJoystickAxisState
static int
getJoystickAxisState(const config::input::InputDevice *device,
SDL_GameController *controller,
vpad::Channel channel,
vpad::CoreAxis axis)
{
decaf_check(device);
decaf_check(controller);
auto joystick = SDL_GameControllerGetJoystick(controller);
decaf_check(joystick);
auto index = -1;
auto name = SDL_CONTROLLER_AXIS_INVALID;
auto invert = false;
switch (axis) {
case vpad::CoreAxis::LeftStickX:
index = device->joystick.left_stick_x;
name = SDL_CONTROLLER_AXIS_LEFTX;
invert = device->joystick.left_stick_x_invert;
break;
case vpad::CoreAxis::LeftStickY:
index = device->joystick.left_stick_y;
name = SDL_CONTROLLER_AXIS_LEFTY;
invert = device->joystick.left_stick_y_invert;
break;
case vpad::CoreAxis::RightStickX:
index = device->joystick.right_stick_x;
name = SDL_CONTROLLER_AXIS_RIGHTX;
invert = device->joystick.right_stick_x_invert;
break;
case vpad::CoreAxis::RightStickY:
index = device->joystick.right_stick_y;
name = SDL_CONTROLLER_AXIS_RIGHTY;
invert = device->joystick.right_stick_y_invert;
break;
}
auto value = 0;
if (index >= 0) {
value = SDL_JoystickGetAxis(joystick, index);
} else if (index == -2) {
if (name != SDL_CONTROLLER_AXIS_INVALID) {
value = SDL_GameControllerGetAxis(controller, name);
}
}
if (invert) {
value = -value;
}
return value;
}
示例13: copySurfacePixels
bool
copySurfacePixels(uint8_t *dstBasePtr,
uint32_t dstWidth,
uint32_t dstHeight,
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT &dstAddrInput,
uint8_t *srcBasePtr,
uint32_t srcWidth,
uint32_t srcHeight,
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT &srcAddrInput)
{
auto handle = getAddrLibHandle();
decaf_check(srcAddrInput.bpp == dstAddrInput.bpp);
auto bpp = dstAddrInput.bpp;
if (USE_ADDRLIBOPT) {
decaf_check(srcAddrInput.isDepth == dstAddrInput.isDepth);
decaf_check(srcAddrInput.numSamples == dstAddrInput.numSamples);
auto isDepth = dstAddrInput.isDepth;
auto numSamples = dstAddrInput.numSamples;
return gpu::addrlibopt::copySurfacePixels(
dstBasePtr, dstWidth, dstHeight, dstAddrInput,
srcBasePtr, srcWidth, srcHeight, srcAddrInput,
bpp, isDepth, numSamples);
} else {
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT srcAddrOutput;
ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT dstAddrOutput;
std::memset(&srcAddrOutput, 0, sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT));
std::memset(&dstAddrOutput, 0, sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT));
srcAddrOutput.size = sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT);
dstAddrOutput.size = sizeof(ADDR_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT);
for (auto y = 0u; y < dstHeight; ++y) {
for (auto x = 0u; x < dstWidth; ++x) {
srcAddrInput.x = srcWidth * x / dstWidth;
srcAddrInput.y = srcHeight * y / dstHeight;
AddrComputeSurfaceAddrFromCoord(handle, &srcAddrInput, &srcAddrOutput);
dstAddrInput.x = x;
dstAddrInput.y = y;
AddrComputeSurfaceAddrFromCoord(handle, &dstAddrInput, &dstAddrOutput);
auto src = &srcBasePtr[srcAddrOutput.addr];
auto dst = &dstBasePtr[dstAddrOutput.addr];
std::memcpy(dst, src, bpp / 8);
}
}
return true;
}
}
示例14: lock
void
FSClient::removeOpenFile(FSFileHandle handle)
{
std::lock_guard<std::mutex> lock(mMutex);
decaf_check(handle < mOpenFiles.size());
decaf_check(mOpenFiles[handle]);
mOpenFiles[handle]->close();
delete mOpenFiles[handle];
mOpenFiles[handle] = nullptr;
}
示例15: OSGetSemaphoreCount
/**
* Get the current semaphore count.
*/
int32_t
OSGetSemaphoreCount(OSSemaphore *semaphore)
{
internal::lockScheduler();
decaf_check(semaphore);
decaf_check(semaphore->tag == OSSemaphore::Tag);
// Return count
auto count = semaphore->count;
internal::unlockScheduler();
return count;
}