Skip to content

Commit

Permalink
Fixed issue with shader limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocelot5836 committed Nov 18, 2024
1 parent 0c07cfb commit f20631c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<VeilShaderLimits> 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,
Expand All @@ -84,11 +85,11 @@ public final class VeilRenderSystem {
private static final Supplier<VeilShaderLimits> 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,
Expand All @@ -97,11 +98,11 @@ public final class VeilRenderSystem {
private static final Supplier<VeilShaderLimits> 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,
Expand All @@ -110,11 +111,11 @@ public final class VeilRenderSystem {
private static final Supplier<VeilShaderLimits> 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,
Expand All @@ -123,11 +124,11 @@ public final class VeilRenderSystem {
private static final Supplier<VeilShaderLimits> 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,
Expand All @@ -136,11 +137,11 @@ public final class VeilRenderSystem {
private static final Supplier<VeilShaderLimits> 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,
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions common/src/main/resources/assets/veil/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",

Expand Down

0 comments on commit f20631c

Please sign in to comment.