mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
e11e4ba7b5
commit
176c6b7128
|
@ -112,7 +112,16 @@ begin
|
||||||
Op.OpTypeArray,
|
Op.OpTypeArray,
|
||||||
Op.OpTypeRuntimeArray:
|
Op.OpTypeRuntimeArray:
|
||||||
begin
|
begin
|
||||||
DecorateList.OpDecorate(node,Decoration.ArrayStride,node^.array_stride);
|
if (node^.array_stride<>0) then
|
||||||
|
begin
|
||||||
|
DecorateList.OpDecorate(node,Decoration.ArrayStride,node^.array_stride);
|
||||||
|
end;
|
||||||
|
//
|
||||||
|
if (node^.is_array_image) then
|
||||||
|
begin
|
||||||
|
AddCapability(Capability.RuntimeDescriptorArray);
|
||||||
|
HeaderList.SPV_EXT_descriptor_indexing;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Op.OpTypeFloat:
|
Op.OpTypeFloat:
|
||||||
|
|
|
@ -79,8 +79,9 @@ type
|
||||||
function MakeChain(pSlot:PsrRegSlot;grp:PsrDataLayout;lvl_0:PsrChainLvl_0;lvl_1:PsrChainLvl_1):PsrRegNode;
|
function MakeChain(pSlot:PsrRegSlot;grp:PsrDataLayout;lvl_0:PsrChainLvl_0;lvl_1:PsrChainLvl_1):PsrRegNode;
|
||||||
Procedure AddVecInput(dst:PsrRegSlot;vtype,rtype:TsrDataType;itype:TpsslInputType;id:Byte);
|
Procedure AddVecInput(dst:PsrRegSlot;vtype,rtype:TsrDataType;itype:TpsslInputType;id:Byte);
|
||||||
function AddPositionsInput(count:Byte):PsrVariable;
|
function AddPositionsInput(count:Byte):PsrVariable;
|
||||||
function FetchUniform(src:PsrDataLayout;pType:PsrType):PsrNode;
|
function FetchUniformSimple(src:PsrDataLayout;pType:PsrType):PsrNode;
|
||||||
function FetchImage(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
|
function FetchImage(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
|
||||||
|
function FetchImageRuntimeArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
|
||||||
function FetchSampler(src:PsrDataLayout):PsrNode;
|
function FetchSampler(src:PsrDataLayout):PsrNode;
|
||||||
function FetchOutput(etype:TpsslExportType;rtype:TsrDataType):PsrVariable;
|
function FetchOutput(etype:TpsslExportType;rtype:TsrDataType):PsrVariable;
|
||||||
end;
|
end;
|
||||||
|
@ -696,7 +697,7 @@ end;
|
||||||
|
|
||||||
////
|
////
|
||||||
|
|
||||||
function TEmitFetch.FetchUniform(src:PsrDataLayout;pType:PsrType):PsrNode;
|
function TEmitFetch.FetchUniformSimple(src:PsrDataLayout;pType:PsrType):PsrNode;
|
||||||
var
|
var
|
||||||
u:PsrUniform;
|
u:PsrUniform;
|
||||||
v:PsrVariable;
|
v:PsrVariable;
|
||||||
|
@ -718,7 +719,17 @@ var
|
||||||
begin
|
begin
|
||||||
pType:=TypeList.Fetch(dtype);
|
pType:=TypeList.Fetch(dtype);
|
||||||
pType:=TypeList.FetchImage(pType,info);
|
pType:=TypeList.FetchImage(pType,info);
|
||||||
Result:=FetchUniform(src,pType);
|
Result:=FetchUniformSimple(src,pType);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEmitFetch.FetchImageRuntimeArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
|
||||||
|
var
|
||||||
|
pType:PsrType;
|
||||||
|
begin
|
||||||
|
pType:=TypeList.Fetch(dtype);
|
||||||
|
pType:=TypeList.FetchImage(pType,info);
|
||||||
|
pType:=TypeList.FetchRuntimeArray(pType);
|
||||||
|
Result:=UniformList.Fetch(src,pType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitFetch.FetchSampler(src:PsrDataLayout):PsrNode;
|
function TEmitFetch.FetchSampler(src:PsrDataLayout):PsrNode;
|
||||||
|
@ -726,7 +737,7 @@ var
|
||||||
pType:PsrType;
|
pType:PsrType;
|
||||||
begin
|
begin
|
||||||
pType:=TypeList.Fetch(dtTypeSampler);
|
pType:=TypeList.Fetch(dtTypeSampler);
|
||||||
Result:=FetchUniform(src,pType);
|
Result:=FetchUniformSimple(src,pType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitFetch.FetchOutput(etype:TpsslExportType;rtype:TsrDataType):PsrVariable;
|
function TEmitFetch.FetchOutput(etype:TpsslExportType;rtype:TsrDataType):PsrVariable;
|
||||||
|
|
|
@ -12,9 +12,11 @@ uses
|
||||||
ps4_pssl,
|
ps4_pssl,
|
||||||
srNode,
|
srNode,
|
||||||
srType,
|
srType,
|
||||||
|
srTypes,
|
||||||
srReg,
|
srReg,
|
||||||
srLayout,
|
srLayout,
|
||||||
srOp,
|
srOp,
|
||||||
|
srUniform,
|
||||||
emit_fetch;
|
emit_fetch;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -1006,13 +1008,15 @@ begin
|
||||||
begin
|
begin
|
||||||
coord:=GatherCoord_u(roffset,info);
|
coord:=GatherCoord_u(roffset,info);
|
||||||
|
|
||||||
//scalar or vector
|
|
||||||
node:=OpImageWrite(line,Tgrp,coord,dst);
|
|
||||||
|
|
||||||
lod:=Gather_value(roffset,dtUint32);
|
lod:=Gather_value(roffset,dtUint32);
|
||||||
|
|
||||||
node^.AddLiteral(ImageOperands.Lod,'Lod');
|
//lod:=OpNonUniform(lod); TODO
|
||||||
node^.AddParam(lod);
|
|
||||||
|
//fetch image by index
|
||||||
|
Tgrp:=PsrUniform(Tgrp)^.FetchArrayChain(line,lod);
|
||||||
|
|
||||||
|
//scalar or vector
|
||||||
|
node:=OpImageWrite(line,Tgrp,coord,dst);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
Assert(false,'MIMG?'+IntToStr(FSPI.MIMG.OP));
|
Assert(false,'MIMG?'+IntToStr(FSPI.MIMG.OP));
|
||||||
|
@ -1146,7 +1150,8 @@ begin
|
||||||
emit_image_load(Tgrp,@info);
|
emit_image_load(Tgrp,@info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
IMAGE_STORE..IMAGE_STORE_MIP_PCK: //stored
|
IMAGE_STORE,
|
||||||
|
IMAGE_STORE_PCK: //stored
|
||||||
begin
|
begin
|
||||||
info.tinfo.Sampled:=2;
|
info.tinfo.Sampled:=2;
|
||||||
Tgrp:=FetchImage(pLayout,info.dtype,info.tinfo);
|
Tgrp:=FetchImage(pLayout,info.dtype,info.tinfo);
|
||||||
|
@ -1154,6 +1159,15 @@ begin
|
||||||
emit_image_store(Tgrp,@info);
|
emit_image_store(Tgrp,@info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
IMAGE_STORE_MIP,
|
||||||
|
IMAGE_STORE_MIP_PCK: //stored mip
|
||||||
|
begin
|
||||||
|
info.tinfo.Sampled:=2;
|
||||||
|
Tgrp:=FetchImageRuntimeArray(pLayout,info.dtype,info.tinfo);
|
||||||
|
|
||||||
|
emit_image_store(Tgrp,@info);
|
||||||
|
end;
|
||||||
|
|
||||||
IMAGE_GET_RESINFO: //get info by mip
|
IMAGE_GET_RESINFO: //get info by mip
|
||||||
begin
|
begin
|
||||||
info.tinfo.Sampled:=1;
|
info.tinfo.Sampled:=1;
|
||||||
|
|
|
@ -48,12 +48,12 @@ type
|
||||||
function OpStore(nLine, dst,src:PsrNode):PsrNode; override;
|
function OpStore(nLine, dst,src:PsrNode):PsrNode; override;
|
||||||
//
|
//
|
||||||
function OpLoad(pLine:PspirvOp;dst:PsrRegNode;src:PsrNode):PSpirvOp;
|
function OpLoad(pLine:PspirvOp;dst:PsrRegNode;src:PsrNode):PSpirvOp;
|
||||||
function OpLoadTo(nLine:PspirvOp;pType:PsrType;src:PsrNode):PsrRegNode;
|
function OpLoadTo(pType:PsrType;src:PsrNode;ppLine:PPspirvOp=nil):PsrRegNode;
|
||||||
//
|
//
|
||||||
function OpExtract(pLine:PspirvOp;dst,src:PsrRegNode;id:DWORD):PSpirvOp;
|
function OpExtract(pLine:PspirvOp;dst,src:PsrRegNode;id:DWORD):PSpirvOp;
|
||||||
function OpConstruct(pLine:PspirvOp;dst:PsrRegNode):PSpirvOp;
|
function OpConstruct(pLine:PspirvOp;dst:PsrRegNode):PSpirvOp;
|
||||||
function OpAccessChain(pLine:PspirvOp;vType:PsrType;dst:PsrNode;src:PsrVariable):PSpirvOp;
|
function OpAccessChain(pLine:PspirvOp;vType:PsrType;dst:PsrNode;src:PsrVariable):PSpirvOp;
|
||||||
function OpAccessChainTo(pLine:PspirvOp;vType:PsrType;src:PsrVariable;idx0:PsrNode):PsrNode;
|
function OpAccessChainTo(vType:PsrType;src:PsrVariable;idx0:PsrNode;ppLine:PPspirvOp=nil):PsrNode;
|
||||||
function OpCondMerge(pLine,pLabel:PspirvOp):PSpirvOp;
|
function OpCondMerge(pLine,pLabel:PspirvOp):PSpirvOp;
|
||||||
function OpLoopMerge(pLine,pLabel0,pLabel1:PspirvOp):PSpirvOp;
|
function OpLoopMerge(pLine,pLabel0,pLabel1:PspirvOp):PSpirvOp;
|
||||||
function OpBranch(pLine,pLabel:PspirvOp):PSpirvOp;
|
function OpBranch(pLine,pLabel:PspirvOp):PSpirvOp;
|
||||||
|
@ -428,11 +428,11 @@ begin
|
||||||
Result:=PSpirvOp(OpLoad(pLine,dtype,dst,src));
|
Result:=PSpirvOp(OpLoad(pLine,dtype,dst,src));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitOp.OpLoadTo(nLine:PspirvOp;pType:PsrType;src:PsrNode):PsrRegNode;
|
function TEmitOp.OpLoadTo(pType:PsrType;src:PsrNode;ppLine:PPspirvOp=nil):PsrRegNode;
|
||||||
begin
|
begin
|
||||||
Result:=NewReg(pType^.dtype);
|
Result:=NewReg(pType^.dtype);
|
||||||
//
|
//
|
||||||
OpLoad(line,pType,Result,src);
|
_set_line(ppLine,PspirvOp(OpLoad(_get_line(ppLine),pType,Result,src)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitOp.OpExtract(pLine:PspirvOp;dst,src:PsrRegNode;id:DWORD):PSpirvOp;
|
function TEmitOp.OpExtract(pLine:PspirvOp;dst,src:PsrRegNode;id:DWORD):PSpirvOp;
|
||||||
|
@ -474,14 +474,15 @@ begin
|
||||||
//index add later
|
//index add later
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitOp.OpAccessChainTo(pLine:PspirvOp;vType:PsrType;src:PsrVariable;idx0:PsrNode):PsrNode;
|
function TEmitOp.OpAccessChainTo(vType:PsrType;src:PsrVariable;idx0:PsrNode;ppLine:PPspirvOp=nil):PsrNode;
|
||||||
Var
|
Var
|
||||||
node:PSpirvOp;
|
node:PSpirvOp;
|
||||||
begin
|
begin
|
||||||
Result:=NewRefNode;
|
Result:=NewRefNode;
|
||||||
//
|
//
|
||||||
node:=OpAccessChain(line,vType,Result,src);
|
node:=OpAccessChain(_get_line(ppLine),vType,Result,src);
|
||||||
node^.AddParam(idx0);
|
node^.AddParam(idx0);
|
||||||
|
_set_line(ppLine,node);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEmitOp.OpCondMerge(pLine,pLabel:PspirvOp):PSpirvOp;
|
function TEmitOp.OpCondMerge(pLine,pLabel:PspirvOp):PSpirvOp;
|
||||||
|
|
|
@ -14,7 +14,15 @@ type
|
||||||
PsrHeaderList=^TsrHeaderList;
|
PsrHeaderList=^TsrHeaderList;
|
||||||
TsrHeaderList=object(TsrOpBlockCustom)
|
TsrHeaderList=object(TsrOpBlockCustom)
|
||||||
FGLSL_std_450:PSpirvOp;
|
FGLSL_std_450:PSpirvOp;
|
||||||
function emit_glsl_ext:PSpirvOp;
|
//
|
||||||
|
FSPV_EXT_descriptor_indexing:Boolean;
|
||||||
|
//
|
||||||
|
function OpExtension(const n:RawByteString):PSpirvOp;
|
||||||
|
function OpExtInstImport(const n:RawByteString):PSpirvOp;
|
||||||
|
//
|
||||||
|
function GLSL_std_450:PSpirvOp;
|
||||||
|
//
|
||||||
|
procedure SPV_EXT_descriptor_indexing;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
PsrDecorate=^TsrDecorate;
|
PsrDecorate=^TsrDecorate;
|
||||||
|
@ -53,17 +61,43 @@ implementation
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
function TsrHeaderList.emit_glsl_ext:PSpirvOp;
|
function TsrHeaderList.OpExtension(const n:RawByteString):PSpirvOp;
|
||||||
|
var
|
||||||
|
node:PSpirvOp;
|
||||||
|
begin
|
||||||
|
node:=AddSpirvOp(Op.OpExtension);
|
||||||
|
node^.AddString(n);
|
||||||
|
Result:=node;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TsrHeaderList.OpExtInstImport(const n:RawByteString):PSpirvOp;
|
||||||
|
var
|
||||||
|
node:PSpirvOp;
|
||||||
|
begin
|
||||||
|
node:=AddSpirvOp(Op.OpExtInstImport);
|
||||||
|
node^.pDst:=Emit.NewRefNode;
|
||||||
|
node^.AddString(n);
|
||||||
|
Result:=node;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TsrHeaderList.GLSL_std_450:PSpirvOp;
|
||||||
begin
|
begin
|
||||||
if (FGLSL_std_450=nil) then
|
if (FGLSL_std_450=nil) then
|
||||||
begin
|
begin
|
||||||
FGLSL_std_450:=AddSpirvOp(Op.OpExtInstImport);
|
FGLSL_std_450:=OpExtInstImport('GLSL.std.450');
|
||||||
FGLSL_std_450^.pDst:=Emit.NewRefNode;
|
|
||||||
FGLSL_std_450^.AddString('GLSL.std.450');
|
|
||||||
end;
|
end;
|
||||||
Result:=FGLSL_std_450;
|
Result:=FGLSL_std_450;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TsrHeaderList.SPV_EXT_descriptor_indexing;
|
||||||
|
begin
|
||||||
|
if not FSPV_EXT_descriptor_indexing then
|
||||||
|
begin
|
||||||
|
OpExtension('SPV_EXT_descriptor_indexing');
|
||||||
|
FSPV_EXT_descriptor_indexing:=True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
function TsrDecorate.c(n1,n2:PsrDecorate):Integer;
|
function TsrDecorate.c(n1,n2:PsrDecorate):Integer;
|
||||||
|
|
|
@ -462,7 +462,7 @@ function TEmitInterface.AddSGlslOp(pLine:PspirvOp;OpId:DWORD):PSpirvOp;
|
||||||
var
|
var
|
||||||
ext,node:PSpirvOp;
|
ext,node:PSpirvOp;
|
||||||
begin
|
begin
|
||||||
ext:=HeaderList.emit_glsl_ext;
|
ext:=HeaderList.GLSL_std_450;
|
||||||
node:=AddSpirvOp(pLine,Op.OpExtInst);
|
node:=AddSpirvOp(pLine,Op.OpExtInst);
|
||||||
node^.AddParam(ext^.pDst);
|
node^.AddParam(ext^.pDst);
|
||||||
node^.AddLiteral(OpId,GlslOp.GetStr(OpId));
|
node^.AddLiteral(OpId,GlslOp.GetStr(OpId));
|
||||||
|
|
|
@ -510,7 +510,7 @@ begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if not can_clear then Exit;
|
if not can_clear then Exit;
|
||||||
|
|
||||||
Assert(read_count=0,IntToStr(OpId));
|
Assert(read_count=0,Op.GetStr(OpId));
|
||||||
|
|
||||||
if is_write_op(OpId) then
|
if is_write_op(OpId) then
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -45,8 +45,11 @@ type
|
||||||
function GetItem(i:Word):PsrNode;
|
function GetItem(i:Word):PsrNode;
|
||||||
function GetDWORD(i:Word):DWORD;
|
function GetDWORD(i:Word):DWORD;
|
||||||
function array_stride:DWORD;
|
function array_stride:DWORD;
|
||||||
|
function is_array_image:Boolean;
|
||||||
|
function array_image_info:TsrTypeImageInfo;
|
||||||
function array_count:DWORD;
|
function array_count:DWORD;
|
||||||
function storage_class:DWORD;
|
function storage_class:DWORD;
|
||||||
|
function is_image:Boolean;
|
||||||
function image_info:TsrTypeImageInfo;
|
function image_info:TsrTypeImageInfo;
|
||||||
function GetPrintName:RawByteString;
|
function GetPrintName:RawByteString;
|
||||||
end;
|
end;
|
||||||
|
@ -196,6 +199,44 @@ begin
|
||||||
Result:=child^.fsize;
|
Result:=child^.fsize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsrType.is_array_image:Boolean;
|
||||||
|
var
|
||||||
|
child:PsrType;
|
||||||
|
begin
|
||||||
|
Result:=False;
|
||||||
|
|
||||||
|
Case fdtype of
|
||||||
|
dtTypeArray:;
|
||||||
|
dtTypeRuntimeArray:;
|
||||||
|
else
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
child:=GetItem(0)^.AsType(ntType);
|
||||||
|
if (child=nil) then Exit;
|
||||||
|
|
||||||
|
Result:=child^.is_image;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TsrType.array_image_info:TsrTypeImageInfo;
|
||||||
|
var
|
||||||
|
child:PsrType;
|
||||||
|
begin
|
||||||
|
Result:=Default(TsrTypeImageInfo);
|
||||||
|
|
||||||
|
Case fdtype of
|
||||||
|
dtTypeArray:;
|
||||||
|
dtTypeRuntimeArray:;
|
||||||
|
else
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
child:=GetItem(0)^.AsType(ntType);
|
||||||
|
if (child=nil) then Exit;
|
||||||
|
|
||||||
|
Result:=child^.image_info;
|
||||||
|
end;
|
||||||
|
|
||||||
function TsrType.array_count:DWORD;
|
function TsrType.array_count:DWORD;
|
||||||
var
|
var
|
||||||
pConst:PsrType;
|
pConst:PsrType;
|
||||||
|
@ -214,8 +255,12 @@ begin
|
||||||
Result:=GetDWORD(0);
|
Result:=GetDWORD(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TsrType.image_info:TsrTypeImageInfo;
|
function TsrType.is_image:Boolean;
|
||||||
|
begin
|
||||||
|
Result:=(fdtype=dtTypeImage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TsrType.image_info:TsrTypeImageInfo;
|
||||||
begin
|
begin
|
||||||
Result:=Default(TsrTypeImageInfo);
|
Result:=Default(TsrTypeImageInfo);
|
||||||
if (fdtype<>dtTypeImage) then Exit;
|
if (fdtype<>dtTypeImage) then Exit;
|
||||||
|
|
|
@ -12,6 +12,7 @@ uses
|
||||||
srRefId,
|
srRefId,
|
||||||
srType,
|
srType,
|
||||||
srTypes,
|
srTypes,
|
||||||
|
srReg,
|
||||||
srLayout,
|
srLayout,
|
||||||
srVariable,
|
srVariable,
|
||||||
srCapability,
|
srCapability,
|
||||||
|
@ -50,6 +51,15 @@ type
|
||||||
function GetPrintName:RawByteString;
|
function GetPrintName:RawByteString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
PsrArrayChain=^TsrArrayChain;
|
||||||
|
TsrArrayChain=packed object(TsrRegUniform)
|
||||||
|
pNext:PsrArrayChain;
|
||||||
|
//
|
||||||
|
idx0:PsrNode;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TsrArrayChainList=specialize TNodeStack<PsrArrayChain>;
|
||||||
|
|
||||||
PsrUniform=^TsrUniform;
|
PsrUniform=^TsrUniform;
|
||||||
TsrUniform=object(TsrDescriptor)
|
TsrUniform=object(TsrDescriptor)
|
||||||
public
|
public
|
||||||
|
@ -61,9 +71,14 @@ type
|
||||||
fwrite_count:DWORD;
|
fwrite_count:DWORD;
|
||||||
//
|
//
|
||||||
FReg:TsrRegUniform;
|
FReg:TsrRegUniform;
|
||||||
|
FArrayChainList:TsrArrayChainList;
|
||||||
public
|
public
|
||||||
Procedure Init; inline;
|
FEmit:TCustomEmit;
|
||||||
|
Procedure Init(Emit:TCustomEmit); inline;
|
||||||
function pReg:PsrRegUniform; inline;
|
function pReg:PsrRegUniform; inline;
|
||||||
|
function FetchArrayChain(pLine:Pointer;idx0:PsrNode):PsrArrayChain;
|
||||||
|
function chain_read:DWORD;
|
||||||
|
function chain_write:DWORD;
|
||||||
function GetStorageName:RawByteString;
|
function GetStorageName:RawByteString;
|
||||||
function GetTypeChar:String2;
|
function GetTypeChar:String2;
|
||||||
function GetRw:Char;
|
function GetRw:Char;
|
||||||
|
@ -87,6 +102,9 @@ type
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
emit_op;
|
||||||
|
|
||||||
class function ntRegUniform.Down(node:PsrNode):Pointer;
|
class function ntRegUniform.Down(node:PsrNode):Pointer;
|
||||||
begin
|
begin
|
||||||
Result:=PsrRegUniform(node)^.FVar;
|
Result:=PsrRegUniform(node)^.FVar;
|
||||||
|
@ -179,11 +197,13 @@ begin
|
||||||
Result:=Integer(n1^.FType>n2^.FType)-Integer(n1^.FType<n2^.FType);
|
Result:=Integer(n1^.FType>n2^.FType)-Integer(n1^.FType<n2^.FType);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TsrUniform.Init; inline;
|
Procedure TsrUniform.Init(Emit:TCustomEmit); inline;
|
||||||
begin
|
begin
|
||||||
fntype :=ntUniform;
|
fntype :=ntUniform;
|
||||||
FStorage:=StorageClass.UniformConstant;
|
FStorage:=StorageClass.UniformConstant;
|
||||||
FBinding:=-1;
|
FBinding:=-1;
|
||||||
|
//
|
||||||
|
FEmit:=Emit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TsrUniform.pReg:PsrRegUniform; inline;
|
function TsrUniform.pReg:PsrRegUniform; inline;
|
||||||
|
@ -191,9 +211,35 @@ begin
|
||||||
Result:=@FReg;
|
Result:=@FReg;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsrUniform.FetchArrayChain(pLine:Pointer;idx0:PsrNode):PsrArrayChain;
|
||||||
|
var
|
||||||
|
iType:PsrType;
|
||||||
|
pChain:PsrNode;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
|
||||||
|
iType:=pType^.GetItem(0)^.AsType(ntType); //Image
|
||||||
|
if (iType=nil) then Exit;
|
||||||
|
|
||||||
|
//Check dublicate?
|
||||||
|
pChain:=TEmitOp(FEmit).OpAccessChainTo(iType,pVar,idx0,@pLine);
|
||||||
|
|
||||||
|
Result:=FEmit.Alloc(SizeOf(TsrArrayChain));
|
||||||
|
Result^.Init(pVar);
|
||||||
|
Result^.idx0:=idx0;
|
||||||
|
|
||||||
|
TEmitOp(FEmit).OpLoad(pLine,iType,Result,pChain);
|
||||||
|
|
||||||
|
//
|
||||||
|
FArrayChainList.Push_head(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
function TsrUniform.GetStorageName:RawByteString;
|
function TsrUniform.GetStorageName:RawByteString;
|
||||||
|
label
|
||||||
|
_image_info;
|
||||||
var
|
var
|
||||||
image_info:TsrTypeImageInfo;
|
image_info:TsrTypeImageInfo;
|
||||||
|
pChild:PsrType;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if (FType<>nil) then
|
if (FType<>nil) then
|
||||||
|
@ -202,6 +248,8 @@ begin
|
||||||
begin
|
begin
|
||||||
image_info:=FType^.image_info;
|
image_info:=FType^.image_info;
|
||||||
|
|
||||||
|
_image_info:
|
||||||
|
|
||||||
if (image_info.Dim=Dim.Buffer) then
|
if (image_info.Dim=Dim.Buffer) then
|
||||||
begin
|
begin
|
||||||
Case image_info.Sampled of
|
Case image_info.Sampled of
|
||||||
|
@ -218,15 +266,50 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
//
|
||||||
dtTypeSampler:Result:='uSmp'+IntToStr(FBinding);
|
dtTypeSampler:Result:='uSmp'+IntToStr(FBinding);
|
||||||
|
//
|
||||||
|
dtTypeRuntimeArray:
|
||||||
|
begin
|
||||||
|
pChild:=pType^.GetItem(0)^.AsType(ntType); //Image
|
||||||
|
|
||||||
|
if (pChild^.dtype=dtTypeImage) then
|
||||||
|
begin
|
||||||
|
image_info:=pChild^.image_info;
|
||||||
|
|
||||||
|
goto _image_info;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
else;
|
else;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//TU
|
||||||
|
//TS
|
||||||
|
//TR
|
||||||
|
|
||||||
|
//IU
|
||||||
|
//IS
|
||||||
|
//IR
|
||||||
|
|
||||||
|
//US
|
||||||
|
|
||||||
|
//RU
|
||||||
|
|
||||||
|
function GetSampledTypeChar(Sampled:Byte):Char;
|
||||||
|
begin
|
||||||
|
Case Sampled of
|
||||||
|
1:Result:='U'; //VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER | VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
|
||||||
|
2:Result:='S'; //VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
|
||||||
|
else Result:='R'; //runtime texel buffer
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TsrUniform.GetTypeChar:String2;
|
function TsrUniform.GetTypeChar:String2;
|
||||||
var
|
var
|
||||||
image_info:TsrTypeImageInfo;
|
image_info:TsrTypeImageInfo;
|
||||||
|
pChild:PsrType;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
if (FType<>nil) then
|
if (FType<>nil) then
|
||||||
|
@ -237,33 +320,88 @@ begin
|
||||||
|
|
||||||
if (image_info.Dim=Dim.Buffer) then
|
if (image_info.Dim=Dim.Buffer) then
|
||||||
begin
|
begin
|
||||||
Case image_info.Sampled of
|
Result:='T'+GetSampledTypeChar(image_info.Sampled);
|
||||||
1:Result:='UB'; //VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
|
|
||||||
2:Result:='SB'; //VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
|
||||||
else Result:='RB'; //runtime texel buffer
|
|
||||||
end;
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Case image_info.Sampled of
|
Result:='I'+GetSampledTypeChar(image_info.Sampled);
|
||||||
1:Result:='UI'; //VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
|
|
||||||
2:Result:='SI'; //VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
|
|
||||||
else Result:='RI'; //runtime image
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
//
|
||||||
dtTypeSampler:Result:='US'; //VK_DESCRIPTOR_TYPE_SAMPLER
|
dtTypeSampler:Result:='US'; //VK_DESCRIPTOR_TYPE_SAMPLER
|
||||||
else;
|
//
|
||||||
|
dtTypeRuntimeArray:
|
||||||
|
begin
|
||||||
|
pChild:=pType^.GetItem(0)^.AsType(ntType); //Image
|
||||||
|
|
||||||
|
if (pChild^.dtype=dtTypeImage) then
|
||||||
|
begin
|
||||||
|
image_info:=pChild^.image_info;
|
||||||
|
|
||||||
|
if (image_info.Dim=Dim.Buffer) then
|
||||||
|
begin
|
||||||
|
Assert(false,'GetTypeChar');
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result:='R'+GetSampledTypeChar(image_info.Sampled);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
Assert(false,'GetTypeChar');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TsrUniform.chain_read:DWORD;
|
||||||
|
var
|
||||||
|
node:PsrArrayChain;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
if FReg.IsUsed then
|
||||||
|
begin
|
||||||
|
Result:=FReg.read_count;
|
||||||
|
end;
|
||||||
|
//
|
||||||
|
node:=FArrayChainList.pHead;
|
||||||
|
While (node<>nil) do
|
||||||
|
begin
|
||||||
|
if node^.IsUsed then
|
||||||
|
begin
|
||||||
|
Result:=Result+node^.read_count;
|
||||||
|
end;
|
||||||
|
node:=node^.pNext;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TsrUniform.chain_write:DWORD;
|
||||||
|
var
|
||||||
|
node:PsrArrayChain;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
if FReg.IsUsed then
|
||||||
|
begin
|
||||||
|
Result:=FReg.write_count;
|
||||||
|
end;
|
||||||
|
//
|
||||||
|
node:=FArrayChainList.pHead;
|
||||||
|
While (node<>nil) do
|
||||||
|
begin
|
||||||
|
if node^.IsUsed then
|
||||||
|
begin
|
||||||
|
Result:=Result+node^.write_count;
|
||||||
|
end;
|
||||||
|
node:=node^.pNext;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TsrUniform.GetRw:Char;
|
function TsrUniform.GetRw:Char;
|
||||||
begin
|
begin
|
||||||
Result:='0';
|
Result:='0';
|
||||||
if (FReg.read_count<>0) then
|
if (chain_read<>0) then
|
||||||
begin
|
begin
|
||||||
Result:='1';
|
Result:='1';
|
||||||
end;
|
end;
|
||||||
if (FReg.write_count<>0) then
|
if (chain_write<>0) then
|
||||||
begin
|
begin
|
||||||
Result:=Char(ord(Result) or ord('2'));
|
Result:=Char(ord(Result) or ord('2'));
|
||||||
end;
|
end;
|
||||||
|
@ -294,7 +432,7 @@ var
|
||||||
node:TsrUniform;
|
node:TsrUniform;
|
||||||
begin
|
begin
|
||||||
node:=Default(TsrUniform);
|
node:=Default(TsrUniform);
|
||||||
node.Init;
|
node.Init(FEmit);
|
||||||
node.pLayout:=s;
|
node.pLayout:=s;
|
||||||
node.FType :=t;
|
node.FType :=t;
|
||||||
Result:=FNTree.Find(@node);
|
Result:=FNTree.Find(@node);
|
||||||
|
@ -358,11 +496,11 @@ begin
|
||||||
|
|
||||||
if (image_info.Sampled=2) then //storage image
|
if (image_info.Sampled=2) then //storage image
|
||||||
begin
|
begin
|
||||||
if (node^.FReg.read_count=0) then
|
if (node^.chain_read=0) then
|
||||||
begin
|
begin
|
||||||
pDecorateList^.OpDecorate(pVar,Decoration.NonReadable,0);
|
pDecorateList^.OpDecorate(pVar,Decoration.NonReadable,0);
|
||||||
end;
|
end;
|
||||||
if (node^.FReg.write_count=0) then
|
if (node^.chain_write=0) then
|
||||||
begin
|
begin
|
||||||
pDecorateList^.OpDecorate(pVar,Decoration.NonWritable,0);
|
pDecorateList^.OpDecorate(pVar,Decoration.NonWritable,0);
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -94,9 +94,9 @@ begin
|
||||||
//load positions
|
//load positions
|
||||||
For i:=0 to 2 do
|
For i:=0 to 2 do
|
||||||
begin
|
begin
|
||||||
pChain:=SprvEmit.OpAccessChainTo(SprvEmit.line,pVec4f,InputPos,UintId[i]);
|
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputPos,UintId[i]);
|
||||||
//
|
//
|
||||||
Positions[i]:=SprvEmit.OpLoadTo(SprvEmit.line,pVec4f,pChain);
|
Positions[i]:=SprvEmit.OpLoadTo(pVec4f,pChain);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//extract
|
//extract
|
||||||
|
@ -143,9 +143,9 @@ begin
|
||||||
//Send vertex by index
|
//Send vertex by index
|
||||||
For i:=0 to 2 do
|
For i:=0 to 2 do
|
||||||
begin
|
begin
|
||||||
pChain:=SprvEmit.OpAccessChainTo(SprvEmit.line,pVec4f,InputPos,pIndex);
|
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputPos,pIndex);
|
||||||
//
|
//
|
||||||
Positions[i]:=SprvEmit.OpLoadTo(SprvEmit.line,pVec4f,pChain);
|
Positions[i]:=SprvEmit.OpLoadTo(pVec4f,pChain);
|
||||||
//
|
//
|
||||||
|
|
||||||
SprvEmit.OpStore(SprvEmit.line,OutputPos,Positions[i]);
|
SprvEmit.OpStore(SprvEmit.line,OutputPos,Positions[i]);
|
||||||
|
|
|
@ -73,6 +73,9 @@ type
|
||||||
procedure OnVertLayout(P:PChar);
|
procedure OnVertLayout(P:PChar);
|
||||||
procedure OnBuffLayout(P:PChar);
|
procedure OnBuffLayout(P:PChar);
|
||||||
procedure OnUnifLayout(P:PChar);
|
procedure OnUnifLayout(P:PChar);
|
||||||
|
procedure OnTexlLayout(P:PChar);
|
||||||
|
procedure OnImgsLayout(P:PChar);
|
||||||
|
procedure OnRuntLayout(P:PChar);
|
||||||
procedure OnFuncLayout(P:PChar);
|
procedure OnFuncLayout(P:PChar);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -451,9 +454,12 @@ begin
|
||||||
'V':OnVertLayout(P);
|
'V':OnVertLayout(P);
|
||||||
'B':OnBuffLayout(P);
|
'B':OnBuffLayout(P);
|
||||||
'U':OnUnifLayout(P);
|
'U':OnUnifLayout(P);
|
||||||
|
'T':OnTexlLayout(P);
|
||||||
|
'I':OnImgsLayout(P);
|
||||||
|
'R':OnRuntLayout(P);
|
||||||
'F':OnFuncLayout(P);
|
'F':OnFuncLayout(P);
|
||||||
else
|
else
|
||||||
Assert(false,'TODO OnSourceExtension:"'+P^+'"');
|
Assert(false,'TODO: OnSourceExtension:"'+P^+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -482,7 +488,7 @@ begin
|
||||||
't':AddDataLayout(vtTSharp4,_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
't':AddDataLayout(vtTSharp4,_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
||||||
'T':AddDataLayout(vtTSharp8,_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
'T':AddDataLayout(vtTSharp8,_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
||||||
else
|
else
|
||||||
Assert(false,'TODO OnDataLayout:"'+P[1]+'"');
|
Assert(false,'TODO: OnDataLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -492,7 +498,7 @@ begin
|
||||||
Case P[1] of
|
Case P[1] of
|
||||||
'D':AddImmData(_get_hex_dword(@P[3]));
|
'D':AddImmData(_get_hex_dword(@P[3]));
|
||||||
else
|
else
|
||||||
Assert(false,'TODO OnIExtLayout:"'+P[1]+'"');
|
Assert(false,'TODO: OnIExtLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -544,7 +550,8 @@ begin
|
||||||
with TvShaderExt(FOwner) do
|
with TvShaderExt(FOwner) do
|
||||||
Case P[1] of
|
Case P[1] of
|
||||||
'A':AddVertLayout(_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
'A':AddVertLayout(_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
||||||
else;
|
else
|
||||||
|
Assert(false,'TODO: OnVertLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -613,7 +620,8 @@ begin
|
||||||
_get_hex_dword(@P[$21]),
|
_get_hex_dword(@P[$21]),
|
||||||
_get_hex_dword(@P[$2E]),
|
_get_hex_dword(@P[$2E]),
|
||||||
_get_hex_char (@P[$3B]));
|
_get_hex_char (@P[$3B]));
|
||||||
else;
|
else
|
||||||
|
Assert(false,'TODO: OnBuffLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -648,7 +656,7 @@ begin
|
||||||
AddToCustomLayout(FUnifLayouts,v);
|
AddToCustomLayout(FUnifLayouts,v);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//UI;PID=00000001;BND=00000000;MRW=1
|
//IU;PID=00000001;BND=00000000;MRW=1
|
||||||
//US;PID=00000002;BND=00000001;MRW=1
|
//US;PID=00000002;BND=00000001;MRW=1
|
||||||
//0123456789ABCDEF0123456789ABCDEF01
|
//0123456789ABCDEF0123456789ABCDEF01
|
||||||
//0 1 2
|
//0 1 2
|
||||||
|
@ -657,18 +665,38 @@ procedure TvShaderParserExt.OnUnifLayout(P:PChar);
|
||||||
begin
|
begin
|
||||||
with TvShaderExt(FOwner) do
|
with TvShaderExt(FOwner) do
|
||||||
Case P[1] of
|
Case P[1] of
|
||||||
'I':AddUnifLayout(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
|
||||||
_get_hex_dword(@P[7]),
|
|
||||||
_get_hex_dword(@P[$14]),
|
|
||||||
_get_hex_char (@P[$21]));
|
|
||||||
'S':AddUnifLayout(VK_DESCRIPTOR_TYPE_SAMPLER,
|
'S':AddUnifLayout(VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||||
_get_hex_dword(@P[7]),
|
_get_hex_dword(@P[7]),
|
||||||
_get_hex_dword(@P[$14]),
|
_get_hex_dword(@P[$14]),
|
||||||
_get_hex_char (@P[$21]));
|
_get_hex_char (@P[$21]));
|
||||||
else;
|
else
|
||||||
|
Assert(false,'TODO: OnUnifLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TvShaderParserExt.OnTexlLayout(P:PChar);
|
||||||
|
begin
|
||||||
|
Assert(false,'TODO: OnTexlLayout:"'+P[1]+'"');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TvShaderParserExt.OnImgsLayout(P:PChar);
|
||||||
|
begin
|
||||||
|
with TvShaderExt(FOwner) do
|
||||||
|
Case P[1] of
|
||||||
|
'U':AddUnifLayout(VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||||
|
_get_hex_dword(@P[7]),
|
||||||
|
_get_hex_dword(@P[$14]),
|
||||||
|
_get_hex_char (@P[$21]));
|
||||||
|
else
|
||||||
|
Assert(false,'TODO: OnImgsLayout:"'+P[1]+'"');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TvShaderParserExt.OnRuntLayout(P:PChar);
|
||||||
|
begin
|
||||||
|
Assert(false,'TODO: OnRuntLayout:"'+P[1]+'"');
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TvShaderExt.EnumUnifLayout(cb:TvCustomLayoutCb;Fset:TVkUInt32;pUserData,pImmData:PDWORD);
|
Procedure TvShaderExt.EnumUnifLayout(cb:TvCustomLayoutCb;Fset:TVkUInt32;pUserData,pImmData:PDWORD);
|
||||||
var
|
var
|
||||||
i:Integer;
|
i:Integer;
|
||||||
|
@ -697,7 +725,8 @@ begin
|
||||||
with TvShaderExt(FOwner) do
|
with TvShaderExt(FOwner) do
|
||||||
Case P[1] of
|
Case P[1] of
|
||||||
'F':AddFuncLayout(_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
'F':AddFuncLayout(_get_hex_dword(@P[7]),_get_hex_dword(@P[$14]));
|
||||||
else;
|
else
|
||||||
|
Assert(false,'TODO: OnFuncLayout:"'+P[1]+'"');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue