Skip to content

Commit

Permalink
Add VkbQueueFamily.first() method
Browse files Browse the repository at this point in the history
  • Loading branch information
knokko committed Aug 20, 2024
1 parent 005945d commit 2a7970c
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ while (renderLoop) {

// Do something (probably wait on some fence and start rendering)

boiler.queueFamilies().graphics().queues().get(0).submit(
boiler.queueFamilies().graphics().first().submit(
commandBuffer, "RingApproximation", waitSemaphores,
fence, swapchainImage.presentSemaphore()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public static void main(String[] args) throws InterruptedException {
vkCmdEndRenderPass(commandBuffer);
assertVkSuccess(vkEndCommandBuffer(commandBuffer), "TriangleDrawing", null);

var renderSubmission = boiler.queueFamilies().graphics().queues().get(0).submit(
var renderSubmission = boiler.queueFamilies().graphics().first().submit(
commandBuffer, "SubmitDraw", waitSemaphores, fence, swapchainImage.presentSemaphore()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ protected void recordRenderCommands(

@Override
protected void submitAndWaitRender() {
xr.boilerInstance.queueFamilies().graphics().queues().get(0).submit(
commandBuffer, "Drawing", new WaitSemaphore[0], fence
xr.boilerInstance.queueFamilies().graphics().first().submit(
commandBuffer, "Drawing", null, fence
);

fence.waitAndReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected AwaitableSubmission renderFrame(

recorder.end();

return boiler.queueFamilies().graphics().queues().get(0).submit(
return boiler.queueFamilies().graphics().first().submit(
commandBuffer, "RingApproximation", waitSemaphores, fence, swapchainImage.presentSemaphore()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private static VkbImage[] createHeightImages(BoilerInstance boiler) {
);
recorder.end();

boiler.queueFamilies().graphics().queues().get(0).submit(
boiler.queueFamilies().graphics().first().submit(
commandBuffer, "CopyHeightImage", new WaitSemaphore[0], fence
);
fence.awaitSignal();
Expand Down Expand Up @@ -630,9 +630,9 @@ class CameraController {
recorder.end();

var timelineFinished = new TimelineInstant(timeline, frameCounter + numFramesInFlight);
boiler.queueFamilies().graphics().queues().get(0).submit(
boiler.queueFamilies().graphics().first().submit(
commandBuffer, "TerrainDraw", waitSemaphores, null,
new long[]{swapchainImage.presentSemaphore()}, null, timelineFinished
new long[]{ swapchainImage.presentSemaphore() }, null, timelineFinished
);

boiler.window().presentSwapchainImage(swapchainImage, timelineFinished);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
import java.util.List;

public record VkbQueueFamily(int index, List<VkbQueue> queues) {
// TODO Create convenience method to submit/present to the first queue

public VkbQueue first() {
return queues.get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected AwaitableSubmission renderFrame(
recordFrame(stack, recorder, acquiredImage, instance);
recorder.end();

return instance.queueFamilies().graphics().queues().get(0).submit(
return instance.queueFamilies().graphics().first().submit(
commandBuffer, "Fill", waitSemaphores, fence, acquiredImage.presentSemaphore()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void presentImage(AcquiredImage image, AwaitableSubmission renderSubmission) {
cleaner.beforePresent(stack, presentInfo, image);


int presentResult = presentFamily.queues().get(0).present(presentInfo);
int presentResult = presentFamily.first().present(presentInfo);
if (presentResult == VK_ERROR_OUT_OF_DATE_KHR || presentResult == VK_SUBOPTIMAL_KHR) {
outdated = true;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/knokko/boiler/xr/SessionLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void run() {
|| this.state == XR_SESSION_STATE_EXITING || this.state == XR_SESSION_STATE_LOSS_PENDING
) {
assertXrSuccess(vkQueueWaitIdle(
xr.boilerInstance.queueFamilies().graphics().queues().get(0).vkQueue()
xr.boilerInstance.queueFamilies().graphics().first().vkQueue()
), "QueueWaitIdle", "End of last frame");
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void testBufferCopies() {

recorder.end();

instance.queueFamilies().graphics().queues().get(0).submit(
commandBuffer, "Copying", new WaitSemaphore[0], fence
instance.queueFamilies().graphics().first().submit(
commandBuffer, "Copying", null, fence
);
fence.awaitSignal();
instance.sync.fenceBank.returnFence(fence);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testCopyImage() {

recorder.end("Copying");

instance.queueFamilies().graphics().queues().get(0).submit(commandBuffer, "Copying", null, fence);
instance.queueFamilies().graphics().first().submit(commandBuffer, "Copying", null, fence);
fence.waitAndReset();

assertEquals((byte) 0, memGetByte(destBuffer.hostAddress()));
Expand Down Expand Up @@ -157,7 +157,7 @@ public void testBlitImage() {
hostBuffer.put(index + 3, (byte) 255);
}

instance.queueFamilies().graphics().queues().get(0).submit(commandBuffer, "Copying", null, fence);
instance.queueFamilies().graphics().first().submit(commandBuffer, "Copying", null, fence);
fence.waitAndReset();

// So the blitted pixel should be (25, 0, 50, 255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testSimpleComputeShader() {

assertVkSuccess(vkEndCommandBuffer(commandBuffer), "EndCommandBuffer", "Filling");
long startTime = System.currentTimeMillis();
instance.queueFamilies().graphics().queues().get(0).submit(
instance.queueFamilies().graphics().first().submit(
commandBuffer, "Filling", new WaitSemaphore[0], fence
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void testWriteImage() {
vkCmdDispatch(commandBuffer, 1, 1, 1);

assertVkSuccess(vkEndCommandBuffer(commandBuffer), "EndCommandBuffer", "Sampling");
instance.queueFamilies().graphics().queues().get(0).submit(
instance.queueFamilies().graphics().first().submit(
commandBuffer, "Sampling", null, fence
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void testDynamicColorRendering(int apiVersion) {
recorder.copyImageToBuffer(VK_IMAGE_ASPECT_COLOR_BIT, image.vkImage(), width, height, destBuffer.vkBuffer());

recorder.end();
instance.queueFamilies().graphics().queues().get(0).submit(commandBuffer, "Test", null, fence);
instance.queueFamilies().graphics().first().submit(commandBuffer, "Test", null, fence);
fence.waitAndReset();

assertEquals((byte) 255, memGetByte(destBuffer.hostAddress()));
Expand Down Expand Up @@ -191,7 +191,7 @@ public void testDynamicDepthAttachment() {
recorder.copyImageToBuffer(VK_IMAGE_ASPECT_DEPTH_BIT, image.vkImage(), width, height, destBuffer.vkBuffer());

recorder.end();
instance.queueFamilies().graphics().queues().get(0).submit(
instance.queueFamilies().graphics().first().submit(
commandBuffer, "DepthSubmission", null, fence
);
fence.waitAndReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ private void signalFence(BoilerInstance instance, VkbFence fence) {
var commands = CommandRecorder.begin(commandBuffer, instance, stack, "Signal");
commands.end();

instance.queueFamilies().graphics().queues().get(0).submit(
commandBuffer, "Signal", new WaitSemaphore[0], fence
instance.queueFamilies().graphics().first().submit(
commandBuffer, "Signal", null, fence
);
fence.awaitSignal();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void emptySubmission(BoilerInstance instance, VkbFence fence) {
emptySubmitInfo.sType$Default();

assertVkSuccess(vkQueueSubmit(
instance.queueFamilies().compute().queues().get(0).vkQueue(), emptySubmitInfo, fence.getVkFenceAndSubmit()
instance.queueFamilies().compute().first().vkQueue(), emptySubmitInfo, fence.getVkFenceAndSubmit()
), "QueueSubmit", "test");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private void testTimelineSemaphores(BoilerInstance instance) throws InterruptedE
var commandBuffer = instance.commands.createPrimaryBuffers(commandPool, 1, "TestBuffers")[0];
CommandRecorder.begin(commandBuffer, instance, stack, "TestRecording").end();

instance.queueFamilies().graphics().queues().get(0).submit(
commandBuffer, "TestTimeline", new WaitSemaphore[0], fence, new long[0],
instance.queueFamilies().graphics().first().submit(
commandBuffer, "TestTimeline", null, fence, null,
new WaitTimelineSemaphore[]{
new WaitTimelineSemaphore(semaphore.vkSemaphore, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 2)
}, new TimelineInstant(semaphore, 5)
Expand Down

0 comments on commit 2a7970c

Please sign in to comment.