Files
fs2open.github.com/code/graphics/opengl/gropenglsync.cpp
asarium c585314ff1 Use a uniform buffer object for storing deferred lighting data
This converts the deferred lighting shader to use uniform buffers for
the dynamic data sent to the GPU while rendering the lighting effects.
This doesn't affect performance but the deferred lighting code is a
nicely isolated piece of rendering code where I could test how the
rendering code could use the uniform buffers.

This is related to #910.
2017-09-03 12:40:33 +02:00

29 lines
1.1 KiB
C++

#include "graphics/opengl/gropenglsync.h"
gr_sync gr_opengl_sync_fence() {
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
// This shouldn't ever fail
Assertion(fence != nullptr, "Fence creation failed!");
return (gr_sync) fence;
}
bool gr_opengl_sync_wait(gr_sync sync, uint64_t timeoutns) {
Assertion(sync != nullptr, "Invalid sync object specified!");
Assertion(glIsSync((GLsync) sync), "Pointer was specified which is not a sync object");
// We only need GL_SYNC_FLUSH_COMMANDS_BIT if we actually wait for the sync object. Otherwise we only check if the
// object is signaled which does not require a flush.
auto res = glClientWaitSync((GLsync) sync, timeoutns != 0 ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, timeoutns);
// Return true if the sync object has been signaled in any way
return res == GL_ALREADY_SIGNALED || res == GL_CONDITION_SATISFIED;
}
void gr_opengl_sync_delete(gr_sync sync) {
Assertion(sync != nullptr, "Invalid sync object specified!");
Assertion(glIsSync((GLsync) sync), "Pointer was specified which is not a sync object");
glDeleteSync((GLsync) sync);
}