working on software backend

This commit is contained in:
2025-03-04 00:13:32 +01:00
parent 8c7b2bb44f
commit 211700b955
19 changed files with 539 additions and 32 deletions

View File

@@ -9,16 +9,51 @@
PulseFence SoftCreateFence(PulseDevice device)
{
PULSE_UNUSED(device);
PulseFence fence = (PulseFence)calloc(1, sizeof(PulseFence));
PULSE_CHECK_ALLOCATION_RETVAL(fence, PULSE_NULL_HANDLE);
SoftFence* soft_fence = (SoftFence*)calloc(1, sizeof(SoftFence));
PULSE_CHECK_ALLOCATION_RETVAL(soft_fence, PULSE_NULL_HANDLE);
atomic_store(&soft_fence->signal, true);
fence->driver_data = soft_fence;
return fence;
}
void SoftDestroyFence(PulseDevice device, PulseFence fence)
{
PULSE_UNUSED(device);
free(fence->driver_data);
free(fence);
}
bool SoftIsFenceReady(PulseDevice device, PulseFence fence)
{
PULSE_UNUSED(device);
SoftFence* soft_fence = SOFT_RETRIEVE_DRIVER_DATA_AS(fence, SoftFence*);
return atomic_load(&soft_fence->signal);
}
bool SoftWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all)
{
PULSE_UNUSED(device);
if(fences_count == 0)
return true;
uint32_t fences_to_wait = fences_count;
while(fences_to_wait != 0)
{
for(uint32_t i = 0; i < fences_count; i++)
{
if(SoftIsFenceReady(device, fences[i]))
fences_to_wait--;
}
if(!wait_for_all && fences_to_wait != fences_count)
return true;
PulseSleep(1); // 1ms
}
return true;
}