Skip to content

Commit

Permalink
Add GigaBarriers debugging option
Browse files Browse the repository at this point in the history
  • Loading branch information
thr3343 committed Nov 25, 2023
1 parent e018762 commit 97e8a72
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ org.gradle.jvmargs=-Xmx3G
fabric_version=0.89.0+1.20.2

# Mod Properties
mod_version = 0.3.6-pre_dev_experimental_UNSTABLE_V13
mod_version = 0.3.6-pre_dev_Unofficial_UNSTABLE_V13
maven_group = net.vulkanmod
archives_base_name = VulkanMod_1.20.2
1 change: 1 addition & 0 deletions src/main/java/net/vulkanmod/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Config {
public boolean indirectDraw = false;
public boolean uniqueOpaqueLayer = true;
public boolean perRenderTypeAreaBuffers = !VideoResolution.isAndroid();
public boolean useGigaBarriers = false;
public boolean renderSky = true;
public boolean entityCulling = true;
public boolean animations = true;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/net/vulkanmod/config/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ Enable Gui optimizations (Stats bar, Chat, Debug Hud)
Improves GPU Performance
But increases VRAM Usage slightly
May vary on System and/or GPU configuration""")),
new SwitchOption("GigaBarriers",
value -> {
config.useGigaBarriers = value;
},
() -> config.useGigaBarriers).setTooltip(Component.nullToEmpty("""
(Debugging feature)
Only Use to fix/troubleshoot game-breaking bugs/crashes
Greatly decreases performance if enabled""")),
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.vulkanmod.Initializer;
import net.vulkanmod.render.chunk.util.StaticQueue;
import net.vulkanmod.vulkan.*;
import net.vulkanmod.vulkan.memory.StagingBuffer;
import net.vulkanmod.vulkan.queue.CommandPool;

import net.vulkanmod.vulkan.queue.QueueFamilyIndices;
import org.lwjgl.system.MemoryStack;

import java.nio.ByteBuffer;
Expand Down Expand Up @@ -79,7 +79,8 @@ public synchronized void submitUploads(boolean b) {
TransferQueue.uploadBufferCmds(this.commandBuffers[currentFrame], stagingBufferId, bufferHandle, vkBufferCopies);
}

TransferQueue.GigaBarrier2(this.commandBuffers[currentFrame].getHandle(), stack, this.hasBufferSwap);
if(!Initializer.CONFIG.useGigaBarriers) TransferQueue.UploadCmdWriteBarrier(this.commandBuffers[currentFrame].getHandle(), stack, this.hasBufferSwap);
else TransferQueue.GigaBarrier(this.commandBuffers[currentFrame].getHandle());
this.hasBufferSwap=false;
}
dstBuffers.clear();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/vulkanmod/render/chunk/WorldRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.vulkanmod.vulkan.memory.Buffer;
import net.vulkanmod.vulkan.memory.IndirectBuffer;
import net.vulkanmod.vulkan.memory.MemoryTypes;
import net.vulkanmod.vulkan.queue.Queue;
import org.joml.FrustumIntersection;
import org.joml.Matrix4f;
import org.lwjgl.vulkan.VkCommandBuffer;
Expand Down Expand Up @@ -608,7 +609,6 @@ else if(terrainRenderType.equals(TRANSLUCENT))
if(!isTranslucent) Renderer.getDrawer().bindAutoIndexBuffer(commandBuffer, 7);
terrainRenderType.setCutoutUniform();
terrainShader.bindDescriptorSets(commandBuffer, currentFrame);

Iterator<DrawBuffers> iterator = this.drawBufferSetQueue.iterator(isTranslucent);
while(iterator.hasNext()) {
DrawBuffers chunkArea = iterator.next();
Expand All @@ -628,7 +628,6 @@ else if(terrainRenderType.equals(TRANSLUCENT))
p.pop();



this.minecraft.getProfiler().pop();
renderType.clearRenderState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.vulkanmod.vulkan.Vulkan;
import net.vulkanmod.vulkan.framebuffer.Framebuffer;
import net.vulkanmod.vulkan.framebuffer.SwapChain;
import net.vulkanmod.vulkan.queue.Queue;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.vulkan.VkCommandBuffer;
import org.lwjgl.vulkan.VkRect2D;
Expand All @@ -20,7 +21,7 @@ public class DefaultMainPass implements MainPass {
public void begin(VkCommandBuffer commandBuffer, MemoryStack stack) {
SwapChain swapChain = Vulkan.getSwapChain();
// swapChain.colorAttachmentLayout(stack, commandBuffer, Renderer.getCurrentImage());

Queue.GraphicsQueue.GigaBarrier(commandBuffer);
swapChain.beginRenderPass(commandBuffer, stack);
// Renderer.clearAttachments(0x4100, swapChain.getWidth(), swapChain.getHeight());
// Framebuffer framebuffer = this.hdrFinalFramebuffer;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void end(VkCommandBuffer commandBuffer) {
// DrawUtil.drawFramebuffer(this.blitGammaShader, this.hdrFinalFramebuffer.getColorAttachment());

Framebuffer.endRenderPass(commandBuffer);

Queue.GraphicsQueue.GigaBarrier(commandBuffer);
// try(MemoryStack stack = MemoryStack.stackPush()) {
// Vulkan.getSwapChain().presentLayout(stack, commandBuffer, Renderer.getCurrentImage());
// }
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/vulkanmod/vulkan/queue/Queue.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.vulkanmod.vulkan.queue;

import net.vulkanmod.Initializer;
import net.vulkanmod.vulkan.Device;
import net.vulkanmod.vulkan.Synchronization;
import net.vulkanmod.vulkan.Vulkan;
Expand Down Expand Up @@ -187,7 +188,7 @@ public void GigaBarrier(CommandPool.CommandBuffer commandBuffer, MemoryStack sta
null);
}

public void GigaBarrier2(VkCommandBuffer handle, MemoryStack stack, boolean resize) {
public void UploadCmdWriteBarrier(VkCommandBuffer handle, MemoryStack stack, boolean resize) {

VkMemoryBarrier.Buffer memBarrier = VkMemoryBarrier.calloc(2, stack);

Expand Down Expand Up @@ -217,8 +218,8 @@ public void GigaBarrier2(VkCommandBuffer handle, MemoryStack stack, boolean resi
null);

}
public void GigaBarrier(CommandPool.CommandBuffer commandBuffer) {

public void GigaBarrier(VkCommandBuffer commandBuffer) {
if(!Initializer.CONFIG.useGigaBarriers) return;
try(MemoryStack stack = MemoryStack.stackPush()) {
VkMemoryBarrier.Buffer memBarrier = VkMemoryBarrier.calloc(1, stack);

Expand All @@ -232,7 +233,7 @@ public void GigaBarrier(CommandPool.CommandBuffer commandBuffer) {
//When Not resizing, Wait on prior Writes Depending on these Writes
// + wait on terrain Shader Vertex+Index reads depending on last CmdBuffer's Writes
vkCmdPipelineBarrier(
commandBuffer.getHandle(),
commandBuffer,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "vulkanmod",
"version": "0.3.6-pre_dev_experimental_UNSTABLE_V13",
"version": "0.3.6-pre_dev_Unofficial_UNSTABLE_V13",

"name": "VulkanMod",
"description": "Bring Vulkan to Minecraft!",
Expand Down

0 comments on commit 97e8a72

Please sign in to comment.