d3d: Unify ReadFramebufferToMemory() signature.
This commit is contained in:
parent
f33515723b
commit
a4d33d77b7
4 changed files with 41 additions and 12 deletions
|
@ -114,6 +114,7 @@ public:
|
||||||
virtual bool NotifyFramebufferCopy(u32 src, u32 dest, int size, bool isMemset = false) = 0;
|
virtual bool NotifyFramebufferCopy(u32 src, u32 dest, int size, bool isMemset = false) = 0;
|
||||||
virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) = 0;
|
virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) = 0;
|
||||||
|
|
||||||
|
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) = 0;
|
||||||
virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
||||||
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
||||||
virtual void DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) = 0;
|
virtual void DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) = 0;
|
||||||
|
|
|
@ -114,7 +114,8 @@ namespace DX9 {
|
||||||
FramebufferManagerDX9::FramebufferManagerDX9() :
|
FramebufferManagerDX9::FramebufferManagerDX9() :
|
||||||
drawPixelsTex_(0),
|
drawPixelsTex_(0),
|
||||||
drawPixelsTexFormat_(GE_FORMAT_INVALID),
|
drawPixelsTexFormat_(GE_FORMAT_INVALID),
|
||||||
convBuf(0)
|
convBuf(0),
|
||||||
|
gameUsesSequentialCopies_(false)
|
||||||
{
|
{
|
||||||
// And an initial clear. We don't clear per frame as the games are supposed to handle that
|
// And an initial clear. We don't clear per frame as the games are supposed to handle that
|
||||||
// by themselves.
|
// by themselves.
|
||||||
|
@ -436,8 +437,7 @@ namespace DX9 {
|
||||||
|
|
||||||
void FramebufferManagerDX9::NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb) {
|
void FramebufferManagerDX9::NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb) {
|
||||||
if (ShouldDownloadFramebuffer(vfb) && !vfb->memoryUpdated) {
|
if (ShouldDownloadFramebuffer(vfb) && !vfb->memoryUpdated) {
|
||||||
// TODO
|
ReadFramebufferToMemory(vfb, true, 0, 0, vfb->width, vfb->height);
|
||||||
//ReadFramebufferToMemory(vfb, true, 0, 0, vfb->width, vfb->height);
|
|
||||||
}
|
}
|
||||||
textureCache_->ForgetLastTexture();
|
textureCache_->ForgetLastTexture();
|
||||||
|
|
||||||
|
@ -650,14 +650,14 @@ namespace DX9 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync) {
|
void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) {
|
||||||
#if 0
|
#if 0
|
||||||
if (sync) {
|
if (sync) {
|
||||||
PackFramebufferAsync_(NULL); // flush async just in case when we go for synchronous update
|
PackFramebufferAsync_(NULL); // flush async just in case when we go for synchronous update
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(vfb) {
|
if (vfb) {
|
||||||
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
|
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
|
||||||
// For now we'll keep these on the same struct as the ones that can get displayed
|
// For now we'll keep these on the same struct as the ones that can get displayed
|
||||||
// (and blatantly copy work already done above while at it).
|
// (and blatantly copy work already done above while at it).
|
||||||
|
@ -692,6 +692,9 @@ namespace DX9 {
|
||||||
nvfb->bufferWidth = vfb->bufferWidth;
|
nvfb->bufferWidth = vfb->bufferWidth;
|
||||||
nvfb->bufferHeight = vfb->bufferHeight;
|
nvfb->bufferHeight = vfb->bufferHeight;
|
||||||
nvfb->format = vfb->format;
|
nvfb->format = vfb->format;
|
||||||
|
nvfb->drawnWidth = vfb->drawnWidth;
|
||||||
|
nvfb->drawnHeight = vfb->drawnHeight;
|
||||||
|
nvfb->drawnFormat = vfb->format;
|
||||||
nvfb->usageFlags = FB_USAGE_RENDERTARGET;
|
nvfb->usageFlags = FB_USAGE_RENDERTARGET;
|
||||||
nvfb->dirtyAfterDisplay = true;
|
nvfb->dirtyAfterDisplay = true;
|
||||||
|
|
||||||
|
@ -712,6 +715,7 @@ namespace DX9 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textureCache_->ForgetLastTexture();
|
||||||
nvfb->fbo = fbo_create(nvfb->width, nvfb->height, 1, true, (FBOColorDepth)nvfb->colorDepth);
|
nvfb->fbo = fbo_create(nvfb->width, nvfb->height, 1, true, (FBOColorDepth)nvfb->colorDepth);
|
||||||
if (!(nvfb->fbo)) {
|
if (!(nvfb->fbo)) {
|
||||||
ERROR_LOG(SCEGE, "Error creating FBO! %i x %i", nvfb->renderWidth, nvfb->renderHeight);
|
ERROR_LOG(SCEGE, "Error creating FBO! %i x %i", nvfb->renderWidth, nvfb->renderHeight);
|
||||||
|
@ -720,7 +724,6 @@ namespace DX9 {
|
||||||
|
|
||||||
nvfb->last_frame_render = gpuStats.numFlips;
|
nvfb->last_frame_render = gpuStats.numFlips;
|
||||||
bvfbs_.push_back(nvfb);
|
bvfbs_.push_back(nvfb);
|
||||||
fbo_bind_as_render_target(nvfb->fbo);
|
|
||||||
ClearBuffer();
|
ClearBuffer();
|
||||||
} else {
|
} else {
|
||||||
nvfb->usageFlags |= FB_USAGE_RENDERTARGET;
|
nvfb->usageFlags |= FB_USAGE_RENDERTARGET;
|
||||||
|
@ -743,9 +746,32 @@ namespace DX9 {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
vfb->memoryUpdated = true;
|
if (gameUsesSequentialCopies_) {
|
||||||
BlitFramebuffer_(nvfb, 0, 0, vfb, 0, 0, vfb->width, vfb->height, 0, false);
|
// Ignore the x/y/etc., read the entire thing.
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
w = vfb->width;
|
||||||
|
h = vfb->height;
|
||||||
|
}
|
||||||
|
if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) {
|
||||||
|
vfb->memoryUpdated = true;
|
||||||
|
} else {
|
||||||
|
const static int FREQUENT_SEQUENTIAL_COPIES = 3;
|
||||||
|
static int frameLastCopy = 0;
|
||||||
|
static u32 bufferLastCopy = 0;
|
||||||
|
static int copiesThisFrame = 0;
|
||||||
|
if (frameLastCopy != gpuStats.numFlips || bufferLastCopy != vfb->fb_address) {
|
||||||
|
frameLastCopy = gpuStats.numFlips;
|
||||||
|
bufferLastCopy = vfb->fb_address;
|
||||||
|
copiesThisFrame = 0;
|
||||||
|
}
|
||||||
|
if (++copiesThisFrame > FREQUENT_SEQUENTIAL_COPIES) {
|
||||||
|
gameUsesSequentialCopies_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlitFramebuffer_(nvfb, x, y, vfb, x, y, w, h, 0, false);
|
||||||
|
|
||||||
|
// TODO: Actually do it.
|
||||||
#if 0
|
#if 0
|
||||||
#ifdef USING_GLES2
|
#ifdef USING_GLES2
|
||||||
PackFramebufferSync_(nvfb); // synchronous glReadPixels
|
PackFramebufferSync_(nvfb); // synchronous glReadPixels
|
||||||
|
@ -943,8 +969,9 @@ namespace DX9 {
|
||||||
VirtualFramebuffer *vfb = vfbs_[i];
|
VirtualFramebuffer *vfb = vfbs_[i];
|
||||||
int age = frameLastFramebufUsed_ - std::max(vfb->last_frame_render, vfb->last_frame_used);
|
int age = frameLastFramebufUsed_ - std::max(vfb->last_frame_render, vfb->last_frame_used);
|
||||||
|
|
||||||
if (updateVram && age == 0 && !vfb->memoryUpdated && vfb == displayFramebuf_)
|
if (ShouldDownloadFramebuffer(vfb) && age == 0 && !vfb->memoryUpdated) {
|
||||||
ReadFramebufferToMemory(vfb);
|
ReadFramebufferToMemory(vfb, false, 0, 0, vfb->width, vfb->height);
|
||||||
|
}
|
||||||
|
|
||||||
if (vfb == displayFramebuf_ || vfb == prevDisplayFramebuf_ || vfb == prevPrevDisplayFramebuf_) {
|
if (vfb == displayFramebuf_ || vfb == prevDisplayFramebuf_ || vfb == prevPrevDisplayFramebuf_) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
void DeviceLost();
|
void DeviceLost();
|
||||||
void CopyDisplayToOutput();
|
void CopyDisplayToOutput();
|
||||||
|
|
||||||
void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync = true);
|
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) override;
|
||||||
|
|
||||||
std::vector<FramebufferInfo> GetFramebufferList();
|
std::vector<FramebufferInfo> GetFramebufferList();
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ private:
|
||||||
std::vector<FBO *> extraFBOs_;
|
std::vector<FBO *> extraFBOs_;
|
||||||
|
|
||||||
bool resized_;
|
bool resized_;
|
||||||
|
bool gameUsesSequentialCopies_;
|
||||||
|
|
||||||
std::vector<VirtualFramebuffer *> bvfbs_; // blitting FBOs
|
std::vector<VirtualFramebuffer *> bvfbs_; // blitting FBOs
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ public:
|
||||||
void NotifyBlockTransferAfter(u32 dstBasePtr, int dstStride, int dstX, int dstY, u32 srcBasePtr, int srcStride, int srcX, int srcY, int w, int h, int bpp);
|
void NotifyBlockTransferAfter(u32 dstBasePtr, int dstStride, int dstX, int dstY, u32 srcBasePtr, int srcStride, int srcX, int srcY, int w, int h, int bpp);
|
||||||
|
|
||||||
// Reads a rectangular subregion of a framebuffer to the right position in its backing memory.
|
// Reads a rectangular subregion of a framebuffer to the right position in its backing memory.
|
||||||
void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h);
|
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) override;
|
||||||
|
|
||||||
std::vector<FramebufferInfo> GetFramebufferList();
|
std::vector<FramebufferInfo> GetFramebufferList();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue