YosysHQ / nextpnr

nextpnr portable FPGA place and route tool
ISC License
1.3k stars 243 forks source link

NextPNR GUI cannot share OpenGL Context on Mac OS X #185

Closed BracketMaster closed 5 years ago

BracketMaster commented 5 years ago

executing ./nextpnr-ice40 --json ./ice40/blinky.json --pcf ./ice40/blinky.pcf --asc ./ice40/blinky.asc --gui on Mac OS X will launch the PyQT windows, but sub window where that shows the FPGA fabric remains blank. I suspect this is because of incompatible versions between the open GL context of the FPGAView application and the PyQT parent application. I get this error

[yehowshuaimmanuel@Yehowshuas-MBP ice40]$ nextpnr-ice40 --json blinky.json --pcf blinky.pcf --asc blinky.asc --gui
qt.qpa.openglcontext: Could not create NSOpenGLContext with shared context, falling back to unshared context.
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' :  version '110' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:2: 'attribute' : syntax error: syntax error

*** Problematic Vertex shader source code ***
#version 110
#define lowp
#define mediump
#define highp
#line 1
attribute highp vec2  position;
attribute highp vec2  normal;
attribute highp float miter;
uniform   highp float thickness;
uniform   highp mat4  projection;
void main() {
   vec2 p = position.xy + vec2(normal * thickness/2.0 / miter);
   gl_Position = projection * vec4(p, 0.0, 1.0);
}

I was able to fix the attribute error with by editing ./nextpnr/gui/lineshader.h:186 to be

    static constexpr const char *fragmentShaderSource_ = "#version 150\n"
                                                         "uniform   lowp  vec4  color;\n"
                                                         "out vec4 out_color;\n"
                                                         "void main() {\n"
                                                         "   out_color = color;\n"
                                                         "}\n";

So now I just get

qt.qpa.openglcontext: Could not create NSOpenGLContext with shared context, falling back to unshared context.
qt.qpa.openglcontext: Could not create NSOpenGLContext with shared context, falling back to unshared context.

I saw that @ajeakins on commit 92ddef9n mentioned he/she? "Fixed crash starting the GUI on macOS" - I imagine ajeakins may have nextpnr GUI mode working on the mac? Any tips

ajeakins commented 5 years ago

I have a pull request to fix this open (but awaiting some changes) - see here https://github.com/YosysHQ/nextpnr/pull/169. The bit you are missing is setting the surface format in application.cc