From 21b7a71cf8cc24200b692fd4e0dd4580b322f896 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Sat, 4 Apr 2020 15:41:36 +0200 Subject: [PATCH 1/3] Fixes SSBO causing GL_INVALID_ENUM in Debug Mode --- .../java/com/jme3/renderer/opengl/GLRenderer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 23bd4d5f7..9c4a89ae9 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -506,12 +506,19 @@ public final class GLRenderer implements Renderer { if (hasExtension("GL_ARB_shader_storage_buffer_object")) { caps.add(Caps.ShaderStorageBufferObject); limits.put(Limits.ShaderStorageBufferObjectMaxBlockSize, getInteger(GL4.GL_MAX_SHADER_STORAGE_BLOCK_SIZE)); - limits.put(Limits.ShaderStorageBufferObjectMaxComputeBlocks, getInteger(GL4.GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS)); - limits.put(Limits.ShaderStorageBufferObjectMaxGeometryBlocks, getInteger(GL4.GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS)); + if (hasExtension("GL_ARB_compute_shader" ) || caps.contains(Caps.OpenGL43)) { + limits.put(Limits.ShaderStorageBufferObjectMaxComputeBlocks, getInteger(GL4.GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS)); + } + if (hasExtension("GL_ARB_geometry_shader_4") || caps.contains(Caps.OpenGL32)) { + limits.put(Limits.ShaderStorageBufferObjectMaxGeometryBlocks, getInteger(GL4.GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS)); + } limits.put(Limits.ShaderStorageBufferObjectMaxFragmentBlocks, getInteger(GL4.GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS)); limits.put(Limits.ShaderStorageBufferObjectMaxVertexBlocks, getInteger(GL4.GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS)); - limits.put(Limits.ShaderStorageBufferObjectMaxTessControlBlocks, getInteger(GL4.GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS)); - limits.put(Limits.ShaderStorageBufferObjectMaxTessEvaluationBlocks, getInteger(GL4.GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS)); + + if (hasExtension("GL_ARB_tessellation_shader") || caps.contains(Caps.OpenGL40)) { + limits.put(Limits.ShaderStorageBufferObjectMaxTessControlBlocks, getInteger(GL4.GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS)); + limits.put(Limits.ShaderStorageBufferObjectMaxTessEvaluationBlocks, getInteger(GL4.GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS)); + } limits.put(Limits.ShaderStorageBufferObjectMaxCombineBlocks, getInteger(GL4.GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS)); } From 64797f9bff73ee7b2fecf612fde242071a251f01 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Sat, 4 Apr 2020 16:19:56 +0200 Subject: [PATCH 2/3] UBO: GL_INVALID_ENUM on Mesa --- .../src/main/java/com/jme3/renderer/opengl/GLRenderer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 9c4a89ae9..f83bb614b 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -525,7 +525,9 @@ public final class GLRenderer implements Renderer { if (hasExtension("GL_ARB_uniform_buffer_object")) { caps.add(Caps.UniformBufferObject); limits.put(Limits.UniformBufferObjectMaxBlockSize, getInteger(GL3.GL_MAX_UNIFORM_BLOCK_SIZE)); - limits.put(Limits.UniformBufferObjectMaxGeometryBlocks, getInteger(GL3.GL_MAX_GEOMETRY_UNIFORM_BLOCKS)); + if (hasExtension("GL_ARB_geometry_shader_4") || caps.contains(Caps.OpenGL32)) { + limits.put(Limits.UniformBufferObjectMaxGeometryBlocks, getInteger(GL3.GL_MAX_GEOMETRY_UNIFORM_BLOCKS)); + } limits.put(Limits.UniformBufferObjectMaxFragmentBlocks, getInteger(GL3.GL_MAX_FRAGMENT_UNIFORM_BLOCKS)); limits.put(Limits.UniformBufferObjectMaxVertexBlocks, getInteger(GL3.GL_MAX_VERTEX_UNIFORM_BLOCKS)); } From 01156166520fe9d3662e4e28ac1552e371261b75 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Sat, 4 Apr 2020 17:19:10 +0200 Subject: [PATCH 3/3] UBO: Re-order the caps detection for a more clean code. --- .../com/jme3/renderer/opengl/GLRenderer.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index f83bb614b..6f9d93f36 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -503,19 +503,25 @@ public final class GLRenderer implements Renderer { } } + if (hasExtension("GL_OES_geometry_shader") || hasExtension("GL_EXT_geometry_shader")) { + caps.add(Caps.GeometryShader); + } + + if (hasExtension("GL_OES_tessellation_shader") || hasExtension("GL_EXT_tessellation_shader")) { + caps.add(Caps.TesselationShader); + } + if (hasExtension("GL_ARB_shader_storage_buffer_object")) { caps.add(Caps.ShaderStorageBufferObject); limits.put(Limits.ShaderStorageBufferObjectMaxBlockSize, getInteger(GL4.GL_MAX_SHADER_STORAGE_BLOCK_SIZE)); - if (hasExtension("GL_ARB_compute_shader" ) || caps.contains(Caps.OpenGL43)) { - limits.put(Limits.ShaderStorageBufferObjectMaxComputeBlocks, getInteger(GL4.GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS)); - } - if (hasExtension("GL_ARB_geometry_shader_4") || caps.contains(Caps.OpenGL32)) { + // Commented out until we support ComputeShaders and the ComputeShader Cap + // limits.put(Limits.ShaderStorageBufferObjectMaxComputeBlocks, getInteger(GL4.GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS)); + if (caps.contains(Caps.GeometryShader)) { limits.put(Limits.ShaderStorageBufferObjectMaxGeometryBlocks, getInteger(GL4.GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS)); } limits.put(Limits.ShaderStorageBufferObjectMaxFragmentBlocks, getInteger(GL4.GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS)); limits.put(Limits.ShaderStorageBufferObjectMaxVertexBlocks, getInteger(GL4.GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS)); - - if (hasExtension("GL_ARB_tessellation_shader") || caps.contains(Caps.OpenGL40)) { + if (caps.contains(Caps.TesselationShader)) { limits.put(Limits.ShaderStorageBufferObjectMaxTessControlBlocks, getInteger(GL4.GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS)); limits.put(Limits.ShaderStorageBufferObjectMaxTessEvaluationBlocks, getInteger(GL4.GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS)); } @@ -525,20 +531,14 @@ public final class GLRenderer implements Renderer { if (hasExtension("GL_ARB_uniform_buffer_object")) { caps.add(Caps.UniformBufferObject); limits.put(Limits.UniformBufferObjectMaxBlockSize, getInteger(GL3.GL_MAX_UNIFORM_BLOCK_SIZE)); - if (hasExtension("GL_ARB_geometry_shader_4") || caps.contains(Caps.OpenGL32)) { + if (caps.contains(Caps.GeometryShader)) { limits.put(Limits.UniformBufferObjectMaxGeometryBlocks, getInteger(GL3.GL_MAX_GEOMETRY_UNIFORM_BLOCKS)); } limits.put(Limits.UniformBufferObjectMaxFragmentBlocks, getInteger(GL3.GL_MAX_FRAGMENT_UNIFORM_BLOCKS)); limits.put(Limits.UniformBufferObjectMaxVertexBlocks, getInteger(GL3.GL_MAX_VERTEX_UNIFORM_BLOCKS)); } - if (hasExtension("GL_OES_geometry_shader") || hasExtension("GL_EXT_geometry_shader")) { - caps.add(Caps.GeometryShader); - } - if (hasExtension("GL_OES_tessellation_shader") || hasExtension("GL_EXT_tessellation_shader")) { - caps.add(Caps.TesselationShader); - } if(caps.contains(Caps.OpenGL20)){ caps.add(Caps.UnpackRowLength);