mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 13:05:46 -04:00
Common: Fix issues in utility classes for readbacks
This commit is contained in:
@ -14,7 +14,7 @@ StagingTexture::~StagingTexture()
|
||||
bool StagingTexture::Create(ID3D11Device* device, u32 width, u32 height, DXGI_FORMAT format, bool for_uploading)
|
||||
{
|
||||
CD3D11_TEXTURE2D_DESC desc(format, width, height, 1, 1, 0, for_uploading ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_STAGING,
|
||||
0, 1, 0, 0);
|
||||
for_uploading ? D3D11_CPU_ACCESS_WRITE : D3D11_CPU_ACCESS_READ, 1, 0, 0);
|
||||
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
const HRESULT tex_hr = device->CreateTexture2D(&desc, nullptr, texture.GetAddressOf());
|
||||
@ -54,6 +54,7 @@ void StagingTexture::Unmap(ID3D11DeviceContext* context)
|
||||
{
|
||||
Assert(IsMapped());
|
||||
context->Unmap(m_texture.Get(), 0);
|
||||
m_map = {};
|
||||
}
|
||||
|
||||
void StagingTexture::CopyToTexture(ID3D11DeviceContext* context, u32 src_x, u32 src_y, ID3D11Texture2D* dst_texture,
|
||||
@ -88,4 +89,4 @@ void StagingTexture::CopyFromTexture(ID3D11DeviceContext* context, ID3D11Texture
|
||||
context->CopySubresourceRegion(m_texture.Get(), 0, dst_x, dst_y, 0, src_texture, src_subresource, &box);
|
||||
}
|
||||
|
||||
} // namespace D3D
|
||||
} // namespace D3D11
|
@ -54,18 +54,18 @@ public:
|
||||
{
|
||||
const u8* src_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T));
|
||||
u8* dst_ptr = reinterpret_cast<u8*>(data);
|
||||
if (m_map.RowPitch != stride)
|
||||
if (m_map.RowPitch != (sizeof(T) * stride))
|
||||
{
|
||||
for (u32 row = 0; row < height; row++)
|
||||
{
|
||||
std::memcpy(dst_ptr, src_ptr, sizeof(T) * width);
|
||||
src_ptr += m_map.RowPitch;
|
||||
dst_ptr += stride;
|
||||
dst_ptr += sizeof(T) * stride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::memcpy(dst_ptr, src_ptr, stride * height);
|
||||
std::memcpy(dst_ptr, src_ptr, (sizeof(T) * stride) * height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,18 +74,18 @@ public:
|
||||
{
|
||||
const u8* src_ptr = reinterpret_cast<const u8*>(data);
|
||||
u8* dst_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T));
|
||||
if (m_map.RowPitch != stride)
|
||||
if (m_map.RowPitch != (sizeof(T) * stride))
|
||||
{
|
||||
for (u32 row = 0; row < height; row++)
|
||||
{
|
||||
std::memcpy(dst_ptr, src_ptr, sizeof(T) * width);
|
||||
src_ptr += stride;
|
||||
src_ptr += sizeof(T) * stride;
|
||||
dst_ptr += m_map.RowPitch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::memcpy(dst_ptr, src_ptr, stride * height);
|
||||
std::memcpy(dst_ptr, src_ptr, (sizeof(T) * stride) * height);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user