Fix GPUTexture::GetData to properly handle volume textures
This commit is contained in:
@@ -169,6 +169,38 @@ bool TextureMipData::GetPixels(Array<Color>& pixels, int32 width, int32 height,
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextureMipData::Copy(void* data, uint32 dataRowPitch, uint32 dataDepthPitch, uint32 dataDepthSlices, uint32 targetRowPitch)
|
||||
{
|
||||
// Check if target row pitch is the same
|
||||
if (targetRowPitch == dataRowPitch || targetRowPitch == 0)
|
||||
{
|
||||
Lines = dataDepthPitch / dataRowPitch;
|
||||
DepthPitch = dataDepthPitch;
|
||||
RowPitch = dataRowPitch;
|
||||
|
||||
// Single memory copy
|
||||
Data.Copy((byte*)data, dataDepthPitch * dataDepthSlices);
|
||||
}
|
||||
else
|
||||
{
|
||||
Lines = dataDepthPitch / dataRowPitch;
|
||||
DepthPitch = targetRowPitch * Lines;
|
||||
RowPitch = targetRowPitch;
|
||||
|
||||
// Convert row by row
|
||||
Data.Allocate(DepthPitch * dataDepthSlices);
|
||||
for (uint32 depth = 0; depth < dataDepthSlices; depth++)
|
||||
{
|
||||
byte* src = (byte*)data + depth * dataDepthPitch;
|
||||
byte* dst = Data.Get() + depth * DepthPitch;
|
||||
for (uint32 row = 0; row < Lines; row++)
|
||||
{
|
||||
Platform::MemoryCopy(dst + row * RowPitch, src + row * dataRowPitch, RowPitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_BINARY_ASSET_ABSTRACT(TextureBase, "FlaxEngine.TextureBase");
|
||||
|
||||
TextureBase::TextureBase(const SpawnParams& params, const AssetInfo* info)
|
||||
|
||||
Reference in New Issue
Block a user