mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
f498b0da64
commit
33572ce5f2
|
@ -10,6 +10,7 @@ uses
|
|||
spirv,
|
||||
si_ci_vi_merged_registers,
|
||||
ps4_pssl,
|
||||
srInterface,
|
||||
srAllocator,
|
||||
srLiteral,
|
||||
srType,
|
||||
|
@ -45,6 +46,9 @@ type
|
|||
RSRC2:TSPI_SHADER_PGM_RSRC2_PS;
|
||||
ENA:TSPI_PS_INPUT_ENA);
|
||||
|
||||
Procedure SET_PIX_CENTER(val:Byte);
|
||||
Procedure SET_SHADER_CONTROL(const SHADER_CONTROL:TDB_SHADER_CONTROL);
|
||||
|
||||
Procedure InitCs(RSRC1:TCOMPUTE_PGM_RSRC1;
|
||||
RSRC2:TCOMPUTE_PGM_RSRC2;
|
||||
NTX:TCOMPUTE_NUM_THREAD_X;
|
||||
|
@ -430,6 +434,22 @@ begin
|
|||
AddCapability(Capability.Shader);
|
||||
end;
|
||||
|
||||
Procedure TSprvEmit.SET_PIX_CENTER(val:Byte);
|
||||
begin
|
||||
FPixelCenter:=(val<>0);
|
||||
end;
|
||||
|
||||
Procedure TSprvEmit.SET_SHADER_CONTROL(const SHADER_CONTROL:TDB_SHADER_CONTROL);
|
||||
begin
|
||||
case SHADER_CONTROL.CONSERVATIVE_Z_EXPORT of
|
||||
1:FDepthMode:=foDepthLess; //EXPORT_LESS_THAN_Z
|
||||
2:FDepthMode:=foDepthGreater; //EXPORT_GREATER_THAN_Z
|
||||
else;
|
||||
end;
|
||||
//
|
||||
FEarlyFragmentTests:=(SHADER_CONTROL.DEPTH_BEFORE_SHADER<>0);
|
||||
end;
|
||||
|
||||
Procedure TSprvEmit.InitCs(RSRC1:TCOMPUTE_PGM_RSRC1;
|
||||
RSRC2:TCOMPUTE_PGM_RSRC2;
|
||||
NTX:TCOMPUTE_NUM_THREAD_X;
|
||||
|
|
|
@ -7,7 +7,9 @@ interface
|
|||
uses
|
||||
sysutils,
|
||||
spirv,
|
||||
|
||||
srNode,
|
||||
srInterface,
|
||||
srType,
|
||||
srTypes,
|
||||
srConst,
|
||||
|
@ -33,6 +35,7 @@ type
|
|||
procedure AllocBinding;
|
||||
procedure AllocTypeBinding;
|
||||
procedure AllocEntryPoint;
|
||||
function AddExecutionMode(mode:PtrUint):PSpirvOp;
|
||||
procedure AllocHeader;
|
||||
procedure AllocOpListId(node:PspirvOp);
|
||||
procedure AllocListId(node:PsrNode);
|
||||
|
@ -165,6 +168,16 @@ begin
|
|||
OutputList .AllocEntryPoint(node);
|
||||
end;
|
||||
|
||||
function TSprvEmit_alloc.AddExecutionMode(mode:PtrUint):PSpirvOp;
|
||||
var
|
||||
node:PSpirvOp;
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(mode,ExecutionMode.GetStr(mode));
|
||||
Result:=node;
|
||||
end;
|
||||
|
||||
procedure TSprvEmit_alloc.AllocHeader;
|
||||
var
|
||||
node:PSpirvOp;
|
||||
|
@ -178,44 +191,30 @@ begin
|
|||
Case FExecutionModel of
|
||||
ExecutionModel.Fragment:
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.OriginUpperLeft,ExecutionMode.GetStr(ExecutionMode.OriginUpperLeft));
|
||||
AddExecutionMode(ExecutionMode.OriginUpperLeft);
|
||||
|
||||
if (foDepthReplacing in DecorateList.FfemOpSet) then
|
||||
if FPixelCenter then
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.DepthReplacing,ExecutionMode.GetStr(ExecutionMode.DepthReplacing));
|
||||
AddExecutionMode(ExecutionMode.PixelCenterInteger);
|
||||
end;
|
||||
|
||||
if (foDepthGreater in DecorateList.FfemOpSet) then
|
||||
if FEarlyFragmentTests then
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.DepthGreater,ExecutionMode.GetStr(ExecutionMode.DepthGreater));
|
||||
AddExecutionMode(ExecutionMode.EarlyFragmentTests);
|
||||
end;
|
||||
|
||||
if (foDepthLess in DecorateList.FfemOpSet) then
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.DepthLess,ExecutionMode.GetStr(ExecutionMode.DepthLess));
|
||||
end;
|
||||
|
||||
if (foDepthUnchanged in DecorateList.FfemOpSet) then
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.DepthUnchanged,ExecutionMode.GetStr(ExecutionMode.DepthUnchanged));
|
||||
case FDepthMode of
|
||||
foDepthReplacing:AddExecutionMode(ExecutionMode.DepthReplacing);
|
||||
foDepthGreater :AddExecutionMode(ExecutionMode.DepthGreater);
|
||||
foDepthLess :AddExecutionMode(ExecutionMode.DepthLess);
|
||||
foDepthUnchanged:AddExecutionMode(ExecutionMode.DepthUnchanged);
|
||||
else;
|
||||
end;
|
||||
|
||||
end;
|
||||
ExecutionModel.GLCompute:
|
||||
begin
|
||||
node:=HeaderList.AddSpirvOp(Op.OpExecutionMode);
|
||||
node^.AddParam(Main);
|
||||
node^.AddLiteral(ExecutionMode.LocalSize,ExecutionMode.GetStr(ExecutionMode.LocalSize));
|
||||
node:=AddExecutionMode(ExecutionMode.LocalSize);
|
||||
node^.AddLiteral(FLocalSize.x);
|
||||
node^.AddLiteral(FLocalSize.y);
|
||||
node^.AddLiteral(FLocalSize.z);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<Units Count="50">
|
||||
<Units Count="38">
|
||||
<Unit0>
|
||||
<Filename Value="pssl-spirv.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -35,214 +35,161 @@
|
|||
<IsPartOfProject Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="srNodes.pas"/>
|
||||
<Filename Value="srTypes.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="srTypes.pas"/>
|
||||
<Filename Value="srConst.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="srConst.pas"/>
|
||||
<Filename Value="srRefId.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="srRefId.pas"/>
|
||||
<Filename Value="srOp.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="srIO.pas"/>
|
||||
<Filename Value="srReg.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="srOp.pas"/>
|
||||
<Filename Value="SprvEmit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="srReg.pas"/>
|
||||
<Filename Value="srAllocator.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="SprvEmit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="srAllocator.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="srArray.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="emit_sop1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_SOP1"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="emit_vop1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VOP1"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="emit_vopc.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VOPC"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="emit_vop3b.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VOP3b"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="emit_mubuf.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_MUBUF"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="emit_exp.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_EXP"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="emit_vintrp.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VINTRP"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="emit_smrd.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_SMRD"/>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="emit_sop2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_SOP2"/>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="emit_vop2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VOP2"/>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="emit_post_process.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit22>
|
||||
<Unit23>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="emit_print.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit23>
|
||||
<Unit24>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="emit_mimg.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_MIMG"/>
|
||||
</Unit24>
|
||||
<Unit25>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
<Filename Value="emit_op.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit25>
|
||||
<Unit26>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
<Filename Value="emit_sopp.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_SOPP"/>
|
||||
</Unit26>
|
||||
<Unit27>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="emit_sopc.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_SOPC"/>
|
||||
</Unit22>
|
||||
<Unit23>
|
||||
<Filename Value="emit_post_op.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit23>
|
||||
<Unit24>
|
||||
<Filename Value="srLayout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit24>
|
||||
<Unit25>
|
||||
<Filename Value="srBuffer.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit25>
|
||||
<Unit26>
|
||||
<Filename Value="srVariable.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit26>
|
||||
<Unit27>
|
||||
<Filename Value="srInput.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit27>
|
||||
<Unit28>
|
||||
<Filename Value="srparsernode.pas"/>
|
||||
<Filename Value="srOutput.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="srParserNode"/>
|
||||
</Unit28>
|
||||
<Unit29>
|
||||
<Filename Value="srLabel.pas"/>
|
||||
<Filename Value="srOpUtils.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit29>
|
||||
<Unit30>
|
||||
<Filename Value="emit_post_op.pas"/>
|
||||
<Filename Value="srVertLayout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit30>
|
||||
<Unit31>
|
||||
<Filename Value="emit_bitcast.pas"/>
|
||||
<Filename Value="srFragLayout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="srBitcast"/>
|
||||
</Unit31>
|
||||
<Unit32>
|
||||
<Filename Value="srVolatile.pas"/>
|
||||
<Filename Value="srDecorate.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit32>
|
||||
<Unit33>
|
||||
<Filename Value="srLayout.pas"/>
|
||||
<Filename Value="emit_bin.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit33>
|
||||
<Unit34>
|
||||
<Filename Value="srBuffer.pas"/>
|
||||
<Filename Value="srConfig.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit34>
|
||||
<Unit35>
|
||||
<Filename Value="gnSplayTree.pas"/>
|
||||
<Filename Value="..\chip\ps4_shader.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit35>
|
||||
<Unit36>
|
||||
<Filename Value="srVariable.pas"/>
|
||||
<Filename Value="srInterface.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit36>
|
||||
<Unit37>
|
||||
<Filename Value="srInput.pas"/>
|
||||
<Filename Value="emit_alloc.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit37>
|
||||
<Unit38>
|
||||
<Filename Value="srOutput.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit38>
|
||||
<Unit39>
|
||||
<Filename Value="srUniformConstant.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit39>
|
||||
<Unit40>
|
||||
<Filename Value="srOpUtils.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit40>
|
||||
<Unit41>
|
||||
<Filename Value="srCFG.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit41>
|
||||
<Unit42>
|
||||
<Filename Value="srCap.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit42>
|
||||
<Unit43>
|
||||
<Filename Value="srVertLayout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit43>
|
||||
<Unit44>
|
||||
<Filename Value="srFragLayout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit44>
|
||||
<Unit45>
|
||||
<Filename Value="srDecorate.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit45>
|
||||
<Unit46>
|
||||
<Filename Value="emit_mbuf.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="emit_VBUF"/>
|
||||
</Unit46>
|
||||
<Unit47>
|
||||
<Filename Value="srbufinfo.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="srBufInfo"/>
|
||||
</Unit47>
|
||||
<Unit48>
|
||||
<Filename Value="emit_bin.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit48>
|
||||
<Unit49>
|
||||
<Filename Value="srConfig.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit49>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -273,7 +273,7 @@ begin
|
|||
until false;
|
||||
end;
|
||||
|
||||
procedure load_pssl(base:Pointer);
|
||||
procedure load_pssl(base:Pointer;ShaderType:Byte);
|
||||
var
|
||||
info:PShaderBinaryInfo;
|
||||
Slots:PInputUsageSlot;
|
||||
|
@ -360,11 +360,9 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
Assert(info<>nil);
|
||||
|
||||
SprvEmit:=TSprvEmit.Create;
|
||||
|
||||
case info^.m_type of
|
||||
case ShaderType of
|
||||
kShaderTypePs :
|
||||
begin
|
||||
if cfg.FPrintInfo then
|
||||
|
@ -372,6 +370,9 @@ begin
|
|||
|
||||
SprvEmit.InitPs(GPU_REGS.PS.RSRC1,GPU_REGS.PS.RSRC2,GPU_REGS.PS.INPUT_ENA);
|
||||
SprvEmit.SetUserData(@GPU_REGS.PS.USER_DATA);
|
||||
|
||||
SprvEmit.SET_PIX_CENTER(0); //PA_SU_VTX_CNTL.PIX_CENTER
|
||||
SprvEmit.SET_SHADER_CONTROL(GPU_REGS.PS.SHADER_CONTROL);
|
||||
end;
|
||||
kShaderTypeVsVs:
|
||||
begin
|
||||
|
@ -512,10 +513,9 @@ begin
|
|||
load_dump(cfg.FName);
|
||||
end;
|
||||
|
||||
load_pssl(GPU_REGS.CS.Addr);
|
||||
|
||||
load_pssl(GPU_REGS.VS.Addr);
|
||||
load_pssl(GPU_REGS.PS.Addr);
|
||||
load_pssl(GPU_REGS.CS.Addr,kShaderTypeCs);
|
||||
load_pssl(GPU_REGS.VS.Addr,kShaderTypeVsVs);
|
||||
load_pssl(GPU_REGS.PS.Addr,kShaderTypePs);
|
||||
|
||||
if cfg.FPrintInfo then
|
||||
begin
|
||||
|
|
|
@ -31,22 +31,12 @@ type
|
|||
node:PSpirvOp;
|
||||
end;
|
||||
|
||||
TfemOp=(
|
||||
foDepthReplacing,
|
||||
foDepthGreater,
|
||||
foDepthLess,
|
||||
foDepthUnchanged
|
||||
);
|
||||
|
||||
TfemOpSet=Set of TfemOp;
|
||||
|
||||
PsrDecorateList=^TsrDecorateList;
|
||||
TsrDecorateList=object(TsrOpBlockCustom)
|
||||
type
|
||||
TNodeFetch=specialize TNodeFetch<PsrDecorate,TsrDecorate>;
|
||||
var
|
||||
FNTree:TNodeFetch;
|
||||
FfemOpSet:TfemOpSet;
|
||||
function Fetch(data:PsrNode;param1,param2,param3:DWORD):PsrDecorate;
|
||||
procedure OpDecorate(Data:PsrNode;dec_id,param:DWORD);
|
||||
procedure OpMember (Data:PsrNode;index,offset:DWORD);
|
||||
|
|
|
@ -38,8 +38,19 @@ type
|
|||
x,y,z:DWORD;
|
||||
end;
|
||||
|
||||
TDepthMode=(
|
||||
foDepthNone,
|
||||
foDepthReplacing,
|
||||
foDepthGreater,
|
||||
foDepthLess,
|
||||
foDepthUnchanged
|
||||
);
|
||||
|
||||
TEmitInterface=class(TCustomEmit)
|
||||
FExecutionModel:Word;
|
||||
FDepthMode:TDepthMode;
|
||||
FPixelCenter:Boolean;
|
||||
FEarlyFragmentTests:Boolean;
|
||||
FLocalSize:TLocalSize;
|
||||
Config:TsrConfig;
|
||||
//
|
||||
|
|
|
@ -131,7 +131,6 @@ begin
|
|||
end;
|
||||
etMrtz:
|
||||
begin
|
||||
pDecorateList^.FfemOpSet:=pDecorateList^.FfemOpSet+[foDepthReplacing,foDepthGreater];
|
||||
pDecorateList^.OpDecorate(pVar,Decoration.BuiltIn,BuiltIn.FragDepth);
|
||||
end;
|
||||
etPos0:
|
||||
|
|
|
@ -108,7 +108,7 @@ type
|
|||
|
||||
Constructor Create;
|
||||
|
||||
function findMemoryType(Filter:TVkUInt32;prop:TVkMemoryPropertyFlags):Integer;
|
||||
function findMemoryType(Filter:TVkUInt32;prop:TVkMemoryPropertyFlags;start:Integer):Integer;
|
||||
procedure LoadMemoryHeaps;
|
||||
procedure PrintMemoryHeaps;
|
||||
procedure PrintMemoryType(typeFilter:TVkUInt32);
|
||||
|
@ -126,7 +126,7 @@ type
|
|||
public
|
||||
|
||||
Function Alloc(const mr:TVkMemoryRequirements;pr:TVkMemoryPropertyFlags):TvPointer;
|
||||
Function Alloc(Size,Align:TVkDeviceSize;mtindex:Byte):TvPointer;
|
||||
Function Alloc(Size,Align:TVkDeviceSize;mtindex:Byte;test_free:Boolean):TvPointer;
|
||||
Function Free(P:TvPointer):Boolean;
|
||||
|
||||
private
|
||||
|
@ -377,12 +377,13 @@ begin
|
|||
TAILQ_INIT(@FHosts);
|
||||
end;
|
||||
|
||||
function TvMemManager.findMemoryType(Filter:TVkUInt32;prop:TVkMemoryPropertyFlags):Integer;
|
||||
function TvMemManager.findMemoryType(Filter:TVkUInt32;prop:TVkMemoryPropertyFlags;start:Integer):Integer;
|
||||
var
|
||||
i:TVkUInt32;
|
||||
i:Integer;
|
||||
begin
|
||||
Result:=-1;
|
||||
For i:=0 to FProperties.memoryTypeCount-1 do
|
||||
if (start<0) or (start>=FProperties.memoryTypeCount) then Exit;
|
||||
For i:=start to FProperties.memoryTypeCount-1 do
|
||||
begin
|
||||
if ((Filter and (1 shl i))<>0) and ((FProperties.memoryTypes[i].propertyFlags and prop)=prop) then
|
||||
begin
|
||||
|
@ -781,12 +782,26 @@ Function TvMemManager.Alloc(const mr:TVkMemoryRequirements;pr:TVkMemoryPropertyF
|
|||
var
|
||||
mt:Integer;
|
||||
begin
|
||||
mt:=findMemoryType(mr.memoryTypeBits,pr);
|
||||
Result:=Default(TvPointer);
|
||||
mt:=-1;
|
||||
|
||||
repeat
|
||||
|
||||
mt:=findMemoryType(mr.memoryTypeBits,pr,mt+1);
|
||||
if (mt=-1) then Break;
|
||||
|
||||
Result:=Alloc(mr.size,mr.alignment,mt,True);
|
||||
if (Result.FMemory<>nil) then Exit;
|
||||
|
||||
until false;
|
||||
|
||||
mt:=findMemoryType(mr.memoryTypeBits,pr,0);
|
||||
if (mt=-1) then Exit(Default(TvPointer));
|
||||
Result:=Alloc(mr.size,mr.alignment,mt);
|
||||
|
||||
Result:=Alloc(mr.size,mr.alignment,mt,False);
|
||||
end;
|
||||
|
||||
Function TvMemManager.Alloc(Size,Align:TVkDeviceSize;mtindex:Byte):TvPointer;
|
||||
Function TvMemManager.Alloc(Size,Align:TVkDeviceSize;mtindex:Byte;test_free:Boolean):TvPointer;
|
||||
var
|
||||
key:TDevNode;
|
||||
Offset:TVkDeviceSize;
|
||||
|
@ -828,25 +843,28 @@ begin
|
|||
Result.FMemory:=FDevBlocks[key.FBlockId];
|
||||
Result.FOffset:=key.FOffset;
|
||||
end else
|
||||
if _AllcDevBlock(System.Align(Size,GRANULAR_DEV_BLOCK_SIZE),mtindex,key.FBlockId) then
|
||||
begin
|
||||
//alloc save
|
||||
key.Fisfree:=False;
|
||||
key.FSize :=Size;
|
||||
key.FOffset:=0;
|
||||
key.FmType :=mtindex;
|
||||
FAllcSet.Insert(key);
|
||||
Result.FMemory:=FDevBlocks[key.FBlockId];
|
||||
Result.FOffset:=0;
|
||||
//next free save
|
||||
FSize:=FDevBlocks[key.FBlockId].FSize;
|
||||
if (Size<>FSize) then
|
||||
if not test_free then
|
||||
if _AllcDevBlock(System.Align(Size,GRANULAR_DEV_BLOCK_SIZE),mtindex,key.FBlockId) then
|
||||
begin
|
||||
key.Fisfree:=True;
|
||||
key.FOffset:=Size;
|
||||
key.FSize :=FSize-Size;
|
||||
FFreeSet.Insert(key);
|
||||
//alloc save
|
||||
key.Fisfree:=False;
|
||||
key.FSize :=Size;
|
||||
key.FOffset:=0;
|
||||
key.FmType :=mtindex;
|
||||
FAllcSet.Insert(key);
|
||||
Result.FMemory:=FDevBlocks[key.FBlockId];
|
||||
Result.FOffset:=0;
|
||||
//next free save
|
||||
FSize:=FDevBlocks[key.FBlockId].FSize;
|
||||
if (Size<>FSize) then
|
||||
begin
|
||||
key.Fisfree:=True;
|
||||
key.FOffset:=Size;
|
||||
key.FSize :=FSize-Size;
|
||||
FFreeSet.Insert(key);
|
||||
FAllcSet.Insert(key);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
//
|
||||
|
|
|
@ -1229,36 +1229,26 @@ begin
|
|||
Assert(SHADER_CONTROL.Z_EXPORT_ENABLE=0 ,'Z_EXPORT_ENABLE');
|
||||
Assert(SHADER_CONTROL.STENCIL_TEST_VAL_EXPORT_ENABLE=0,'STENCIL_TEST_VAL_EXPORT_ENABLE');
|
||||
|
||||
|
||||
//SHADER_CONTROL.CONSERVATIVE_Z_EXPORT ->
|
||||
//VkPhysicalDeviceConservativeRasterizationPropertiesEXT::conservativeRasterizationPostDepthCoverage
|
||||
|
||||
Assert(SHADER_CONTROL.DEPTH_BEFORE_SHADER=0,'DEPTH_BEFORE_SHADER');
|
||||
Assert(CX_REG^.DB_RENDER_OVERRIDE.FORCE_SHADER_Z_ORDER=0,'FORCE_SHADER_Z_ORDER');
|
||||
|
||||
//SHADER_CONTROL.DEPTH_BEFORE_SHADER
|
||||
//SHADER_CONTROL.CONSERVATIVE_Z_EXPORT -> SPIRV DepthGreater/DepthLess
|
||||
//CX_REG^.PA_SU_VTX_CNTL.PIX_CENTER -> SPIRV PixelCenterInteger
|
||||
//SHADER_CONTROL.DEPTH_BEFORE_SHADER -> SPIRV EarlyFragmentTests
|
||||
|
||||
//CX_REG^.CB_COLOR_CONTROL
|
||||
//CX_REG^.DB_RENDER_OVERRIDE.FORCE_SHADER_Z_ORDER
|
||||
|
||||
{if (CX_REG^.DB_RENDER_OVERRIDE.FORCE_SHADER_Z_ORDER<>0) then
|
||||
begin}
|
||||
Case SHADER_CONTROL.Z_ORDER of
|
||||
LATE_Z,
|
||||
RE_Z :Result.zorder_stage:=ord(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
Case SHADER_CONTROL.Z_ORDER of
|
||||
LATE_Z,
|
||||
RE_Z :Result.zorder_stage:=ord(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
|
||||
EARLY_Z_THEN_LATE_Z,
|
||||
EARLY_Z_THEN_RE_Z :Result.zorder_stage:=ord(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
end;
|
||||
|
||||
EARLY_Z_THEN_LATE_Z,
|
||||
EARLY_Z_THEN_RE_Z :Result.zorder_stage:=ord(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT) or
|
||||
ord(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
end;
|
||||
{end else
|
||||
if (SHADER_CONTROL.DEPTH_BEFORE_SHADER<>0) then
|
||||
begin
|
||||
Result.zorder_stage:=ord(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||
end else
|
||||
begin
|
||||
Result.zorder_stage:=ord(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT);
|
||||
end;}
|
||||
Result.zorder_stage:=Result.zorder_stage or ord(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||
end;
|
||||
|
||||
Result.FImageInfo.Addr:=Result.Z_READ_ADDR;
|
||||
|
||||
|
@ -1317,20 +1307,24 @@ end;
|
|||
Function TGPU_REGS.GET_RASTERIZATION:TVkPipelineRasterizationStateCreateInfo;
|
||||
var
|
||||
SU_SC_MODE_CNTL:TPA_SU_SC_MODE_CNTL;
|
||||
PA_CL_CLIP_CNTL:TPA_CL_CLIP_CNTL;
|
||||
begin
|
||||
SU_SC_MODE_CNTL:=CX_REG^.PA_SU_SC_MODE_CNTL;
|
||||
PA_CL_CLIP_CNTL:=CX_REG^.PA_CL_CLIP_CNTL;
|
||||
|
||||
Result:=Default(TVkPipelineRasterizationStateCreateInfo);
|
||||
Result.sType:=VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
|
||||
if (SH_REG^.SPI_SHADER_PGM_LO_PS<>0) and
|
||||
if (SH_REG^.SPI_SHADER_PGM_LO_PS<>0) or
|
||||
(SH_REG^.SPI_SHADER_PGM_HI_PS.MEM_BASE<>0) then
|
||||
if (CX_REG^.DB_RENDER_CONTROL.DEPTH_CLEAR_ENABLE=0) and
|
||||
(CX_REG^.DB_RENDER_CONTROL.STENCIL_CLEAR_ENABLE=0) then
|
||||
begin
|
||||
Result.rasterizerDiscardEnable:=CX_REG^.DB_SHADER_CONTROL.KILL_ENABLE;
|
||||
Result.rasterizerDiscardEnable:=PA_CL_CLIP_CNTL.DX_RASTERIZATION_KILL;
|
||||
end;
|
||||
|
||||
//VkPhysicalDeviceDepthClampZeroOneFeaturesEXT::depthClampZeroOne
|
||||
Result.depthClampEnable :=CX_REG^.PA_CL_CLIP_CNTL.DX_CLIP_SPACE_DEF;
|
||||
Result.depthClampEnable :=PA_CL_CLIP_CNTL.ZCLIP_NEAR_DISABLE or PA_CL_CLIP_CNTL.ZCLIP_FAR_DISABLE;
|
||||
Result.polygonMode :=get_polygon_mode(SU_SC_MODE_CNTL);
|
||||
Result.cullMode :=get_cull_mode (SU_SC_MODE_CNTL);
|
||||
Result.frontFace :=TVkFrontFace (SU_SC_MODE_CNTL.FACE); //1:1
|
||||
|
@ -1363,23 +1357,28 @@ begin
|
|||
end;
|
||||
|
||||
Function TGPU_REGS.GET_MULTISAMPLE:TVkPipelineMultisampleStateCreateInfo;
|
||||
var
|
||||
ps_iter_samples,num_samples:Integer;
|
||||
begin
|
||||
Result:=Default(TVkPipelineMultisampleStateCreateInfo);
|
||||
Result.sType:=VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
|
||||
if (CX_REG^.PA_SC_MODE_CNTL_1.PS_ITER_SAMPLE<>0) then
|
||||
if (CX_REG^.DB_EQAA.PS_ITER_SAMPLES<>0) or
|
||||
(CX_REG^.PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES<>0) then
|
||||
begin
|
||||
ps_iter_samples:=1 shl CX_REG^.DB_EQAA.PS_ITER_SAMPLES;
|
||||
num_samples :=1 shl CX_REG^.PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES;
|
||||
|
||||
Result.sampleShadingEnable :=VK_TRUE;
|
||||
Result.rasterizationSamples :=TVkSampleCountFlagBits(1 shl CX_REG^.PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES);
|
||||
Result.minSampleShading :=0.5;
|
||||
Result.pSampleMask :=nil;
|
||||
Result.rasterizationSamples :=TVkSampleCountFlagBits(num_samples);
|
||||
Result.minSampleShading :=ps_iter_samples/num_samples;
|
||||
Result.pSampleMask :=nil; //TODO
|
||||
Result.alphaToCoverageEnable:=CX_REG^.DB_ALPHA_TO_MASK.ALPHA_TO_MASK_ENABLE;
|
||||
Result.alphaToOneEnable :=VK_FALSE;
|
||||
end else
|
||||
begin
|
||||
Result.rasterizationSamples:=VK_SAMPLE_COUNT_1_BIT;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function TGPU_REGS.GET_PRIM_RESET:TVkBool32;
|
||||
|
|
|
@ -292,6 +292,9 @@ begin
|
|||
GPU_REGS.CX_REG^.SPI_PS_INPUT_ENA);
|
||||
|
||||
SprvEmit.SetUserData(GPU_REGS.get_user_data(FStage));
|
||||
|
||||
SprvEmit.SET_PIX_CENTER (GPU_REGS.CX_REG^.PA_SU_VTX_CNTL.PIX_CENTER);
|
||||
SprvEmit.SET_SHADER_CONTROL(GPU_REGS.CX_REG^.DB_SHADER_CONTROL);
|
||||
end;
|
||||
vShaderStageVs:
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue