1#include "backend_base.h"
2#include <base/system.h>
3
4bool CCommandProcessorFragment_GLBase::Texture2DTo3D(uint8_t *pImageBuffer, int ImageWidth, int ImageHeight, size_t PixelSize, int SplitCountWidth, int SplitCountHeight, uint8_t *pTarget3DImageData, int &Target3DImageWidth, int &Target3DImageHeight)
5{
6 Target3DImageWidth = ImageWidth / SplitCountWidth;
7 Target3DImageHeight = ImageHeight / SplitCountHeight;
8
9 const size_t FullImageWidth = (size_t)ImageWidth * PixelSize;
10
11 for(int Y = 0; Y < SplitCountHeight; ++Y)
12 {
13 for(int X = 0; X < SplitCountWidth; ++X)
14 {
15 for(int Y3D = 0; Y3D < Target3DImageHeight; ++Y3D)
16 {
17 int DepthIndex = X + Y * SplitCountWidth;
18
19 size_t TargetImageFullWidth = (size_t)Target3DImageWidth * PixelSize;
20 size_t TargetImageFullSize = TargetImageFullWidth * Target3DImageHeight;
21 ptrdiff_t ImageOffset = (ptrdiff_t)(((size_t)Y * FullImageWidth * (size_t)Target3DImageHeight) + ((size_t)Y3D * FullImageWidth) + ((size_t)X * TargetImageFullWidth));
22 ptrdiff_t TargetImageOffset = (ptrdiff_t)(TargetImageFullSize * (size_t)DepthIndex + ((size_t)Y3D * TargetImageFullWidth));
23 mem_copy(dest: pTarget3DImageData + TargetImageOffset, source: pImageBuffer + ImageOffset, size: TargetImageFullWidth);
24 }
25 }
26 }
27
28 return true;
29}
30