D3D: Remove redundant cast, move pitch calculation to caller
This commit is contained in:
parent
6be4608a0d
commit
d1b132731d
|
@ -15,9 +15,8 @@ namespace DX11
|
||||||
namespace D3D
|
namespace D3D
|
||||||
{
|
{
|
||||||
|
|
||||||
void ReplaceRGBATexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int width, unsigned int height, unsigned int expanded_width, unsigned int level, D3D11_USAGE usage)
|
void ReplaceRGBATexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int width, unsigned int height, unsigned int src_pitch, unsigned int level, D3D11_USAGE usage)
|
||||||
{
|
{
|
||||||
unsigned int src_pitch = 4 * expanded_width;
|
|
||||||
if (usage == D3D11_USAGE_DYNAMIC || usage == D3D11_USAGE_STAGING)
|
if (usage == D3D11_USAGE_DYNAMIC || usage == D3D11_USAGE_STAGING)
|
||||||
{
|
{
|
||||||
D3D11_MAPPED_SUBRESOURCE map;
|
D3D11_MAPPED_SUBRESOURCE map;
|
||||||
|
@ -32,7 +31,7 @@ void ReplaceRGBATexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned
|
||||||
// pitch to what the driver returns, so copy whichever is smaller.
|
// pitch to what the driver returns, so copy whichever is smaller.
|
||||||
unsigned int copy_size = std::min(src_pitch, map.RowPitch);
|
unsigned int copy_size = std::min(src_pitch, map.RowPitch);
|
||||||
for (unsigned int y = 0; y < height; ++y)
|
for (unsigned int y = 0; y < height; ++y)
|
||||||
memcpy((u8*)map.pData + y * map.RowPitch, (u8*)buffer + y * src_pitch, copy_size);
|
memcpy((u8*)map.pData + y * map.RowPitch, buffer + y * src_pitch, copy_size);
|
||||||
}
|
}
|
||||||
D3D::context->Unmap(pTexture, level);
|
D3D::context->Unmap(pTexture, level);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace DX11
|
||||||
|
|
||||||
namespace D3D
|
namespace D3D
|
||||||
{
|
{
|
||||||
void ReplaceRGBATexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int width, unsigned int height, unsigned int expanded_width, unsigned int level, D3D11_USAGE usage);
|
void ReplaceRGBATexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int width, unsigned int height, unsigned int src_pitch, unsigned int level, D3D11_USAGE usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
class D3DTexture2D
|
class D3DTexture2D
|
||||||
|
|
|
@ -142,7 +142,8 @@ void TextureCache::TCacheEntry::CopyRectangleFromTexture(
|
||||||
void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||||
unsigned int expanded_width, unsigned int level)
|
unsigned int expanded_width, unsigned int level)
|
||||||
{
|
{
|
||||||
D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage);
|
unsigned int src_pitch = 4 * expanded_width;
|
||||||
|
D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, src_pitch, level, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config)
|
TextureCacheBase::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConfig& config)
|
||||||
|
|
Loading…
Reference in New Issue