@@ -195,6 +195,7 @@ GR_RESULT GR_STDCALL grCreateDescriptorSet(
195195 .grObj = { GR_OBJ_TYPE_DESCRIPTOR_SET , grDevice },
196196 .slotCount = pCreateInfo -> slots ,
197197 .slots = calloc (pCreateInfo -> slots , sizeof (DescriptorSetSlot )),
198+ .descriptorLock = SRWLOCK_INIT ,
198199 .descriptorPool = descriptorPool ,
199200 .descriptorSet = descriptorSet ,
200201 .descriptorBufferPtr = descriptorBufferPtr ,
@@ -246,6 +247,10 @@ GR_VOID GR_STDCALL grAttachSamplerDescriptors(
246247 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
247248 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
248249
250+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
251+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
252+ }
253+
249254 if (grDevice -> descriptorBufferSupported && grDevice -> descriptorBufferAllowPreparedSampler ) {
250255 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
251256 const GrSampler * grSampler = (GrSampler * )pSamplers [i ];
@@ -311,6 +316,9 @@ GR_VOID GR_STDCALL grAttachSamplerDescriptors(
311316 STACK_ARRAY_FINISH (writeDescriptors );
312317 }
313318
319+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
320+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
321+ }
314322}
315323
316324GR_VOID GR_STDCALL grAttachImageViewDescriptors (
@@ -323,6 +331,10 @@ GR_VOID GR_STDCALL grAttachImageViewDescriptors(
323331 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
324332 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
325333
334+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
335+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
336+ }
337+
326338 if (grDevice -> descriptorBufferSupported && grDevice -> descriptorBufferAllowPreparedImageView ) {
327339 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
328340 const GR_IMAGE_VIEW_ATTACH_INFO * info = & pImageViews [i ];
@@ -428,6 +440,10 @@ GR_VOID GR_STDCALL grAttachImageViewDescriptors(
428440 VKD .vkUpdateDescriptorSets (grDevice -> device , descriptorWriteCount , writeDescriptors , 0 , NULL );
429441 STACK_ARRAY_FINISH (writeDescriptors );
430442 }
443+
444+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
445+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
446+ }
431447}
432448
433449GR_VOID GR_STDCALL grAttachMemoryViewDescriptors (
@@ -441,6 +457,10 @@ GR_VOID GR_STDCALL grAttachMemoryViewDescriptors(
441457 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
442458 VkResult vkRes ;
443459
460+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
461+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
462+ }
463+
444464 if (grDevice -> descriptorBufferSupported ) {
445465 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
446466 DescriptorSetSlot * slot = & grDescriptorSet -> slots [startSlot + i ];
@@ -596,6 +616,10 @@ GR_VOID GR_STDCALL grAttachMemoryViewDescriptors(
596616 VKD .vkUpdateDescriptorSets (grDevice -> device , descriptorWriteCount , writeDescriptors , 0 , NULL );
597617 STACK_ARRAY_FINISH (writeDescriptors );
598618 }
619+
620+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
621+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
622+ }
599623}
600624
601625GR_VOID GR_STDCALL grAttachNestedDescriptors (
@@ -608,6 +632,10 @@ GR_VOID GR_STDCALL grAttachNestedDescriptors(
608632 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
609633 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
610634
635+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
636+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
637+ }
638+
611639 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
612640 DescriptorSetSlot * slot = & grDescriptorSet -> slots [startSlot + i ];
613641 const GR_DESCRIPTOR_SET_ATTACH_INFO * info = & pNestedDescriptorSets [i ];
@@ -622,6 +650,9 @@ GR_VOID GR_STDCALL grAttachNestedDescriptors(
622650 },
623651 };
624652 }
653+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
654+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
655+ }
625656}
626657
627658GR_VOID GR_STDCALL grClearDescriptorSetSlots (
@@ -633,6 +664,10 @@ GR_VOID GR_STDCALL grClearDescriptorSetSlots(
633664 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
634665 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
635666
667+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
668+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
669+ }
670+
636671 if (grDevice -> descriptorBufferSupported ) {
637672 memset (grDescriptorSet -> descriptorBufferPtr + (startSlot * DESCRIPTORS_PER_SLOT * grDevice -> maxMutableDescriptorSize ), 0 , grDevice -> maxMutableDescriptorSize * slotCount * DESCRIPTORS_PER_SLOT );
638673 memset (& grDescriptorSet -> slots [startSlot ], 0 , sizeof (DescriptorSetSlot ) * slotCount );
@@ -645,4 +680,8 @@ GR_VOID GR_STDCALL grClearDescriptorSetSlots(
645680 slot -> type = SLOT_TYPE_NONE ;
646681 }
647682 }
683+
684+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
685+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
686+ }
648687}
0 commit comments