Add ComputeParticlesTest
Renderer: Add a way to execute commands on the device
This commit is contained in:
committed by
Jérôme Leclercq
parent
9e7b98a017
commit
e34ba8c05d
@@ -160,7 +160,7 @@ namespace Nz
|
||||
|
||||
void OpenGLCommandBufferBuilder::PostTransferBarrier()
|
||||
{
|
||||
/* nothing to do */
|
||||
m_commandBuffer.InsertMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
void OpenGLCommandBufferBuilder::SetScissor(const Recti& scissorRegion)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLBuffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLCommandPool.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLComputePipeline.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLFboFramebuffer.hpp>
|
||||
@@ -155,6 +156,22 @@ namespace Nz
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLDevice::Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueType /*queueType*/)
|
||||
{
|
||||
const GL::Context* activeContext = GL::Context::GetCurrentContext();
|
||||
if (!activeContext || activeContext->GetDevice() != this)
|
||||
{
|
||||
if (!GL::Context::SetCurrentContext(m_referenceContext.get()))
|
||||
throw std::runtime_error("failed to activate context");
|
||||
}
|
||||
|
||||
OpenGLCommandBuffer commandBuffer; //< TODO: Use a pool and remove default constructor
|
||||
OpenGLCommandBufferBuilder builder(commandBuffer);
|
||||
callback(builder);
|
||||
|
||||
commandBuffer.Execute();
|
||||
}
|
||||
|
||||
const RenderDeviceInfo& OpenGLDevice::GetDeviceInfo() const
|
||||
{
|
||||
return m_deviceInfo;
|
||||
@@ -318,4 +335,16 @@ namespace Nz
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenGLDevice::WaitForIdle()
|
||||
{
|
||||
const GL::Context* activeContext = GL::Context::GetCurrentContext();
|
||||
if (!activeContext || activeContext->GetDevice() != this)
|
||||
{
|
||||
if (!GL::Context::SetCurrentContext(m_referenceContext.get()))
|
||||
throw std::runtime_error("failed to activate context");
|
||||
}
|
||||
|
||||
m_referenceContext->glFinish();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user