From f20631ca7bc5d961d774844d1ea338753e7c1ef0 Mon Sep 17 00:00:00 2001 From: Ocelot Date: Mon, 18 Nov 2024 11:21:40 -0700 Subject: [PATCH] Fixed issue with shader limits --- .../api/client/render/VeilRenderSystem.java | 64 +++++++++++-------- .../api/client/render/VeilShaderLimits.java | 10 +-- .../impl/client/editor/DeviceInfoViewer.java | 6 ++ .../resources/assets/veil/lang/en_us.json | 4 ++ 4 files changed, 51 insertions(+), 33 deletions(-) diff --git a/common/src/main/java/foundry/veil/api/client/render/VeilRenderSystem.java b/common/src/main/java/foundry/veil/api/client/render/VeilRenderSystem.java index ffe328e4..b642e770 100644 --- a/common/src/main/java/foundry/veil/api/client/render/VeilRenderSystem.java +++ b/common/src/main/java/foundry/veil/api/client/render/VeilRenderSystem.java @@ -67,15 +67,16 @@ public final class VeilRenderSystem { private static final IntSupplier MAX_UNIFORM_BUFFER_BINDINGS = VeilRenderSystem.glGetter(() -> glGetInteger(GL_MAX_UNIFORM_BUFFER_BINDINGS)); private static final IntSupplier MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = VeilRenderSystem.glGetter(() -> glGetInteger(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS)); private static final IntSupplier MAX_SHADER_STORAGE_BUFFER_BINDINGS = VeilRenderSystem.glGetter(() -> glGetInteger(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS)); + private static final IntSupplier MAX_ARRAY_TEXTURE_LAYERS = VeilRenderSystem.glGetter(() -> glGetInteger(GL_MAX_ARRAY_TEXTURE_LAYERS)); private static final Supplier VERTEX_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_VERTEX_UNIFORM_COMPONENTS, - GL_MAX_VERTEX_UNIFORM_BLOCKS, - GL_MAX_VERTEX_ATTRIBS * 4, - GL_MAX_VERTEX_OUTPUT_COMPONENTS, - GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_VERTEX_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_VERTEX_UNIFORM_BLOCKS), + glGetInteger(GL_MAX_VERTEX_ATTRIBS) * 4, + glGetInteger(GL_MAX_VERTEX_OUTPUT_COMPONENTS), + glGetInteger(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS), GL_MAX_VERTEX_IMAGE_UNIFORMS, GL_MAX_VERTEX_ATOMIC_COUNTERS, GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, @@ -84,11 +85,11 @@ public final class VeilRenderSystem { private static final Supplier GL_TESS_CONTROL_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS, - GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS, - GL_MAX_TESS_CONTROL_INPUT_COMPONENTS, - GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS, - GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS), + glGetInteger(GL_MAX_TESS_CONTROL_INPUT_COMPONENTS), + glGetInteger(GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS), + glGetInteger(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS), GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS, GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS, GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, @@ -97,11 +98,11 @@ public final class VeilRenderSystem { private static final Supplier GL_TESS_EVALUATION_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS, - GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, - GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS, - GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS, - GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS), + glGetInteger(GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS), + glGetInteger(GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS), + glGetInteger(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS), GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS, GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS, GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, @@ -110,11 +111,11 @@ public final class VeilRenderSystem { private static final Supplier GL_GEOMETRY_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, - GL_MAX_GEOMETRY_UNIFORM_BLOCKS, - GL_MAX_GEOMETRY_INPUT_COMPONENTS, - GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, - GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_GEOMETRY_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_GEOMETRY_UNIFORM_BLOCKS), + glGetInteger(GL_MAX_GEOMETRY_INPUT_COMPONENTS), + glGetInteger(GL_MAX_GEOMETRY_OUTPUT_COMPONENTS), + glGetInteger(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS), GL_MAX_GEOMETRY_IMAGE_UNIFORMS, GL_MAX_GEOMETRY_ATOMIC_COUNTERS, GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, @@ -123,11 +124,11 @@ public final class VeilRenderSystem { private static final Supplier GL_FRAGMENT_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, - GL_MAX_FRAGMENT_UNIFORM_BLOCKS, - GL_MAX_FRAGMENT_INPUT_COMPONENTS, - GL_MAX_DRAW_BUFFERS * 4, - GL_MAX_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_FRAGMENT_UNIFORM_BLOCKS), + glGetInteger(GL_MAX_FRAGMENT_INPUT_COMPONENTS), + glGetInteger(GL_MAX_DRAW_BUFFERS) * 4, + glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS), GL_MAX_FRAGMENT_IMAGE_UNIFORMS, GL_MAX_FRAGMENT_ATOMIC_COUNTERS, GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, @@ -136,11 +137,11 @@ public final class VeilRenderSystem { private static final Supplier GL_COMPUTE_SHADER_LIMITS = VeilRenderSystem.glGetter(() -> { GLCapabilities caps = GL.getCapabilities(); return new VeilShaderLimits(caps, - GL_MAX_COMPUTE_UNIFORM_COMPONENTS, - GL_MAX_COMPUTE_UNIFORM_BLOCKS, + glGetInteger(GL_MAX_COMPUTE_UNIFORM_COMPONENTS), + glGetInteger(GL_MAX_COMPUTE_UNIFORM_BLOCKS), 0, 0, - GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, + glGetInteger(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS), GL_MAX_COMPUTE_IMAGE_UNIFORMS, GL_MAX_COMPUTE_ATOMIC_COUNTERS, GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, @@ -543,6 +544,13 @@ public static int maxShaderStorageBufferBindings() { return VeilRenderSystem.MAX_SHADER_STORAGE_BUFFER_BINDINGS.getAsInt(); } + /** + * @return The GL maximum number of array texture layers available + */ + public static int maxArrayTextureLayers() { + return VeilRenderSystem.MAX_ARRAY_TEXTURE_LAYERS.getAsInt(); + } + /** * @return The GL maximum width of framebuffers */ diff --git a/common/src/main/java/foundry/veil/api/client/render/VeilShaderLimits.java b/common/src/main/java/foundry/veil/api/client/render/VeilShaderLimits.java index b5eed98c..93779ce1 100644 --- a/common/src/main/java/foundry/veil/api/client/render/VeilShaderLimits.java +++ b/common/src/main/java/foundry/veil/api/client/render/VeilShaderLimits.java @@ -49,11 +49,11 @@ public VeilShaderLimits(GLCapabilities caps, int maxAtomicCounters, int maxAtomicCountBuffers, int maxShaderStorageBlocks) { - this(glGetInteger(maxUniformComponents), - glGetInteger(maxUniformBlocks), - glGetInteger(maxInputComponents), - glGetInteger(maxOutputComponents), - glGetInteger(maxTextureImageUnits), + this(maxUniformComponents, + maxUniformBlocks, + maxInputComponents, + maxOutputComponents, + maxTextureImageUnits, caps.OpenGL42 || caps.GL_ARB_shader_image_load_store ? glGetInteger(maxImageUniforms) : 0, caps.OpenGL42 || caps.GL_ARB_shader_atomic_counters ? glGetInteger(maxAtomicCounters) : 0, caps.OpenGL42 || caps.GL_ARB_shader_atomic_counters ? glGetInteger(maxAtomicCountBuffers) : 0, diff --git a/common/src/main/java/foundry/veil/impl/client/editor/DeviceInfoViewer.java b/common/src/main/java/foundry/veil/impl/client/editor/DeviceInfoViewer.java index 9d35de6f..9abce23d 100644 --- a/common/src/main/java/foundry/veil/impl/client/editor/DeviceInfoViewer.java +++ b/common/src/main/java/foundry/veil/impl/client/editor/DeviceInfoViewer.java @@ -1,5 +1,6 @@ package foundry.veil.impl.client.editor; +import com.mojang.blaze3d.systems.RenderSystem; import foundry.veil.api.client.editor.SingleWindowEditor; import foundry.veil.api.client.imgui.VeilImGuiUtil; import foundry.veil.api.client.render.VeilRenderSystem; @@ -41,6 +42,7 @@ public class DeviceInfoViewer extends SingleWindowEditor { private static final Component GL_TRANSFORM_FEEDBACK = Component.translatable("editor.veil.device_info.opengl.transform_feedback"); private static final Component GL_ATOMIC_COUNTER = Component.translatable("editor.veil.device_info.opengl.atomic_counter"); private static final Component GL_SHADER_STORAGE = Component.translatable("editor.veil.device_info.opengl.shader_storage"); + private static final Component GL_TEXTURE = Component.translatable("editor.veil.device_info.opengl.texture"); private static final Component GL_FRAMEBUFFER = Component.translatable("editor.veil.device_info.opengl.framebuffer"); private static final Component CL_PLATFORMS = Component.translatable("editor.veil.device_info.opencl.platforms"); private static final Component CL_DEVICES = Component.translatable("editor.veil.device_info.opencl.devices"); @@ -166,6 +168,10 @@ private void renderOpenGL() { text("editor.veil.device_info.opengl.shader_storage.max_output_resources", shaderStorageBuffers ? glGetInteger(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES) : null, "The total number of shader storage blocks, image variables, and fragment shader outputs across all active programs cannot exceed this number. This is the \"amount of stuff\" that a sequence of shaders can write to (barring Transform Feedback)."); ImGui.separator(); + title(GL_TEXTURE); + text("editor.veil.device_info.opengl.texture.max_texture_size", RenderSystem.maxSupportedTextureSize(), null); + text("editor.veil.device_info.opengl.texture.max_array_texture_layers", VeilRenderSystem.maxArrayTextureLayers(), null); + title(GL_FRAMEBUFFER); text("editor.veil.device_info.opengl.framebuffer.max_color_attachments", VeilRenderSystem.maxColorAttachments(), null); text("editor.veil.device_info.opengl.framebuffer.max_samples", VeilRenderSystem.maxSamples(), null); diff --git a/common/src/main/resources/assets/veil/lang/en_us.json b/common/src/main/resources/assets/veil/lang/en_us.json index d65d0bff..43c37ecd 100644 --- a/common/src/main/resources/assets/veil/lang/en_us.json +++ b/common/src/main/resources/assets/veil/lang/en_us.json @@ -40,6 +40,7 @@ "editor.veil.device_info.opengl.transform_feedback": "Transform Feedback:", "editor.veil.device_info.opengl.atomic_counter": "Atomic Counter:", "editor.veil.device_info.opengl.shader_storage": "Shader Storage:", + "editor.veil.device_info.opengl.texture": "Texture:", "editor.veil.device_info.opengl.framebuffer": "Framebuffer:", "editor.veil.device_info.opengl.vendor": "Vendor: %s", @@ -80,6 +81,9 @@ "editor.veil.device_info.opengl.shader_storage.max_combined_blocks": "Max Combined Shader Storage Blocks: %s", "editor.veil.device_info.opengl.shader_storage.max_output_resources": "Max Combined Shader Output Resources: %s", + "editor.veil.device_info.opengl.texture.max_texture_size": "Max Texture Size: %1$sx%1$s", + "editor.veil.device_info.opengl.texture.max_array_texture_layers": "Max Array Texture Layers: %s", + "editor.veil.device_info.opengl.framebuffer.max_color_attachments": "Max Framebuffer Color Attachments: %s", "editor.veil.device_info.opengl.framebuffer.max_samples": "Max Framebuffer Samples: %s",