From a154ac64b11da044478f0341c692253ad30af336 Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Fri, 3 Jan 2025 04:14:19 +0300 Subject: [PATCH] + --- chip/pm4_me.pas | 4 ++-- spirv/srLayout.pas | 6 ++--- vulkan/vCmdBuffer.pas | 56 ++++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/chip/pm4_me.pas b/chip/pm4_me.pas index bc8282b9..975f1720 100644 --- a/chip/pm4_me.pas +++ b/chip/pm4_me.pas @@ -1968,7 +1968,7 @@ begin case node^.ntype of ntDrawIndex2: begin - ctx.Cmd.DrawIndex2(Pointer(node^.indexBase),node^.indexCount); + ctx.Cmd.DrawIndexOffset2(Pointer(node^.indexBase),node^.indexOffset,node^.indexCount); end; ntDrawIndexOffset2: begin @@ -1976,7 +1976,7 @@ begin end; ntDrawIndexAuto: begin - ctx.Cmd.DrawIndexAuto(node^.indexCount); + ctx.Cmd.DrawIndexAuto(node^.indexOffset,node^.indexCount); end; ntClearDepth: begin diff --git a/spirv/srLayout.pas b/spirv/srLayout.pas index ff9cffee..1497aa17 100644 --- a/spirv/srLayout.pas +++ b/spirv/srLayout.pas @@ -630,9 +630,9 @@ begin if (pData<>nil) then case t of - rtRoot, - rtBufPtr2, - rtFunPtr2:Result.pData:={%H-}Pointer(PPtrUint(pData+o)^ and (not 3)); + rtRoot :Result.pData:=pData; + rtFunPtr2:Result.pData:={%H-}Pointer(PPtrUint(pData+o)^); + rtBufPtr2:Result.pData:={%H-}Pointer(PPtrUint(pData+o)^ and (not 3)); rtVSharp4, rtSSharp4, rtTSharp4, diff --git a/vulkan/vCmdBuffer.pas b/vulkan/vCmdBuffer.pas index e9186c60..7d73a540 100644 --- a/vulkan/vCmdBuffer.pas +++ b/vulkan/vCmdBuffer.pas @@ -204,8 +204,7 @@ type Procedure WriteEvent(eventType:Byte); Procedure DrawIndexOffset2(IndexBase:Pointer;indexOffset,indexCount:DWORD); - Procedure DrawIndex2(IndexBase:Pointer;indexCount:DWORD); - Procedure DrawIndexAuto(indexCount:DWORD); + Procedure DrawIndexAuto (indexOffset,indexCount:DWORD); end; implementation @@ -915,6 +914,8 @@ var last_binding:TVkUInt32; last_size :TVkUInt32; + + diff:TVkDeviceSize; begin if (Self=nil) then begin @@ -927,6 +928,7 @@ begin if (not BeginCmdBuffer) then Exit; + rb:=nil; last_binding:=0; last_size :=0; For i:=0 to c-1 do @@ -947,10 +949,12 @@ begin last_binding:=binding; end; - Buffers[last_size]:=rb.FHandle; - Offsets[last_size]:=QWORD(min_addr)-rb.FAddr; + diff:=QWORD(min_addr)-rb.FAddr; - last_size:=last_size+1; + Buffers[last_size]:=rb.FHandle; + Offsets[last_size]:=diff; + + Inc(last_size); end; //flush @@ -973,6 +977,8 @@ begin if not limits.VK_EXT_vertex_input_dynamic_state then Exit; + if (FAttrBuilder.FAttrDescsCount=0) then Exit; + if (not BeginCmdBuffer) then Exit; FAttrBuilder.Export2(input); @@ -1572,18 +1578,18 @@ begin InsertLabel('DI_PT_QUADLIST'); Assert(FinstanceCount<=1,'instance DI_PT_QUADLIST'); - Assert(indexOffset=0,'OFFSET DI_PT_QUADLIST'); + h:=indexCount div 4; if (h>0) then h:=h-1; For i:=0 to h do begin vkCmdDrawIndexed( Fcmdbuf, - 4, //indexCount - 1, //instanceCount - i*4, //firstIndex - 0, //vertexOffset - 0); //firstInstance + 4, //indexCount + 1, //instanceCount + indexOffset+i*4, //firstIndex + 0, //vertexOffset + 0); //firstInstance end; end; else @@ -1592,12 +1598,7 @@ begin end; -Procedure TvCmdBuffer.DrawIndex2(IndexBase:Pointer;indexCount:DWORD); -begin - DrawIndexOffset2(IndexBase,0,indexCount); -end; - -Procedure TvCmdBuffer.DrawIndexAuto(indexCount:DWORD); +Procedure TvCmdBuffer.DrawIndexAuto(indexOffset,indexCount:DWORD); var i,h:DWORD; begin @@ -1625,7 +1626,7 @@ begin FCmdbuf, indexCount, //vertexCount FinstanceCount, //instanceCount - 0, //firstVertex + indexOffset, //firstVertex 0); //firstInstance end; @@ -1653,10 +1654,10 @@ begin Inc(cmd_count); vkCmdDraw( FCmdbuf, - 4, //vertexCount - 1, //instanceCount - 0, //firstVertex - 0); //firstInstance + 4, //vertexCount + 1, //instanceCount + indexOffset+i*3, //firstVertex + 0); //firstInstance end; end else @@ -1668,7 +1669,7 @@ begin FCmdbuf, indexCount, //vertexCount FinstanceCount, //instanceCount - 0, //firstVertex + indexOffset, //firstVertex 0); //firstInstance end; @@ -1679,6 +1680,7 @@ begin InsertLabel('DI_PT_QUADLIST'); Assert(FinstanceCount<=1,'instance DI_PT_QUADLIST'); + h:=indexCount div 4; if (h>0) then h:=h-1; For i:=0 to h do @@ -1686,10 +1688,10 @@ begin Inc(cmd_count); vkCmdDraw( FCmdbuf, - 4, //vertexCount - 1, //instanceCount - i*4, //firstVertex - 0); //firstInstance + 4, //vertexCount + 1, //instanceCount + indexOffset+i*4, //firstVertex + 0); //firstInstance end; end; //DI_PT_QUADSTRIP:;