Wrapped up graphics Queues
This commit is contained in:
parent
20d0867755
commit
015c5aaa84
3 changed files with 40 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ import net.halbear.Terrain4J.EngineCore.Logic.VulkanContext;
|
|||
public class Render {
|
||||
private final VulkanContext RendererContext;
|
||||
public Render(EngineInstance engineInstance) {
|
||||
RendererContext = new VulkanContext();
|
||||
RendererContext = new VulkanContext(engineInstance.window());
|
||||
}
|
||||
public void cleanup() {
|
||||
RendererContext.cleanup();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package net.halbear.Terrain4J.EngineCore.Logic;
|
||||
|
||||
import net.halbear.Terrain4J.EngineCore.Display.Window;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.Device;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Structure.DeviceLayers.PhysicalDevice;
|
||||
import net.halbear.Terrain4J.EngineCore.Vulkan.Structure.Surface;
|
||||
|
|
@ -11,11 +12,12 @@ public class VulkanContext {
|
|||
private Surface surface;
|
||||
private final PhysicalDevice PhysDevice;
|
||||
|
||||
public VulkanContext(){
|
||||
public VulkanContext(Window window){
|
||||
var EngineGlobals = EngineConfig.getInstance();
|
||||
Instance = new VulkanInstance(EngineGlobals.VkValidated());
|
||||
PhysDevice = PhysicalDevice.createPhysicalDevice(Instance,EngineGlobals.getPhysDeviceName());
|
||||
|
||||
PhysDevice = PhysicalDevice.createPhysicalDevice(Instance,EngineGlobals.GetPhysicalDeviceName());
|
||||
device = new Device(PhysDevice);
|
||||
surface = new Surface(Instance, PhysDevice, window);
|
||||
}
|
||||
|
||||
public void cleanup(){
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import net.halbear.Terrain4J.EngineCore.Logic.VulkanContext;
|
|||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.vulkan.VkQueue;
|
||||
import org.lwjgl.vulkan.VkQueueFamilyProperties;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
import static org.lwjgl.vulkan.VK13.*;
|
||||
|
|
@ -23,4 +24,37 @@ public class Queue {
|
|||
VulkanQueue = new VkQueue(Queue, vkContext.GetDevice().FetchVulkanDevice());
|
||||
}
|
||||
}
|
||||
public int GetQueueFamilyIndex(){
|
||||
return QueueFamilyIndex;
|
||||
}
|
||||
public VkQueue GetVulkanQueue(){
|
||||
return VulkanQueue;
|
||||
}
|
||||
public void WaitIdle(){
|
||||
vkQueueWaitIdle(VulkanQueue);
|
||||
}
|
||||
|
||||
public static class GraphicsQueue extends Queue {
|
||||
public GraphicsQueue(VulkanContext vulkanContext, int QueueIndex){
|
||||
super(vulkanContext, GetGraphicsQueueFamilyIndex(vulkanContext),QueueIndex);
|
||||
}
|
||||
private static int GetGraphicsQueueFamilyIndex(VulkanContext vulkanContext){
|
||||
int index = -1;
|
||||
var QueuePropertiesBuffer = vulkanContext.GetPhysicalDevice().GetQueueFamilyProperties();
|
||||
int QueueFamilyCount = QueuePropertiesBuffer.capacity();
|
||||
for(int i = 0; i < QueueFamilyCount; i++){
|
||||
VkQueueFamilyProperties Properties = QueuePropertiesBuffer.get(i);
|
||||
boolean GraphicsQueue = (Properties.queueFlags() & VK_QUEUE_GRAPHICS_BIT)!= 0;
|
||||
if (GraphicsQueue){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < 0){
|
||||
throw new RuntimeException("Failed to fetch graphics queue family");
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue