- 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
42 lines
738 B
C++
42 lines
738 B
C++
#pragma once
|
|
|
|
#include <GLFW/glfw3.h>
|
|
#include <cstdint>
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
enum class FenceStatus {
|
|
Signaled,
|
|
Unsignaled,
|
|
Error
|
|
};
|
|
|
|
class OpenGLFence {
|
|
public:
|
|
OpenGLFence();
|
|
~OpenGLFence();
|
|
|
|
bool Initialize(bool signaled = false);
|
|
void Shutdown();
|
|
|
|
void Signal();
|
|
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:
|
|
void* m_sync;
|
|
uint64_t m_fenceValue;
|
|
uint64_t m_completedValue;
|
|
bool m_signaled;
|
|
};
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|