mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
df0c4565d5
commit
e239da9978
|
@ -18,6 +18,7 @@ uses
|
|||
vRender,
|
||||
vRenderPassManager,
|
||||
vPipelineManager,
|
||||
vFramebufferManager,
|
||||
vShader,
|
||||
vShaderExt,
|
||||
vShaderManager,
|
||||
|
@ -164,7 +165,9 @@ var
|
|||
GP_KEY:TvGraphicsPipelineKey;
|
||||
GP:TvGraphicsPipeline2;
|
||||
|
||||
FFramebuffer:TvFramebufferIL;
|
||||
FB_KEY:TvFramebufferImagelessKey;
|
||||
FB_KEY2:TvFramebufferBindedKey;
|
||||
FFramebuffer:TvFramebuffer;
|
||||
|
||||
FRenderCmd:TvRenderTargets;
|
||||
|
||||
|
@ -294,36 +297,47 @@ begin
|
|||
|
||||
GP:=FetchGraphicsPipeline(CmdBuffer,@GP_KEY);
|
||||
|
||||
FFramebuffer:=TvFramebufferIL.Create;
|
||||
FFramebuffer.Key.FRenderPass :=RP;
|
||||
FFramebuffer.Key.FSize :=GPU_REGS.GET_SCREEN_SIZE;
|
||||
if limits.VK_KHR_imageless_framebuffer then
|
||||
begin
|
||||
FB_KEY:=Default(TvFramebufferImagelessKey);
|
||||
|
||||
FB_KEY.SetRenderPass(RP);
|
||||
FB_KEY.SetSize(GPU_REGS.GET_SCREEN_SIZE);
|
||||
|
||||
if (RT_COUNT<>0) then
|
||||
For i:=0 to RT_COUNT-1 do
|
||||
begin
|
||||
FFramebuffer.Key.AddImageAt(RT_INFO[i].FImageInfo);
|
||||
FB_KEY.AddImageAt(RT_INFO[i].FImageInfo);
|
||||
end;
|
||||
|
||||
if GPU_REGS.DB_ENABLE then
|
||||
begin
|
||||
FFramebuffer.Key.AddImageAt(DB_INFO.FImageInfo);
|
||||
FB_KEY.AddImageAt(DB_INFO.FImageInfo);
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
FB_KEY2:=Default(TvFramebufferBindedKey);
|
||||
|
||||
FFramebuffer.Compile;
|
||||
FB_KEY2.SetRenderPass(RP);
|
||||
FB_KEY2.SetSize(GPU_REGS.GET_SCREEN_SIZE);
|
||||
end;
|
||||
|
||||
FRenderCmd:=TvRenderTargets.Create;
|
||||
|
||||
FRenderCmd.FRenderPass:=RP;
|
||||
FRenderCmd.FPipeline :=GP;
|
||||
|
||||
FRenderCmd.FFramebuffer:=FFramebuffer;
|
||||
|
||||
FRenderCmd.FRenderArea:=GPU_REGS.GET_SCREEN;
|
||||
|
||||
if limits.VK_KHR_imageless_framebuffer then
|
||||
begin
|
||||
FFramebuffer:=FetchFramebufferImageless(CmdBuffer,@FB_KEY);
|
||||
FRenderCmd.FFramebuffer:=FFramebuffer;
|
||||
end;
|
||||
|
||||
if (RT_COUNT<>0) then
|
||||
For i:=0 to RT_COUNT-1 do
|
||||
begin
|
||||
//RT_INFO[i].CLEAR_COLOR.float32[2]:=1;
|
||||
|
||||
FRenderCmd.AddClearColor(RT_INFO[i].CLEAR_COLOR);
|
||||
|
||||
|
@ -335,7 +349,10 @@ begin
|
|||
|
||||
iv:=ri.FetchView(CmdBuffer,RT_INFO[i].FImageView,iu_attachment);
|
||||
|
||||
if limits.VK_KHR_imageless_framebuffer then
|
||||
begin
|
||||
FRenderCmd.AddImageView(iv);
|
||||
end;
|
||||
|
||||
ri.PushBarrier(CmdBuffer,
|
||||
ord(VK_ACCESS_TRANSFER_READ_BIT),
|
||||
|
@ -348,6 +365,17 @@ begin
|
|||
ord(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT) );
|
||||
|
||||
if not limits.VK_KHR_imageless_framebuffer then
|
||||
begin
|
||||
FB_KEY2.AddImageView(iv);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
if not limits.VK_KHR_imageless_framebuffer then
|
||||
begin
|
||||
FFramebuffer:=FetchFramebufferBinded(CmdBuffer,@FB_KEY2);
|
||||
FRenderCmd.FFramebuffer:=FFramebuffer;
|
||||
end;
|
||||
|
||||
if GPU_REGS.DB_ENABLE then
|
||||
|
|
|
@ -78,7 +78,7 @@ begin
|
|||
ring^.wptr:=0;
|
||||
ring^.aptr:=0;
|
||||
|
||||
Result:=md_reserve_ex(ring^.buff,size+GC_RING_PADD);
|
||||
Result:=md_reserve_ex(ring^.buff,size shl 1);
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
Result:=md_split(ring^.buff,size);
|
||||
|
@ -95,7 +95,7 @@ begin
|
|||
Exit;
|
||||
end;
|
||||
|
||||
Result:=md_file_mmap_ex(hMem,ring^.buff+size,0,GC_RING_PADD,MD_PROT_RW);
|
||||
Result:=md_file_mmap_ex(hMem,ring^.buff+size,0,size,MD_PROT_RW);
|
||||
|
||||
md_memfd_close(hMem);
|
||||
end;
|
||||
|
@ -107,7 +107,7 @@ begin
|
|||
if (ring^.buff=nil) then Exit;
|
||||
if (ring^.size=0) then Exit;
|
||||
|
||||
Result:=md_unmap_ex(ring^.buff,ring^.size+GC_RING_PADD);
|
||||
Result:=md_unmap_ex(ring^.buff,ring^.size shl 1);
|
||||
end;
|
||||
|
||||
function block_id(val,size:DWORD):DWORD; inline;
|
||||
|
@ -177,9 +177,7 @@ begin
|
|||
s:=block_ofs(wptr,rsiz)-block_ofs(rptr,rsiz);
|
||||
end else
|
||||
begin
|
||||
s:=block_ofs(wptr,rsiz);
|
||||
if (s>GC_RING_PADD) then s:=GC_RING_PADD;
|
||||
s:=(rsiz-block_ofs(rptr,rsiz))+s;
|
||||
s:=(rsiz-block_ofs(rptr,rsiz))+block_ofs(wptr,rsiz);
|
||||
end;
|
||||
|
||||
if (s<>0) then
|
||||
|
|
|
@ -994,6 +994,10 @@
|
|||
<Filename Value="vulkan\vPipelineManager.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="vulkan\vFramebufferManager.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -254,8 +254,8 @@ end;
|
|||
|
||||
function TvCmdBuffer.BeginRenderPass(RT:TvRenderTargets):Boolean;
|
||||
var
|
||||
info:TVkRenderPassBeginInfo;
|
||||
info2:TVkRenderPassAttachmentBeginInfo;
|
||||
rinfo:TVkRenderPassBeginInfo;
|
||||
ainfo:TVkRenderPassAttachmentBeginInfo;
|
||||
begin
|
||||
Result:=False;
|
||||
|
||||
|
@ -281,10 +281,13 @@ begin
|
|||
|
||||
EndRenderPass;
|
||||
|
||||
info:=RT.GetInfo;
|
||||
info2:=RT.GetInfo2;
|
||||
rinfo:=RT.GetRInfo;
|
||||
|
||||
info.pNext:=@info2;
|
||||
if RT.FFramebuffer.IsImageless then
|
||||
begin
|
||||
ainfo:=RT.GetAInfo;
|
||||
rinfo.pNext:=@ainfo;
|
||||
end;
|
||||
|
||||
FCurrPipeline[0]:=RT.FPipeline.FHandle;
|
||||
FCurrLayout [0]:=RT.FPipeline.Key.FShaderGroup.FLayout.FHandle;
|
||||
|
@ -292,7 +295,7 @@ begin
|
|||
|
||||
Inc(cmd_count);
|
||||
|
||||
vkCmdBeginRenderPass(FCmdbuf,@info,VK_SUBPASS_CONTENTS_INLINE);
|
||||
vkCmdBeginRenderPass(FCmdbuf,@rinfo,VK_SUBPASS_CONTENTS_INLINE);
|
||||
vkCmdBindPipeline (FCmdbuf,VK_PIPELINE_BIND_POINT_GRAPHICS,FCurrPipeline[0]);
|
||||
|
||||
if AddDependence(@RT.Release) then
|
||||
|
@ -300,7 +303,7 @@ begin
|
|||
RT.Acquire(Self);
|
||||
end;
|
||||
|
||||
FRenderPass:=info.renderPass;
|
||||
FRenderPass:=rinfo.renderPass;
|
||||
|
||||
Result:=True;
|
||||
end;
|
||||
|
|
|
@ -0,0 +1,260 @@
|
|||
unit vFramebufferManager;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
mqueue,
|
||||
g23tree,
|
||||
vDependence,
|
||||
vImage;
|
||||
|
||||
type
|
||||
TvFramebufferImageless2=class(TvFramebufferImageless)
|
||||
FRefs:ptruint;
|
||||
Procedure Acquire;
|
||||
procedure Release(Sender:TObject);
|
||||
end;
|
||||
|
||||
TvFramebufferBinded2=class(TvFramebufferBinded)
|
||||
FEntry:TAILQ_ENTRY;
|
||||
FRefs:ptruint;
|
||||
Procedure Acquire;
|
||||
procedure Release(Sender:TObject);
|
||||
end;
|
||||
|
||||
function FetchFramebufferImageless(cmd:TvDependenciesObject;P:PvFramebufferImagelessKey):TvFramebufferImageless2;
|
||||
function FetchFramebufferBinded (cmd:TvDependenciesObject;P:PvFramebufferBindedKey ):TvFramebufferBinded2;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
kern_rwlock;
|
||||
|
||||
type
|
||||
TvFramebufferImagelessKey2Compare=object
|
||||
function c(a,b:PvFramebufferImagelessKey):Integer; static;
|
||||
end;
|
||||
|
||||
TvFramebufferImageless2Set=specialize T23treeSet<PvFramebufferImagelessKey,TvFramebufferImagelessKey2Compare>;
|
||||
|
||||
TvFramebufferBinded2Set=object
|
||||
const
|
||||
MaxCount=256;
|
||||
var
|
||||
Queue:TAILQ_HEAD;
|
||||
Count:Ptruint;
|
||||
end;
|
||||
|
||||
var
|
||||
global_lock:Pointer=nil;
|
||||
|
||||
FFramebufferImageless2Set:TvFramebufferImageless2Set;
|
||||
|
||||
FFramebufferBinded:TvFramebufferBinded2Set=(
|
||||
Queue:(tqh_first:nil;tqh_last:@FFramebufferBinded.Queue.tqh_first);
|
||||
Count:0
|
||||
);
|
||||
|
||||
function TvFramebufferImagelessKey2Compare.c(a,b:PvFramebufferImagelessKey):Integer;
|
||||
begin
|
||||
Result:=CompareByte(a^,b^,SizeOf(TvFramebufferImagelessKey));
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferImageless2.Acquire;
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
end;
|
||||
|
||||
procedure TvFramebufferImageless2.Release(Sender:TObject);
|
||||
begin
|
||||
if System.InterlockedDecrement(Pointer(FRefs))=nil then
|
||||
begin
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferBinded2.Acquire;
|
||||
begin
|
||||
System.InterlockedIncrement(Pointer(FRefs));
|
||||
end;
|
||||
|
||||
procedure TvFramebufferBinded2.Release(Sender:TObject);
|
||||
begin
|
||||
if System.InterlockedDecrement(Pointer(FRefs))=nil then
|
||||
begin
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure Global_Lock_wr;
|
||||
begin
|
||||
rw_wlock(global_lock);
|
||||
end;
|
||||
|
||||
Procedure Global_Unlock_wr;
|
||||
begin
|
||||
rw_wunlock(global_lock);
|
||||
end;
|
||||
|
||||
function _FindImageless(P:PvFramebufferImagelessKey):TvFramebufferImageless2;
|
||||
var
|
||||
i:TvFramebufferImageless2Set.Iterator;
|
||||
begin
|
||||
Result:=nil;
|
||||
i:=FFramebufferImageless2Set.find(P);
|
||||
if (i.Item<>nil) then
|
||||
begin
|
||||
Result:=TvFramebufferImageless2(ptruint(i.Item^)-ptruint(@TvFramebufferImageless2(nil).key));
|
||||
end;
|
||||
end;
|
||||
|
||||
function _FetchImageless(P:PvFramebufferImagelessKey):TvFramebufferImageless2;
|
||||
var
|
||||
t:TvFramebufferImageless2;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
t:=_FindImageless(P);
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
|
||||
t:=TvFramebufferImageless2.Create;
|
||||
t.key:=P^;
|
||||
|
||||
if not t.Compile then
|
||||
begin
|
||||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
t.Acquire; //map ref
|
||||
FFramebufferImageless2Set.Insert(@t.key);
|
||||
end;
|
||||
end;
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
function FetchFramebufferImageless(cmd:TvDependenciesObject;P:PvFramebufferImagelessKey):TvFramebufferImageless2;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (P=nil) then Exit;
|
||||
|
||||
Global_Lock_wr;
|
||||
|
||||
Result:=_FetchImageless(P);
|
||||
|
||||
if (cmd<>nil) and (Result<>nil) then
|
||||
begin
|
||||
if cmd.AddDependence(@Result.Release) then
|
||||
begin
|
||||
Result.Acquire;
|
||||
end;
|
||||
end;
|
||||
|
||||
Global_Unlock_wr;
|
||||
end;
|
||||
|
||||
///
|
||||
|
||||
function _FindBinded(P:PvFramebufferBindedKey):TvFramebufferBinded2;
|
||||
var
|
||||
node:TvFramebufferBinded2;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
node:=TvFramebufferBinded2(TAILQ_FIRST(@FFramebufferBinded.Queue));
|
||||
|
||||
while (node<>nil) do
|
||||
begin
|
||||
|
||||
if (CompareByte(P^,node.Key,SizeOf(TvFramebufferBindedKey))=0) then
|
||||
begin
|
||||
if (node<>TvFramebufferBinded2(TAILQ_FIRST(@FFramebufferBinded.Queue))) then
|
||||
begin
|
||||
//set to top
|
||||
TAILQ_REMOVE (@FFramebufferBinded.Queue,node,@node.FEntry);
|
||||
TAILQ_INSERT_HEAD(@FFramebufferBinded.Queue,node,@node.FEntry);
|
||||
end;
|
||||
Break;
|
||||
end;
|
||||
|
||||
node:=TvFramebufferBinded2(TAILQ_NEXT(node,@node.FEntry));
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure _BoundBinded;
|
||||
var
|
||||
node:TvFramebufferBinded2;
|
||||
begin
|
||||
if (FFramebufferBinded.Count>FFramebufferBinded.MaxCount) then
|
||||
begin
|
||||
node:=TvFramebufferBinded2(TAILQ_LAST(@FFramebufferBinded.Queue));
|
||||
|
||||
if (node<>nil) then
|
||||
begin
|
||||
TAILQ_REMOVE(@FFramebufferBinded.Queue,node,@node.FEntry);
|
||||
node.Release(nil);
|
||||
end;
|
||||
|
||||
Dec(FFramebufferBinded.Count);
|
||||
end;
|
||||
end;
|
||||
|
||||
function _FetchBinded(P:PvFramebufferBindedKey):TvFramebufferBinded2;
|
||||
var
|
||||
t:TvFramebufferBinded2;
|
||||
begin
|
||||
Result:=nil;
|
||||
|
||||
t:=_FindBinded(P);
|
||||
|
||||
if (t=nil) then
|
||||
begin
|
||||
|
||||
t:=TvFramebufferBinded2.Create;
|
||||
t.key:=P^;
|
||||
|
||||
if not t.Compile then
|
||||
begin
|
||||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
t.Acquire; //map ref
|
||||
TAILQ_INSERT_HEAD(@FFramebufferBinded.Queue,t,@t.FEntry);
|
||||
Inc(FFramebufferBinded.Count);
|
||||
|
||||
_BoundBinded;
|
||||
end;
|
||||
end;
|
||||
|
||||
Result:=t;
|
||||
end;
|
||||
|
||||
function FetchFramebufferBinded(cmd:TvDependenciesObject;P:PvFramebufferBindedKey):TvFramebufferBinded2;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (P=nil) then Exit;
|
||||
|
||||
Global_Lock_wr;
|
||||
|
||||
Result:=_FetchBinded(P);
|
||||
|
||||
if (cmd<>nil) and (Result<>nil) then
|
||||
begin
|
||||
if cmd.AddDependence(@Result.Release) then
|
||||
begin
|
||||
Result.Acquire;
|
||||
end;
|
||||
end;
|
||||
|
||||
Global_Unlock_wr;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
|
@ -160,40 +160,64 @@ type
|
|||
function GetImageInfo:TVkImageCreateInfo; override;
|
||||
end;
|
||||
|
||||
AvFramebufferImages=array[0..8] of TvImageView;
|
||||
TvFramebufferAttachmentShort=packed record
|
||||
cformat :TVkFormat;
|
||||
width :Word;
|
||||
height :Word;
|
||||
layerCount:Word;
|
||||
end;
|
||||
|
||||
AvFramebufferAttach=array[0..8] of TVkFramebufferAttachmentImageInfo;
|
||||
AvFramebufferAShort=array[0..8] of TvFramebufferAttachmentShort;
|
||||
|
||||
AvFramebufferImages=array[0..8] of TvImageView;
|
||||
AvImageViews =array[0..8] of TVkImageView;
|
||||
|
||||
TvFramebuffer=class
|
||||
FHandle:TVkFramebuffer;
|
||||
function IsImageless:Boolean; virtual;
|
||||
Destructor Destroy; override;
|
||||
end;
|
||||
|
||||
PvFramebufferImagelessKey=^TvFramebufferImagelessKey;
|
||||
TvFramebufferImagelessKey=packed object
|
||||
FRenderPass :TvRenderPass;
|
||||
FSize :TVkExtent2D;
|
||||
FImagesCount:ptruint;
|
||||
FImages :AvFramebufferAttach;
|
||||
FWidth :Word;
|
||||
FHeight :Word;
|
||||
FLayers :Word;
|
||||
FImagesCount:Word;
|
||||
FImages :AvFramebufferAShort;
|
||||
Procedure SetRenderPass(r:TvRenderPass);
|
||||
Procedure SetSize(Size:TVkExtent2D);
|
||||
Procedure AddImageAt(Key:TvImageKey);
|
||||
Procedure Export(var F:AvFramebufferAttach);
|
||||
end;
|
||||
|
||||
TvFramebufferIL=class(TvFramebuffer)
|
||||
TvFramebufferImageless=class(TvFramebuffer)
|
||||
Key:TvFramebufferImagelessKey;
|
||||
function IsImageless:Boolean; override;
|
||||
function Compile:Boolean;
|
||||
end;
|
||||
|
||||
TvFramebufferIV=class(TvFramebuffer)
|
||||
FEdit,FCompile:ptruint;
|
||||
PvFramebufferBindedKey=^TvFramebufferBindedKey;
|
||||
TvFramebufferBindedKey=packed object
|
||||
FRenderPass :TvRenderPass;
|
||||
FSize :TVkExtent2D;
|
||||
FImagesCount:ptruint;
|
||||
FWidth :Word;
|
||||
FHeight :Word;
|
||||
FLayers :Word;
|
||||
FImagesCount:Word;
|
||||
FImages :AvFramebufferImages;
|
||||
Procedure SetRenderPass(r:TvRenderPass);
|
||||
Procedure SetSize(Size:TVkExtent2D);
|
||||
Procedure AddImageView(v:TvImageView);
|
||||
Procedure FreeImageViews;
|
||||
function IsEdit:Boolean;
|
||||
end;
|
||||
|
||||
TvFramebufferBinded=class(TvFramebuffer)
|
||||
Key:TvFramebufferBindedKey;
|
||||
FAcquire:bitpacked array[0..8] of Boolean;
|
||||
function Compile:Boolean;
|
||||
Procedure AcquireImageViews;
|
||||
Procedure ReleaseImageViews;
|
||||
Destructor Destroy; override;
|
||||
end;
|
||||
|
||||
|
@ -321,6 +345,11 @@ end;
|
|||
|
||||
//
|
||||
|
||||
function TvFramebuffer.IsImageless:Boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
end;
|
||||
|
||||
Destructor TvFramebuffer.Destroy;
|
||||
begin
|
||||
if (FHandle<>VK_NULL_HANDLE) then
|
||||
|
@ -332,55 +361,24 @@ end;
|
|||
|
||||
//
|
||||
|
||||
Procedure TvFramebufferIV.SetRenderPass(r:TvRenderPass);
|
||||
Procedure TvFramebufferBindedKey.SetRenderPass(r:TvRenderPass);
|
||||
begin
|
||||
if (r=FRenderPass) then Exit;
|
||||
FRenderPass:=r;
|
||||
Inc(FEdit);
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferIV.SetSize(Size:TVkExtent2D);
|
||||
Procedure TvFramebufferBindedKey.SetSize(Size:TVkExtent2D);
|
||||
begin
|
||||
if CompareByte(Size,FSize,SizeOf(TVkExtent2D))=0 then Exit;
|
||||
FSize:=Size;
|
||||
Inc(FEdit);
|
||||
FWidth :=Size.width;
|
||||
FHeight:=Size.height;
|
||||
FLayers:=1;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferIV.AddImageView(v:TvImageView);
|
||||
Procedure TvFramebufferBindedKey.AddImageView(v:TvImageView);
|
||||
begin
|
||||
if (v=nil) then Exit;
|
||||
if (FImagesCount>=Length(AvFramebufferImages)) then Exit;
|
||||
FImages[FImagesCount]:=v;
|
||||
Inc(FImagesCount);
|
||||
v.Acquire;
|
||||
Inc(FEdit);
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferIV.FreeImageViews;
|
||||
var
|
||||
i:Integer;
|
||||
begin
|
||||
if (FImagesCount<>0) then
|
||||
For i:=0 to FImagesCount-1 do
|
||||
if (FImages[i]<>nil) then
|
||||
begin
|
||||
FImages[i].Release;
|
||||
FImages[i]:=nil;
|
||||
end;
|
||||
FImagesCount:=0;
|
||||
|
||||
//It:=FImages.cbegin;
|
||||
//if (It.Item<>nil) then
|
||||
//repeat
|
||||
// TvImageView(It.Item^).Release;
|
||||
//until not It.Next;
|
||||
//FImages.Free;
|
||||
Inc(FEdit);
|
||||
end;
|
||||
|
||||
function TvFramebufferIV.IsEdit:Boolean;
|
||||
begin
|
||||
Result:=(FEdit<>FCompile);
|
||||
end;
|
||||
|
||||
///
|
||||
|
@ -893,37 +891,90 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferImagelessKey.SetRenderPass(r:TvRenderPass);
|
||||
begin
|
||||
FRenderPass:=r;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferImagelessKey.SetSize(Size:TVkExtent2D);
|
||||
begin
|
||||
FWidth :=Size.width;
|
||||
FHeight:=Size.height;
|
||||
FLayers:=1;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferImagelessKey.AddImageAt(Key:TvImageKey);
|
||||
var
|
||||
MUTABLE:PVkFormat;
|
||||
begin
|
||||
if (FImagesCount>=Length(FImages)) then Exit;
|
||||
|
||||
MUTABLE:=GET_VK_IMAGE_MUTABLE(Key.cformat);
|
||||
if (Key.params.width>FWidth) then
|
||||
begin
|
||||
FWidth:=Key.params.width;
|
||||
end;
|
||||
|
||||
if (Key.params.height>FHeight) then
|
||||
begin
|
||||
FHeight:=Key.params.height;
|
||||
end;
|
||||
|
||||
if (Key.params.arrayLayers>FLayers) then
|
||||
begin
|
||||
FLayers:=Key.params.arrayLayers;
|
||||
end;
|
||||
|
||||
with FImages[FImagesCount] do
|
||||
begin
|
||||
sType :=VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO;
|
||||
pNext :=nil;
|
||||
flags :=GET_VK_IMAGE_CREATE_DEFAULT(Key.cformat);
|
||||
usage :=GET_VK_IMAGE_USAGE_DEFAULT (Key.cformat);
|
||||
cformat :=Key.cformat;
|
||||
width :=Key.params.width;
|
||||
height :=Key.params.height;
|
||||
layerCount:=key.params.arrayLayers;
|
||||
viewFormatCount:=GET_FORMATS_LEN(MUTABLE);
|
||||
pViewFormats :=MUTABLE;
|
||||
end;
|
||||
|
||||
Inc(FImagesCount);
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferImagelessKey.Export(var F:AvFramebufferAttach);
|
||||
var
|
||||
cformat:TVkFormat;
|
||||
MUTABLE:PVkFormat;
|
||||
i:Word;
|
||||
begin
|
||||
|
||||
if (FImagesCount<>0) then
|
||||
For i:=0 to FImagesCount-1 do
|
||||
begin
|
||||
cformat:=FImages[i].cformat;
|
||||
MUTABLE:=GET_VK_IMAGE_MUTABLE(cformat);
|
||||
|
||||
with F[i] do
|
||||
begin
|
||||
sType :=VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO;
|
||||
pNext :=nil;
|
||||
flags :=GET_VK_IMAGE_CREATE_DEFAULT(cformat);
|
||||
usage :=GET_VK_IMAGE_USAGE_DEFAULT (cformat);
|
||||
width :=FImages[i].width;
|
||||
height :=FImages[i].height;
|
||||
layerCount :=FImages[i].layerCount;
|
||||
viewFormatCount:=GET_FORMATS_LEN(MUTABLE);
|
||||
pViewFormats :=MUTABLE;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
///
|
||||
|
||||
function TvFramebufferIL.Compile:Boolean;
|
||||
function TvFramebufferImageless.IsImageless:Boolean;
|
||||
begin
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
function TvFramebufferImageless.Compile:Boolean;
|
||||
var
|
||||
r:TVkResult;
|
||||
info:TVkFramebufferCreateInfo;
|
||||
imgs:TVkFramebufferAttachmentsCreateInfo;
|
||||
fatt:AvFramebufferAttach;
|
||||
begin
|
||||
Result:=False;
|
||||
if (FHandle<>VK_NULL_HANDLE) then Exit(True);
|
||||
|
@ -931,22 +982,24 @@ begin
|
|||
if (Key.FRenderPass=nil) then Exit;
|
||||
if (Key.FRenderPass.FHandle=VK_NULL_HANDLE) then Exit;
|
||||
if (Key.FImagesCount=0) then Exit;
|
||||
if (Key.FSize.width=0) or (Key.FSize.height=0) then Exit;
|
||||
if (Key.FWidth=0) or (Key.FHeight=0) then Exit;
|
||||
|
||||
info:=Default(TVkFramebufferCreateInfo);
|
||||
info.sType :=VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
info.renderPass :=Key.FRenderPass.FHandle;
|
||||
info.attachmentCount:=Key.FImagesCount;
|
||||
info.width :=Key.FSize.width;
|
||||
info.height :=Key.FSize.height;
|
||||
info.layers :=1;
|
||||
info.width :=Key.FWidth;
|
||||
info.height :=Key.FHeight;
|
||||
info.layers :=Key.FLayers;
|
||||
info.flags :=ord(VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT);
|
||||
info.pAttachments :=nil;
|
||||
|
||||
Key.Export(fatt);
|
||||
|
||||
imgs:=Default(TVkFramebufferAttachmentsCreateInfo);
|
||||
imgs.sType:=VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO;
|
||||
imgs.attachmentImageInfoCount:=Key.FImagesCount;
|
||||
imgs.pAttachmentImageInfos :=@Key.FImages;
|
||||
imgs.pAttachmentImageInfos :=@fatt;
|
||||
|
||||
info.pNext:=@imgs;
|
||||
|
||||
|
@ -961,7 +1014,35 @@ end;
|
|||
|
||||
///
|
||||
|
||||
function TvFramebufferIV.Compile:Boolean;
|
||||
Procedure TvFramebufferBinded.AcquireImageViews;
|
||||
var
|
||||
i:Word;
|
||||
begin
|
||||
if (Key.FImagesCount<>0) then
|
||||
For i:=0 to Key.FImagesCount-1 do
|
||||
if (Key.FImages[i]<>nil) then
|
||||
if (not FAcquire[i]) then
|
||||
begin
|
||||
Key.FImages[i].Acquire;
|
||||
FAcquire[i]:=True;
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TvFramebufferBinded.ReleaseImageViews;
|
||||
var
|
||||
i:Word;
|
||||
begin
|
||||
if (Key.FImagesCount<>0) then
|
||||
For i:=0 to Key.FImagesCount-1 do
|
||||
if (Key.FImages[i]<>nil) then
|
||||
if (FAcquire[i]) then
|
||||
begin
|
||||
Key.FImages[i].Release;
|
||||
FAcquire[i]:=False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TvFramebufferBinded.Compile:Boolean;
|
||||
var
|
||||
i:TVkUInt32;
|
||||
r:TVkResult;
|
||||
|
@ -969,32 +1050,29 @@ var
|
|||
FImageViews:AvImageViews;
|
||||
begin
|
||||
Result:=False;
|
||||
if (not IsEdit) then Exit(true);
|
||||
if (FRenderPass=nil) then Exit;
|
||||
if (FRenderPass.FHandle=VK_NULL_HANDLE) then Exit;
|
||||
if (FImagesCount=0) then Exit;
|
||||
if (FSize.width=0) or (FSize.height=0) then Exit;
|
||||
if (FHandle<>VK_NULL_HANDLE) then Exit(True);
|
||||
|
||||
if (FHandle<>VK_NULL_HANDLE) then
|
||||
begin
|
||||
vkDestroyFramebuffer(Device.FHandle,FHandle,nil);
|
||||
FHandle:=VK_NULL_HANDLE;
|
||||
end;
|
||||
if (Key.FRenderPass=nil) then Exit;
|
||||
if (Key.FRenderPass.FHandle=VK_NULL_HANDLE) then Exit;
|
||||
if (Key.FImagesCount=0) then Exit;
|
||||
if (Key.FWidth=0) or (Key.FHeight=0) then Exit;
|
||||
|
||||
AcquireImageViews;
|
||||
|
||||
info:=Default(TVkFramebufferCreateInfo);
|
||||
info.sType :=VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
info.renderPass :=FRenderPass.FHandle;
|
||||
info.attachmentCount:=FImagesCount;
|
||||
info.width :=FSize.width;
|
||||
info.height :=FSize.height;
|
||||
info.layers :=1;
|
||||
info.renderPass :=Key.FRenderPass.FHandle;
|
||||
info.attachmentCount:=Key.FImagesCount;
|
||||
info.width :=Key.FWidth;
|
||||
info.height :=Key.FHeight;
|
||||
info.layers :=Key.FLayers;
|
||||
|
||||
FImageViews:=Default(AvImageViews);
|
||||
|
||||
For i:=0 to FImagesCount-1 do
|
||||
if (FImages[i]<>nil) then
|
||||
For i:=0 to Key.FImagesCount-1 do
|
||||
if (Key.FImages[i]<>nil) then
|
||||
begin
|
||||
FImageViews[i]:=FImages[i].FHandle;
|
||||
FImageViews[i]:=Key.FImages[i].FHandle;
|
||||
end;
|
||||
|
||||
info.pAttachments:=@FImageViews;
|
||||
|
@ -1008,9 +1086,9 @@ begin
|
|||
Result:=(r=VK_SUCCESS);
|
||||
end;
|
||||
|
||||
Destructor TvFramebufferIV.Destroy;
|
||||
Destructor TvFramebufferBinded.Destroy;
|
||||
begin
|
||||
FreeImageViews;
|
||||
ReleaseImageViews;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ begin
|
|||
t.Parent :=Self;
|
||||
t.key :=key2;
|
||||
|
||||
t.Acquire;
|
||||
t.Acquire; //map ref
|
||||
FViews.Insert(@t.key);
|
||||
end;
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ const
|
|||
);
|
||||
|
||||
function vkAllocMemory (device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32):TVkDeviceMemory;
|
||||
function vkAllocHostMemory(device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;adr:Pointer):TVkDeviceMemory;
|
||||
function vkAllocHostMemory (device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;addr:Pointer ):TVkDeviceMemory;
|
||||
function vkAllocDedicatedImage (device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;FHandle:TVkImage ):TVkDeviceMemory;
|
||||
function vkAllocDedicatedBuffer(device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;FHandle:TVkBuffer):TVkDeviceMemory;
|
||||
|
||||
|
@ -1136,7 +1136,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function vkAllocHostMemory(device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;adr:Pointer):TVkDeviceMemory;
|
||||
function vkAllocHostMemory(device:TVkDevice;Size:TVkDeviceSize;mtindex:TVkUInt32;addr:Pointer):TVkDeviceMemory;
|
||||
var
|
||||
ainfo:TVkMemoryAllocateInfo;
|
||||
import:TVkImportMemoryHostPointerInfoEXT;
|
||||
|
@ -1151,7 +1151,7 @@ begin
|
|||
import:=Default(TVkImportMemoryHostPointerInfoEXT);
|
||||
import.sType :=VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT;
|
||||
import.handleType :=VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT;
|
||||
import.pHostPointer:=adr;
|
||||
import.pHostPointer:=addr;
|
||||
//
|
||||
Result:=VK_NULL_HANDLE;
|
||||
r:=vkAllocateMemory(device,@ainfo,nil,@Result);
|
||||
|
|
|
@ -251,13 +251,6 @@ begin
|
|||
|
||||
//
|
||||
|
||||
//VK_EXT_vertex_input_dynamic_state
|
||||
//VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME
|
||||
// VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT
|
||||
// VK_DYNAMIC_STATE_VERTEX_INPUT_EXT
|
||||
// VkVertexInputBindingDescription2EXT
|
||||
// VkVertexInputAttributeDescription2EXT
|
||||
|
||||
vertexInputInfo:=Default(TVkPipelineVertexInputStateCreateInfo);
|
||||
vertexInputInfo.sType :=VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
vertexInputInfo.vertexBindingDescriptionCount :=Key.vertexInputInfo.vertexBindingDescriptionCount;
|
||||
|
@ -388,7 +381,7 @@ begin
|
|||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
t.Acquire;
|
||||
t.Acquire; //map ref
|
||||
FGraphicsPipeline2Set.Insert(@t.key);
|
||||
end;
|
||||
end;
|
||||
|
|
|
@ -102,8 +102,8 @@ type
|
|||
Procedure AddClearColor(clr:TVkClearValue);
|
||||
Procedure AddClearColor(clr:TVkClearColorValue);
|
||||
Procedure AddImageView(v:TvImageView);
|
||||
Function GetInfo:TVkRenderPassBeginInfo;
|
||||
Function GetInfo2:TVkRenderPassAttachmentBeginInfo;
|
||||
Function GetRInfo:TVkRenderPassBeginInfo;
|
||||
Function GetAInfo:TVkRenderPassAttachmentBeginInfo;
|
||||
class function c(const a,b:TvRenderTargets):Integer;
|
||||
Destructor Destroy; override;
|
||||
Procedure Acquire(Sender:TObject);
|
||||
|
@ -624,7 +624,7 @@ begin
|
|||
Inc(FImagesCount);
|
||||
end;
|
||||
|
||||
Function TvRenderTargets.GetInfo:TVkRenderPassBeginInfo;
|
||||
Function TvRenderTargets.GetRInfo:TVkRenderPassBeginInfo;
|
||||
begin
|
||||
Result:=Default(TVkRenderPassBeginInfo);
|
||||
Result.sType :=VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
|
@ -635,7 +635,7 @@ begin
|
|||
Result.framebuffer :=FFramebuffer.FHandle;
|
||||
end;
|
||||
|
||||
Function TvRenderTargets.GetInfo2:TVkRenderPassAttachmentBeginInfo;
|
||||
Function TvRenderTargets.GetAInfo:TVkRenderPassAttachmentBeginInfo;
|
||||
begin
|
||||
Result:=Default(TVkRenderPassAttachmentBeginInfo);
|
||||
Result.sType :=VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO;
|
||||
|
@ -652,7 +652,7 @@ Destructor TvRenderTargets.Destroy;
|
|||
begin
|
||||
/////FreeAndNil(FRenderPass);
|
||||
/////FreeAndNil(FPipeline);
|
||||
FreeAndNil(FFramebuffer);
|
||||
//FreeAndNil(FFramebuffer);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ begin
|
|||
FreeAndNil(t);
|
||||
end else
|
||||
begin
|
||||
t.Acquire;
|
||||
t.Acquire; //map ref
|
||||
FRenderPass2Set.Insert(@t.key);
|
||||
end;
|
||||
end;
|
||||
|
|
Loading…
Reference in New Issue