summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/TextureCache.cpp
diff options
context:
space:
mode:
authorRodolfo Bogado <rodolfoosvaldobogado@gmail.com>2015-06-29 22:19:19 -0300
committerRodolfo Bogado <rodolfoosvaldobogado@gmail.com>2015-07-02 08:53:40 -0300
commitd8cd2c3252ab6f2ce6c1656b5eb194863e834f52 (patch)
treebfefa30392b15403d1792f83cd5ea8cd709a397e /Source/Core/VideoBackends/D3D/TextureCache.cpp
parent8d69c2b4b722e2c4f9f0496b9ff1912c1a10d9e1 (diff)
Implement scaled partial texture updates
Diffstat (limited to 'Source/Core/VideoBackends/D3D/TextureCache.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/TextureCache.cpp62
1 files changed, 59 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp
index 2c820849d5..de204fa2af 100644
--- a/Source/Core/VideoBackends/D3D/TextureCache.cpp
+++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp
@@ -77,11 +77,67 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
return saved_png;
}
-void TextureCache::TCacheEntry::DoPartialTextureUpdate(TCacheEntryBase* entry_, u32 x, u32 y)
+void TextureCache::TCacheEntry::CopyRectangleFromTexture(
+ const TCacheEntryBase* source,
+ const MathUtil::Rectangle<int> &srcrect,
+ const MathUtil::Rectangle<int> &dstrect)
{
- TCacheEntry* entry = (TCacheEntry*)entry_;
+ TCacheEntry* srcentry = (TCacheEntry*)source;
+ if (srcrect.GetWidth() == dstrect.GetWidth()
+ && srcrect.GetHeight() == dstrect.GetHeight())
+ {
+ const D3D11_BOX *psrcbox = nullptr;
+ D3D11_BOX srcbox;
+ if (srcrect.left != 0 || srcrect.top != 0)
+ {
+ srcbox.left = srcrect.left;
+ srcbox.top = srcrect.top;
+ srcbox.right = srcrect.right;
+ srcbox.bottom = srcrect.bottom;
+ psrcbox = &srcbox;
+ }
+ D3D::context->CopySubresourceRegion(
+ texture->GetTex(),
+ 0,
+ dstrect.left,
+ dstrect.top,
+ 0,
+ srcentry->texture->GetTex(),
+ 0,
+ psrcbox);
+ return;
+ }
+ else if (!config.rendertarget)
+ {
+ return;
+ }
+ g_renderer->ResetAPIState(); // reset any game specific settings
- D3D::context->CopySubresourceRegion(texture->GetTex(), 0, x , y , 0, entry->texture->GetTex(), 0, NULL);
+ const D3D11_VIEWPORT vp = CD3D11_VIEWPORT(
+ float(dstrect.left),
+ float(dstrect.top),
+ float(dstrect.GetWidth()),
+ float(dstrect.GetHeight()));
+
+ D3D::context->OMSetRenderTargets(1, &texture->GetRTV(), nullptr);
+ D3D::context->RSSetViewports(1, &vp);
+ D3D::SetLinearCopySampler();
+ D3D11_RECT srcRC;
+ srcRC.left = srcrect.left;
+ srcRC.right = srcrect.right;
+ srcRC.top = srcrect.top;
+ srcRC.bottom = srcrect.bottom;
+ D3D::drawShadedTexQuad(srcentry->texture->GetSRV(), &srcRC,
+ srcentry->config.width, srcentry->config.height,
+ PixelShaderCache::GetColorCopyProgram(false),
+ VertexShaderCache::GetSimpleVertexShader(),
+ VertexShaderCache::GetSimpleInputLayout(), nullptr, 1.0, 0);
+
+ D3D::context->OMSetRenderTargets(1,
+ &FramebufferManager::GetEFBColorTexture()->GetRTV(),
+ FramebufferManager::GetEFBDepthTexture()->GetDSV());
+
+ g_renderer->RestoreAPIState();
}
void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,