Skip to content

Commit

Permalink
VK: Use queue for sending update message.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Jan 1, 2024
1 parent db0d07e commit da32ea1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion include/vkRenderMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
enum VulkanRendererMessage : uint32_t
{
/** Export, if ready */
exportRender = 0
exportRender = 0,

/** Update the renderer */
updateRenderer = 1
};
1 change: 1 addition & 0 deletions include/vkrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ class AsyVkRender
static void exportHandler(int=0);
void Export(int imageIndex);
bool readyForExport=false;
bool readyForUpdate=false;
void quit();

double spinStep();
Expand Down
16 changes: 10 additions & 6 deletions src/vkrender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void AsyVkRender::framebufferResizeCallback(GLFWwindow* window, int width, int h
static bool initialize=true;
if(initialize) {
initialize=false;
Signal(SIGUSR1,updateHandler);
app->readyForUpdate=true;
}
}
}
Expand Down Expand Up @@ -646,11 +646,8 @@ void AsyVkRender::vkrender(const string& prefix, const picture* pic, const strin
#ifdef HAVE_PTHREAD
if(vkthread && initializedView) {
if(View) {
#ifdef __MSDOS__ // Signals are unreliable in MSWindows
vkupdate=true;
#else
pthread_kill(mainthread,SIGUSR1);
#endif
// called from asymain thread, main thread handles vulkan rendering
messageQueue.enqueue(updateRenderer);
} else readyAfterExport=queueExport=true;
return;
}
Expand Down Expand Up @@ -3893,6 +3890,13 @@ void AsyVkRender::processMessages(VulkanRendererMessage const& msg)
}
}
break;
case updateRenderer: {
if (readyForUpdate)
{
readyForUpdate=false;
updateHandler(0);
}
}
default:
break;
}
Expand Down

0 comments on commit da32ea1

Please sign in to comment.