Skip to content

Commit

Permalink
Added vulkanite define
Browse files Browse the repository at this point in the history
  • Loading branch information
MCRcortex committed Sep 14, 2023
1 parent 72a1bb2 commit 58cc965
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ public static void add(long handleDescriptor) {
}

public static void close(long handleDescriptor) {
boolean shouldClose = false;
synchronized (USED_HANDLE_DESCRIPTORS) {
shouldClose = USED_HANDLE_DESCRIPTORS.addTo(handleDescriptor, -1) == 1;
}
if (shouldClose) {
synchronized (USED_HANDLE_DESCRIPTORS) {
USED_HANDLE_DESCRIPTORS.remove(handleDescriptor);
int val = USED_HANDLE_DESCRIPTORS.addTo(handleDescriptor, -1);
if (val <= 0) {
throw new IllegalStateException();
}
if (Vulkanite.IS_WINDOWS) {
Kernel32.INSTANCE.CloseHandle(new WinNT.HANDLE(new Pointer(handleDescriptor)));
} else {
LibC.INSTANCE.close((int) handleDescriptor);
if (val == 1) {
USED_HANDLE_DESCRIPTORS.remove(handleDescriptor);
if (Vulkanite.IS_WINDOWS) {
if (!Kernel32.INSTANCE.CloseHandle(new WinNT.HANDLE(new Pointer(handleDescriptor)))) {
throw new IllegalStateException();
}
} else {
if (LibC.INSTANCE.close((int) handleDescriptor) != 0) {
throw new IllegalStateException();
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package me.cortex.vulkanite.mixin.iris;

import net.coderbot.iris.gl.shader.StandardMacros;
import net.coderbot.iris.shaderpack.StringPair;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import java.util.ArrayList;

@Mixin(value = StandardMacros.class, remap = false)
public class MixinStandardMacros {
@Inject(method = "createStandardEnvironmentDefines", at = @At(value = "INVOKE", target = "Lnet/coderbot/iris/gl/shader/StandardMacros;define(Ljava/util/List;Ljava/lang/String;)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
private static void injectVulkaniteDefine(CallbackInfoReturnable<Iterable<StringPair>> cir, ArrayList<StringPair> defines) {
defines.add(new StringPair("VULKANITE", ""));
}
}
11 changes: 5 additions & 6 deletions src/main/resources/vulkanite.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"iris.MixinPBRAtlasTexture",
"iris.MixinProgramSet",
"iris.MixinRenderTarget",
"iris.MixinPackRenderTargetDirectives",
"iris.MixinStandardMacros",
"iris.MixinShaderPackSourceNames",
"minecraft.MixinAbstractTexture",
"minecraft.MixinMinecraftClient",
Expand All @@ -21,13 +23,10 @@
"sodium.gl.MixinCommandList",
"sodium.gl.MixinGlBufferArena",
"sodium.gl.MixinGLRenderDevice",
"sodium.gl.MixinMutableBuffer"
"sodium.gl.MixinMutableBuffer",
"sodium.PendingSectionUploadAccessor"
],
"injectors": {
"defaultRequire": 1
},
"mixins": [
"iris.MixinPackRenderTargetDirectives",
"sodium.PendingSectionUploadAccessor"
]
}
}

0 comments on commit 58cc965

Please sign in to comment.