2021-03-03 04:42:55 +00:00
|
|
|
#include "ppsspp_config.h"
|
2022-04-14 22:35:22 +00:00
|
|
|
|
|
|
|
#if defined(_M_SSE)
|
|
|
|
#include <emmintrin.h>
|
|
|
|
#endif
|
|
|
|
#if PPSSPP_ARCH(ARM_NEON)
|
|
|
|
#if defined(_MSC_VER) && PPSSPP_ARCH(ARM64)
|
|
|
|
#include <arm64_neon.h>
|
|
|
|
#else
|
|
|
|
#include <arm_neon.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-04-02 06:54:19 +00:00
|
|
|
#include <algorithm>
|
2015-10-11 12:38:26 +00:00
|
|
|
|
2020-10-04 08:04:01 +00:00
|
|
|
#include "Common/Profiler/Profiler.h"
|
2017-08-18 11:39:42 +00:00
|
|
|
|
2020-03-01 06:27:00 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2022-12-27 22:58:20 +00:00
|
|
|
#include "Common/LogReporting.h"
|
2020-08-10 07:12:51 +00:00
|
|
|
#include "Common/Serialize/Serializer.h"
|
|
|
|
#include "Common/Serialize/SerializeFuncs.h"
|
|
|
|
#include "Common/Serialize/SerializeList.h"
|
2020-08-15 18:53:08 +00:00
|
|
|
#include "Common/TimeUtil.h"
|
2015-05-23 17:33:24 +00:00
|
|
|
#include "GPU/GeDisasm.h"
|
2015-07-26 20:38:40 +00:00
|
|
|
#include "GPU/GPU.h"
|
2015-05-23 17:33:24 +00:00
|
|
|
#include "GPU/GPUCommon.h"
|
|
|
|
#include "GPU/GPUState.h"
|
2013-04-21 22:16:45 +00:00
|
|
|
#include "Core/Config.h"
|
2013-04-03 15:10:35 +00:00
|
|
|
#include "Core/CoreTiming.h"
|
2021-02-02 08:08:05 +00:00
|
|
|
#include "Core/Debugger/MemBlockInfo.h"
|
2013-04-01 06:02:46 +00:00
|
|
|
#include "Core/MemMap.h"
|
2013-04-05 08:13:54 +00:00
|
|
|
#include "Core/Reporting.h"
|
2014-06-14 15:42:18 +00:00
|
|
|
#include "Core/HLE/HLE.h"
|
2013-04-04 07:35:38 +00:00
|
|
|
#include "Core/HLE/sceKernelMemory.h"
|
2013-08-29 06:15:13 +00:00
|
|
|
#include "Core/HLE/sceKernelInterrupt.h"
|
2014-03-30 00:02:41 +00:00
|
|
|
#include "Core/HLE/sceKernelThread.h"
|
2013-04-01 06:02:46 +00:00
|
|
|
#include "Core/HLE/sceGe.h"
|
2022-01-30 18:46:50 +00:00
|
|
|
#include "Core/HW/Display.h"
|
2023-02-26 18:54:30 +00:00
|
|
|
#include "Core/Util/PPGeDraw.h"
|
2016-12-21 17:26:06 +00:00
|
|
|
#include "Core/MemMapHelpers.h"
|
2018-06-29 02:47:33 +00:00
|
|
|
#include "GPU/Common/DrawEngineCommon.h"
|
2020-08-03 21:17:22 +00:00
|
|
|
#include "GPU/Common/FramebufferManagerCommon.h"
|
2016-12-21 17:07:17 +00:00
|
|
|
#include "GPU/Common/TextureCacheCommon.h"
|
2018-09-01 15:32:03 +00:00
|
|
|
#include "GPU/Debugger/Debugger.h"
|
2017-06-03 04:53:20 +00:00
|
|
|
#include "GPU/Debugger/Record.h"
|
2012-12-28 20:58:00 +00:00
|
|
|
|
2017-01-23 19:56:25 +00:00
|
|
|
void GPUCommon::Flush() {
|
|
|
|
drawEngineCommon_->DispatchFlush();
|
|
|
|
}
|
|
|
|
|
2022-01-22 21:12:59 +00:00
|
|
|
void GPUCommon::DispatchFlush() {
|
|
|
|
drawEngineCommon_->DispatchFlush();
|
|
|
|
}
|
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) :
|
|
|
|
gfxCtx_(gfxCtx),
|
|
|
|
draw_(draw)
|
2013-04-05 06:19:28 +00:00
|
|
|
{
|
2015-10-11 16:42:32 +00:00
|
|
|
// This assert failed on GCC x86 32-bit (but not MSVC 32-bit!) before adding the
|
2015-10-11 12:38:26 +00:00
|
|
|
// "padding" field at the end. This is important for save state compatibility.
|
2015-10-11 16:42:32 +00:00
|
|
|
// The compiler was not rounding the struct size up to an 8 byte boundary, which
|
|
|
|
// you'd expect due to the int64 field, but the Linux ABI apparently does not require that.
|
2015-10-11 12:38:26 +00:00
|
|
|
static_assert(sizeof(DisplayList) == 456, "Bad DisplayList size");
|
|
|
|
|
2013-11-28 23:34:41 +00:00
|
|
|
Reinitialize();
|
2016-01-06 22:49:02 +00:00
|
|
|
gstate.Reset();
|
|
|
|
gstate_c.Reset();
|
2016-04-02 08:28:38 +00:00
|
|
|
gpuStats.Reset();
|
2018-02-26 10:44:02 +00:00
|
|
|
|
2023-02-26 18:54:30 +00:00
|
|
|
PPGeSetDrawContext(draw);
|
2022-09-28 05:29:55 +00:00
|
|
|
ResetMatrices();
|
2013-11-28 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
2016-01-06 22:53:21 +00:00
|
|
|
void GPUCommon::BeginHostFrame() {
|
|
|
|
ReapplyGfxState();
|
2017-03-19 17:40:23 +00:00
|
|
|
|
|
|
|
// TODO: Assume config may have changed - maybe move to resize.
|
|
|
|
gstate_c.Dirty(DIRTY_ALL);
|
2022-11-21 16:55:30 +00:00
|
|
|
|
|
|
|
UpdateCmdInfo();
|
2022-12-14 14:15:31 +00:00
|
|
|
|
|
|
|
UpdateMSAALevel(draw_);
|
2022-11-21 16:59:56 +00:00
|
|
|
CheckConfigChanged();
|
|
|
|
CheckDisplayResized();
|
|
|
|
CheckRenderResized();
|
2016-01-06 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::EndHostFrame() {
|
2022-11-21 16:55:30 +00:00
|
|
|
// Probably not necessary.
|
2022-11-21 18:57:59 +00:00
|
|
|
if (draw_) {
|
2022-12-01 18:15:38 +00:00
|
|
|
draw_->Invalidate(InvalidationFlags::CACHED_RENDER_STATE);
|
2022-11-21 18:57:59 +00:00
|
|
|
}
|
2016-01-06 22:53:21 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 23:34:41 +00:00
|
|
|
void GPUCommon::Reinitialize() {
|
2013-04-15 20:57:54 +00:00
|
|
|
memset(dls, 0, sizeof(dls));
|
2013-04-06 09:28:49 +00:00
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
2013-04-05 06:19:28 +00:00
|
|
|
dls[i].state = PSP_GE_DL_STATE_NONE;
|
2013-04-07 19:45:42 +00:00
|
|
|
dls[i].waitTicks = 0;
|
2013-04-06 09:28:49 +00:00
|
|
|
}
|
2013-11-28 23:34:41 +00:00
|
|
|
|
|
|
|
nextListID = 0;
|
2017-11-05 18:44:07 +00:00
|
|
|
currentList = nullptr;
|
2013-11-28 23:34:41 +00:00
|
|
|
isbreak = false;
|
|
|
|
drawCompleteTicks = 0;
|
|
|
|
busyTicks = 0;
|
2014-06-14 15:42:18 +00:00
|
|
|
timeSpentStepping_ = 0.0;
|
2013-11-28 23:34:41 +00:00
|
|
|
interruptsEnabled_ = true;
|
2020-05-13 07:06:13 +00:00
|
|
|
|
|
|
|
if (textureCache_)
|
|
|
|
textureCache_->Clear(true);
|
|
|
|
if (framebufferManager_)
|
|
|
|
framebufferManager_->DestroyAllFBOs();
|
2017-11-05 19:10:05 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:00:44 +00:00
|
|
|
int GPUCommon::EstimatePerVertexCost() {
|
|
|
|
// TODO: This is transform cost, also account for rasterization cost somehow... although it probably
|
|
|
|
// runs in parallel with transform.
|
|
|
|
|
|
|
|
// Also, this is all pure guesswork. If we can find a way to do measurements, that would be great.
|
|
|
|
|
|
|
|
// GTA wants a low value to run smooth, GoW wants a high value (otherwise it thinks things
|
|
|
|
// went too fast and starts doing all the work over again).
|
|
|
|
|
|
|
|
int cost = 20;
|
|
|
|
if (gstate.isLightingEnabled()) {
|
|
|
|
cost += 10;
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
if (gstate.isLightChanEnabled(i))
|
2018-07-15 10:13:25 +00:00
|
|
|
cost += 7;
|
2017-01-23 20:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gstate.getUVGenMode() != GE_TEXMAP_TEXTURE_COORDS) {
|
|
|
|
cost += 20;
|
|
|
|
}
|
|
|
|
int morphCount = gstate.getNumMorphWeights();
|
|
|
|
if (morphCount > 1) {
|
|
|
|
cost += 5 * morphCount;
|
|
|
|
}
|
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
void GPUCommon::PopDLQueue() {
|
|
|
|
if(!dlQueue.empty()) {
|
|
|
|
dlQueue.pop_front();
|
|
|
|
if(!dlQueue.empty()) {
|
|
|
|
bool running = currentList->state == PSP_GE_DL_STATE_RUNNING;
|
|
|
|
currentList = &dls[dlQueue.front()];
|
|
|
|
if (running)
|
|
|
|
currentList->state = PSP_GE_DL_STATE_RUNNING;
|
|
|
|
} else {
|
2017-11-05 19:15:57 +00:00
|
|
|
currentList = nullptr;
|
2013-04-05 06:19:28 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-28 20:58:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-22 02:31:54 +00:00
|
|
|
bool GPUCommon::BusyDrawing() {
|
|
|
|
u32 state = DrawSync(1);
|
|
|
|
if (state == PSP_GE_LIST_DRAWING || state == PSP_GE_LIST_STALLING) {
|
|
|
|
if (currentList && currentList->state != PSP_GE_DL_STATE_PAUSED) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-11-21 14:14:20 +00:00
|
|
|
void GPUCommon::NotifyConfigChanged() {
|
|
|
|
configChanged_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::NotifyRenderResized() {
|
|
|
|
renderResized_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::NotifyDisplayResized() {
|
|
|
|
displayResized_ = true;
|
2016-12-21 17:13:58 +00:00
|
|
|
}
|
|
|
|
|
2017-06-03 02:39:11 +00:00
|
|
|
void GPUCommon::DumpNextFrame() {
|
|
|
|
dumpNextFrame_ = true;
|
|
|
|
}
|
|
|
|
|
2013-04-01 06:23:03 +00:00
|
|
|
u32 GPUCommon::DrawSync(int mode) {
|
2023-02-07 21:59:46 +00:00
|
|
|
gpuStats.numDrawSyncs++;
|
|
|
|
|
2013-04-01 06:42:56 +00:00
|
|
|
if (mode < 0 || mode > 1)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_MODE;
|
|
|
|
|
2013-04-04 06:31:01 +00:00
|
|
|
if (mode == 0) {
|
2013-08-28 15:13:44 +00:00
|
|
|
if (!__KernelIsDispatchEnabled()) {
|
|
|
|
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
|
|
|
}
|
2013-08-29 06:15:13 +00:00
|
|
|
if (__IsInInterrupt()) {
|
|
|
|
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
|
|
|
}
|
2013-08-28 15:13:44 +00:00
|
|
|
|
2013-04-07 19:45:42 +00:00
|
|
|
if (drawCompleteTicks > CoreTiming::GetTicks()) {
|
2014-03-30 00:02:41 +00:00
|
|
|
__GeWaitCurrentThread(GPU_SYNC_DRAW, 1, "GeDrawSync");
|
2013-04-06 05:38:19 +00:00
|
|
|
} else {
|
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
|
|
|
if (dls[i].state == PSP_GE_DL_STATE_COMPLETED) {
|
|
|
|
dls[i].state = PSP_GE_DL_STATE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-04 06:31:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-06 05:38:19 +00:00
|
|
|
// If there's no current list, it must be complete.
|
|
|
|
DisplayList *top = NULL;
|
|
|
|
for (auto it = dlQueue.begin(), end = dlQueue.end(); it != end; ++it) {
|
|
|
|
if (dls[*it].state != PSP_GE_DL_STATE_COMPLETED) {
|
|
|
|
top = &dls[*it];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!top || top->state == PSP_GE_DL_STATE_COMPLETED)
|
2013-04-04 06:31:01 +00:00
|
|
|
return PSP_GE_LIST_COMPLETED;
|
|
|
|
|
|
|
|
if (currentList->pc == currentList->stall)
|
|
|
|
return PSP_GE_LIST_STALLING;
|
|
|
|
|
|
|
|
return PSP_GE_LIST_DRAWING;
|
2013-04-01 06:23:03 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
void GPUCommon::CheckDrawSync() {
|
2013-04-05 06:19:28 +00:00
|
|
|
if (dlQueue.empty()) {
|
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i)
|
|
|
|
dls[i].state = PSP_GE_DL_STATE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
int GPUCommon::ListSync(int listid, int mode) {
|
2023-02-07 21:59:46 +00:00
|
|
|
gpuStats.numListSyncs++;
|
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
if (listid < 0 || listid >= DisplayListMaxCount)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_ID;
|
|
|
|
|
2013-04-01 06:42:56 +00:00
|
|
|
if (mode < 0 || mode > 1)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_MODE;
|
|
|
|
|
2013-04-06 09:28:49 +00:00
|
|
|
DisplayList& dl = dls[listid];
|
2013-04-04 06:05:54 +00:00
|
|
|
if (mode == 1) {
|
2013-04-05 06:19:28 +00:00
|
|
|
switch (dl.state) {
|
2013-04-04 06:05:54 +00:00
|
|
|
case PSP_GE_DL_STATE_QUEUED:
|
2013-04-05 06:19:28 +00:00
|
|
|
if (dl.interrupted)
|
2013-04-04 07:35:38 +00:00
|
|
|
return PSP_GE_LIST_PAUSED;
|
2013-04-04 06:05:54 +00:00
|
|
|
return PSP_GE_LIST_QUEUED;
|
|
|
|
|
|
|
|
case PSP_GE_DL_STATE_RUNNING:
|
2013-04-05 06:19:28 +00:00
|
|
|
if (dl.pc == dl.stall)
|
2013-04-04 06:05:54 +00:00
|
|
|
return PSP_GE_LIST_STALLING;
|
|
|
|
return PSP_GE_LIST_DRAWING;
|
|
|
|
|
|
|
|
case PSP_GE_DL_STATE_COMPLETED:
|
|
|
|
return PSP_GE_LIST_COMPLETED;
|
|
|
|
|
|
|
|
case PSP_GE_DL_STATE_PAUSED:
|
|
|
|
return PSP_GE_LIST_PAUSED;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_ID;
|
2012-12-28 20:58:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-04 06:05:54 +00:00
|
|
|
|
2013-08-28 15:13:44 +00:00
|
|
|
if (!__KernelIsDispatchEnabled()) {
|
|
|
|
return SCE_KERNEL_ERROR_CAN_NOT_WAIT;
|
2013-08-29 06:15:13 +00:00
|
|
|
}
|
|
|
|
if (__IsInInterrupt()) {
|
|
|
|
return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT;
|
2013-08-28 15:13:44 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 19:45:42 +00:00
|
|
|
if (dl.waitTicks > CoreTiming::GetTicks()) {
|
2014-03-30 00:02:41 +00:00
|
|
|
__GeWaitCurrentThread(GPU_SYNC_LIST, listid, "GeListSync");
|
2013-04-06 09:28:49 +00:00
|
|
|
}
|
2013-04-04 06:05:54 +00:00
|
|
|
return PSP_GE_LIST_COMPLETED;
|
2012-12-28 20:58:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-21 17:03:49 +00:00
|
|
|
int GPUCommon::GetStack(int index, u32 stackPtr) {
|
2017-11-05 18:44:07 +00:00
|
|
|
if (!currentList) {
|
2013-09-21 17:03:49 +00:00
|
|
|
// Seems like it doesn't return an error code?
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentList->stackptr <= index) {
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_INDEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index >= 0) {
|
2021-02-19 06:25:24 +00:00
|
|
|
auto stack = PSPPointer<u32_le>::Create(stackPtr);
|
2013-09-21 17:03:49 +00:00
|
|
|
if (stack.IsValid()) {
|
|
|
|
auto entry = currentList->stack[index];
|
|
|
|
// Not really sure what most of these values are.
|
|
|
|
stack[0] = 0;
|
|
|
|
stack[1] = entry.pc + 4;
|
|
|
|
stack[2] = entry.offsetAddr;
|
|
|
|
stack[7] = entry.baseAddr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return currentList->stackptr;
|
|
|
|
}
|
|
|
|
|
2022-09-28 05:29:55 +00:00
|
|
|
static void CopyMatrix24(u32_le *result, const float *mtx, u32 count, u32 cmdbits) {
|
2023-02-25 13:59:14 +00:00
|
|
|
// Screams out for simple SIMD, but probably not called often enough to be worth it.
|
2022-09-28 03:20:46 +00:00
|
|
|
for (u32 i = 0; i < count; ++i) {
|
2022-09-28 05:29:55 +00:00
|
|
|
result[i] = toFloat24(mtx[i]) | cmdbits;
|
2022-09-28 03:20:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-28 05:29:55 +00:00
|
|
|
bool GPUCommon::GetMatrix24(GEMatrixType type, u32_le *result, u32 cmdbits) {
|
2022-09-28 03:20:46 +00:00
|
|
|
switch (type) {
|
|
|
|
case GE_MTX_BONE0:
|
|
|
|
case GE_MTX_BONE1:
|
|
|
|
case GE_MTX_BONE2:
|
|
|
|
case GE_MTX_BONE3:
|
|
|
|
case GE_MTX_BONE4:
|
|
|
|
case GE_MTX_BONE5:
|
|
|
|
case GE_MTX_BONE6:
|
|
|
|
case GE_MTX_BONE7:
|
2022-09-28 05:29:55 +00:00
|
|
|
CopyMatrix24(result, gstate.boneMatrix + (type - GE_MTX_BONE0) * 12, 12, cmdbits);
|
2022-09-28 03:20:46 +00:00
|
|
|
break;
|
|
|
|
case GE_MTX_TEXGEN:
|
2022-09-28 05:29:55 +00:00
|
|
|
CopyMatrix24(result, gstate.tgenMatrix, 12, cmdbits);
|
2022-09-28 03:20:46 +00:00
|
|
|
break;
|
|
|
|
case GE_MTX_WORLD:
|
2022-09-28 05:29:55 +00:00
|
|
|
CopyMatrix24(result, gstate.worldMatrix, 12, cmdbits);
|
2022-09-28 03:20:46 +00:00
|
|
|
break;
|
|
|
|
case GE_MTX_VIEW:
|
2022-09-28 05:29:55 +00:00
|
|
|
CopyMatrix24(result, gstate.viewMatrix, 12, cmdbits);
|
2022-09-28 03:20:46 +00:00
|
|
|
break;
|
|
|
|
case GE_MTX_PROJECTION:
|
2022-09-28 05:29:55 +00:00
|
|
|
CopyMatrix24(result, gstate.projMatrix, 16, cmdbits);
|
2022-09-28 03:20:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-28 05:29:55 +00:00
|
|
|
void GPUCommon::ResetMatrices() {
|
|
|
|
// This means we restored a context, so update the visible matrix data.
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(gstate.boneMatrix); ++i)
|
|
|
|
matrixVisible.bone[i] = toFloat24(gstate.boneMatrix[i]);
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(gstate.worldMatrix); ++i)
|
|
|
|
matrixVisible.world[i] = toFloat24(gstate.worldMatrix[i]);
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(gstate.viewMatrix); ++i)
|
|
|
|
matrixVisible.view[i] = toFloat24(gstate.viewMatrix[i]);
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(gstate.projMatrix); ++i)
|
|
|
|
matrixVisible.proj[i] = toFloat24(gstate.projMatrix[i]);
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(gstate.tgenMatrix); ++i)
|
|
|
|
matrixVisible.tgen[i] = toFloat24(gstate.tgenMatrix[i]);
|
2022-09-30 04:36:53 +00:00
|
|
|
|
|
|
|
// Assume all the matrices changed, so dirty things related to them.
|
|
|
|
gstate_c.Dirty(DIRTY_WORLDMATRIX | DIRTY_VIEWMATRIX | DIRTY_PROJMATRIX | DIRTY_TEXMATRIX | DIRTY_FRAGMENTSHADER_STATE | DIRTY_BONE_UNIFORMS);
|
2022-09-28 05:29:55 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 16:42:09 +00:00
|
|
|
u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<PspGeListArgs> args, bool head) {
|
2013-04-04 07:04:24 +00:00
|
|
|
// TODO Check the stack values in missing arg and ajust the stack depth
|
|
|
|
|
|
|
|
// Check alignment
|
|
|
|
// TODO Check the context and stack alignement too
|
2018-08-25 17:32:32 +00:00
|
|
|
if (((listpc | stall) & 3) != 0 || !Memory::IsValidAddress(listpc)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "sceGeListEnqueue: invalid address %08x", listpc);
|
2013-09-29 23:51:49 +00:00
|
|
|
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
2018-08-25 17:32:32 +00:00
|
|
|
}
|
2020-05-20 08:25:54 +00:00
|
|
|
|
2020-05-22 05:16:13 +00:00
|
|
|
// If args->size is below 16, it's the old struct without stack info.
|
|
|
|
if (args.IsValid() && args->size >= 16 && args->numStacks >= 256) {
|
|
|
|
return hleLogError(G3D, SCE_KERNEL_ERROR_INVALID_SIZE, "invalid stack depth %d", args->numStacks);
|
|
|
|
}
|
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
int id = -1;
|
2013-10-26 17:38:59 +00:00
|
|
|
u64 currentTicks = CoreTiming::GetTicks();
|
2021-02-19 06:25:24 +00:00
|
|
|
u32 stackAddr = args.IsValid() && args->size >= 16 ? (u32)args->stackAddr : 0;
|
2013-10-26 17:38:59 +00:00
|
|
|
// Check compatibility
|
2013-04-05 06:19:28 +00:00
|
|
|
if (sceKernelGetCompiledSdkVersion() > 0x01FFFFFF) {
|
|
|
|
//numStacks = 0;
|
|
|
|
//stack = NULL;
|
2013-10-26 17:38:59 +00:00
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
|
|
|
if (dls[i].state != PSP_GE_DL_STATE_NONE && dls[i].state != PSP_GE_DL_STATE_COMPLETED) {
|
2014-05-26 01:52:31 +00:00
|
|
|
// Logically, if the CPU has not interrupted yet, it hasn't seen the latest pc either.
|
|
|
|
// Exit enqueues right after an END, which fails without ignoring pendingInterrupt lists.
|
|
|
|
if (dls[i].pc == listpc && !dls[i].pendingInterrupt) {
|
2013-10-26 17:38:59 +00:00
|
|
|
ERROR_LOG(G3D, "sceGeListEnqueue: can't enqueue, list address %08X already used", listpc);
|
|
|
|
return 0x80000021;
|
2014-08-18 23:04:36 +00:00
|
|
|
} else if (stackAddr != 0 && dls[i].stackAddr == stackAddr && !dls[i].pendingInterrupt) {
|
2014-08-13 13:15:30 +00:00
|
|
|
ERROR_LOG(G3D, "sceGeListEnqueue: can't enqueue, stack address %08X already used", stackAddr);
|
|
|
|
return 0x80000021;
|
|
|
|
}
|
2013-04-05 06:19:28 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-21 20:18:20 +00:00
|
|
|
}
|
2013-10-27 13:09:46 +00:00
|
|
|
// TODO Check if list stack dls[i].stack already used then return 0x80000021 as above
|
2013-10-26 17:38:59 +00:00
|
|
|
|
2013-09-21 20:18:20 +00:00
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
|
|
|
int possibleID = (i + nextListID) % DisplayListMaxCount;
|
|
|
|
auto possibleList = dls[possibleID];
|
|
|
|
if (possibleList.pendingInterrupt) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (possibleList.state == PSP_GE_DL_STATE_NONE) {
|
|
|
|
id = possibleID;
|
2013-04-05 06:19:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-21 20:18:20 +00:00
|
|
|
if (possibleList.state == PSP_GE_DL_STATE_COMPLETED && possibleList.waitTicks < currentTicks) {
|
|
|
|
id = possibleID;
|
2013-04-05 06:19:28 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-21 20:18:20 +00:00
|
|
|
if (id < 0) {
|
2013-04-05 08:13:54 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "No DL ID available to enqueue");
|
2013-09-21 20:18:20 +00:00
|
|
|
for (auto it = dlQueue.begin(); it != dlQueue.end(); ++it) {
|
2013-04-05 06:19:28 +00:00
|
|
|
DisplayList &dl = dls[*it];
|
|
|
|
DEBUG_LOG(G3D, "DisplayList %d status %d pc %08x stall %08x", *it, dl.state, dl.pc, dl.stall);
|
|
|
|
}
|
|
|
|
return SCE_KERNEL_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2013-09-21 20:18:20 +00:00
|
|
|
nextListID = id + 1;
|
2013-04-05 06:19:28 +00:00
|
|
|
|
|
|
|
DisplayList &dl = dls[id];
|
|
|
|
dl.id = id;
|
2013-08-23 06:23:48 +00:00
|
|
|
dl.startpc = listpc & 0x0FFFFFFF;
|
|
|
|
dl.pc = listpc & 0x0FFFFFFF;
|
|
|
|
dl.stall = stall & 0x0FFFFFFF;
|
2013-04-02 06:54:19 +00:00
|
|
|
dl.subIntrBase = std::max(subIntrBase, -1);
|
2013-04-01 06:28:35 +00:00
|
|
|
dl.stackptr = 0;
|
2013-04-02 06:54:19 +00:00
|
|
|
dl.signal = PSP_GE_SIGNAL_NONE;
|
2013-04-04 07:35:38 +00:00
|
|
|
dl.interrupted = false;
|
2013-04-07 19:45:42 +00:00
|
|
|
dl.waitTicks = (u64)-1;
|
2013-08-07 06:59:28 +00:00
|
|
|
dl.interruptsEnabled = interruptsEnabled_;
|
2013-09-20 16:42:09 +00:00
|
|
|
dl.started = false;
|
2013-09-22 03:47:35 +00:00
|
|
|
dl.offsetAddr = 0;
|
2013-09-24 10:59:34 +00:00
|
|
|
dl.bboxResult = false;
|
2014-08-13 13:15:30 +00:00
|
|
|
dl.stackAddr = stackAddr;
|
2013-09-24 10:59:34 +00:00
|
|
|
|
2013-09-20 16:42:09 +00:00
|
|
|
if (args.IsValid() && args->context.IsValid())
|
|
|
|
dl.context = args->context;
|
|
|
|
else
|
2013-10-07 05:07:57 +00:00
|
|
|
dl.context = 0;
|
2013-04-05 06:19:28 +00:00
|
|
|
|
2013-04-04 07:04:24 +00:00
|
|
|
if (head) {
|
|
|
|
if (currentList) {
|
|
|
|
if (currentList->state != PSP_GE_DL_STATE_PAUSED)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
|
|
|
currentList->state = PSP_GE_DL_STATE_QUEUED;
|
2019-07-07 20:10:28 +00:00
|
|
|
// Make sure we clear the signal so we don't try to pause it again.
|
|
|
|
currentList->signal = PSP_GE_SIGNAL_NONE;
|
2013-04-04 07:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dl.state = PSP_GE_DL_STATE_PAUSED;
|
2013-04-05 06:19:28 +00:00
|
|
|
|
|
|
|
currentList = &dl;
|
|
|
|
dlQueue.push_front(id);
|
2013-04-04 07:04:24 +00:00
|
|
|
} else if (currentList) {
|
|
|
|
dl.state = PSP_GE_DL_STATE_QUEUED;
|
2013-04-05 06:19:28 +00:00
|
|
|
dlQueue.push_back(id);
|
2013-04-04 07:04:24 +00:00
|
|
|
} else {
|
|
|
|
dl.state = PSP_GE_DL_STATE_RUNNING;
|
2013-04-05 06:19:28 +00:00
|
|
|
currentList = &dl;
|
|
|
|
dlQueue.push_front(id);
|
2013-04-04 07:04:24 +00:00
|
|
|
|
2013-04-07 19:45:42 +00:00
|
|
|
drawCompleteTicks = (u64)-1;
|
2013-04-06 05:38:19 +00:00
|
|
|
|
2013-04-04 07:04:24 +00:00
|
|
|
// TODO save context when starting the list if param is set
|
|
|
|
ProcessDLQueue();
|
|
|
|
}
|
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
return id;
|
2012-12-28 20:58:00 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
u32 GPUCommon::DequeueList(int listid) {
|
2013-04-05 06:25:13 +00:00
|
|
|
if (listid < 0 || listid >= DisplayListMaxCount || dls[listid].state == PSP_GE_DL_STATE_NONE)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_ID;
|
|
|
|
|
2013-09-21 21:58:39 +00:00
|
|
|
auto &dl = dls[listid];
|
|
|
|
if (dl.started)
|
|
|
|
return SCE_KERNEL_ERROR_BUSY;
|
2013-04-05 06:25:13 +00:00
|
|
|
|
2013-09-21 21:58:39 +00:00
|
|
|
dl.state = PSP_GE_DL_STATE_NONE;
|
2013-04-05 06:25:13 +00:00
|
|
|
|
|
|
|
if (listid == dlQueue.front())
|
|
|
|
PopDLQueue();
|
|
|
|
else
|
|
|
|
dlQueue.remove(listid);
|
|
|
|
|
2013-09-21 21:58:39 +00:00
|
|
|
dl.waitTicks = 0;
|
2014-03-30 00:02:41 +00:00
|
|
|
__GeTriggerWait(GPU_SYNC_LIST, listid);
|
2013-04-05 06:25:13 +00:00
|
|
|
|
|
|
|
CheckDrawSync();
|
|
|
|
|
2013-04-01 06:23:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
u32 GPUCommon::UpdateStall(int listid, u32 newstall) {
|
2013-04-05 06:19:28 +00:00
|
|
|
if (listid < 0 || listid >= DisplayListMaxCount || dls[listid].state == PSP_GE_DL_STATE_NONE)
|
2013-04-05 06:25:13 +00:00
|
|
|
return SCE_KERNEL_ERROR_INVALID_ID;
|
2013-09-21 21:54:07 +00:00
|
|
|
auto &dl = dls[listid];
|
|
|
|
if (dl.state == PSP_GE_DL_STATE_COMPLETED)
|
|
|
|
return SCE_KERNEL_ERROR_ALREADY;
|
2013-04-05 06:19:28 +00:00
|
|
|
|
2013-09-21 21:54:07 +00:00
|
|
|
dl.stall = newstall & 0x0FFFFFFF;
|
2012-12-28 20:58:00 +00:00
|
|
|
|
|
|
|
ProcessDLQueue();
|
2013-04-01 06:23:03 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
u32 GPUCommon::Continue() {
|
2013-04-04 07:35:38 +00:00
|
|
|
if (!currentList)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (currentList->state == PSP_GE_DL_STATE_PAUSED)
|
|
|
|
{
|
2019-07-07 20:10:28 +00:00
|
|
|
if (!isbreak) {
|
2014-04-12 06:32:34 +00:00
|
|
|
// TODO: Supposedly this returns SCE_KERNEL_ERROR_BUSY in some case, previously it had
|
|
|
|
// currentList->signal == PSP_GE_SIGNAL_HANDLER_PAUSE, but it doesn't reproduce.
|
2013-04-04 07:35:38 +00:00
|
|
|
|
|
|
|
currentList->state = PSP_GE_DL_STATE_RUNNING;
|
|
|
|
currentList->signal = PSP_GE_SIGNAL_NONE;
|
|
|
|
|
|
|
|
// TODO Restore context of DL is necessary
|
|
|
|
// TODO Restore BASE
|
2013-04-06 05:38:19 +00:00
|
|
|
|
|
|
|
// We have a list now, so it's not complete.
|
2013-04-07 19:45:42 +00:00
|
|
|
drawCompleteTicks = (u64)-1;
|
2019-07-07 20:10:28 +00:00
|
|
|
} else {
|
2013-04-04 07:35:38 +00:00
|
|
|
currentList->state = PSP_GE_DL_STATE_QUEUED;
|
2019-07-07 20:10:28 +00:00
|
|
|
currentList->signal = PSP_GE_SIGNAL_NONE;
|
|
|
|
}
|
2013-04-04 07:35:38 +00:00
|
|
|
}
|
|
|
|
else if (currentList->state == PSP_GE_DL_STATE_RUNNING)
|
|
|
|
{
|
|
|
|
if (sceKernelGetCompiledSdkVersion() >= 0x02000000)
|
|
|
|
return 0x80000020;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sceKernelGetCompiledSdkVersion() >= 0x02000000)
|
|
|
|
return 0x80000004;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessDLQueue();
|
2013-04-01 06:23:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
u32 GPUCommon::Break(int mode) {
|
2013-04-01 06:42:56 +00:00
|
|
|
if (mode < 0 || mode > 1)
|
|
|
|
return SCE_KERNEL_ERROR_INVALID_MODE;
|
|
|
|
|
2013-04-04 07:35:38 +00:00
|
|
|
if (!currentList)
|
2013-09-22 02:07:02 +00:00
|
|
|
return SCE_KERNEL_ERROR_ALREADY;
|
2013-04-04 07:35:38 +00:00
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
if (mode == 1)
|
2013-04-04 07:35:38 +00:00
|
|
|
{
|
2013-04-05 06:19:28 +00:00
|
|
|
// Clear the queue
|
2013-04-04 07:35:38 +00:00
|
|
|
dlQueue.clear();
|
2013-04-05 06:19:28 +00:00
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i)
|
|
|
|
{
|
|
|
|
dls[i].state = PSP_GE_DL_STATE_NONE;
|
|
|
|
dls[i].signal = PSP_GE_SIGNAL_NONE;
|
|
|
|
}
|
|
|
|
|
2013-09-21 20:18:20 +00:00
|
|
|
nextListID = 0;
|
2013-04-05 06:19:28 +00:00
|
|
|
currentList = NULL;
|
2013-04-04 07:35:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentList->state == PSP_GE_DL_STATE_NONE || currentList->state == PSP_GE_DL_STATE_COMPLETED)
|
|
|
|
{
|
|
|
|
if (sceKernelGetCompiledSdkVersion() >= 0x02000000)
|
|
|
|
return 0x80000004;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentList->state == PSP_GE_DL_STATE_PAUSED)
|
|
|
|
{
|
|
|
|
if (sceKernelGetCompiledSdkVersion() > 0x02000010)
|
|
|
|
{
|
|
|
|
if (currentList->signal == PSP_GE_SIGNAL_HANDLER_PAUSE)
|
|
|
|
{
|
2013-04-05 08:13:54 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "sceGeBreak: can't break signal-pausing list");
|
2013-04-04 07:35:38 +00:00
|
|
|
}
|
|
|
|
else
|
2013-09-22 02:07:02 +00:00
|
|
|
return SCE_KERNEL_ERROR_ALREADY;
|
2013-04-04 07:35:38 +00:00
|
|
|
}
|
2013-09-22 02:07:02 +00:00
|
|
|
return SCE_KERNEL_ERROR_BUSY;
|
2013-04-04 07:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentList->state == PSP_GE_DL_STATE_QUEUED)
|
|
|
|
{
|
|
|
|
currentList->state = PSP_GE_DL_STATE_PAUSED;
|
|
|
|
return currentList->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO Save BASE
|
|
|
|
// TODO Adjust pc to be just before SIGNAL/END
|
|
|
|
|
|
|
|
// TODO: Is this right?
|
|
|
|
if (currentList->signal == PSP_GE_SIGNAL_SYNC)
|
|
|
|
currentList->pc += 8;
|
|
|
|
|
|
|
|
currentList->interrupted = true;
|
|
|
|
currentList->state = PSP_GE_DL_STATE_PAUSED;
|
|
|
|
currentList->signal = PSP_GE_SIGNAL_HANDLER_SUSPEND;
|
|
|
|
isbreak = true;
|
|
|
|
|
|
|
|
return currentList->id;
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2014-06-14 15:42:18 +00:00
|
|
|
void GPUCommon::NotifySteppingEnter() {
|
2017-03-24 01:57:18 +00:00
|
|
|
if (coreCollectDebugStats) {
|
2014-06-14 15:42:18 +00:00
|
|
|
timeSteppingStarted_ = time_now_d();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void GPUCommon::NotifySteppingExit() {
|
2017-03-24 01:57:18 +00:00
|
|
|
if (coreCollectDebugStats) {
|
2014-06-14 15:42:18 +00:00
|
|
|
if (timeSteppingStarted_ <= 0.0) {
|
|
|
|
ERROR_LOG(G3D, "Mismatched stepping enter/exit.");
|
|
|
|
}
|
2021-01-31 23:06:11 +00:00
|
|
|
double total = time_now_d() - timeSteppingStarted_;
|
|
|
|
_dbg_assert_msg_(total >= 0.0, "Time spent stepping became negative");
|
|
|
|
timeSpentStepping_ += total;
|
2014-06-14 15:42:18 +00:00
|
|
|
timeSteppingStarted_ = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 06:46:10 +00:00
|
|
|
bool GPUCommon::InterpretList(DisplayList &list) {
|
2013-04-21 22:16:45 +00:00
|
|
|
// Initialized to avoid a race condition with bShowDebugStats changing.
|
|
|
|
double start = 0.0;
|
2017-03-24 01:57:18 +00:00
|
|
|
if (coreCollectDebugStats) {
|
2013-04-21 22:16:45 +00:00
|
|
|
start = time_now_d();
|
|
|
|
}
|
|
|
|
|
2014-04-12 06:32:34 +00:00
|
|
|
if (list.state == PSP_GE_DL_STATE_PAUSED)
|
|
|
|
return false;
|
2013-08-09 07:32:40 +00:00
|
|
|
currentList = &list;
|
2013-04-06 16:59:24 +00:00
|
|
|
|
2013-10-07 05:07:57 +00:00
|
|
|
if (!list.started && list.context.IsValid()) {
|
2013-09-20 16:42:09 +00:00
|
|
|
gstate.Save(list.context);
|
|
|
|
}
|
|
|
|
list.started = true;
|
|
|
|
|
2013-09-22 03:47:35 +00:00
|
|
|
gstate_c.offsetAddr = list.offsetAddr;
|
2013-01-29 16:07:36 +00:00
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
if (!Memory::IsValidAddress(list.pc)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "DL PC = %08x WTF!!!!", list.pc);
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-02 22:47:35 +00:00
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
cycleLastPC = list.pc;
|
2013-10-12 08:20:27 +00:00
|
|
|
cyclesExecuted += 60;
|
2013-08-23 06:23:48 +00:00
|
|
|
downcount = list.stall == 0 ? 0x0FFFFFFF : (list.stall - list.pc) / 4;
|
2013-08-09 07:32:40 +00:00
|
|
|
list.state = PSP_GE_DL_STATE_RUNNING;
|
|
|
|
list.interrupted = false;
|
2013-04-03 15:10:35 +00:00
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
gpuState = list.pc == list.stall ? GPUSTATE_STALL : GPUSTATE_RUNNING;
|
2013-04-28 21:56:38 +00:00
|
|
|
|
2022-02-06 08:16:35 +00:00
|
|
|
// To enable breakpoints, we don't do fast matrix loads while debugger active.
|
|
|
|
debugRecording_ = GPUDebug::IsActive() || GPURecord::IsActive();
|
|
|
|
const bool useFastRunLoop = !dumpThisFrame_ && !debugRecording_;
|
2013-08-09 06:46:10 +00:00
|
|
|
while (gpuState == GPUSTATE_RUNNING) {
|
2013-08-09 08:03:54 +00:00
|
|
|
{
|
|
|
|
if (list.pc == list.stall) {
|
|
|
|
gpuState = GPUSTATE_STALL;
|
|
|
|
downcount = 0;
|
|
|
|
}
|
2013-04-04 08:07:30 +00:00
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
|
2013-08-09 06:46:10 +00:00
|
|
|
if (useFastRunLoop) {
|
2013-04-28 21:23:30 +00:00
|
|
|
FastRunLoop(list);
|
2013-08-09 06:46:10 +00:00
|
|
|
} else {
|
2013-04-28 21:23:30 +00:00
|
|
|
SlowRunLoop(list);
|
2013-08-09 06:46:10 +00:00
|
|
|
}
|
2013-04-28 21:23:30 +00:00
|
|
|
|
2013-08-09 08:03:54 +00:00
|
|
|
{
|
2013-08-23 06:23:48 +00:00
|
|
|
downcount = list.stall == 0 ? 0x0FFFFFFF : (list.stall - list.pc) / 4;
|
2013-08-09 06:46:10 +00:00
|
|
|
|
2013-08-09 08:03:54 +00:00
|
|
|
if (gpuState == GPUSTATE_STALL && list.stall != list.pc) {
|
|
|
|
// Unstalled.
|
|
|
|
gpuState = GPUSTATE_RUNNING;
|
|
|
|
}
|
2013-08-09 06:46:10 +00:00
|
|
|
}
|
2013-04-28 21:23:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 01:11:00 +00:00
|
|
|
FinishDeferred();
|
2022-02-20 21:51:40 +00:00
|
|
|
if (debugRecording_)
|
|
|
|
GPURecord::NotifyCPU();
|
2015-03-15 01:11:00 +00:00
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
// We haven't run the op at list.pc, so it shouldn't count.
|
2013-08-09 06:46:10 +00:00
|
|
|
if (cycleLastPC != list.pc) {
|
2013-04-28 21:23:30 +00:00
|
|
|
UpdatePC(list.pc - 4, list.pc);
|
2013-08-09 06:46:10 +00:00
|
|
|
}
|
2013-04-28 21:23:30 +00:00
|
|
|
|
2013-09-22 03:47:35 +00:00
|
|
|
list.offsetAddr = gstate_c.offsetAddr;
|
|
|
|
|
2017-03-24 01:57:18 +00:00
|
|
|
if (coreCollectDebugStats) {
|
2014-06-14 15:42:18 +00:00
|
|
|
double total = time_now_d() - start - timeSpentStepping_;
|
2021-01-31 23:06:11 +00:00
|
|
|
_dbg_assert_msg_(total >= 0.0, "Time spent DL processing became negative");
|
2014-06-14 15:42:18 +00:00
|
|
|
hleSetSteppingTime(timeSpentStepping_);
|
2022-01-30 18:46:50 +00:00
|
|
|
DisplayNotifySleep(timeSpentStepping_);
|
2014-06-14 15:42:18 +00:00
|
|
|
timeSpentStepping_ = 0.0;
|
|
|
|
gpuStats.msProcessingDisplayLists += total;
|
2013-04-28 21:23:30 +00:00
|
|
|
}
|
|
|
|
return gpuState == GPUSTATE_DONE || gpuState == GPUSTATE_ERROR;
|
|
|
|
}
|
|
|
|
|
2023-12-11 22:05:37 +00:00
|
|
|
void GPUCommon::PSPFrame() {
|
2017-12-01 19:01:13 +00:00
|
|
|
immCount_ = 0;
|
2017-06-03 02:39:11 +00:00
|
|
|
if (dumpNextFrame_) {
|
|
|
|
NOTICE_LOG(G3D, "DUMPING THIS FRAME");
|
|
|
|
dumpThisFrame_ = true;
|
|
|
|
dumpNextFrame_ = false;
|
|
|
|
} else if (dumpThisFrame_) {
|
|
|
|
dumpThisFrame_ = false;
|
|
|
|
}
|
2022-08-24 02:48:34 +00:00
|
|
|
GPUDebug::NotifyBeginFrame();
|
2022-08-24 02:20:14 +00:00
|
|
|
GPURecord::NotifyBeginFrame();
|
2017-06-03 02:39:11 +00:00
|
|
|
}
|
|
|
|
|
2023-12-11 12:06:15 +00:00
|
|
|
bool GPUCommon::PresentedThisFrame() const {
|
|
|
|
return framebufferManager_ ? framebufferManager_->PresentedThisFrame() : true;
|
|
|
|
}
|
|
|
|
|
2023-02-25 16:37:57 +00:00
|
|
|
void GPUCommon::SlowRunLoop(DisplayList &list) {
|
2013-04-28 21:23:30 +00:00
|
|
|
const bool dumpThisFrame = dumpThisFrame_;
|
2023-02-25 16:37:57 +00:00
|
|
|
while (downcount > 0) {
|
2022-02-07 05:25:33 +00:00
|
|
|
bool process = GPUDebug::NotifyCommand(list.pc);
|
|
|
|
if (process) {
|
|
|
|
GPURecord::NotifyCommand(list.pc);
|
|
|
|
u32 op = Memory::ReadUnchecked_U32(list.pc);
|
|
|
|
u32 cmd = op >> 24;
|
|
|
|
|
|
|
|
u32 diff = op ^ gstate.cmdmem[cmd];
|
|
|
|
PreExecuteOp(op, diff);
|
|
|
|
if (dumpThisFrame) {
|
|
|
|
char temp[256];
|
|
|
|
u32 prev;
|
|
|
|
if (Memory::IsValidAddress(list.pc - 4)) {
|
|
|
|
prev = Memory::ReadUnchecked_U32(list.pc - 4);
|
|
|
|
} else {
|
|
|
|
prev = 0;
|
|
|
|
}
|
|
|
|
GeDisassembleOp(list.pc, op, prev, temp, 256);
|
|
|
|
NOTICE_LOG(G3D, "%08x: %s", op, temp);
|
2013-10-07 20:57:44 +00:00
|
|
|
}
|
2022-02-07 05:25:33 +00:00
|
|
|
gstate.cmdmem[cmd] = op;
|
2013-04-03 15:10:35 +00:00
|
|
|
|
2022-02-07 05:25:33 +00:00
|
|
|
ExecuteOp(op, diff);
|
|
|
|
}
|
2013-04-03 15:10:35 +00:00
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
list.pc += 4;
|
|
|
|
--downcount;
|
2013-04-21 22:16:45 +00:00
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2013-04-28 20:34:29 +00:00
|
|
|
// The newPC parameter is used for jumps, we don't count cycles between.
|
2014-03-04 10:38:25 +00:00
|
|
|
void GPUCommon::UpdatePC(u32 currentPC, u32 newPC) {
|
2013-04-07 23:55:48 +00:00
|
|
|
// Rough estimate, 2 CPU ticks (it's double the clock rate) per GPU instruction.
|
2014-04-05 08:41:54 +00:00
|
|
|
u32 executed = (currentPC - cycleLastPC) / 4;
|
2013-08-23 09:42:15 +00:00
|
|
|
cyclesExecuted += 2 * executed;
|
2014-04-05 21:08:44 +00:00
|
|
|
cycleLastPC = newPC;
|
2013-04-28 21:23:30 +00:00
|
|
|
|
2014-03-06 07:24:18 +00:00
|
|
|
// Exit the runloop and recalculate things. This happens a lot in some games.
|
|
|
|
if (currentList)
|
2014-04-05 21:08:44 +00:00
|
|
|
downcount = currentList->stall == 0 ? 0x0FFFFFFF : (currentList->stall - newPC) / 4;
|
2014-03-06 07:24:18 +00:00
|
|
|
else
|
|
|
|
downcount = 0;
|
2013-04-28 20:34:29 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 06:59:32 +00:00
|
|
|
void GPUCommon::ReapplyGfxState() {
|
2013-08-04 22:15:50 +00:00
|
|
|
// The commands are embedded in the command memory so we can just reexecute the words. Convenient.
|
2013-08-23 06:23:48 +00:00
|
|
|
// To be safe we pass 0xFFFFFFFF as the diff.
|
2013-08-04 22:15:50 +00:00
|
|
|
|
2020-05-24 14:30:37 +00:00
|
|
|
// TODO: Consider whether any of this should really be done. We might be able to get all the way
|
|
|
|
// by simplying dirtying the appropriate gstate_c dirty flags.
|
|
|
|
|
2013-08-08 06:59:32 +00:00
|
|
|
for (int i = GE_CMD_VERTEXTYPE; i < GE_CMD_BONEMATRIXNUMBER; i++) {
|
2014-04-16 14:53:07 +00:00
|
|
|
if (i != GE_CMD_ORIGIN && i != GE_CMD_OFFSETADDR) {
|
2013-08-04 22:15:50 +00:00
|
|
|
ExecuteOp(gstate.cmdmem[i], 0xFFFFFFFF);
|
2013-08-08 06:59:32 +00:00
|
|
|
}
|
2013-08-04 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Can't write to bonematrixnumber here
|
|
|
|
|
2013-09-20 07:43:45 +00:00
|
|
|
for (int i = GE_CMD_MORPHWEIGHT0; i <= GE_CMD_PATCHFACING; i++) {
|
2013-08-04 22:15:50 +00:00
|
|
|
ExecuteOp(gstate.cmdmem[i], 0xFFFFFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
// There are a few here in the middle that we shouldn't execute...
|
|
|
|
|
2020-05-24 14:30:37 +00:00
|
|
|
// 0x42 to 0xEA
|
2015-11-04 21:03:29 +00:00
|
|
|
for (int i = GE_CMD_VIEWPORTXSCALE; i < GE_CMD_TRANSFERSTART; i++) {
|
2020-05-24 14:30:37 +00:00
|
|
|
switch (i) {
|
|
|
|
case GE_CMD_LOADCLUT:
|
|
|
|
case GE_CMD_TEXSYNC:
|
|
|
|
case GE_CMD_TEXFLUSH:
|
|
|
|
break;
|
|
|
|
default:
|
2020-05-24 07:12:41 +00:00
|
|
|
ExecuteOp(gstate.cmdmem[i], 0xFFFFFFFF);
|
2020-05-24 14:30:37 +00:00
|
|
|
break;
|
2020-05-24 07:12:41 +00:00
|
|
|
}
|
2013-08-04 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 07:43:45 +00:00
|
|
|
// Let's just skip the transfer size stuff, it's just values.
|
2013-08-04 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
2022-10-02 06:18:42 +00:00
|
|
|
uint32_t GPUCommon::SetAddrTranslation(uint32_t value) {
|
|
|
|
std::swap(edramTranslation_, value);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GPUCommon::GetAddrTranslation() {
|
|
|
|
return edramTranslation_;
|
|
|
|
}
|
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
inline void GPUCommon::UpdateState(GPURunState state) {
|
2013-04-28 20:34:29 +00:00
|
|
|
gpuState = state;
|
2013-04-28 21:23:30 +00:00
|
|
|
if (state != GPUSTATE_RUNNING)
|
|
|
|
downcount = 0;
|
2013-04-03 15:10:35 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 23:31:11 +00:00
|
|
|
int GPUCommon::GetNextListIndex() {
|
|
|
|
auto iter = dlQueue.begin();
|
|
|
|
if (iter != dlQueue.end()) {
|
|
|
|
return *iter;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void GPUCommon::ProcessDLQueue() {
|
2013-04-03 15:10:35 +00:00
|
|
|
startingTicks = CoreTiming::GetTicks();
|
|
|
|
cyclesExecuted = 0;
|
|
|
|
|
2013-08-25 01:13:34 +00:00
|
|
|
// Seems to be correct behaviour to process the list anyway?
|
2013-08-04 23:31:11 +00:00
|
|
|
if (startingTicks < busyTicks) {
|
2013-09-07 20:31:14 +00:00
|
|
|
DEBUG_LOG(G3D, "Can't execute a list yet, still busy for %lld ticks", busyTicks - startingTicks);
|
2013-08-25 01:13:34 +00:00
|
|
|
//return;
|
2013-04-09 07:56:04 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 23:31:11 +00:00
|
|
|
for (int listIndex = GetNextListIndex(); listIndex != -1; listIndex = GetNextListIndex()) {
|
|
|
|
DisplayList &l = dls[listIndex];
|
2015-05-25 22:39:27 +00:00
|
|
|
DEBUG_LOG(G3D, "Starting DL execution at %08x - stall = %08x", l.pc, l.stall);
|
2013-08-04 23:31:11 +00:00
|
|
|
if (!InterpretList(l)) {
|
2013-08-08 06:59:32 +00:00
|
|
|
return;
|
2013-08-04 23:31:11 +00:00
|
|
|
} else {
|
2014-05-04 01:40:27 +00:00
|
|
|
// Some other list could've taken the spot while we dilly-dallied around.
|
|
|
|
if (l.state != PSP_GE_DL_STATE_QUEUED) {
|
|
|
|
// At the end, we can remove it from the queue and continue.
|
|
|
|
dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end());
|
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-04 23:31:11 +00:00
|
|
|
|
2017-11-05 18:44:07 +00:00
|
|
|
currentList = nullptr;
|
2013-04-06 05:38:19 +00:00
|
|
|
|
2023-01-01 20:18:53 +00:00
|
|
|
if (coreCollectDebugStats) {
|
|
|
|
gpuStats.otherGPUCycles += cyclesExecuted;
|
|
|
|
}
|
|
|
|
|
2013-04-07 19:45:42 +00:00
|
|
|
drawCompleteTicks = startingTicks + cyclesExecuted;
|
2013-04-09 07:56:04 +00:00
|
|
|
busyTicks = std::max(busyTicks, drawCompleteTicks);
|
2014-03-30 00:02:41 +00:00
|
|
|
__GeTriggerSync(GPU_SYNC_DRAW, 1, drawCompleteTicks);
|
2013-08-11 20:41:42 +00:00
|
|
|
// Since the event is in CoreTiming, we're in sync. Just set 0 now.
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_OffsetAddr(u32 op, u32 diff) {
|
|
|
|
gstate_c.offsetAddr = op << 8;
|
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2017-01-28 10:53:28 +00:00
|
|
|
void GPUCommon::Execute_Vaddr(u32 op, u32 diff) {
|
|
|
|
gstate_c.vertexAddr = gstate_c.getRelativeAddress(op & 0x00FFFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::Execute_Iaddr(u32 op, u32 diff) {
|
|
|
|
gstate_c.indexAddr = gstate_c.getRelativeAddress(op & 0x00FFFFFF);
|
|
|
|
}
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_Origin(u32 op, u32 diff) {
|
2022-09-30 04:36:53 +00:00
|
|
|
if (currentList)
|
|
|
|
gstate_c.offsetAddr = currentList->pc;
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_Jump(u32 op, u32 diff) {
|
2014-05-05 00:58:44 +00:00
|
|
|
const u32 target = gstate_c.getRelativeAddress(op & 0x00FFFFFC);
|
2017-01-28 10:39:34 +00:00
|
|
|
if (!Memory::IsValidAddress(target)) {
|
2020-09-22 19:57:51 +00:00
|
|
|
ERROR_LOG(G3D, "JUMP to illegal address %08x - ignoring! data=%06x", target, op & 0x00FFFFFF);
|
2018-08-25 17:32:32 +00:00
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2017-01-28 10:39:34 +00:00
|
|
|
return;
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
2017-01-28 10:39:34 +00:00
|
|
|
UpdatePC(currentList->pc, target - 4);
|
|
|
|
currentList->pc = target - 4; // pc will be increased after we return, counteract that
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_BJump(u32 op, u32 diff) {
|
|
|
|
if (!currentList->bboxResult) {
|
|
|
|
// bounding box jump.
|
2014-05-05 00:58:44 +00:00
|
|
|
const u32 target = gstate_c.getRelativeAddress(op & 0x00FFFFFC);
|
2023-07-30 12:42:22 +00:00
|
|
|
gpuStats.numBBOXJumps++;
|
2014-04-16 15:12:21 +00:00
|
|
|
if (Memory::IsValidAddress(target)) {
|
|
|
|
UpdatePC(currentList->pc, target - 4);
|
|
|
|
currentList->pc = target - 4; // pc will be increased after we return, counteract that
|
|
|
|
} else {
|
2020-09-22 19:57:51 +00:00
|
|
|
ERROR_LOG(G3D, "BJUMP to illegal address %08x - ignoring! data=%06x", target, op & 0x00FFFFFF);
|
2018-08-25 17:32:32 +00:00
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2013-08-08 06:27:29 +00:00
|
|
|
}
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_Call(u32 op, u32 diff) {
|
2017-08-18 11:39:42 +00:00
|
|
|
PROFILE_THIS_SCOPE("gpu_call");
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-05-05 00:58:44 +00:00
|
|
|
const u32 target = gstate_c.getRelativeAddress(op & 0x00FFFFFC);
|
2014-09-23 15:31:29 +00:00
|
|
|
if (!Memory::IsValidAddress(target)) {
|
2020-09-22 19:57:51 +00:00
|
|
|
ERROR_LOG(G3D, "CALL to illegal address %08x - ignoring! data=%06x", target, op & 0x00FFFFFF);
|
2018-08-25 17:32:32 +00:00
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2014-09-23 15:31:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-25 17:38:56 +00:00
|
|
|
DoExecuteCall(target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::DoExecuteCall(u32 target) {
|
2014-04-16 15:12:21 +00:00
|
|
|
// Bone matrix optimization - many games will CALL a bone matrix (!).
|
2017-06-04 19:50:12 +00:00
|
|
|
// We don't optimize during recording - so the matrix data gets recorded.
|
2023-01-01 19:42:29 +00:00
|
|
|
if (!debugRecording_ && Memory::IsValidRange(target, 13 * 4) && (Memory::ReadUnchecked_U32(target) >> 24) == GE_CMD_BONEMATRIXDATA) {
|
2014-04-16 15:12:21 +00:00
|
|
|
// Check for the end
|
|
|
|
if ((Memory::ReadUnchecked_U32(target + 11 * 4) >> 24) == GE_CMD_BONEMATRIXDATA &&
|
2023-01-01 19:42:29 +00:00
|
|
|
(Memory::ReadUnchecked_U32(target + 12 * 4) >> 24) == GE_CMD_RET &&
|
|
|
|
(gstate.boneMatrixNumber & 0x00FFFFFF) <= 96 - 12) {
|
2017-06-04 19:50:12 +00:00
|
|
|
// Yep, pretty sure this is a bone matrix call. Double check stall first.
|
|
|
|
if (target > currentList->stall || target + 12 * 4 < currentList->stall) {
|
|
|
|
FastLoadBoneMatrix(target);
|
|
|
|
return;
|
|
|
|
}
|
2013-09-24 10:59:34 +00:00
|
|
|
}
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
2013-11-14 13:02:31 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
if (currentList->stackptr == ARRAY_SIZE(currentList->stack)) {
|
2020-09-22 19:57:51 +00:00
|
|
|
ERROR_LOG(G3D, "CALL: Stack full!");
|
2023-05-05 21:46:19 +00:00
|
|
|
// TODO: UpdateState(GPUSTATE_ERROR) ?
|
2014-04-16 15:12:21 +00:00
|
|
|
} else {
|
|
|
|
auto &stackEntry = currentList->stack[currentList->stackptr++];
|
2023-12-04 17:56:06 +00:00
|
|
|
stackEntry.pc = currentList->pc + 4;
|
2014-04-16 15:12:21 +00:00
|
|
|
stackEntry.offsetAddr = gstate_c.offsetAddr;
|
|
|
|
// The base address is NOT saved/restored for a regular call.
|
|
|
|
UpdatePC(currentList->pc, target - 4);
|
|
|
|
currentList->pc = target - 4; // pc will be increased after we return, counteract that
|
|
|
|
}
|
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_Ret(u32 op, u32 diff) {
|
|
|
|
if (currentList->stackptr == 0) {
|
2020-09-22 19:57:51 +00:00
|
|
|
DEBUG_LOG(G3D, "RET: Stack empty!");
|
2014-04-16 15:12:21 +00:00
|
|
|
} else {
|
|
|
|
auto &stackEntry = currentList->stack[--currentList->stackptr];
|
|
|
|
gstate_c.offsetAddr = stackEntry.offsetAddr;
|
2014-05-05 00:58:44 +00:00
|
|
|
// We always clear the top (uncached/etc.) bits
|
|
|
|
const u32 target = stackEntry.pc & 0x0FFFFFFF;
|
2014-04-16 15:12:21 +00:00
|
|
|
UpdatePC(currentList->pc, target - 4);
|
|
|
|
currentList->pc = target - 4;
|
2017-01-28 10:39:34 +00:00
|
|
|
#ifdef _DEBUG
|
2014-04-16 15:12:21 +00:00
|
|
|
if (!Memory::IsValidAddress(currentList->pc)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Invalid DL PC %08x on return", currentList->pc);
|
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2013-04-01 06:02:46 +00:00
|
|
|
}
|
2017-01-28 10:39:34 +00:00
|
|
|
#endif
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
void GPUCommon::Execute_End(u32 op, u32 diff) {
|
2022-02-01 03:32:46 +00:00
|
|
|
if (flushOnParams_)
|
|
|
|
Flush();
|
2022-01-31 22:57:56 +00:00
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
const u32 prev = Memory::ReadUnchecked_U32(currentList->pc - 4);
|
2017-02-27 20:57:46 +00:00
|
|
|
UpdatePC(currentList->pc, currentList->pc);
|
2014-04-29 07:08:43 +00:00
|
|
|
// Count in a few extra cycles on END.
|
|
|
|
cyclesExecuted += 60;
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
switch (prev >> 24) {
|
2013-04-01 06:02:46 +00:00
|
|
|
case GE_CMD_SIGNAL:
|
2014-04-16 15:12:21 +00:00
|
|
|
{
|
|
|
|
// TODO: see http://code.google.com/p/jpcsp/source/detail?r=2935#
|
|
|
|
SignalBehavior behaviour = static_cast<SignalBehavior>((prev >> 16) & 0xFF);
|
2014-04-22 15:07:10 +00:00
|
|
|
const int signal = prev & 0xFFFF;
|
|
|
|
const int enddata = op & 0xFFFF;
|
2014-04-16 15:12:21 +00:00
|
|
|
bool trigger = true;
|
|
|
|
currentList->subIntrToken = signal;
|
|
|
|
|
|
|
|
switch (behaviour) {
|
|
|
|
case PSP_GE_SIGNAL_HANDLER_SUSPEND:
|
|
|
|
// Suspend the list, and call the signal handler. When it's done, resume.
|
|
|
|
// Before sdkver 0x02000010, listsync should return paused.
|
|
|
|
if (sceKernelGetCompiledSdkVersion() <= 0x02000010)
|
|
|
|
currentList->state = PSP_GE_DL_STATE_PAUSED;
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
DEBUG_LOG(G3D, "Signal with wait. signal/end: %04x %04x", signal, enddata);
|
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_HANDLER_CONTINUE:
|
|
|
|
// Resume the list right away, then call the handler.
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
DEBUG_LOG(G3D, "Signal without wait. signal/end: %04x %04x", signal, enddata);
|
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_HANDLER_PAUSE:
|
|
|
|
// Pause the list instead of ending at the next FINISH.
|
|
|
|
// Call the handler with the PAUSE signal value at that FINISH.
|
|
|
|
// Technically, this ought to trigger an interrupt, but it won't do anything.
|
|
|
|
// But right now, signal is always reset by interrupts, so that causes pause to not work.
|
|
|
|
trigger = false;
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
DEBUG_LOG(G3D, "Signal with Pause. signal/end: %04x %04x", signal, enddata);
|
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_SYNC:
|
|
|
|
// Acts as a memory barrier, never calls any user code.
|
|
|
|
// Technically, this ought to trigger an interrupt, but it won't do anything.
|
|
|
|
// Triggering here can cause incorrect rescheduling, which breaks 3rd Birthday.
|
|
|
|
// However, this is likely a bug in how GE signal interrupts are handled.
|
|
|
|
trigger = false;
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
DEBUG_LOG(G3D, "Signal with Sync. signal/end: %04x %04x", signal, enddata);
|
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_JUMP:
|
2022-01-24 07:03:30 +00:00
|
|
|
case PSP_GE_SIGNAL_RJUMP:
|
|
|
|
case PSP_GE_SIGNAL_OJUMP:
|
2014-04-16 15:12:21 +00:00
|
|
|
{
|
2014-04-09 05:20:33 +00:00
|
|
|
trigger = false;
|
2013-04-06 17:05:09 +00:00
|
|
|
currentList->signal = behaviour;
|
2014-04-16 15:12:21 +00:00
|
|
|
// pc will be increased after we return, counteract that.
|
2017-08-20 20:30:39 +00:00
|
|
|
u32 target = (((signal << 16) | enddata) & 0xFFFFFFFC) - 4;
|
2022-01-24 07:03:30 +00:00
|
|
|
const char *targetType = "absolute";
|
|
|
|
if (behaviour == PSP_GE_SIGNAL_RJUMP) {
|
|
|
|
target += currentList->pc - 4;
|
|
|
|
targetType = "relative";
|
|
|
|
} else if (behaviour == PSP_GE_SIGNAL_OJUMP) {
|
|
|
|
target = gstate_c.getRelativeAddress(target);
|
|
|
|
targetType = "origin";
|
|
|
|
}
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
if (!Memory::IsValidAddress(target)) {
|
2022-01-24 07:03:30 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Signal with Jump (%s): bad address. signal/end: %04x %04x", targetType, signal, enddata);
|
2018-08-25 17:32:32 +00:00
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2014-04-16 15:12:21 +00:00
|
|
|
} else {
|
|
|
|
UpdatePC(currentList->pc, target);
|
|
|
|
currentList->pc = target;
|
2022-01-24 07:03:30 +00:00
|
|
|
DEBUG_LOG(G3D, "Signal with Jump (%s). signal/end: %04x %04x", targetType, signal, enddata);
|
2013-04-06 17:30:12 +00:00
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
}
|
2014-04-16 15:12:21 +00:00
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_CALL:
|
2022-01-24 07:03:30 +00:00
|
|
|
case PSP_GE_SIGNAL_RCALL:
|
|
|
|
case PSP_GE_SIGNAL_OCALL:
|
2014-04-16 15:12:21 +00:00
|
|
|
{
|
|
|
|
trigger = false;
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
// pc will be increased after we return, counteract that.
|
2017-08-20 20:30:39 +00:00
|
|
|
u32 target = (((signal << 16) | enddata) & 0xFFFFFFFC) - 4;
|
2022-01-24 07:03:30 +00:00
|
|
|
const char *targetType = "absolute";
|
|
|
|
if (behaviour == PSP_GE_SIGNAL_RCALL) {
|
|
|
|
target += currentList->pc - 4;
|
|
|
|
targetType = "relative";
|
|
|
|
} else if (behaviour == PSP_GE_SIGNAL_OCALL) {
|
|
|
|
target = gstate_c.getRelativeAddress(target);
|
|
|
|
targetType = "origin";
|
|
|
|
}
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
if (currentList->stackptr == ARRAY_SIZE(currentList->stack)) {
|
2022-01-24 07:03:30 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Signal with Call (%s): stack full. signal/end: %04x %04x", targetType, signal, enddata);
|
2014-04-16 15:12:21 +00:00
|
|
|
} else if (!Memory::IsValidAddress(target)) {
|
2022-01-24 07:03:30 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Signal with Call (%s): bad address. signal/end: %04x %04x", targetType, signal, enddata);
|
2018-08-25 17:32:32 +00:00
|
|
|
UpdateState(GPUSTATE_ERROR);
|
2014-04-16 15:12:21 +00:00
|
|
|
} else {
|
|
|
|
// TODO: This might save/restore other state...
|
|
|
|
auto &stackEntry = currentList->stack[currentList->stackptr++];
|
|
|
|
stackEntry.pc = currentList->pc;
|
|
|
|
stackEntry.offsetAddr = gstate_c.offsetAddr;
|
|
|
|
stackEntry.baseAddr = gstate.base;
|
|
|
|
UpdatePC(currentList->pc, target);
|
|
|
|
currentList->pc = target;
|
2022-01-24 07:03:30 +00:00
|
|
|
DEBUG_LOG(G3D, "Signal with Call (%s). signal/end: %04x %04x", targetType, signal, enddata);
|
2013-09-01 17:16:29 +00:00
|
|
|
}
|
2013-04-05 07:21:47 +00:00
|
|
|
}
|
2014-04-16 15:12:21 +00:00
|
|
|
break;
|
|
|
|
case PSP_GE_SIGNAL_RET:
|
|
|
|
{
|
|
|
|
trigger = false;
|
|
|
|
currentList->signal = behaviour;
|
|
|
|
if (currentList->stackptr == 0) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Signal with Return: stack empty. signal/end: %04x %04x", signal, enddata);
|
|
|
|
} else {
|
|
|
|
// TODO: This might save/restore other state...
|
|
|
|
auto &stackEntry = currentList->stack[--currentList->stackptr];
|
|
|
|
gstate_c.offsetAddr = stackEntry.offsetAddr;
|
|
|
|
gstate.base = stackEntry.baseAddr;
|
|
|
|
UpdatePC(currentList->pc, stackEntry.pc);
|
|
|
|
currentList->pc = stackEntry.pc;
|
|
|
|
DEBUG_LOG(G3D, "Signal with Return. signal/end: %04x %04x", signal, enddata);
|
2013-09-01 17:16:29 +00:00
|
|
|
}
|
2013-04-06 16:59:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-04-16 15:12:21 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "UNKNOWN Signal UNIMPLEMENTED %i ! signal/end: %04x %04x", behaviour, signal, enddata);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// TODO: Technically, jump/call/ret should generate an interrupt, but before the pc change maybe?
|
|
|
|
if (currentList->interruptsEnabled && trigger) {
|
|
|
|
if (__GeTriggerInterrupt(currentList->id, currentList->pc, startingTicks + cyclesExecuted)) {
|
2013-09-01 17:16:29 +00:00
|
|
|
currentList->pendingInterrupt = true;
|
2014-04-16 15:12:21 +00:00
|
|
|
UpdateState(GPUSTATE_INTERRUPT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GE_CMD_FINISH:
|
|
|
|
switch (currentList->signal) {
|
|
|
|
case PSP_GE_SIGNAL_HANDLER_PAUSE:
|
|
|
|
currentList->state = PSP_GE_DL_STATE_PAUSED;
|
|
|
|
if (currentList->interruptsEnabled) {
|
|
|
|
if (__GeTriggerInterrupt(currentList->id, currentList->pc, startingTicks + cyclesExecuted)) {
|
|
|
|
currentList->pendingInterrupt = true;
|
|
|
|
UpdateState(GPUSTATE_INTERRUPT);
|
2013-04-06 16:59:24 +00:00
|
|
|
}
|
2013-04-06 15:19:54 +00:00
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
break;
|
2014-04-16 15:12:21 +00:00
|
|
|
|
|
|
|
case PSP_GE_SIGNAL_SYNC:
|
|
|
|
currentList->signal = PSP_GE_SIGNAL_NONE;
|
|
|
|
// TODO: Technically this should still cause an interrupt. Probably for memory sync.
|
|
|
|
break;
|
|
|
|
|
2013-04-01 06:02:46 +00:00
|
|
|
default:
|
2022-09-06 05:45:34 +00:00
|
|
|
FlushImm();
|
2014-04-16 15:12:21 +00:00
|
|
|
currentList->subIntrToken = prev & 0xFFFF;
|
|
|
|
UpdateState(GPUSTATE_DONE);
|
2021-01-31 08:28:42 +00:00
|
|
|
// Since we marked done, we have to restore the context now before the next list runs.
|
|
|
|
if (currentList->started && currentList->context.IsValid()) {
|
|
|
|
gstate.Restore(currentList->context);
|
|
|
|
ReapplyGfxState();
|
|
|
|
// Don't restore the context again.
|
|
|
|
currentList->started = false;
|
|
|
|
}
|
|
|
|
|
2014-04-16 15:12:21 +00:00
|
|
|
if (currentList->interruptsEnabled && __GeTriggerInterrupt(currentList->id, currentList->pc, startingTicks + cyclesExecuted)) {
|
|
|
|
currentList->pendingInterrupt = true;
|
|
|
|
} else {
|
|
|
|
currentList->state = PSP_GE_DL_STATE_COMPLETED;
|
|
|
|
currentList->waitTicks = startingTicks + cyclesExecuted;
|
|
|
|
busyTicks = std::max(busyTicks, currentList->waitTicks);
|
|
|
|
__GeTriggerSync(GPU_SYNC_LIST, currentList->id, currentList->waitTicks);
|
|
|
|
}
|
2013-04-01 06:02:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2014-04-16 15:12:21 +00:00
|
|
|
default:
|
|
|
|
DEBUG_LOG(G3D,"Ah, not finished: %06x", prev & 0xFFFFFF);
|
|
|
|
break;
|
2013-04-20 22:23:35 +00:00
|
|
|
}
|
2014-04-16 15:12:21 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 19:42:40 +00:00
|
|
|
void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) {
|
|
|
|
// Just resetting, nothing to check bounds for.
|
2022-10-22 16:06:33 +00:00
|
|
|
const u32 count = op & 0xFFFF;
|
2017-11-17 12:36:48 +00:00
|
|
|
if (count == 0) {
|
2017-08-20 20:30:10 +00:00
|
|
|
currentList->bboxResult = false;
|
2017-01-21 19:42:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-10-22 16:06:33 +00:00
|
|
|
|
2022-10-22 16:09:17 +00:00
|
|
|
// Approximate based on timings of several counts on a PSP.
|
|
|
|
cyclesExecuted += count * 22;
|
|
|
|
|
2022-10-22 17:01:56 +00:00
|
|
|
const bool useInds = (gstate.vertType & GE_VTYPE_IDX_MASK) != 0;
|
2022-10-22 16:06:33 +00:00
|
|
|
VertexDecoder *dec = drawEngineCommon_->GetVertexDecoder(gstate.vertType);
|
2022-10-22 17:01:56 +00:00
|
|
|
int bytesRead = (useInds ? 1 : dec->VertexSize()) * count;
|
2022-10-22 16:06:33 +00:00
|
|
|
|
|
|
|
if (Memory::IsValidRange(gstate_c.vertexAddr, bytesRead)) {
|
|
|
|
const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
2017-11-17 12:36:48 +00:00
|
|
|
if (!control_points) {
|
2022-01-23 06:41:41 +00:00
|
|
|
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Invalid verts in bounding box check");
|
|
|
|
currentList->bboxResult = true;
|
2017-11-17 12:36:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-22 17:01:56 +00:00
|
|
|
const void *inds = nullptr;
|
|
|
|
if (useInds) {
|
|
|
|
int indexShift = ((gstate.vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1;
|
|
|
|
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
|
|
|
if (!inds || !Memory::IsValidRange(gstate_c.indexAddr, count << indexShift)) {
|
|
|
|
ERROR_LOG_REPORT_ONCE(boundingboxInds, G3D, "Invalid inds in bounding box check");
|
|
|
|
currentList->bboxResult = true;
|
|
|
|
return;
|
|
|
|
}
|
2017-01-21 19:42:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test if the bounding box is within the drawing region.
|
2022-10-22 16:06:33 +00:00
|
|
|
// The PSP only seems to vary the result based on a single range of 0x100.
|
|
|
|
if (count > 0x200) {
|
|
|
|
// The second to last set of 0x100 is checked (even for odd counts.)
|
|
|
|
size_t skipSize = (count - 0x200) * dec->VertexSize();
|
2022-10-22 17:01:56 +00:00
|
|
|
currentList->bboxResult = drawEngineCommon_->TestBoundingBox((const uint8_t *)control_points + skipSize, inds, 0x100, gstate.vertType);
|
2022-10-22 16:06:33 +00:00
|
|
|
} else if (count > 0x100) {
|
|
|
|
int checkSize = count - 0x100;
|
2022-10-22 17:01:56 +00:00
|
|
|
currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, inds, checkSize, gstate.vertType);
|
2022-10-22 16:06:33 +00:00
|
|
|
} else {
|
2022-10-22 17:01:56 +00:00
|
|
|
currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, inds, count, gstate.vertType);
|
2022-10-22 16:06:33 +00:00
|
|
|
}
|
2017-11-17 12:36:48 +00:00
|
|
|
AdvanceVerts(gstate.vertType, count, bytesRead);
|
2017-01-21 19:42:40 +00:00
|
|
|
} else {
|
2017-11-17 12:36:48 +00:00
|
|
|
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Bad bounding box data: %06x", count);
|
2017-01-21 19:42:40 +00:00
|
|
|
// Data seems invalid. Let's assume the box test passed.
|
|
|
|
currentList->bboxResult = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-24 09:44:02 +00:00
|
|
|
void GPUCommon::Execute_MorphWeight(u32 op, u32 diff) {
|
|
|
|
gstate_c.morphWeights[(op >> 24) - GE_CMD_MORPHWEIGHT0] = getFloat24(op);
|
|
|
|
}
|
|
|
|
|
2017-11-24 16:54:56 +00:00
|
|
|
void GPUCommon::Execute_ImmVertexAlphaPrim(u32 op, u32 diff) {
|
2017-11-24 20:55:25 +00:00
|
|
|
// Safety check.
|
2017-11-25 11:13:02 +00:00
|
|
|
if (immCount_ >= MAX_IMMBUFFER_SIZE) {
|
|
|
|
// Only print once for each overrun.
|
|
|
|
if (immCount_ == MAX_IMMBUFFER_SIZE) {
|
2017-12-01 19:01:13 +00:00
|
|
|
ERROR_LOG_REPORT_ONCE(exceed_imm_buffer, G3D, "Exceeded immediate draw buffer size. gstate.imm_ap=%06x , prim=%d", gstate.imm_ap & 0xFFFFFF, (int)immPrim_);
|
2017-11-25 11:13:02 +00:00
|
|
|
}
|
|
|
|
if (immCount_ < 0x7fffffff) // Paranoia :)
|
|
|
|
immCount_++;
|
2017-11-24 20:55:25 +00:00
|
|
|
return;
|
2017-11-25 11:13:02 +00:00
|
|
|
}
|
2017-11-24 20:55:25 +00:00
|
|
|
|
2022-09-06 05:45:34 +00:00
|
|
|
int prim = (op >> 8) & 0x7;
|
|
|
|
if (prim != GE_PRIM_KEEP_PREVIOUS) {
|
|
|
|
// Flush before changing the prim type. Only continue can be used to continue a prim.
|
|
|
|
FlushImm();
|
|
|
|
}
|
|
|
|
|
2017-11-24 16:54:56 +00:00
|
|
|
TransformedVertex &v = immBuffer_[immCount_++];
|
|
|
|
|
2022-09-06 05:45:34 +00:00
|
|
|
// ThrillVille does a clear with this, additional parameters found via tests.
|
|
|
|
// The current vtype affects how the coordinate is processed.
|
|
|
|
if (gstate.isModeThrough()) {
|
|
|
|
v.x = ((int)(gstate.imm_vscx & 0xFFFF) - 0x8000) / 16.0f;
|
|
|
|
v.y = ((int)(gstate.imm_vscy & 0xFFFF) - 0x8000) / 16.0f;
|
|
|
|
} else {
|
|
|
|
int offsetX = gstate.getOffsetX16();
|
|
|
|
int offsetY = gstate.getOffsetY16();
|
|
|
|
v.x = ((int)(gstate.imm_vscx & 0xFFFF) - offsetX) / 16.0f;
|
|
|
|
v.y = ((int)(gstate.imm_vscy & 0xFFFF) - offsetY) / 16.0f;
|
|
|
|
}
|
2017-11-24 16:54:56 +00:00
|
|
|
v.z = gstate.imm_vscz & 0xFFFF;
|
2021-10-31 04:03:01 +00:00
|
|
|
v.pos_w = 1.0f;
|
2017-11-25 11:13:02 +00:00
|
|
|
v.u = getFloat24(gstate.imm_vtcs);
|
|
|
|
v.v = getFloat24(gstate.imm_vtct);
|
2021-10-31 04:03:01 +00:00
|
|
|
v.uv_w = getFloat24(gstate.imm_vtcq);
|
2017-11-24 16:54:56 +00:00
|
|
|
v.color0_32 = (gstate.imm_cv & 0xFFFFFF) | (gstate.imm_ap << 24);
|
2022-09-07 05:03:46 +00:00
|
|
|
// TODO: When !gstate.isModeThrough(), direct fog coefficient (0 = entirely fog), ignore fog flag (also GE_IMM_FOG.)
|
|
|
|
v.fog = (gstate.imm_fc & 0xFF) / 255.0f;
|
|
|
|
// TODO: Apply if gstate.isUsingSecondaryColor() && !gstate.isModeThrough(), ignore lighting flag.
|
2017-11-24 16:54:56 +00:00
|
|
|
v.color1_32 = gstate.imm_scv & 0xFFFFFF;
|
2017-11-25 11:13:02 +00:00
|
|
|
if (prim != GE_PRIM_KEEP_PREVIOUS) {
|
2017-11-24 20:45:25 +00:00
|
|
|
immPrim_ = (GEPrimitiveType)prim;
|
2022-09-06 06:13:16 +00:00
|
|
|
// Flags seem to only be respected from the first prim.
|
|
|
|
immFlags_ = op & 0x00FFF800;
|
2022-09-18 03:15:40 +00:00
|
|
|
immFirstSent_ = false;
|
2022-09-06 05:45:34 +00:00
|
|
|
} else if (prim == GE_PRIM_KEEP_PREVIOUS && immPrim_ != GE_PRIM_INVALID) {
|
|
|
|
static constexpr int flushPrimCount[] = { 1, 2, 0, 3, 0, 0, 2, 0 };
|
2022-09-18 01:42:59 +00:00
|
|
|
// Instead of finding a proper point to flush, we just emit prims when we can.
|
2022-09-06 05:45:34 +00:00
|
|
|
if (immCount_ == flushPrimCount[immPrim_ & 7])
|
|
|
|
FlushImm();
|
2017-11-25 11:13:02 +00:00
|
|
|
} else {
|
|
|
|
ERROR_LOG_REPORT_ONCE(imm_draw_prim, G3D, "Immediate draw: Unexpected primitive %d at count %d", prim, immCount_);
|
2017-11-24 16:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:45:25 +00:00
|
|
|
void GPUCommon::FlushImm() {
|
2022-09-06 05:45:34 +00:00
|
|
|
if (immCount_ == 0 || immPrim_ == GE_PRIM_INVALID)
|
|
|
|
return;
|
|
|
|
|
2017-11-24 20:45:25 +00:00
|
|
|
SetDrawType(DRAW_PRIM, immPrim_);
|
2023-03-23 16:14:12 +00:00
|
|
|
VirtualFramebuffer *vfb = nullptr;
|
2022-09-06 05:38:21 +00:00
|
|
|
if (framebufferManager_)
|
2023-03-23 16:14:12 +00:00
|
|
|
vfb = framebufferManager_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
|
2017-11-24 20:45:25 +00:00
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
|
|
|
// No idea how many cycles to skip, heh.
|
2022-09-06 05:45:34 +00:00
|
|
|
immCount_ = 0;
|
2017-11-24 20:45:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-12-01 22:54:34 +00:00
|
|
|
gstate_c.UpdateUVScaleOffset();
|
2023-03-23 16:14:12 +00:00
|
|
|
if (vfb) {
|
|
|
|
CheckDepthUsage(vfb);
|
|
|
|
}
|
2017-11-24 20:45:25 +00:00
|
|
|
|
2022-09-07 05:03:46 +00:00
|
|
|
bool antialias = (immFlags_ & GE_IMM_ANTIALIAS) != 0;
|
|
|
|
bool prevAntialias = gstate.isAntiAliasEnabled();
|
|
|
|
bool shading = (immFlags_ & GE_IMM_SHADING) != 0;
|
|
|
|
bool prevShading = gstate.getShadeMode() == GE_SHADE_GOURAUD;
|
2022-09-06 06:13:16 +00:00
|
|
|
bool cullEnable = (immFlags_ & GE_IMM_CULLENABLE) != 0;
|
|
|
|
bool prevCullEnable = gstate.isCullEnabled();
|
|
|
|
int cullMode = (immFlags_ & GE_IMM_CULLFACE) != 0 ? 1 : 0;
|
2022-09-07 05:03:46 +00:00
|
|
|
bool texturing = (immFlags_ & GE_IMM_TEXTURE) != 0;
|
|
|
|
bool prevTexturing = gstate.isTextureMapEnabled();
|
2022-09-18 02:42:41 +00:00
|
|
|
bool fog = (immFlags_ & GE_IMM_FOG) != 0;
|
|
|
|
bool prevFog = gstate.isFogEnabled();
|
2022-09-06 06:13:16 +00:00
|
|
|
bool dither = (immFlags_ & GE_IMM_DITHER) != 0;
|
2022-09-07 05:03:46 +00:00
|
|
|
bool prevDither = gstate.isDitherEnabled();
|
2022-09-06 06:13:16 +00:00
|
|
|
|
2022-09-07 05:18:55 +00:00
|
|
|
if ((immFlags_ & GE_IMM_CLIPMASK) != 0) {
|
|
|
|
WARN_LOG_REPORT_ONCE(geimmclipvalue, G3D, "Imm vertex used clip value, flags=%06x", immFlags_);
|
|
|
|
}
|
|
|
|
|
2022-09-18 04:08:26 +00:00
|
|
|
bool changed = texturing != prevTexturing || cullEnable != prevCullEnable || dither != prevDither;
|
|
|
|
changed = changed || prevShading != shading || prevFog != fog;
|
|
|
|
if (changed) {
|
2022-09-06 06:13:16 +00:00
|
|
|
DispatchFlush();
|
2022-09-07 05:03:46 +00:00
|
|
|
gstate.antiAliasEnable = (GE_CMD_ANTIALIASENABLE << 24) | (int)antialias;
|
|
|
|
gstate.shademodel = (GE_CMD_SHADEMODE << 24) | (int)shading;
|
2022-09-06 06:13:16 +00:00
|
|
|
gstate.cullfaceEnable = (GE_CMD_CULLFACEENABLE << 24) | (int)cullEnable;
|
2022-09-07 05:03:46 +00:00
|
|
|
gstate.textureMapEnable = (GE_CMD_TEXTUREMAPENABLE << 24) | (int)texturing;
|
2022-09-18 02:42:41 +00:00
|
|
|
gstate.fogEnable = (GE_CMD_FOGENABLE << 24) | (int)fog;
|
2022-09-06 06:13:16 +00:00
|
|
|
gstate.ditherEnable = (GE_CMD_DITHERENABLE << 24) | (int)dither;
|
2022-09-18 04:08:26 +00:00
|
|
|
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_UVSCALEOFFSET | DIRTY_CULLRANGE);
|
2022-09-06 06:13:16 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 03:15:40 +00:00
|
|
|
drawEngineCommon_->DispatchSubmitImm(immPrim_, immBuffer_, immCount_, cullMode, immFirstSent_);
|
2022-09-06 05:45:34 +00:00
|
|
|
immCount_ = 0;
|
2022-09-18 03:15:40 +00:00
|
|
|
immFirstSent_ = true;
|
2022-09-06 06:13:16 +00:00
|
|
|
|
2022-09-18 04:08:26 +00:00
|
|
|
if (changed) {
|
|
|
|
DispatchFlush();
|
|
|
|
gstate.antiAliasEnable = (GE_CMD_ANTIALIASENABLE << 24) | (int)prevAntialias;
|
|
|
|
gstate.shademodel = (GE_CMD_SHADEMODE << 24) | (int)prevShading;
|
|
|
|
gstate.cullfaceEnable = (GE_CMD_CULLFACEENABLE << 24) | (int)prevCullEnable;
|
|
|
|
gstate.textureMapEnable = (GE_CMD_TEXTUREMAPENABLE << 24) | (int)prevTexturing;
|
|
|
|
gstate.fogEnable = (GE_CMD_FOGENABLE << 24) | (int)prevFog;
|
|
|
|
gstate.ditherEnable = (GE_CMD_DITHERENABLE << 24) | (int)prevDither;
|
|
|
|
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_UVSCALEOFFSET | DIRTY_CULLRANGE);
|
|
|
|
}
|
2017-11-24 20:45:25 +00:00
|
|
|
}
|
|
|
|
|
2017-01-24 09:44:02 +00:00
|
|
|
void GPUCommon::Execute_Unknown(u32 op, u32 diff) {
|
2017-12-01 17:32:23 +00:00
|
|
|
if ((op & 0xFFFFFF) != 0)
|
|
|
|
WARN_LOG_REPORT_ONCE(unknowncmd, G3D, "Unknown GE command : %08x ", op);
|
2013-04-01 06:02:46 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 02:12:40 +00:00
|
|
|
void GPUCommon::FastLoadBoneMatrix(u32 target) {
|
2020-09-28 22:35:38 +00:00
|
|
|
const u32 num = gstate.boneMatrixNumber & 0x7F;
|
2022-01-01 23:26:00 +00:00
|
|
|
_dbg_assert_msg_(num + 12 <= 96, "FastLoadBoneMatrix would corrupt memory");
|
2020-09-28 22:35:38 +00:00
|
|
|
const u32 mtxNum = num / 12;
|
|
|
|
u32 uniformsToDirty = DIRTY_BONEMATRIX0 << mtxNum;
|
2020-09-24 21:00:48 +00:00
|
|
|
if (num != 12 * mtxNum) {
|
2018-04-10 10:22:02 +00:00
|
|
|
uniformsToDirty |= DIRTY_BONEMATRIX0 << ((mtxNum + 1) & 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g_Config.bSoftwareSkinning) {
|
2022-02-01 03:32:46 +00:00
|
|
|
if (flushOnParams_)
|
|
|
|
Flush();
|
2018-04-10 10:22:02 +00:00
|
|
|
gstate_c.Dirty(uniformsToDirty);
|
|
|
|
} else {
|
|
|
|
gstate_c.deferredVertTypeDirty |= uniformsToDirty;
|
|
|
|
}
|
2014-03-03 02:12:40 +00:00
|
|
|
gstate.FastLoadBoneMatrix(target);
|
2023-01-01 19:35:04 +00:00
|
|
|
|
|
|
|
cyclesExecuted += 2 * 14; // one to reset the counter, 12 to load the matrix, and a return.
|
|
|
|
|
|
|
|
if (coreCollectDebugStats) {
|
|
|
|
gpuStats.otherGPUCycles += 2 * 14;
|
|
|
|
}
|
2014-03-03 02:12:40 +00:00
|
|
|
}
|
|
|
|
|
2014-08-17 08:52:06 +00:00
|
|
|
struct DisplayList_v1 {
|
2013-10-07 05:07:57 +00:00
|
|
|
int id;
|
|
|
|
u32 startpc;
|
|
|
|
u32 pc;
|
|
|
|
u32 stall;
|
|
|
|
DisplayListState state;
|
|
|
|
SignalBehavior signal;
|
|
|
|
int subIntrBase;
|
|
|
|
u16 subIntrToken;
|
|
|
|
DisplayListStackEntry stack[32];
|
|
|
|
int stackptr;
|
|
|
|
bool interrupted;
|
|
|
|
u64 waitTicks;
|
|
|
|
bool interruptsEnabled;
|
|
|
|
bool pendingInterrupt;
|
|
|
|
bool started;
|
|
|
|
size_t contextPtr;
|
|
|
|
u32 offsetAddr;
|
|
|
|
bool bboxResult;
|
|
|
|
};
|
|
|
|
|
2014-08-17 08:52:06 +00:00
|
|
|
struct DisplayList_v2 {
|
|
|
|
int id;
|
|
|
|
u32 startpc;
|
|
|
|
u32 pc;
|
|
|
|
u32 stall;
|
|
|
|
DisplayListState state;
|
|
|
|
SignalBehavior signal;
|
|
|
|
int subIntrBase;
|
|
|
|
u16 subIntrToken;
|
|
|
|
DisplayListStackEntry stack[32];
|
|
|
|
int stackptr;
|
|
|
|
bool interrupted;
|
|
|
|
u64 waitTicks;
|
|
|
|
bool interruptsEnabled;
|
|
|
|
bool pendingInterrupt;
|
|
|
|
bool started;
|
|
|
|
PSPPointer<u32_le> context;
|
|
|
|
u32 offsetAddr;
|
|
|
|
bool bboxResult;
|
|
|
|
};
|
|
|
|
|
2012-12-29 19:41:33 +00:00
|
|
|
void GPUCommon::DoState(PointerWrap &p) {
|
2022-10-02 06:18:42 +00:00
|
|
|
auto s = p.Section("GPUCommon", 1, 6);
|
2013-09-15 03:23:03 +00:00
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
2020-08-10 04:20:42 +00:00
|
|
|
Do<int>(p, dlQueue);
|
2015-10-11 12:38:26 +00:00
|
|
|
if (s >= 4) {
|
2020-08-10 04:20:42 +00:00
|
|
|
DoArray(p, dls, ARRAY_SIZE(dls));
|
2015-10-11 12:38:26 +00:00
|
|
|
} else if (s >= 3) {
|
2015-12-24 22:31:43 +00:00
|
|
|
// This may have been saved with or without padding, depending on platform.
|
|
|
|
// We need to upconvert it to our consistently-padded struct.
|
|
|
|
static const size_t DisplayList_v3_size = 452;
|
|
|
|
static const size_t DisplayList_v4_size = 456;
|
|
|
|
static_assert(DisplayList_v4_size == sizeof(DisplayList), "Make sure to change here when updating DisplayList");
|
|
|
|
|
|
|
|
p.DoVoid(&dls[0], DisplayList_v3_size);
|
|
|
|
dls[0].padding = 0;
|
|
|
|
|
|
|
|
const u8 *savedPtr = *p.GetPPtr();
|
|
|
|
const u32 *savedPtr32 = (const u32 *)savedPtr;
|
|
|
|
// Here's the trick: the first member (id) is always the same as the index.
|
|
|
|
// The second member (startpc) is always an address, or 0, never 1. So we can see the padding.
|
|
|
|
const bool hasPadding = savedPtr32[1] == 1;
|
|
|
|
if (hasPadding) {
|
|
|
|
u32 padding;
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, padding);
|
2015-12-24 22:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 1; i < ARRAY_SIZE(dls); ++i) {
|
|
|
|
p.DoVoid(&dls[i], DisplayList_v3_size);
|
2015-10-11 12:38:26 +00:00
|
|
|
dls[i].padding = 0;
|
2015-12-24 22:31:43 +00:00
|
|
|
if (hasPadding) {
|
|
|
|
u32 padding;
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, padding);
|
2015-12-24 22:31:43 +00:00
|
|
|
}
|
2015-10-11 12:38:26 +00:00
|
|
|
}
|
2014-08-17 08:52:06 +00:00
|
|
|
} else if (s >= 2) {
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(dls); ++i) {
|
|
|
|
DisplayList_v2 oldDL;
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, oldDL);
|
2014-08-17 08:52:06 +00:00
|
|
|
// Copy over everything except the last, new member (stackAddr.)
|
|
|
|
memcpy(&dls[i], &oldDL, sizeof(DisplayList_v2));
|
|
|
|
dls[i].stackAddr = 0;
|
|
|
|
}
|
2013-10-07 05:07:57 +00:00
|
|
|
} else {
|
|
|
|
// Can only be in read mode here.
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(dls); ++i) {
|
2014-08-17 08:52:06 +00:00
|
|
|
DisplayList_v1 oldDL;
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, oldDL);
|
2013-10-07 05:07:57 +00:00
|
|
|
// On 32-bit, they're the same, on 64-bit oldDL is bigger.
|
2020-05-17 06:49:45 +00:00
|
|
|
memcpy(&dls[i], &oldDL, sizeof(DisplayList_v1));
|
2013-10-07 05:07:57 +00:00
|
|
|
// Fix the other fields. Let's hope context wasn't important, it was a pointer.
|
|
|
|
dls[i].context = 0;
|
|
|
|
dls[i].offsetAddr = oldDL.offsetAddr;
|
|
|
|
dls[i].bboxResult = oldDL.bboxResult;
|
2014-08-17 08:52:06 +00:00
|
|
|
dls[i].stackAddr = 0;
|
2013-10-07 05:07:57 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-05 06:19:28 +00:00
|
|
|
int currentID = 0;
|
2016-01-22 06:14:47 +00:00
|
|
|
if (currentList != nullptr) {
|
|
|
|
currentID = (int)(currentList - &dls[0]);
|
2013-04-05 06:19:28 +00:00
|
|
|
}
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, currentID);
|
2013-02-12 09:06:11 +00:00
|
|
|
if (currentID == 0) {
|
2016-01-22 06:14:47 +00:00
|
|
|
currentList = nullptr;
|
2013-02-12 09:06:11 +00:00
|
|
|
} else {
|
2013-04-05 06:19:28 +00:00
|
|
|
currentList = &dls[currentID];
|
2013-02-12 09:06:11 +00:00
|
|
|
}
|
2020-08-10 04:20:42 +00:00
|
|
|
Do(p, interruptRunning);
|
|
|
|
Do(p, gpuState);
|
|
|
|
Do(p, isbreak);
|
|
|
|
Do(p, drawCompleteTicks);
|
|
|
|
Do(p, busyTicks);
|
2022-09-28 05:29:55 +00:00
|
|
|
|
|
|
|
if (s >= 5) {
|
|
|
|
Do(p, matrixVisible.all);
|
|
|
|
}
|
2022-10-02 06:18:42 +00:00
|
|
|
if (s >= 6) {
|
|
|
|
Do(p, edramTranslation_);
|
|
|
|
}
|
2012-12-29 19:41:33 +00:00
|
|
|
}
|
2013-02-03 23:41:16 +00:00
|
|
|
|
2013-08-09 07:32:40 +00:00
|
|
|
void GPUCommon::InterruptStart(int listid) {
|
2013-02-03 23:41:16 +00:00
|
|
|
interruptRunning = true;
|
|
|
|
}
|
2013-08-09 07:32:40 +00:00
|
|
|
void GPUCommon::InterruptEnd(int listid) {
|
2013-02-03 23:41:16 +00:00
|
|
|
interruptRunning = false;
|
2013-04-04 07:35:38 +00:00
|
|
|
isbreak = false;
|
2013-04-06 15:19:54 +00:00
|
|
|
|
|
|
|
DisplayList &dl = dls[listid];
|
2013-09-01 17:16:29 +00:00
|
|
|
dl.pendingInterrupt = false;
|
2013-04-06 15:19:54 +00:00
|
|
|
// TODO: Unless the signal handler could change it?
|
2013-04-07 23:47:29 +00:00
|
|
|
if (dl.state == PSP_GE_DL_STATE_COMPLETED || dl.state == PSP_GE_DL_STATE_NONE) {
|
2013-10-07 05:07:57 +00:00
|
|
|
if (dl.started && dl.context.IsValid()) {
|
2013-09-20 16:42:09 +00:00
|
|
|
gstate.Restore(dl.context);
|
2013-09-24 06:17:36 +00:00
|
|
|
ReapplyGfxState();
|
2013-09-20 16:42:09 +00:00
|
|
|
}
|
2013-04-07 19:45:42 +00:00
|
|
|
dl.waitTicks = 0;
|
2014-03-30 00:02:41 +00:00
|
|
|
__GeTriggerWait(GPU_SYNC_LIST, listid);
|
2019-07-07 20:10:28 +00:00
|
|
|
|
|
|
|
// Make sure the list isn't still queued since it's now completed.
|
|
|
|
if (!dlQueue.empty()) {
|
|
|
|
if (listid == dlQueue.front())
|
|
|
|
PopDLQueue();
|
|
|
|
else
|
|
|
|
dlQueue.remove(listid);
|
|
|
|
}
|
2013-04-06 15:19:54 +00:00
|
|
|
}
|
|
|
|
|
2013-02-03 23:41:16 +00:00
|
|
|
ProcessDLQueue();
|
|
|
|
}
|
2013-04-07 19:45:42 +00:00
|
|
|
|
|
|
|
// TODO: Maybe cleaner to keep this in GE and trigger the clear directly?
|
2014-03-29 23:51:38 +00:00
|
|
|
void GPUCommon::SyncEnd(GPUSyncType waitType, int listid, bool wokeThreads) {
|
|
|
|
if (waitType == GPU_SYNC_DRAW && wokeThreads)
|
2013-04-07 19:45:42 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
|
|
|
if (dls[i].state == PSP_GE_DL_STATE_COMPLETED) {
|
|
|
|
dls[i].state = PSP_GE_DL_STATE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-22 17:22:33 +00:00
|
|
|
|
|
|
|
bool GPUCommon::GetCurrentDisplayList(DisplayList &list) {
|
|
|
|
if (!currentList) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
list = *currentList;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<DisplayList> GPUCommon::ActiveDisplayLists() {
|
|
|
|
std::vector<DisplayList> result;
|
|
|
|
|
|
|
|
for (auto it = dlQueue.begin(), end = dlQueue.end(); it != end; ++it) {
|
|
|
|
result.push_back(dls[*it]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::ResetListPC(int listID, u32 pc) {
|
|
|
|
if (listID < 0 || listID >= DisplayListMaxCount) {
|
2020-07-19 15:47:02 +00:00
|
|
|
_dbg_assert_msg_(false, "listID out of range: %d", listID);
|
2013-09-22 17:22:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-31 01:21:32 +00:00
|
|
|
Reporting::NotifyDebugger();
|
2013-09-22 17:22:33 +00:00
|
|
|
dls[listID].pc = pc;
|
2022-02-06 00:57:36 +00:00
|
|
|
downcount = 0;
|
2013-09-22 17:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::ResetListStall(int listID, u32 stall) {
|
|
|
|
if (listID < 0 || listID >= DisplayListMaxCount) {
|
2020-07-19 15:47:02 +00:00
|
|
|
_dbg_assert_msg_(false, "listID out of range: %d", listID);
|
2013-09-22 17:22:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-31 01:21:32 +00:00
|
|
|
Reporting::NotifyDebugger();
|
2013-09-22 17:22:33 +00:00
|
|
|
dls[listID].stall = stall;
|
2022-02-06 00:57:36 +00:00
|
|
|
downcount = 0;
|
2013-09-22 17:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPUCommon::ResetListState(int listID, DisplayListState state) {
|
|
|
|
if (listID < 0 || listID >= DisplayListMaxCount) {
|
2020-07-19 15:47:02 +00:00
|
|
|
_dbg_assert_msg_(false, "listID out of range: %d", listID);
|
2013-09-22 17:22:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-31 01:21:32 +00:00
|
|
|
Reporting::NotifyDebugger();
|
2013-09-22 17:22:33 +00:00
|
|
|
dls[listID].state = state;
|
2022-02-06 00:57:36 +00:00
|
|
|
downcount = 0;
|
2013-09-22 17:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GPUDebugOp GPUCommon::DissassembleOp(u32 pc, u32 op) {
|
|
|
|
char buffer[1024];
|
2022-08-24 02:50:01 +00:00
|
|
|
u32 prev = Memory::IsValidAddress(pc - 4) ? Memory::ReadUnchecked_U32(pc - 4) : 0;
|
|
|
|
GeDisassembleOp(pc, op, prev, buffer, sizeof(buffer));
|
2013-09-22 17:22:33 +00:00
|
|
|
|
|
|
|
GPUDebugOp info;
|
|
|
|
info.pc = pc;
|
|
|
|
info.cmd = op >> 24;
|
|
|
|
info.op = op;
|
|
|
|
info.desc = buffer;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<GPUDebugOp> GPUCommon::DissassembleOpRange(u32 startpc, u32 endpc) {
|
|
|
|
char buffer[1024];
|
|
|
|
std::vector<GPUDebugOp> result;
|
|
|
|
GPUDebugOp info;
|
|
|
|
|
2013-10-06 22:07:54 +00:00
|
|
|
// Don't trigger a pause.
|
|
|
|
u32 prev = Memory::IsValidAddress(startpc - 4) ? Memory::Read_U32(startpc - 4) : 0;
|
2023-12-12 12:13:43 +00:00
|
|
|
result.reserve((endpc - startpc) / 4);
|
2013-09-22 17:22:33 +00:00
|
|
|
for (u32 pc = startpc; pc < endpc; pc += 4) {
|
2013-10-06 22:07:54 +00:00
|
|
|
u32 op = Memory::IsValidAddress(pc) ? Memory::Read_U32(pc) : 0;
|
2014-09-13 21:50:42 +00:00
|
|
|
GeDisassembleOp(pc, op, prev, buffer, sizeof(buffer));
|
2013-09-22 17:22:33 +00:00
|
|
|
prev = op;
|
|
|
|
|
|
|
|
info.pc = pc;
|
|
|
|
info.cmd = op >> 24;
|
|
|
|
info.op = op;
|
|
|
|
info.desc = buffer;
|
|
|
|
result.push_back(info);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GPUCommon::GetRelativeAddress(u32 data) {
|
|
|
|
return gstate_c.getRelativeAddress(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GPUCommon::GetVertexAddress() {
|
|
|
|
return gstate_c.vertexAddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GPUCommon::GetIndexAddress() {
|
|
|
|
return gstate_c.indexAddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUgstate GPUCommon::GetGState() {
|
|
|
|
return gstate;
|
|
|
|
}
|
2013-10-07 02:17:06 +00:00
|
|
|
|
|
|
|
void GPUCommon::SetCmdValue(u32 op) {
|
|
|
|
u32 cmd = op >> 24;
|
|
|
|
u32 diff = op ^ gstate.cmdmem[cmd];
|
|
|
|
|
2022-07-31 01:21:32 +00:00
|
|
|
Reporting::NotifyDebugger();
|
2013-10-07 02:17:06 +00:00
|
|
|
PreExecuteOp(op, diff);
|
|
|
|
gstate.cmdmem[cmd] = op;
|
|
|
|
ExecuteOp(op, diff);
|
2022-02-06 00:57:36 +00:00
|
|
|
downcount = 0;
|
2013-10-07 02:17:06 +00:00
|
|
|
}
|
2016-04-10 20:07:08 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
|
|
|
|
u32 srcBasePtr = gstate.getTransferSrcAddress();
|
|
|
|
u32 srcStride = gstate.getTransferSrcStride();
|
|
|
|
|
|
|
|
u32 dstBasePtr = gstate.getTransferDstAddress();
|
|
|
|
u32 dstStride = gstate.getTransferDstStride();
|
|
|
|
|
|
|
|
int srcX = gstate.getTransferSrcX();
|
|
|
|
int srcY = gstate.getTransferSrcY();
|
|
|
|
|
|
|
|
int dstX = gstate.getTransferDstX();
|
|
|
|
int dstY = gstate.getTransferDstY();
|
|
|
|
|
|
|
|
int width = gstate.getTransferWidth();
|
|
|
|
int height = gstate.getTransferHeight();
|
|
|
|
|
|
|
|
int bpp = gstate.getTransferBpp();
|
|
|
|
|
|
|
|
DEBUG_LOG(G3D, "Block transfer: %08x/%x -> %08x/%x, %ix%ix%i (%i,%i)->(%i,%i)", srcBasePtr, srcStride, dstBasePtr, dstStride, width, height, bpp, srcX, srcY, dstX, dstY);
|
2023-10-03 11:15:55 +00:00
|
|
|
gpuStats.numBlockTransfers++;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2022-12-01 03:12:06 +00:00
|
|
|
// For VRAM, we wrap around when outside valid memory (mirrors still work.)
|
|
|
|
if ((srcBasePtr & 0x04800000) == 0x04800000)
|
|
|
|
srcBasePtr &= ~0x00800000;
|
|
|
|
if ((dstBasePtr & 0x04800000) == 0x04800000)
|
|
|
|
dstBasePtr &= ~0x00800000;
|
|
|
|
|
2024-05-10 11:50:49 +00:00
|
|
|
// Use height less one to account for width, which can be greater or less than stride, and then add it on for the last line.
|
|
|
|
// NOTE: The sizes are only used for validity checks and memory info tracking.
|
2022-12-01 03:12:06 +00:00
|
|
|
const uint32_t src = srcBasePtr + (srcY * srcStride + srcX) * bpp;
|
|
|
|
const uint32_t dst = dstBasePtr + (dstY * dstStride + dstX) * bpp;
|
2024-05-10 11:50:49 +00:00
|
|
|
const uint32_t srcSize = ((height - 1) * srcStride) + width * bpp;
|
|
|
|
const uint32_t dstSize = ((height - 1) * dstStride) + width * bpp;
|
2022-12-01 03:12:06 +00:00
|
|
|
|
|
|
|
bool srcDstOverlap = src + srcSize > dst && dst + dstSize > src;
|
|
|
|
bool srcValid = Memory::IsValidRange(src, srcSize);
|
|
|
|
bool dstValid = Memory::IsValidRange(dst, dstSize);
|
|
|
|
bool srcWraps = Memory::IsVRAMAddress(srcBasePtr) && !srcValid;
|
|
|
|
bool dstWraps = Memory::IsVRAMAddress(dstBasePtr) && !dstValid;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2022-12-01 14:39:22 +00:00
|
|
|
char tag[128];
|
|
|
|
size_t tagSize;
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
// Tell the framebuffer manager to take action if possible. If it does the entire thing, let's just return.
|
2022-12-01 03:12:06 +00:00
|
|
|
if (!framebufferManager_ || !framebufferManager_->NotifyBlockTransferBefore(dstBasePtr, dstStride, dstX, dstY, srcBasePtr, srcStride, srcX, srcY, width, height, bpp, skipDrawReason)) {
|
2016-12-21 17:07:17 +00:00
|
|
|
// Do the copy! (Hm, if we detect a drawn video frame (see below) then we could maybe skip this?)
|
|
|
|
// Can use GetPointerUnchecked because we checked the addresses above. We could also avoid them
|
|
|
|
// entirely by walking a couple of pointers...
|
2022-12-01 03:12:06 +00:00
|
|
|
|
|
|
|
// Simple case: just a straight copy, no overlap or wrapping.
|
|
|
|
if (srcStride == dstStride && (u32)width == srcStride && !srcDstOverlap && srcValid && dstValid) {
|
2016-12-21 17:07:17 +00:00
|
|
|
u32 srcLineStartAddr = srcBasePtr + (srcY * srcStride + srcX) * bpp;
|
|
|
|
u32 dstLineStartAddr = dstBasePtr + (dstY * dstStride + dstX) * bpp;
|
2022-12-01 03:12:06 +00:00
|
|
|
u32 bytesToCopy = width * height * bpp;
|
|
|
|
|
|
|
|
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
|
|
|
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
|
|
|
memcpy(dstp, srcp, bytesToCopy);
|
|
|
|
|
|
|
|
if (MemBlockInfoDetailed(bytesToCopy)) {
|
2023-09-25 01:03:12 +00:00
|
|
|
NotifyMemInfoCopy(dst, src, bytesToCopy, "GPUBlockTransfer/");
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
} else if ((srcDstOverlap || srcWraps || dstWraps) && (srcValid || srcWraps) && (dstValid || dstWraps)) {
|
|
|
|
// This path means we have either src/dst overlap, OR one or both of src and dst wrap.
|
|
|
|
// This should be uncommon so it's the slowest path.
|
|
|
|
u32 bytesToCopy = width * bpp;
|
|
|
|
bool notifyDetail = MemBlockInfoDetailed(srcWraps || dstWraps ? 64 : bytesToCopy);
|
|
|
|
bool notifyAll = !notifyDetail && MemBlockInfoDetailed(srcSize, dstSize);
|
|
|
|
if (notifyDetail || notifyAll) {
|
2022-12-01 14:39:22 +00:00
|
|
|
tagSize = FormatMemWriteTagAt(tag, sizeof(tag), "GPUBlockTransfer/", src, srcSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto notifyingMemmove = [&](u32 d, u32 s, u32 sz) {
|
|
|
|
const u8 *srcp = Memory::GetPointer(s);
|
|
|
|
u8 *dstp = Memory::GetPointerWrite(d);
|
|
|
|
memmove(dstp, srcp, sz);
|
|
|
|
|
|
|
|
if (notifyDetail) {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, s, sz, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, d, sz, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
|
|
|
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
|
|
|
// If we already passed a wrap, we can use the quicker path.
|
|
|
|
if ((srcLineStartAddr & 0x04800000) == 0x04800000)
|
|
|
|
srcLineStartAddr &= ~0x00800000;
|
|
|
|
if ((dstLineStartAddr & 0x04800000) == 0x04800000)
|
|
|
|
dstLineStartAddr &= ~0x00800000;
|
|
|
|
// These flags mean there's a wrap inside this line.
|
|
|
|
bool srcLineWrap = !Memory::IsValidRange(srcLineStartAddr, bytesToCopy);
|
|
|
|
bool dstLineWrap = !Memory::IsValidRange(dstLineStartAddr, bytesToCopy);
|
|
|
|
|
|
|
|
if (!srcLineWrap && !dstLineWrap) {
|
|
|
|
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
|
|
|
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
|
|
|
for (u32 i = 0; i < bytesToCopy; i += 64) {
|
|
|
|
u32 chunk = i + 64 > bytesToCopy ? bytesToCopy - i : 64;
|
|
|
|
memmove(dstp + i, srcp + i, chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're tracking detail, it's useful to have the gaps illustrated properly.
|
|
|
|
if (notifyDetail) {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, srcLineStartAddr, bytesToCopy, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dstLineStartAddr, bytesToCopy, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We can wrap at any point, so along with overlap this gets a bit complicated.
|
|
|
|
// We're just going to do this the slow and easy way.
|
|
|
|
u32 srcLinePos = srcLineStartAddr;
|
|
|
|
u32 dstLinePos = dstLineStartAddr;
|
|
|
|
for (u32 i = 0; i < bytesToCopy; i += 64) {
|
|
|
|
u32 chunk = i + 64 > bytesToCopy ? bytesToCopy - i : 64;
|
|
|
|
u32 srcValid = Memory::ValidSize(srcLinePos, chunk);
|
|
|
|
u32 dstValid = Memory::ValidSize(dstLinePos, chunk);
|
|
|
|
|
|
|
|
// First chunk, for which both are valid.
|
|
|
|
u32 bothSize = std::min(srcValid, dstValid);
|
|
|
|
if (bothSize != 0)
|
|
|
|
notifyingMemmove(dstLinePos, srcLinePos, bothSize);
|
|
|
|
|
|
|
|
// Now, whichever side has more valid (or the rest, if only one side must wrap.)
|
|
|
|
u32 exclusiveSize = std::max(srcValid, dstValid) - bothSize;
|
|
|
|
if (exclusiveSize != 0 && srcValid >= dstValid) {
|
|
|
|
notifyingMemmove(PSP_GetVidMemBase(), srcLineStartAddr + bothSize, exclusiveSize);
|
|
|
|
} else if (exclusiveSize != 0 && srcValid < dstValid) {
|
|
|
|
notifyingMemmove(dstLineStartAddr + bothSize, PSP_GetVidMemBase(), exclusiveSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, if both src and dst wrapped, that portion.
|
|
|
|
u32 wrappedSize = chunk - bothSize - exclusiveSize;
|
|
|
|
if (wrappedSize != 0 && srcValid >= dstValid) {
|
|
|
|
notifyingMemmove(PSP_GetVidMemBase() + exclusiveSize, PSP_GetVidMemBase(), wrappedSize);
|
|
|
|
} else if (wrappedSize != 0 && srcValid < dstValid) {
|
|
|
|
notifyingMemmove(PSP_GetVidMemBase(), PSP_GetVidMemBase() + exclusiveSize, wrappedSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
srcLinePos += chunk;
|
|
|
|
dstLinePos += chunk;
|
|
|
|
if ((srcLinePos & 0x04800000) == 0x04800000)
|
|
|
|
srcLinePos &= ~0x00800000;
|
|
|
|
if ((dstLinePos & 0x04800000) == 0x04800000)
|
|
|
|
dstLinePos &= ~0x00800000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notifyAll) {
|
|
|
|
if (srcWraps) {
|
|
|
|
u32 validSize = Memory::ValidSize(src, srcSize);
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, src, validSize, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::READ, PSP_GetVidMemBase(), srcSize - validSize, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
} else {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, src, srcSize, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
if (dstWraps) {
|
|
|
|
u32 validSize = Memory::ValidSize(dst, dstSize);
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dst, validSize, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetVidMemBase(), dstSize - validSize, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
} else {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dst, dstSize, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (srcValid && dstValid) {
|
|
|
|
u32 bytesToCopy = width * bpp;
|
|
|
|
bool notifyDetail = MemBlockInfoDetailed(bytesToCopy);
|
|
|
|
bool notifyAll = !notifyDetail && MemBlockInfoDetailed(srcSize, dstSize);
|
|
|
|
if (notifyDetail || notifyAll) {
|
2022-12-01 14:39:22 +00:00
|
|
|
tagSize = FormatMemWriteTagAt(tag, sizeof(tag), "GPUBlockTransfer/", src, srcSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
|
|
|
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
|
|
|
|
2022-12-01 03:12:06 +00:00
|
|
|
const u8 *srcp = Memory::GetPointer(srcLineStartAddr);
|
|
|
|
u8 *dstp = Memory::GetPointerWrite(dstLineStartAddr);
|
|
|
|
memcpy(dstp, srcp, bytesToCopy);
|
|
|
|
|
|
|
|
// If we're tracking detail, it's useful to have the gaps illustrated properly.
|
|
|
|
if (notifyDetail) {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, srcLineStartAddr, bytesToCopy, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dstLineStartAddr, bytesToCopy, tag, tagSize);
|
2022-12-01 03:12:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notifyAll) {
|
2022-12-01 14:39:22 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::READ, src, srcSize, tag, tagSize);
|
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dst, dstSize, tag, tagSize);
|
2016-12-21 17:07:17 +00:00
|
|
|
}
|
2022-12-01 03:12:06 +00:00
|
|
|
} else {
|
|
|
|
// This seems to cause the GE to require a break/reset on a PSP.
|
|
|
|
// TODO: Handle that and figure out which bytes are still copied?
|
|
|
|
ERROR_LOG_REPORT_ONCE(invalidtransfer, G3D, "Block transfer invalid: %08x/%x -> %08x/%x, %ix%ix%i (%i,%i)->(%i,%i)", srcBasePtr, srcStride, dstBasePtr, dstStride, width, height, bpp, srcX, srcY, dstX, dstY);
|
2016-12-21 17:07:17 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 03:12:06 +00:00
|
|
|
if (framebufferManager_) {
|
|
|
|
// Fixes Gran Turismo's funky text issue, since it overwrites the current texture.
|
|
|
|
textureCache_->Invalidate(dstBasePtr + (dstY * dstStride + dstX) * bpp, height * dstStride * bpp, GPU_INVALIDATE_HINT);
|
|
|
|
framebufferManager_->NotifyBlockTransferAfter(dstBasePtr, dstStride, dstX, dstY, srcBasePtr, srcStride, srcX, srcY, width, height, bpp, skipDrawReason);
|
|
|
|
}
|
2022-02-06 17:28:48 +00:00
|
|
|
}
|
2016-12-21 17:07:17 +00:00
|
|
|
|
|
|
|
// TODO: Correct timing appears to be 1.9, but erring a bit low since some of our other timing is inaccurate.
|
|
|
|
cyclesExecuted += ((height * width * bpp) * 16) / 10;
|
2016-12-21 17:26:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-04 03:17:25 +00:00
|
|
|
bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags) {
|
2016-12-21 17:26:06 +00:00
|
|
|
// Track stray copies of a framebuffer in RAM. MotoGP does this.
|
2023-12-06 08:42:44 +00:00
|
|
|
if (framebufferManager_->MayIntersectFramebufferColor(src) || framebufferManager_->MayIntersectFramebufferColor(dest)) {
|
2022-10-04 03:17:25 +00:00
|
|
|
if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, flags, gstate_c.skipDrawReason)) {
|
2022-11-08 15:29:36 +00:00
|
|
|
// We use matching values in PerformReadbackToMemory/PerformWriteColorFromMemory.
|
2017-11-05 19:33:28 +00:00
|
|
|
// Since they're identical we don't need to copy.
|
2022-11-08 15:29:36 +00:00
|
|
|
if (dest != src) {
|
2023-09-25 01:03:12 +00:00
|
|
|
if (Memory::IsValidRange(dest, size) && Memory::IsValidRange(src, size)) {
|
|
|
|
memcpy(Memory::GetPointerWriteUnchecked(dest), Memory::GetPointerUnchecked(src), size);
|
|
|
|
}
|
2022-02-06 17:28:48 +00:00
|
|
|
if (MemBlockInfoDetailed(size)) {
|
2023-09-25 01:03:12 +00:00
|
|
|
NotifyMemInfoCopy(dest, src, size, "GPUMemcpy/");
|
2022-02-06 17:28:48 +00:00
|
|
|
}
|
2017-11-05 19:33:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
|
2016-12-21 17:26:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-02-06 17:28:48 +00:00
|
|
|
if (MemBlockInfoDetailed(size)) {
|
2023-09-25 01:03:12 +00:00
|
|
|
NotifyMemInfoCopy(dest, src, size, "GPUMemcpy/");
|
2022-02-06 17:28:48 +00:00
|
|
|
}
|
2016-12-21 17:26:06 +00:00
|
|
|
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
|
2022-10-04 03:17:25 +00:00
|
|
|
if (!(flags & GPUCopyFlag::DEBUG_NOTIFIED))
|
|
|
|
GPURecord::NotifyMemcpy(dest, src, size);
|
2016-12-21 17:26:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) {
|
|
|
|
// This may indicate a memset, usually to 0, of a framebuffer.
|
2023-12-06 08:42:44 +00:00
|
|
|
if (framebufferManager_->MayIntersectFramebufferColor(dest)) {
|
2021-02-03 07:53:16 +00:00
|
|
|
Memory::Memset(dest, v, size, "GPUMemset");
|
2022-10-04 03:17:25 +00:00
|
|
|
if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, GPUCopyFlag::MEMSET, gstate_c.skipDrawReason)) {
|
2017-11-05 19:33:28 +00:00
|
|
|
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
|
|
|
|
}
|
2016-12-21 17:26:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-03 07:53:16 +00:00
|
|
|
NotifyMemInfo(MemBlockFlags::WRITE, dest, size, "GPUMemset");
|
2016-12-21 17:26:06 +00:00
|
|
|
// Or perhaps a texture, let's invalidate.
|
|
|
|
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
|
2017-06-03 07:09:58 +00:00
|
|
|
GPURecord::NotifyMemset(dest, v, size);
|
2016-12-21 17:26:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-09 20:49:41 +00:00
|
|
|
bool GPUCommon::PerformReadbackToMemory(u32 dest, int size) {
|
2016-12-21 17:26:06 +00:00
|
|
|
if (Memory::IsVRAMAddress(dest)) {
|
2023-03-26 06:25:42 +00:00
|
|
|
return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_DST_MATCH_MEM);
|
2016-12-21 17:26:06 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-09 20:49:41 +00:00
|
|
|
bool GPUCommon::PerformWriteColorFromMemory(u32 dest, int size) {
|
2016-12-21 17:26:06 +00:00
|
|
|
if (Memory::IsVRAMAddress(dest)) {
|
2017-06-03 07:09:58 +00:00
|
|
|
GPURecord::NotifyUpload(dest, size);
|
2023-03-26 06:25:42 +00:00
|
|
|
return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_SRC_MATCH_MEM | GPUCopyFlag::DEBUG_NOTIFIED);
|
2016-12-21 17:26:06 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-21 17:33:08 +00:00
|
|
|
|
2022-10-09 20:49:41 +00:00
|
|
|
void GPUCommon::PerformWriteFormattedFromMemory(u32 addr, int size, int frameWidth, GEBufferFormat format) {
|
2016-12-21 17:33:08 +00:00
|
|
|
if (Memory::IsVRAMAddress(addr)) {
|
2022-10-09 20:49:41 +00:00
|
|
|
framebufferManager_->PerformWriteFormattedFromMemory(addr, size, frameWidth, format);
|
2016-12-21 17:33:08 +00:00
|
|
|
}
|
2022-10-09 20:49:41 +00:00
|
|
|
textureCache_->NotifyWriteFormattedFromMemory(addr, size, frameWidth, format);
|
2016-12-21 17:33:08 +00:00
|
|
|
InvalidateCache(addr, size, GPU_INVALIDATE_SAFE);
|
|
|
|
}
|
|
|
|
|
2022-10-09 20:49:41 +00:00
|
|
|
bool GPUCommon::PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) {
|
2023-12-06 08:42:44 +00:00
|
|
|
if (framebufferManager_->MayIntersectFramebufferColor(dest)) {
|
2022-10-09 20:49:41 +00:00
|
|
|
framebufferManager_->PerformWriteStencilFromMemory(dest, size, flags);
|
2016-12-21 17:33:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-18 11:03:49 +00:00
|
|
|
bool GPUCommon::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
|
2023-12-01 22:54:34 +00:00
|
|
|
gstate_c.UpdateUVScaleOffset();
|
2017-10-18 11:03:49 +00:00
|
|
|
return drawEngineCommon_->GetCurrentSimpleVertices(count, vertices, indices);
|
|
|
|
}
|
|
|
|
|
2017-10-20 09:06:06 +00:00
|
|
|
bool GPUCommon::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
2023-12-19 11:25:54 +00:00
|
|
|
// The only part of GPU emulation (other than software) that jits is the vertex decoder, currently,
|
|
|
|
// which is owned by the drawengine.
|
|
|
|
return drawEngineCommon_->DescribeCodePtr(ptr, name);
|
2017-10-20 09:06:06 +00:00
|
|
|
}
|