Hi together,
I'm currently working on a relaunch of the DX12 headers, since Free Pascal has made big improvements over the last 10 years

But I have now one problem with the UpdateSubresources for the Stack.
This ist the Microsoft Header snippet
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
template <UINT MaxSubresources>
inline UINT64 UpdateSubresources(
_In_ ID3D12GraphicsCommandList* pCmdList,
_In_ ID3D12Resource* pDestinationResource,
_In_ ID3D12Resource* pIntermediate,
UINT64 IntermediateOffset,
_In_range_(0,MaxSubresources) UINT FirstSubresource,
_In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources,
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept
This is my pascal definition:
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
generic function UpdateSubresources_Stack<const MaxSubresources: integer>(
{_In_ } pCmdList: ID3D12GraphicsCommandList;
{_In_ } pDestinationResource: ID3D12Resource;
{_In_ } pIntermediate: ID3D12Resource; IntermediateOffset: uint64;
{_In_range_(0,MaxSubresources) } FirstSubresource: UINT;
{_In_range_(1,MaxSubresources-FirstSubresource) } NumSubresources: UINT;
{_In_reads_(NumSubresources) } pSrcData: PD3D12_SUBRESOURCE_DATA_ARRAY): uint64;
and my pascal implementation
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
generic function UpdateSubresources_Stack<const MaxSubresources: integer>(pCmdList: ID3D12GraphicsCommandList; pDestinationResource: ID3D12Resource; pIntermediate: ID3D12Resource; IntermediateOffset: uint64; FirstSubresource: UINT;
NumSubresources: UINT; pSrcData: PD3D12_SUBRESOURCE_DATA_ARRAY): uint64;
var
RequiredSize: uint64 = 0;
Layouts: array [0..MaxSubresources-1] of TD3D12_PLACED_SUBRESOURCE_FOOTPRINT;
NumRows: array [0..MaxSubresources-1] of UINT;
RowSizesInBytes: array [0..MaxSubresources - 1] of uint64;
Desc: TD3D12_RESOURCE_DESC;
pDevice: ID3D12Device = nil;
begin
if ((NumSubresources + FirstSubresource) > MaxSubresources) then
begin
Result := 0;
Exit;
end;
pDestinationResource.GetDesc(@Desc);
pDestinationResource.GetDevice(@IID_ID3D12Device, pDevice);
pDevice.GetCopyableFootprints(@Desc, FirstSubresource, NumSubresources, IntermediateOffset, @Layouts[0], NumRows, RowSizesInBytes, @RequiredSize);
pDevice := nil;
Result := UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, @Layouts[0], @NumRows[0], @RowSizesInBytes[0], pSrcData);
end;
but the compiler (CT 8.8, FPC 3.3.1) fails with:
DX12.D3DX12_Resource_Helpers.pas(144,18) Error: Forward declaration not solved "UpdateSubresources_Stack$1(ID3D12GraphicsCommandList;ID3D12Resource;ID3D12Resource;QWord;LongWord;LongWord;PD3D12_SUBRESOURCE_DATA_ARRAY):System.QWord;"
the funny thing: commenting the declaration the headers will compile. so the code itselfs is working. just the declaration fails.
Why does the compiler complain? Any hints or ideas?
best regards
PS: for the Microsoft multithreading sample I've use the heap version at the moment, since the heap code is compiling. See attached screenshot.