mirror of
https://github.com/red-prig/fpPS4.git
synced 2024-11-26 16:10:25 +00:00
+
This commit is contained in:
parent
94f3c061b1
commit
fb40aa7070
@ -1237,7 +1237,7 @@ begin
|
||||
IMG_DATA_FORMAT_16_16 :Result:=VK_FORMAT_R16_UNORM;
|
||||
IMG_DATA_FORMAT_16_16_16_16:Result:=VK_FORMAT_R16G16B16A16_UNORM;
|
||||
IMG_DATA_FORMAT_5_6_5 :Result:=VK_FORMAT_R5G6B5_UNORM_PACK16;
|
||||
IMG_DATA_FORMAT_BC1 :Result:=VK_FORMAT_BC1_RGB_UNORM_BLOCK;
|
||||
IMG_DATA_FORMAT_BC1 :Result:=VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
|
||||
IMG_DATA_FORMAT_BC3 :Result:=VK_FORMAT_BC3_UNORM_BLOCK
|
||||
else
|
||||
Assert(false,_get_tex_dfmt_str(PT^.dfmt));
|
||||
@ -1248,7 +1248,7 @@ begin
|
||||
IMG_DATA_FORMAT_8 :Result:=VK_FORMAT_R8_SRGB;
|
||||
IMG_DATA_FORMAT_8_8 :Result:=VK_FORMAT_R8G8_SRGB;
|
||||
IMG_DATA_FORMAT_8_8_8_8 :Result:=VK_FORMAT_R8G8B8A8_SRGB;
|
||||
IMG_DATA_FORMAT_BC1 :Result:=VK_FORMAT_BC1_RGB_SRGB_BLOCK;
|
||||
IMG_DATA_FORMAT_BC1 :Result:=VK_FORMAT_BC1_RGBA_SRGB_BLOCK;
|
||||
IMG_DATA_FORMAT_BC3 :Result:=VK_FORMAT_BC3_SRGB_BLOCK
|
||||
else
|
||||
Assert(false,_get_tex_dfmt_str(PT^.dfmt));
|
||||
|
@ -40,6 +40,8 @@ uses
|
||||
vSampler,
|
||||
vSamplerManager,
|
||||
|
||||
vRenderPassManager,
|
||||
|
||||
si_ci_vi_merged_offset,
|
||||
si_ci_vi_merged_enum,
|
||||
si_ci_vi_merged_registers
|
||||
@ -439,50 +441,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{
|
||||
procedure copy_submit_addr(node:PvSubmitInfo;dcbAddr,ccbAddr:Pointer);
|
||||
var
|
||||
n:DWORD;
|
||||
size,dcbSize,ccbSize:DWORD;
|
||||
begin
|
||||
dcbSize:=0;
|
||||
ccbSize:=0;
|
||||
|
||||
n:=0;
|
||||
While (n<node^.count) do
|
||||
begin
|
||||
|
||||
if (node^.dcbGpuAddrs<>nil) and (node^.dcbSizesInBytes<>nil) then
|
||||
begin
|
||||
if (node^.dcbGpuAddrs[n]<>nil) and (node^.dcbSizesInBytes[n]<>0) then
|
||||
begin
|
||||
size:=node^.dcbSizesInBytes[n];
|
||||
if (size<>0) then
|
||||
begin
|
||||
Move(node^.dcbGpuAddrs[n]^,PByte(dcbAddr)[dcbSize],size);
|
||||
dcbSize:=dcbSize+size;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (node^.ccbGpuAddrs<>nil) and (node^.ccbSizesInBytes<>nil) then
|
||||
begin
|
||||
if (node^.ccbGpuAddrs[n]<>nil) and (node^.ccbSizesInBytes[n]<>0) then
|
||||
begin
|
||||
size:=node^.ccbSizesInBytes[n];
|
||||
if (size<>0) then
|
||||
begin
|
||||
Move(node^.ccbGpuAddrs[n]^,PByte(ccbAddr)[ccbSize],size);
|
||||
ccbSize:=ccbSize+size;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Inc(n);
|
||||
end;
|
||||
end;
|
||||
}
|
||||
|
||||
function vSubmitCommandBuffers(
|
||||
Submit:PvSubmitInfo;
|
||||
Flip:PqcFlipInfo):Integer;
|
||||
@ -570,7 +528,7 @@ end;
|
||||
procedure vSubmitDone;
|
||||
begin
|
||||
//Sleep(100);
|
||||
//Device.WaitIdle;
|
||||
Device.WaitIdle;
|
||||
end;
|
||||
|
||||
|
||||
@ -753,6 +711,7 @@ begin
|
||||
begin
|
||||
GFXRing.AllocCmdBuffer;
|
||||
GFXRing.CmdBuffer.dmaData(adrSrc,adrDst,Body^.Flags2.byteCount,Boolean(Body^.Flags1.cpSync));
|
||||
//Move(adrSrc^,adrDst^,Body^.Flags2.byteCount);
|
||||
end;
|
||||
CP_DMA_ENGINE_PFP:
|
||||
begin
|
||||
@ -788,6 +747,7 @@ begin
|
||||
begin
|
||||
GFXRing.AllocCmdBuffer;
|
||||
GFXRing.CmdBuffer.dmaData(Body^.srcAddrLo,adrDst,Body^.Flags2.byteCount,Boolean(Body^.Flags1.cpSync));
|
||||
//FillDWORD(adrDst^,Body^.Flags2.byteCount div 4,Body^.srcAddrLo);
|
||||
end;
|
||||
CP_DMA_ENGINE_PFP:
|
||||
begin
|
||||
@ -834,6 +794,7 @@ begin
|
||||
begin
|
||||
GFXRing.AllocCmdBuffer;
|
||||
GFXRing.CmdBuffer.dmaData(@Body^.DATA,adr,count*SizeOf(DWORD),Boolean(Body^.CONTROL.wrConfirm));
|
||||
//Move(Body^.DATA,adr^,count*SizeOf(DWORD));
|
||||
end;
|
||||
WRITE_DATA_ENGINE_PFP:
|
||||
begin
|
||||
@ -1067,14 +1028,12 @@ begin
|
||||
GPU_REGS.Clear;
|
||||
end;
|
||||
|
||||
procedure onSetCommonReg(reg:WORD;value:DWORD);
|
||||
procedure SetContextReg(reg:WORD;value:DWORD);
|
||||
begin
|
||||
GFXRing.LastSetReg:=reg;
|
||||
|
||||
Case reg of
|
||||
|
||||
//onSetContextReg
|
||||
|
||||
mmCB_COLOR0_BASE..mmCB_COLOR7_DCC_BASE:
|
||||
begin
|
||||
PDWORD(@GPU_REGS.RENDER_TARGET)[reg-mmCB_COLOR0_BASE]:=value;
|
||||
@ -1201,8 +1160,17 @@ begin
|
||||
|
||||
mmPA_SU_POLY_OFFSET_DB_FMT_CNTL:DWORD(GPU_REGS.PA_SU_POLY_OFFSET_DB_FMT_CNTL):=value;
|
||||
|
||||
{$ifdef ww}else
|
||||
Writeln('SetContextReg:',getRegName(reg),'=',HexStr(value,8));{$endif}
|
||||
end;
|
||||
|
||||
//SetShReg
|
||||
end;
|
||||
|
||||
procedure SetShReg(reg:WORD;value:DWORD);
|
||||
begin
|
||||
GFXRing.LastSetReg:=reg;
|
||||
|
||||
Case reg of
|
||||
|
||||
mmSPI_SHADER_PGM_LO_PS :GPU_REGS.SPI.PS.LO:=value;
|
||||
mmSPI_SHADER_PGM_HI_PS :GPU_REGS.SPI.PS.HI:=value;
|
||||
@ -1245,7 +1213,16 @@ begin
|
||||
mmCOMPUTE_STATIC_THREAD_MGMT_SE1:DWORD(GPU_REGS.SPI.CS.STATIC_THREAD_MGMT_SE1):=value;
|
||||
mmCOMPUTE_RESOURCE_LIMITS :DWORD(GPU_REGS.SPI.CS.RESOURCE_LIMITS):=value;
|
||||
|
||||
//SetUConfigReg
|
||||
{$ifdef ww}else
|
||||
Writeln('onSetShReg:',getRegName(reg),'=',HexStr(value,8));{$endif}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SetUContextReg(reg:WORD;value:DWORD);
|
||||
begin
|
||||
GFXRing.LastSetReg:=reg;
|
||||
|
||||
Case reg of
|
||||
|
||||
mmVGT_PRIMITIVE_TYPE:DWORD(GPU_REGS.VGT_PRIMITIVE_TYPE):=value;
|
||||
mmVGT_INDEX_TYPE :DWORD(GPU_REGS.VGT_INDEX_TYPE ):=value;
|
||||
@ -1253,8 +1230,9 @@ begin
|
||||
mmGRBM_GFX_INDEX :DWORD(GPU_REGS.GRBM_GFX_INDEX ):=value;
|
||||
|
||||
{$ifdef ww}else
|
||||
Writeln('onSetCommonReg:',getRegName(reg),'=',HexStr(value,8));{$endif}
|
||||
Writeln('SetUContextReg:',getRegName(reg),'=',HexStr(value,8));{$endif}
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
const
|
||||
@ -1278,7 +1256,7 @@ begin
|
||||
|
||||
Inc(GFXRing.SetCxCount);
|
||||
|
||||
onSetCommonReg(r,v);
|
||||
SetContextReg(r,v);
|
||||
|
||||
end;
|
||||
end;
|
||||
@ -1303,7 +1281,7 @@ begin
|
||||
|
||||
Inc(GFXRing.SetShCount);
|
||||
|
||||
onSetCommonReg(r,v);
|
||||
SetShReg(r,v);
|
||||
|
||||
end;
|
||||
end;
|
||||
@ -1336,7 +1314,7 @@ begin
|
||||
|
||||
//{$ifdef ww}Writeln('SetUConfigReg:',getRegName(r),'=',HexStr(v,8));{$endif}
|
||||
|
||||
onSetCommonReg(r,v);
|
||||
SetUContextReg(r,v);
|
||||
|
||||
end;
|
||||
|
||||
@ -1376,8 +1354,6 @@ begin
|
||||
end;
|
||||
|
||||
var
|
||||
FShaderGroup:TvShaderGroup;
|
||||
|
||||
LastSetShCount:ptruint;
|
||||
LastSetCxCount:ptruint;
|
||||
|
||||
@ -1417,6 +1393,9 @@ var
|
||||
FVSShader:TvShaderExt;
|
||||
FPSShader:TvShaderExt;
|
||||
|
||||
FShadersKey:TvShadersKey;
|
||||
FShaderGroup:TvShaderGroup;
|
||||
|
||||
ctx_change:Boolean;
|
||||
|
||||
begin
|
||||
@ -1430,6 +1409,7 @@ begin
|
||||
end;
|
||||
|
||||
ctx_change:=(LastSetCxCount<>GFXRing.SetCxCount);
|
||||
ctx_change:=True;
|
||||
|
||||
LastSetShCount:=GFXRing.SetShCount;
|
||||
LastSetCxCount:=GFXRing.SetCxCount;
|
||||
@ -1456,7 +1436,6 @@ begin
|
||||
|
||||
FRenderCmd.FRenderPass:=TvRenderPass.Create;
|
||||
FRenderCmd.FPipeline :=TvGraphicsPipeline.Create;
|
||||
/////FRenderCmd.FPipeline.FLayout:=TvPipelineLayout.Create;
|
||||
FRenderCmd.FPipeline.FRenderPass:=FRenderCmd.FRenderPass;
|
||||
|
||||
FRenderCmd.FFramebuffer:=TvFramebuffer.Create;
|
||||
@ -1524,12 +1503,11 @@ begin
|
||||
|
||||
//RT_INFO.IMAGE_USAGE:=RT_INFO.IMAGE_USAGE and (not TM_CLEAR);
|
||||
|
||||
GFXRing.CmdBuffer.PushImageBarrier(ri.FHandle,
|
||||
iv.GetSubresRange,
|
||||
GetColorAccessMask(RT_INFO.IMAGE_USAGE),
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) );
|
||||
ri.PushBarrier(GFXRing.CmdBuffer,
|
||||
GetColorAccessMask(RT_INFO.IMAGE_USAGE),
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) );
|
||||
|
||||
FRenderCmd.FFramebuffer.AddImageView(iv);
|
||||
|
||||
@ -1546,10 +1524,7 @@ begin
|
||||
//RT_INFO.blend.blendEnable:=0;
|
||||
FRenderCmd.FPipeline.AddBlend(RT_INFO.blend);
|
||||
|
||||
//if RT_INFO.FAST_CLEAR then
|
||||
begin
|
||||
FRenderCmd.AddClearColor(TVkClearValue(RT_INFO.CLEAR_COLOR));
|
||||
end;
|
||||
FRenderCmd.AddClearColor(TVkClearValue(RT_INFO.CLEAR_COLOR));
|
||||
|
||||
end;
|
||||
|
||||
@ -1582,11 +1557,10 @@ begin
|
||||
|
||||
if not GPU_REGS.COMP_ENABLE then
|
||||
begin
|
||||
GFXRing.CmdBuffer.PushImageBarrier(ri.FHandle,
|
||||
iv.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
ri.PushBarrier(GFXRing.CmdBuffer,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
range:=iv.GetSubresRange;
|
||||
clr2:=DB_INFO.CLEAR_VALUE.depthStencil;
|
||||
@ -1599,11 +1573,11 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
GFXRing.CmdBuffer.PushImageBarrier(ri.FHandle,
|
||||
iv.GetSubresRange,
|
||||
GetDepthStencilAccessMask(DB_INFO.DEPTH_USAGE,DB_INFO.STENCIL_USAGE),
|
||||
GetDepthStencilLayout (DB_INFO.DEPTH_USAGE,DB_INFO.STENCIL_USAGE),
|
||||
DB_INFO.zorder_stage );
|
||||
ri.PushBarrier(GFXRing.CmdBuffer,
|
||||
GetDepthStencilAccessMask(DB_INFO.DEPTH_USAGE,DB_INFO.STENCIL_USAGE),
|
||||
GetDepthStencilLayout (DB_INFO.DEPTH_USAGE,DB_INFO.STENCIL_USAGE),
|
||||
DB_INFO.zorder_stage );
|
||||
|
||||
|
||||
FRenderCmd.FFramebuffer.AddImageView(iv);
|
||||
|
||||
@ -1650,19 +1624,6 @@ begin
|
||||
FAttrBuilder:=Default(TvAttrBuilder);
|
||||
FVSShader.EnumVertLayout(@FAttrBuilder.AddAttr,FVSShader.FDescSetId,@GPU_REGS.SPI.VS.USER_DATA);
|
||||
|
||||
//if (FVSShader=nil) then
|
||||
//begin
|
||||
// FVSShader:=TvShaderExt.Create;
|
||||
// FVSShader.FDescSetId:=0;
|
||||
// FVSShader.LoadFromFile(ChangeFileExt(fdump_vs,'.spv'));
|
||||
//
|
||||
//
|
||||
// FAttrBuilder:=Default(TvAttrBuilder);
|
||||
//
|
||||
// FVSShader.EnumVertLayout(@FAttrBuilder.AddAttr,FVSShader.FDescSetId,@GPU_REGS.SPI.VS.USER_DATA);
|
||||
//
|
||||
//end;
|
||||
|
||||
if (Length(FAttrBuilder.FBindDescs)<>0) then
|
||||
begin
|
||||
With FRenderCmd.FPipeline.vertexInputInfo do
|
||||
@ -1678,25 +1639,12 @@ begin
|
||||
FPSShader:=FetchShader(vShaderStagePs,1,GPU_REGS);
|
||||
if (FPSShader=nil) then Exit;
|
||||
|
||||
//if (FPSShader=nil) then
|
||||
//begin
|
||||
// FPSShader:=TvShaderExt.Create;
|
||||
// FPSShader.FDescSetId:=1;
|
||||
// FPSShader.LoadFromFile(ChangeFileExt(fdump_ps,'.spv'));
|
||||
//end;
|
||||
FShadersKey:=Default(TvShadersKey);
|
||||
FShadersKey.SetVSShader(FVSShader);
|
||||
FShadersKey.SetPSShader(FPSShader);
|
||||
|
||||
if (FShaderGroup=nil) then
|
||||
begin
|
||||
FShaderGroup:=TvShaderGroup.Create;
|
||||
end;
|
||||
|
||||
FShaderGroup.Clear;
|
||||
|
||||
FShaderGroup.SetVSShader(FVSShader);
|
||||
FShaderGroup.SetPSShader(FPSShader);
|
||||
|
||||
FShaderGroup.Compile;
|
||||
//end;
|
||||
FShaderGroup:=FetchShaderGroup(@FShadersKey);
|
||||
Assert(FShaderGroup<>nil);
|
||||
|
||||
FRenderCmd.FPipeline.FShaderGroup:=FShaderGroup;
|
||||
|
||||
@ -1726,65 +1674,14 @@ begin
|
||||
|
||||
iv:=ri.FetchView(GFXRing.CmdBuffer,FView);
|
||||
|
||||
{
|
||||
|
||||
FCmdBuffer.PushImageBarrier(ri.FHandle,
|
||||
iv.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
{//
|
||||
range:=iv.GetSubresRange;
|
||||
clr.float32[0]:=1;
|
||||
clr.float32[1]:=1;
|
||||
clr.float32[2]:=1;
|
||||
clr.float32[3]:=1;
|
||||
|
||||
vkCmdClearColorImage(FCmdBuffer.cmdbuf,
|
||||
ri.FHandle,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
@clr,
|
||||
1,@range);
|
||||
//}
|
||||
|
||||
|
||||
//
|
||||
|
||||
buf:=FetchHostBuffer(FCmdBuffer,
|
||||
ri.key.Addr,
|
||||
ri.key.params.extend.width*ri.key.params.extend.height*4,
|
||||
ord(VK_BUFFER_USAGE_TRANSFER_SRC_BIT));
|
||||
|
||||
BufferImageCopy:=Default(TVkBufferImageCopy);
|
||||
|
||||
BufferImageCopy.bufferOffset:=buf.Foffset;
|
||||
BufferImageCopy.bufferRowLength:=0;
|
||||
BufferImageCopy.bufferImageHeight:=0;
|
||||
BufferImageCopy.imageSubresource:=ri.GetSubresLayer;
|
||||
//BufferImageCopy.imageOffset:TVkOffset3D; //0
|
||||
BufferImageCopy.imageExtent.Create(ri.key.params.extend.width,
|
||||
ri.key.params.extend.height,
|
||||
ri.key.params.extend.depth);
|
||||
|
||||
vkCmdCopyBufferToImage(FCmdBuffer.cmdbuf,
|
||||
buf.FHandle,
|
||||
ri.FHandle,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,
|
||||
@BufferImageCopy);
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
if ctx_change then
|
||||
GFXRing.CmdBuffer.PushImageBarrier(ri.FHandle,
|
||||
iv.GetSubresRange,
|
||||
ord(VK_ACCESS_SHADER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_VERTEX_SHADER_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) );
|
||||
//if not GFXRing.CmdBuffer.IsRenderPass then
|
||||
begin
|
||||
ri.PushBarrier(GFXRing.CmdBuffer,
|
||||
ord(VK_ACCESS_SHADER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_VERTEX_SHADER_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) );
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
@ -1913,7 +1810,6 @@ end;
|
||||
|
||||
procedure UpdateGpuRegsInfoCompute;
|
||||
var
|
||||
FAttrBuilder:TvAttrBuilder;
|
||||
FUniformBuilder:TvUniformBuilder;
|
||||
|
||||
fdump_cs:RawByteString;
|
||||
@ -1928,7 +1824,10 @@ var
|
||||
|
||||
FCSShader:TvShaderExt;
|
||||
|
||||
FComputePipeline:TvComputePipeline;
|
||||
FShadersKey:TvShadersKey;
|
||||
FShaderGroup:TvShaderGroup;
|
||||
|
||||
FComputePipeline:TvComputePipeline2;
|
||||
begin
|
||||
|
||||
{$ifdef null_rt}Exit;{$endif}
|
||||
@ -1949,23 +1848,19 @@ begin
|
||||
FCSShader:=FetchShader(vShaderStageCs,0,GPU_REGS);
|
||||
if (FCSShader=nil) then Exit;
|
||||
|
||||
if (FShaderGroup=nil) then
|
||||
begin
|
||||
FShaderGroup:=TvShaderGroup.Create;
|
||||
end;
|
||||
|
||||
FShaderGroup.Clear;
|
||||
FShaderGroup.SetCSShader(FCSShader);
|
||||
FShaderGroup.Compile;
|
||||
FShadersKey:=Default(TvShadersKey);
|
||||
FShadersKey.SetCSShader(FCSShader);
|
||||
|
||||
FShaderGroup:=FetchShaderGroup(@FShadersKey);
|
||||
Assert(FShaderGroup<>nil);
|
||||
|
||||
FComputePipeline:=TvComputePipeline.Create;
|
||||
FComputePipeline.SetLayout(FShaderGroup.FLayout);
|
||||
FComputePipeline.SetShader(FCSShader);
|
||||
FComputePipeline.Compile;
|
||||
FComputePipeline:=TvComputePipeline2.Create;
|
||||
FComputePipeline.SetLayout(FShaderGroup.FLayout);
|
||||
FComputePipeline.SetShader(FCSShader);
|
||||
FComputePipeline.Compile;
|
||||
|
||||
GFXRing.CmdBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE,FComputePipeline.FHandle);
|
||||
GFXRing.CmdBuffer.BindLayout(VK_PIPELINE_BIND_POINT_COMPUTE,FShaderGroup.FLayout);
|
||||
GFXRing.CmdBuffer.BindCompute(FComputePipeline);
|
||||
|
||||
if (FCSShader.FPushConst.size<>0) then
|
||||
begin
|
||||
@ -1991,38 +1886,6 @@ begin
|
||||
|
||||
buf:=FetchHostBuffer(GFXRing.CmdBuffer,addr,size,ord(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT));
|
||||
|
||||
{
|
||||
if (bind=0) then
|
||||
begin
|
||||
Writeln(HexStr(PDWORD(addr)^,8));
|
||||
end;
|
||||
}
|
||||
|
||||
{
|
||||
if (bind=1) then
|
||||
begin
|
||||
//FillDWORD(addr^,size div 4,$FFBBBBBB);
|
||||
Writeln('CLEAR RT:',HexStr(addr));
|
||||
|
||||
|
||||
vkBufferMemoryBarrier(FCmdBuffer.cmdbuf,
|
||||
buf.FHandle,
|
||||
ord(VK_ACCESS_NONE_KHR),
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
0,size,
|
||||
ord(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT),
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT)
|
||||
);
|
||||
|
||||
end;
|
||||
}
|
||||
|
||||
//Writeln(PInteger(addr)[0]);
|
||||
//Writeln(PByte(@PInteger(addr)[1])[0]);
|
||||
//Writeln(PByte(@PInteger(addr)[1])[1]);
|
||||
//Writeln(PByte(@PInteger(addr)[1])[2]);
|
||||
//Writeln(PByte(@PInteger(addr)[1])[3]);
|
||||
|
||||
o:=buf.Foffset;
|
||||
|
||||
a:=o-AlignDw(o,limits.minStorageBufferOffsetAlignment);
|
||||
@ -2106,7 +1969,7 @@ end;
|
||||
|
||||
procedure gfx_cp_parser(node:PvSubmitInfo);
|
||||
var
|
||||
n,i,s:DWORD;
|
||||
n,i,s,t:DWORD;
|
||||
token:DWORD;
|
||||
P:PByte;
|
||||
|
||||
@ -2253,9 +2116,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
P:=P+PM4_LENGTH_DW(token)*sizeof(DWORD);
|
||||
i:=i+PM4_LENGTH_DW(token)*sizeof(DWORD);
|
||||
t:=PM4_LENGTH_DW(token)*sizeof(DWORD);
|
||||
P:=P+t;
|
||||
i:=i+t;
|
||||
end;
|
||||
Inc(n);
|
||||
end;
|
||||
@ -2284,8 +2147,8 @@ begin
|
||||
if Result then
|
||||
begin
|
||||
CmdBuffer.ReleaseResource;
|
||||
CmdBuffer.Free;
|
||||
GPU_REGS.ClearDMA;
|
||||
FreeAndNil(CmdBuffer);
|
||||
//GPU_REGS.ClearDMA;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="38">
|
||||
<Units Count="39">
|
||||
<Unit0>
|
||||
<Filename Value="fpPS4.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -194,6 +194,10 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ps4_libScePlayGo"/>
|
||||
</Unit37>
|
||||
<Unit38>
|
||||
<Filename Value="vulkan\vRenderPassManager.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit38>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
148
ps4_libkernel/libsysmodule.inc
Normal file
148
ps4_libkernel/libsysmodule.inc
Normal file
@ -0,0 +1,148 @@
|
||||
|
||||
const
|
||||
// module ID definitions
|
||||
SCE_SYSMODULE_INVALID =$0000;
|
||||
SCE_SYSMODULE_FIBER =$0006;
|
||||
SCE_SYSMODULE_ULT =$0007;
|
||||
SCE_SYSMODULE_NGS2 =$000b;
|
||||
SCE_SYSMODULE_XML =$0017;
|
||||
SCE_SYSMODULE_NP_UTILITY =$0019;
|
||||
SCE_SYSMODULE_VOICE =$001a;
|
||||
SCE_SYSMODULE_VOICEQOS =$001b;
|
||||
SCE_SYSMODULE_NP_MATCHING2 =$001c;
|
||||
SCE_SYSMODULE_NP_SCORE_RANKING =$001e;
|
||||
SCE_SYSMODULE_RUDP =$0021;
|
||||
SCE_SYSMODULE_NP_TUS =$002c;
|
||||
SCE_SYSMODULE_FACE =$0038;
|
||||
SCE_SYSMODULE_SMART =$0039;
|
||||
SCE_SYSMODULE_GAME_LIVE_STREAMING =$0081;
|
||||
SCE_SYSMODULE_COMPANION_UTIL =$0082;
|
||||
SCE_SYSMODULE_PLAYGO =$0083;
|
||||
SCE_SYSMODULE_FONT =$0084;
|
||||
SCE_SYSMODULE_VIDEO_RECORDING =$0085;
|
||||
SCE_SYSMODULE_S3DCONVERSION =$0086;
|
||||
SCE_SYSMODULE_AUDIODEC =$0088;
|
||||
SCE_SYSMODULE_JPEG_DEC =$008a;
|
||||
SCE_SYSMODULE_JPEG_ENC =$008b;
|
||||
SCE_SYSMODULE_PNG_DEC =$008c;
|
||||
SCE_SYSMODULE_PNG_ENC =$008d;
|
||||
SCE_SYSMODULE_VIDEODEC =$008e;
|
||||
SCE_SYSMODULE_MOVE =$008f;
|
||||
SCE_SYSMODULE_PAD_TRACKER =$0091;
|
||||
SCE_SYSMODULE_DEPTH =$0092;
|
||||
SCE_SYSMODULE_HAND =$0093;
|
||||
SCE_SYSMODULE_LIBIME =$0095;
|
||||
SCE_SYSMODULE_IME_DIALOG =$0096;
|
||||
SCE_SYSMODULE_NP_PARTY =$0097;
|
||||
SCE_SYSMODULE_FONT_FT =$0098;
|
||||
SCE_SYSMODULE_FREETYPE_OT =$0099;
|
||||
SCE_SYSMODULE_FREETYPE_OL =$009a;
|
||||
SCE_SYSMODULE_FREETYPE_OPT_OL =$009b;
|
||||
SCE_SYSMODULE_SCREEN_SHOT =$009c;
|
||||
SCE_SYSMODULE_NP_AUTH =$009d;
|
||||
SCE_SYSMODULE_SULPHA =$009f;
|
||||
SCE_SYSMODULE_SAVE_DATA_DIALOG =$00a0;
|
||||
SCE_SYSMODULE_INVITATION_DIALOG =$00a2;
|
||||
SCE_SYSMODULE_DEBUG_KEYBOARD =$00a3;
|
||||
SCE_SYSMODULE_MESSAGE_DIALOG =$00a4;
|
||||
SCE_SYSMODULE_AV_PLAYER =$00a5;
|
||||
SCE_SYSMODULE_CONTENT_EXPORT =$00a6;
|
||||
SCE_SYSMODULE_AUDIO_3D =$00a7;
|
||||
SCE_SYSMODULE_NP_COMMERCE =$00a8;
|
||||
SCE_SYSMODULE_MOUSE =$00a9;
|
||||
SCE_SYSMODULE_COMPANION_HTTPD =$00aa;
|
||||
SCE_SYSMODULE_WEB_BROWSER_DIALOG =$00ab;
|
||||
SCE_SYSMODULE_ERROR_DIALOG =$00ac;
|
||||
SCE_SYSMODULE_NP_TROPHY =$00ad;
|
||||
SCE_SYSMODULE_RESERVED30 =$00ae;
|
||||
SCE_SYSMODULE_RESERVED31 =$00af;
|
||||
SCE_SYSMODULE_NP_SNS_FACEBOOK =$00b0;
|
||||
SCE_SYSMODULE_MOVE_TRACKER =$00b1;
|
||||
SCE_SYSMODULE_NP_PROFILE_DIALOG =$00b2;
|
||||
SCE_SYSMODULE_NP_FRIEND_LIST_DIALOG =$00b3;
|
||||
SCE_SYSMODULE_APP_CONTENT =$00b4;
|
||||
SCE_SYSMODULE_NP_SIGNALING =$00b5;
|
||||
SCE_SYSMODULE_REMOTE_PLAY =$00b6;
|
||||
SCE_SYSMODULE_USBD =$00b7;
|
||||
SCE_SYSMODULE_GAME_CUSTOM_DATA_DIALOG =$00b8;
|
||||
SCE_SYSMODULE_RESERVED0 =$00b9;
|
||||
SCE_SYSMODULE_RESERVED1 =$00ba;
|
||||
SCE_SYSMODULE_RESERVED2 =$00bb;
|
||||
SCE_SYSMODULE_M4AAC_ENC =$00bc;
|
||||
SCE_SYSMODULE_AUDIODEC_CPU =$00bd;
|
||||
SCE_SYSMODULE_RESERVED32 =$00be;
|
||||
SCE_SYSMODULE_RESERVED33 =$00c0;
|
||||
SCE_SYSMODULE_RESERVED3 =$00c1;
|
||||
SCE_SYSMODULE_RESERVED4 =$00c2;
|
||||
SCE_SYSMODULE_RESERVED5 =$00c3;
|
||||
SCE_SYSMODULE_RESERVED6 =$00c4;
|
||||
SCE_SYSMODULE_ZLIB =$00c5;
|
||||
SCE_SYSMODULE_RESERVED8 =$00c6;
|
||||
SCE_SYSMODULE_CONTENT_SEARCH =$00c7;
|
||||
SCE_SYSMODULE_RESERVED9 =$00c8;
|
||||
SCE_SYSMODULE_RESERVED34 =$00c9;
|
||||
SCE_SYSMODULE_DECI4H =$00ca;
|
||||
SCE_SYSMODULE_HEAD_TRACKER =$00cb;
|
||||
SCE_SYSMODULE_RESERVED11 =$00cc;
|
||||
SCE_SYSMODULE_RESERVED12 =$00cd;
|
||||
SCE_SYSMODULE_SYSTEM_GESTURE =$00ce;
|
||||
SCE_SYSMODULE_VIDEODEC2 =$00cf;
|
||||
SCE_SYSMODULE_RESERVED14 =$00d0;
|
||||
SCE_SYSMODULE_AT9_ENC =$00d1;
|
||||
SCE_SYSMODULE_CONVERT_KEYCODE =$00d2;
|
||||
SCE_SYSMODULE_SHARE_PLAY =$00d3;
|
||||
SCE_SYSMODULE_HMD =$00d4;
|
||||
SCE_SYSMODULE_RESERVED18 =$00d5;
|
||||
SCE_SYSMODULE_RESERVED16 =$00d6;
|
||||
SCE_SYSMODULE_RESERVED17 =$00d7;
|
||||
SCE_SYSMODULE_FACE_TRACKER =$00d8;
|
||||
SCE_SYSMODULE_HAND_TRACKER =$00d9;
|
||||
SCE_SYSMODULE_RESERVED19 =$00da;
|
||||
SCE_SYSMODULE_RESERVED20 =$00dc;
|
||||
SCE_SYSMODULE_RESERVED21 =$00dd;
|
||||
SCE_SYSMODULE_RESERVED22 =$00de;
|
||||
SCE_SYSMODULE_RESERVED23 =$00df;
|
||||
SCE_SYSMODULE_RESERVED24 =$00e0;
|
||||
SCE_SYSMODULE_AUDIODEC_CPU_HEVAG =$00e1;
|
||||
SCE_SYSMODULE_LOGIN_DIALOG =$00e2;
|
||||
SCE_SYSMODULE_LOGIN_SERVICE =$00e3;
|
||||
SCE_SYSMODULE_SIGNIN_DIALOG =$00e4;
|
||||
SCE_SYSMODULE_RESERVED35 =$00e5;
|
||||
SCE_SYSMODULE_RESERVED25 =$00e6;
|
||||
SCE_SYSMODULE_JSON2 =$00e7;
|
||||
SCE_SYSMODULE_AUDIO_LATENCY_ESTIMATION =$00e8;
|
||||
SCE_SYSMODULE_RESERVED26 =$00e9;
|
||||
SCE_SYSMODULE_RESERVED27 =$00ea;
|
||||
SCE_SYSMODULE_HMD_SETUP_DIALOG =$00eb;
|
||||
SCE_SYSMODULE_RESERVED28 =$00ec;
|
||||
SCE_SYSMODULE_VR_TRACKER =$00ed;
|
||||
SCE_SYSMODULE_CONTENT_DELETE =$00ee;
|
||||
SCE_SYSMODULE_IME_BACKEND =$00ef;
|
||||
SCE_SYSMODULE_NET_CTL_AP_DIALOG =$00f0;
|
||||
SCE_SYSMODULE_PLAYGO_DIALOG =$00f1;
|
||||
SCE_SYSMODULE_SOCIAL_SCREEN =$00f2;
|
||||
SCE_SYSMODULE_EDIT_MP4 =$00f3;
|
||||
SCE_SYSMODULE_RESERVED37 =$00f5;
|
||||
SCE_SYSMODULE_TEXT_TO_SPEECH =$00f6;
|
||||
SCE_SYSMODULE_RESERVED38 =$00f8;
|
||||
SCE_SYSMODULE_RESERVED39 =$00f9;
|
||||
SCE_SYSMODULE_RESERVED40 =$00fa;
|
||||
SCE_SYSMODULE_BLUETOOTH_HID =$00fb;
|
||||
SCE_SYSMODULE_RESERVED41 =$00fc;
|
||||
SCE_SYSMODULE_VR_SERVICE_DIALOG =$00fd;
|
||||
SCE_SYSMODULE_JOB_MANAGER =$00fe;
|
||||
SCE_SYSMODULE_RESERVED42 =$00ff;
|
||||
SCE_SYSMODULE_SOCIAL_SCREEN_DIALOG =$0100;
|
||||
SCE_SYSMODULE_RESERVED43 =$0101;
|
||||
SCE_SYSMODULE_NP_TOOLKIT2 =$0102;
|
||||
SCE_SYSMODULE_RESERVED44 =$0103;
|
||||
SCE_SYSMODULE_RESERVED45 =$0104;
|
||||
SCE_SYSMODULE_RESERVED46 =$00f7;
|
||||
|
||||
|
||||
SCE_SYSMODULE_ERROR_INVALID_VALUE=-2141581312; // 0x805A1000
|
||||
SCE_SYSMODULE_ERROR_UNLOADED =-2141581311; // 0x805A1001
|
||||
SCE_SYSMODULE_ERROR_FATAL =-2141581057; // 0x805A10FF
|
||||
SCE_SYSMODULE_LOADED =0;
|
||||
|
||||
|
@ -504,9 +504,113 @@ begin
|
||||
P^.mstate_table :=@g_mstate_table;
|
||||
end;
|
||||
|
||||
{$I libsysmodule.inc}
|
||||
|
||||
function ps4_sceSysmoduleLoadModule(id:Word):Integer; SysV_ABI_CDecl;
|
||||
begin
|
||||
Writeln('sceSysmoduleLoadModule:',HexStr(id,4)); //libSceNgs2.sprx SCE_SYSMODULE_NGS2 0x000B
|
||||
Write('sceSysmoduleLoadModule:');
|
||||
|
||||
Case id of
|
||||
SCE_SYSMODULE_FIBER :Writeln('SCE_SYSMODULE_FIBER ');
|
||||
SCE_SYSMODULE_ULT :Writeln('SCE_SYSMODULE_ULT ');
|
||||
SCE_SYSMODULE_NGS2 :Writeln('SCE_SYSMODULE_NGS2 ');
|
||||
SCE_SYSMODULE_XML :Writeln('SCE_SYSMODULE_XML ');
|
||||
SCE_SYSMODULE_NP_UTILITY :Writeln('SCE_SYSMODULE_NP_UTILITY ');
|
||||
SCE_SYSMODULE_VOICE :Writeln('SCE_SYSMODULE_VOICE ');
|
||||
SCE_SYSMODULE_VOICEQOS :Writeln('SCE_SYSMODULE_VOICEQOS ');
|
||||
SCE_SYSMODULE_NP_MATCHING2 :Writeln('SCE_SYSMODULE_NP_MATCHING2 ');
|
||||
SCE_SYSMODULE_NP_SCORE_RANKING :Writeln('SCE_SYSMODULE_NP_SCORE_RANKING ');
|
||||
SCE_SYSMODULE_RUDP :Writeln('SCE_SYSMODULE_RUDP ');
|
||||
SCE_SYSMODULE_NP_TUS :Writeln('SCE_SYSMODULE_NP_TUS ');
|
||||
SCE_SYSMODULE_FACE :Writeln('SCE_SYSMODULE_FACE ');
|
||||
SCE_SYSMODULE_SMART :Writeln('SCE_SYSMODULE_SMART ');
|
||||
SCE_SYSMODULE_GAME_LIVE_STREAMING :Writeln('SCE_SYSMODULE_GAME_LIVE_STREAMING ');
|
||||
SCE_SYSMODULE_COMPANION_UTIL :Writeln('SCE_SYSMODULE_COMPANION_UTIL ');
|
||||
SCE_SYSMODULE_PLAYGO :Writeln('SCE_SYSMODULE_PLAYGO ');
|
||||
SCE_SYSMODULE_FONT :Writeln('SCE_SYSMODULE_FONT ');
|
||||
SCE_SYSMODULE_VIDEO_RECORDING :Writeln('SCE_SYSMODULE_VIDEO_RECORDING ');
|
||||
SCE_SYSMODULE_S3DCONVERSION :Writeln('SCE_SYSMODULE_S3DCONVERSION ');
|
||||
SCE_SYSMODULE_AUDIODEC :Writeln('SCE_SYSMODULE_AUDIODEC ');
|
||||
SCE_SYSMODULE_JPEG_DEC :Writeln('SCE_SYSMODULE_JPEG_DEC ');
|
||||
SCE_SYSMODULE_JPEG_ENC :Writeln('SCE_SYSMODULE_JPEG_ENC ');
|
||||
SCE_SYSMODULE_PNG_DEC :Writeln('SCE_SYSMODULE_PNG_DEC ');
|
||||
SCE_SYSMODULE_PNG_ENC :Writeln('SCE_SYSMODULE_PNG_ENC ');
|
||||
SCE_SYSMODULE_VIDEODEC :Writeln('SCE_SYSMODULE_VIDEODEC ');
|
||||
SCE_SYSMODULE_MOVE :Writeln('SCE_SYSMODULE_MOVE ');
|
||||
SCE_SYSMODULE_PAD_TRACKER :Writeln('SCE_SYSMODULE_PAD_TRACKER ');
|
||||
SCE_SYSMODULE_DEPTH :Writeln('SCE_SYSMODULE_DEPTH ');
|
||||
SCE_SYSMODULE_HAND :Writeln('SCE_SYSMODULE_HAND ');
|
||||
SCE_SYSMODULE_LIBIME :Writeln('SCE_SYSMODULE_LIBIME ');
|
||||
SCE_SYSMODULE_IME_DIALOG :Writeln('SCE_SYSMODULE_IME_DIALOG ');
|
||||
SCE_SYSMODULE_NP_PARTY :Writeln('SCE_SYSMODULE_NP_PARTY ');
|
||||
SCE_SYSMODULE_FONT_FT :Writeln('SCE_SYSMODULE_FONT_FT ');
|
||||
SCE_SYSMODULE_FREETYPE_OT :Writeln('SCE_SYSMODULE_FREETYPE_OT ');
|
||||
SCE_SYSMODULE_FREETYPE_OL :Writeln('SCE_SYSMODULE_FREETYPE_OL ');
|
||||
SCE_SYSMODULE_FREETYPE_OPT_OL :Writeln('SCE_SYSMODULE_FREETYPE_OPT_OL ');
|
||||
SCE_SYSMODULE_SCREEN_SHOT :Writeln('SCE_SYSMODULE_SCREEN_SHOT ');
|
||||
SCE_SYSMODULE_NP_AUTH :Writeln('SCE_SYSMODULE_NP_AUTH ');
|
||||
SCE_SYSMODULE_SULPHA :Writeln('SCE_SYSMODULE_SULPHA ');
|
||||
SCE_SYSMODULE_SAVE_DATA_DIALOG :Writeln('SCE_SYSMODULE_SAVE_DATA_DIALOG ');
|
||||
SCE_SYSMODULE_INVITATION_DIALOG :Writeln('SCE_SYSMODULE_INVITATION_DIALOG ');
|
||||
SCE_SYSMODULE_DEBUG_KEYBOARD :Writeln('SCE_SYSMODULE_DEBUG_KEYBOARD ');
|
||||
SCE_SYSMODULE_MESSAGE_DIALOG :Writeln('SCE_SYSMODULE_MESSAGE_DIALOG ');
|
||||
SCE_SYSMODULE_AV_PLAYER :Writeln('SCE_SYSMODULE_AV_PLAYER ');
|
||||
SCE_SYSMODULE_CONTENT_EXPORT :Writeln('SCE_SYSMODULE_CONTENT_EXPORT ');
|
||||
SCE_SYSMODULE_AUDIO_3D :Writeln('SCE_SYSMODULE_AUDIO_3D ');
|
||||
SCE_SYSMODULE_NP_COMMERCE :Writeln('SCE_SYSMODULE_NP_COMMERCE ');
|
||||
SCE_SYSMODULE_MOUSE :Writeln('SCE_SYSMODULE_MOUSE ');
|
||||
SCE_SYSMODULE_COMPANION_HTTPD :Writeln('SCE_SYSMODULE_COMPANION_HTTPD ');
|
||||
SCE_SYSMODULE_WEB_BROWSER_DIALOG :Writeln('SCE_SYSMODULE_WEB_BROWSER_DIALOG ');
|
||||
SCE_SYSMODULE_ERROR_DIALOG :Writeln('SCE_SYSMODULE_ERROR_DIALOG ');
|
||||
SCE_SYSMODULE_NP_TROPHY :Writeln('SCE_SYSMODULE_NP_TROPHY ');
|
||||
SCE_SYSMODULE_NP_SNS_FACEBOOK :Writeln('SCE_SYSMODULE_NP_SNS_FACEBOOK ');
|
||||
SCE_SYSMODULE_MOVE_TRACKER :Writeln('SCE_SYSMODULE_MOVE_TRACKER ');
|
||||
SCE_SYSMODULE_NP_PROFILE_DIALOG :Writeln('SCE_SYSMODULE_NP_PROFILE_DIALOG ');
|
||||
SCE_SYSMODULE_NP_FRIEND_LIST_DIALOG :Writeln('SCE_SYSMODULE_NP_FRIEND_LIST_DIALOG ');
|
||||
SCE_SYSMODULE_APP_CONTENT :Writeln('SCE_SYSMODULE_APP_CONTENT ');
|
||||
SCE_SYSMODULE_NP_SIGNALING :Writeln('SCE_SYSMODULE_NP_SIGNALING ');
|
||||
SCE_SYSMODULE_REMOTE_PLAY :Writeln('SCE_SYSMODULE_REMOTE_PLAY ');
|
||||
SCE_SYSMODULE_USBD :Writeln('SCE_SYSMODULE_USBD ');
|
||||
SCE_SYSMODULE_GAME_CUSTOM_DATA_DIALOG :Writeln('SCE_SYSMODULE_GAME_CUSTOM_DATA_DIALOG ');
|
||||
SCE_SYSMODULE_M4AAC_ENC :Writeln('SCE_SYSMODULE_M4AAC_ENC ');
|
||||
SCE_SYSMODULE_AUDIODEC_CPU :Writeln('SCE_SYSMODULE_AUDIODEC_CPU ');
|
||||
SCE_SYSMODULE_ZLIB :Writeln('SCE_SYSMODULE_ZLIB ');
|
||||
SCE_SYSMODULE_CONTENT_SEARCH :Writeln('SCE_SYSMODULE_CONTENT_SEARCH ');
|
||||
SCE_SYSMODULE_DECI4H :Writeln('SCE_SYSMODULE_DECI4H ');
|
||||
SCE_SYSMODULE_HEAD_TRACKER :Writeln('SCE_SYSMODULE_HEAD_TRACKER ');
|
||||
SCE_SYSMODULE_SYSTEM_GESTURE :Writeln('SCE_SYSMODULE_SYSTEM_GESTURE ');
|
||||
SCE_SYSMODULE_VIDEODEC2 :Writeln('SCE_SYSMODULE_VIDEODEC2 ');
|
||||
SCE_SYSMODULE_AT9_ENC :Writeln('SCE_SYSMODULE_AT9_ENC ');
|
||||
SCE_SYSMODULE_CONVERT_KEYCODE :Writeln('SCE_SYSMODULE_CONVERT_KEYCODE ');
|
||||
SCE_SYSMODULE_SHARE_PLAY :Writeln('SCE_SYSMODULE_SHARE_PLAY ');
|
||||
SCE_SYSMODULE_HMD :Writeln('SCE_SYSMODULE_HMD ');
|
||||
SCE_SYSMODULE_FACE_TRACKER :Writeln('SCE_SYSMODULE_FACE_TRACKER ');
|
||||
SCE_SYSMODULE_HAND_TRACKER :Writeln('SCE_SYSMODULE_HAND_TRACKER ');
|
||||
SCE_SYSMODULE_AUDIODEC_CPU_HEVAG :Writeln('SCE_SYSMODULE_AUDIODEC_CPU_HEVAG ');
|
||||
SCE_SYSMODULE_LOGIN_DIALOG :Writeln('SCE_SYSMODULE_LOGIN_DIALOG ');
|
||||
SCE_SYSMODULE_LOGIN_SERVICE :Writeln('SCE_SYSMODULE_LOGIN_SERVICE ');
|
||||
SCE_SYSMODULE_SIGNIN_DIALOG :Writeln('SCE_SYSMODULE_SIGNIN_DIALOG ');
|
||||
SCE_SYSMODULE_JSON2 :Writeln('SCE_SYSMODULE_JSON2 ');
|
||||
SCE_SYSMODULE_AUDIO_LATENCY_ESTIMATION :Writeln('SCE_SYSMODULE_AUDIO_LATENCY_ESTIMATION');
|
||||
SCE_SYSMODULE_HMD_SETUP_DIALOG :Writeln('SCE_SYSMODULE_HMD_SETUP_DIALOG ');
|
||||
SCE_SYSMODULE_VR_TRACKER :Writeln('SCE_SYSMODULE_VR_TRACKER ');
|
||||
SCE_SYSMODULE_CONTENT_DELETE :Writeln('SCE_SYSMODULE_CONTENT_DELETE ');
|
||||
SCE_SYSMODULE_IME_BACKEND :Writeln('SCE_SYSMODULE_IME_BACKEND ');
|
||||
SCE_SYSMODULE_NET_CTL_AP_DIALOG :Writeln('SCE_SYSMODULE_NET_CTL_AP_DIALOG ');
|
||||
SCE_SYSMODULE_PLAYGO_DIALOG :Writeln('SCE_SYSMODULE_PLAYGO_DIALOG ');
|
||||
SCE_SYSMODULE_SOCIAL_SCREEN :Writeln('SCE_SYSMODULE_SOCIAL_SCREEN ');
|
||||
SCE_SYSMODULE_EDIT_MP4 :Writeln('SCE_SYSMODULE_EDIT_MP4 ');
|
||||
SCE_SYSMODULE_TEXT_TO_SPEECH :Writeln('SCE_SYSMODULE_TEXT_TO_SPEECH ');
|
||||
SCE_SYSMODULE_BLUETOOTH_HID :Writeln('SCE_SYSMODULE_BLUETOOTH_HID ');
|
||||
SCE_SYSMODULE_VR_SERVICE_DIALOG :Writeln('SCE_SYSMODULE_VR_SERVICE_DIALOG ');
|
||||
SCE_SYSMODULE_JOB_MANAGER :Writeln('SCE_SYSMODULE_JOB_MANAGER ');
|
||||
SCE_SYSMODULE_SOCIAL_SCREEN_DIALOG :Writeln('SCE_SYSMODULE_SOCIAL_SCREEN_DIALOG ');
|
||||
SCE_SYSMODULE_NP_TOOLKIT2 :Writeln('SCE_SYSMODULE_NP_TOOLKIT2 ');
|
||||
else
|
||||
Writeln(HexStr(id,4));
|
||||
end;
|
||||
|
||||
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
|
@ -278,7 +278,7 @@ begin
|
||||
|
||||
if (err<>0) then
|
||||
begin
|
||||
Writeln('Pa_GetErrorText:',Pa_GetErrorText(err));
|
||||
Writeln('Pa_GetErrorText:',PaErrorCode(err),':',Pa_GetErrorText(err));
|
||||
//Exit(SCE_AUDIO_OUT_ERROR_NOT_INIT);
|
||||
pstream:=nil;
|
||||
end;
|
||||
@ -586,9 +586,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
if (err<>0) and (err<>paOutputUnderflow) then
|
||||
Writeln('Pa_GetErrorText:',Pa_GetErrorText(err));
|
||||
Case err of
|
||||
0:;
|
||||
Integer(paOutputUnderflowed):;
|
||||
else
|
||||
Writeln('Pa_GetErrorText:',PaErrorCode(err),':',Pa_GetErrorText(err));
|
||||
end;
|
||||
|
||||
//Writeln('sceAudioOutOutput:',handle,':',HexStr(ptr));
|
||||
|
||||
|
@ -1122,8 +1122,8 @@ begin
|
||||
post_event_vblank(flipArg);
|
||||
end else
|
||||
begin
|
||||
post_event_vblank(flipArg);
|
||||
post_event_flip(flipArg);
|
||||
post_event_vblank(flipArg);
|
||||
end;
|
||||
|
||||
Case _type of
|
||||
@ -1377,8 +1377,7 @@ begin
|
||||
_sig_unlock;
|
||||
if (H=nil) then Exit(SCE_VIDEO_OUT_ERROR_INVALID_HANDLE);
|
||||
|
||||
hz:=H.FlipRate;
|
||||
if (hz=0) then hz:=60;
|
||||
hz:=60; //59.94
|
||||
|
||||
time:=(1000000 div hz);
|
||||
elap:=SwTimePassedUnits(H.VblankStatus.FTsc);
|
||||
|
@ -39,7 +39,7 @@ function SwWaitForSingleObject(
|
||||
TimeOut:PQWORD;
|
||||
Alertable:LONGBOOL):DWORD;
|
||||
|
||||
function SwWaitFor(Handle:THandle;pTimeout:PQWORD):Integer; //pTimeout in 100ns
|
||||
function SwWaitFor(Handle:THandle;pTimeout:PQWORD):Integer; //pTimeout in ns
|
||||
|
||||
Function safe_move(const src;var dst;count:QWORD):QWORD;
|
||||
procedure safe_move_ptr(const src;var dst);
|
||||
|
@ -62,12 +62,6 @@ type
|
||||
|
||||
TvSemaphoreWaitSet=specialize T23treeSet<TvSemaphoreWait,TvSemaphoreWaitCompare>;
|
||||
|
||||
TvImageBarrierCompare=object
|
||||
function c(a,b:TvImageBarrier):Integer; static;
|
||||
end;
|
||||
|
||||
TvImageBarrierSet=specialize T23treeSet<TvImageBarrier,TvImageBarrierCompare>;
|
||||
|
||||
TvCustomCmdBuffer=class
|
||||
parent:TvCmdPool;
|
||||
FQueue:TvQueue;
|
||||
@ -90,8 +84,6 @@ type
|
||||
|
||||
FCBState:Boolean;
|
||||
|
||||
FImageBarriers:TvImageBarrierSet;
|
||||
|
||||
Constructor Create(pool:TvCmdPool;Queue:TvQueue);
|
||||
Destructor Destroy; override;
|
||||
|
||||
@ -107,17 +99,6 @@ type
|
||||
function AddDependence(cb:TvReleaseCb):Boolean;
|
||||
Procedure AddWaitSemaphore(S:TvSemaphore;W:TVkPipelineStageFlags);
|
||||
|
||||
Procedure SetImageBarrier(image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
AccessMask:TVkAccessFlags;
|
||||
ImageLayout:TVkImageLayout;
|
||||
StageMask:TVkPipelineStageFlags);
|
||||
Procedure PushImageBarrier(image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
|
||||
Procedure BindLayout(BindPoint:TVkPipelineBindPoint;F:TvPipelineLayout);
|
||||
Procedure BindSet(BindPoint:TVkPipelineBindPoint;fset:TVkUInt32;FHandle:TVkDescriptorSet);
|
||||
Procedure PushConstant(BindPoint:TVkPipelineBindPoint;stageFlags:TVkShaderStageFlags;offset,size:TVkUInt32;const pValues:PVkVoid);
|
||||
@ -142,6 +123,8 @@ type
|
||||
|
||||
function BeginRenderPass(RT:TvRenderTargets):Boolean;
|
||||
|
||||
function BindCompute(CP:TvComputePipeline2):Boolean;
|
||||
|
||||
Procedure BindSets(BindPoint:TVkPipelineBindPoint;F:TvDescriptorGroup);
|
||||
|
||||
Procedure dmaData(src,dst:Pointer;byteCount:DWORD;isBlocking:Boolean);
|
||||
@ -175,15 +158,6 @@ begin
|
||||
Result:=Integer(Pointer(a.FSemaphore)>Pointer(b.FSemaphore))-Integer(Pointer(a.FSemaphore)<Pointer(b.FSemaphore));
|
||||
end;
|
||||
|
||||
function TvImageBarrierCompare.c(a,b:TvImageBarrier):Integer;
|
||||
begin
|
||||
//1 image
|
||||
Result:=Integer(a.image>b.image)-Integer(a.image<b.image);
|
||||
if (Result<>0) then Exit;
|
||||
//2 range
|
||||
Result:=CompareByte(a.range,b.range,SizeOf(TVkImageSubresourceRange));
|
||||
end;
|
||||
|
||||
Procedure TObjectSetLock.Init;
|
||||
begin
|
||||
rwlock_init(lock);
|
||||
@ -246,12 +220,12 @@ end;
|
||||
|
||||
Destructor TvCustomCmdBuffer.Destroy;
|
||||
begin
|
||||
ReleaseResource;
|
||||
FreeAndNil(Fence);
|
||||
if (parent<>nil) and (cmdbuf<>VK_NULL_HANDLE) then
|
||||
begin
|
||||
parent.Free(cmdbuf);
|
||||
end;
|
||||
ReleaseResource;
|
||||
FreeAndNil(Fence);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -383,6 +357,23 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TvCmdBuffer.BindCompute(CP:TvComputePipeline2):Boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
|
||||
if (Self=nil) or (CP=nil) then Exit;
|
||||
|
||||
BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE,CP.FHandle);
|
||||
BindLayout (VK_PIPELINE_BIND_POINT_COMPUTE,CP.FLayout);
|
||||
|
||||
if AddDependence(@CP.Release) then
|
||||
begin
|
||||
CP.Acquire(Self);
|
||||
end;
|
||||
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
function TvCustomCmdBuffer.QueueSubmit:Boolean;
|
||||
var
|
||||
r:TVkResult;
|
||||
@ -458,6 +449,7 @@ var
|
||||
It:TvRelease.Iterator;
|
||||
begin
|
||||
if (Self=nil) then Exit;
|
||||
|
||||
It:=FDependence.cbegin;
|
||||
if (It.Item<>nil) then
|
||||
repeat
|
||||
@ -473,7 +465,6 @@ begin
|
||||
FDependence.Free;
|
||||
|
||||
FWaitSemaphores.Free;
|
||||
FImageBarriers .Free;
|
||||
|
||||
cmd_count:=0;
|
||||
ret:=0;
|
||||
@ -506,67 +497,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvCustomCmdBuffer.SetImageBarrier(image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
AccessMask:TVkAccessFlags;
|
||||
ImageLayout:TVkImageLayout;
|
||||
StageMask:TVkPipelineStageFlags);
|
||||
var
|
||||
i:TvImageBarrierSet.Iterator;
|
||||
t:TvImageBarrier;
|
||||
begin
|
||||
if (Self=nil) then Exit;
|
||||
if (cmdbuf=VK_NULL_HANDLE) then Exit;
|
||||
|
||||
t:=Default(TvImageBarrier);
|
||||
t.image :=image;
|
||||
t.range :=range;
|
||||
t.AccessMask:=AccessMask;
|
||||
t.ImgLayout :=ImageLayout;
|
||||
t.StageMask :=StageMask;
|
||||
|
||||
i:=FImageBarriers.find(t);
|
||||
|
||||
if (i.Item=nil) then
|
||||
begin
|
||||
FImageBarriers.Insert(t);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvCustomCmdBuffer.PushImageBarrier(image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
var
|
||||
i:TvImageBarrierSet.Iterator;
|
||||
t:TvImageBarrier;
|
||||
p:PvImageBarrier;
|
||||
begin
|
||||
if (Self=nil) then Exit;
|
||||
|
||||
if (not BeginCmdBuffer) then Exit;
|
||||
|
||||
t:=Default(TvImageBarrier);
|
||||
t.Init(image,range);
|
||||
|
||||
i:=FImageBarriers.find(t);
|
||||
|
||||
p:=i.Item;
|
||||
if (p=nil) then
|
||||
begin
|
||||
FImageBarriers.Insert(t);
|
||||
i:=FImageBarriers.find(t);
|
||||
p:=i.Item;
|
||||
end;
|
||||
|
||||
Inc(cmd_count);
|
||||
P^.Push(cmdbuf,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask);
|
||||
end;
|
||||
|
||||
Procedure TvCustomCmdBuffer.BindLayout(BindPoint:TVkPipelineBindPoint;F:TvPipelineLayout);
|
||||
begin
|
||||
if (Self=nil) then Exit;
|
||||
|
@ -73,7 +73,7 @@ type
|
||||
pNext:PVkVoid;
|
||||
end;
|
||||
|
||||
TvDeviceQueues=class
|
||||
TvDeviceCreateInfo=class
|
||||
data:array of TSortQueueRec;
|
||||
exts:array of Pchar;
|
||||
pFeature:PVkVoid;
|
||||
@ -84,18 +84,20 @@ type
|
||||
|
||||
TvDevice=class
|
||||
FHandle:TVkDevice;
|
||||
FLock:Pointer;
|
||||
Constructor Create(Queues:TvDeviceQueues);
|
||||
FLock:System.TRTLCriticalSection;
|
||||
Constructor Create(Queues:TvDeviceCreateInfo);
|
||||
Destructor Destroy; override;
|
||||
function WaitIdle:TVkResult;
|
||||
end;
|
||||
|
||||
TvQueue=class
|
||||
FHandle:TVkQueue;
|
||||
FLock:Pointer;
|
||||
function Submit(submitCount:TVkUInt32;const pSubmits:PVkSubmitInfo;fence:TVkFence):TVkResult;
|
||||
function WaitIdle:TVkResult;
|
||||
function PresentKHR(const pPresentInfo:PVkPresentInfoKHR):TVkResult;
|
||||
FLock:System.TRTLCriticalSection;
|
||||
Constructor Create;
|
||||
Destructor Destroy; override;
|
||||
function Submit(submitCount:TVkUInt32;const pSubmits:PVkSubmitInfo;fence:TVkFence):TVkResult;
|
||||
function WaitIdle:TVkResult;
|
||||
function PresentKHR(const pPresentInfo:PVkPresentInfoKHR):TVkResult;
|
||||
end;
|
||||
|
||||
TvCmdPool=class
|
||||
@ -994,7 +996,7 @@ begin
|
||||
Result:=Fcap.currentExtent;
|
||||
end;
|
||||
|
||||
procedure TvDeviceQueues.add_queue(Index:TVkUInt32;Queue:PVkQueue);
|
||||
procedure TvDeviceCreateInfo.add_queue(Index:TVkUInt32;Queue:PVkQueue);
|
||||
var
|
||||
i,count:Integer;
|
||||
r:Boolean;
|
||||
@ -1024,7 +1026,7 @@ begin
|
||||
data[count].pQueue:=Queue;
|
||||
end;
|
||||
|
||||
procedure TvDeviceQueues.add_ext(P:Pchar);
|
||||
procedure TvDeviceCreateInfo.add_ext(P:Pchar);
|
||||
var
|
||||
i:Integer;
|
||||
begin
|
||||
@ -1033,7 +1035,7 @@ begin
|
||||
exts[i]:=P;
|
||||
end;
|
||||
|
||||
procedure TvDeviceQueues.add_feature(P:PVkVoid);
|
||||
procedure TvDeviceCreateInfo.add_feature(P:PVkVoid);
|
||||
begin
|
||||
PAbstractFeature(P)^.pNext:=pFeature;
|
||||
pFeature:=P;
|
||||
@ -1060,7 +1062,7 @@ begin
|
||||
if (max<1) then max:=1;
|
||||
end;
|
||||
|
||||
Constructor TvDevice.Create(Queues:TvDeviceQueues);
|
||||
Constructor TvDevice.Create(Queues:TvDeviceCreateInfo);
|
||||
Var
|
||||
DeviceFeature:TVkPhysicalDeviceFeatures;
|
||||
SortIndex:TSortIndex;
|
||||
@ -1069,6 +1071,8 @@ Var
|
||||
r:TVkResult;
|
||||
i,p,w:Integer;
|
||||
begin
|
||||
System.InitCriticalSection(FLock);
|
||||
|
||||
DeviceFeature:=VulkanApp.FDeviceFeature;
|
||||
DeviceFeature.robustBufferAccess:=0;
|
||||
|
||||
@ -1119,37 +1123,50 @@ end;
|
||||
|
||||
Destructor TvDevice.Destroy;
|
||||
begin
|
||||
System.DoneCriticalSection(FLock);
|
||||
vkDestroyDevice(FHandle,nil);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TvDevice.WaitIdle:TVkResult;
|
||||
begin
|
||||
spin_lock(FLock);
|
||||
System.EnterCriticalSection(FLock);
|
||||
Result:=vkDeviceWaitIdle(FHandle);
|
||||
spin_unlock(FLock);
|
||||
System.LeaveCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
Constructor TvQueue.Create;
|
||||
begin
|
||||
System.InitCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
Destructor TvQueue.Destroy;
|
||||
begin
|
||||
System.DoneCriticalSection(FLock);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TvQueue.Submit(submitCount:TVkUInt32;const pSubmits:PVkSubmitInfo;fence:TVkFence):TVkResult;
|
||||
begin
|
||||
spin_lock(FLock);
|
||||
System.EnterCriticalSection(FLock);
|
||||
Result:=vkQueueSubmit(FHandle,submitCount,pSubmits,fence);
|
||||
spin_unlock(FLock);
|
||||
System.LeaveCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
function TvQueue.WaitIdle:TVkResult;
|
||||
begin
|
||||
spin_lock(FLock);
|
||||
System.EnterCriticalSection(FLock);
|
||||
Result:=vkQueueWaitIdle(FHandle);
|
||||
spin_unlock(FLock);
|
||||
System.LeaveCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
function TvQueue.PresentKHR(const pPresentInfo:PVkPresentInfoKHR):TVkResult;
|
||||
begin
|
||||
spin_lock(FLock);
|
||||
System.EnterCriticalSection(FLock);
|
||||
Result:=vkQueuePresentKHR(FHandle,pPresentInfo);
|
||||
spin_unlock(FLock);
|
||||
System.LeaveCriticalSection(FLock);
|
||||
end;
|
||||
|
||||
//
|
||||
@ -1497,7 +1514,7 @@ end;
|
||||
|
||||
Procedure InitVulkan;
|
||||
var
|
||||
DeviceQueues:TvDeviceQueues;
|
||||
DeviceInfo:TvDeviceCreateInfo;
|
||||
//ImgProp:TVkFormatProperties;
|
||||
|
||||
F16_8:TVkPhysicalDeviceShaderFloat16Int8Features;
|
||||
@ -1527,35 +1544,35 @@ begin
|
||||
raise Exception.Create('VK_EXT_external_memory_host not support!');
|
||||
end;
|
||||
|
||||
DeviceQueues:=TvDeviceQueues.Create;
|
||||
DeviceInfo:=TvDeviceCreateInfo.Create;
|
||||
|
||||
if (VulkanApp.FGFamilyCount>1) then
|
||||
begin
|
||||
FlipQueue :=TvQueue.Create;
|
||||
RenderQueue:=TvQueue.Create;
|
||||
DeviceQueues.add_queue(VulkanApp.FGFamily,@FlipQueue .FHandle);
|
||||
DeviceQueues.add_queue(VulkanApp.FGFamily,@RenderQueue.FHandle);
|
||||
DeviceInfo.add_queue(VulkanApp.FGFamily,@FlipQueue .FHandle);
|
||||
DeviceInfo.add_queue(VulkanApp.FGFamily,@RenderQueue.FHandle);
|
||||
end else
|
||||
begin
|
||||
FlipQueue :=TvQueue.Create;
|
||||
RenderQueue:=FlipQueue;
|
||||
DeviceQueues.add_queue(VulkanApp.FGFamily,@FlipQueue .FHandle);
|
||||
DeviceInfo.add_queue(VulkanApp.FGFamily,@FlipQueue .FHandle);
|
||||
end;
|
||||
|
||||
DeviceQueues.add_ext(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
|
||||
DeviceQueues.add_ext(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
DeviceQueues.add_ext(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
|
||||
|
||||
if limits.VK_AMD_device_coherent_memory then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME);
|
||||
|
||||
FCoherent:=Default(TVkPhysicalDeviceCoherentMemoryFeaturesAMD);
|
||||
FCoherent.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD;
|
||||
FCoherent.deviceCoherentMemory:=VK_TRUE;
|
||||
|
||||
DeviceQueues.add_feature(@FCoherent);
|
||||
DeviceInfo.add_feature(@FCoherent);
|
||||
end;
|
||||
|
||||
//if limits.VK_KHR_push_descriptor then
|
||||
@ -1565,23 +1582,23 @@ begin
|
||||
|
||||
if limits.VK_KHR_shader_non_semantic_info then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);
|
||||
end;
|
||||
|
||||
if limits.VK_EXT_scalar_block_layout then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME);
|
||||
|
||||
FScalar:=Default(TVkPhysicalDeviceScalarBlockLayoutFeatures);
|
||||
FScalar.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES;
|
||||
FScalar.scalarBlockLayout:=VK_TRUE;
|
||||
|
||||
DeviceQueues.add_feature(@FScalar);
|
||||
DeviceInfo.add_feature(@FScalar);
|
||||
end;
|
||||
|
||||
if limits.VK_KHR_shader_float16_int8 then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
|
||||
end;
|
||||
|
||||
if (VulkanApp.F16_8.shaderInt8<>0) or
|
||||
@ -1592,12 +1609,12 @@ begin
|
||||
F16_8.shaderFloat16:=VulkanApp.F16_8.shaderFloat16;
|
||||
F16_8.shaderInt8 :=VulkanApp.F16_8.shaderInt8;
|
||||
|
||||
DeviceQueues.add_feature(@F16_8);
|
||||
DeviceInfo.add_feature(@F16_8);
|
||||
end;
|
||||
|
||||
if limits.VK_KHR_8bit_storage then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
|
||||
end;
|
||||
|
||||
if (VulkanApp.FSF_8.storageBuffer8BitAccess<>0) or
|
||||
@ -1609,12 +1626,12 @@ begin
|
||||
FSF_8.uniformAndStorageBuffer8BitAccess:=VulkanApp.FSF_8.uniformAndStorageBuffer8BitAccess;
|
||||
//FSF_8.storagePushConstant8
|
||||
|
||||
DeviceQueues.add_feature(@FSF_8);
|
||||
DeviceInfo.add_feature(@FSF_8);
|
||||
end;
|
||||
|
||||
if limits.VK_KHR_16bit_storage then
|
||||
begin
|
||||
DeviceQueues.add_ext(VK_KHR_16BIT_STORAGE_EXTENSION_NAME);
|
||||
DeviceInfo.add_ext(VK_KHR_16BIT_STORAGE_EXTENSION_NAME);
|
||||
end;
|
||||
|
||||
if (VulkanApp.FSF16.storageBuffer16BitAccess<>0) or
|
||||
@ -1628,11 +1645,11 @@ begin
|
||||
//FSF16.storagePushConstant16
|
||||
FSF16.storageInputOutput16 :=VulkanApp.FSF16.storageInputOutput16;
|
||||
|
||||
DeviceQueues.add_feature(@FSF16);
|
||||
DeviceInfo.add_feature(@FSF16);
|
||||
end;
|
||||
|
||||
Device:=TvDevice.Create(DeviceQueues);
|
||||
DeviceQueues.Free;
|
||||
Device:=TvDevice.Create(DeviceInfo);
|
||||
DeviceInfo.Free;
|
||||
|
||||
MemManager:=TvMemManager.Create;
|
||||
|
||||
|
229
vulkan/vFlip.pas
229
vulkan/vFlip.pas
@ -16,8 +16,7 @@ uses
|
||||
vBuffer,
|
||||
vImage,
|
||||
vImageManager,
|
||||
vCmdBuffer,
|
||||
vRender;
|
||||
vCmdBuffer;
|
||||
|
||||
type
|
||||
TFlipCfg=packed object
|
||||
@ -47,9 +46,6 @@ type
|
||||
|
||||
FSet:TvDescriptorSet;
|
||||
|
||||
//cmdfence:TvFence; //
|
||||
//cmdbuf:TVkCommandBuffer; //
|
||||
|
||||
cmdbuf:TvCustomCmdBuffer;
|
||||
|
||||
Extent:TVkExtent3D;
|
||||
@ -68,9 +64,6 @@ type
|
||||
|
||||
Cursors:array[0..SCE_VIDEO_OUT_CURSOR_NUM_MAX-1] of TvFlipBufferCursor;
|
||||
|
||||
//ur:TURDevcImage2D;
|
||||
//ur:TvImage2;
|
||||
|
||||
Procedure Init(Flip:TvFlip);
|
||||
Procedure Free(Flip:TvFlip);
|
||||
function IsPrepare:Boolean;
|
||||
@ -90,7 +83,7 @@ type
|
||||
|
||||
TvFlip=class
|
||||
FSurface:TVSurface;
|
||||
FSwapChain:TSwapChain;
|
||||
FSwapChain:TvSwapChain;
|
||||
FSetLayout:TvSetLayout;
|
||||
FLayout:TvPipelineLayout;
|
||||
FPipelineFlip:TvComputePipeline;
|
||||
@ -152,7 +145,6 @@ end;
|
||||
Constructor TvFlip.Create(Handle:THandle);
|
||||
var
|
||||
i:Byte;
|
||||
//P1,P2,P3:TvPointer;
|
||||
begin
|
||||
InitVulkan;
|
||||
|
||||
@ -228,15 +220,6 @@ begin
|
||||
begin
|
||||
cmdbuf:=TvCustomCmdBuffer.Create(Flip.FCmdPool,FlipQueue);
|
||||
end;
|
||||
|
||||
{if (cmdbuf=VK_NULL_HANDLE) then
|
||||
begin
|
||||
cmdbuf:=Flip.FCmdPool.Alloc;
|
||||
end;
|
||||
if (cmdfence=nil) then
|
||||
begin
|
||||
cmdfence:=TvFence.Create(true);
|
||||
end;}
|
||||
end;
|
||||
|
||||
Procedure TvFlipBuffer.Free(Flip:TvFlip);
|
||||
@ -247,14 +230,7 @@ begin
|
||||
FreeAndNil(HostBuf);
|
||||
|
||||
FreeAndNil(cmdbuf);
|
||||
{
|
||||
FreeAndNil(cmdfence);
|
||||
if (cmdbuf<>VK_NULL_HANDLE) then
|
||||
begin
|
||||
Flip.FCmdPool.Free(cmdbuf);
|
||||
cmdbuf:=VK_NULL_HANDLE;
|
||||
end;
|
||||
}
|
||||
|
||||
MemManager.Free(DevcMem);
|
||||
DevcMem:=Default(TvPointer);
|
||||
Cursors[0].Free;
|
||||
@ -265,8 +241,6 @@ function TvFlipBuffer.IsPrepare:Boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
if (FSet=nil) then Exit;
|
||||
//if (cmdfence=nil) then Exit;
|
||||
//if (cmdbuf=VK_NULL_HANDLE) then Exit;
|
||||
if (cmdbuf=nil) then Exit;
|
||||
if (DstImgNORM=nil) then Exit;
|
||||
if (ImgViewDst=nil) then Exit;
|
||||
@ -424,7 +398,6 @@ end;
|
||||
Procedure TvFlip.SetImageSize(width,height:DWORD);
|
||||
var
|
||||
buf:PvFlipBuffer;
|
||||
//mt:TVkUInt32;
|
||||
memr:TVkMemoryRequirements;
|
||||
begin
|
||||
buf:=@FBuffers[FcurrentBuffer];
|
||||
@ -509,26 +482,11 @@ const
|
||||
handleTypes:ord(VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT);
|
||||
);
|
||||
var
|
||||
//r:TURDevcImage2D;
|
||||
//r:TvImage2;
|
||||
hbuf:TvPointer;
|
||||
buf:PvFlipBuffer;
|
||||
begin
|
||||
buf:=@FBuffers[FcurrentBuffer];
|
||||
|
||||
{
|
||||
r:=FindImage(nil,Addr,cformat);
|
||||
//r:=FindUnionImage2D(Addr);
|
||||
if (r<>nil) then
|
||||
begin
|
||||
FreeAndNil(buf^.HostBuf);
|
||||
buf^.ur:=r;
|
||||
end else
|
||||
begin
|
||||
buf^.ur:=nil;
|
||||
end;
|
||||
}
|
||||
|
||||
hbuf:=Default(TvPointer);
|
||||
if not TryGetHostPointerByAddr(addr,hbuf) then Exit;
|
||||
|
||||
@ -589,14 +547,14 @@ procedure TvFlip.recreateSwapChain;
|
||||
begin
|
||||
Device.WaitIdle;
|
||||
FreeAndNil(FSwapChain);
|
||||
FSwapChain:=TSwapChain.Create(FSurface,0{1},ord(VK_IMAGE_USAGE_TRANSFER_DST_BIT));
|
||||
FSwapChain:=TvSwapChain.Create(FSurface,0{1},ord(VK_IMAGE_USAGE_TRANSFER_DST_BIT));
|
||||
end;
|
||||
|
||||
Procedure TvFlip.FixCurrentFrame;
|
||||
begin
|
||||
if (FSwapChain=nil) then Exit;
|
||||
if (Length(FSwapChain.FImage)=0) then Exit;
|
||||
FcurrentFrame:=FcurrentFrame mod Length(FSwapChain.FImage);
|
||||
if (Length(FSwapChain.FImages)=0) then Exit;
|
||||
FcurrentFrame:=FcurrentFrame mod Length(FSwapChain.FImages);
|
||||
end;
|
||||
|
||||
function TvFlip.IsComplite(currentBuffer:Byte):Boolean;
|
||||
@ -636,7 +594,7 @@ Procedure TvFlip.Flip;
|
||||
var
|
||||
r:TVkResult;
|
||||
imageIndex:TVkUInt32;
|
||||
SwapImage:TVkImage;
|
||||
SwapImage:TvSwapChainImage;
|
||||
|
||||
imageAvailableSemaphore:TvSemaphore;
|
||||
renderFinishedSemaphore:TvSemaphore;
|
||||
@ -652,7 +610,7 @@ var
|
||||
|
||||
prInfo:TVkPresentInfoKHR;
|
||||
|
||||
//img_reg:TVkImageCopy;
|
||||
img_reg:TVkImageCopy;
|
||||
|
||||
ur:TvImage2;
|
||||
begin
|
||||
@ -698,7 +656,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
until false;
|
||||
SwapImage:=FSwapChain.FImage[imageIndex];
|
||||
SwapImage:=FSwapChain.FImages[imageIndex];
|
||||
|
||||
//Writeln('>Flip.Fence.Wait');
|
||||
if (buf^.cmdbuf.ret=0) then
|
||||
@ -729,19 +687,19 @@ begin
|
||||
|
||||
FCurSet.BindSTI(1,0,buf^.ImgViewDst.FHandle,VK_IMAGE_LAYOUT_GENERAL);
|
||||
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgNORM.FHandle,
|
||||
buf^.DstImgNORM.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
begin
|
||||
buf^.DstImgSRGB.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgSRGB.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
end;
|
||||
|
||||
buf^.cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE,FPipelineFlip.FHandle);
|
||||
@ -765,61 +723,28 @@ begin
|
||||
end else
|
||||
begin
|
||||
|
||||
buf^.cmdbuf.SetImageBarrier(ur.FHandle,SubresColor,
|
||||
ord(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT));
|
||||
ur.PushBarrier(buf^.cmdbuf,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
buf^.cmdbuf.PushImageBarrier(ur.FHandle,SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
if (buf^.DstImgSRGB<>nil) and (ur.key.cformat=VK_FORMAT_R8G8B8A8_SRGB) then
|
||||
begin
|
||||
buf^.DstImgSRGB.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) and (ur.key.cformat=VK_FORMAT_R8G8B8A8_SRGB) then
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgSRGB.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
end else
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgNORM.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
buf^.DstImgNORM.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
end;
|
||||
|
||||
imgBlitRegion:=Default(TVkImageBlit);
|
||||
imgBlitRegion.srcSubresource.aspectMask:=ord(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
imgBlitRegion.srcSubresource.layerCount:=1;
|
||||
imgBlitRegion.dstSubresource.aspectMask:=ord(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
imgBlitRegion.dstSubresource.layerCount:=1;
|
||||
imgBlitRegion.srcOffsets[1].x:=ur.key.params.extend.width;
|
||||
imgBlitRegion.srcOffsets[1].y:=ur.key.params.extend.height;
|
||||
imgBlitRegion.srcOffsets[1].z:=1;
|
||||
imgBlitRegion.dstOffsets[1].x:=buf^.DstImgNORM.FExtent.width;
|
||||
imgBlitRegion.dstOffsets[1].y:=buf^.DstImgNORM.FExtent.height;
|
||||
imgBlitRegion.dstOffsets[1].z:=1;
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) and (ur.key.cformat=VK_FORMAT_R8G8B8A8_SRGB) then
|
||||
begin
|
||||
vkCmdBlitImage(
|
||||
buf^.cmdbuf.cmdbuf,
|
||||
ur.FHandle ,VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
buf^.DstImgSRGB.FHandle,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,@imgBlitRegion,VK_FILTER_LINEAR);
|
||||
end else
|
||||
begin
|
||||
vkCmdBlitImage(
|
||||
buf^.cmdbuf.cmdbuf,
|
||||
ur.FHandle ,VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
buf^.DstImgNORM.FHandle,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,@imgBlitRegion,VK_FILTER_LINEAR);
|
||||
end;
|
||||
|
||||
{
|
||||
img_reg:=Default(TVkImageCopy);
|
||||
img_reg.srcSubresource.aspectMask:=ord(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
img_reg.srcSubresource.layerCount:=1;
|
||||
@ -831,7 +756,7 @@ begin
|
||||
ur.key.params.extend.height,
|
||||
1);
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
if (buf^.DstImgSRGB<>nil) and (ur.key.cformat=VK_FORMAT_R8G8B8A8_SRGB) then
|
||||
begin
|
||||
|
||||
vkCmdCopyImage(buf^.cmdbuf.cmdbuf,
|
||||
@ -852,7 +777,6 @@ begin
|
||||
1,@img_reg);
|
||||
|
||||
end;
|
||||
}
|
||||
|
||||
end;
|
||||
|
||||
@ -888,18 +812,18 @@ begin
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgSRGB.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
buf^.DstImgSRGB.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
end else
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgNORM.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
buf^.DstImgNORM.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
end;
|
||||
|
||||
buf^.cmdbuf.PushConstant(VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
@ -944,18 +868,18 @@ begin
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgSRGB.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
buf^.DstImgSRGB.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
end else
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgNORM.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
buf^.DstImgNORM.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_SHADER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
ord(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT));
|
||||
end;
|
||||
|
||||
buf^.cmdbuf.PushConstant(VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||
@ -982,25 +906,25 @@ begin
|
||||
|
||||
if (buf^.DstImgSRGB<>nil) then
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgSRGB.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
buf^.DstImgSRGB.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
end else
|
||||
begin
|
||||
buf^.cmdbuf.PushImageBarrier(buf^.DstImgNORM.FHandle,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
buf^.DstImgNORM.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
end;
|
||||
|
||||
buf^.cmdbuf.PushImageBarrier(SwapImage,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
SwapImage.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
imgBlitRegion:=Default(TVkImageBlit);
|
||||
imgBlitRegion.srcSubresource.aspectMask:=ord(VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
@ -1019,23 +943,23 @@ begin
|
||||
vkCmdBlitImage(
|
||||
buf^.cmdbuf.cmdbuf,
|
||||
buf^.DstImgSRGB.FHandle,VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
SwapImage ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
SwapImage.FHandle ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,@imgBlitRegion,VK_FILTER_LINEAR);
|
||||
end else
|
||||
begin
|
||||
vkCmdBlitImage(
|
||||
buf^.cmdbuf.cmdbuf,
|
||||
buf^.DstImgNORM.FHandle,VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
SwapImage ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
SwapImage.FHandle ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
1,@imgBlitRegion,VK_FILTER_LINEAR);
|
||||
end;
|
||||
|
||||
|
||||
buf^.cmdbuf.PushImageBarrier(SwapImage,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_NONE_KHR),
|
||||
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT));
|
||||
SwapImage.PushBarrier(buf^.cmdbuf.cmdbuf,
|
||||
SubresColor,
|
||||
ord(VK_ACCESS_NONE_KHR),
|
||||
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT));
|
||||
|
||||
buf^.cmdbuf.EndCmdBuffer;
|
||||
|
||||
@ -1076,7 +1000,6 @@ begin
|
||||
|
||||
FcurrentFrame:=FcurrentFrame+1;
|
||||
FixCurrentFrame;
|
||||
//vkQueueWaitIdle(FlipQueue);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@ type
|
||||
Foffset:TVkDeviceSize; //offset inside buffer
|
||||
//
|
||||
FRefs:ptruint;
|
||||
//FDeps:TObjectSetLock;
|
||||
Procedure Acquire(Sender:TObject);
|
||||
procedure Release(Sender:TObject);
|
||||
end;
|
||||
@ -42,8 +41,8 @@ type
|
||||
function c(a,b:PPointer):Integer; static;
|
||||
end;
|
||||
|
||||
_TvHostBufferPool=specialize T23treeSet<PPointer,TvAddrCompare>;
|
||||
TvHostBufferPool=object(_TvHostBufferPool)
|
||||
_TvHostBufferSet=specialize T23treeSet<PPointer,TvAddrCompare>;
|
||||
TvHostBufferSet=object(_TvHostBufferSet)
|
||||
lock:TRWLock;
|
||||
Procedure Init;
|
||||
Procedure Lock_wr;
|
||||
@ -51,19 +50,19 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
FHostBufferPool:TvHostBufferPool;
|
||||
FHostBufferSet:TvHostBufferSet;
|
||||
|
||||
Procedure TvHostBufferPool.Init;
|
||||
Procedure TvHostBufferSet.Init;
|
||||
begin
|
||||
rwlock_init(lock);
|
||||
end;
|
||||
|
||||
Procedure TvHostBufferPool.Lock_wr;
|
||||
Procedure TvHostBufferSet.Lock_wr;
|
||||
begin
|
||||
rwlock_wrlock(lock);
|
||||
end;
|
||||
|
||||
Procedure TvHostBufferPool.Unlock;
|
||||
Procedure TvHostBufferSet.Unlock;
|
||||
begin
|
||||
rwlock_unlock(lock);
|
||||
end;
|
||||
@ -75,10 +74,10 @@ end;
|
||||
|
||||
function _Find(Addr:Pointer):TvHostBuffer;
|
||||
var
|
||||
i:TvHostBufferPool.Iterator;
|
||||
i:TvHostBufferSet.Iterator;
|
||||
begin
|
||||
Result:=nil;
|
||||
i:=FHostBufferPool.find(@Addr);
|
||||
i:=FHostBufferSet.find(@Addr);
|
||||
if (i.Item<>nil) then
|
||||
begin
|
||||
Result:=TvHostBuffer(ptruint(i.Item^)-ptruint(@TvHostBuffer(nil).FAddr));
|
||||
@ -108,7 +107,6 @@ begin
|
||||
FreeAndNil(t);
|
||||
|
||||
t:=TvHostBuffer.Create(Size,usage,@buf_ext);
|
||||
//t.FDeps.Init;
|
||||
end;
|
||||
|
||||
t.Fhost:=host;
|
||||
@ -129,7 +127,7 @@ label
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
FHostBufferPool.Lock_wr;
|
||||
FHostBufferSet.Lock_wr;
|
||||
|
||||
t:=_Find(Addr);
|
||||
|
||||
@ -139,21 +137,23 @@ begin
|
||||
((t.FUsage and usage)<>usage) then
|
||||
begin
|
||||
usage:=usage or t.FUsage;
|
||||
FHostBufferSet.delete(@t.FAddr);
|
||||
t.Release(nil);
|
||||
t:=nil;
|
||||
end;
|
||||
FHostBufferPool.delete(@t.FAddr);
|
||||
t.Release(nil);
|
||||
t:=nil;
|
||||
end;
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
//Writeln('NewBuf:',HexStr(Addr));
|
||||
host:=Default(TvPointer);
|
||||
if not TryGetHostPointerByAddr(addr,host) then
|
||||
begin
|
||||
Goto _exit;
|
||||
end;
|
||||
t:=_New(host,Size,usage);
|
||||
FHostBufferPool.Insert(@t.FAddr);
|
||||
t.FAddr:=addr;
|
||||
FHostBufferSet.Insert(@t.FAddr);
|
||||
t.Acquire(nil);
|
||||
end;
|
||||
|
||||
@ -166,25 +166,17 @@ begin
|
||||
end;
|
||||
|
||||
_exit:
|
||||
FHostBufferPool.Unlock;
|
||||
FHostBufferSet.Unlock;
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
Procedure TvHostBuffer.Acquire(Sender:TObject);
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
//if (Sender<>nil) then
|
||||
//begin
|
||||
// FDeps.Insert(Sender);
|
||||
//end;
|
||||
end;
|
||||
|
||||
procedure TvHostBuffer.Release(Sender:TObject);
|
||||
begin
|
||||
//if (Sender<>nil) then
|
||||
//begin
|
||||
// FDeps.delete(Sender);
|
||||
//end;
|
||||
if System.InterlockedDecrement(Pointer(FRefs))=nil then
|
||||
begin
|
||||
Free;
|
||||
@ -192,7 +184,7 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
FHostBufferPool.Init;
|
||||
FHostBufferSet.Init;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -5,19 +5,45 @@ unit vImage;
|
||||
interface
|
||||
|
||||
uses
|
||||
g23tree,
|
||||
vulkan,
|
||||
vDevice,
|
||||
vPipeline,
|
||||
vMemory;
|
||||
|
||||
type
|
||||
TSwapChain=class
|
||||
PvImageBarrier=^TvImageBarrier;
|
||||
TvImageBarrier=object
|
||||
//image:TVkImage;
|
||||
//range:TVkImageSubresourceRange;
|
||||
//
|
||||
AccessMask:TVkAccessFlags;
|
||||
ImgLayout:TVkImageLayout;
|
||||
StageMask:TVkPipelineStageFlags;
|
||||
Procedure Init({_image:TVkImage;_sub:TVkImageSubresourceRange});
|
||||
function Push(cmd:TVkCommandBuffer;
|
||||
image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags):Boolean;
|
||||
end;
|
||||
|
||||
TvSwapChainImage=class
|
||||
FHandle:TVkImage;
|
||||
FView :TVkImage;
|
||||
Barrier:TvImageBarrier;
|
||||
procedure PushBarrier(cmd:TVkCommandBuffer;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
end;
|
||||
|
||||
TvSwapChain=class
|
||||
FSurface:TvSurface;
|
||||
FSize:TVkExtent2D;
|
||||
FHandle:TVkSwapchainKHR;
|
||||
FImage:array of TVkImage;
|
||||
FViews:array of TVkImageView;
|
||||
FImages:array of TvSwapChainImage;
|
||||
Constructor Create(Surface:TvSurface;mode:Integer;imageUsage:TVkImageUsageFlags);
|
||||
Destructor Destroy; override;
|
||||
end;
|
||||
@ -86,11 +112,17 @@ type
|
||||
FFormat:TVkFormat;
|
||||
FUsage:TVkFlags;
|
||||
FExtent:TVkExtent3D;
|
||||
Barrier:TvImageBarrier;
|
||||
Constructor Create(format:TVkFormat;extent:TVkExtent3D;usage:TVkFlags;ext:Pointer=nil);
|
||||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
function GetViewInfo:TVkImageViewCreateInfo; virtual; abstract;
|
||||
function NewView:TvImageView;
|
||||
//function NewViewF(Format:TVkFormat):TvImageView;
|
||||
procedure PushBarrier(cmd:TVkCommandBuffer;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
end;
|
||||
|
||||
TvHostImage1D=class(TvImage)
|
||||
@ -111,12 +143,6 @@ type
|
||||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
end;
|
||||
|
||||
//_TvImageViewCompare=object
|
||||
// function c(const a,b:TvImageView):Integer; static;
|
||||
//end;
|
||||
|
||||
//_TvImageViewSet=specialize T23treeSet<TvImageView,_TvImageViewCompare>;
|
||||
|
||||
AvFramebufferImages=array[0..8] of TvImageView;
|
||||
AvImageViews=array[0..8] of TVkImageView;
|
||||
|
||||
@ -125,7 +151,6 @@ type
|
||||
FEdit,FCompile:ptruint;
|
||||
FRenderPass:TvRenderPass;
|
||||
FSize:TVkExtent2D;
|
||||
//FImages:_TvImageViewSet;
|
||||
FImages:AvFramebufferImages;
|
||||
FImagesCount:ptruint;
|
||||
Procedure SetRenderPass(r:TvRenderPass);
|
||||
@ -137,30 +162,10 @@ type
|
||||
Destructor Destroy; override;
|
||||
end;
|
||||
|
||||
PvImageBarrier=^TvImageBarrier;
|
||||
TvImageBarrier=object
|
||||
image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
//
|
||||
AccessMask:TVkAccessFlags;
|
||||
ImgLayout:TVkImageLayout;
|
||||
StageMask:TVkPipelineStageFlags;
|
||||
Procedure Init(_image:TVkImage;_sub:TVkImageSubresourceRange);
|
||||
procedure Push(cmd:TVkCommandBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
end;
|
||||
|
||||
Function GetAspectMaskByFormat(cformat:TVkFormat):DWORD;
|
||||
|
||||
implementation
|
||||
|
||||
//function _TvImageViewCompare.c(const a,b:TvImageView):Integer;
|
||||
//begin
|
||||
// Result:=Integer(Pointer(a)>Pointer(b))-Integer(Pointer(a)<Pointer(b));
|
||||
//end;
|
||||
|
||||
Procedure TvFramebuffer.SetRenderPass(r:TvRenderPass);
|
||||
begin
|
||||
if (r=FRenderPass) then Exit;
|
||||
@ -182,15 +187,11 @@ begin
|
||||
FImages[FImagesCount]:=v;
|
||||
Inc(FImagesCount);
|
||||
v.Acquire;
|
||||
//if FImages.Contains(v) then Exit;
|
||||
//v.Acquire;
|
||||
//FImages.Insert(v);
|
||||
Inc(FEdit);
|
||||
end;
|
||||
|
||||
Procedure TvFramebuffer.FreeImageViews;
|
||||
var
|
||||
// It:_TvImageViewSet.Iterator;
|
||||
i:Integer;
|
||||
begin
|
||||
if (FImagesCount<>0) then
|
||||
@ -219,8 +220,6 @@ end;
|
||||
function TvFramebuffer.Compile:Boolean;
|
||||
var
|
||||
i:TVkUInt32;
|
||||
//It:_TvImageViewSet.Iterator;
|
||||
//v:TvImageView;
|
||||
r:TVkResult;
|
||||
info:TVkFramebufferCreateInfo;
|
||||
FImageViews:AvImageViews;
|
||||
@ -240,7 +239,7 @@ begin
|
||||
info:=Default(TVkFramebufferCreateInfo);
|
||||
info.sType :=VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
info.renderPass :=FRenderPass.FHandle;
|
||||
info.attachmentCount:={FImages.Size}FImagesCount;
|
||||
info.attachmentCount:=FImagesCount;
|
||||
info.width :=FSize.width;
|
||||
info.height:=FSize.height;
|
||||
info.layers:=1;
|
||||
@ -256,21 +255,6 @@ begin
|
||||
end;
|
||||
|
||||
info.pAttachments:=@FImageViews;
|
||||
{
|
||||
info.pAttachments:=AllocMem(info.attachmentCount*SizeOf(TVkImageView));
|
||||
i:=0;
|
||||
It:=FImages.cbegin;
|
||||
if (It.Item<>nil) then
|
||||
repeat
|
||||
v:=It.Item^;
|
||||
if (v<>nil) then
|
||||
begin
|
||||
info.pAttachments[i]:=v.FHandle;
|
||||
Inc(i);
|
||||
end;
|
||||
until not It.Next;
|
||||
info.attachmentCount:=i;
|
||||
}
|
||||
end;
|
||||
|
||||
if (info.attachmentCount=0) then
|
||||
@ -287,9 +271,6 @@ begin
|
||||
Writeln('vkCreateFramebuffer');
|
||||
end;
|
||||
|
||||
//if (info.pAttachments<>nil) then
|
||||
// FreeMem(info.pAttachments);
|
||||
|
||||
Result:=(r=VK_SUCCESS);
|
||||
end;
|
||||
|
||||
@ -301,13 +282,15 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
Constructor TSwapChain.Create(Surface:TvSurface;mode:Integer;imageUsage:TVkImageUsageFlags);
|
||||
Constructor TvSwapChain.Create(Surface:TvSurface;mode:Integer;imageUsage:TVkImageUsageFlags);
|
||||
var
|
||||
queueFamilyIndices:array[0..1] of TVkUInt32;
|
||||
cinfo:TVkSwapchainCreateInfoKHR;
|
||||
r:TVkResult;
|
||||
i,count:TVkUInt32;
|
||||
cimg:TVkImageViewCreateInfo;
|
||||
FImage:array of TVkImage;
|
||||
FView:TVkImageView;
|
||||
begin
|
||||
FSurface:=Surface;
|
||||
|
||||
@ -364,7 +347,7 @@ begin
|
||||
end;
|
||||
|
||||
SetLength(FImage,count);
|
||||
SetLength(FViews,count);
|
||||
SetLength(FImages,count);
|
||||
|
||||
r:=vkGetSwapchainImagesKHR(Device.FHandle,FHandle,@count,@FImage[0]);
|
||||
if (r<>VK_SUCCESS) then
|
||||
@ -390,22 +373,28 @@ begin
|
||||
For i:=0 to count-1 do
|
||||
begin
|
||||
cimg.image:=FImage[i];
|
||||
r:=vkCreateImageView(Device.FHandle,@cimg,nil,@FViews[i]);
|
||||
FView:=VK_NULL_HANDLE;
|
||||
r:=vkCreateImageView(Device.FHandle,@cimg,nil,@FView);
|
||||
if (r<>VK_SUCCESS) then
|
||||
begin
|
||||
Writeln('vkCreateImageView:',r);
|
||||
Exit;
|
||||
end;
|
||||
FImages[i]:=TvSwapChainImage.Create;
|
||||
FImages[i].FHandle:=FImage[i];
|
||||
FImages[i].FView :=FView;
|
||||
FImages[i].Barrier.Init;
|
||||
end;
|
||||
end;
|
||||
|
||||
Destructor TSwapChain.Destroy;
|
||||
Destructor TvSwapChain.Destroy;
|
||||
var
|
||||
i:Integer;
|
||||
begin
|
||||
For i:=0 to High(FViews) do
|
||||
For i:=0 to High(FImages) do
|
||||
begin
|
||||
vkDestroyImageView(Device.FHandle,FViews[i],nil);
|
||||
vkDestroyImageView(Device.FHandle,FImages[i].FView,nil);
|
||||
FImages[i].Free;
|
||||
end;
|
||||
vkDestroySwapchainKHR(Device.FHandle,FHandle,nil);
|
||||
end;
|
||||
@ -478,6 +467,7 @@ begin
|
||||
FFormat:=format;
|
||||
FUsage:=usage;
|
||||
FExtent:=extent;
|
||||
Barrier.Init;
|
||||
Compile(ext);
|
||||
end;
|
||||
|
||||
@ -509,6 +499,38 @@ begin
|
||||
Result.FHandle:=FImg;
|
||||
end;
|
||||
|
||||
procedure TvSwapChainImage.PushBarrier(cmd:TVkCommandBuffer;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
begin
|
||||
if (cmd=VK_NULL_HANDLE) then Exit;
|
||||
|
||||
Barrier.Push(cmd,
|
||||
FHandle,
|
||||
range,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask);
|
||||
end;
|
||||
|
||||
procedure TvImage.PushBarrier(cmd:TVkCommandBuffer;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
begin
|
||||
if (cmd=VK_NULL_HANDLE) then Exit;
|
||||
|
||||
Barrier.Push(cmd,
|
||||
FHandle,
|
||||
range,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask);
|
||||
end;
|
||||
|
||||
{
|
||||
function TvImage.NewViewF(Format:TVkFormat):TvImageView;
|
||||
var
|
||||
@ -677,35 +699,41 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvImageBarrier.Init(_image:TVkImage;_sub:TVkImageSubresourceRange);
|
||||
Procedure TvImageBarrier.Init({_image:TVkImage;_sub:TVkImageSubresourceRange});
|
||||
begin
|
||||
image :=_image;
|
||||
range :=_sub;
|
||||
//image :=_image;
|
||||
//range :=_sub;
|
||||
AccessMask:=ord(VK_ACCESS_NONE_KHR);
|
||||
ImgLayout :=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
StageMask :=ord(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT);
|
||||
end;
|
||||
|
||||
procedure TvImageBarrier.Push(cmd:TVkCommandBuffer;
|
||||
function TvImageBarrier.Push(cmd:TVkCommandBuffer;
|
||||
image:TVkImage;
|
||||
range:TVkImageSubresourceRange;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
dstStageMask:TVkPipelineStageFlags):Boolean;
|
||||
var
|
||||
info:TVkImageMemoryBarrier;
|
||||
begin
|
||||
info:=Default(TVkImageMemoryBarrier);
|
||||
info.sType :=VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
info.srcAccessMask :=AccessMask;
|
||||
info.dstAccessMask :=dstAccessMask;
|
||||
info.oldLayout :=ImgLayout;
|
||||
info.newLayout :=newImageLayout;
|
||||
info.image :=image;
|
||||
info.subresourceRange:=range;
|
||||
Result:=False;
|
||||
|
||||
if (AccessMask<>dstAccessMask) or
|
||||
(ImgLayout <>newImageLayout) or
|
||||
(StageMask <>dstStageMask) then
|
||||
begin
|
||||
Result:=True;
|
||||
|
||||
info:=Default(TVkImageMemoryBarrier);
|
||||
info.sType :=VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
info.srcAccessMask :=AccessMask;
|
||||
info.dstAccessMask :=dstAccessMask;
|
||||
info.oldLayout :=ImgLayout;
|
||||
info.newLayout :=newImageLayout;
|
||||
info.image :=image;
|
||||
info.subresourceRange:=range;
|
||||
|
||||
vkCmdPipelineBarrier(cmd,
|
||||
StageMask,
|
||||
dstStageMask,
|
||||
|
@ -20,28 +20,49 @@ type
|
||||
function c(a,b:PvImageViewKey):Integer; static;
|
||||
end;
|
||||
|
||||
TvImage2=class;
|
||||
|
||||
TvImageView2=class(TvImageView)
|
||||
Parent:TvImage2;
|
||||
key:TvImageViewKey;
|
||||
procedure Release(Sender:TObject);
|
||||
Function GetSubresRange:TVkImageSubresourceRange;
|
||||
Function GetSubresLayer:TVkImageSubresourceLayers;
|
||||
//
|
||||
//Barrier:TvImageBarrier;
|
||||
//
|
||||
//Constructor Create;
|
||||
procedure PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
procedure Release(Sender:TObject);
|
||||
Function GetSubresRange:TVkImageSubresourceRange;
|
||||
Function GetSubresLayer:TVkImageSubresourceLayers;
|
||||
end;
|
||||
|
||||
TvImageView2Set=specialize T23treeSet<PvImageViewKey,TvImageView2Compare>;
|
||||
|
||||
TvImage2=class;
|
||||
|
||||
TvHostImage2=class(TvCustomImage)
|
||||
parent:TvImage2;
|
||||
Parent:TvImage2;
|
||||
FUsage:TVkFlags;
|
||||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
//
|
||||
Barrier:TvImageBarrier;
|
||||
//
|
||||
Constructor Create;
|
||||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
procedure PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
end;
|
||||
|
||||
TvImage2=class(TvCustomImage)
|
||||
key:TvImageKey;
|
||||
FUsage:TVkFlags;
|
||||
//
|
||||
lock:TRWLock;
|
||||
FViews:TvImageView2Set;
|
||||
//
|
||||
Barrier:TvImageBarrier;
|
||||
//
|
||||
FHostImage:TvHostImage2;
|
||||
//
|
||||
Fdevc:TvPointer;
|
||||
@ -50,6 +71,7 @@ type
|
||||
FDeps:TObjectSetLock;
|
||||
//
|
||||
data_usage:Byte;
|
||||
Constructor Create;
|
||||
Destructor Destroy; override;
|
||||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
Function GetSubresRange:TVkImageSubresourceRange;
|
||||
@ -57,6 +79,10 @@ type
|
||||
function FetchView(cmd:TvCustomCmdBuffer;var F:TvImageViewKey):TvImageView2;
|
||||
function FetchView(cmd:TvCustomCmdBuffer):TvImageView2;
|
||||
function FetchHostImage(cmd:TvCustomCmdBuffer;usage:TVkFlags):TvHostImage2;
|
||||
procedure PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
Procedure Acquire(Sender:TObject);
|
||||
procedure Release(Sender:TObject);
|
||||
end;
|
||||
@ -121,6 +147,37 @@ begin
|
||||
Result:=CompareByte(a^,b^,SizeOf(TvImageViewKey));
|
||||
end;
|
||||
|
||||
{
|
||||
Constructor TvImageView2.Create;
|
||||
begin
|
||||
inherited;
|
||||
Barrier.Init;
|
||||
end;
|
||||
}
|
||||
|
||||
procedure TvImageView2.PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
begin
|
||||
if (Parent=nil) then Exit;
|
||||
Parent.PushBarrier(cmd,dstAccessMask,newImageLayout,dstStageMask);
|
||||
{
|
||||
if (cmd=nil) then Exit;
|
||||
if (not cmd.BeginCmdBuffer) then Exit;
|
||||
|
||||
if Barrier.Push(cmd.cmdbuf,
|
||||
Parent.FHandle,
|
||||
GetSubresRange,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask) then
|
||||
begin
|
||||
Inc(cmd.cmd_count);
|
||||
end;
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TvImageView2.Release(Sender:TObject);
|
||||
begin
|
||||
inherited Release;
|
||||
@ -145,6 +202,13 @@ begin
|
||||
Result.layerCount :=key.last_array-key.base_array+1;
|
||||
end;
|
||||
|
||||
Constructor TvImage2.Create;
|
||||
begin
|
||||
inherited;
|
||||
rwlock_init(lock);
|
||||
Barrier.Init;
|
||||
end;
|
||||
|
||||
Destructor TvImage2.Destroy;
|
||||
var
|
||||
i:TvImageView2Set.Iterator;
|
||||
@ -180,9 +244,15 @@ begin
|
||||
Result.initialLayout:=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
end;
|
||||
|
||||
Constructor TvHostImage2.Create;
|
||||
begin
|
||||
inherited;
|
||||
Barrier.Init;
|
||||
end;
|
||||
|
||||
function TvHostImage2.GetImageInfo:TVkImageCreateInfo;
|
||||
begin
|
||||
Result:=parent.GetImageInfo;
|
||||
Result:=Parent.GetImageInfo;
|
||||
Result.tiling:=VK_IMAGE_TILING_LINEAR;
|
||||
Result.usage :=FUsage;
|
||||
end;
|
||||
@ -216,6 +286,8 @@ begin
|
||||
Result:=nil;
|
||||
if (FHandle=VK_NULL_HANDLE) then Exit;
|
||||
|
||||
rwlock_wrlock(lock);
|
||||
|
||||
t:=nil;
|
||||
i:=FViews.find(@F);
|
||||
if (i.Item<>nil) then
|
||||
@ -243,12 +315,14 @@ begin
|
||||
r:=vkCreateImageView(Device.FHandle,@cinfo,nil,@FView);
|
||||
if (r<>VK_SUCCESS) then
|
||||
begin
|
||||
rwlock_unlock(lock);
|
||||
Writeln('vkCreateImageView:',r);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
t:=TvImageView2.Create;
|
||||
t.FHandle:=FView;
|
||||
t.Parent :=Self;
|
||||
t.key :=F;
|
||||
|
||||
t.Acquire;
|
||||
@ -263,6 +337,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
rwlock_unlock(lock);
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
@ -317,7 +393,7 @@ begin
|
||||
end;
|
||||
|
||||
t:=TvHostImage2.Create;
|
||||
t.parent:=Self;
|
||||
t.Parent:=Self;
|
||||
t.FUsage:=usage;
|
||||
|
||||
if not t.Compile(@img_ext) then
|
||||
@ -352,6 +428,44 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TvImage2.PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
begin
|
||||
if (cmd=nil) then Exit;
|
||||
if (not cmd.BeginCmdBuffer) then Exit;
|
||||
|
||||
if Barrier.Push(cmd.cmdbuf,
|
||||
FHandle,
|
||||
GetSubresRange,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask) then
|
||||
begin
|
||||
Inc(cmd.cmd_count);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TvHostImage2.PushBarrier(cmd:TvCustomCmdBuffer;
|
||||
dstAccessMask:TVkAccessFlags;
|
||||
newImageLayout:TVkImageLayout;
|
||||
dstStageMask:TVkPipelineStageFlags);
|
||||
begin
|
||||
if (cmd=nil) then Exit;
|
||||
if (not cmd.BeginCmdBuffer) then Exit;
|
||||
|
||||
if Barrier.Push(cmd.cmdbuf,
|
||||
FHandle,
|
||||
Parent.GetSubresRange,
|
||||
dstAccessMask,
|
||||
newImageLayout,
|
||||
dstStageMask) then
|
||||
begin
|
||||
Inc(cmd.cmd_count);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvImage2.Acquire(Sender:TObject);
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
@ -496,64 +610,6 @@ begin
|
||||
FImage2Set.Unlock;
|
||||
end;
|
||||
|
||||
{
|
||||
function _FetchImageView2D(cmd:TvCustomCmdBuffer;
|
||||
Addr:Pointer;
|
||||
tiling_idx:Byte;
|
||||
cformat:TVkFormat;
|
||||
extend:TVkExtent2D;
|
||||
usage:TVkFlags):TvImageView2;
|
||||
var
|
||||
FImageKey:TvImageKey;
|
||||
FImageViewKey:TvImageViewKey;
|
||||
|
||||
Image:TvImage2;
|
||||
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
FImageKey:=Default(TvImageKey);
|
||||
FImageKey.Addr:=Addr;
|
||||
FImageKey.cformat:=cformat;
|
||||
FImageKey.params.itype :=ord(VK_IMAGE_TYPE_2D);
|
||||
FImageKey.params.tiling_idx :=tiling_idx;
|
||||
FImageKey.params.extend.width :=extend.width;
|
||||
FImageKey.params.extend.height:=extend.height;
|
||||
FImageKey.params.extend.depth :=1;
|
||||
FImageKey.params.samples :=1;
|
||||
FImageKey.params.mipLevels :=1;
|
||||
FImageKey.params.arrayLayers :=1;
|
||||
|
||||
FImageViewKey:=Default(TvImageViewKey);
|
||||
FImageViewKey.cformat:=cformat;
|
||||
FImageViewKey.vtype :=ord(VK_IMAGE_VIEW_TYPE_2D);
|
||||
//FImageViewKey.dstSel
|
||||
//FImageViewKey.base_level:Byte;
|
||||
//FImageViewKey.last_level:Byte;
|
||||
//FImageViewKey.base_array:Word;
|
||||
//FImageViewKey.last_array:Word;
|
||||
|
||||
FImage2Set.Lock_wr;
|
||||
|
||||
Image:=_FetchImage(FImageKey,usage);
|
||||
|
||||
if (cmd<>nil) and (Image<>nil) then
|
||||
begin
|
||||
if cmd.AddDependence(@Image.Release) then
|
||||
begin
|
||||
Image.Acquire(cmd);
|
||||
end;
|
||||
end;
|
||||
|
||||
if (Image<>nil) then
|
||||
begin
|
||||
Result:=Image.FetchView(cmd,FImageViewKey);
|
||||
end;
|
||||
|
||||
FImage2Set.Unlock;
|
||||
end;
|
||||
}
|
||||
|
||||
initialization
|
||||
FImage2Set.Init;
|
||||
|
||||
|
@ -51,11 +51,10 @@ begin
|
||||
image.key.params.extend.depth*
|
||||
getFormatSize(image.key.cformat);
|
||||
|
||||
cmd.PushImageBarrier(image.FHandle,
|
||||
image.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
image.PushBarrier(cmd,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
buf:=FetchHostBuffer(cmd,
|
||||
image.key.Addr,
|
||||
@ -110,17 +109,15 @@ begin
|
||||
|
||||
Assert(buf<>nil,'FetchHostImage');
|
||||
|
||||
cmd.PushImageBarrier(image.FHandle,
|
||||
image.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
image.PushBarrier(cmd,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
cmd.PushImageBarrier(buf.FHandle,
|
||||
image.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
buf.PushBarrier(cmd,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
|
||||
ImageCopy:=Default(TVkImageCopy);
|
||||
@ -175,11 +172,10 @@ begin
|
||||
image.key.params.extend.depth*
|
||||
getFormatSize(image.key.cformat);
|
||||
|
||||
cmd.PushImageBarrier(image.FHandle,
|
||||
image.GetSubresRange,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
image.PushBarrier(cmd,
|
||||
ord(VK_ACCESS_TRANSFER_WRITE_BIT),
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
ord(VK_PIPELINE_STAGE_TRANSFER_BIT));
|
||||
|
||||
vkBufferMemoryBarrier(cmd.cmdbuf,
|
||||
buf.FHandle,
|
||||
@ -280,6 +276,8 @@ begin
|
||||
Case image.key.cformat of
|
||||
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGB_SRGB_BLOCK,
|
||||
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
VK_FORMAT_BC3_SRGB_BLOCK:
|
||||
begin
|
||||
|
@ -917,18 +917,18 @@ begin
|
||||
Result:=False;
|
||||
if (FHandle<>VK_NULL_HANDLE) then Exit(true);
|
||||
|
||||
if ({key.}FPipeline=nil) then Exit;
|
||||
if (FPipeline=nil) then Exit;
|
||||
if (FmaxGroup=0) then Exit;
|
||||
|
||||
if (not {key.}FPipeline.Compile) then Exit;
|
||||
if (not FPipeline.Compile) then Exit;
|
||||
FSizes:=Default(AvDescriptorPoolSize);
|
||||
|
||||
FmaxSets:=0;
|
||||
FCounts:=Default(TvCountsGroup);
|
||||
|
||||
if Length({key.}FPipeline.key.FLayouts)<>0 then
|
||||
For i:=0 to High({key.}FPipeline.key.FLayouts) do
|
||||
With {key.}FPipeline.key.FLayouts[i] do
|
||||
if Length(FPipeline.key.FLayouts)<>0 then
|
||||
For i:=0 to High(FPipeline.key.FLayouts) do
|
||||
With FPipeline.key.FLayouts[i] do
|
||||
if (Length(key.FBinds)<>0) then
|
||||
begin
|
||||
Inc(FmaxSets,FmaxGroup);
|
||||
@ -963,9 +963,6 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//FGroups:=Default(AvDescriptorGroup);
|
||||
//SetLength(FGroups,FmaxGroup);
|
||||
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
@ -997,39 +994,6 @@ begin
|
||||
Result.FHandle:=FResult;
|
||||
end;
|
||||
|
||||
{
|
||||
function TvSetsPool2.Alloc:TvDescriptorGroup;
|
||||
var
|
||||
i,s:Integer;
|
||||
begin
|
||||
Result:=nil;
|
||||
if Length(FGroups)<>0 then
|
||||
For i:=0 to High(FGroups) do
|
||||
begin
|
||||
if (FGroups[i]=nil) then
|
||||
begin
|
||||
Result:=TvDescriptorGroup.Create;
|
||||
Result.lock:=1;
|
||||
SetLength(Result.FSets,Length(key.FPipeline.key.FLayouts));
|
||||
|
||||
If (Length(Result.FSets)<>0) then
|
||||
For s:=0 to High(Result.FSets) do
|
||||
begin
|
||||
Result.FSets[s]:=Alloc(key.FPipeline.key.FLayouts[s]);
|
||||
end;
|
||||
|
||||
FGroups[i]:=Result;
|
||||
end else
|
||||
if (FGroups[i].lock=0) then
|
||||
begin
|
||||
Result:=FGroups[i];
|
||||
Result.lock:=1;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
}
|
||||
|
||||
function TvSetsPool2.IsFull:Boolean;
|
||||
begin
|
||||
Result:=(FAlcGroup>=FmaxGroup);
|
||||
|
@ -21,8 +21,8 @@ type
|
||||
class function c(a,b:PvPipelineLayoutKey):Integer; static;
|
||||
end;
|
||||
|
||||
_TvPipelineLayoutPool=specialize T23treeSet<PvPipelineLayoutKey,TvPipelineLayoutCompare>;
|
||||
TvPipelineLayoutPool=object(_TvPipelineLayoutPool)
|
||||
_TvPipelineLayoutSet=specialize T23treeSet<PvPipelineLayoutKey,TvPipelineLayoutCompare>;
|
||||
TvPipelineLayoutSet=object(_TvPipelineLayoutSet)
|
||||
lock:TRWLock;
|
||||
Procedure Init;
|
||||
Procedure Lock_wr;
|
||||
@ -30,54 +30,73 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
FPipelineLayoutPool:TvPipelineLayoutPool;
|
||||
FPipelineLayoutSet:TvPipelineLayoutSet;
|
||||
|
||||
Procedure TvPipelineLayoutPool.Init;
|
||||
Procedure TvPipelineLayoutSet.Init;
|
||||
begin
|
||||
rwlock_init(lock);
|
||||
end;
|
||||
|
||||
Procedure TvPipelineLayoutPool.Lock_wr;
|
||||
Procedure TvPipelineLayoutSet.Lock_wr;
|
||||
begin
|
||||
rwlock_wrlock(lock);
|
||||
end;
|
||||
|
||||
Procedure TvPipelineLayoutPool.Unlock;
|
||||
Procedure TvPipelineLayoutSet.Unlock;
|
||||
begin
|
||||
rwlock_unlock(lock);
|
||||
end;
|
||||
|
||||
function _Find(F:PvPipelineLayoutKey):TvPipelineLayout;
|
||||
var
|
||||
i:TvPipelineLayoutSet.Iterator;
|
||||
begin
|
||||
Result:=nil;
|
||||
i:=FPipelineLayoutSet.find(F);
|
||||
if (i.Item<>nil) then
|
||||
begin
|
||||
Result:=TvPipelineLayout(ptruint(i.Item^)-ptruint(@TvPipelineLayout(nil).key));
|
||||
end;
|
||||
end;
|
||||
|
||||
Function _Fetch(F:PvPipelineLayoutKey):TvPipelineLayout;
|
||||
var
|
||||
t:TvPipelineLayout;
|
||||
begin
|
||||
t:=_Find(F);
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
t:=TvPipelineLayout.Create;
|
||||
t.key:=F^;
|
||||
|
||||
if not t.Compile then
|
||||
begin
|
||||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
FPipelineLayoutSet.Insert(@t.key);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
Function FetchPipelineLayout(const A:AvSetLayout;
|
||||
const B:AvPushConstantRange):TvPipelineLayout;
|
||||
var
|
||||
key:TvPipelineLayoutKey;
|
||||
|
||||
t:TvPipelineLayout;
|
||||
i:TvPipelineLayoutPool.Iterator;
|
||||
begin
|
||||
key:=Default(TvPipelineLayoutKey);
|
||||
key.FLayouts :=A;
|
||||
key.FPushConsts:=B;
|
||||
|
||||
FPipelineLayoutPool.Lock_wr;
|
||||
FPipelineLayoutSet.Lock_wr;
|
||||
|
||||
i:=FPipelineLayoutPool.find(@key);
|
||||
if (i.Item=nil) then
|
||||
begin
|
||||
t:=TvPipelineLayout.Create;
|
||||
t.key:=key;
|
||||
FPipelineLayoutPool.Insert(@t.key);
|
||||
Result:=t;
|
||||
end else
|
||||
begin
|
||||
t:=TvPipelineLayout(ptruint(i.Item^)-ptruint(@TvPipelineLayout(nil).key));
|
||||
Result:=_Fetch(@key);
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
FPipelineLayoutPool.Unlock;
|
||||
|
||||
t.Compile;
|
||||
FPipelineLayoutSet.Unlock;
|
||||
end;
|
||||
|
||||
function ComparePtruint(buf1,buf2:PPtruint;count:PtrUint):Integer;
|
||||
@ -134,7 +153,7 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
FPipelineLayoutPool.Init;
|
||||
FPipelineLayoutSet.Init;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -22,6 +22,12 @@ uses
|
||||
vImage;
|
||||
|
||||
type
|
||||
TvComputePipeline2=class(TvComputePipeline)
|
||||
FRefs:ptruint;
|
||||
Procedure Acquire(Sender:TObject);
|
||||
Procedure Release(Sender:TOBject);
|
||||
end;
|
||||
|
||||
TvRenderPass=class(vPipeline.TvRenderPass)
|
||||
|
||||
AtCount:TVkUInt32;
|
||||
@ -39,14 +45,11 @@ type
|
||||
Procedure AddColorRef(id:TVkUInt32;IMAGE_USAGE:Byte);
|
||||
Procedure SetDepthStencilRef(id:TVkUInt32;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
Procedure AddColorAt(format:TVkFormat;IMAGE_USAGE:Byte;samples:TVkSampleCountFlagBits);
|
||||
//Procedure AddColorAt(format:TVkFormat;ClearColor,DrawColor:Boolean;samples:TVkSampleCountFlagBits);
|
||||
//Procedure AddDepthAt(format:TVkFormat;ClearDepth,DrawDepth,ClearStencil,DrawStencil:Boolean);
|
||||
Procedure AddDepthAt(format:TVkFormat;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
Function Compile:Boolean;
|
||||
end;
|
||||
|
||||
TvGraphicsPipeline=class(TvPipeline)
|
||||
//FLayout:TvPipelineLayout;
|
||||
FRenderPass:TvRenderPass;
|
||||
|
||||
Viewports:array[0..15] of TVkViewport; //viewportState.viewportCount
|
||||
@ -54,7 +57,6 @@ type
|
||||
|
||||
ColorBlends:array[0..7] of TVkPipelineColorBlendAttachmentState; //colorBlending.attachmentCount
|
||||
|
||||
//FShaders:array[0..5] of TvShader;
|
||||
FShaderGroup:TvShaderGroup;
|
||||
|
||||
dynamicStates:array[0..1] of TVkDynamicState; //dynamicState.dynamicStateCount
|
||||
@ -249,37 +251,6 @@ begin
|
||||
Inc(AtCount);
|
||||
end;
|
||||
|
||||
{
|
||||
Procedure TvRenderPass.AddColorAt(format:TVkFormat;ClearColor,DrawColor:Boolean;samples:TVkSampleCountFlagBits);
|
||||
begin
|
||||
if (AtCount>8) then Exit;
|
||||
|
||||
ColorAt[AtCount]:=Default(TVkAttachmentDescription);
|
||||
ColorAt[AtCount].format :=format;
|
||||
ColorAt[AtCount].samples :=samples{VK_SAMPLE_COUNT_1_BIT};
|
||||
|
||||
Case ClearColor of
|
||||
True :ColorAt[AtCount].loadOp:=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
False:ColorAt[AtCount].loadOp:={VK_ATTACHMENT_LOAD_OP_DONT_CARE} VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
end;
|
||||
|
||||
Case DrawColor of
|
||||
True :ColorAt[AtCount].storeOp:=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
False:ColorAt[AtCount].storeOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
ColorAt[AtCount].stencilLoadOp :=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
ColorAt[AtCount].stencilStoreOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
|
||||
ColorAt[AtCount].initialLayout :={VK_IMAGE_LAYOUT_UNDEFINED} VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
ColorAt[AtCount].finalLayout :=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
{VK_IMAGE_LAYOUT_GENERAL}
|
||||
{VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL};
|
||||
Inc(AtCount);
|
||||
end;
|
||||
}
|
||||
|
||||
Function GetDepthStencilLayout(DEPTH_USAGE,STENCIL_USAGE:Byte):TVkImageLayout;
|
||||
begin
|
||||
if ((DEPTH_USAGE or STENCIL_USAGE) and (TM_WRITE or TM_CLEAR)<>0) then
|
||||
@ -463,7 +434,6 @@ begin
|
||||
FillChar(Viewports ,SizeOf(Viewports),0);
|
||||
FillChar(Scissors ,SizeOf(Scissors) ,0);
|
||||
FillChar(ColorBlends,SizeOf(ColorBlends),0);
|
||||
//FillChar(FShaders ,SizeOf(FShaders),0);
|
||||
|
||||
FShaderGroup:=nil;
|
||||
|
||||
@ -477,10 +447,10 @@ begin
|
||||
rasterizer:=Default(TVkPipelineRasterizationStateCreateInfo);
|
||||
rasterizer.sType :=VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
rasterizer.depthClampEnable:=VK_FALSE;
|
||||
rasterizer.rasterizerDiscardEnable:=VK_FALSE; //DB_SHADER_CONTROL.KILL_ENABLE DB_RENDER_CONTROL.FORCE_COLOR_KILL
|
||||
rasterizer.polygonMode :=VK_POLYGON_MODE_FILL; //PA_SU_SC_MODE_CNTL.POLY_MODE POLYMODE_FRONT_PTYPE POLYMODE_BACK_PTYPE
|
||||
rasterizer.lineWidth :=1; //PA_SU_LINE_CNTL.WIDTH
|
||||
rasterizer.cullMode :=ord(VK_CULL_MODE_NONE); //CULL_FRONT CULL_BACK
|
||||
rasterizer.rasterizerDiscardEnable:=VK_FALSE; //DB_SHADER_CONTROL.KILL_ENABLE DB_RENDER_CONTROL.FORCE_COLOR_KILL
|
||||
rasterizer.polygonMode :=VK_POLYGON_MODE_FILL; //PA_SU_SC_MODE_CNTL.POLY_MODE POLYMODE_FRONT_PTYPE POLYMODE_BACK_PTYPE
|
||||
rasterizer.lineWidth :=1; //PA_SU_LINE_CNTL.WIDTH
|
||||
rasterizer.cullMode :=ord(VK_CULL_MODE_NONE); //CULL_FRONT CULL_BACK
|
||||
rasterizer.frontFace :=VK_FRONT_FACE_COUNTER_CLOCKWISE; //FACE
|
||||
rasterizer.depthBiasEnable :=VK_FALSE;
|
||||
rasterizer.depthBiasConstantFactor:=0;
|
||||
@ -554,7 +524,6 @@ begin
|
||||
Result:=False;
|
||||
|
||||
if (FShaderGroup=nil) then Exit;
|
||||
//if (FLayout=nil) then Exit;
|
||||
if (FRenderPass=nil) then Exit;
|
||||
if (viewportState.viewportCount=0) then Exit;
|
||||
if (viewportState.scissorCount=0) then Exit;
|
||||
@ -563,7 +532,7 @@ begin
|
||||
|
||||
Stages:=Default(AVkPipelineShaderStageCreateInfo);
|
||||
|
||||
FShaderGroup.ExportStages(@Stages,@info.stageCount);
|
||||
FShaderGroup.FKey.ExportStages(@Stages,@info.stageCount);
|
||||
|
||||
if (info.stageCount=0) then Exit;
|
||||
|
||||
@ -642,6 +611,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvComputePipeline2.Acquire(Sender:TObject);
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
end;
|
||||
|
||||
Procedure TvComputePipeline2.Release(Sender:TOBject);
|
||||
begin
|
||||
if System.InterlockedDecrement(Pointer(FRefs))=nil then
|
||||
begin
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
//////////////
|
||||
|
||||
|
||||
|
396
vulkan/vRenderPassManager.pas
Normal file
396
vulkan/vRenderPassManager.pas
Normal file
@ -0,0 +1,396 @@
|
||||
unit vRenderPassManager;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
RWLock,
|
||||
g23tree,
|
||||
Vulkan,
|
||||
vDevice,
|
||||
vImage,
|
||||
vPipeline,
|
||||
vCmdBuffer;
|
||||
|
||||
type
|
||||
PvRenderPassKey=^TvRenderPassKey;
|
||||
TvRenderPassKey=packed object
|
||||
AtdCount:Byte;
|
||||
RefCount:Byte; //VkSubpassDescription.colorAttachmentCount
|
||||
DepCount:Byte; //DepthRef
|
||||
_align:Byte;
|
||||
ColorAtd:array[0..8] of TVkAttachmentDescription;
|
||||
ColorRef:array[0..7] of TVkAttachmentReference;
|
||||
DepthRef:TVkAttachmentReference;
|
||||
Dependency:TVkSubpassDependency;
|
||||
Procedure Clear;
|
||||
Procedure SetZorderStage(s:TVkPipelineStageFlags);
|
||||
Procedure AddColorRef(id:TVkUInt32;IMAGE_USAGE:Byte);
|
||||
Procedure SetDepthRef(id:TVkUInt32;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
Procedure AddColorAt(format:TVkFormat;IMAGE_USAGE:Byte;samples:TVkSampleCountFlagBits);
|
||||
Procedure AddDepthAt(format:TVkFormat;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
end;
|
||||
|
||||
TvRenderPass2=class(TvRenderPass)
|
||||
Key:TvRenderPassKey;
|
||||
//
|
||||
FRefs:ptruint;
|
||||
Function Compile:Boolean;
|
||||
Procedure Acquire;
|
||||
procedure Release(Sender:TObject);
|
||||
end;
|
||||
|
||||
function FetchRenderPass(cmd:TvCustomCmdBuffer;P:PvRenderPassKey):TvRenderPass2;
|
||||
|
||||
implementation
|
||||
|
||||
type
|
||||
TvRenderPassKey2Compare=object
|
||||
function c(a,b:PvRenderPassKey):Integer; static;
|
||||
end;
|
||||
|
||||
_TvRenderPass2Set=specialize T23treeSet<PvRenderPassKey,TvRenderPassKey2Compare>;
|
||||
TvRenderPass2Set=object(_TvRenderPass2Set)
|
||||
lock:TRWLock;
|
||||
Procedure Init;
|
||||
Procedure Lock_wr;
|
||||
Procedure Unlock;
|
||||
end;
|
||||
|
||||
var
|
||||
FRenderPass2Set:TvRenderPass2Set;
|
||||
|
||||
Function GetDepthStencilLayout(DEPTH_USAGE,STENCIL_USAGE:Byte):TVkImageLayout;
|
||||
begin
|
||||
if ((DEPTH_USAGE or STENCIL_USAGE) and (TM_WRITE or TM_CLEAR)<>0) then
|
||||
begin
|
||||
Result:=VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
end else
|
||||
begin
|
||||
Result:=VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function GetDepthStencilAccessMask(DEPTH_USAGE,STENCIL_USAGE:Byte):TVkAccessFlags;
|
||||
begin
|
||||
Result:=(ord(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT) *ord((DEPTH_USAGE or STENCIL_USAGE) and TM_READ <>0) ) or
|
||||
(ord(VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT)*ord((DEPTH_USAGE or STENCIL_USAGE) and (TM_WRITE or TM_CLEAR)<>0) );
|
||||
end;
|
||||
|
||||
Function GetColorAccessMask(IMAGE_USAGE:Byte):TVkAccessFlags;
|
||||
begin
|
||||
Result:=(ord(VK_ACCESS_COLOR_ATTACHMENT_READ_BIT) *ord(IMAGE_USAGE and TM_READ<>0) ) or
|
||||
(ord(VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT)*ord(IMAGE_USAGE and (TM_WRITE or TM_CLEAR)<>0) );
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.Clear;
|
||||
begin
|
||||
Self:=Default(TvRenderPassKey);
|
||||
Dependency.srcSubpass:=VK_SUBPASS_EXTERNAL;
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.SetZorderStage(s:TVkPipelineStageFlags);
|
||||
begin
|
||||
Dependency.srcStageMask:=Dependency.srcStageMask or s;
|
||||
Dependency.dstStageMask:=Dependency.dstStageMask or s;
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.AddColorRef(id:TVkUInt32;IMAGE_USAGE:Byte);
|
||||
var
|
||||
am:TVkAccessFlags;
|
||||
begin
|
||||
if (RefCount>7) then Exit;
|
||||
ColorRef[RefCount].attachment:=id;
|
||||
ColorRef[RefCount].layout :=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL{VK_IMAGE_LAYOUT_GENERAL};
|
||||
Inc(RefCount);
|
||||
|
||||
Dependency.srcStageMask :=Dependency.srcStageMask or ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||
Dependency.dstStageMask :=Dependency.dstStageMask or ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
|
||||
|
||||
am:=GetColorAccessMask(IMAGE_USAGE);
|
||||
|
||||
Dependency.srcAccessMask:=Dependency.srcAccessMask or am;
|
||||
Dependency.dstAccessMask:=Dependency.dstAccessMask or am;
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.SetDepthRef(id:TVkUInt32;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
var
|
||||
am:TVkAccessFlags;
|
||||
begin
|
||||
DepCount:=1;
|
||||
|
||||
DepthRef.attachment :=id;
|
||||
DepthRef.layout :=GetDepthStencilLayout(DEPTH_USAGE,STENCIL_USAGE);
|
||||
|
||||
am:=GetDepthStencilAccessMask(DEPTH_USAGE,STENCIL_USAGE);
|
||||
|
||||
Dependency.srcAccessMask:=Dependency.srcAccessMask or am;
|
||||
Dependency.dstAccessMask:=Dependency.dstAccessMask or am;
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.AddColorAt(format:TVkFormat;IMAGE_USAGE:Byte;samples:TVkSampleCountFlagBits);
|
||||
begin
|
||||
if (AtdCount>8) then Exit;
|
||||
|
||||
ColorAtd[AtdCount]:=Default(TVkAttachmentDescription);
|
||||
ColorAtd[AtdCount].format :=format;
|
||||
ColorAtd[AtdCount].samples :=samples;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (IMAGE_USAGE and TM_CLEAR<>0) then
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
end else
|
||||
if (IMAGE_USAGE and TM_READ<>0) then
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
end else
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (IMAGE_USAGE and TM_WRITE<>0) then
|
||||
begin
|
||||
storeOp:=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
end else
|
||||
begin
|
||||
storeOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
ColorAtd[AtdCount].stencilLoadOp :=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
ColorAtd[AtdCount].stencilStoreOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (IMAGE_USAGE and TM_READ<>0) then
|
||||
begin
|
||||
initialLayout :=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
end else
|
||||
begin
|
||||
initialLayout :=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
finalLayout:=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
||||
Inc(AtdCount);
|
||||
end;
|
||||
|
||||
Procedure TvRenderPassKey.AddDepthAt(format:TVkFormat;DEPTH_USAGE,STENCIL_USAGE:Byte);
|
||||
begin
|
||||
if (AtdCount>8) then Exit;
|
||||
|
||||
ColorAtd[AtdCount]:=Default(TVkAttachmentDescription);
|
||||
ColorAtd[AtdCount].format :=format;
|
||||
ColorAtd[AtdCount].samples :=VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (DEPTH_USAGE and TM_CLEAR<>0) then
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
end else
|
||||
if (DEPTH_USAGE and TM_READ<>0) then
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
end else
|
||||
begin
|
||||
loadOp:=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (DEPTH_USAGE and TM_WRITE<>0) then
|
||||
begin
|
||||
storeOp:=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
end else
|
||||
begin
|
||||
storeOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (STENCIL_USAGE and TM_CLEAR<>0) then
|
||||
begin
|
||||
stencilLoadOp:=VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
end else
|
||||
if (STENCIL_USAGE and TM_READ<>0) then
|
||||
begin
|
||||
stencilLoadOp:=VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
end else
|
||||
begin
|
||||
stencilLoadOp:=VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if (STENCIL_USAGE and TM_WRITE<>0) then
|
||||
begin
|
||||
stencilStoreOp:=VK_ATTACHMENT_STORE_OP_STORE;
|
||||
end else
|
||||
begin
|
||||
stencilStoreOp:=VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
if ((DEPTH_USAGE or STENCIL_USAGE) and TM_READ<>0) then
|
||||
begin
|
||||
initialLayout :=GetDepthStencilLayout(DEPTH_USAGE,STENCIL_USAGE);
|
||||
end else
|
||||
begin
|
||||
initialLayout :=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
end;
|
||||
|
||||
With ColorAtd[AtdCount] do
|
||||
finalLayout:=GetDepthStencilLayout(DEPTH_USAGE,STENCIL_USAGE);
|
||||
|
||||
Inc(AtdCount);
|
||||
end;
|
||||
|
||||
///
|
||||
|
||||
Function TvRenderPass2.Compile:Boolean;
|
||||
var
|
||||
r:TVkResult;
|
||||
sub:TVkSubpassDescription;
|
||||
info:TVkRenderPassCreateInfo;
|
||||
begin
|
||||
Result:=False;
|
||||
if (Key.AtdCount=0) then Exit;
|
||||
|
||||
if (FHandle<>VK_NULL_HANDLE) then Exit(True);
|
||||
|
||||
sub:=Default(TVkSubpassDescription);
|
||||
sub.pipelineBindPoint:=VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
|
||||
sub.inputAttachmentCount :=0;
|
||||
sub.pInputAttachments :=nil;
|
||||
|
||||
sub.colorAttachmentCount :=Key.RefCount;
|
||||
sub.pColorAttachments :=@Key.ColorRef;
|
||||
|
||||
sub.pResolveAttachments :=nil; //colorAttachmentCount VK_ATTACHMENT_UNUSED
|
||||
|
||||
if (Key.DepCount<>0) then
|
||||
begin
|
||||
sub.pDepthStencilAttachment:=@Key.DepthRef; //1
|
||||
end;
|
||||
|
||||
sub.preserveAttachmentCount:=0;
|
||||
sub.pPreserveAttachments :=nil;
|
||||
|
||||
info:=Default(TVkRenderPassCreateInfo);
|
||||
info.sType :=VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
info.attachmentCount:=Key.AtdCount;
|
||||
info.pAttachments :=@Key.ColorAtd;
|
||||
info.subpassCount :=1;
|
||||
info.pSubpasses :=@sub;
|
||||
info.dependencyCount:=1;
|
||||
info.pDependencies :=@Key.Dependency;
|
||||
|
||||
r:=vkCreateRenderPass(Device.FHandle,@info,nil,@FHandle);
|
||||
if (r<>VK_SUCCESS) then
|
||||
begin
|
||||
Writeln('vkCreateRenderPass');
|
||||
Exit;
|
||||
end;
|
||||
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
Procedure TvRenderPass2Set.Init;
|
||||
begin
|
||||
rwlock_init(lock);
|
||||
end;
|
||||
|
||||
Procedure TvRenderPass2Set.Lock_wr;
|
||||
begin
|
||||
rwlock_wrlock(lock);
|
||||
end;
|
||||
|
||||
Procedure TvRenderPass2Set.Unlock;
|
||||
begin
|
||||
rwlock_unlock(lock);
|
||||
end;
|
||||
|
||||
Procedure TvRenderPass2.Acquire;
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
end;
|
||||
|
||||
procedure TvRenderPass2.Release(Sender:TObject);
|
||||
begin
|
||||
if System.InterlockedDecrement(Pointer(FRefs))=nil then
|
||||
begin
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TvRenderPassKey2Compare.c(a,b:PvRenderPassKey):Integer;
|
||||
begin
|
||||
Result:=CompareByte(a^,b^,SizeOf(TvRenderPassKey));
|
||||
end;
|
||||
|
||||
function _Find(P:PvRenderPassKey):TvRenderPass2;
|
||||
var
|
||||
i:TvRenderPass2Set.Iterator;
|
||||
begin
|
||||
Result:=nil;
|
||||
i:=FRenderPass2Set.find(P);
|
||||
if (i.Item<>nil) then
|
||||
begin
|
||||
Result:=TvRenderPass2(ptruint(i.Item^)-ptruint(@TvRenderPass2(nil).key));
|
||||
end;
|
||||
end;
|
||||
|
||||
function _FetchRenderPass(P:PvRenderPassKey):TvRenderPass2;
|
||||
var
|
||||
t:TvRenderPass2;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
t:=_Find(P);
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
|
||||
t:=TvRenderPass2.Create;
|
||||
t.key:=P^;
|
||||
|
||||
if not t.Compile then
|
||||
begin
|
||||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
t.Acquire;
|
||||
FRenderPass2Set.Insert(@t.key);
|
||||
end;
|
||||
end;
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
function FetchRenderPass(cmd:TvCustomCmdBuffer;P:PvRenderPassKey):TvRenderPass2;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (P=nil) then Exit;
|
||||
|
||||
FRenderPass2Set.Lock_wr;
|
||||
|
||||
Result:=_FetchRenderPass(P);
|
||||
|
||||
if (cmd<>nil) and (Result<>nil) then
|
||||
begin
|
||||
if cmd.AddDependence(@TvRenderPass2(Result).Release) then
|
||||
begin
|
||||
TvRenderPass2(Result).Acquire;
|
||||
end;
|
||||
end;
|
||||
|
||||
FRenderPass2Set.Unlock;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
FRenderPass2Set.Init;
|
||||
|
||||
end.
|
||||
|
@ -119,6 +119,7 @@ end;
|
||||
|
||||
function FetchSampler(cmd:TvCustomCmdBuffer;PS:PSSharpResource4):TvSampler;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (PS=nil) then Exit;
|
||||
|
||||
FSampler2Set.Lock_wr;
|
||||
|
@ -95,9 +95,9 @@ type
|
||||
|
||||
AvShaderStage=array[TvShaderStage] of TvShaderExt;
|
||||
|
||||
TvShaderGroup=class
|
||||
PvShadersKey=^TvShadersKey;
|
||||
TvShadersKey=object
|
||||
FShaders:AvShaderStage;
|
||||
FLayout:TvPipelineLayout;
|
||||
Procedure SetLSShader(Shader:TvShaderExt);
|
||||
Procedure SetHSShader(Shader:TvShaderExt);
|
||||
Procedure SetESShader(Shader:TvShaderExt);
|
||||
@ -105,9 +105,15 @@ type
|
||||
Procedure SetVSShader(Shader:TvShaderExt);
|
||||
Procedure SetPSShader(Shader:TvShaderExt);
|
||||
Procedure SetCSShader(Shader:TvShaderExt);
|
||||
procedure ExportLayout(var A:AvSetLayout;var B:AvPushConstantRange);
|
||||
Procedure ExportStages(Stages:PVkPipelineShaderStageCreateInfo;stageCount:PVkUInt32);
|
||||
end;
|
||||
|
||||
TvShaderGroup=class
|
||||
FKey:TvShadersKey;
|
||||
FLayout:TvPipelineLayout;
|
||||
Procedure Clear;
|
||||
Function Compile:Boolean;
|
||||
Procedure ExportStages(Stages:PVkPipelineShaderStageCreateInfo;stageCount:PVkUInt32);
|
||||
end;
|
||||
|
||||
TAttrBindExt=packed record
|
||||
@ -739,73 +745,61 @@ end;
|
||||
|
||||
//
|
||||
|
||||
Procedure TvShaderGroup.SetLSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetLSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_VERTEX_BIT) then
|
||||
FShaders[vShaderStageLs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetHSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetHSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) then
|
||||
FShaders[vShaderStageHs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetESShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetESShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) then
|
||||
FShaders[vShaderStageEs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetGSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetGSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_GEOMETRY_BIT) then
|
||||
FShaders[vShaderStageGs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetVSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetVSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_VERTEX_BIT) then
|
||||
FShaders[vShaderStageVs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetPSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetPSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_FRAGMENT_BIT) then
|
||||
FShaders[vShaderStagePs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.SetCSShader(Shader:TvShaderExt);
|
||||
Procedure TvShadersKey.SetCSShader(Shader:TvShaderExt);
|
||||
begin
|
||||
if (Shader=nil) then Exit;
|
||||
if (Shader.FStage=VK_SHADER_STAGE_COMPUTE_BIT) then
|
||||
FShaders[vShaderStageCs]:=Shader;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.Clear;
|
||||
begin
|
||||
FShaders:=Default(AvShaderStage);
|
||||
FLayout:=nil;;
|
||||
end;
|
||||
|
||||
Function TvShaderGroup.Compile:Boolean;
|
||||
procedure TvShadersKey.ExportLayout(var A:AvSetLayout;
|
||||
var B:AvPushConstantRange);
|
||||
var
|
||||
i:TvShaderStage;
|
||||
c,p:Integer;
|
||||
A:AvSetLayout;
|
||||
B:AvPushConstantRange;
|
||||
begin
|
||||
if (FLayout<>nil) then Exit(True);
|
||||
|
||||
A:=Default(AvSetLayout);
|
||||
B:=Default(AvPushConstantRange);
|
||||
|
||||
c:=0;
|
||||
p:=0;
|
||||
|
||||
@ -832,23 +826,47 @@ begin
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
FLayout:=FetchPipelineLayout(A,B);
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.ExportStages(Stages:PVkPipelineShaderStageCreateInfo;stageCount:PVkUInt32);
|
||||
Procedure TvShadersKey.ExportStages(Stages:PVkPipelineShaderStageCreateInfo;stageCount:PVkUInt32);
|
||||
var
|
||||
i:TvShaderStage;
|
||||
i:TvShaderStage;
|
||||
c:Integer;
|
||||
begin
|
||||
c:=0;
|
||||
For i:=Low(TvShaderStage) to High(TvShaderStage) do
|
||||
if (FShaders[i]<>nil) then
|
||||
begin
|
||||
Stages[stageCount^].sType :=VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
Stages[stageCount^].stage :=FShaders[i].FStage;
|
||||
Stages[stageCount^].module:=FShaders[i].FHandle;
|
||||
Stages[stageCount^].pName :=PChar(FShaders[i].FEntry);
|
||||
Inc(stageCount^);
|
||||
Stages[c].sType :=VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
Stages[c].stage :=FShaders[i].FStage;
|
||||
Stages[c].module:=FShaders[i].FHandle;
|
||||
Stages[c].pName :=PChar(FShaders[i].FEntry);
|
||||
Inc(c);
|
||||
end;
|
||||
stageCount^:=c;
|
||||
end;
|
||||
|
||||
Procedure TvShaderGroup.Clear;
|
||||
begin
|
||||
FKey:=Default(TvShadersKey);
|
||||
FLayout:=nil;
|
||||
end;
|
||||
|
||||
Function TvShaderGroup.Compile:Boolean;
|
||||
var
|
||||
A:AvSetLayout;
|
||||
B:AvPushConstantRange;
|
||||
begin
|
||||
Result:=True;
|
||||
if (FLayout<>nil) then Exit;
|
||||
|
||||
A:=Default(AvSetLayout);
|
||||
B:=Default(AvPushConstantRange);
|
||||
|
||||
FKey.ExportLayout(A,B);
|
||||
|
||||
FLayout:=FetchPipelineLayout(A,B);
|
||||
Result:=(FLayout<>nil);
|
||||
end;
|
||||
|
||||
procedure TvBufOffsetChecker.AddAttr(const b:TvCustomLayout;Fset:TVkUInt32;FData:PDWORD);
|
||||
|
@ -32,10 +32,6 @@ type
|
||||
function c(var a,b:TShaderFunc):Integer;
|
||||
end;
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PShaderDataKey=^TShaderDataKey;
|
||||
TShaderDataKey=packed record
|
||||
FStage:TvShaderStage;
|
||||
@ -50,6 +46,7 @@ type
|
||||
end;
|
||||
|
||||
function FetchShader(FStage:TvShaderStage;FDescSetId:Integer;var GPU_REGS:TGPU_REGS):TvShaderExt;
|
||||
function FetchShaderGroup(F:PvShadersKey):TvShaderGroup;
|
||||
|
||||
implementation
|
||||
|
||||
@ -58,6 +55,10 @@ type
|
||||
function c(a,b:PShaderDataKey):Integer; static;
|
||||
end;
|
||||
|
||||
TShadersKeyCompare=object
|
||||
function c(a,b:PvShadersKey):Integer; static;
|
||||
end;
|
||||
|
||||
_TShaderCacheSet=specialize T23treeSet<PShaderDataKey,TShaderCacheCompare>;
|
||||
TShaderCacheSet=object(_TShaderCacheSet)
|
||||
lock:TRWLock;
|
||||
@ -66,8 +67,17 @@ type
|
||||
Procedure Unlock;
|
||||
end;
|
||||
|
||||
_TShaderGroupSet=specialize T23treeSet<PvShadersKey,TShadersKeyCompare>;
|
||||
TShaderGroupSet=object(_TShaderGroupSet)
|
||||
lock:TRWLock;
|
||||
Procedure Init;
|
||||
Procedure Lock_wr;
|
||||
Procedure Unlock;
|
||||
end;
|
||||
|
||||
var
|
||||
FShaderCacheSet:TShaderCacheSet;
|
||||
FShaderGroupSet:TShaderGroupSet;
|
||||
|
||||
Procedure TShaderCacheSet.Init;
|
||||
begin
|
||||
@ -84,6 +94,23 @@ begin
|
||||
rwlock_unlock(lock);
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
Procedure TShaderGroupSet.Init;
|
||||
begin
|
||||
rwlock_init(lock);
|
||||
end;
|
||||
|
||||
Procedure TShaderGroupSet.Lock_wr;
|
||||
begin
|
||||
rwlock_wrlock(lock);
|
||||
end;
|
||||
|
||||
Procedure TShaderGroupSet.Unlock;
|
||||
begin
|
||||
rwlock_unlock(lock);
|
||||
end;
|
||||
|
||||
function Max(a,b:PtrInt):PtrInt; inline;
|
||||
begin
|
||||
if (a>b) then Result:=a else Result:=b;
|
||||
@ -103,6 +130,11 @@ begin
|
||||
Result:=CompareDWord(a^.pData^,b^.pData^,Max(a^.FLen,b^.FLen) div 4);
|
||||
end;
|
||||
|
||||
function TShadersKeyCompare.c(a,b:PvShadersKey):Integer;
|
||||
begin
|
||||
Result:=CompareByte(a^.FShaders,b^.FShaders,SizeOf(AvShaderStage));
|
||||
end;
|
||||
|
||||
Destructor TShaderCache.Destroy;
|
||||
begin
|
||||
if (Key.pData<>nil) then FreeMem(Key.pData);
|
||||
@ -119,7 +151,7 @@ begin
|
||||
Result:=CompareDWord(a.pData^,b.pData^,Max(a.FLen,b.FLen) div 4);
|
||||
end;
|
||||
|
||||
function _Find(var F:TShaderDataKey):TShaderCache;
|
||||
function _FindShaderCache(var F:TShaderDataKey):TShaderCache;
|
||||
var
|
||||
i:TShaderCacheSet.Iterator;
|
||||
begin
|
||||
@ -170,7 +202,7 @@ begin
|
||||
SprvEmit.FBuffers.cfg.minStorageBufferOffsetAlignment:=limits.minStorageBufferOffsetAlignment; // $10
|
||||
SprvEmit.FBuffers.cfg.minUniformBufferOffsetAlignment:=limits.minUniformBufferOffsetAlignment; // $100
|
||||
|
||||
//SprvEmit.FBuffers.cfg.maxPushConstantsSize:=0;
|
||||
SprvEmit.FBuffers.cfg.maxPushConstantsSize:=0;
|
||||
//SprvEmit.FUseVertexInput:=False;
|
||||
|
||||
if (SprvEmit.Parse(pData)>1) then
|
||||
@ -191,7 +223,7 @@ begin
|
||||
SprvEmit.FAllocator.Free;
|
||||
end;
|
||||
|
||||
function _Fetch(FStage:TvShaderStage;pData:PDWORD;FDescSetId:Integer;var GPU_REGS:TGPU_REGS):TvShaderExt;
|
||||
function _FetchShader(FStage:TvShaderStage;pData:PDWORD;FDescSetId:Integer;var GPU_REGS:TGPU_REGS):TvShaderExt;
|
||||
var
|
||||
F:TShaderDataKey;
|
||||
|
||||
@ -212,7 +244,7 @@ begin
|
||||
F.FStage:=FStage;
|
||||
F.pData :=pData;
|
||||
|
||||
t:=_Find(F);
|
||||
t:=_FindShaderCache(F);
|
||||
|
||||
if (t<>nil) then
|
||||
begin
|
||||
@ -320,13 +352,66 @@ begin
|
||||
|
||||
FShaderCacheSet.Lock_wr;
|
||||
|
||||
Result:=_Fetch(FStage,pData,FDescSetId,GPU_REGS);
|
||||
Result:=_FetchShader(FStage,pData,FDescSetId,GPU_REGS);
|
||||
|
||||
FShaderCacheSet.Unlock;
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
function _FindShaderGroup(F:PvShadersKey):TvShaderGroup;
|
||||
var
|
||||
i:TShaderGroupSet.Iterator;
|
||||
begin
|
||||
Result:=nil;
|
||||
i:=FShaderGroupSet.find(F);
|
||||
if (i.Item<>nil) then
|
||||
begin
|
||||
Result:=TvShaderGroup(ptruint(i.Item^)-ptruint(@TvShaderGroup(nil).FKey));
|
||||
end;
|
||||
end;
|
||||
|
||||
function _FetchShaderGroup(F:PvShadersKey):TvShaderGroup;
|
||||
var
|
||||
t:TvShaderGroup;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
t:=_FindShaderGroup(F);
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
|
||||
t:=TvShaderGroup.Create;
|
||||
t.FKey:=F^;
|
||||
|
||||
if not t.Compile then
|
||||
begin
|
||||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
FShaderGroupSet.Insert(@t.FKey);
|
||||
end;
|
||||
end;
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
function FetchShaderGroup(F:PvShadersKey):TvShaderGroup;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (F=nil) then Exit;
|
||||
|
||||
FShaderGroupSet.Lock_wr;
|
||||
|
||||
Result:=_FetchShaderGroup(F);
|
||||
|
||||
FShaderGroupSet.Unlock;
|
||||
end;
|
||||
|
||||
initialization
|
||||
FShaderCacheSet.Init;
|
||||
FShaderGroupSet.Init;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user