Skip to content

Commit

Permalink
dont use mojang's pair
Browse files Browse the repository at this point in the history
and a couple other things
  • Loading branch information
RogueLogix committed Oct 22, 2023
1 parent 15dbadd commit 3abc380
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

import java.nio.LongBuffer;

import static com.sun.jna.Native.LONG_SIZE;
import static com.sun.jna.Native.POINTER_SIZE;
import static net.roguelogix.biggerreactors.multiblocks.reactor.simulation.accellerated.vk.VkPools.allocCommandBuffer;
import static net.roguelogix.biggerreactors.multiblocks.reactor.simulation.accellerated.vk.VkPools.freeCommandBufferNow;
import static net.roguelogix.biggerreactors.multiblocks.reactor.simulation.accellerated.vk.VkUtil.*;
import static org.lwjgl.system.MemoryUtil.memGetAddress;
import static org.lwjgl.system.MemoryUtil.memPutAddress;
import static org.lwjgl.system.MemoryUtil.memPutLong;
import static org.lwjgl.vulkan.VK13.*;

@NonnullDefault
Expand Down Expand Up @@ -505,16 +503,16 @@ private void waitSemaphore() {
}

@Override
protected void finalize() throws Throwable {
protected void finalize() {
waitSemaphore();
}

public void addSemaphoreToWaitInto(VkSemaphoreWaitInfo waitInfo, int index) {
var structAddress = waitInfo.address();
var semaphoresPointer = memGetAddress(structAddress + VkSemaphoreWaitInfo.PSEMAPHORES);
var valuesPointer = memGetAddress(structAddress + VkSemaphoreWaitInfo.PVALUES);
memPutAddress(semaphoresPointer + ((long) index * POINTER_SIZE), semaphorePointer.get(0));
memPutAddress(valuesPointer + ((long) index * LONG_SIZE), semaphoreWaitValuePointer.get(0));
memPutLong(semaphoresPointer + ((long) index * 8), semaphorePointer.get(0));
memPutLong(valuesPointer + ((long) index * 8), semaphoreWaitValuePointer.get(0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.roguelogix.biggerreactors.multiblocks.reactor.simulation.accellerated.vk;

import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
import net.roguelogix.phosphophyllite.util.NonnullDefault;
import net.roguelogix.phosphophyllite.util.Pair;
import net.roguelogix.quartz.internal.util.PointerWrapper;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryStack;
Expand Down Expand Up @@ -134,19 +134,19 @@ private Info attemptAllocInSpace(Info freeAlloc, long size, long alignment) {
if (alignmentWaste > 0) {
final var newAllocs = freeAlloc.split(alignmentWaste);
// not concurrent modification because this will always return
freeAllocations.add(newAllocs.getFirst());
freeAlloc = newAllocs.getSecond();
freeAllocations.add(newAllocs.first);
freeAlloc = newAllocs.second;

int index = freeAllocations.indexOf(newAllocs.getFirst());
int index = freeAllocations.indexOf(newAllocs.first);
collapseFreeAllocationWithNext(index - 1);
collapseFreeAllocationWithNext(index);
}
if (freeAlloc.size > size) {
final var newAllocs = freeAlloc.split(size);
// not concurrent modification because this will always return
freeAlloc = newAllocs.getFirst();
freeAllocations.add(newAllocs.getSecond());
int index = freeAllocations.indexOf(newAllocs.getSecond());
freeAlloc = newAllocs.first;
freeAllocations.add(newAllocs.second);
int index = freeAllocations.indexOf(newAllocs.second);
collapseFreeAllocationWithNext(index - 1);
collapseFreeAllocationWithNext(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ public static int checkVkResult(int returnCode) {
return returnCode;
}

public static boolean canThreadSubmit(){
return roundRobinQueues || threadQueueIndex.get() != -1;
}

public static void queueSubmit(VkSubmitInfo2.Buffer submitInfos) {
final int queueIndex;
if (roundRobinQueues) {
Expand All @@ -454,7 +458,7 @@ public static void queueSubmit(VkSubmitInfo2.Buffer submitInfos) {
} else {
queueIndex = threadQueueIndex.get();
if (queueIndex == -1) {
throw new VulkanException("No queue aquired for thread");
throw new VulkanException("No queue acquired for thread");
}
}
vkQueueSubmit2(queues.get(queueIndex), submitInfos, VK_NULL_HANDLE);
Expand Down

0 comments on commit 3abc380

Please sign in to comment.