Skip to content

Commit

Permalink
Mesa detection (set to "Poor" quality, Mesa software rendering is slo…
Browse files Browse the repository at this point in the history
…w and VirtualBox Hardware Acceleration disrupts frame buffers)
  • Loading branch information
neurolabusc committed Jul 30, 2020
1 parent d1ebc8f commit 9507fe5
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 92 deletions.
10 changes: 8 additions & 2 deletions mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4405,6 +4405,12 @@ procedure TGLForm1.PrefMenuClick(Sender: TObject);
gPrefs.RenderQuality := kRenderPoor
else
gPrefs.RenderQuality := kRenderBetter;
{$IFDEF LINUX}
if (gPrefs.RenderQuality > kRenderPoor) and (AnsiContainsText(gShader.Vendor,'MESA'))then begin
ShowMessage('Mesa drivers may have visual artifacts for quality better than "Poor".');
gPrefs.isMesaWarned:= true;
end;
{$ENDIF}
if QualityCombo.ItemIndex = 2 then //only for best quality
gPrefs.OcclusionAmount := 25
else
Expand Down Expand Up @@ -5564,7 +5570,7 @@ function isExeReadOnly: string;
{$ENDIF}

procedure TGLForm1.AboutMenuClick(Sender: TObject);
{$DEFINE TIMEABOUT}
//{$DEFINE TIMEABOUT}
{$IFDEF TIMEABOUT}
const
kSamp = 36;
Expand Down Expand Up @@ -5621,7 +5627,7 @@ procedure TGLForm1.AboutMenuClick(Sender: TObject);
{$IFDEF Linux} + ' Linux'{$ENDIF}
{$IFDEF Windows} + ' Windows'{$ENDIF}
{$IFDEF DGL} + ' DGL'{$ENDIF}
{$IFNDEF COREGL}+' (Legacy OpenGL)'{$ENDIF}
{$IFNDEF COREGL}+' (Legacy '+{$IFDEF LEGACY_INDEXING}'Indexed '+{$ENDIF}'OpenGL)'{$ENDIF}
{$IFDEF Darwin}
{$IFDEF LCLCocoa}
+''; titleStr := Str; str := ' '+GetHardwareVersion
Expand Down
4 changes: 2 additions & 2 deletions opts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// NOT COREGL, DEFINED LEGACY_INDEXING : uses indexed vertices and glDrawElements (medium efficiency)
// NOT COREGL, NOT LEGACY_INDEXING : glCallList with redundant vertices (least efficient)

//{$DEFINE COREGL}
{$DEFINE COREGL}
{$DEFINE LEGACY_INDEXING}
{$DEFINE GEOM_GLEXT}
//{$DEFINE HEMISSAO} //for hemispherical SSAO - requires shaders that save surface normal - see hemiAO3 and hemiAO
{$DEFINE CTM} //support OpenCTM format, requires LZMA decoding
//{$DEFINE TUBES}
{$DEFINE MATCAP}
{$DEFINE MATCAP}
12 changes: 9 additions & 3 deletions optsCompat.inc
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{$DEFINE MYPY}
//{$DEFINE FASTGZ}
//{$DEFINE DGL} //for DGL library, otherwise gl/glext
{$DEFINE FASTGZ}
//There are 3 modes
// DEFINED COREGL : uses "modern" OpenGL 3.3 for most efficient use of resources (most efficient)
// NOT COREGL, DEFINED LEGACY_INDEXING : uses indexed vertices and glDrawElements (medium efficiency)
// NOT COREGL, NOT LEGACY_INDEXING : glCallList with redundant vertices (least efficient)

//{$DEFINE COREGL}
{$DEFINE GEOM_GLEXT} //if glext.pp defines
{$DEFINE LEGACY_INDEXING}
{$DEFINE GEOM_GLEXT}
//{$DEFINE HEMISSAO} //for hemispherical SSAO - requires shaders that save surface normal - see hemiAO3 and hemiAO
{$DEFINE CTM} //support OpenCTM format, requires LZMA decoding
//{$DEFINE TUBES}
{$DEFINE MATCAP}
{$DEFINE MATCAP}
9 changes: 8 additions & 1 deletion optsCompatGeom.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{$DEFINE MYPY}
//{$DEFINE DGL} //for DGL library, otherwise gl/glext
{$DEFINE FASTGZ}
//There are 3 modes
// DEFINED COREGL : uses "modern" OpenGL 3.3 for most efficient use of resources (most efficient)
// NOT COREGL, DEFINED LEGACY_INDEXING : uses indexed vertices and glDrawElements (medium efficiency)
// NOT COREGL, NOT LEGACY_INDEXING : glCallList with redundant vertices (least efficient)

//{$DEFINE COREGL}
{$DEFINE GEOM_GLEXT} //if glext.pp defines
{$DEFINE LEGACY_INDEXING}
{$DEFINE GEOM_GLEXT}
//{$DEFINE HEMISSAO} //for hemispherical SSAO - requires shaders that save surface normal - see hemiAO3 and hemiAO
{$DEFINE CTM} //support OpenCTM format, requires LZMA decoding
//{$DEFINE TUBES}
Expand Down
7 changes: 7 additions & 0 deletions optsCore.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{$DEFINE MYPY}
//{$DEFINE DGL} //for DGL library, otherwise gl/glext
{$DEFINE FASTGZ}
//There are 3 modes
// DEFINED COREGL : uses "modern" OpenGL 3.3 for most efficient use of resources (most efficient)
// NOT COREGL, DEFINED LEGACY_INDEXING : uses indexed vertices and glDrawElements (medium efficiency)
// NOT COREGL, NOT LEGACY_INDEXING : glCallList with redundant vertices (least efficient)

{$DEFINE COREGL}
{$DEFINE LEGACY_INDEXING}
{$DEFINE GEOM_GLEXT}
//{$DEFINE HEMISSAO} //for hemispherical SSAO - requires shaders that save surface normal - see hemiAO3 and hemiAO
{$DEFINE CTM} //support OpenCTM format, requires LZMA decoding
//{$DEFINE TUBES}
Expand Down
5 changes: 4 additions & 1 deletion prefs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ TPrefs = record //ObjectBasedClipPlane,
SmoothVoxelwiseData,
OverlayClip, StartupScript, SupportBetterRenderQuality, AdditiveOverlay,Perspective, OrientCube, MultiSample, BlackDefaultBackground,
Colorbar,TracksAreTubes, ScreenCaptureTransparentBackground,LoadTrackOnLaunch,ColorBarPrecedenceTracksNotOverlays,HideDarkTracks, HideBrightTracks,
OverlappingOverlaysOverwrite, ZDimIsUp, ShaderForBackgroundOnly, CoreTrackDisableDepth, SkipPrefWriting, isFlipMeshOverlay, DarkMode, RetinaDisplay, GenerateSmoothCurves : boolean;
OverlappingOverlaysOverwrite, ZDimIsUp, ShaderForBackgroundOnly, CoreTrackDisableDepth, SkipPrefWriting, isFlipMeshOverlay, DarkMode,
RetinaDisplay, GenerateSmoothCurves {$IFDEF LINX}, isMesaWarned {$ENDIF} : boolean;
TrackTubeSlices, ScreenCaptureZoom,ColorbarColor,ColorBarPosition,
window_width, window_height, RenderQuality,
StartupWindowMode,
Expand Down Expand Up @@ -299,6 +300,7 @@ procedure SetDefaultPrefs (var lPrefs: TPrefs; lEverything, askUserIfMissing: b
with lPrefs do begin
//CrossHairs := true;
ColorbarSize := 0.035;
{$IFDEF LINUX}isMesaWarned := false; {$ENDIF}
StartupWindowMode := 0;
ObjColor := RGBToColor(212, 168, 168);
BackColor := RGBToColor(0, 0, 0);
Expand Down Expand Up @@ -646,6 +648,7 @@ function IniFile(lRead: boolean; lFilename: string; var lPrefs: TPrefs): boolean
IniBool(lRead,lIniFile, 'Perspective',lPrefs.Perspective);
IniBool(lRead,lIniFile, 'AdditiveOverlay',lPrefs.AdditiveOverlay);
IniBool(lRead,lIniFile, 'StartupScript',lPrefs.StartupScript);
{$IFDEF LINUX}IniBool(lRead,lIniFile, 'MesaWarned', lPrefs.isMesaWarned);{$ENDIF}
//IniBool(lRead,lIniFile, 'ObjectBasedClipPlane',lPrefs.ObjectBasedClipPlane);
{$IFDEF LCLCocoa}
IniBool(lRead,lIniFile, 'RetinaDisplay',lPrefs.RetinaDisplay);
Expand Down
13 changes: 10 additions & 3 deletions shaderu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ procedure freeFrame (var f : TFrameBuffer);
//procedure Set2DDraw (w,h: integer; r,g,b: byte);

implementation
uses mainunit, shaderui;
uses {$IFDEF LINUX} prefs, {$ENDIF} mainunit, shaderui;

{$IFDEF COREGL}
const kVert2D ='#version 330'
Expand Down Expand Up @@ -953,7 +953,15 @@ function InitGLSL (isStartUp: boolean): boolean;
{$ENDIF}
{$ENDIF}
{$ENDIF}
gShader.Vendor := glGetString(GL_VENDOR)+' :: OpenGL '+glGetString(GL_VERSION)+' :: GLSL ' +glGetString(GL_SHADING_LANGUAGE_VERSION);
gShader.Vendor := glGetString(GL_VERSION);
{$IFDEF LINUX}
if AnsiContainsText(gShader.Vendor,'MESA') then begin
writeln('Mesa driver detected. If you observe artifacts set "Quality: Poor" in the Preferences window.');
if not gPrefs.isMesaWarned then
gPrefs.RenderQuality := min(kRenderPoor, gPrefs.RenderQuality);
end;
{$ENDIF}
gShader.Vendor := glGetString(GL_VENDOR)+' :: OpenGL '+gShader.Vendor+' :: GLSL ' +glGetString(GL_SHADING_LANGUAGE_VERSION);
gShader.program2d := initVertFrag(kVert2D, '', kFrag2D);
gShader.program3dx := initVertFrag(kVert3d, '', kFrag3d);
gShader.programDefault := initVertFrag(kVert3d, '', kFrag3d);
Expand Down Expand Up @@ -1222,7 +1230,6 @@ procedure RunTrackGLSL (lineWidth, ScreenPixelX, ScreenPixelY: integer; isTubes:
begin
glUseProgram(gShader.programTrackID);
SetTrackUniforms (lineWidth, ScreenPixelX, ScreenPixelY);

{$IFDEF COREGL}
{$ELSE}
{$IFDEF LEGACY_INDEXING}
Expand Down
Loading

0 comments on commit 9507fe5

Please sign in to comment.