Fences and Semaphores
This commit is contained in:
parent
edf13611b5
commit
14282e0b5d
4 changed files with 71 additions and 3 deletions
|
|
@ -74,7 +74,7 @@ public class PrimaryRuntime {
|
|||
PrimaryThread.KillThread();
|
||||
DrawingThread.KillThread();
|
||||
cleanup();
|
||||
Logger.debug("Waiting to close Primary Thread, making sure vulkan has shut down properly first and Engine Threads are closed");
|
||||
Logger.debug("Waiting to close Primary Thread, making sure vulkan has shut down properly first and Engine Threads are closed\nThreads Open:[{}]\nVulkan Layers Open:[{}]",ThreadsOpen, VulkanContext.VulkanLayersOpen);
|
||||
while(ThreadsOpen > 0 || VulkanContext.VulkanLayersOpen > 0){
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,44 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.GPUSynchronisation;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.VulkanContext;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.vulkan.VkFenceCreateInfo;
|
||||
|
||||
import java.nio.LongBuffer;
|
||||
|
||||
import static net.halbear.Terrain4J.EngineCore.Vulkan.Util.VulkanUtils.vkCheck;
|
||||
import static org.lwjgl.vulkan.VK13.vkResetFences;
|
||||
import static org.lwjgl.vulkan.VK13.vkWaitForFences;
|
||||
import static org.lwjgl.vulkan.VK13.vkDestroyFence;
|
||||
import static org.lwjgl.vulkan.VK13.VK_FENCE_CREATE_SIGNALED_BIT;
|
||||
import static org.lwjgl.vulkan.VK13.vkCreateFence;
|
||||
|
||||
public class Fence {
|
||||
//To Be Completed Later
|
||||
private final long VulkanFence;
|
||||
public Fence(VulkanContext vulkanContext, boolean Signaled){
|
||||
try(var MemStack = MemoryStack.stackPush()){
|
||||
var VulkanFenceCreateInfo = VkFenceCreateInfo.calloc(MemStack)
|
||||
.sType$Default()
|
||||
.flags(Signaled ? VK_FENCE_CREATE_SIGNALED_BIT : 0);
|
||||
LongBuffer LongPointers = MemStack.mallocLong(1);
|
||||
vkCheck(vkCreateFence(vulkanContext.GetDevice().FetchVulkanDevice(),VulkanFenceCreateInfo, null, LongPointers),"Failed to create Vulkan Fence");
|
||||
VulkanFence = LongPointers.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup(VulkanContext vulkanContext){
|
||||
vkDestroyFence(vulkanContext.GetDevice().FetchVulkanDevice(), VulkanFence, null);
|
||||
}
|
||||
|
||||
public void FenceWait(VulkanContext vulkanContext){
|
||||
vkWaitForFences(vulkanContext.GetDevice().FetchVulkanDevice(), VulkanFence,true,Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public long GetVulkanFence(){
|
||||
return VulkanFence;
|
||||
}
|
||||
|
||||
public void Reset(VulkanContext vulkanContext){
|
||||
vkResetFences(vulkanContext.GetDevice().FetchVulkanDevice(), VulkanFence);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,30 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.GPUSynchronisation;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Logic.VulkanContext;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.vulkan.VkSemaphoreCreateInfo;
|
||||
|
||||
import java.nio.LongBuffer;
|
||||
|
||||
import static net.halbear.Terrain4J.EngineCore.Vulkan.Util.VulkanUtils.vkCheck;
|
||||
import static org.lwjgl.vulkan.VK13.vkCreateSemaphore;
|
||||
import static org.lwjgl.vulkan.VK13.vkDestroySemaphore;
|
||||
|
||||
public class Semaphore {
|
||||
//To Be Completed Later
|
||||
private final long VulkanSemaphore;
|
||||
public Semaphore(VulkanContext vulkanContext){
|
||||
try(var MemStack = MemoryStack.stackPush()){
|
||||
var SemaphoreCreateInfo = VkSemaphoreCreateInfo.calloc(MemStack).sType$Default();
|
||||
LongBuffer LongPointers = MemStack.mallocLong(1);
|
||||
vkCheck(vkCreateSemaphore(vulkanContext.GetDevice().FetchVulkanDevice(), SemaphoreCreateInfo, null, LongPointers),"Failed to Create Semaphore");
|
||||
VulkanSemaphore = LongPointers.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup(VulkanContext vulkanContext){
|
||||
vkDestroySemaphore(vulkanContext.GetDevice().FetchVulkanDevice(), VulkanSemaphore, null);
|
||||
}
|
||||
public long GetSemaphore(){
|
||||
return VulkanSemaphore;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DisplayToScreen;
|
||||
|
||||
public class SceneRender {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue