mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
20a74db5de
commit
5abbdcb0f4
|
@ -2878,18 +2878,12 @@ begin
|
|||
m_element_table :=getElementTableXYZ(m_bitsPerElement,m_microTileMode,m_arrayMode);
|
||||
end;
|
||||
|
||||
Function Get1dThinAlignWidth(bpp,width:Ptruint):Ptruint; inline;
|
||||
var
|
||||
align_m:Ptruint;
|
||||
begin
|
||||
align_m:=(32 div bpp)-1;
|
||||
Result:=(width+align_m) and (not align_m);
|
||||
end;
|
||||
|
||||
procedure Tiler1d.init_size_2d(width,height:DWORD);
|
||||
begin
|
||||
m_paddedWidth :=Get1dThinAlignWidth(m_bytePerElement,width);
|
||||
m_paddedHeight:=(height+7) and (not 7);
|
||||
//m_paddedWidth :=(width+7) and (not 7);
|
||||
|
||||
//m_paddedWidth :=Get1dThinAlignWidth(m_bytePerElement,width);
|
||||
//m_paddedHeight:=(height+7) and (not 7);
|
||||
m_paddedDepth :=1;
|
||||
|
||||
m_linearWidth :=width;
|
||||
|
@ -2898,13 +2892,16 @@ begin
|
|||
|
||||
if (m_isBlockCompressed<>0) then
|
||||
begin
|
||||
m_paddedWidth :=(m_paddedWidth +3) shr 2;
|
||||
m_paddedHeight:=(m_paddedHeight+3) shr 2;
|
||||
//m_paddedWidth :=(m_paddedWidth +3) shr 2;
|
||||
//m_paddedHeight:=(m_paddedHeight+3) shr 2;
|
||||
//
|
||||
m_linearWidth :=(m_linearWidth +3) shr 2;
|
||||
m_linearHeight:=(m_linearHeight+3) shr 2;
|
||||
end;
|
||||
|
||||
m_paddedWidth :=(m_linearWidth +7) and (not 7);
|
||||
m_paddedHeight:=(m_linearHeight+7) and (not 7);
|
||||
|
||||
m_linearSizeBytes:=m_linearWidth*m_linearHeight*m_linearDepth*m_bytePerElement;
|
||||
m_tiledSizeBytes :=m_paddedWidth*m_paddedHeight*m_paddedDepth*m_bytePerElement;
|
||||
|
||||
|
@ -2912,6 +2909,7 @@ begin
|
|||
|
||||
m_tilesPerRow :=m_paddedWidth div kMicroTileWidth;
|
||||
m_tilesPerSlice :=m_tilesPerRow * (m_paddedHeight div kMicroTileHeight);
|
||||
|
||||
end;
|
||||
|
||||
function Tiler1d.getTiledElementBitOffset(var outTiledBitOffset:QWORD;x,y,z:DWORD):integer;
|
||||
|
|
|
@ -116,9 +116,11 @@ type
|
|||
end;
|
||||
|
||||
TvImageKeyParams=bitpacked record
|
||||
itype :0..3; //2 TVkImageType 0..2
|
||||
cube :0..1; //1 VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
|
||||
reserved :0..31; //5
|
||||
itype :0..3; //2 TVkImageType 0..2
|
||||
cube :0..1; //1 VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
|
||||
array_2d :0..1; //1 VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT
|
||||
pow2pad :0..1; //1
|
||||
reserved :0..7; //3
|
||||
tiling :TvTiling;
|
||||
samples :Byte; //TVkSampleCountFlagBits 1..4 (3)
|
||||
mipLevels :Byte; //(0..15) (4)
|
||||
|
@ -126,6 +128,7 @@ type
|
|||
height :Word; //(0..16383)
|
||||
depth :Word; //(0..8192)
|
||||
arrayLayers:Word; //(0..16383)
|
||||
pitch :Word; //(0..16383)
|
||||
pad_width :Word;
|
||||
pad_height :Word;
|
||||
end;
|
||||
|
|
|
@ -469,7 +469,9 @@ function TvImage2.GetImageInfo:TVkImageCreateInfo;
|
|||
begin
|
||||
Result:=Default(TVkImageCreateInfo);
|
||||
Result.sType :=VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
Result.flags :=GET_VK_IMAGE_CREATE_DEFAULT(key.cformat) or (key.params.cube)*ord(VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT);
|
||||
Result.flags :=GET_VK_IMAGE_CREATE_DEFAULT(key.cformat) or
|
||||
(key.params.cube )*ord(VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) or
|
||||
(key.params.array_2d)*ord(VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT);
|
||||
Result.imageType :=TVkImageType(key.params.itype);
|
||||
Result.format :=key.cformat;
|
||||
Result.extent.Create(key.params.width,key.params.height,key.params.depth);
|
||||
|
@ -482,7 +484,7 @@ begin
|
|||
|
||||
if (key.params.cube<>0) then
|
||||
begin
|
||||
Assert(key.params.arrayLayers=6,'VK_IMAGE_VIEW_TYPE_CUBE layerCount must be 6');
|
||||
Assert((key.params.arrayLayers mod 6)=0,'CUBE: layerCount must be a multiple of 6');
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -537,9 +539,16 @@ begin
|
|||
cinfo.subresourceRange.baseArrayLayer:=F.base_array;
|
||||
cinfo.subresourceRange.layerCount :=F.last_array-F.base_array+1;
|
||||
|
||||
if (cinfo.viewType=VK_IMAGE_VIEW_TYPE_CUBE) then
|
||||
begin
|
||||
Assert(cinfo.subresourceRange.layerCount=6,'VK_IMAGE_VIEW_TYPE_CUBE layerCount must be 6');
|
||||
case cinfo.viewType of
|
||||
VK_IMAGE_VIEW_TYPE_CUBE:
|
||||
begin
|
||||
Assert(cinfo.subresourceRange.layerCount=6,'VK_IMAGE_VIEW_TYPE_CUBE: layerCount must be 6');
|
||||
end;
|
||||
VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
|
||||
begin
|
||||
Assert((cinfo.subresourceRange.layerCount mod 6)=0,'VK_IMAGE_VIEW_TYPE_CUBE_ARRAY: layerCount must be a multiple of 6');
|
||||
end;
|
||||
else;
|
||||
end;
|
||||
|
||||
cinfo.format:=vkFixFormatSupport(cinfo.format,VK_IMAGE_TILING_OPTIMAL,usage);
|
||||
|
@ -638,24 +647,22 @@ begin
|
|||
end;
|
||||
VK_IMAGE_TYPE_2D:
|
||||
begin
|
||||
if (key.params.arrayLayers>1) then
|
||||
if (key.params.cube<>0) then
|
||||
begin
|
||||
if (key.params.cube<>0) then
|
||||
if (key.params.arrayLayers>6) then
|
||||
begin
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_CUBE_ARRAY);
|
||||
end else
|
||||
begin
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_2D_ARRAY);
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_CUBE);
|
||||
end;
|
||||
end else
|
||||
if (key.params.array_2d<>0) then
|
||||
begin
|
||||
if (key.params.cube<>0) then
|
||||
begin
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_CUBE);
|
||||
end else
|
||||
begin
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_2D);
|
||||
end;
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_2D_ARRAY);
|
||||
end else
|
||||
begin
|
||||
fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_2D);
|
||||
end;
|
||||
end;
|
||||
VK_IMAGE_TYPE_3D:fkey.vtype:=ord(VK_IMAGE_VIEW_TYPE_3D);
|
||||
|
|
|
@ -70,9 +70,11 @@ begin
|
|||
|
||||
m_slice:=m_padwidth*
|
||||
m_padheight*
|
||||
key.params.depth*
|
||||
key.params.arrayLayers*
|
||||
m_bytePerElement;
|
||||
|
||||
//m_slice:=(m_slice+255) and (not Ptruint(255));
|
||||
//64?
|
||||
|
||||
Result:=Result+m_slice;
|
||||
|
||||
|
@ -81,9 +83,6 @@ begin
|
|||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
|
||||
Result:=Result*
|
||||
key.params.depth*
|
||||
key.params.arrayLayers;
|
||||
end;
|
||||
|
||||
Function GetLinearAlignSize(const key:TvImageKey):Ptruint;
|
||||
|
@ -91,35 +90,53 @@ begin
|
|||
Result:=GetLinearSize(key,true);
|
||||
end;
|
||||
|
||||
Function Get1dThinAlignWidth(bpp,width:Ptruint):Ptruint; inline;
|
||||
var
|
||||
align_m:Ptruint;
|
||||
function nextPowerOfTwo(x:Ptruint):Ptruint; inline;
|
||||
begin
|
||||
align_m:=(32 div bpp)-1;
|
||||
Result:=(width+align_m) and (not align_m);
|
||||
x:=(x-1);
|
||||
x:=x or (x shr 1);
|
||||
x:=x or (x shr 2);
|
||||
x:=x or (x shr 4);
|
||||
x:=x or (x shr 8);
|
||||
x:=x or (x shr 16);
|
||||
x:=x or (x shr 32);
|
||||
Result:=(x+1);
|
||||
end;
|
||||
|
||||
Function Get1dThinSize(const key:TvImageKey):Ptruint;
|
||||
var
|
||||
m_bytePerElement:Ptruint;
|
||||
m_level,m_width,m_height:Ptruint;
|
||||
m_padwidth,m_padheight:Ptruint;
|
||||
m_padwidth :Ptruint;
|
||||
m_padheight :Ptruint;
|
||||
m_depth :Ptruint;
|
||||
m_arrayLayers:Ptruint;
|
||||
m_slice:Ptruint;
|
||||
begin
|
||||
Assert(key.params.samples<=1,'key.params.samples>1');
|
||||
|
||||
m_bytePerElement:=getFormatSize(key.cformat);
|
||||
|
||||
m_level :=key.params.mipLevels;
|
||||
m_width :=key.params.width;
|
||||
m_height:=key.params.height;
|
||||
m_level :=key.params.mipLevels;
|
||||
//
|
||||
m_width :=key.params.width;
|
||||
m_height :=key.params.height;
|
||||
m_depth :=key.params.depth;
|
||||
m_arrayLayers:=key.params.arrayLayers;
|
||||
|
||||
if (key.params.pow2pad<>0) then
|
||||
begin
|
||||
m_width :=nextPowerOfTwo(m_width);
|
||||
m_height :=nextPowerOfTwo(m_height);
|
||||
m_depth :=nextPowerOfTwo(m_depth);
|
||||
m_arrayLayers:=nextPowerOfTwo(m_arrayLayers);
|
||||
end;
|
||||
|
||||
Result:=0;
|
||||
|
||||
while (m_level>0) do
|
||||
begin
|
||||
m_padwidth :=Get1dThinAlignWidth(m_bytePerElement,m_width);
|
||||
m_padheight:=(m_height+7) and (not 7);
|
||||
m_padwidth :=m_width;
|
||||
m_padheight:=m_height;
|
||||
|
||||
if IsTexelFormat(key.cformat) then
|
||||
begin
|
||||
|
@ -127,11 +144,16 @@ begin
|
|||
m_padheight:=(m_padheight+3) shr 2;
|
||||
end;
|
||||
|
||||
m_padwidth :=(m_padwidth +7) and (not 7);
|
||||
m_padheight:=(m_padheight+7) and (not 7);
|
||||
|
||||
m_slice:=m_padwidth*
|
||||
m_padheight*
|
||||
m_depth*
|
||||
m_arrayLayers*
|
||||
m_bytePerElement;
|
||||
|
||||
//m_slice:=(m_slice+255) and (not Ptruint(255));
|
||||
m_slice:=(m_slice+255) and (not Ptruint(255));
|
||||
|
||||
Result:=Result+m_slice;
|
||||
|
||||
|
@ -140,11 +162,6 @@ begin
|
|||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
|
||||
//Result:=(Result+255) and (not Ptruint(255));
|
||||
|
||||
Result:=Result*
|
||||
key.params.depth*
|
||||
key.params.arrayLayers;
|
||||
end;
|
||||
|
||||
function AlignDw(addr:PtrUInt;alignment:PtrUInt):PtrUInt; inline;
|
||||
|
@ -257,28 +274,6 @@ begin
|
|||
FileClose(F);
|
||||
end;
|
||||
|
||||
Procedure copy_1dThin(var tiler:Tiler1d;src,dst:Pointer);
|
||||
var
|
||||
m_bytePerElement:Ptruint;
|
||||
m_slice_size:Ptruint;
|
||||
i,x,y,z:QWORD;
|
||||
pSrc,pDst:Pointer;
|
||||
begin
|
||||
m_bytePerElement:=tiler.m_bitsPerElement div 8;
|
||||
m_slice_size:=(tiler.m_linearWidth*tiler.m_linearHeight);
|
||||
//
|
||||
For z:=0 to tiler.m_linearDepth-1 do
|
||||
For y:=0 to tiler.m_linearHeight-1 do
|
||||
For x:=0 to tiler.m_linearWidth-1 do
|
||||
begin
|
||||
i:=0;
|
||||
tiler.getTiledElementByteOffset(i,x,y,z);
|
||||
pSrc:=@PByte(src)[i];
|
||||
pDst:=@PByte(dst)[(z*m_slice_size+y*tiler.m_linearWidth+x)*m_bytePerElement];
|
||||
Move(pSrc^,pDst^,m_bytePerElement);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure _Copy_Linear(cmd:TvCustomCmdBuffer;buf:TvTempBuffer;image:TvCustomImage2);
|
||||
var
|
||||
BufferImageCopy:TVkBufferImageCopy;
|
||||
|
@ -325,49 +320,52 @@ begin
|
|||
|
||||
m_offset:=0;
|
||||
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
//mips
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
|
||||
while (m_level>0) do
|
||||
begin
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
|
||||
while (m_level>0) do
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
//array
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
begin
|
||||
Assert((m_offset and 3)=0,'align by 4');
|
||||
BufferImageCopy.bufferOffset:=m_offset;
|
||||
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
|
||||
BufferImageCopyA[b]:=BufferImageCopy;
|
||||
Inc(b);
|
||||
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
m_offset:=m_offset+m_slice;
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//array
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//mips
|
||||
|
||||
cmd.CopyBufferToImage(buf.FHandle,
|
||||
image.FHandle,
|
||||
|
@ -378,6 +376,28 @@ begin
|
|||
|
||||
end;
|
||||
|
||||
Procedure copy_1dThin(var tiler:Tiler1d;src,dst:Pointer);
|
||||
var
|
||||
m_bytePerElement:Ptruint;
|
||||
m_slice_size:Ptruint;
|
||||
i,x,y,z:QWORD;
|
||||
pSrc,pDst:Pointer;
|
||||
begin
|
||||
m_bytePerElement:=tiler.m_bytePerElement;
|
||||
m_slice_size:=(tiler.m_linearWidth*tiler.m_linearHeight);
|
||||
//
|
||||
For z:=0 to tiler.m_linearDepth-1 do
|
||||
For y:=0 to tiler.m_linearHeight-1 do
|
||||
For x:=0 to tiler.m_linearWidth-1 do
|
||||
begin
|
||||
i:=0;
|
||||
tiler.getTiledElementByteOffset(i,x,y,z);
|
||||
pSrc:=@PByte(src)[i];
|
||||
pDst:=@PByte(dst)[(z*m_slice_size+y*tiler.m_linearWidth+x)*m_bytePerElement];
|
||||
Move(pSrc^,pDst^,m_bytePerElement);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure load_1dThin(cmd:TvCustomCmdBuffer;image:TvCustomImage2);
|
||||
var
|
||||
buf:TvTempBuffer;
|
||||
|
@ -396,6 +416,8 @@ var
|
|||
|
||||
src:Pointer;
|
||||
dst:Pointer;
|
||||
|
||||
a:Ptruint;
|
||||
begin
|
||||
Assert(image.key.params.samples<=1,'image.key.params.samples>1');
|
||||
|
||||
|
@ -434,44 +456,75 @@ begin
|
|||
|
||||
//TvBuffer
|
||||
|
||||
//mips
|
||||
m_level :=image.key.params.mipLevels;
|
||||
//
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
|
||||
if (image.key.params.pow2pad<>0) then
|
||||
begin
|
||||
m_width :=nextPowerOfTwo(m_width);
|
||||
m_height:=nextPowerOfTwo(m_height);
|
||||
end;
|
||||
|
||||
src:=image.key.addr;
|
||||
|
||||
while (m_level>0) do
|
||||
begin
|
||||
tiler.init_size_2d(m_width,m_height);
|
||||
|
||||
//
|
||||
|
||||
if (ptruint(dst-m_base)+tiler.m_linearSizeBytes)>m_full_linear_size then
|
||||
//array
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
begin
|
||||
Writeln(ptruint(dst-m_base)+tiler.m_linearSizeBytes,'>',m_full_linear_size);
|
||||
Assert(false);
|
||||
|
||||
if (ptruint(dst-m_base)+tiler.m_linearSizeBytes)>m_full_linear_size then
|
||||
begin
|
||||
Writeln(ptruint(dst-m_base)+tiler.m_linearSizeBytes,'>',m_full_linear_size);
|
||||
Assert(false);
|
||||
end;
|
||||
|
||||
//x,y,z
|
||||
copy_1dThin(tiler,src,dst);
|
||||
//x,y,z
|
||||
|
||||
{
|
||||
SaveToTGA('shader_dump\texture_a'+IntToStr(a)+
|
||||
'_mip'+IntToStr(m_level)+
|
||||
'_'+IntToStr(m_width)+
|
||||
'x'+IntToStr(m_height)+
|
||||
'.tga',
|
||||
dst,
|
||||
tiler.m_linearWidth,
|
||||
tiler.m_linearHeight,
|
||||
tiler.m_bitsPerElement);
|
||||
}
|
||||
|
||||
src:=src+tiler.m_tiledSizeBytes;
|
||||
dst:=dst+tiler.m_linearSizeBytes;
|
||||
|
||||
end;
|
||||
//array
|
||||
|
||||
if (image.key.params.pow2pad<>0) then
|
||||
begin
|
||||
a:=nextPowerOfTwo(image.key.params.arrayLayers)-image.key.params.arrayLayers;
|
||||
|
||||
src:=src+tiler.m_tiledSizeBytes*a;
|
||||
end;
|
||||
|
||||
copy_1dThin(tiler,src,dst);
|
||||
//Writeln('nextPowerOfTwo =',nextPowerOfTwo(image.key.params.arrayLayers));
|
||||
|
||||
{
|
||||
SaveToTGA('shader_dump\texture_mip'+IntToStr(m_level)+
|
||||
'_'+IntToStr(m_width)+
|
||||
'x'+IntToStr(m_height)+
|
||||
'.tga',
|
||||
dst,
|
||||
tiler.m_linearWidth,
|
||||
tiler.m_linearHeight,
|
||||
tiler.m_bitsPerElement);
|
||||
}
|
||||
|
||||
src:=src+tiler.m_tiledSizeBytes;
|
||||
dst:=dst+tiler.m_linearSizeBytes;
|
||||
src:=Pointer((qword(src)+255) and (not 255));
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//mips
|
||||
|
||||
Writeln('size1=',(src-image.key.addr));
|
||||
Writeln('size2=',Get1dThinSize(image.key));
|
||||
|
||||
vkUnmapMemory(Device.FHandle,buf.FBind.FMemory.FHandle);
|
||||
//FreeMem(m_base);
|
||||
|
@ -530,54 +583,57 @@ begin
|
|||
SetLength(BufferImageCopyA,image.key.params.arrayLayers*image.key.params.depth*image.key.params.mipLevels);
|
||||
b:=0;
|
||||
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
//mips
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
|
||||
while (m_level>0) do
|
||||
begin
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
|
||||
while (m_level>0) do
|
||||
if (image.key.params.tiling.idx=8) then
|
||||
begin
|
||||
BufferImageCopy.bufferRowLength:=GetLinearAlignWidth(m_bytePerElement,m_width);
|
||||
end;
|
||||
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
//array
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
begin
|
||||
Assert((m_offset and 3)=0,'align by 4');
|
||||
BufferImageCopy.bufferOffset:=m_offset;
|
||||
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
|
||||
if (image.key.params.tiling.idx=8) then
|
||||
begin
|
||||
BufferImageCopy.bufferRowLength:=GetLinearAlignWidth(m_bytePerElement,m_width);
|
||||
end;
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
|
||||
BufferImageCopyA[b]:=BufferImageCopy;
|
||||
Inc(b);
|
||||
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
m_offset:=m_offset+m_slice;
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//array
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//mips
|
||||
|
||||
cmd.CopyBufferToImage(buf.FHandle,
|
||||
image.FHandle,
|
||||
|
@ -639,54 +695,57 @@ begin
|
|||
SetLength(BufferImageCopyA,image.key.params.arrayLayers*image.key.params.depth*image.key.params.mipLevels);
|
||||
b:=0;
|
||||
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
//mips
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
|
||||
while (m_level>0) do
|
||||
begin
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
m_level :=image.key.params.mipLevels;
|
||||
m_width :=image.key.params.width;
|
||||
m_height:=image.key.params.height;
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
|
||||
while (m_level>0) do
|
||||
if (image.key.params.tiling.idx=8) then
|
||||
begin
|
||||
BufferImageCopy.bufferRowLength:=GetLinearAlignWidth(m_bytePerElement,m_width);
|
||||
end;
|
||||
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
//array
|
||||
for a:=0 to image.key.params.arrayLayers-1 do
|
||||
for d:=0 to image.key.params.depth-1 do
|
||||
begin
|
||||
Assert((m_offset and 3)=0,'align by 4');
|
||||
BufferImageCopy.bufferOffset:=m_offset;
|
||||
|
||||
BufferImageCopy.imageSubresource.mipLevel:=image.key.params.mipLevels-m_level;
|
||||
|
||||
BufferImageCopy.imageExtent.width :=m_width;
|
||||
BufferImageCopy.imageExtent.height:=m_height;
|
||||
|
||||
if (image.key.params.tiling.idx=8) then
|
||||
begin
|
||||
BufferImageCopy.bufferRowLength:=GetLinearAlignWidth(m_bytePerElement,m_width);
|
||||
end;
|
||||
BufferImageCopy.imageSubresource.baseArrayLayer:=a;
|
||||
BufferImageCopy.imageOffset.z:=d;
|
||||
|
||||
BufferImageCopyA[b]:=BufferImageCopy;
|
||||
Inc(b);
|
||||
|
||||
if IsTexelFormat(image.key.cformat) then
|
||||
begin
|
||||
m_padwidth :=(m_width +3) shr 2;
|
||||
m_padheight:=(m_height+3) shr 2;
|
||||
end else
|
||||
begin
|
||||
m_padwidth :=m_width ;
|
||||
m_padheight:=m_height;
|
||||
end;
|
||||
|
||||
m_slice:=m_padwidth*m_padheight*m_bytePerElement;
|
||||
|
||||
m_offset:=m_offset+m_slice;
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//array
|
||||
|
||||
Dec(m_level);
|
||||
m_width :=Max(1,m_width shr 1);
|
||||
m_height:=Max(1,m_height shr 1);
|
||||
end;
|
||||
//mips
|
||||
|
||||
cmd.CopyImageToBuffer(image.FHandle,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
|
|
|
@ -1909,22 +1909,27 @@ begin
|
|||
Result.cformat:=_get_tsharp4_cformat(PT);
|
||||
|
||||
Case PT^._type of
|
||||
SQ_RSRC_IMG_1D :Result.params.itype:=ord(VK_IMAGE_TYPE_1D);
|
||||
SQ_RSRC_IMG_2D :Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
SQ_RSRC_IMG_1D,
|
||||
SQ_RSRC_IMG_1D_ARRAY :Result.params.itype:=ord(VK_IMAGE_TYPE_1D);
|
||||
SQ_RSRC_IMG_2D,
|
||||
SQ_RSRC_IMG_2D_MSAA :Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
SQ_RSRC_IMG_3D :Result.params.itype:=ord(VK_IMAGE_TYPE_3D);
|
||||
SQ_RSRC_IMG_CUBE :
|
||||
begin
|
||||
Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
Result.params.cube :=1;
|
||||
end;
|
||||
SQ_RSRC_IMG_1D_ARRAY :Result.params.itype:=ord(VK_IMAGE_TYPE_1D);
|
||||
SQ_RSRC_IMG_2D_ARRAY :Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
SQ_RSRC_IMG_2D_MSAA :Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
SQ_RSRC_IMG_2D_MSAA_ARRAY:Result.params.itype:=ord(VK_IMAGE_TYPE_2D);
|
||||
SQ_RSRC_IMG_2D_ARRAY ,
|
||||
SQ_RSRC_IMG_2D_MSAA_ARRAY:
|
||||
begin
|
||||
Result.params.itype :=ord(VK_IMAGE_TYPE_2D);
|
||||
Result.params.array_2d:=1;
|
||||
end;
|
||||
else;
|
||||
Assert(false,'Unknow tsharp4 type:0x'+HexStr(PT^._type,1));
|
||||
end;
|
||||
|
||||
Result.params.pow2pad :=PT^.pow2pad;
|
||||
Result.params.tiling.idx:=PT^.tiling_idx;
|
||||
Result.params.tiling.alt:=0;
|
||||
Result.params.width :=PT^.width +1;
|
||||
|
@ -1955,6 +1960,8 @@ function _get_tsharp8_image_info(PT:PTSharpResource8):TvImageKey;
|
|||
begin
|
||||
Result:=_get_tsharp4_image_info(PTSharpResource4(PT));
|
||||
//
|
||||
Result.params.pitch:=PT^.pitch+1;
|
||||
//
|
||||
if (p_neomode<>0) then
|
||||
begin
|
||||
Result.params.tiling.alt:=PT^.alt_tile_mode;
|
||||
|
@ -2056,7 +2063,16 @@ begin
|
|||
Result:=_get_tsharp4_image_view(PTSharpResource4(PT));
|
||||
//
|
||||
Case PT^._type of
|
||||
SQ_RSRC_IMG_CUBE,
|
||||
SQ_RSRC_IMG_CUBE:
|
||||
begin
|
||||
Result.base_array:=PT^.base_array;
|
||||
Result.last_array:=PT^.last_array;
|
||||
//
|
||||
if (Result.last_array-Result.base_array)>5 then
|
||||
begin
|
||||
Result.vtype:=ord(VK_IMAGE_VIEW_TYPE_CUBE_ARRAY);
|
||||
end;
|
||||
end;
|
||||
SQ_RSRC_IMG_1D_ARRAY ,
|
||||
SQ_RSRC_IMG_2D_ARRAY ,
|
||||
SQ_RSRC_IMG_2D_MSAA_ARRAY:
|
||||
|
@ -2066,6 +2082,7 @@ begin
|
|||
end;
|
||||
else;
|
||||
end;
|
||||
//
|
||||
end;
|
||||
|
||||
function _get_xy_filter(b:Byte):TVkFilter;
|
||||
|
|
Loading…
Reference in New Issue