FPPS4/spirv/emit_vintrp.pas

108 lines
1.9 KiB
Plaintext
Raw Normal View History

2022-05-31 07:17:14 +00:00
unit emit_VINTRP;
{$mode objfpc}{$H+}
interface
uses
sysutils,
2022-09-05 13:30:24 +00:00
spirv,
2022-05-31 07:17:14 +00:00
ps4_pssl,
2022-09-05 13:30:24 +00:00
srType,
2022-05-31 07:17:14 +00:00
srInput,
srReg,
2022-09-05 13:30:24 +00:00
emit_fetch;
2022-05-31 07:17:14 +00:00
type
2022-09-05 13:30:24 +00:00
TEmit_VINTRP=class(TEmitFetch)
procedure emit_VINTRP;
2022-05-31 07:17:14 +00:00
end;
implementation
2022-09-05 13:30:24 +00:00
procedure TEmit_VINTRP.emit_VINTRP;
2022-05-31 07:17:14 +00:00
var
inp_M0:PsrInput;
src:PsrRegSlot;
dst:PsrRegSlot;
inp_SRC:PsrInput;
rsl:PsrRegNode;
begin
Assert(FExecutionModel=ExecutionModel.Fragment); //only pixel shader
2022-09-05 13:30:24 +00:00
dst:=get_vdst8(FSPI.VINTRP.VDST);
2022-05-31 07:17:14 +00:00
2022-09-05 13:30:24 +00:00
inp_M0:=GetInputRegNode(get_m0^.current);
2022-05-31 07:17:14 +00:00
Assert(inp_M0<>nil);
2022-09-05 13:30:24 +00:00
Assert(inp_M0^.itype=itPsState);
2022-05-31 07:17:14 +00:00
Case FSPI.VINTRP.OP of
V_INTERP_P1_F32:
begin
2022-09-05 13:30:24 +00:00
src:=get_vsrc8(FSPI.VINTRP.VSRC);
2022-05-31 07:17:14 +00:00
inp_SRC:=GetInputRegNode(src^.current);
Assert(inp_SRC<>nil);
2022-09-05 13:30:24 +00:00
Case inp_SRC^.itype of
2022-05-31 07:17:14 +00:00
itPerspSample,
itPerspCenter, //barycentrics with perspective interpolation
itPerspCentroid,
itLinearSample,
itLinearCenter,
itLinearCentroid:;
else
Assert(false);
end;
2022-09-05 13:30:24 +00:00
Assert(inp_SRC^.typeid=0); //I
2022-05-31 07:17:14 +00:00
2022-09-05 13:30:24 +00:00
rsl:=AddFragLayout(inp_SRC^.itype,dtVec4f,FSPI.VINTRP.ATTR);
2022-05-31 07:17:14 +00:00
dst^.New(line,dtFloat32);
2022-09-05 13:30:24 +00:00
OpExtract(line,dst^.current,rsl,FSPI.VINTRP.ATTRCHAN);
2022-05-31 07:17:14 +00:00
end;
V_INTERP_P2_F32:
begin
2022-09-05 13:30:24 +00:00
src:=get_vsrc8(FSPI.VINTRP.VSRC);
2022-05-31 07:17:14 +00:00
inp_SRC:=GetInputRegNode(src^.current);
Assert(inp_SRC<>nil);
2022-09-05 13:30:24 +00:00
Case inp_SRC^.itype of
2022-05-31 07:17:14 +00:00
itPerspSample,
itPerspCenter, //barycentrics with perspective interpolation
itPerspCentroid,
itLinearSample,
itLinearCenter,
itLinearCentroid:;
else
Assert(false);
end;
2022-09-05 13:30:24 +00:00
Assert(inp_SRC^.typeid=1); //J
2022-05-31 07:17:14 +00:00
2022-09-05 13:30:24 +00:00
rsl:=AddFragLayout(inp_SRC^.itype,dtVec4f,FSPI.VINTRP.ATTR);
2022-05-31 07:17:14 +00:00
dst^.New(line,dtFloat32);
2022-09-05 13:30:24 +00:00
OpExtract(line,dst^.current,rsl,FSPI.VINTRP.ATTRCHAN);
2022-05-31 07:17:14 +00:00
end;
else
Assert(False,'VINTRP?'+IntToStr(FSPI.VINTRP.OP));
end;
end;
end.