d3d9: Add BindFramebufferColor().

This commit is contained in:
Henrik Rydgard 2014-09-17 23:26:20 +02:00 committed by Unknown W. Brackets
parent 856154a5f9
commit 718d7e291f
2 changed files with 37 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "Core/Reporting.h"
#include "GPU/ge_constants.h"
#include "GPU/GPUState.h"
#include "GPU/Debugger/Stepping.h"
#include "helper/dx_state.h"
#include "helper/fbo.h"
@ -642,6 +643,40 @@ namespace DX9 {
return offscreen;
}
void FramebufferManagerDX9::BindFramebufferColor(VirtualFramebuffer *framebuffer, bool skipCopy) {
if (framebuffer == NULL) {
framebuffer = currentRenderVfb_;
}
if (!framebuffer->fbo || !useBufferedRendering_) {
pD3Ddevice->SetTexture(0, nullptr);
gstate_c.skipDrawReason |= SKIPDRAW_BAD_FB_TEXTURE;
return;
}
// currentRenderVfb_ will always be set when this is called, except from the GE debugger.
// Let's just not bother with the copy in that case.
if (GPUStepping::IsStepping() || g_Config.bDisableSlowFramebufEffects) {
skipCopy = true;
}
if (!skipCopy && currentRenderVfb_ && framebuffer->fb_address == gstate.getFrameBufRawAddress()) {
// TODO: Maybe merge with bvfbs_? Not sure if those could be packing, and they're created at a different size.
FBO *renderCopy = GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, (FBOColorDepth)framebuffer->colorDepth);
if (renderCopy) {
VirtualFramebuffer copyInfo = *framebuffer;
copyInfo.fbo = renderCopy;
BlitFramebuffer(&copyInfo, 0, 0, framebuffer, 0, 0, framebuffer->drawnWidth, framebuffer->drawnHeight, 0, false);
RebindFramebuffer();
fbo_bind_color_as_texture(renderCopy, 0);
} else {
fbo_bind_color_as_texture(framebuffer->fbo, 0);
}
} else {
fbo_bind_color_as_texture(framebuffer->fbo, 0);
}
}
void FramebufferManagerDX9::CopyDisplayToOutput() {
fbo_unbind();

View File

@ -73,6 +73,8 @@ public:
void BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFramebuffer *dst);
void BindFramebufferColor(VirtualFramebuffer *framebuffer, bool skipCopy);
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) override;
std::vector<FramebufferInfo> GetFramebufferList();