Skip to content

Commit

Permalink
Merge pull request #6815 from unknownbrackets/gpu-minor
Browse files Browse the repository at this point in the history
Eat cycles during GE block transfers
  • Loading branch information
hrydgard committed Aug 31, 2014
2 parents afb31ef + e1d2e72 commit 94ee0c5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
3 changes: 3 additions & 0 deletions GPU/Directx9/GPU_DX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,9 @@ void DIRECTX9_GPU::DoBlockTransfer() {
dstStride == 512 && height == 272) {
framebufferManager_.DrawPixels(Memory::GetPointerUnchecked(dstBasePtr), GE_FORMAT_8888, 512);
}

// 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;
}

void DIRECTX9_GPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) {
Expand Down
3 changes: 3 additions & 0 deletions GPU/GLES/GLES_GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,9 @@ void GLES_GPU::DoBlockTransfer() {
CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc);
CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc);
#endif

// 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;
}

void GLES_GPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) {
Expand Down
6 changes: 3 additions & 3 deletions GPU/GLES/SoftwareTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ void TransformDrawEngine::SoftwareTransformAndDraw(
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(ATTR_POSITION, 4, GL_FLOAT, GL_FALSE, vertexSize, drawBuffer);
int attrMask = program->attrMask;
if (attrMask & (1 << ATTR_TEXCOORD)) glVertexAttribPointer(ATTR_TEXCOORD, doTextureProjection ? 3 : 2, GL_FLOAT, GL_FALSE, vertexSize, ((uint8_t*)drawBuffer) + 4 * 4);
if (attrMask & (1 << ATTR_COLOR0)) glVertexAttribPointer(ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + 7 * 4);
if (attrMask & (1 << ATTR_COLOR1)) glVertexAttribPointer(ATTR_COLOR1, 3, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + 8 * 4);
if (attrMask & (1 << ATTR_TEXCOORD)) glVertexAttribPointer(ATTR_TEXCOORD, doTextureProjection ? 3 : 2, GL_FLOAT, GL_FALSE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, u));
if (attrMask & (1 << ATTR_COLOR0)) glVertexAttribPointer(ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, color0));
if (attrMask & (1 << ATTR_COLOR1)) glVertexAttribPointer(ATTR_COLOR1, 3, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, color1));
if (drawIndexed) {
#if 1 // USING_GLES2
glDrawElements(glprim[prim], numTrans, GL_UNSIGNED_SHORT, inds);
Expand Down
50 changes: 40 additions & 10 deletions GPU/Null/NullGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.


#include "NullGpu.h"
#include "../GPUState.h"
#include "../ge_constants.h"
#include "../../Core/MemMap.h"
#include "../../Core/HLE/sceKernelInterrupt.h"
#include "../../Core/HLE/sceGe.h"
#include "GPU/Null/NullGpu.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
#include "Core/Debugger/Breakpoints.h"
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceGe.h"

NullGPU::NullGPU() { }
NullGPU::~NullGPU() { }
Expand Down Expand Up @@ -306,10 +308,38 @@ void NullGPU::ExecuteOp(u32 op, u32 diff) {

case GE_CMD_TRANSFERSTART:
{
DEBUG_LOG(G3D, "DL Texture Transfer Start: PixFormat %i", data);
// TODO: Here we should check if the transfer overlaps a framebuffer or any textures,
// and take appropriate action. If not, this should just be a block transfer within
// GPU memory which could be implemented by a copy loop.
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);

for (int y = 0; y < height; y++) {
const u8 *src = Memory::GetPointer(srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp);
u8 *dst = Memory::GetPointer(dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp);
memcpy(dst, src, width * bpp);
}

#ifndef MOBILE_DEVICE
CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc);
CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc);
#endif

// 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;
break;
}

Expand Down
3 changes: 3 additions & 0 deletions GPU/Software/SoftGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ void SoftGPU::ExecuteOp(u32 op, u32 diff)
CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc);
#endif

// 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;

// Could theoretically dirty the framebuffer.
framebufferDirty_ = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion UI/GameInfoCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ GameInfo *GameInfoCache::GetInfo(Thin3DContext *thin3d, const std::string &gameP
void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Thin3DContext *thin3d, Thin3DTexture *&tex, double &loadTime) {
if (textureData.size()) {
if (!tex) {
tex = thin3d->CreateTextureFromFileData(textureData.data(), textureData.size(), T3DFileType::PNG);
tex = thin3d->CreateTextureFromFileData(textureData.data(), (int)textureData.size(), T3DFileType::PNG);
if (tex) {
loadTime = time_now_d();
} else {
Expand Down

0 comments on commit 94ee0c5

Please sign in to comment.