mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-28 10:51:06 +00:00
d3d: Migrate a few more things into common code.
This commit is contained in:
parent
8ef326e531
commit
ae2e8c5c7c
@ -41,6 +41,29 @@ void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, G
|
||||
displayFormat_ = format;
|
||||
}
|
||||
|
||||
VirtualFramebuffer *FramebufferManagerCommon::GetVFBAt(u32 addr) {
|
||||
VirtualFramebuffer *match = NULL;
|
||||
for (size_t i = 0; i < vfbs_.size(); ++i) {
|
||||
VirtualFramebuffer *v = vfbs_[i];
|
||||
if (MaskedEqual(v->fb_address, addr)) {
|
||||
// Could check w too but whatever
|
||||
if (match == NULL || match->last_frame_render < v->last_frame_render) {
|
||||
match = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
return match;
|
||||
}
|
||||
|
||||
DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FramebufferManagerCommon::MaskedEqual(u32 addr1, u32 addr2) {
|
||||
return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF);
|
||||
}
|
||||
|
||||
// Heuristics to figure out the size of FBO to create.
|
||||
void FramebufferManagerCommon::EstimateDrawingSize(int &drawing_width, int &drawing_height) {
|
||||
static const int MAX_FRAMEBUF_HEIGHT = 512;
|
||||
|
@ -138,6 +138,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Break out into some form of FBO manager
|
||||
VirtualFramebuffer *GetVFBAt(u32 addr);
|
||||
VirtualFramebuffer *GetDisplayVFB() {
|
||||
return GetVFBAt(displayFramebufPtr_);
|
||||
}
|
||||
|
||||
int GetRenderWidth() const { return currentRenderVfb_ ? currentRenderVfb_->renderWidth : 480; }
|
||||
int GetRenderHeight() const { return currentRenderVfb_ ? currentRenderVfb_->renderHeight : 272; }
|
||||
int GetTargetWidth() const { return currentRenderVfb_ ? currentRenderVfb_->width : 480; }
|
||||
@ -149,6 +155,7 @@ public:
|
||||
|
||||
protected:
|
||||
void EstimateDrawingSize(int &drawing_width, int &drawing_height);
|
||||
static bool MaskedEqual(u32 addr1, u32 addr2);
|
||||
|
||||
void SetColorUpdated(VirtualFramebuffer *dstBuffer) {
|
||||
dstBuffer->memoryUpdated = false;
|
||||
|
@ -41,10 +41,6 @@ namespace DX9 {
|
||||
FBO_OLD_AGE = 5,
|
||||
};
|
||||
|
||||
static bool MaskedEqual(u32 addr1, u32 addr2) {
|
||||
return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF);
|
||||
}
|
||||
|
||||
inline u16 RGBA8888toRGB565(u32 px) {
|
||||
return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
|
||||
}
|
||||
@ -294,26 +290,6 @@ namespace DX9 {
|
||||
pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
VirtualFramebuffer *FramebufferManagerDX9::GetVFBAt(u32 addr) {
|
||||
VirtualFramebuffer *match = NULL;
|
||||
for (size_t i = 0; i < vfbs_.size(); ++i) {
|
||||
VirtualFramebuffer *v = vfbs_[i];
|
||||
if (MaskedEqual(v->fb_address, addr) && v->format == displayFormat_ && v->width >= 480) {
|
||||
// Could check w too but whatever
|
||||
if (match == NULL || match->last_frame_render < v->last_frame_render) {
|
||||
match = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
return match;
|
||||
}
|
||||
|
||||
DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FramebufferManagerDX9::DestroyFramebuf(VirtualFramebuffer *v) {
|
||||
textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED);
|
||||
if (v->fbo) {
|
||||
|
@ -72,12 +72,6 @@ public:
|
||||
|
||||
void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync = true);
|
||||
|
||||
// TODO: Break out into some form of FBO manager
|
||||
VirtualFramebuffer *GetVFBAt(u32 addr);
|
||||
VirtualFramebuffer *GetDisplayVFB() {
|
||||
return GetVFBAt(displayFramebufPtr_);
|
||||
}
|
||||
|
||||
std::vector<FramebufferInfo> GetFramebufferList();
|
||||
|
||||
void NotifyFramebufferCopy(u32 src, u32 dest, int size);
|
||||
|
@ -102,10 +102,6 @@ enum {
|
||||
FBO_OLD_AGE = 5,
|
||||
};
|
||||
|
||||
bool FramebufferManager::MaskedEqual(u32 addr1, u32 addr2) {
|
||||
return (addr1 & 0x03FFFFFF) == (addr2 & 0x03FFFFFF);
|
||||
}
|
||||
|
||||
inline u16 RGBA8888toRGB565(u32 px) {
|
||||
return ((px >> 3) & 0x001F) | ((px >> 5) & 0x07E0) | ((px >> 8) & 0xF800);
|
||||
}
|
||||
@ -640,26 +636,6 @@ void FramebufferManager::DrawActiveTexture(GLuint texture, float x, float y, flo
|
||||
glsl_unbind();
|
||||
}
|
||||
|
||||
|
||||
VirtualFramebuffer *FramebufferManager::GetVFBAt(u32 addr) {
|
||||
VirtualFramebuffer *match = NULL;
|
||||
for (size_t i = 0; i < vfbs_.size(); ++i) {
|
||||
VirtualFramebuffer *v = vfbs_[i];
|
||||
if (MaskedEqual(v->fb_address, addr)) {
|
||||
// Could check w too but whatever
|
||||
if (match == NULL || match->last_frame_render < v->last_frame_render) {
|
||||
match = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
return match;
|
||||
}
|
||||
|
||||
DEBUG_LOG(SCEGE, "Finding no FBO matching address %08x", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FramebufferManager::DestroyFramebuf(VirtualFramebuffer *v) {
|
||||
textureCache_->NotifyFramebuffer(v->fb_address, v, NOTIFY_FB_DESTROYED);
|
||||
if (v->fbo) {
|
||||
|
@ -110,12 +110,6 @@ public:
|
||||
// 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);
|
||||
|
||||
// TODO: Break out into some form of FBO manager
|
||||
VirtualFramebuffer *GetVFBAt(u32 addr);
|
||||
VirtualFramebuffer *GetDisplayVFB() {
|
||||
return GetVFBAt(displayFramebufPtr_);
|
||||
}
|
||||
|
||||
std::vector<FramebufferInfo> GetFramebufferList();
|
||||
|
||||
bool NotifyFramebufferCopy(u32 src, u32 dest, int size, bool isMemset = false);
|
||||
@ -147,8 +141,6 @@ private:
|
||||
|
||||
void SetNumExtraFBOs(int num);
|
||||
|
||||
static bool MaskedEqual(u32 addr1, u32 addr2);
|
||||
|
||||
inline bool ShouldDownloadFramebuffer(const VirtualFramebuffer *vfb) const;
|
||||
inline bool ShouldDownloadUsingCPU(const VirtualFramebuffer *vfb) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user