mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:17:43 +02:00
Add support for executing arbitrary commands on the texture transfer thread
This commit is contained in:
parent
ee476a6048
commit
255e9e6435
2 changed files with 18 additions and 2 deletions
|
@ -97,12 +97,23 @@ void GLTextureTransferHelper::shutdown() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLTextureTransferHelper::queueExecution(VoidLambda lambda) {
|
||||||
|
Lock lock(_mutex);
|
||||||
|
_pendingCommands.push_back(lambda);
|
||||||
|
}
|
||||||
|
|
||||||
bool GLTextureTransferHelper::process() {
|
bool GLTextureTransferHelper::process() {
|
||||||
// Take any new textures off the queue
|
// Take any new textures or commands off the queue
|
||||||
|
VoidLambdaList pendingCommands;
|
||||||
TextureList newTransferTextures;
|
TextureList newTransferTextures;
|
||||||
{
|
{
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
newTransferTextures.swap(_pendingTextures);
|
newTransferTextures.swap(_pendingTextures);
|
||||||
|
pendingCommands.swap(_pendingCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto command : pendingCommands) {
|
||||||
|
command();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newTransferTextures.empty()) {
|
if (!newTransferTextures.empty()) {
|
||||||
|
@ -144,7 +155,7 @@ bool GLTextureTransferHelper::process() {
|
||||||
gltexture->finishTransfer();
|
gltexture->finishTransfer();
|
||||||
//glNamedFramebufferTexture(_readFramebuffer, GL_COLOR_ATTACHMENT0, gltexture->_id, 0);
|
//glNamedFramebufferTexture(_readFramebuffer, GL_COLOR_ATTACHMENT0, gltexture->_id, 0);
|
||||||
//glBlitNamedFramebuffer(_readFramebuffer, _drawFramebuffer, 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
//glBlitNamedFramebuffer(_readFramebuffer, _drawFramebuffer, 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
//clientWait();
|
clientWait();
|
||||||
gltexture->_contentStamp = gltexture->_gpuObject.getDataStamp();
|
gltexture->_contentStamp = gltexture->_gpuObject.getDataStamp();
|
||||||
gltexture->updateSize();
|
gltexture->updateSize();
|
||||||
gltexture->setSyncState(gpu::gl::GLSyncState::Transferred);
|
gltexture->setSyncState(gpu::gl::GLSyncState::Transferred);
|
||||||
|
|
|
@ -28,10 +28,13 @@ using TextureListIterator = TextureList::iterator;
|
||||||
|
|
||||||
class GLTextureTransferHelper : public GenericThread {
|
class GLTextureTransferHelper : public GenericThread {
|
||||||
public:
|
public:
|
||||||
|
using VoidLambda = std::function<void()>;
|
||||||
|
using VoidLambdaList = std::list<VoidLambda>;
|
||||||
using Pointer = std::shared_ptr<GLTextureTransferHelper>;
|
using Pointer = std::shared_ptr<GLTextureTransferHelper>;
|
||||||
GLTextureTransferHelper();
|
GLTextureTransferHelper();
|
||||||
~GLTextureTransferHelper();
|
~GLTextureTransferHelper();
|
||||||
void transferTexture(const gpu::TexturePointer& texturePointer);
|
void transferTexture(const gpu::TexturePointer& texturePointer);
|
||||||
|
void queueExecution(VoidLambda lambda);
|
||||||
|
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void shutdown() override;
|
void shutdown() override;
|
||||||
|
@ -47,6 +50,8 @@ private:
|
||||||
#endif
|
#endif
|
||||||
// A mutex for protecting items access on the render and transfer threads
|
// A mutex for protecting items access on the render and transfer threads
|
||||||
Mutex _mutex;
|
Mutex _mutex;
|
||||||
|
// Commands that have been submitted for execution on the texture transfer thread
|
||||||
|
VoidLambdaList _pendingCommands;
|
||||||
// Textures that have been submitted for transfer
|
// Textures that have been submitted for transfer
|
||||||
TextureList _pendingTextures;
|
TextureList _pendingTextures;
|
||||||
// Textures currently in the transfer process
|
// Textures currently in the transfer process
|
||||||
|
|
Loading…
Reference in a new issue