From b39cf1d367861ec954d36225000b5778234ed4b5 Mon Sep 17 00:00:00 2001 From: ZhuRuoLing Date: Tue, 22 Sep 2026 06:58:16 +0800 Subject: [PATCH 1/3] feat(rendering): add alrUseIntelBindlessImageArrayWorkaround --- module.gradle | 1 + .../lib/v2/rendering/ALROptions.java | 27 ++++++- .../shader/ALRComputeProgramInstance.java | 2 + .../bindless/GlBindlessTexturingSupport.java | 72 +++++++++++++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) diff --git a/module.gradle b/module.gradle index 29e4d03a..011bacc2 100644 --- a/module.gradle +++ b/module.gradle @@ -53,6 +53,7 @@ neoForge { systemProperty('neoforge.enabledGameTestNamespaces', project.mod_id) systemProperty('neoforge.enabledGameTestNamespaces', project.mod_id) systemProperty("alrEnableDebugContext", "true") + systemProperty("alrUseIntelBindlessImageArrayWorkaround", "2") jvmArgument("-XX:+UseParallelGC") jvmArgument("-XX:+UnlockDiagnosticVMOptions") jvmArgument("-XX:+DebugNonSafepoints") diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java index 9f811f83..ebd21d95 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java @@ -11,13 +11,24 @@ public class ALROptions { public static final String OCCLUSION_CULLING_FORCE_IMPL = getProperty("alrOcclusionCullingForceImplementation", null); public static final boolean TEXTURE_DEBUG_CLEAR = getPropertyBoolean("alrTextureDebugClear", false); public static final boolean DEBUG_CONTEXT = getPropertyBoolean("alrEnableDebugContext", false); + /// 0 -> default implementation + /// + /// 1 -> use alrBindTextureHandleMultipleIntel, query each of the array element location and set them separately + /// + /// 2 -> use alrBindTextureHandleMultipleIntelBaseLocation, query the location of array uniform as base location and set each element separately + /// + /// 3 -> use alrBindTextureHandleMultipleIntelPadded, pads the input array + /// + /// Option 0 and 2 works on NVIDIA + public static final int USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND = getPropertyInt("alrUseIntelBindlessImageArrayWorkaround", 0); public static void logAllOptions() { - log.info("ALR options: SPD_OPTION_WAVE_INTEROP_LDS={}, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS={}, OCCLUSION_CULLING_FORCE_IMPL={}, TEXTURE_DEBUG_CLEAR={}", + log.info("ALR options: SPD_OPTION_WAVE_INTEROP_LDS={}, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS={}, OCCLUSION_CULLING_FORCE_IMPL={}, TEXTURE_DEBUG_CLEAR={}, USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND={}", SPD_OPTION_WAVE_INTEROP_LDS, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS, OCCLUSION_CULLING_FORCE_IMPL, - TEXTURE_DEBUG_CLEAR + TEXTURE_DEBUG_CLEAR, + USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND ); } @@ -33,6 +44,18 @@ private static boolean getPropertyBoolean(String key, boolean defaultValue) { return !"false".equals(prop); } + private static int getPropertyInt(String key, int defaultValue) { + String prop = System.getProperty(key); + if (prop == null) { + return defaultValue; + } + try { + return Integer.parseInt(prop); + } catch (NumberFormatException ignored) { + return defaultValue; + } + } + private static boolean getPropertyBoolean(String key) { String prop = System.getProperty(key); return !"false".equals(prop); diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/compute/shader/ALRComputeProgramInstance.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/compute/shader/ALRComputeProgramInstance.java index db32b3b7..b07d1dcb 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/compute/shader/ALRComputeProgramInstance.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/compute/shader/ALRComputeProgramInstance.java @@ -47,6 +47,8 @@ public int getUniformLocation(String name, ALRGpuDeviceBackendExtension device) int orDefault = this.uniformLocationCache.getOrDefault(name, -2); if (orDefault == -2){ orDefault = device.alrGetUniformLocation(this, owner, name); + System.out.println("uniformName = " + name); + System.out.println("uniformLocation = " + orDefault); this.uniformLocationCache.put(name, orDefault); } return orDefault; diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java index 02e049f2..dca2fa4d 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.textures.GpuSampler; import com.mojang.blaze3d.textures.GpuTexture; +import dev.anvilcraft.lib.v2.rendering.ALROptions; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRGpuDeviceBackendExtension; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.NamedUniformAccess; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.texture.ExtendedGpuTexture; @@ -17,7 +18,10 @@ import org.jetbrains.annotations.ApiStatus; import org.lwjgl.opengl.ARBBindlessTexture; import org.lwjgl.opengl.GL46; +import org.lwjgl.system.MemoryStack; +import org.lwjgl.system.MemoryUtil; +import java.nio.LongBuffer; import java.util.List; @ApiStatus.Internal @@ -126,6 +130,23 @@ public void alrBindTextureHandleMultiple( String name, List handle ) { + if (!handle.isEmpty() && handle.stream().noneMatch(TextureHandle::isTexture)) { + switch (ALROptions.USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND) { + case 1 -> { + this.alrBindTextureHandleMultipleIntel(namedUniformAccess, name, handle); + return; + } + case 2 -> { + this.alrBindTextureHandleMultipleIntelBaseLocation(namedUniformAccess, name, handle); + return; + } + case 3 -> { + this.alrBindTextureHandleMultipleIntelPadded(namedUniformAccess, name, handle); + return; + } + } + } + int uniformLocation = namedUniformAccess.getUniformLocation(name, this.backendExtension); long[] handles = new long[handle.size()]; @@ -137,6 +158,57 @@ public void alrBindTextureHandleMultiple( ARBBindlessTexture.glUniformHandleui64vARB(uniformLocation, handles); } + /// Windows intel drivers has the wrong implementation of `glUniformHandleui64vARB` + /// + /// It reads the input `GLuint64 const *` using a 16 bytes stride instead of 8 bytes + /// + /// So query each of the array element location and set them separately may fix the segfault + private void alrBindTextureHandleMultipleIntel( + NamedUniformAccess namedUniformAccess, + String name, + List handle + ) { + int i = 0; + for (TextureHandle textureHandle : handle) { + String uniformName = name + "[" + i++ + "]"; + int uniformLocation = namedUniformAccess.getUniformLocation(uniformName, this.backendExtension); + ARBBindlessTexture.glUniformHandleui64ARB(uniformLocation, handleId(textureHandle)); + } + } + + /// Query the location of array uniform as base location and set each element separately + private void alrBindTextureHandleMultipleIntelBaseLocation( + NamedUniformAccess namedUniformAccess, + String name, + List handle + ) { + int i = 0; + int locationStart = namedUniformAccess.getUniformLocation(name, this.backendExtension); + for (TextureHandle textureHandle : handle) { + ARBBindlessTexture.glUniformHandleui64ARB(locationStart + i++, handleId(textureHandle)); + } + } + + /// Pads the input array + private void alrBindTextureHandleMultipleIntelPadded( + NamedUniformAccess namedUniformAccess, + String name, + List handle + ) { + int uniformLocation = namedUniformAccess.getUniformLocation(name, this.backendExtension); + + try (MemoryStack stack = MemoryStack.stackPush()){ + int count = handle.size(); + LongBuffer padded = stack.mallocLong(count * 2); + for (int i = 0; i < count; i++) { + padded.put(i * 2, handleId(handle.get(i))); + padded.put(i * 2 + 1, handleId(handle.get(i))); + } + + ARBBindlessTexture.nglUniformHandleui64vARB(uniformLocation, count, MemoryUtil.memAddress(padded)); + } + } + @SuppressWarnings("resource") @Override public void alrTextureDisposed(GpuTexture texture) { From dd54d1633dae8ef63a34ffdc5a5199864e9b747e Mon Sep 17 00:00:00 2001 From: ZhuRuoLing Date: Tue, 22 Sep 2026 07:10:15 +0800 Subject: [PATCH 2/3] feat(rendering): disable alr$isWindowsArcGraphics --- .../lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java index 6eb92631..e68b8fa1 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java @@ -145,7 +145,9 @@ public ALRHICapabilities alrhiCreateCapabilities() { @Override public ALRHIHeuristics alrhiCreateHeuristics() { if (this.alr$heuristics == null) { - this.alr$heuristics = new ALRHIHeuristics(this.alr$isWindowsArcGraphics()); +// this.alr$heuristics = new ALRHIHeuristics(this.alr$isWindowsArcGraphics()); + // TODO: temporary return false as we need to test the workarounds + this.alr$heuristics = new ALRHIHeuristics(false); } return this.alr$heuristics; } From 860814687777235ab40b1708d4eaf93715bd0e6a Mon Sep 17 00:00:00 2001 From: ZhuRuoLing Date: Tue, 22 Sep 2026 18:48:07 +0800 Subject: [PATCH 3/3] feat(rendering): implement intel workaround --- module.gradle | 2 +- .../lib/v2/rendering/ALROptions.java | 18 +++------- .../extension/blaze3d/ALRHIHeuristics.java | 2 +- .../bindless/GlBindlessTexturingSupport.java | 32 ++++++----------- .../mixins/blaze3d/gl/GlDeviceMixin.java | 34 ++++++------------- .../occlusion/hiz/HierarchicalZSupport.java | 11 +++--- 6 files changed, 33 insertions(+), 66 deletions(-) diff --git a/module.gradle b/module.gradle index 011bacc2..b247db82 100644 --- a/module.gradle +++ b/module.gradle @@ -53,7 +53,7 @@ neoForge { systemProperty('neoforge.enabledGameTestNamespaces', project.mod_id) systemProperty('neoforge.enabledGameTestNamespaces', project.mod_id) systemProperty("alrEnableDebugContext", "true") - systemProperty("alrUseIntelBindlessImageArrayWorkaround", "2") + // systemProperty("alrUseIntelBindlessImageArrayWorkaround", "2") jvmArgument("-XX:+UseParallelGC") jvmArgument("-XX:+UnlockDiagnosticVMOptions") jvmArgument("-XX:+DebugNonSafepoints") diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java index ebd21d95..2f286aef 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/ALROptions.java @@ -11,24 +11,16 @@ public class ALROptions { public static final String OCCLUSION_CULLING_FORCE_IMPL = getProperty("alrOcclusionCullingForceImplementation", null); public static final boolean TEXTURE_DEBUG_CLEAR = getPropertyBoolean("alrTextureDebugClear", false); public static final boolean DEBUG_CONTEXT = getPropertyBoolean("alrEnableDebugContext", false); - /// 0 -> default implementation - /// - /// 1 -> use alrBindTextureHandleMultipleIntel, query each of the array element location and set them separately - /// - /// 2 -> use alrBindTextureHandleMultipleIntelBaseLocation, query the location of array uniform as base location and set each element separately - /// - /// 3 -> use alrBindTextureHandleMultipleIntelPadded, pads the input array - /// - /// Option 0 and 2 works on NVIDIA - public static final int USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND = getPropertyInt("alrUseIntelBindlessImageArrayWorkaround", 0); + // public static final int USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND = getPropertyInt("alrUseIntelBindlessImageArrayWorkaround", 0); public static void logAllOptions() { - log.info("ALR options: SPD_OPTION_WAVE_INTEROP_LDS={}, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS={}, OCCLUSION_CULLING_FORCE_IMPL={}, TEXTURE_DEBUG_CLEAR={}, USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND={}", + log.info("ALR options: SPD_OPTION_WAVE_INTEROP_LDS={}, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS={}, OCCLUSION_CULLING_FORCE_IMPL={}, TEXTURE_DEBUG_CLEAR={}", + // + ", USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND={}", SPD_OPTION_WAVE_INTEROP_LDS, OCCLUSION_QUERY_USE_FRUSTUM_PRE_PASS, OCCLUSION_CULLING_FORCE_IMPL, - TEXTURE_DEBUG_CLEAR, - USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND + TEXTURE_DEBUG_CLEAR + // , USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND ); } diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/ALRHIHeuristics.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/ALRHIHeuristics.java index 9c8a8382..e0cdee5e 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/ALRHIHeuristics.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/ALRHIHeuristics.java @@ -4,6 +4,6 @@ @ApiStatus.Internal public record ALRHIHeuristics( - boolean isWindowsArcGraphics + boolean isWindowsIntelGraphics ) { } diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java index dca2fa4d..32b38674 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/extension/blaze3d/texture/gl/bindless/GlBindlessTexturingSupport.java @@ -5,7 +5,6 @@ import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.textures.GpuSampler; import com.mojang.blaze3d.textures.GpuTexture; -import dev.anvilcraft.lib.v2.rendering.ALROptions; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRGpuDeviceBackendExtension; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.NamedUniformAccess; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.texture.ExtendedGpuTexture; @@ -130,21 +129,10 @@ public void alrBindTextureHandleMultiple( String name, List handle ) { - if (!handle.isEmpty() && handle.stream().noneMatch(TextureHandle::isTexture)) { - switch (ALROptions.USE_INTEL_BINDLESS_IMAGE_ARRAY_WORKAROUND) { - case 1 -> { - this.alrBindTextureHandleMultipleIntel(namedUniformAccess, name, handle); - return; - } - case 2 -> { - this.alrBindTextureHandleMultipleIntelBaseLocation(namedUniformAccess, name, handle); - return; - } - case 3 -> { - this.alrBindTextureHandleMultipleIntelPadded(namedUniformAccess, name, handle); - return; - } - } + // Windows intel drivers has the wrong implementation of `glUniformHandleui64vARB` + if (this.backendExtension.alrhiCreateHeuristics().isWindowsIntelGraphics()) { + this.alrBindTextureHandleMultipleIntelBaseLocation(namedUniformAccess, name, handle); + return; } int uniformLocation = namedUniformAccess.getUniformLocation(name, this.backendExtension); @@ -158,11 +146,7 @@ public void alrBindTextureHandleMultiple( ARBBindlessTexture.glUniformHandleui64vARB(uniformLocation, handles); } - /// Windows intel drivers has the wrong implementation of `glUniformHandleui64vARB` - /// - /// It reads the input `GLuint64 const *` using a 16 bytes stride instead of 8 bytes - /// - /// So query each of the array element location and set them separately may fix the segfault + /// Queries each array element by name; requires element names to be accepted by NamedUniformAccess. private void alrBindTextureHandleMultipleIntel( NamedUniformAccess namedUniformAccess, String name, @@ -172,6 +156,9 @@ private void alrBindTextureHandleMultipleIntel( for (TextureHandle textureHandle : handle) { String uniformName = name + "[" + i++ + "]"; int uniformLocation = namedUniformAccess.getUniformLocation(uniformName, this.backendExtension); + if (uniformLocation == -1) { + continue; + } ARBBindlessTexture.glUniformHandleui64ARB(uniformLocation, handleId(textureHandle)); } } @@ -184,6 +171,7 @@ private void alrBindTextureHandleMultipleIntelBaseLocation( ) { int i = 0; int locationStart = namedUniformAccess.getUniformLocation(name, this.backendExtension); + if (locationStart == -1) return; for (TextureHandle textureHandle : handle) { ARBBindlessTexture.glUniformHandleui64ARB(locationStart + i++, handleId(textureHandle)); } @@ -197,7 +185,7 @@ private void alrBindTextureHandleMultipleIntelPadded( ) { int uniformLocation = namedUniformAccess.getUniformLocation(name, this.backendExtension); - try (MemoryStack stack = MemoryStack.stackPush()){ + try (MemoryStack stack = MemoryStack.stackPush()) { int count = handle.size(); LongBuffer padded = stack.mallocLong(count * 2); for (int i = 0; i < count; i++) { diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java index e68b8fa1..a1482720 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/mixins/blaze3d/gl/GlDeviceMixin.java @@ -3,12 +3,10 @@ import com.mojang.blaze3d.GpuOutOfMemoryException; import com.mojang.blaze3d.opengl.GlConst; import com.mojang.blaze3d.opengl.GlDebugLabel; +import com.mojang.blaze3d.opengl.GlDevice; import com.mojang.blaze3d.opengl.GlStateManager; -import com.mojang.blaze3d.opengl.GlTexture; -import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.preprocessor.GlslPreprocessor; import com.mojang.blaze3d.textures.GpuTexture; -import dev.anvilcraft.lib.v2.rendering.ALROptions; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRGpuDeviceBackendExtension; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRHICapabilities; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRHIHeuristics; @@ -38,12 +36,11 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.Locale; import java.util.function.Supplier; -@Mixin(targets = "com.mojang.blaze3d.opengl.GlDevice") +@Mixin(GlDevice.class) public abstract class GlDeviceMixin implements ALRGpuDeviceBackendExtension { @Shadow @@ -145,34 +142,25 @@ public ALRHICapabilities alrhiCreateCapabilities() { @Override public ALRHIHeuristics alrhiCreateHeuristics() { if (this.alr$heuristics == null) { -// this.alr$heuristics = new ALRHIHeuristics(this.alr$isWindowsArcGraphics()); - // TODO: temporary return false as we need to test the workarounds - this.alr$heuristics = new ALRHIHeuristics(false); + this.alr$heuristics = new ALRHIHeuristics(this.alr$isWindowsIntelGraphics()); } return this.alr$heuristics; } @Unique - private boolean alr$isWindowsArcGraphics() { + private boolean alr$isWindowsIntelGraphics() { if (Util.getPlatform() != Util.OS.WINDOWS) { return false; } - String renderer = this.getRenderer(); - String lowerRenderer = renderer.toLowerCase(Locale.ROOT); - if (!lowerRenderer.contains("intel")) { - return false; - } - String cpuInfo = GLX._getCpuInfo(); - String lowerCpuInfo = cpuInfo.toLowerCase(Locale.ROOT); - boolean windowsArcGraphics = lowerRenderer.contains("arc") - || (lowerCpuInfo.contains("intel") && lowerCpuInfo.contains("ultra")); + String vendor = GL11.glGetString(GL11.GL_VENDOR); + boolean windowsIntelGraphics = vendor != null && vendor.toLowerCase(Locale.ROOT).contains("intel"); LOGGER.info( - "Windows graphics info: renderer='{}', cpu='{}', windowsArcGraphics={}", - renderer, - cpuInfo, - windowsArcGraphics + "Windows graphics info: renderer='{}', vendor='{}', windowsIntelGraphics={}", + this.getRenderer(), + vendor, + windowsIntelGraphics ); - return windowsArcGraphics; + return windowsIntelGraphics; } @Override diff --git a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/optimization/occlusion/hiz/HierarchicalZSupport.java b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/optimization/occlusion/hiz/HierarchicalZSupport.java index d27cffc8..d5195567 100644 --- a/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/optimization/occlusion/hiz/HierarchicalZSupport.java +++ b/module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/optimization/occlusion/hiz/HierarchicalZSupport.java @@ -1,11 +1,12 @@ package dev.anvilcraft.lib.v2.rendering.optimization.occlusion.hiz; import dev.anvilcraft.lib.v2.rendering.extension.blaze3d.ALRGpuDeviceExtension; +import dev.anvilcraft.lib.v2.rendering.optimization.occlusion.hiz.spd.SinglePassDownsampler; import org.jetbrains.annotations.ApiStatus; /// Device policy for the hierarchical-Z backend. /// -/// The {@link dev.anvilcraft.lib.v2.rendering.optimization.occlusion.hiz.spd.SinglePassDownsampler SPD pass} +/// The {@link SinglePassDownsampler SPD pass} /// and the Hi-Z occlusion test bind their mip chain either as consecutive image /// units, or - on devices that cannot spare that many units - through a bindless /// image array: @@ -15,9 +16,8 @@ /// `layout(binding = N)` index that is not below `GL_MAX_IMAGE_UNITS`. /// {@link #REQUIRED_IMAGE_UNITS} is the smallest power of two that satisfies /// this requirement. -/// - The bindless fallback is what makes hierarchical-Z usable on devices with -/// fewer image units, but it is broken on Intel Arc graphics under Windows: -/// the driver advertises `GL_ARB_bindless_texture`, yet using it crashes the JVM. +/// - The bindless fallback makes hierarchical-Z usable on devices with fewer +/// image units. Windows Intel image arrays use the per-element upload workaround. @ApiStatus.Internal public final class HierarchicalZSupport { /// `GL_MAX_IMAGE_UNITS` needed to bind the SPD mip chain as image units. @@ -46,8 +46,7 @@ public static boolean hasEnoughImageUnits(ALRGpuDeviceExtension device) { /// @return `true` when the bindless path has to be and may be used public static boolean useBindlessTexturing(ALRGpuDeviceExtension device) { return !hasEnoughImageUnits(device) - && device.alrhiCreateCapabilities().bindlessTexturing() - && !device.alrhiCreateHeuristics().isWindowsArcGraphics(); + && device.alrhiCreateCapabilities().bindlessTexturing(); } /// Returns whether hierarchical-Z can run on the device at all.