|
|
@@ -24,9 +24,6 @@
|
|
|
|
#include "PixelShaderCache.h"
|
|
|
|
#include "PixelShaderCache.h"
|
|
|
|
#include "VertexShaderCache.h"
|
|
|
|
#include "VertexShaderCache.h"
|
|
|
|
|
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
#define CHECK(cond, Message) if (!(cond)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: %s" , __FILE__, __LINE__, Message); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FramebufferManager FBManager;
|
|
|
|
FramebufferManager FBManager;
|
|
|
|
ID3D11SamplerState* copytoVirtualXFBsampler = NULL;
|
|
|
|
ID3D11SamplerState* copytoVirtualXFBsampler = NULL;
|
|
|
|
|
|
|
|
|
|
|
@@ -47,7 +44,7 @@ void FramebufferManager::Create()
|
|
|
|
|
|
|
|
|
|
|
|
// create framebuffer color texture
|
|
|
|
// create framebuffer color texture
|
|
|
|
m_efb.color_tex = D3DTexture2D::Create(target_width, target_height, (D3D11_BIND_FLAG)(D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE), D3D11_USAGE_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM);
|
|
|
|
m_efb.color_tex = D3DTexture2D::Create(target_width, target_height, (D3D11_BIND_FLAG)(D3D11_BIND_RENDER_TARGET|D3D11_BIND_SHADER_RESOURCE), D3D11_USAGE_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM);
|
|
|
|
CHECK(m_efb.color_tex != NULL, "create EFB color texture");
|
|
|
|
CHECK(m_efb.color_tex!=NULL, "create EFB color texture (size: %dx%d)", target_width, target_height);
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetTex(), "EFB color texture");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetTex(), "EFB color texture");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetRTV(), "EFB color texture render target view");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetRTV(), "EFB color texture render target view");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetSRV(), "EFB color texture shader resource view");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_tex->GetSRV(), "EFB color texture shader resource view");
|
|
|
@@ -55,14 +52,14 @@ void FramebufferManager::Create()
|
|
|
|
// create a staging texture for Renderer::AccessEFB
|
|
|
|
// create a staging texture for Renderer::AccessEFB
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_WRITE|D3D11_CPU_ACCESS_READ);
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_WRITE|D3D11_CPU_ACCESS_READ);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.color_staging_buf);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.color_staging_buf);
|
|
|
|
CHECK(hr==S_OK, "create EFB color staging buffer");
|
|
|
|
CHECK(hr==S_OK, "create EFB color staging buffer (hr=%#x)", hr);
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_staging_buf, "EFB color staging texture (used for Renderer::AccessEFB)");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.color_staging_buf, "EFB color staging texture (used for Renderer::AccessEFB)");
|
|
|
|
|
|
|
|
|
|
|
|
// EFB depth buffer
|
|
|
|
// EFB depth buffer
|
|
|
|
// TODO: Only bind as shader resource if EFB access enabled
|
|
|
|
// TODO: Only bind as shader resource if EFB access enabled
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R24G8_TYPELESS, target_width, target_height, 1, 1, D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE);
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R24G8_TYPELESS, target_width, target_height, 1, 1, D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf);
|
|
|
|
CHECK(hr==S_OK, "create EFB depth texture");
|
|
|
|
CHECK(hr==S_OK, "create EFB depth texture (size: %dx%d; hr=%#x)", target_width, target_height, hr);
|
|
|
|
m_efb.depth_tex = new D3DTexture2D(buf, (D3D11_BIND_FLAG)(D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE), DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_D24_UNORM_S8_UINT);
|
|
|
|
m_efb.depth_tex = new D3DTexture2D(buf, (D3D11_BIND_FLAG)(D3D11_BIND_DEPTH_STENCIL|D3D11_BIND_SHADER_RESOURCE), DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_D24_UNORM_S8_UINT);
|
|
|
|
buf->Release();
|
|
|
|
buf->Release();
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_tex->GetTex(), "EFB depth texture");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_tex->GetTex(), "EFB depth texture");
|
|
|
@@ -72,7 +69,7 @@ void FramebufferManager::Create()
|
|
|
|
// render target for depth buffer access in Renderer::AccessEFB
|
|
|
|
// render target for depth buffer access in Renderer::AccessEFB
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, D3D11_BIND_RENDER_TARGET);
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, D3D11_BIND_RENDER_TARGET);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &buf);
|
|
|
|
CHECK(hr==S_OK, "create EFB depth read texture");
|
|
|
|
CHECK(hr==S_OK, "create EFB depth read texture (hr=%#x)", hr);
|
|
|
|
m_efb.depth_read_texture = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET);
|
|
|
|
m_efb.depth_read_texture = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET);
|
|
|
|
buf->Release();
|
|
|
|
buf->Release();
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_read_texture->GetTex(), "EFB depth read texture (used in Renderer::AccessEFB)");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_read_texture->GetTex(), "EFB depth read texture (used in Renderer::AccessEFB)");
|
|
|
@@ -81,7 +78,7 @@ void FramebufferManager::Create()
|
|
|
|
// staging texture to which we copy the data from m_efb.depth_read_texture
|
|
|
|
// staging texture to which we copy the data from m_efb.depth_read_texture
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE);
|
|
|
|
texdesc = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R32_FLOAT, 4, 4, 1, 1, 0, D3D11_USAGE_STAGING, D3D11_CPU_ACCESS_READ|D3D11_CPU_ACCESS_WRITE);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.depth_staging_buf);
|
|
|
|
hr = D3D::device->CreateTexture2D(&texdesc, NULL, &m_efb.depth_staging_buf);
|
|
|
|
CHECK(hr==S_OK, "create EFB depth staging buffer");
|
|
|
|
CHECK(hr==S_OK, "create EFB depth staging buffer (hr=%#x)", hr);
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_staging_buf, "EFB depth staging texture (used for Renderer::AccessEFB)");
|
|
|
|
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_efb.depth_staging_buf, "EFB depth staging texture (used for Renderer::AccessEFB)");
|
|
|
|
|
|
|
|
|
|
|
|
// sampler state for FramebufferManager::copyToVirtualXFB
|
|
|
|
// sampler state for FramebufferManager::copyToVirtualXFB
|
|
|
|