@@ -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 ) {
250255 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
251256 const GrSampler * grSampler = (GrSampler * )pSamplers [i ];
@@ -304,6 +309,9 @@ GR_VOID GR_STDCALL grAttachSamplerDescriptors(
304309 STACK_ARRAY_FINISH (writeDescriptors );
305310 }
306311
312+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
313+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
314+ }
307315}
308316
309317GR_VOID GR_STDCALL grAttachImageViewDescriptors (
@@ -316,6 +324,10 @@ GR_VOID GR_STDCALL grAttachImageViewDescriptors(
316324 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
317325 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
318326
327+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
328+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
329+ }
330+
319331 if (grDevice -> descriptorBufferSupported ) {
320332 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
321333 const GR_IMAGE_VIEW_ATTACH_INFO * info = & pImageViews [i ];
@@ -405,6 +417,10 @@ GR_VOID GR_STDCALL grAttachImageViewDescriptors(
405417 VKD .vkUpdateDescriptorSets (grDevice -> device , descriptorWriteCount , writeDescriptors , 0 , NULL );
406418 STACK_ARRAY_FINISH (writeDescriptors );
407419 }
420+
421+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
422+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
423+ }
408424}
409425
410426GR_VOID GR_STDCALL grAttachMemoryViewDescriptors (
@@ -418,6 +434,10 @@ GR_VOID GR_STDCALL grAttachMemoryViewDescriptors(
418434 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
419435 VkResult vkRes ;
420436
437+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
438+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
439+ }
440+
421441 if (grDevice -> descriptorBufferSupported ) {
422442 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
423443 DescriptorSetSlot * slot = & grDescriptorSet -> slots [startSlot + i ];
@@ -573,6 +593,10 @@ GR_VOID GR_STDCALL grAttachMemoryViewDescriptors(
573593 VKD .vkUpdateDescriptorSets (grDevice -> device , descriptorWriteCount , writeDescriptors , 0 , NULL );
574594 STACK_ARRAY_FINISH (writeDescriptors );
575595 }
596+
597+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
598+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
599+ }
576600}
577601
578602GR_VOID GR_STDCALL grAttachNestedDescriptors (
@@ -585,6 +609,10 @@ GR_VOID GR_STDCALL grAttachNestedDescriptors(
585609 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
586610 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
587611
612+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
613+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
614+ }
615+
588616 for (unsigned i = 0 ; i < slotCount ; i ++ ) {
589617 DescriptorSetSlot * slot = & grDescriptorSet -> slots [startSlot + i ];
590618 const GR_DESCRIPTOR_SET_ATTACH_INFO * info = & pNestedDescriptorSets [i ];
@@ -599,6 +627,9 @@ GR_VOID GR_STDCALL grAttachNestedDescriptors(
599627 },
600628 };
601629 }
630+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
631+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
632+ }
602633}
603634
604635GR_VOID GR_STDCALL grClearDescriptorSetSlots (
@@ -610,6 +641,10 @@ GR_VOID GR_STDCALL grClearDescriptorSetSlots(
610641 GrDescriptorSet * grDescriptorSet = (GrDescriptorSet * )descriptorSet ;
611642 const GrDevice * grDevice = GET_OBJ_DEVICE (grDescriptorSet );
612643
644+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
645+ AcquireSRWLockExclusive (& grDescriptorSet -> descriptorLock );
646+ }
647+
613648 if (grDevice -> descriptorBufferSupported ) {
614649 memset (grDescriptorSet -> descriptorBufferPtr + (startSlot * DESCRIPTORS_PER_SLOT * grDevice -> maxMutableDescriptorSize ), 0 , grDevice -> maxMutableDescriptorSize * slotCount * DESCRIPTORS_PER_SLOT );
615650 memset (& grDescriptorSet -> slots [startSlot ], 0 , sizeof (DescriptorSetSlot ) * slotCount );
@@ -622,4 +657,8 @@ GR_VOID GR_STDCALL grClearDescriptorSetSlots(
622657 slot -> type = SLOT_TYPE_NONE ;
623658 }
624659 }
660+
661+ if (quirkHas (QUIRK_DESCRIPTOR_SET_INTERNAL_SYNCHRONIZED )) {
662+ ReleaseSRWLockExclusive (& grDescriptorSet -> descriptorLock );
663+ }
625664}
0 commit comments