@@ -412,33 +412,65 @@ struct Vertex
412412 public Color VColor ;
413413 }
414414
415- internal class EffekseerRendererUnity : IEffekseerRenderer
416- {
417- const CameraEvent cameraEvent = CameraEvent . AfterForwardAlpha ;
418- private StandardBlitter standardBlitter = new StandardBlitter ( ) ;
419-
420- class MaterialPropCollection
415+ internal class EffekseerRendererUnity : IEffekseerRenderer
421416 {
422- List < MaterialPropertyBlock > materialPropBlocks = new List < MaterialPropertyBlock > ( ) ;
423- int materialPropBlockOffset = 0 ;
417+ const CameraEvent cameraEvent = CameraEvent . AfterForwardAlpha ;
418+ private StandardBlitter standardBlitter = new StandardBlitter ( ) ;
424419
425- public void Reset ( )
420+ static bool IsScriptableRenderPipelineActive ( RenderPipelineAsset currentRenderPipeline )
426421 {
427- materialPropBlockOffset = 0 ;
422+ return currentRenderPipeline != null ;
428423 }
429424
430- public MaterialPropertyBlock GetNext ( )
425+ static bool RequiresGlobalBufferFallback ( )
431426 {
432- if ( materialPropBlockOffset >= materialPropBlocks . Count )
427+ #if UNITY_6000_0_OR_NEWER
428+ return SystemInfo . graphicsDeviceType == GraphicsDeviceType . Vulkan &&
429+ IsScriptableRenderPipelineActive ( GraphicsSettings . currentRenderPipeline ) ;
430+ #else
431+ return false ;
432+ #endif
433+ }
434+
435+ static void SetBufferProperty ( CommandBuffer commandBuffer , MaterialPropertyBlock prop , string name , ComputeBuffer buffer )
436+ {
437+ prop . SetBuffer ( name , buffer ) ;
438+
439+ // Workaround:
440+ // On Unity 6 SRP rendering with Vulkan, buffers bound only through
441+ // MaterialPropertyBlock can be treated as unbound for DrawProcedural.
442+ // Mirror the binding to a global shader property as well.
443+ // Keep this isolated here because it is likely compensating for a
444+ // Unity-side issue affecting HDRP/URP paths and may be removable once
445+ // Unity fixes it.
446+ if ( RequiresGlobalBufferFallback ( ) )
433447 {
434- materialPropBlocks . Add ( new MaterialPropertyBlock ( ) ) ;
448+ commandBuffer . SetGlobalBuffer ( name , buffer ) ;
435449 }
450+ }
451+
452+ class MaterialPropCollection
453+ {
454+ List < MaterialPropertyBlock > materialPropBlocks = new List < MaterialPropertyBlock > ( ) ;
455+ int materialPropBlockOffset = 0 ;
456+
457+ public void Reset ( )
458+ {
459+ materialPropBlockOffset = 0 ;
460+ }
461+
462+ public MaterialPropertyBlock GetNext ( )
463+ {
464+ if ( materialPropBlockOffset >= materialPropBlocks . Count )
465+ {
466+ materialPropBlocks . Add ( new MaterialPropertyBlock ( ) ) ;
467+ }
436468
437- var ret = materialPropBlocks [ materialPropBlockOffset ] ;
438- materialPropBlockOffset ++ ;
439- return ret ;
469+ var ret = materialPropBlocks [ materialPropBlockOffset ] ;
470+ materialPropBlockOffset ++ ;
471+ return ret ;
472+ }
440473 }
441- }
442474
443475 [ StructLayout ( LayoutKind . Sequential ) ]
444476 struct CustomDataBuffer
@@ -1203,14 +1235,14 @@ unsafe void RenderSprite(Plugin.UnityRenderParameter parameter, IntPtr infoBuffe
12031235
12041236 Debug . Assert ( computeBuffer . HasBuffer ( parameter . VertexBufferStride ) ) ;
12051237 var vertexBuffer = computeBuffer . Get ( parameter . VertexBufferStride , false ) ;
1206- if ( vertexBuffer == null )
1238+ if ( vertexBuffer == null || ! vertexBuffer . IsValid ( ) )
12071239 {
12081240 Debug . LogWarning ( "Invalid allocation" ) ;
12091241 return ;
12101242 }
12111243 Debug . Assert ( vertexBuffer . IsValid ( ) ) ;
12121244
1213- prop . SetBuffer ( "buf_vertex" , vertexBuffer ) ;
1245+ SetBufferProperty ( commandBuffer , prop , "buf_vertex" , vertexBuffer ) ;
12141246
12151247 prop . SetVector ( "mUVInversed" , new Vector4 ( 1.0f , - 1.0f , 0.0f , 0.0f ) ) ;
12161248 prop . SetVector ( "mUVInversedBack" , new Vector4 ( 0.0f , 1.0f , 0.0f , 0.0f ) ) ;
@@ -1222,14 +1254,14 @@ unsafe void RenderSprite(Plugin.UnityRenderParameter parameter, IntPtr infoBuffe
12221254 if ( isAdvanced )
12231255 {
12241256 var bufAd = computeBuffer . Get ( sizeof ( Effekseer . Plugin . AdvancedVertexParameter ) , false ) ;
1225- if ( bufAd == null )
1257+ if ( bufAd == null || ! bufAd . IsValid ( ) )
12261258 {
12271259 Debug . LogWarning ( "Invalid allocation" ) ;
12281260 return ;
12291261 }
12301262 Debug . Assert ( bufAd . IsValid ( ) ) ;
12311263
1232- prop . SetBuffer ( "buf_ad" , bufAd ) ;
1264+ SetBufferProperty ( commandBuffer , prop , "buf_ad" , bufAd ) ;
12331265 prop . SetFloat ( "buf_ad_offset" , parameter . AdvancedDataOffset / sizeof ( Effekseer . Plugin . AdvancedVertexParameter ) ) ;
12341266
12351267 ApplyAdvancedParameter ( parameter , prop ) ;
@@ -1409,17 +1441,44 @@ unsafe void RenderModdel(Plugin.UnityRenderParameter parameter, IntPtr infoBuffe
14091441 ApplyReconstructionParameter ( parameter , prop ) ;
14101442 prop . SetVector ( "softParticleParam" , parameter . SoftParticleParam ) ;
14111443
1412- prop . SetBuffer ( "buf_model_parameter" , computeBuf1 ) ;
1444+ if ( computeBuf1 == null || ! computeBuf1 . IsValid ( ) )
1445+ {
1446+ Debug . LogWarning ( "Invalid allocation" ) ;
1447+ offset += allocated ;
1448+ count -= allocated ;
1449+ continue ;
1450+ }
1451+
1452+ SetBufferProperty ( commandBuffer , prop , "buf_model_parameter" , computeBuf1 ) ;
14131453
14141454 if ( isAdvanced )
14151455 {
1416- prop . SetBuffer ( "buf_model_parameter2" , computeBuf2 ) ;
1456+ if ( computeBuf2 == null || ! computeBuf2 . IsValid ( ) )
1457+ {
1458+ Debug . LogWarning ( "Invalid allocation" ) ;
1459+ offset += allocated ;
1460+ count -= allocated ;
1461+ continue ;
1462+ }
1463+
1464+ SetBufferProperty ( commandBuffer , prop , "buf_model_parameter2" , computeBuf2 ) ;
1465+ }
1466+
1467+ if ( model . VertexBuffer == null || ! model . VertexBuffer . IsValid ( ) ||
1468+ model . IndexBuffer == null || ! model . IndexBuffer . IsValid ( ) ||
1469+ model . VertexOffsets == null || ! model . VertexOffsets . IsValid ( ) ||
1470+ model . IndexOffsets == null || ! model . IndexOffsets . IsValid ( ) )
1471+ {
1472+ Debug . LogWarning ( "Invalid allocation" ) ;
1473+ offset += allocated ;
1474+ count -= allocated ;
1475+ continue ;
14171476 }
14181477
1419- prop . SetBuffer ( "buf_vertex" , model . VertexBuffer ) ;
1420- prop . SetBuffer ( "buf_index" , model . IndexBuffer ) ;
1421- prop . SetBuffer ( "buf_vertex_offsets" , model . VertexOffsets ) ;
1422- prop . SetBuffer ( "buf_index_offsets" , model . IndexOffsets ) ;
1478+ SetBufferProperty ( commandBuffer , prop , "buf_vertex" , model . VertexBuffer ) ;
1479+ SetBufferProperty ( commandBuffer , prop , "buf_index" , model . IndexBuffer ) ;
1480+ SetBufferProperty ( commandBuffer , prop , "buf_vertex_offsets" , model . VertexOffsets ) ;
1481+ SetBufferProperty ( commandBuffer , prop , "buf_index_offsets" , model . IndexOffsets ) ;
14231482
14241483 prop . SetVector ( "mUVInversed" , new Vector4 ( 1.0f , - 1.0f , 0.0f , 0.0f ) ) ;
14251484 prop . SetVector ( "mUVInversedBack" , new Vector4 ( 0.0f , 1.0f , 0.0f , 0.0f ) ) ;
@@ -1491,15 +1550,15 @@ unsafe void RenderModdel(Plugin.UnityRenderParameter parameter, IntPtr infoBuffe
14911550 ComputeBuffer cb = null ;
14921551 var all = customDataBuffers . Allocate ( ( CustomDataBuffer * ) ( ( byte * ) infoBuffer . ToPointer ( ) + parameter . CustomData1BufferOffset ) , offset , count , ref cb ) ;
14931552 if ( all != allocated ) throw new Exception ( ) ;
1494- prop . SetBuffer ( "buf_customData1" , cb ) ;
1553+ SetBufferProperty ( commandBuffer , prop , "buf_customData1" , cb ) ;
14951554 }
14961555
14971556 if ( efkMaterial . asset . CustomData2Count > 0 )
14981557 {
14991558 ComputeBuffer cb = null ;
15001559 var all = customDataBuffers . Allocate ( ( CustomDataBuffer * ) ( ( byte * ) infoBuffer . ToPointer ( ) + parameter . CustomData2BufferOffset ) , offset , count , ref cb ) ;
15011560 if ( all != allocated ) throw new Exception ( ) ;
1502- prop . SetBuffer ( "buf_customData2" , cb ) ;
1561+ SetBufferProperty ( commandBuffer , prop , "buf_customData2" , cb ) ;
15031562 }
15041563
15051564 if ( parameter . IsRefraction > 0 && background != null )
0 commit comments