[Gpu] Update

Conflicts:
	GPU/Directx9/FramebufferDX9.cpp
	GPU/Directx9/FramebufferDX9.h
	GPU/Directx9/VertexDecoderDX9.cpp
	GPU/Directx9/helper/fbo.cpp
This commit is contained in:
Ced2911 2013-11-15 15:15:12 +01:00 committed by Henrik Rydgard
parent e0c3b5a112
commit 6ee39c9abd
6 changed files with 77 additions and 38 deletions

View File

@ -639,11 +639,6 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebufferDX9 *vfb,
return;
}
#if 0
if(sync) {
PackFramebufferAsync_(NULL); // flush async just in case when we go for synchronous update
}
#endif
if(vfb) {
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
@ -718,7 +713,6 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebufferDX9 *vfb,
nvfb->last_frame_render = gpuStats.numFlips;
nvfb->dirtyAfterDisplay = true;
#if 0
fbo_bind_as_render_target(nvfb->fbo);
// Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering
@ -728,13 +722,13 @@ void FramebufferManagerDX9::ReadFramebufferToMemory(VirtualFramebufferDX9 *vfb,
if (nvfb->last_frame_render != gpuStats.numFlips) {
ClearBuffer();
}
#if 1
PackFramebufferSync_(nvfb);
#endif
}
vfb->memoryUpdated = true;
BlitFramebuffer_(vfb, nvfb, false);
PackFramebufferDirectx9_(nvfb);
}
}
@ -828,14 +822,46 @@ static void Resolve(u8* data, VirtualFramebufferDX9 *vfb) {
#endif
}
void FramebufferManagerDX9::PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb) {
if (useBufferedRendering_ && vfb->fbo) {
fbo_bind_for_read(vfb->fbo);
} else {
fbo_unbind();
void FramebufferManagerDX9::PackFramebufferAsync_(VirtualFramebufferDX9 *vfb) {
return;
const int MAX_PBO = 2;
bool unbind = false;
bool useCPU = false;
// Order packing/readback of the framebuffer
if (vfb) {
int pixelType, pixelSize, pixelFormat, align;
if (vfb->fbo) {
fbo_bind_for_read(vfb->fbo);
} else {
fbo_unbind();
return;
}
#ifdef _XBOX
D3DTexture * rtt = (D3DTexture*)fbo_get_rtt(vfb->fbo);
pD3Ddevice->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, rtt, NULL, 0, 0, NULL, 0.f, 0, NULL);
#endif
fbo_unbind();
unbind = true;
}
}
void FramebufferManagerDX9::PackFramebufferSync_(VirtualFramebufferDX9 *vfb) {
if (vfb->fbo) {
fbo_bind_for_read(vfb->fbo);
} else {
// ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "PackFramebufferSync_: vfb->fbo == 0");
fbo_unbind();
return;
}
// Pixel size always 4 here because we always request RGBA8888
size_t bufSize = vfb->fb_stride * vfb->height * 4;
u32 fb_address = (0x04000000) | vfb->fb_address;
@ -857,6 +883,7 @@ void FramebufferManagerDX9::PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb)
ConvertFromRGBA8888(Memory::GetPointer(fb_address), packed, vfb->fb_stride, vfb->height, vfb->format);
free(packed);
}
}
fbo_unbind();
@ -867,6 +894,10 @@ void FramebufferManagerDX9::EndFrame() {
dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
resized_ = false;
}
#if 0
// We flush to memory last requested framebuffer, if any
PackFramebufferAsync_(NULL);
#endif
}
void FramebufferManagerDX9::DeviceLost() {
@ -1010,4 +1041,4 @@ void FramebufferManagerDX9::Resized() {
resized_ = true;
}
};
} // namespace DX9

View File

@ -151,8 +151,10 @@ private:
// Used by ReadFramebufferToMemory
void BlitFramebuffer_(VirtualFramebufferDX9 *src, VirtualFramebufferDX9 *dst, bool flip = false, float upscale = 1.0f, float vscale = 1.0f);
void PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb);
std::vector<VirtualFramebufferDX9 *> bvfbs_; // blitting FBOs
//void PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb);
void PackFramebufferAsync_(VirtualFramebufferDX9 *vfb);
void PackFramebufferSync_(VirtualFramebufferDX9 *vfb);
// Used by DrawPixels
LPDIRECT3DTEXTURE9 drawPixelsTex_;

View File

@ -58,7 +58,6 @@ TextureCacheDX9::TextureCacheDX9() : clearCacheNextFrame_(false), lowMemoryMode_
tmpTexBufRearrange.resize(1024 * 512); // 2MB
clutBufConverted_ = (u32 *)AllocateAlignedMemory(4096 * sizeof(u32), 16); // 16KB
clutBufRaw_ = (u32 *)AllocateAlignedMemory(4096 * sizeof(u32), 16); // 16KB
// glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropyLevel);
maxAnisotropyLevel = 16;
SetupTextureDecoder();
#ifdef _XBOX
@ -206,37 +205,42 @@ inline void AttachFramebufferInvalid(T &entry, VirtualFramebufferDX9 *framebuffe
}
inline void TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebufferDX9 *framebuffer, bool exactMatch) {
// If they match exactly, it's non-CLUT and from the top left.
// If they match exactly, it's non-CLUT and from the top left.
if (exactMatch) {
// Apply to non-buffered and buffered mode only.
if (!(g_Config.iRenderingMode == FB_NON_BUFFERED_MODE || g_Config.iRenderingMode == FB_BUFFERED_MODE))
return;
DEBUG_LOG(G3D, "Render to texture detected at %08x!", address);
if (!entry->framebuffer || entry->invalidHint == -1) {
if (entry->format != framebuffer->format) {
WARN_LOG_REPORT_ONCE(diffFormat1, G3D, "Render to texture with different formats %d != %d", entry->format, framebuffer->format);
// If it already has one, let's hope that one is correct.
// If "AttachFramebufferValid" , Evangelion Jo and Kurohyou 2 will be 'blue background' in-game
AttachFramebufferInvalid(entry, framebuffer);
} else {
AttachFramebufferValid(entry, framebuffer);
}
// TODO: Delete the original non-fbo texture too.
}
} else if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE || g_Config.iRenderingMode == FB_BUFFERED_MODE) {
// 3rd Birthday (and possibly other games) render to a 16 bit clut texture.
const bool compatFormat = framebuffer->format == entry->format
|| (framebuffer->format == GE_FORMAT_8888 && entry->format == GE_TFMT_CLUT32)
|| (framebuffer->format != GE_FORMAT_8888 && entry->format == GE_TFMT_CLUT16);
}
} else {
// Apply to buffered mode only.
if (!(g_Config.iRenderingMode == FB_BUFFERED_MODE))
return;
// Is it at least the right stride?
if (framebuffer->fb_stride == entry->bufw && compatFormat) {
if (framebuffer->format != entry->format) {
// 3rd Birthday (and possibly other games) render to a 16 bit clut texture.
const bool compatFormat = framebuffer->format == entry->format
|| (framebuffer->format == GE_FORMAT_8888 && entry->format == GE_TFMT_CLUT32)
|| (framebuffer->format != GE_FORMAT_8888 && entry->format == GE_TFMT_CLUT16);
// Is it at least the right stride?
if (framebuffer->fb_stride == entry->bufw && compatFormat) {
if (framebuffer->format != entry->format) {
WARN_LOG_REPORT_ONCE(diffFormat2, G3D, "Render to texture with different formats %d != %d at %08x", entry->format, framebuffer->format, address);
// TODO: Use an FBO to translate the palette?
// If 'AttachFramebufferInvalid' , Kurohyou 2 will be missing battle scene in-game and FF Type-0 will have black box shadow/'blue fog' and 3rd birthday will have 'blue fog'
// If 'AttachFramebufferValid' , DBZ VS Tag will have 'burning effect' ,
AttachFramebufferValid(entry, framebuffer);
} else if ((entry->addr - address) / entry->bufw < framebuffer->height) {
// TODO: Use an FBO to translate the palette?
AttachFramebufferValid(entry, framebuffer);
} else if ((entry->addr - address) / entry->bufw < framebuffer->height) {
WARN_LOG_REPORT_ONCE(subarea, G3D, "Render to area containing texture at %08x", address);
// TODO: Keep track of the y offset.
// TODO: Keep track of the y offset.
// If "AttachFramebufferValid" , God of War Ghost of Sparta/Chains of Olympus will be missing special effect.
AttachFramebufferInvalid(entry, framebuffer);
}
@ -743,7 +747,7 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry)
if (useBufferedRendering) {
// For now, let's not bind FBOs that we know are off (invalidHint will be -1.)
// But let's still not use random memory.
if (entry->framebuffer->fbo && entry->invalidHint != -1) {
if (entry->framebuffer->fbo) {
fbo_bind_color_as_texture(entry->framebuffer->fbo, 0);
// Keep the framebuffer alive.
// TODO: Dangerous if it sets a new one?
@ -765,7 +769,7 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry)
}
}
void TextureCacheDX9::SetTexture() {
void TextureCacheDX9::SetTexture(bool force) {
#ifdef DEBUG_TEXTURES
if (SetDebugTexture()) {
// A different texture was bound, let's rebind next time.
@ -774,6 +778,9 @@ void TextureCacheDX9::SetTexture() {
}
#endif
if (force) {
lastBoundTexture = INVALID_TEX;
}
u32 texaddr = gstate.getTextureAddress(0);
if (!Memory::IsValidAddress(texaddr)) {
// Bind a null texture and return.

View File

@ -47,7 +47,7 @@ public:
TextureCacheDX9();
~TextureCacheDX9();
void SetTexture();
void SetTexture(bool t = false);
void Clear(bool delete_them);
void StartFrame();

View File

@ -32,7 +32,6 @@ namespace DX9 {
#define USE_WEIGHT_HACK
#define USE_TC_HACK
static const u8 tcsize[4] = {0,2,4,8}, tcalign[4] = {0,1,2,4};
static const u8 colsize[8] = {0,0,0,0,2,2,2,4}, colalign[8] = {0,0,0,0,2,2,2,4};
static const u8 nrmsize[4] = {0,3,6,12}, nrmalign[4] = {0,1,2,4};

View File

@ -90,7 +90,7 @@ void fbo_bind_as_render_target(FBO *fbo) {
}
void fbo_bind_for_read(FBO *fbo) {
OutputDebugStringA("fbo_bind_for_read: Fix me\r\n");
// pD3Ddevice->SetRenderTarget(0, fbo->surf);
}
void fbo_bind_color_as_texture(FBO *fbo, int color) {