2015-07-26 20:38:40 +00:00
|
|
|
// Copyright (c) 2015- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstring>
|
2022-09-05 21:40:43 +00:00
|
|
|
#include <cstdint>
|
2015-07-26 20:38:40 +00:00
|
|
|
|
|
|
|
class GPUInterface;
|
|
|
|
class GPUDebugInterface;
|
2015-12-31 15:59:40 +00:00
|
|
|
class GraphicsContext;
|
2015-07-26 20:38:40 +00:00
|
|
|
|
2022-08-08 09:24:35 +00:00
|
|
|
// PSP rasterization has two outputs, color and depth. Stencil is packed
|
|
|
|
// into the alpha channel of color (if exists), so possibly RASTER_COLOR
|
|
|
|
// should be named RASTER_COLOR_STENCIL but it gets kinda hard to read.
|
2022-09-05 21:31:30 +00:00
|
|
|
enum RasterChannel : uint8_t {
|
2022-08-08 09:24:35 +00:00
|
|
|
RASTER_COLOR = 0,
|
|
|
|
RASTER_DEPTH = 1,
|
2022-07-31 11:01:50 +00:00
|
|
|
};
|
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
enum SkipDrawReasonFlags {
|
|
|
|
SKIPDRAW_SKIPFRAME = 1,
|
|
|
|
SKIPDRAW_NON_DISPLAYED_FB = 2, // Skip drawing to FBO:s that have not been displayed.
|
|
|
|
SKIPDRAW_BAD_FB_TEXTURE = 4,
|
|
|
|
SKIPDRAW_WINDOW_MINIMIZED = 8, // Don't draw when the host window is minimized.
|
|
|
|
};
|
|
|
|
|
2022-09-11 12:14:18 +00:00
|
|
|
enum class ShaderDepalMode {
|
|
|
|
OFF = 0,
|
|
|
|
NORMAL = 1,
|
|
|
|
SMOOTHED = 2,
|
|
|
|
CLUT8_8888 = 3, // Read 8888 framebuffer as 8-bit CLUT.
|
|
|
|
};
|
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
// Global GPU-related utility functions.
|
|
|
|
// Nothing directly Ge-related in here.
|
|
|
|
|
|
|
|
// PSP uses a curious 24-bit float - it's the top 24 bits of a regular IEEE754 32-bit float.
|
|
|
|
// This is used for light positions, transform matrices, you name it.
|
|
|
|
inline float getFloat24(unsigned int data) {
|
|
|
|
data <<= 8;
|
|
|
|
float f;
|
|
|
|
memcpy(&f, &data, 4);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
// in case we ever want to generate PSP display lists...
|
|
|
|
inline unsigned int toFloat24(float f) {
|
|
|
|
unsigned int i;
|
|
|
|
memcpy(&i, &f, 4);
|
|
|
|
return i >> 8;
|
|
|
|
}
|
|
|
|
|
2023-07-30 12:42:22 +00:00
|
|
|
// The ToString function lives in GPUCommonHW.cpp.
|
2015-07-26 20:38:40 +00:00
|
|
|
struct GPUStatistics {
|
|
|
|
void Reset() {
|
2022-08-29 13:39:29 +00:00
|
|
|
ResetFrame();
|
|
|
|
numFlips = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
}
|
2020-09-20 19:33:06 +00:00
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
void ResetFrame() {
|
|
|
|
numDrawCalls = 0;
|
2023-10-02 15:28:25 +00:00
|
|
|
numVertexDecodes = 0;
|
2023-11-26 10:14:13 +00:00
|
|
|
numCulledDraws = 0;
|
2023-02-07 21:59:46 +00:00
|
|
|
numDrawSyncs = 0;
|
|
|
|
numListSyncs = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
numVertsSubmitted = 0;
|
2024-02-01 18:19:53 +00:00
|
|
|
numVertsDecoded = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
numUncachedVertsDrawn = 0;
|
|
|
|
numTextureInvalidations = 0;
|
2020-09-15 07:34:40 +00:00
|
|
|
numTextureInvalidationsByFramebuffer = 0;
|
2020-09-20 19:33:06 +00:00
|
|
|
numTexturesHashed = 0;
|
|
|
|
numTextureDataBytesHashed = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
numFlushes = 0;
|
2023-07-30 12:42:22 +00:00
|
|
|
numBBOXJumps = 0;
|
|
|
|
numPlaneUpdates = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
numTexturesDecoded = 0;
|
2020-09-12 13:37:03 +00:00
|
|
|
numFramebufferEvaluations = 0;
|
2023-02-05 15:59:23 +00:00
|
|
|
numBlockingReadbacks = 0;
|
2017-11-08 10:57:53 +00:00
|
|
|
numReadbacks = 0;
|
2017-12-29 03:27:45 +00:00
|
|
|
numUploads = 0;
|
2023-11-11 18:51:44 +00:00
|
|
|
numCachedUploads = 0;
|
2022-08-29 13:39:29 +00:00
|
|
|
numDepal = 0;
|
2017-12-27 03:34:57 +00:00
|
|
|
numClears = 0;
|
2022-07-24 15:12:43 +00:00
|
|
|
numDepthCopies = 0;
|
2022-08-18 08:51:50 +00:00
|
|
|
numReinterpretCopies = 0;
|
|
|
|
numColorCopies = 0;
|
2022-08-29 13:39:29 +00:00
|
|
|
numCopiesForShaderBlend = 0;
|
2022-08-29 13:57:39 +00:00
|
|
|
numCopiesForSelfTex = 0;
|
2023-10-03 11:15:55 +00:00
|
|
|
numBlockTransfers = 0;
|
2023-03-10 11:20:55 +00:00
|
|
|
numReplacerTrackedTex = 0;
|
|
|
|
numCachedReplacedTextures = 0;
|
2024-10-29 07:16:57 +00:00
|
|
|
numClutTextures = 0;
|
2015-07-26 20:38:40 +00:00
|
|
|
msProcessingDisplayLists = 0;
|
|
|
|
vertexGPUCycles = 0;
|
|
|
|
otherGPUCycles = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Per frame statistics
|
|
|
|
int numDrawCalls;
|
2023-10-02 15:28:25 +00:00
|
|
|
int numVertexDecodes;
|
2023-11-26 10:14:13 +00:00
|
|
|
int numCulledDraws;
|
2023-02-07 21:59:46 +00:00
|
|
|
int numDrawSyncs;
|
|
|
|
int numListSyncs;
|
2015-07-26 20:38:40 +00:00
|
|
|
int numFlushes;
|
2023-07-30 12:42:22 +00:00
|
|
|
int numBBOXJumps;
|
|
|
|
int numPlaneUpdates;
|
2015-07-26 20:38:40 +00:00
|
|
|
int numVertsSubmitted;
|
2024-02-01 18:19:53 +00:00
|
|
|
int numVertsDecoded;
|
2015-07-26 20:38:40 +00:00
|
|
|
int numUncachedVertsDrawn;
|
|
|
|
int numTextureInvalidations;
|
2020-09-15 07:34:40 +00:00
|
|
|
int numTextureInvalidationsByFramebuffer;
|
2020-09-20 19:33:06 +00:00
|
|
|
int numTexturesHashed;
|
|
|
|
int numTextureDataBytesHashed;
|
2015-07-26 20:38:40 +00:00
|
|
|
int numTexturesDecoded;
|
2020-09-12 13:37:03 +00:00
|
|
|
int numFramebufferEvaluations;
|
2023-02-05 15:59:23 +00:00
|
|
|
int numBlockingReadbacks;
|
2017-11-08 10:57:53 +00:00
|
|
|
int numReadbacks;
|
2017-12-29 03:27:45 +00:00
|
|
|
int numUploads;
|
2023-11-11 18:51:44 +00:00
|
|
|
int numCachedUploads;
|
2022-08-29 13:39:29 +00:00
|
|
|
int numDepal;
|
2017-12-27 03:34:57 +00:00
|
|
|
int numClears;
|
2022-07-24 15:12:43 +00:00
|
|
|
int numDepthCopies;
|
2022-08-18 08:51:50 +00:00
|
|
|
int numReinterpretCopies;
|
|
|
|
int numColorCopies;
|
2022-08-29 13:39:29 +00:00
|
|
|
int numCopiesForShaderBlend;
|
2022-08-29 13:57:39 +00:00
|
|
|
int numCopiesForSelfTex;
|
2023-10-03 11:15:55 +00:00
|
|
|
int numBlockTransfers;
|
2023-03-10 11:20:55 +00:00
|
|
|
int numReplacerTrackedTex;
|
|
|
|
int numCachedReplacedTextures;
|
2024-10-29 07:16:57 +00:00
|
|
|
int numClutTextures;
|
2015-07-26 20:38:40 +00:00
|
|
|
double msProcessingDisplayLists;
|
|
|
|
int vertexGPUCycles;
|
|
|
|
int otherGPUCycles;
|
|
|
|
|
2016-04-02 09:06:05 +00:00
|
|
|
// Flip count. Doesn't really belong here.
|
2015-07-26 20:38:40 +00:00
|
|
|
int numFlips;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern GPUStatistics gpuStats;
|
|
|
|
extern GPUInterface *gpu;
|
|
|
|
extern GPUDebugInterface *gpuDebug;
|
|
|
|
|
2016-12-25 17:18:19 +00:00
|
|
|
namespace Draw {
|
2016-12-25 20:01:57 +00:00
|
|
|
class DrawContext;
|
2016-12-25 17:18:19 +00:00
|
|
|
}
|
2016-03-20 19:04:49 +00:00
|
|
|
|
2019-09-29 04:36:03 +00:00
|
|
|
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw);
|
2017-12-03 18:54:38 +00:00
|
|
|
bool GPU_IsReady();
|
2023-01-01 14:59:14 +00:00
|
|
|
bool GPU_IsStarted();
|
2015-07-26 20:38:40 +00:00
|
|
|
void GPU_Shutdown();
|
2023-02-04 11:05:50 +00:00
|
|
|
|
|
|
|
const char *RasterChannelToString(RasterChannel channel);
|