start the process of making sync objects an extension
This commit is contained in:
10
projects/extensions/CMakeLists.txt
Normal file
10
projects/extensions/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
|
||||
project(GryphnExtensions)
|
||||
add_compile_definitions(GN_REVEAL_IMPL)
|
||||
|
||||
file(GLOB_RECURSE SYNC_EXT_SRC CONFIGURE_DEPENDS "synchronization/*.c")
|
||||
add_library(GryphnExtensions ${SYNC_EXT_SRC})
|
||||
target_include_directories(GryphnExtensions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../utils/)
|
||||
target_include_directories(GryphnExtensions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../core/)
|
||||
target_include_directories(GryphnExtensions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../core/src/)
|
||||
target_include_directories(GryphnExtensions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
28
projects/extensions/synchronization/fence/gryphn_fence.c
Normal file
28
projects/extensions/synchronization/fence/gryphn_fence.c
Normal file
@@ -0,0 +1,28 @@
|
||||
// #ifdef GN_EXT_GN_EXT_SYNCHRONIZATION
|
||||
|
||||
#include "gryphn_fence.h"
|
||||
#include "output_device/gryphn_output_device.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
|
||||
gnReturnCode gnCreateFence(gnFenceHandle* fence, gnDevice device) {
|
||||
*fence = malloc(sizeof(struct gnFence_t));
|
||||
(*fence)->device = device;
|
||||
(*fence)->signaled = gnFalse;
|
||||
return device->instance->callingLayer->deviceFunctions._gnCreateFence(*fence, device);
|
||||
}
|
||||
void gnSignalFence(gnFenceHandle fence) {
|
||||
fence->signaled = gnTrue;
|
||||
}
|
||||
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout) {
|
||||
if (fence->signaled == gnTrue) return;
|
||||
fence->device->instance->callingLayer->deviceFunctions._gnWaitForFence(fence, timeout);
|
||||
}
|
||||
void gnResetFence(gnFenceHandle fence) {
|
||||
fence->signaled = gnFalse;
|
||||
fence->device->instance->callingLayer->deviceFunctions._gnResetFence(fence);
|
||||
}
|
||||
void gnDestroyFence(gnFenceHandle fence) {
|
||||
fence->device->instance->callingLayer->deviceFunctions._gnDestroyFence(fence);
|
||||
}
|
||||
|
||||
// #endif
|
20
projects/extensions/synchronization/fence/gryphn_fence.h
Normal file
20
projects/extensions/synchronization/fence/gryphn_fence.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <utils/gryphn_bool.h>
|
||||
#include "utils/gryphn_error_code.h"
|
||||
#include "utils/lists/gryphn_array_list.h"
|
||||
#include "gryphn_handles.h"
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnFence_t {
|
||||
struct gnPlatformFence_t* fence;
|
||||
gnOutputDeviceHandle device;
|
||||
gnBool signaled;
|
||||
};
|
||||
#endif
|
||||
GN_ARRAY_LIST(gnFence);
|
||||
|
||||
gnReturnCode gnCreateFence(gnFenceHandle* fence, gnOutputDeviceHandle device);
|
||||
void gnSignalFence(gnFenceHandle fence);
|
||||
void gnWaitForFence(gnFenceHandle fence, uint64_t timeout);
|
||||
void gnResetFence(gnFenceHandle fence);
|
||||
void gnDestroyFence(gnFenceHandle fence);
|
@@ -0,0 +1,16 @@
|
||||
// #ifdef GN_EXT_SYNCHRONIZATION
|
||||
|
||||
#include "gryphn_semaphore.h"
|
||||
#include "output_device/gryphn_output_device.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
|
||||
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device) {
|
||||
*semaphore = malloc(sizeof(struct gnSemaphore_t));
|
||||
(*semaphore)->device = device;
|
||||
return device->instance->callingLayer->deviceFunctions._gnCreateSemaphore((*semaphore), device);
|
||||
}
|
||||
void gnDestroySemaphore(struct gnSemaphore_t* semaphore) {
|
||||
semaphore->device->instance->callingLayer->deviceFunctions._gnDestroySemaphore(semaphore);
|
||||
}
|
||||
|
||||
// #endif
|
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "utils/gryphn_error_code.h"
|
||||
#include "utils/lists/gryphn_array_list.h"
|
||||
#include "gryphn_handles.h"
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnSemaphore_t {
|
||||
struct gnPlatformSemaphore_t* semaphore;
|
||||
gnOutputDeviceHandle device;
|
||||
};
|
||||
#endif
|
||||
GN_ARRAY_LIST(gnSemaphore);
|
||||
|
||||
gnReturnCode gnCreateSemaphore(gnSemaphore* semaphore, struct gnOutputDevice_t* device);
|
||||
void gnDestroySemaphore(gnSemaphore semaphore);
|
Reference in New Issue
Block a user