summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/TextureCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/D3D/TextureCache.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/TextureCache.cpp80
1 files changed, 33 insertions, 47 deletions
diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp
index aab90e2560..488bc3ecc0 100644
--- a/Source/Core/VideoBackends/D3D/TextureCache.cpp
+++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp
@@ -125,56 +125,46 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
bool isIntensity, bool scaleByHalf, unsigned int cbufid,
const float *colmat)
{
- if (type != TCET_EC_DYNAMIC || g_ActiveConfig.bCopyEFBToTexture)
- {
- g_renderer->ResetAPIState();
-
- // stretch picture with increased internal resolution
- const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)config.width, (float)config.height);
- D3D::context->RSSetViewports(1, &vp);
-
- // set transformation
- if (nullptr == efbcopycbuf[cbufid])
- {
- const D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(28 * sizeof(float), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DEFAULT);
- D3D11_SUBRESOURCE_DATA data;
- data.pSysMem = colmat;
- HRESULT hr = D3D::device->CreateBuffer(&cbdesc, &data, &efbcopycbuf[cbufid]);
- CHECK(SUCCEEDED(hr), "Create efb copy constant buffer %d", cbufid);
- D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopycbuf[cbufid], "a constant buffer used in TextureCache::CopyRenderTargetToTexture");
- }
- D3D::stateman->SetPixelConstants(efbcopycbuf[cbufid]);
+ g_renderer->ResetAPIState();
- const TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect);
- // TODO: try targetSource.asRECT();
- const D3D11_RECT sourcerect = CD3D11_RECT(targetSource.left, targetSource.top, targetSource.right, targetSource.bottom);
+ // stretch picture with increased internal resolution
+ const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, (float)config.width, (float)config.height);
+ D3D::context->RSSetViewports(1, &vp);
- // Use linear filtering if (bScaleByHalf), use point filtering otherwise
- if (scaleByHalf)
- D3D::SetLinearCopySampler();
- else
- D3D::SetPointCopySampler();
+ // set transformation
+ if (nullptr == efbcopycbuf[cbufid])
+ {
+ const D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(28 * sizeof(float), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DEFAULT);
+ D3D11_SUBRESOURCE_DATA data;
+ data.pSysMem = colmat;
+ HRESULT hr = D3D::device->CreateBuffer(&cbdesc, &data, &efbcopycbuf[cbufid]);
+ CHECK(SUCCEEDED(hr), "Create efb copy constant buffer %d", cbufid);
+ D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopycbuf[cbufid], "a constant buffer used in TextureCache::CopyRenderTargetToTexture");
+ }
+ D3D::stateman->SetPixelConstants(efbcopycbuf[cbufid]);
- // if texture is currently in use, it needs to be temporarily unset
- u32 textureSlotMask = D3D::stateman->UnsetTexture(texture->GetSRV());
- D3D::stateman->Apply();
+ const TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect);
+ // TODO: try targetSource.asRECT();
+ const D3D11_RECT sourcerect = CD3D11_RECT(targetSource.left, targetSource.top, targetSource.right, targetSource.bottom);
- D3D::context->OMSetRenderTargets(1, &texture->GetRTV(), nullptr);
+ // Use linear filtering if (bScaleByHalf), use point filtering otherwise
+ if (scaleByHalf)
+ D3D::SetLinearCopySampler();
+ else
+ D3D::SetPointCopySampler();
- // Create texture copy
- D3D::drawShadedTexQuad(
- (srcFormat == PEControl::Z24) ? FramebufferManager::GetEFBDepthTexture()->GetSRV() : FramebufferManager::GetEFBColorTexture()->GetSRV(),
- &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(),
- (srcFormat == PEControl::Z24) ? PixelShaderCache::GetDepthMatrixProgram(true) : PixelShaderCache::GetColorMatrixProgram(true),
- VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), GeometryShaderCache::GetCopyGeometryShader());
+ D3D::context->OMSetRenderTargets(1, &texture->GetRTV(), nullptr);
- D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV());
+ // Create texture copy
+ D3D::drawShadedTexQuad(
+ (srcFormat == PEControl::Z24) ? FramebufferManager::GetEFBDepthTexture()->GetSRV() : FramebufferManager::GetEFBColorTexture()->GetSRV(),
+ &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(),
+ (srcFormat == PEControl::Z24) ? PixelShaderCache::GetDepthMatrixProgram(true) : PixelShaderCache::GetColorMatrixProgram(true),
+ VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout(), GeometryShaderCache::GetCopyGeometryShader());
- g_renderer->RestoreAPIState();
+ D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV());
- // Restore old texture in all previously used slots, if any
- D3D::stateman->SetTextureByMask(textureSlotMask, texture->GetSRV());
- }
+ g_renderer->RestoreAPIState();
if (!g_ActiveConfig.bCopyEFBToTexture)
{
@@ -185,11 +175,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
size_in_bytes = (u32)encoded_size;
- // Mark texture entries in destination address range dynamic unless caching is enabled and the texture entry is up to date
- if (!g_ActiveConfig.bEFBCopyCacheEnable)
- TextureCache::MakeRangeDynamic(addr, (u32)encoded_size);
- else if (!TextureCache::Find(addr, hash))
- TextureCache::MakeRangeDynamic(addr, (u32)encoded_size);
+ TextureCache::MakeRangeDynamic(addr, (u32)encoded_size);
this->hash = hash;
}