diff options
Diffstat (limited to 'Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp')
| -rw-r--r-- | Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp | 200 |
1 files changed, 128 insertions, 72 deletions
diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index f9d73bc169..c0772b2b4d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -23,34 +23,62 @@ namespace FBManager
{
-static LPDIRECT3DTEXTURE9 s_efb_color_texture;
-static LPDIRECT3DTEXTURE9 s_efb_colorBuffer_texture;
-static LPDIRECT3DTEXTURE9 s_efb_depth_texture;
-static LPDIRECT3DTEXTURE9 s_efb_depthBuffer_texture;
-static LPDIRECT3DSURFACE9 s_efb_color_surface;
-static LPDIRECT3DSURFACE9 s_efb_depth_surface;
+static LPDIRECT3DTEXTURE9 s_efb_color_texture;//Texture thats contains the color data of the render target
+static LPDIRECT3DTEXTURE9 s_efb_colorRead_texture;//1 pixel texture for temporal data store
+static LPDIRECT3DTEXTURE9 s_efb_depth_texture;//Texture thats contains the depth data of the render target
+static LPDIRECT3DTEXTURE9 s_efb_depthRead_texture;//1 pixel texture for temporal data store
-static LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer;
-static LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer;
+static LPDIRECT3DSURFACE9 s_efb_depth_surface;//Depth Surface
+static LPDIRECT3DSURFACE9 s_efb_depthColor_surface;//Depth, color encoded Surface
+static LPDIRECT3DSURFACE9 s_efb_color_surface;//Color Surface
+static LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer;//Surface 0 of s_efb_colorRead_texture
+static LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer;//Surface 0 of s_efb_depthRead_texture
-static LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;
-static LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;
+static LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
+static LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
-static D3DFORMAT s_efb_color_surface_Format;
-static D3DFORMAT s_efb_depth_surface_Format;
+static D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface
+static D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth color encoded Surface
#undef CHECK
#define CHECK(hr,Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" ,Message); }
-LPDIRECT3DSURFACE9 GetEFBColorRTSurface() { return s_efb_color_surface; }
-LPDIRECT3DSURFACE9 GetEFBDepthRTSurface() { return s_efb_depth_surface; }
-LPDIRECT3DSURFACE9 GetEFBColorOffScreenRTSurface() { return s_efb_color_OffScreenReadBuffer; }
-LPDIRECT3DSURFACE9 GetEFBDepthOffScreenRTSurface() { return s_efb_depth_OffScreenReadBuffer; }
+LPDIRECT3DSURFACE9 GetEFBColorRTSurface()
+{
+ return s_efb_color_surface;
+}
+LPDIRECT3DSURFACE9 GetEFBDepthRTSurface()
+{
+ return s_efb_depth_surface;
+}
+
+LPDIRECT3DSURFACE9 GetEFBDepthEncodedSurface()
+{
+ return s_efb_depthColor_surface;
+}
+
+LPDIRECT3DSURFACE9 GetEFBColorOffScreenRTSurface()
+{
+ return s_efb_color_OffScreenReadBuffer;
+}
+LPDIRECT3DSURFACE9 GetEFBDepthOffScreenRTSurface()
+{
+ return s_efb_depth_OffScreenReadBuffer;
+}
+
+LPDIRECT3DSURFACE9 GetEFBColorReadSurface()
+{
+
+ return s_efb_color_ReadBuffer;
+}
+LPDIRECT3DSURFACE9 GetEFBDepthReadSurface()
+{
+
+ return s_efb_depth_ReadBuffer;
+}
-LPDIRECT3DSURFACE9 GetEFBColorReadSurface() { return s_efb_color_ReadBuffer; }
-LPDIRECT3DSURFACE9 GetEFBDepthReadSurface() { return s_efb_depth_ReadBuffer; }
D3DFORMAT GetEFBDepthRTSurfaceFormat(){return s_efb_depth_surface_Format;}
D3DFORMAT GetEFBColorRTSurfaceFormat(){return s_efb_color_surface_Format;}
@@ -63,14 +91,9 @@ LPDIRECT3DTEXTURE9 GetEFBColorTexture(const EFBRectangle& sourceRc) LPDIRECT3DTEXTURE9 GetEFBDepthTexture(const EFBRectangle &sourceRc)
{
- // Depth textures not supported under DX9. We're gonna fake this
- // with a secondary render target later.
return s_efb_depth_texture;
}
-
-
-
void Create()
{
@@ -79,29 +102,55 @@ void Create() int target_height = Renderer::GetTargetHeight();
s_efb_color_surface_Format = D3DFMT_A8R8G8B8;
//get the framebuffer texture
- HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
+ HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_color_texture, NULL);
+ if(s_efb_color_texture)
+ {
+ s_efb_color_texture->GetSurfaceLevel(0,&s_efb_color_surface);
+ }
CHECK(hr,"Create Color Texture");
- //get the Surface
- hr = s_efb_color_texture->GetSurfaceLevel(0, &s_efb_color_surface);
- CHECK(hr,"Get Color Surface");
- //create a one pixel texture to work as a buffer for peeking
- hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
- D3DPOOL_DEFAULT, &s_efb_colorBuffer_texture, NULL);
- if (!FAILED(hr))
+ hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
+ D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL);
+ CHECK(hr,"Create Color Read Texture");
+ if(s_efb_colorRead_texture)
{
- //get the surface for the peeking texture
- hr = s_efb_colorBuffer_texture->GetSurfaceLevel(0, &s_efb_color_ReadBuffer);
- CHECK(hr,"Get Color Pixel Surface");
- //create an offscreen surface that we can lock to retrieve the data
- hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL );
- CHECK(hr,"Create Color offScreen Surface");
+ s_efb_colorRead_texture->GetSurfaceLevel(0,&s_efb_color_ReadBuffer);
}
+ //create an offscreen surface that we can lock to retrieve the data
+ hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_color_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL );
+ CHECK(hr,"Create Color offScreen Surface");
//Select Zbuffer format supported by hadware.
if (g_ActiveConfig.bEFBAccessEnable)
{
- //depth format in prefered order
+
+ hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, D3DFMT_D24X8,
+ D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL);
+ CHECK(hr,"CreateDepthStencilSurface");
+
+ s_efb_depth_surface_Format = D3DFMT_A8R8G8B8;
+ //get the framebuffer Depth texture
+ HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_surface_Format,
+ D3DPOOL_DEFAULT, &s_efb_depth_texture, NULL);
+ CHECK(hr,"Depth Color Texture");
+ //get the Surface
+ if(s_efb_depth_texture)
+ {
+ s_efb_depth_texture->GetSurfaceLevel(0,&s_efb_depthColor_surface);
+ }
+ //create a one pixel texture to work as a buffer for peeking
+ hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_surface_Format,
+ D3DPOOL_DEFAULT, &s_efb_depthRead_texture, NULL);
+ CHECK(hr,"Create Depth Read texture");
+ if(s_efb_depthRead_texture)
+ {
+ s_efb_depthRead_texture->GetSurfaceLevel(0,&s_efb_depth_ReadBuffer);
+ }
+ //create an offscreen surface that we can lock to retrieve the data
+ hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_depth_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_depth_OffScreenReadBuffer, NULL );
+ CHECK(hr,"Create Depth offScreen Surface");
+
+ /*//depth format in prefered order
D3DFORMAT *DepthTexFormats = new D3DFORMAT[3];
DepthTexFormats[0] = D3DFMT_D32F_LOCKABLE;
DepthTexFormats[1] = D3DFMT_D16_LOCKABLE;
@@ -116,7 +165,7 @@ void Create() s_efb_depth_ReadBuffer = s_efb_depth_surface;
s_efb_depth_OffScreenReadBuffer = s_efb_depth_surface;
CHECK(hr,"CreateDepthStencilSurface");
- delete [] DepthTexFormats;
+ delete [] DepthTexFormats;*/
}
else
{
@@ -129,44 +178,51 @@ void Create() void Destroy()
{
- if(s_efb_depth_ReadBuffer)
- s_efb_depth_ReadBuffer->Release();
- s_efb_depth_ReadBuffer = NULL;
- if(s_efb_depth_OffScreenReadBuffer)
- s_efb_depth_OffScreenReadBuffer->Release();
+if(s_efb_depth_surface)
+s_efb_depth_surface->Release();
+s_efb_depth_surface=NULL;
- if(s_efb_depth_surface)
- s_efb_depth_surface->Release();
- s_efb_depth_surface = NULL;
-
- if(s_efb_depthBuffer_texture)
- s_efb_depthBuffer_texture->Release();
- s_efb_depthBuffer_texture=NULL;
+if(s_efb_depthColor_surface)
+s_efb_depthColor_surface->Release();
+s_efb_depthColor_surface=NULL;
- if(s_efb_depth_texture)
- s_efb_depth_texture->Release();
- s_efb_depth_texture = NULL;
+if(s_efb_color_surface)
+s_efb_color_surface->Release();
+s_efb_color_surface=NULL;
- if(s_efb_color_OffScreenReadBuffer )
- s_efb_color_OffScreenReadBuffer->Release();
- s_efb_color_OffScreenReadBuffer = NULL;
-
- if(s_efb_color_ReadBuffer )
- s_efb_color_ReadBuffer->Release();
- s_efb_color_ReadBuffer = NULL;
+if(s_efb_color_ReadBuffer)
+s_efb_color_ReadBuffer->Release();
+s_efb_color_ReadBuffer=NULL;
+
+if(s_efb_depth_ReadBuffer)
+s_efb_depth_ReadBuffer->Release();
+s_efb_depth_ReadBuffer=NULL;
+
+if(s_efb_color_OffScreenReadBuffer)
+s_efb_color_OffScreenReadBuffer->Release();
+s_efb_color_OffScreenReadBuffer=NULL;
+
+if(s_efb_depth_OffScreenReadBuffer)
+s_efb_depth_OffScreenReadBuffer->Release();
+s_efb_depth_OffScreenReadBuffer=NULL;
+
+if(s_efb_color_texture)
+ s_efb_color_texture->Release();
+s_efb_color_texture=NULL;
+
+if(s_efb_colorRead_texture)
+s_efb_colorRead_texture->Release();
+s_efb_colorRead_texture=NULL;
+
+if(s_efb_depth_texture)
+s_efb_depth_texture->Release();
+s_efb_depth_texture=NULL;
+
+if(s_efb_depthRead_texture)
+s_efb_depthRead_texture->Release();
+s_efb_depthRead_texture=NULL;
- if(s_efb_color_surface)
- s_efb_color_surface->Release();
- s_efb_color_surface = NULL;
-
- if(s_efb_colorBuffer_texture)
- s_efb_colorBuffer_texture->Release();
- s_efb_colorBuffer_texture = NULL;
-
- if(s_efb_color_texture)
- s_efb_color_texture->Release();
- s_efb_color_texture = NULL;
}
} // namespace
\ No newline at end of file |
