From d7d870435367b2a9eb2f5153c954b354efd98202 Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 29 Oct 2015 08:55:50 +0100 Subject: [PATCH] D3D-TextureEncoder: Remove TCache::Entry usage --- .../VideoBackends/D3D/PSTextureEncoder.cpp | 18 +++++++++--------- .../Core/VideoBackends/D3D/PSTextureEncoder.h | 6 +++--- Source/Core/VideoBackends/D3D/TextureCache.cpp | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index c337927ac9..b3209bef48 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -87,7 +87,7 @@ void PSTextureEncoder::Shutdown() SAFE_RELEASE(m_out); } -void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *texture_entry, +void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) { @@ -101,9 +101,9 @@ void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *text // Set up all the state for EFB encoding { - const u32 words_per_row = texture_entry->BytesPerRow() / sizeof(u32); + const u32 words_per_row = bytes_per_row / sizeof(u32); - D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, FLOAT(words_per_row), FLOAT(texture_entry->NumBlocksY())); + D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, FLOAT(words_per_row), FLOAT(num_blocks_y)); D3D::context->RSSetViewports(1, &vp); EFBRectangle fullSrcRect; @@ -125,7 +125,7 @@ void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *text EFBEncodeParams params; params.SrcLeft = srcRect.left; params.SrcTop = srcRect.top; - params.DestWidth = texture_entry->native_width; + params.DestWidth = native_width; params.ScaleFactor = scaleByHalf ? 2 : 1; D3D::context->UpdateSubresource(m_encodeParams, 0, nullptr, ¶ms, 0, 0); D3D::stateman->SetPixelConstants(m_encodeParams); @@ -140,12 +140,12 @@ void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *text targetRect.AsRECT(), Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), - SetStaticShader(texture_entry->format, srcFormat, isIntensity, scaleByHalf), + SetStaticShader(format, srcFormat, isIntensity, scaleByHalf), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); // Copy to staging buffer - D3D11_BOX srcBox = CD3D11_BOX(0, 0, 0, words_per_row, texture_entry->NumBlocksY(), 1); + D3D11_BOX srcBox = CD3D11_BOX(0, 0, 0, words_per_row, num_blocks_y, 1); D3D::context->CopySubresourceRegion(m_outStage, 0, 0, 0, 0, m_out, 0, &srcBox); // Transfer staging buffer to GameCube/Wii RAM @@ -154,11 +154,11 @@ void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *text CHECK(SUCCEEDED(hr), "map staging buffer (0x%x)", hr); u8* src = (u8*)map.pData; - u32 readStride = std::min(texture_entry->BytesPerRow(), map.RowPitch); - for (unsigned int y = 0; y < texture_entry->NumBlocksY(); ++y) + u32 readStride = std::min(bytes_per_row, map.RowPitch); + for (unsigned int y = 0; y < num_blocks_y; ++y) { memcpy(dst, src, readStride); - dst += texture_entry->memory_stride; + dst += memory_stride; src += map.RowPitch; } diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h index 40f49a0728..e82db8779e 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h @@ -31,9 +31,9 @@ public: void Init(); void Shutdown(); - void Encode(u8* dst, const TextureCacheBase::TCacheEntryBase* texture_entry, - PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, - bool isIntensity, bool scaleByHalf); + void Encode(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf); private: bool m_ready; diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index 1738a1f4d5..eab591c7ee 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -240,7 +240,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u8* dst, unsigned int dstFormat if (g_ActiveConfig.bSkipEFBCopyToRam) this->Zero(dst); else - g_encoder->Encode(dst, this, srcFormat, srcRect, isIntensity, scaleByHalf); + g_encoder->Encode(dst, format, native_width, BytesPerRow(), NumBlocksY(), memory_stride, srcFormat, srcRect, isIntensity, scaleByHalf); } const char palette_shader[] =