Enhance OpenGLFence with proper synchronization
- Add FenceStatus enum for status query - Add m_sync (GLsync) for OpenGL fence synchronization - Add Signal(value) overload with fence value - Add Wait(timeoutNs) with timeout support - Add GetStatus() for async status check - Add GetCompletedValue() and GetCurrentValue() - Implement using glSync for proper GPU synchronization - Replace glFinish blocking with glClientWaitSync
This commit is contained in:
@@ -6,23 +6,34 @@
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
enum class FenceStatus {
|
||||
Signaled,
|
||||
Unsignaled,
|
||||
Error
|
||||
};
|
||||
|
||||
class OpenGLFence {
|
||||
public:
|
||||
OpenGLFence();
|
||||
~OpenGLFence();
|
||||
|
||||
bool Initialize();
|
||||
bool Initialize(bool signaled = false);
|
||||
void Shutdown();
|
||||
|
||||
void Signal();
|
||||
void Wait();
|
||||
void Signal(uint64_t value);
|
||||
void Wait(uint64_t timeoutNs = UINT64_MAX);
|
||||
void Reset();
|
||||
|
||||
bool IsSignaled() const;
|
||||
FenceStatus GetStatus() const;
|
||||
uint64_t GetCompletedValue() const;
|
||||
uint64_t GetCurrentValue() const { return m_fenceValue; }
|
||||
|
||||
private:
|
||||
unsigned int m_fence;
|
||||
int64_t m_fenceValue;
|
||||
void* m_sync;
|
||||
uint64_t m_fenceValue;
|
||||
uint64_t m_completedValue;
|
||||
bool m_signaled;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user