This commit is contained in:
Pavel 2024-08-09 17:41:45 +03:00
parent 176c6b7128
commit 46a49261af
16 changed files with 612 additions and 150 deletions

View File

@ -549,6 +549,7 @@ begin
if (r<>VK_SUCCESS) then
begin
EndFrameCapture;
Assert(false,'QueueSubmit');
end;
@ -772,7 +773,7 @@ begin
begin
ri:=FetchImage(ctx.Cmd,
FImage,
{[iu_sampled]} resource_instance^.curr.img_usage
resource_instance^.curr.img_usage
);
resource_instance^.resource^.rimage:=ri;
@ -780,7 +781,7 @@ begin
//Writeln(ri.key.cformat);
pm4_load_from(ctx.Cmd,ri,TM_READ);
pm4_load_from(ctx.Cmd,ri,resource_instance^.curr.mem_usage);
ri.PushBarrier(ctx.Cmd,
GetAccessMask(resource_instance^.curr),
@ -798,6 +799,52 @@ begin
Result:=addr-(addr mod alignment);
end;
procedure BindMipStorage(var ctx:t_me_render_context;
fset,bind:TVkUInt32;
DescriptorGroup:TvDescriptorInterface;
ri:TvImage2;
const FView:TvImageViewKey;
Layout:TVkImageLayout);
var
i,p:Integer;
iv:TvImageView2;
aiv:array[0..15] of TVkImageView;
MView:TvImageViewKey;
begin
p:=0;
For i:=FView.base_array to FView.last_level do
begin
MView:=FView;
MView.last_level:=i;
//
iv:=ri.FetchView(ctx.Cmd,MView,iu_storage);
aiv[p]:=iv.FHandle;
//
Inc(p);
end;
//fill by 16?
while (p<16) do
begin
aiv[p]:=iv.FHandle;
//
Inc(p);
end;
//For i:=0 to p-1 do
//begin
// aiv[i]:=VK_NULL_HANDLE;
//end;
DescriptorGroup.BindStorages(fset,bind,
0,p,
@aiv[0],
Layout);
end;
procedure Bind_Uniforms(var ctx:t_me_render_context;
BindPoint:TVkPipelineBindPoint;
var UniformBuilder:TvUniformBuilder);
@ -836,19 +883,36 @@ begin
Assert(ri<>nil);
{
ri:=FetchImage(ctx.Cmd,
FImage,
[iu_sampled]
);
}
case btype of
vbSampled:
begin
iv:=ri.FetchView(ctx.Cmd,FView,iu_sampled);
iv:=ri.FetchView(ctx.Cmd,FView,iu_sampled);
DescriptorGroup.BindImage(fset,bind,
iv.FHandle,
GetImageLayout(resource_instance^.curr));
end;
vbStorage:
begin
iv:=ri.FetchView(ctx.Cmd,FView,iu_storage);
DescriptorGroup.BindImage(fset,bind,
iv.FHandle,
GetImageLayout(resource_instance^.curr));
DescriptorGroup.BindImage(fset,bind,
iv.FHandle,
GetImageLayout(resource_instance^.curr));
end;
vbMipStorage:
begin
BindMipStorage(ctx,
fset,bind,
DescriptorGroup,
ri,
FView,
GetImageLayout(resource_instance^.curr));
end;
else
Assert(false);
end;
end;
end;

View File

@ -1301,10 +1301,25 @@ begin
With UniformBuilder.FImages[i] do
begin
insert_image_resource(@node^.scope,
FImage,
TM_READ,
[iu_sampled]);
case btype of
vbSampled:
begin
insert_image_resource(@node^.scope,
FImage,
memuse,
[iu_sampled]);
end;
vbStorage,
vbMipStorage:
begin
insert_image_resource(@node^.scope,
FImage,
memuse,
[iu_storage]);
end;
else
Assert(false);
end;
end;
end;

View File

@ -117,6 +117,7 @@ begin
DecorateList.OpDecorate(node,Decoration.ArrayStride,node^.array_stride);
end;
//
if (node^.OpId=Op.OpTypeRuntimeArray) then
if (node^.is_array_image) then
begin
AddCapability(Capability.RuntimeDescriptorArray);

View File

@ -79,8 +79,10 @@ type
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);
function AddPositionsInput(count:Byte):PsrVariable;
function AddParametersInput(id,count:Byte):PsrVariable;
function FetchUniformSimple(src:PsrDataLayout;pType:PsrType):PsrNode;
function FetchImage(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
function FetchImageArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo;array_count:DWORD):PsrNode;
function FetchImageRuntimeArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
function FetchSampler(src:PsrDataLayout):PsrNode;
function FetchOutput(etype:TpsslExportType;rtype:TsrDataType):PsrVariable;
@ -690,7 +692,19 @@ var
begin
t:=TypeList.FetchArray(TypeList.Fetch(dtVec4f),count);
i:=InputList.Fetch(t,itPosition,0);
i:=InputList.Fetch(t,itPositions,0);
Result:=i^.pVar;
end;
function TEmitFetch.AddParametersInput(id,count:Byte):PsrVariable;
var
i:PsrInput;
t:PsrType;
begin
t:=TypeList.FetchArray(TypeList.Fetch(dtVec4f),count);
i:=InputList.Fetch(t,itParameters,id);
Result:=i^.pVar;
end;
@ -722,6 +736,16 @@ begin
Result:=FetchUniformSimple(src,pType);
end;
function TEmitFetch.FetchImageArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo;array_count:DWORD):PsrNode;
var
pType:PsrType;
begin
pType:=TypeList.Fetch(dtype);
pType:=TypeList.FetchImage(pType,info);
pType:=TypeList.FetchArray(pType,array_count);
Result:=UniformList.Fetch(src,pType);
end;
function TEmitFetch.FetchImageRuntimeArray(src:PsrDataLayout;dtype:TsrDataType;info:TsrTypeImageInfo):PsrNode;
var
pType:PsrType;

View File

@ -1010,6 +1010,10 @@ begin
lod:=Gather_value(roffset,dtUint32);
lod:=OpAndTo(lod,15);
//lod:=NewReg_i(dtUint32,0);
//lod:=OpNonUniform(lod); TODO
//fetch image by index
@ -1163,7 +1167,9 @@ begin
IMAGE_STORE_MIP_PCK: //stored mip
begin
info.tinfo.Sampled:=2;
Tgrp:=FetchImageRuntimeArray(pLayout,info.dtype,info.tinfo);
//Tgrp:=FetchImageRuntimeArray(pLayout,info.dtype,info.tinfo);
Tgrp:=FetchImageArray(pLayout,info.dtype,info.tinfo,16);
PsrUniform(Tgrp)^.FMipArray:=True;
emit_image_store(Tgrp,@info);
end;

View File

@ -62,7 +62,8 @@ type
itSubgroupLocalInvocationId,
itPosition
itPositions,
itParameters
);
ntInput=class(ntDescriptor)
@ -313,11 +314,16 @@ begin
//
end;
itPosition:
itPositions:
begin
pDecorateList^.OpDecorate(pVar,Decoration.BuiltIn,BuiltIn.Position);
end;
itParameters:
begin
pDecorateList^.OpDecorate(pVar,Decoration.Location,node^.key.typeid);
end;
else
Assert(false,'AllocBinding:'+GetEnumName(TypeInfo(TpsslInputType),ord(node^.key.itype)));
end;

View File

@ -12,7 +12,6 @@ uses
srRefId,
srType,
srTypes,
srReg,
srLayout,
srVariable,
srCapability,
@ -74,6 +73,7 @@ type
FArrayChainList:TsrArrayChainList;
public
FEmit:TCustomEmit;
FMipArray:Boolean;
Procedure Init(Emit:TCustomEmit); inline;
function pReg:PsrRegUniform; inline;
function FetchArrayChain(pLine:Pointer;idx0:PsrNode):PsrArrayChain;
@ -269,10 +269,12 @@ begin
//
dtTypeSampler:Result:='uSmp'+IntToStr(FBinding);
//
dtTypeArray,
dtTypeRuntimeArray:
begin
pChild:=pType^.GetItem(0)^.AsType(ntType); //Image
if (pChild<>nil) then
if (pChild^.dtype=dtTypeImage) then
begin
image_info:=pChild^.image_info;
@ -329,10 +331,12 @@ begin
//
dtTypeSampler:Result:='US'; //VK_DESCRIPTOR_TYPE_SAMPLER
//
dtTypeArray,
dtTypeRuntimeArray:
begin
pChild:=pType^.GetItem(0)^.AsType(ntType); //Image
if (pChild<>nil) then
if (pChild^.dtype=dtTypeImage) then
begin
image_info:=pChild^.image_info;
@ -342,7 +346,11 @@ begin
Assert(false,'GetTypeChar');
end else
begin
Result:='R'+GetSampledTypeChar(image_info.Sampled);
Case FType^.dtype of
dtTypeArray :Result:='A'+GetSampledTypeChar(image_info.Sampled);
dtTypeRuntimeArray:Result:='R'+GetSampledTypeChar(image_info.Sampled);
else;
end;
end;
end;
@ -405,6 +413,10 @@ begin
begin
Result:=Char(ord(Result) or ord('2'));
end;
if (FMipArray) then
begin
Result:=Char(ord(Result) or ord('4'));
end;
end;
function TsrUniform.GetString:RawByteString;

View File

@ -23,6 +23,7 @@ type
// set bind
p_count:array[0..6] of Byte;
p_binds:array[0..6] of PVkWriteDescriptorSet;
P_bmaxd:array[0..6] of PByte;
//
p_change_any:Boolean;
p_change:array[0..6] of Boolean;
@ -35,6 +36,7 @@ type
procedure SetAllChange;
procedure BindBuffer (aSet,aBind:TVkUInt32;dtype:TVkDescriptorType;buffer:TVkBuffer;offset,range:TVkDeviceSize);
procedure BindImage (aSet,aBind:TVkUInt32;dtype:TVkDescriptorType;img:TVkImageView;aLayout:TVkImageLayout);
procedure BindImages (aSet,aBind,aElem,aCount:TVkUInt32;dtype:TVkDescriptorType;img:PVkImageView;aLayout:TVkImageLayout);
procedure BindSampler(aSet,aBind:TVkUInt32;smp:TVkSampler);
end;
@ -42,11 +44,12 @@ type
TvDescriptorInterface=object
FHandle:PvDescriptorCache;
Procedure BindBuffer (aSet,aBind:TVkUInt32;buffer:TVkBuffer;offset,range:TVkDeviceSize);
Procedure BindUniform(aSet,aBind:TVkUInt32;buffer:TVkBuffer;offset,range:TVkDeviceSize);
Procedure BindStorage(aSet,aBind:TVkUInt32;img:TVkImageView;Layout:TVkImageLayout);
Procedure BindImage (aSet,aBind:TVkUInt32;img:TVkImageView;Layout:TVkImageLayout);
Procedure BindSampler(aSet,aBind:TVkUInt32;smp:TVkSampler);
Procedure BindBuffer (aSet,aBind:TVkUInt32;buffer:TVkBuffer;offset,range:TVkDeviceSize);
Procedure BindUniform (aSet,aBind:TVkUInt32;buffer:TVkBuffer;offset,range:TVkDeviceSize);
Procedure BindStorage (aSet,aBind:TVkUInt32;img:TVkImageView;Layout:TVkImageLayout);
Procedure BindStorages(aSet,aBind,aElem,aCount:TVkUInt32;img:PVkImageView;Layout:TVkImageLayout);
Procedure BindImage (aSet,aBind:TVkUInt32;img:TVkImageView;Layout:TVkImageLayout);
Procedure BindSampler (aSet,aBind:TVkUInt32;smp:TVkSampler);
end;
TvDescriptorSet2=object
@ -238,6 +241,13 @@ begin
FHandle^.BindImage(aSet,aBind,VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,img,Layout);
end;
Procedure TvDescriptorInterface.BindStorages(aSet,aBind,aElem,aCount:TVkUInt32;img:PVkImageView;Layout:TVkImageLayout);
begin
if (FHandle=nil) then Exit;
FHandle^.BindImages(aSet,aBind,aElem,aCount,VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,img,Layout);
end;
Procedure TvDescriptorInterface.BindImage(aSet,aBind:TVkUInt32;img:TVkImageView;Layout:TVkImageLayout);
begin
if (FHandle=nil) then Exit;
@ -261,6 +271,7 @@ var
dwrite_count:Integer;
dimg_count :Integer;
dbuf_count :Integer;
dmax_count :Integer;
size :Integer;
base :Pointer;
ends :Pointer;
@ -304,8 +315,11 @@ begin
layout.FCounts[ord(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)]+
layout.FCounts[ord(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)];
dmax_count:=dwrite_count;
size:=SizeOf(TvDescriptorCache)+
dwrite_count*SizeOf(TVkWriteDescriptorSet)+
dmax_count *SizeOf(Byte)+
dimg_count *SizeOf(TVkDescriptorImageInfo)+
dbuf_count *SizeOf(TVkDescriptorBufferInfo);
@ -331,15 +345,18 @@ begin
Result^.p_count[i]:=Length(key.FBinds);
Result^.p_binds[i]:=AllocWrite(Length(key.FBinds));
Result^.P_bmaxd[i]:=AllocBase (Length(key.FBinds)*SizeOf(Byte));
For b:=0 to High(key.FBinds) do
with key.FBinds[b] do
begin
Result^.p_binds[i][b].sType :=VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
Result^.p_binds[i][b].dstBinding :=b;
Result^.p_binds[i][b].descriptorCount:=1;
Result^.p_binds[i][b].descriptorType :=descriptorType;
Result^.p_binds[i][binding].sType :=VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
Result^.p_binds[i][binding].dstBinding :=binding;
Result^.p_binds[i][binding].descriptorCount:=1; //initial
Result^.p_binds[i][binding].descriptorType :=descriptorType;
Result^.P_bmaxd[i][binding]:=descriptorCount; //max
case descriptorType of
VK_DESCRIPTOR_TYPE_SAMPLER,
@ -347,13 +364,13 @@ begin
VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
begin
Result^.p_binds[i][b].pImageInfo:=AllocBase(SizeOf(TVkDescriptorImageInfo));
Result^.p_binds[i][binding].pImageInfo:=AllocBase(SizeOf(TVkDescriptorImageInfo)*descriptorCount);
end;
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
begin
Result^.p_binds[i][b].pBufferInfo:=AllocBase(SizeOf(TVkDescriptorBufferInfo));
Result^.p_binds[i][binding].pBufferInfo:=AllocBase(SizeOf(TVkDescriptorBufferInfo)*descriptorCount);
end;
else;
@ -452,6 +469,52 @@ begin
end;
end;
procedure TvDescriptorCache.BindImages(aSet,aBind,aElem,aCount:TVkUInt32;dtype:TVkDescriptorType;img:PVkImageView;aLayout:TVkImageLayout);
var
dwrite:PVkWriteDescriptorSet;
dimg :PVkDescriptorImageInfo;
i :TVkUInt32;
change:Boolean;
begin
Assert(aSet<7);
Assert(aBind<p_count[aSet]);
Assert(aCount>0);
Assert(p_binds[aSet]<>nil);
dwrite:=@p_binds[aSet][aBind];
Assert(dwrite^.descriptorType=dtype);
Assert((aElem+aCount)<=P_bmaxd[aSet][aBind]);
dimg:=dwrite^.pImageInfo;
Assert(dimg<>nil);
change:=False;
change:=change or (dwrite^.dstArrayElement<>aElem );
change:=change or (dwrite^.descriptorCount<>aCount);
dwrite^.dstArrayElement:=aElem;
dwrite^.descriptorCount:=aCount;
For i:=0 to aCount-1 do
begin
change:=change or (dimg[i].imageView <>img[i] );
change:=change or (dimg[i].imageLayout<>aLayout);
dimg[i].imageView :=img[i];
dimg[i].imageLayout:=aLayout;
end;
if change then
begin
p_change_any:=True;
p_change[aSet]:=True;
end;
end;
procedure TvDescriptorCache.BindSampler(aSet,aBind:TVkUInt32;smp:TVkSampler);
var
dwrite:PVkWriteDescriptorSet;

View File

@ -22,12 +22,6 @@ type
FCFamilyCount:TVkUInt32;
FTFamilyCount:TVkUInt32;
//
FDeviceFeature:TVkPhysicalDeviceFeatures;
F16_8:TVkPhysicalDeviceShaderFloat16Int8Features;
FSF_8:TVkPhysicalDevice8BitStorageFeatures;
FSF16:TVkPhysicalDevice16BitStorageFeatures;
FSFRF:TVkPhysicalDeviceRobustness2FeaturesEXT;
//
Constructor Create(debug,printf,validate:Boolean);
Destructor Destroy; override;
Procedure LoadFamily; virtual;
@ -260,6 +254,7 @@ var
VK_KHR_imageless_framebuffer :Boolean;
VK_EXT_provoking_vertex :Boolean;
VK_KHR_image_format_list :Boolean;
VK_EXT_descriptor_indexing :Boolean;
VK_KHR_shader_float16_int8 :Boolean;
VK_KHR_16bit_storage :Boolean;
@ -273,6 +268,26 @@ var
VK_AMD_device_coherent_memory :Boolean;
DeviceFeature:TVkPhysicalDeviceFeatures;
shaderFloat16:TVkBool32;
shaderInt8 :TVkBool32;
storageBuffer8BitAccess :TVkBool32;
uniformAndStorageBuffer8BitAccess:TVkBool32;
storagePushConstant8 :TVkBool32;
storageBuffer16BitAccess :TVkBool32;
uniformAndStorageBuffer16BitAccess:TVkBool32;
storagePushConstant16 :TVkBool32;
storageInputOutput16 :TVkBool32;
robustBufferAccess2:TVkBool32;
robustImageAccess2 :TVkBool32;
nullDescriptor :TVkBool32;
DescriptorIndexingFeatures:TVkPhysicalDeviceDescriptorIndexingFeatures;
maxUniformBufferRange:TVkUInt32;
maxStorageBufferRange:TVkUInt32;
maxPushConstantsSize :TVkUInt32;
@ -308,72 +323,72 @@ uses
function shaderStorageImageExtendedFormats:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.shaderStorageImageExtendedFormats);
Result:=Boolean(limits.DeviceFeature.shaderStorageImageExtendedFormats);
end;
function shaderStorageImageReadWithoutFormat:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.shaderStorageImageReadWithoutFormat);
Result:=Boolean(limits.DeviceFeature.shaderStorageImageReadWithoutFormat);
end;
function shaderStorageImageWriteWithoutFormat:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.shaderStorageImageWriteWithoutFormat);
Result:=Boolean(limits.DeviceFeature.shaderStorageImageWriteWithoutFormat);
end;
function shaderInt64:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.shaderInt64);
Result:=Boolean(limits.DeviceFeature.shaderInt64);
end;
function shaderInt16:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.shaderInt16);
Result:=Boolean(limits.DeviceFeature.shaderInt16);
end;
function shaderInt8:Boolean;
begin
Result:=Boolean(VulkanApp.F16_8.shaderInt8);
Result:=Boolean(limits.shaderInt8);
end;
function shaderFloat16:Boolean;
begin
Result:=Boolean(VulkanApp.F16_8.shaderFloat16);
Result:=Boolean(limits.shaderFloat16);
end;
function storageBuffer8Bit:Boolean;
begin
Result:=Boolean(VulkanApp.FSF_8.storageBuffer8BitAccess);
Result:=Boolean(limits.storageBuffer8BitAccess);
end;
function uniformBuffer8Bit:Boolean;
begin
Result:=Boolean(VulkanApp.FSF_8.uniformAndStorageBuffer8BitAccess);
Result:=Boolean(limits.uniformAndStorageBuffer8BitAccess);
end;
function storageBuffer16Bit:Boolean;
begin
Result:=Boolean(VulkanApp.FSF16.storageBuffer16BitAccess);
Result:=Boolean(limits.storageBuffer16BitAccess);
end;
function uniformBuffer16Bit:Boolean;
begin
Result:=Boolean(VulkanApp.FSF16.uniformAndStorageBuffer16BitAccess);
Result:=Boolean(limits.uniformAndStorageBuffer16BitAccess);
end;
function storageInputOutput16:Boolean;
begin
Result:=Boolean(VulkanApp.FSF16.storageInputOutput16);
Result:=Boolean(limits.storageInputOutput16);
end;
function sparseBinding:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.sparseBinding);
Result:=Boolean(limits.DeviceFeature.sparseBinding);
end;
function sparseResidencyAliased:Boolean;
begin
Result:=Boolean(VulkanApp.FDeviceFeature.sparseResidencyAliased);
Result:=Boolean(limits.DeviceFeature.sparseResidencyAliased);
end;
procedure FillDeviceProperties(physicalDevice:TVkPhysicalDevice);
@ -439,6 +454,7 @@ begin
VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME :limits.VK_KHR_imageless_framebuffer :=True;
VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME :limits.VK_EXT_provoking_vertex :=True;
VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME :limits.VK_KHR_image_format_list :=True;
VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME :limits.VK_EXT_descriptor_indexing :=True;
VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME :limits.VK_KHR_shader_float16_int8 :=True;
VK_KHR_16BIT_STORAGE_EXTENSION_NAME :limits.VK_KHR_16bit_storage :=True;
@ -805,6 +821,11 @@ var
vkPrintf :TVkValidationFeaturesEXT;
vkFeature:TVkValidationFeatureEnableEXT;
Features2:TVkPhysicalDeviceFeatures2;
F16_8 :TVkPhysicalDeviceShaderFloat16Int8Features;
FSF_8 :TVkPhysicalDevice8BitStorageFeatures;
FSF16 :TVkPhysicalDevice16BitStorageFeatures;
FRF :TVkPhysicalDeviceRobustness2FeaturesEXT;
FDI :TVkPhysicalDeviceDescriptorIndexingFeatures;
r:TVkResult;
begin
vkApp:=Default(TVkApplicationInfo);
@ -870,11 +891,12 @@ begin
halt;
end;
FDeviceFeature:=Default(TVkPhysicalDeviceFeatures);
limits.DeviceFeature:=Default(TVkPhysicalDeviceFeatures);
F16_8:=Default(TVkPhysicalDeviceShaderFloat16Int8Features);
FSF_8:=Default(TVkPhysicalDevice8BitStorageFeatures);
FSF16:=Default(TVkPhysicalDevice16BitStorageFeatures);
FSFRF:=Default(TVkPhysicalDeviceRobustness2FeaturesEXT);
FRF :=Default(TVkPhysicalDeviceRobustness2FeaturesEXT);
FDI :=Default(TVkPhysicalDeviceDescriptorIndexingFeatures);
if (vkGetPhysicalDeviceFeatures2<>nil) then
begin
@ -890,19 +912,40 @@ begin
FSF_8.pNext:=@FSF16;
FSF16.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
FSF16.pNext:=@FSFRF;
FSF16.pNext:=@FRF;
FSFRF.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT;
FRF.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT;
FRF.pNext:=@FDI;
FDI.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
vkGetPhysicalDeviceFeatures2(FPhysicalDevice,@Features2);
FDeviceFeature:=Features2.features;
limits.DeviceFeature:=Features2.features;
end else
begin
vkGetPhysicalDeviceFeatures(FPhysicalDevice,@FDeviceFeature);
vkGetPhysicalDeviceFeatures(FPhysicalDevice,@limits.DeviceFeature);
end;
limits.shaderFloat16 :=F16_8.shaderFloat16;
limits.shaderInt8 :=F16_8.shaderInt8;
limits.storageBuffer8BitAccess :=FSF_8.storageBuffer8BitAccess;
limits.uniformAndStorageBuffer8BitAccess :=FSF_8.uniformAndStorageBuffer8BitAccess;
limits.storagePushConstant8 :=FSF_8.storagePushConstant8;
limits.storageBuffer16BitAccess :=FSF16.storageBuffer16BitAccess;
limits.uniformAndStorageBuffer16BitAccess:=FSF16.uniformAndStorageBuffer16BitAccess;
limits.storagePushConstant16 :=FSF16.storagePushConstant16;
limits.storageInputOutput16 :=FSF16.storageInputOutput16;
limits.robustBufferAccess2 :=FRF.robustBufferAccess2;
limits.robustImageAccess2 :=FRF.robustImageAccess2;
limits.nullDescriptor :=FRF.nullDescriptor;
FDI.pNext:=nil;
limits.DescriptorIndexingFeatures :=FDI;
LoadFamily;
end;
@ -1222,7 +1265,7 @@ Var
begin
System.InitCriticalSection(FLock);
DeviceFeature:=VulkanApp.FDeviceFeature;
DeviceFeature:=limits.DeviceFeature;
DeviceFeature.robustBufferAccess:=VK_FALSE;
DeviceInfo:=Default(TVkDeviceCreateInfo);
@ -1710,7 +1753,8 @@ var
F16_8:TVkPhysicalDeviceShaderFloat16Int8Features;
FSF_8:TVkPhysicalDevice8BitStorageFeatures;
FSF16:TVkPhysicalDevice16BitStorageFeatures;
FSFRF:TVkPhysicalDeviceRobustness2FeaturesEXT;
FRF :TVkPhysicalDeviceRobustness2FeaturesEXT;
FDI :TVkPhysicalDeviceDescriptorIndexingFeatures;
FIVML:TVkPhysicalDeviceImageViewMinLodFeaturesEXT;
FScalar:TVkPhysicalDeviceScalarBlockLayoutFeatures;
@ -1813,7 +1857,17 @@ begin
if limits.VK_KHR_image_format_list then
begin
DeviceInfo.add_ext(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
DeviceInfo.add_ext(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
end;
if limits.VK_EXT_descriptor_indexing then
begin
DeviceInfo.add_ext(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
FDI:=limits.DescriptorIndexingFeatures;
FDI.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
DeviceInfo.add_feature(@FDI);
end;
//if limits.VK_KHR_push_descriptor then
@ -1842,13 +1896,13 @@ begin
DeviceInfo.add_ext(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME);
end;
if (VulkanApp.F16_8.shaderInt8<>0) or
(VulkanApp.F16_8.shaderFloat16<>0) then
if (limits.shaderInt8<>0) or
(limits.shaderFloat16<>0) then
begin
F16_8:=Default(TVkPhysicalDeviceShaderFloat16Int8Features);
F16_8.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES;
F16_8.shaderFloat16:=VulkanApp.F16_8.shaderFloat16;
F16_8.shaderInt8 :=VulkanApp.F16_8.shaderInt8;
F16_8.shaderFloat16:=limits.shaderFloat16;
F16_8.shaderInt8 :=limits.shaderInt8;
DeviceInfo.add_feature(@F16_8);
end;
@ -1858,14 +1912,14 @@ begin
DeviceInfo.add_ext(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
end;
if (VulkanApp.FSF_8.storageBuffer8BitAccess<>0) or
(VulkanApp.FSF_8.uniformAndStorageBuffer8BitAccess<>0) then
if (limits.storageBuffer8BitAccess<>0) or
(limits.uniformAndStorageBuffer8BitAccess<>0) then
begin
FSF_8:=Default(TVkPhysicalDevice8BitStorageFeaturesKHR);
FSF_8.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
FSF_8.storageBuffer8BitAccess :=VulkanApp.FSF_8.storageBuffer8BitAccess;
FSF_8.uniformAndStorageBuffer8BitAccess:=VulkanApp.FSF_8.uniformAndStorageBuffer8BitAccess;
//FSF_8.storagePushConstant8
FSF_8.storageBuffer8BitAccess :=limits.storageBuffer8BitAccess;
FSF_8.uniformAndStorageBuffer8BitAccess:=limits.uniformAndStorageBuffer8BitAccess;
//limits.storagePushConstant8
DeviceInfo.add_feature(@FSF_8);
end;
@ -1875,16 +1929,16 @@ begin
DeviceInfo.add_ext(VK_KHR_16BIT_STORAGE_EXTENSION_NAME);
end;
if (VulkanApp.FSF16.storageBuffer16BitAccess<>0) or
(VulkanApp.FSF16.uniformAndStorageBuffer16BitAccess<>0) or
(VulkanApp.FSF16.storageInputOutput16<>0) then
if (limits.storageBuffer16BitAccess<>0) or
(limits.uniformAndStorageBuffer16BitAccess<>0) or
(limits.storageInputOutput16<>0) then
begin
FSF16:=Default(TVkPhysicalDevice16BitStorageFeatures);
FSF16.sType:=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
FSF16.storageBuffer16BitAccess :=VulkanApp.FSF16.storageBuffer16BitAccess;
FSF16.uniformAndStorageBuffer16BitAccess:=VulkanApp.FSF16.uniformAndStorageBuffer16BitAccess;
FSF16.storageBuffer16BitAccess :=limits.storageBuffer16BitAccess;
FSF16.uniformAndStorageBuffer16BitAccess:=limits.uniformAndStorageBuffer16BitAccess;
//FSF16.storagePushConstant16
FSF16.storageInputOutput16 :=VulkanApp.FSF16.storageInputOutput16;
FSF16.storageInputOutput16 :=limits.storageInputOutput16;
DeviceInfo.add_feature(@FSF16);
end;
@ -1893,11 +1947,11 @@ begin
begin
DeviceInfo.add_ext(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME);
FSFRF:=Default(TVkPhysicalDeviceRobustness2FeaturesEXT);
FSFRF.sType :=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT;
FSFRF.nullDescriptor:=VulkanApp.FSFRF.nullDescriptor;
FRF:=Default(TVkPhysicalDeviceRobustness2FeaturesEXT);
FRF.sType :=VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT;
FRF.nullDescriptor:=limits.nullDescriptor;
DeviceInfo.add_feature(@FSFRF);
DeviceInfo.add_feature(@FRF);
end;
if limits.VK_EXT_image_view_min_lod then

View File

@ -1023,20 +1023,23 @@ begin
end;
end;
//VK_IMAGE_USAGE_STORAGE_BIT
const
VK_IMAGE_USAGE_DEFAULT=
VK_IMAGE_USAGE_=
ord(VK_IMAGE_USAGE_TRANSFER_SRC_BIT) or
ord(VK_IMAGE_USAGE_TRANSFER_DST_BIT) or
ord(VK_IMAGE_USAGE_SAMPLED_BIT);
VK_IMAGE_USAGE_DEFAULT=
VK_IMAGE_USAGE_ or
ord(VK_IMAGE_USAGE_STORAGE_BIT);
VK_IMAGE_USAGE_DEFAULT_COLOR=
VK_IMAGE_USAGE_DEFAULT or
VK_IMAGE_USAGE_ or
ord(VK_IMAGE_USAGE_STORAGE_BIT) or
ord(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
VK_IMAGE_USAGE_DEFAULT_DEPTH=
(VK_IMAGE_USAGE_DEFAULT {and (not ord(VK_IMAGE_USAGE_SAMPLED_BIT))}) or
VK_IMAGE_USAGE_ or
ord(VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
function GET_VK_IMAGE_USAGE_DEFAULT(cformat:TVkFormat):TVkFlags;

View File

@ -617,7 +617,7 @@ begin
iu_storage:
begin
//Separate storage access for special cases?
fkey.cformat:=GET_VK_FORMAT_STORAGE(fkey.cformat);
//fkey.cformat:=GET_VK_FORMAT_STORAGE(fkey.cformat);
fusage:=ord(VK_IMAGE_USAGE_STORAGE_BIT);
end;
else
@ -690,7 +690,7 @@ begin
iu_storage:
begin
//Separate storage access for special cases?
fkey.cformat:=GET_VK_FORMAT_STORAGE(fkey.cformat);
//fkey.cformat:=GET_VK_FORMAT_STORAGE(fkey.cformat);
fusage:=ord(VK_IMAGE_USAGE_STORAGE_BIT);
end;
else

View File

@ -116,7 +116,11 @@ end;
function TvSetLayout.Compile:Boolean;
var
cinfo:TVkDescriptorSetLayoutCreateInfo;
binfo:TVkDescriptorSetLayoutBindingFlagsCreateInfo;
bflag:array of TVkDescriptorBindingFlags;
r:TVkResult;
i,c:Integer;
partially:Boolean;
begin
Result:=False;
@ -126,10 +130,50 @@ begin
cinfo.sType:=VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
cinfo.flags:=key.FFlags;
cinfo.bindingCount:=Length(key.FBinds);
//
if (cinfo.bindingCount<>0) then
begin
cinfo.pBindings:=@key.FBinds[0];
end;
//
{
if (limits.DescriptorIndexingFeatures.descriptorBindingPartiallyBound<>0) then
begin
partially:=False;
c:=Length(key.FBinds);
if (c<>0) then
begin
For i:=0 to c-1 do
if (key.FBinds[i].descriptorCount>1) then
begin
partially:=True;
Break;
end;
end;
//
if partially then
begin
SetLength(bflag,c);
For i:=0 to c-1 do
begin
bflag[i]:=0;
if (key.FBinds[i].descriptorCount>1) then
begin
bflag[i]:=ord(VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT) or
ord(VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT);
end;
end;
//
binfo:=Default(TVkDescriptorSetLayoutBindingFlagsCreateInfo);
binfo.sType:=VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO;
binfo.bindingCount :=c;
binfo.pBindingFlags:=@bflag[0];
//
cinfo.pNext:=@binfo;
end;
end;
}
//
r:=vkCreateDescriptorSetLayout(Device.FHandle,@cinfo,nil,@FHandle);
if (r<>VK_SUCCESS) then
begin

View File

@ -44,36 +44,62 @@ begin
Result:=SprvEmit.OpFAddTo(Result,tmp[2]);
end;
type
TINPUT_INFO=packed record
LAYOUT_ID :Byte;
FLAT_SHADE :Boolean;
end;
//source: [amdilc_rect_gs_compiler.c]
function CompileRectangleGeometryShader(var GPU_REGS:TGPU_REGS):TMemoryStream;
var
INPUT_INFO :array[0..31] of TINPUT_INFO;
INPUT_COUNT:Byte;
//
SprvEmit:TSprvEmit;
//
pVec4f :PsrType;
InputPos :PsrVariable;
OutputPos :PsrVariable;
pChain :PsrNode;
UintId :array[0..3] of PsrRegNode;
Positions :array[0..3] of PsrRegNode;
positionsX :array[0..2] of PsrRegNode;
positionsY :array[0..2] of PsrRegNode;
CoordEqualX:array[0..2] of PsrRegNode;
CoordEqualY:array[0..2] of PsrRegNode;
EdgeVertex :array[0..2] of PsrRegNode;
barycentric:array[0..2] of PsrRegNode;
xyEqual :PsrRegNode;
yxEqual :PsrRegNode;
pOneId :PsrRegNode;
pMinusOne :PsrRegNode;
pIndex :PsrRegNode;
pVec4f :PsrType;
InputPos :PsrVariable;
OutputPos :PsrVariable;
InputParams :array[0..31] of PsrVariable;
OutputParams:array[0..31] of PsrVariable;
//
i:Byte;
pChain :PsrNode;
UintId :array[0..3] of PsrRegNode;
Positions :array[0..3] of PsrRegNode;
positionsX :array[0..2] of PsrRegNode;
positionsY :array[0..2] of PsrRegNode;
CoordEqualX :array[0..2] of PsrRegNode;
CoordEqualY :array[0..2] of PsrRegNode;
EdgeVertex :array[0..2] of PsrRegNode;
barycentric :array[0..2] of PsrRegNode;
Parameters :array[0..2] of PsrRegNode;
xyEqual :PsrRegNode;
yxEqual :PsrRegNode;
pOneId :PsrRegNode;
pMinusOne :PsrRegNode;
pIndex :PsrRegNode;
pLoaded :PsrRegNode;
//
i,a:Byte;
begin
Result:=nil;
if (GPU_REGS.CX_REG^.SPI_PS_IN_CONTROL.NUM_INTERP>0) then
INPUT_COUNT:=GPU_REGS.CX_REG^.SPI_PS_IN_CONTROL.NUM_INTERP;
if (INPUT_COUNT<>0) then
begin
Assert(false,'TODO:input attr');
a:=0;
for i:=0 to INPUT_COUNT-1 do
//if not default
if ((GPU_REGS.CX_REG^.SPI_PS_INPUT_CNTL[i].OFFSET shr 5)=0) then
begin
INPUT_INFO[a].LAYOUT_ID :=(GPU_REGS.CX_REG^.SPI_PS_INPUT_CNTL[i].OFFSET and 31);
INPUT_INFO[a].FLAT_SHADE:=(GPU_REGS.CX_REG^.SPI_PS_INPUT_CNTL[i].FLAT_SHADE)<>0;
//
Inc(a);
end;
//update count
INPUT_COUNT:=a;
end;
SprvEmit:=TSprvEmit.Create;
@ -82,9 +108,20 @@ begin
pVec4f :=SprvEmit.TypeList.Fetch(dtVec4f);
//postion i/o
InputPos :=SprvEmit.AddPositionsInput(3);
OutputPos:=SprvEmit.FetchOutput(etPos0,dtVec4f);
//input param i/o
if (INPUT_COUNT<>0) then
begin
for a:=0 to INPUT_COUNT-1 do
begin
InputParams [a]:=SprvEmit.AddParametersInput(INPUT_INFO[a].LAYOUT_ID,3);
OutputParams[a]:=SprvEmit.FetchOutput(TpsslExportType(ord(etParam0)+INPUT_INFO[a].LAYOUT_ID),dtVec4f);
end;
end;
//gen const id
For i:=0 to 3 do
begin
@ -143,14 +180,28 @@ begin
//Send vertex by index
For i:=0 to 2 do
begin
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputPos,pIndex);
//
Positions[i]:=SprvEmit.OpLoadTo(pVec4f,pChain);
//
SprvEmit.OpStore(SprvEmit.line,OutputPos,Positions[i]);
pChain :=SprvEmit.OpAccessChainTo(pVec4f,InputPos,pIndex);
pLoaded:=SprvEmit.OpLoadTo(pVec4f,pChain);
SprvEmit.OpStore(SprvEmit.line,OutputPos,pLoaded);
//emit input attr
if (INPUT_COUNT<>0) then
begin
for a:=0 to INPUT_COUNT-1 do
begin
if INPUT_INFO[a].FLAT_SHADE then
begin
//get first
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputParams[a],UintId[0]);
end else
begin
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputParams[a],pIndex);
end;
pLoaded:=SprvEmit.OpLoadTo(pVec4f,pChain);
SprvEmit.OpStore(SprvEmit.line,OutputParams[a],pLoaded);
end;
end;
//end vertex
SprvEmit.OpEmitVertex(SprvEmit.line);
@ -167,6 +218,32 @@ begin
SprvEmit.OpStore(SprvEmit.line,OutputPos,Positions[3]);
//emit input attr
if (INPUT_COUNT<>0) then
begin
for a:=0 to INPUT_COUNT-1 do
begin
if INPUT_INFO[a].FLAT_SHADE then
begin
//get first
pChain :=SprvEmit.OpAccessChainTo(pVec4f,InputParams[a],UintId[0]);
pLoaded:=SprvEmit.OpLoadTo(pVec4f,pChain);
end else
begin
//load parameters
For i:=0 to 2 do
begin
pChain:=SprvEmit.OpAccessChainTo(pVec4f,InputParams[a],UintId[i]);
//
Parameters[i]:=SprvEmit.OpLoadTo(pVec4f,pChain);
end;
//calc last parameter
pLoaded:=interpolate(SprvEmit,dtVec4f,@barycentric,@Parameters);
end;
SprvEmit.OpStore(SprvEmit.line,OutputParams[a],pLoaded);
end;
end;
//end vertex
SprvEmit.OpEmitVertex(SprvEmit.line);

View File

@ -111,6 +111,7 @@ begin
ainfo.descriptorPool :=FHandle;
ainfo.descriptorSetCount:=1;
ainfo.pSetLayouts :=@L.FHandle;
//VkDescriptorSetVariableDescriptorCountAllocateInfo -> RuntimeArray
r:=vkAllocateDescriptorSets(Device.FHandle,@ainfo,@FResult);
if (r<>VK_SUCCESS) then
begin

View File

@ -42,12 +42,14 @@ type
TvFuncCb=procedure(addr:ADataLayout) of object;
TvLayoutFlags=Set of (vMemoryRead,vMemoryWrite,vMipArray);
TvCustomLayout=packed record
dtype :DWORD;
bind :DWORD;
size :DWORD;
offset:DWORD;
flags :DWORD;
flags :TvLayoutFlags;
addr :ADataLayout;
end;
@ -76,6 +78,7 @@ type
procedure OnTexlLayout(P:PChar);
procedure OnImgsLayout(P:PChar);
procedure OnRuntLayout(P:PChar);
procedure OnArrsLayout(P:PChar);
procedure OnFuncLayout(P:PChar);
end;
@ -167,9 +170,13 @@ type
size :TVkUInt32;
end;
TvBindImageType=(vbSampled,vbStorage,vbMipStorage);
TImageBindExt=packed record
fset:TVkUInt32;
bind:TVkUInt32;
btype :TvBindImageType;
fset :TVkUInt32;
bind :TVkUInt32;
memuse:TVkUInt32;
FImage:TvImageKey;
FView :TvImageViewKey;
@ -187,11 +194,11 @@ type
FImages :array of TImageBindExt;
FSamplers:array of TSamplerBindExt;
Procedure AddVSharp(PV:PVSharpResource4;fset,bind,offset,flags:DWord);
Procedure AddBufPtr(P:Pointer;fset,size,bind,offset,flags:DWord);
Procedure AddVSharp(PV:PVSharpResource4;fset,bind,offset:DWord;flags:TvLayoutFlags);
Procedure AddBufPtr(P:Pointer;fset,size,bind,offset:DWord;flags:TvLayoutFlags);
Procedure AddTSharp4(PT:PTSharpResource4;fset,bind:DWord);
Procedure AddTSharp8(PT:PTSharpResource8;fset,bind:DWord);
Procedure AddTSharp4(PT:PTSharpResource4;btype:TvBindImageType;fset,bind:DWord;flags:TvLayoutFlags);
Procedure AddTSharp8(PT:PTSharpResource8;btype:TvBindImageType;fset,bind:DWord;flags:TvLayoutFlags);
Procedure AddSSharp4(PS:PSSharpResource4;fset,bind:DWord);
procedure AddAttr (const b:TvCustomLayout;Fset:TVkUInt32;pUserData,pImmData:PDWORD);
end;
@ -361,22 +368,40 @@ end;
procedure TvShaderExt.InitSetLayout;
var
i:Integer;
i,p:Integer;
descriptorCount:TVkUInt32;
A:AVkDescriptorSetLayoutBinding;
begin
if (FSetLayout<>nil) then Exit;
A:=Default(AVkDescriptorSetLayoutBinding);
SetLength(A,Length(FUnifLayouts)); //++ other todo
//++ other todo
SetLength(A,
Length(FUnifLayouts)
);
p:=0;
if (Length(FUnifLayouts)<>0) then
begin
For i:=0 to High(FUnifLayouts) do
begin
A[i]:=Default(TVkDescriptorSetLayoutBinding);
A[i].binding :=FUnifLayouts[i].bind;
A[i].descriptorType :=TVkDescriptorType(FUnifLayouts[i].dtype);
A[i].descriptorCount:=1;
A[i].stageFlags :=ord(FStage);
if (vMipArray in FUnifLayouts[i].flags) then
begin
descriptorCount:=16;
end else
begin
descriptorCount:=1;
end;
//
A[p]:=Default(TVkDescriptorSetLayoutBinding);
A[p].binding :=FUnifLayouts[i].bind;
A[p].descriptorType :=TVkDescriptorType(FUnifLayouts[i].dtype);
A[p].descriptorCount:=descriptorCount;
A[p].stageFlags :=ord(FStage);
//
Inc(p);
end;
end;
FSetLayout:=FetchSetLayout(ord(FStage),0,A);
end;
@ -456,6 +481,7 @@ begin
'U':OnUnifLayout(P);
'T':OnTexlLayout(P);
'I':OnImgsLayout(P);
'A':OnArrsLayout(P);
'R':OnRuntLayout(P);
'F':OnFuncLayout(P);
else
@ -587,7 +613,7 @@ begin
v.bind :=bind;
v.size :=size;
v.offset:=offset;
v.flags :=flags;
v.flags :=TvLayoutFlags(flags);
v.addr :=GetLayoutAddr(parent);
AddToCustomLayout(FUnifLayouts,v);
@ -650,7 +676,7 @@ begin
v:=Default(TvCustomLayout);
v.dtype:=ord(dtype);
v.bind :=bind;
v.flags:=flags;
v.flags:=TvLayoutFlags(flags);
v.addr :=GetLayoutAddr(parent);
AddToCustomLayout(FUnifLayouts,v);
@ -694,7 +720,28 @@ end;
procedure TvShaderParserExt.OnRuntLayout(P:PChar);
begin
Assert(false,'TODO: OnRuntLayout:"'+P[1]+'"');
with TvShaderExt(FOwner) do
Case P[1] of
'S':AddUnifLayout(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
_get_hex_dword(@P[7]),
_get_hex_dword(@P[$14]),
_get_hex_char (@P[$21]));
else
Assert(false,'TODO: OnRuntLayout:"'+P[1]+'"');
end;
end;
procedure TvShaderParserExt.OnArrsLayout(P:PChar);
begin
with TvShaderExt(FOwner) do
Case P[1] of
'S':AddUnifLayout(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
_get_hex_dword(@P[7]),
_get_hex_dword(@P[$14]),
_get_hex_char (@P[$21]));
else
Assert(false,'TODO: OnArrsLayout:"'+P[1]+'"');
end;
end;
Procedure TvShaderExt.EnumUnifLayout(cb:TvCustomLayoutCb;Fset:TVkUInt32;pUserData,pImmData:PDWORD);
@ -1137,13 +1184,13 @@ end;
//
function _get_buf_mem_usage(b:Byte):Byte; inline;
function _get_buf_mem_usage(flags:TvLayoutFlags):Byte; inline;
begin
Result:=((b and 1)*TM_READ) or
(((b shr 1) and 1)*TM_WRITE);
Result:=(ord(vMemoryRead in flags)*TM_READ) or
(ord(vMemoryWrite in flags)*TM_WRITE);
end;
Procedure TvUniformBuilder.AddVSharp(PV:PVSharpResource4;fset,bind,offset,flags:DWord);
Procedure TvUniformBuilder.AddVSharp(PV:PVSharpResource4;fset,bind,offset:DWord;flags:TvLayoutFlags);
var
b:TBufBindExt;
i,stride,num_records:Integer;
@ -1172,7 +1219,7 @@ begin
FBuffers[i]:=b;
end;
Procedure TvUniformBuilder.AddBufPtr(P:Pointer;fset,size,bind,offset,flags:DWord);
Procedure TvUniformBuilder.AddBufPtr(P:Pointer;fset,size,bind,offset:DWord;flags:TvLayoutFlags);
var
b:TBufBindExt;
i:Integer;
@ -1194,7 +1241,7 @@ begin
FBuffers[i]:=b;
end;
Procedure TvUniformBuilder.AddTSharp4(PT:PTSharpResource4;fset,bind:DWord);
Procedure TvUniformBuilder.AddTSharp4(PT:PTSharpResource4;btype:TvBindImageType;fset,bind:DWord;flags:TvLayoutFlags);
var
b:TImageBindExt;
i:Integer;
@ -1205,8 +1252,10 @@ begin
//print_tsharp4(PT);
b:=Default(TImageBindExt);
b.fset:=fset;
b.bind:=bind;
b.btype :=btype;
b.fset :=fset;
b.bind :=bind;
b.memuse:=_get_buf_mem_usage(flags);
b.FImage:=_get_tsharp4_image_info(PT);
b.FView :=_get_tsharp4_image_view(PT);
@ -1216,7 +1265,7 @@ begin
FImages[i]:=b;
end;
Procedure TvUniformBuilder.AddTSharp8(PT:PTSharpResource8;fset,bind:DWord);
Procedure TvUniformBuilder.AddTSharp8(PT:PTSharpResource8;btype:TvBindImageType;fset,bind:DWord;flags:TvLayoutFlags);
var
b:TImageBindExt;
i:Integer;
@ -1227,8 +1276,10 @@ begin
//print_tsharp8(PT);
b:=Default(TImageBindExt);
b.fset:=fset;
b.bind:=bind;
b.btype :=btype;
b.fset :=fset;
b.bind :=bind;
b.memuse:=_get_buf_mem_usage(flags);
b.FImage:=_get_tsharp8_image_info(PT);
b.FView :=_get_tsharp8_image_view(PT);
@ -1251,15 +1302,36 @@ begin
Case b.addr[0].rtype of
vtSSharp4:AddSSharp4(P,fset,b.bind);
else
Assert(false);
Assert(false,'AddAttr');
end;
//
VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
Case b.addr[0].rtype of
vtTSharp4:AddTSharp4(P,fset,b.bind);
vtTSharp8:AddTSharp8(P,fset,b.bind);
vtTSharp4:AddTSharp4(P,vbSampled,fset,b.bind,b.flags);
vtTSharp8:AddTSharp8(P,vbSampled,fset,b.bind,b.flags);
else
Assert(false);
Assert(false,'AddAttr');
end;
//
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
if (vMipArray in b.flags) then
begin
Case b.addr[0].rtype of
vtTSharp4:AddTSharp4(P,vbMipStorage,fset,b.bind,b.flags);
vtTSharp8:AddTSharp8(P,vbMipStorage,fset,b.bind,b.flags);
else
Assert(false,'AddAttr');
end;
end else
begin
Case b.addr[0].rtype of
vtTSharp4:AddTSharp4(P,vbStorage,fset,b.bind,b.flags);
vtTSharp8:AddTSharp8(P,vbStorage,fset,b.bind,b.flags);
else
Assert(false,'AddAttr');
end;
end;
//
//VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER=4,
//VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER=5,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@ -1269,11 +1341,11 @@ begin
vtBufPtr2:AddBufPtr(P,Fset,b.size,b.bind,b.offset,b.flags);
vtVSharp4:AddVSharp(P,Fset,b.bind,b.offset,b.flags);
else
Assert(false);
Assert(false,'AddAttr');
end;
else
Assert(false);
Assert(false,'AddAttr');
end;
//Writeln('----');

View File

@ -701,9 +701,13 @@ end;
procedure EmitShaderGroupExtension(var GPU_REGS:TGPU_REGS;F:PvShadersKey);
Var
M:TMemoryStream;
PS:TvShaderExt;
VS:TvShaderExt;
GS:TvShaderExt;
begin
//
PS:=F^.FShaders[vShaderStagePs];
VS:=F^.FShaders[vShaderStageVs];
if (VS<>nil) and
@ -712,7 +716,15 @@ begin
begin
Assert(F^.FShaders[vShaderStageGs]=nil,'Geometry shader is already present');
GS:=VS.FGeomRectList;
//load cache
if (PS<>nil) then
begin
GS:=PS.FGeomRectList;
end else
begin
GS:=VS.FGeomRectList;
end;
//load cache
if (GS=nil) then
begin
@ -726,7 +738,15 @@ begin
M.Free;
VS.FGeomRectList:=GS;
//save cache
if (PS<>nil) then
begin
PS.FGeomRectList:=GS;
end else
begin
VS.FGeomRectList:=GS;
end;
//save cache
end;
F^.FShaders[vShaderStageGs]:=GS;