Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X 10.14 does not compile glsl version 130 #4681

Open
serejkus opened this issue Sep 27, 2019 · 1 comment

Comments

@serejkus
Copy link

commented Sep 27, 2019

Observed behaviour

Pioneer on Mac OS X 10.14 requires glsl version 410, but the default one guessed by imgui is 130. This leads to failures in shader compilation. The visible effect is that error messages pop up and no GUI is drawn.

Expected behaviour

Pioneer runs with no error messages and GUI drawn.

Steps to reproduce

PiGui::Init() callsImGui_ImplOpenGL3_Init(NULL), which sets an g_GlslVersionString parameter. The default for Mac OS X is #version 130 with option to make it #version 300 es. Neither of these work on Mac OS X. The actual version is:

(lldb) p (const char*) glGetString(0x1f02) # 0x1f02 is GL_VERSION
(const char *) $1 = 0x000000010718231a "4.1 ATI-2.11.20"

So, the g_GlslVersionString is set to #version 130. Then PiGui::NewFrame() calls ImGui_ImplOpenGL3_NewFrame() which ends in a call to ImGui_ImplOpenGL3_CreateDeviceObjects(). It does the following things:

    int glsl_version = 130;
    sscanf(g_GlslVersionString, "#version %d", &glsl_version);

and then selects shaders code based on glsl_version. By default it leads to selecting version 130. Then it tries to compile shaders and fails:

    const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
    g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
    glCompileShader(g_VertHandle);
    CheckShader(g_VertHandle, "vertex shader");

CheckShader() detects and reports a problem:

ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile vertex shader!
ERROR: 0:1: '' :  version '130' is not supported
ERROR: 0:2: '' :  #version required and missing.

This simple PoC patch fixes problem for Mac OS X:

diff --git a/src/PiGui.cpp b/src/PiGui.cpp
index 099ff4120..d83b2890d 100644
--- a/src/PiGui.cpp
+++ b/src/PiGui.cpp
@@ -214,7 +214,7 @@ void PiGui::Init(SDL_Window *window)
                Error("RENDERER_DUMMY is not a valid renderer, aborting.");
                return;
        case Graphics::RENDERER_OPENGL_3x:
-               ImGui_ImplOpenGL3_Init();
+               ImGui_ImplOpenGL3_Init("#version 410 core");
                break;
        }

So, I guess that a possible solution for this problem is to try to guess the current version of shader language from glGetString().

My pioneer version (and OS):

My machine spec:

Mac OS X 10.14.6 (18G95)
Radeon Pro 560X 4 ГБ
Intel UHD Graphics 630 1536 МБ

Runtime version info:

--------------------
SDL Version (build) 2.0.10
SDL Version (dynamic) 2.0.10
SDL Versions match
SDL_image Version (build): 2.0.5
SDL_image Version (dynamic): 2.0.5
SDL_image Versions match
Assimp Version: 4.1.0
FreeType Version: 2.10.1
GLEW dynamic version: 2.0.0
--------------------

opengl.txt:

OpenGL version 4.1 ATI-2.11.20, running on ATI Technologies Inc. AMD Radeon Pro 560X OpenGL Engine
Available extensions:
Shading language version: 4.10
  GL_ARB_blend_func_extended
  GL_ARB_draw_buffers_blend
  GL_ARB_draw_indirect
  GL_ARB_ES2_compatibility
  GL_ARB_explicit_attrib_location
  GL_ARB_gpu_shader_fp64
  GL_ARB_gpu_shader5
  GL_ARB_instanced_arrays
  GL_ARB_internalformat_query
  GL_ARB_occlusion_query2
  GL_ARB_sample_shading
  GL_ARB_sampler_objects
  GL_ARB_separate_shader_objects
  GL_ARB_shader_bit_encoding
  GL_ARB_shader_subroutine
  GL_ARB_shading_language_include
  GL_ARB_tessellation_shader
  GL_ARB_texture_buffer_object_rgb32
  GL_ARB_texture_cube_map_array
  GL_ARB_texture_gather
  GL_ARB_texture_query_lod
  GL_ARB_texture_rgb10_a2ui
  GL_ARB_texture_storage
  GL_ARB_texture_swizzle
  GL_ARB_timer_query
  GL_ARB_transform_feedback2
  GL_ARB_transform_feedback3
  GL_ARB_vertex_attrib_64bit
  GL_ARB_vertex_type_2_10_10_10_rev
  GL_ARB_viewport_array
  GL_EXT_debug_label
  GL_EXT_debug_marker
  GL_EXT_depth_bounds_test
  GL_EXT_texture_compression_s3tc
  GL_EXT_texture_filter_anisotropic
  GL_EXT_texture_mirror_clamp
  GL_EXT_texture_sRGB_decode
  GL_APPLE_client_storage
  GL_APPLE_container_object_shareable
  GL_APPLE_flush_render
  GL_APPLE_object_purgeable
  GL_APPLE_rgb_422
  GL_APPLE_row_bytes
  GL_APPLE_texture_range
  GL_ATI_texture_mirror_once
  GL_NV_texture_barrier

Implementation Limits:
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 80
GL_MAX_CUBE_MAP_TEXTURE_SIZE = 16384
GL_MAX_DRAW_BUFFERS = 8
GL_MAX_ELEMENTS_INDICES = 150000
GL_MAX_ELEMENTS_VERTICES = 1.04858e+06
GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 4096
GL_MAX_TEXTURE_IMAGE_UNITS = 16
GL_MAX_TEXTURE_LOD_BIAS = 16
GL_MAX_TEXTURE_SIZE = 16384
GL_MAX_VERTEX_ATTRIBS = 16
GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16
GL_MAX_VERTEX_UNIFORM_COMPONENTS = 4096
GL_NUM_COMPRESSED_TEXTURE_FORMATS = 3
GL_SAMPLE_BUFFERS = 1
GL_SAMPLES = 2
GL_ALIASED_LINE_WIDTH_RANGE = 1, 1
GL_MAX_VIEWPORT_DIMS = 16384, 16384
GL_SMOOTH_LINE_WIDTH_RANGE = 1, 1
GL_SMOOTH_POINT_SIZE_RANGE = 1, 8191

Compressed texture formats:
  0x83f0
  0x83f2
  0x83f3
@fluffyfreak

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2019

Wow, that's a great bug report, very detailed! Thankyou.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.