This commit is contained in:
Ben Kyd
2023-01-24 18:01:45 +00:00
parent 41b451dbe2
commit 1598a25e51
5 changed files with 12 additions and 7 deletions

View File

@@ -101,7 +101,7 @@ public:
inline void passContext(void* context, HART_HIT_CALLBACK callback)
{
spdlog::debug("[hartmodule] Recieved context from HHM");
spdlog::debug("[hartmodule] Recieved context");
std::lock_guard<std::mutex> lock(_mData);
mCtx = context;
Hit = callback;

View File

@@ -74,6 +74,7 @@ void HHM::bounce(Ray* newRay)
void HHM::startTrace(RayField sourceScatter)
{
// TODO: Signal start
HARTModule* mod = mDirectory.getActiveModule();
mod->passContext((void*)this, &rayHitCallback);
spdlog::debug("SubmitQueue {}", sourceScatter.size());

View File

@@ -69,7 +69,7 @@ bool RenderDispatcher::progressionStatus()
GLuint RenderDispatcher::getLatestTexture()
{
std::lock_guard<std::mutex> lock(mRenderer->_mTarget);
std::lock_guard<std::mutex> lock(mRenderer->_RenderData);
glBindTexture(GL_TEXTURE_2D, mRenderer->mRenderTargetTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mRenderer->mRenderTargetSize.x, mRenderer->mRenderTargetSize.y, 0, GL_RGBA, GL_FLOAT, mRenderer->mTarget);
glBindTexture(GL_TEXTURE_2D, 0);

View File

@@ -67,7 +67,7 @@ glm::ivec2 RayRenderer::getTargetSize()
GLuint RayRenderer::getRenderedTexture()
{
std::lock_guard<std::mutex> lock(this->_mTarget);
std::lock_guard<std::mutex> lock(this->_RenderData);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, mRenderTargetTexture);
return mRenderTargetTexture;
@@ -93,7 +93,7 @@ void RayRenderer::mHaultWait()
bool frameStatus = false;
while (!frameStatus)
{
std::lock_guard<std::mutex> lock(this->_mTarget);
std::lock_guard<std::mutex> lock(this->_RenderData);
switch(mIface->getModuleState())
{
case EModuleState::Bad:
@@ -121,10 +121,11 @@ void RayRenderer::draw()
{
mTarget[y * mRenderTargetSize.x + x] = { 1.0f, 0.0f, 0.0f, 1.0f };
}
mCurrentRefTable = &startRays.Reference;
// TODO: Why do we need to wait here?
mHaultWait();
mCurrentRefTable = &startRays.Reference;
mIface->startTrace(startRays.Field);
mHaultWait();
@@ -139,13 +140,13 @@ void RayRenderer::draw()
void RayRenderer::computeHit(HitInfo* info)
{
// TODO: Make sure signal is started
if (!(*mCurrentRefTable).count(info->Caller->Reference))
{
spdlog::warn("Why is the ray not in the map?!");
return;
}
glm::ivec2 pos = (*mCurrentRefTable)[info->Caller->Reference];
std::lock_guard<std::mutex> lock(this->_mTarget);
float d = info->Distance;
mTarget[pos.y * mRenderTargetSize.x + pos.x] = { d, d, d, 1.0f };
}

View File

@@ -4,6 +4,7 @@
#include <mutex>
#include <unordered_map>
#include <condition_variable>
namespace inferno {
@@ -41,7 +42,9 @@ private:
private:
GLuint mRenderTargetTexture = 0;
glm::fvec4* mTarget;
std::mutex _mTarget;
std::mutex _RenderData;
std::condition_variable _RenderPause;
glm::ivec2 mRenderTargetSize = {300, 300};