View Issue Details

IDProjectCategoryView StatusLast Update
0026711Open CASCADEOCCT:Visualizationpublic2017-04-02 16:50
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Target Version7.0.0Fixed in Version7.0.0 
Summary0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs
DescriptionIt is desirable to support creation of FBOs with multisampling textures.

See:
https://www.opengl.org/wiki/Multisampling
Steps To Reproduce
pload MODELING VISUALIZATION
box b 2 3 1
vclear
vclose ALL
vinit View1 w=512 h=512
vdisplay b
vfit
vrotate 0.5 0 0
vrenderparams -msaa 8
TagsNo tags attached.
Test case numberv3d glsl msaa

Attached Files

  • penrose_msaa_off.png (48,006 bytes)
  • penrose_msaa_8.png (49,133 bytes)

Relationships

parent of 0026834 closedbugmaster Open CASCADE Visualization, OpenGl_FrameBuffer - use GL_DEPTH_COMPONENT instead of GL_DEPTH for texture initialization 
parent of 0028615 closedbugmaster Open CASCADE Visualization, TKOpenGl - enabling MSAA leads to black screen on OpenGL ES 
has duplicate 0026756 closedbugmaster Community Antialiasing cannot be controlled anymore by graphics driver 
related to 0024324 closedbugmaster Community Antialiasing exposes triangulation edges [on NVIDIA] 
related to 0027360 closedbugmaster Open CASCADE Visualization - remove obsolete anti-aliasing API 
related to 0027606 closedbugmaster Community Visualization - view is blocking when MSAA has been overridden in graphics driver settings 
related to 0027755 closedbugmaster Open CASCADE Visualization, V3d_View::ToPixMap() - fix image dump with MSAA turned on 

Activities

git

2015-09-19 16:46

administrator   ~0045932

Branch CR26711 has been created by kgv.

SHA-1: 1d10df3a20507824fb8e7cce431f4ad6f907c34d


No new revisions were added by this update.

git

2015-09-19 18:56

administrator   ~0045935

Branch CR26711 has been updated forcibly by kgv.

SHA-1: 454b6834af8e898899efd1b337693ea3cf7d0076

kgv

2015-09-19 19:04

developer  

penrose_msaa_off.png (48,006 bytes)

kgv

2015-09-19 19:04

developer  

penrose_msaa_8.png (49,133 bytes)

kgv

2015-10-14 10:51

developer   ~0046716

// GLSL Fragment shader resolving MSAA buffer into normal buffer
uniform sampler2DMS uColorSampler;
uniform sampler2DMS uDepthSampler;

int main(void)
{
  // only integer coordinates can be used to fetch from sampler2DMS
  ivec2 aTexCoord = ivec2 (int(gl_FragCoord.x), int(gl_FragCoord.y));

  // fetch depth from the first sample - simple blending is not applicable
  gl_FragDepth = texelFetch (uDepthSampler, aTexCoord, 0).r;"

  // compute average color
  vec3 aColor (0.0, 0.0, 0.0);
  for (int aSample = 0; aSample < THE_NB_SAMPLES; ++aSample)
  {
    aColor += texelFetch (uColorSampler, aTexCoord, aSample).rgb;
  }
  occFragColor = vec4 (aColor / THE_NB_SAMPLES, 1.0);


// GLSL Fragment shader for blitting from one MSAA buffer
// to another one of the same size.
// Uses gl_SampleID variable which forces shader to be executed for each sample individually.
// This vaiable is available in OpenGL 4.0+ and OpenGL ES 3.2+
// or on lower versions with extensions
// GL_ARB_sample_shading and GL_OES_sample_variables.
#version 150
#extension GL_ARB_sample_shading : enable
// or just #version 400

/*
#version 300 es
#extension GL_OES_sample_variables
// or just #version 320 es
*/

uniform sampler2DMS uColorSampler;
uniform sampler2DMS uDepthSampler;

int main(void)
{
  // only integer coordinates can be used to fetch from sampler2DMS
  ivec2 aTexCoord = ivec2 (int(gl_FragCoord.x), int(gl_FragCoord.y));

  gl_FragDepth = texelFetch (uDepthSampler, aTexCoord, gl_SampleID).r;"
  occFragColor = texelFetch (uColorSampler, aTexCoord, gl_SampleID);"

kgv

2015-10-14 10:55

developer   ~0046717

Conservative Morphological Anti-Aliasing (CMAA) can be used as alternative to MSAA and FXAA algorithms, see:
- OpenGL extension GL_INTEL_framebuffer_CMAA.
  https://www.khronos.org/registry/gles/extensions/INTEL/framebuffer_CMAA.txt
- Article describing the algorithm.
  https://software.intel.com/en-us/articles/conservative-morphological-anti-aliasing-cmaa-update

However at the moment it seems there no OpenGL driver implementing this extension yet.

kgv

2015-10-14 11:01

developer   ~0046718

OpenGL ES extension GL_EXT_multisampled_render_to_texture is an alternative to traditional MSAA available on some mobile devices.

Some GPU architectures - such as tile-based renderers - are capable of performing multisampled rendering by storing multisample data in internal high-speed memory and downsampling the data when writing out to external memory after rendering has finished.

Since per-sample data is never written out to external memory, this approach saves bandwidth and storage space.

https://www.khronos.org/registry/gles/extensions/EXT/EXT_multisampled_render_to_texture.txt

kgv

2015-10-14 11:19

developer   ~0046719

The following issues have been observed within implementation:
- Radeon HD 6450 on Windows 7 + AMD Catalyst 15.7 fails to blit between to identical MSAA depth buffers using glBlitFramebuffer(). Debug context emits erroneous message: "glBlitFramebuffer was called with either GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT set while there was no valid depth/stencil attachment on the read framebuffer".
- Redeon R9 290 on Linux + Mesa (RadeonSI) fails to resolve MSAA FBO to screen buffer using glBlitFramebuffer() when color buffers do not match due to alpha channel (e.g. window buffer is RGB8 and FBO is RGBA8).
- RayTracing GLSL programs can no be trivially adapted to use MSAA, because of reading from uOpenGlColorTexture and uOpenGlDepthTexture. Using gl_SampleID within RayTracing core would make evaluation of entire shader per-sample, performing expensive super-sampling rather than lazy multi-sampling. It should be considered to reorganize combining of RayTracing and OpenGL Rasterization to avoid reading from OpenGL Rasterization buffers (write depth value and color as is and rely on fixed functionality for blending colors).

kgv

2015-10-14 12:16

developer   ~0046728

Last edited: 2015-10-14 12:22

Current list of FBOs in OpenGl_View with description:
//! GL_RGBA8, off-screen dump
myFBO;

//! GL_RGBA8, FBOs (Left + Right) containing main scene content.
myMainSceneFbos[2];

//! GL_RGBA8, additional buffers for immediate layer in stereo mode.
myImmediateSceneFbos[2];

//! GL_RGBA32F, either FSAA buffers
//! (for RayTracing, does not actually require higher precision)
//! or PathTracing accumulation buffers (require extra precision).
myRaytraceFBO1;
myRaytraceFBO2;

//! GL_RGBA8, additional FBO used as texture containing OpenGL Rasterization to be fetched within RayTracing core.
myOpenGlFBO


git

2015-10-14 15:26

administrator   ~0046740

Branch CR26711_1 has been created by kgv.

SHA-1: f691f053277613e52f307f466e43d06d4a38223e


Detailed log of new commits:

Author: kgv
Date: Wed Oct 14 15:26:28 2015 +0300

    0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs
    
    OpenGl_Texture::Init2DMultisample() - new method to initialize multisampled texture.
    Graphic3d_RenderingParams::NbMsaaSamples - add option defining MSAA samples number.
    
    RayTracing will keep using FBO without MSAA, however it is possible to combine
    MSAA for rasterization and FSAA for RayTracing.
    
    OpenGl_FrameBuffer constructor has been changed to do not take arguments.
    OpenGl_FrameBuffer::Init() method has been extended with mandatory parameters
    defining Color and Depth attachment formats
    and optional parameter defining number of MSAA parameters.
    
    Draw Harness, add option -msaa to vrenderparams.

git

2015-10-14 15:39

administrator   ~0046742

Branch CR26711_1 has been updated forcibly by kgv.

SHA-1: 8be893e9a141467263bc035c31b2a698a5170175

kgv

2015-10-14 15:41

developer   ~0046743

Patch is ready for review.

san

2015-10-20 19:50

developer   ~0047241

Branch CR26711_1 reviewed without remarks, ready for testing.

mkv

2015-10-20 20:30

tester   ~0047243

Dear kgv,
could you please rebase branch CR26711_1 on current master, there are conflict files.

git

2015-10-20 20:43

administrator   ~0047244

Branch CR26711_1 has been updated forcibly by kgv.

SHA-1: 5ca942863a4415e19111ccde871ca4c460222e97

kgv

2015-10-20 20:44

developer   ~0047245

Dear mkv,

branch has been rebased onto current master.
There have not been any merge conflicts.

mkv

2015-10-21 12:59

tester   ~0047265

Dear BugMaster,
Branch CR26711_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
SHA-1: 5ca942863a4415e19111ccde871ca4c460222e97

There are following compilation errors:

Windows:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26711-1-master/job/CR26711-1-master_build_occt_windows_64/1/parsed_console/
95>d:\builds\vc10\cr26711-1-master-occt-64\inc\opengl_framebuffer.hxx(126): error C4716: 'OpenGl_FrameBuffer::InitLazy' : must return a value

Number of compiler warnings:

occt component :
Linux: 12 (8 on master)

products component :
Linux: 39 (39 on master)

There is new additional compilation warning on Linux platform:
http://jenkins-test-01.nnov.opencascade.com:8080/user/mnt/my-views/view/A_mnt_warnings/portlet/dashboard_portlet_17008/job/CR26711-1-master_build_occt_linux/1/warnings17Result/package.-133837126/
OpenGl_View.cxx:54, GNU C Compiler 4 (gcc), Priority: Normal
when initialized here [-Wreorder]

http://jenkins-test-01.nnov.opencascade.com:8080/user/mnt/my-views/view/A_mnt_warnings/portlet/dashboard_portlet_17008/job/CR26711-1-master_build_occt_linux/1/warnings17Result/package.-671474530/
OpenGl_FrameBuffer.hxx:126, GNU C Compiler 4 (gcc), Priority: Normal
no return statement in function returning non-void [-Wreturn-type]
OpenGl_View.hxx:605, GNU C Compiler 4 (gcc), Priority: Normal
'GLint OpenGl_View::myFboColorFormat' [-Wreorder]
OpenGl_View.hxx:611, GNU C Compiler 4 (gcc), Priority: Normal
'OpenGl_View::myToFlipOutput' will be initialized after [-Wreorder]

mkv

2015-10-21 13:00

tester   ~0047266

Dear kgv,
Branch CR26711_1 has been rejected due to:
- compilation errors
- additional warnings

git

2015-10-21 19:04

administrator   ~0047301

Branch CR26711_1 has been updated by kgv.

SHA-1: 021202b77816ca483fb4a7dad65359b7553c1342


Detailed log of new commits:

Author: kgv
Date: Wed Oct 21 19:04:46 2015 +0300

    fix compilation issues

git

2015-10-21 19:06

administrator   ~0047302

Branch CR26711_2 has been created by kgv.

SHA-1: 905d3c5a413528f451c0b5776c491af3e3bb1d5c


Detailed log of new commits:

Author: kgv
Date: Wed Oct 21 19:06:02 2015 +0300

    0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs
    
    OpenGl_Texture::Init2DMultisample() - new method to initialize multisampled texture.
    Graphic3d_RenderingParams::NbMsaaSamples - add option defining MSAA samples number.
    
    RayTracing will keep using FBO without MSAA, however it is possible to combine
    MSAA for rasterization and FSAA for RayTracing.
    
    OpenGl_FrameBuffer constructor has been changed to do not take arguments.
    OpenGl_FrameBuffer::Init() method has been extended with mandatory parameters
    defining Color and Depth attachment formats
    and optional parameter defining number of MSAA parameters.
    
    Draw Harness, add option -msaa to vrenderparams.

kgv

2015-10-21 19:06

developer   ~0047303

Please test updated patch from branch CR26711_2.

mkv

2015-10-22 17:49

tester   ~0047347

Dear kgv,
could you please rebase branch CR26711_2 on IR-2015-10-22, there are conflict files.

git

2015-10-22 18:23

administrator   ~0047349

Branch CR26711_3 has been created by kgv.

SHA-1: 1eae662e547d34d2e83d82beb71c3c2d9e23ee83


Detailed log of new commits:

Author: kgv
Date: Wed Oct 21 19:06:02 2015 +0300

    0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs
    
    OpenGl_Texture::Init2DMultisample() - new method to initialize multisampled texture.
    Graphic3d_RenderingParams::NbMsaaSamples - add option defining MSAA samples number.
    
    RayTracing will keep using FBO without MSAA, however it is possible to combine
    MSAA for rasterization and FSAA for RayTracing.
    
    OpenGl_FrameBuffer constructor has been changed to do not take arguments.
    OpenGl_FrameBuffer::Init() method has been extended with mandatory parameters
    defining Color and Depth attachment formats
    and optional parameter defining number of MSAA parameters.
    
    Draw Harness, add option -msaa to vrenderparams.

kgv

2015-10-22 18:24

developer   ~0047350

Please test rebased patch in branch CR26711_3.

mkv

2015-10-26 14:26

tester   ~0047439

Dear BugMaster,
Branch CR26711_3 was rebased on branch IR-2015-10-22 of occt git-repository.
SHA-1: 1eae662e547d34d2e83d82beb71c3c2d9e23ee83

mkv

2015-10-26 14:26

tester   ~0047440

Dear BugMaster,
Branch CR26711_3 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
SHA-1: 1eae662e547d34d2e83d82beb71c3c2d9e23ee83

Number of compiler warnings:

occt component :
Linux: 1 (1 on master)
Windows: 0 (0 on master)

products component :
Linux: 39 (39 on master)
Windows: 0 (0 on master)

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
http://occt-tests/CR26711-3-master-occt-64/Debian70-64/v3d/glsl/msaa.html
http://occt-tests/CR26711-3-master-occt-64/Windows-64-VC10/v3d/glsl/msaa.html
v3d glsl msaa: OK

Testing on Linux:
occt component :
Total MEMORY difference: 92314267 / 92336834 [-0.02%]
Total CPU difference: 19748.929999999793 / 19731.589999999687 [+0.09%]
products component :
Total MEMORY difference: 26175596 / 26216391 [-0.16%]
Total CPU difference: 7404.779999999986 / 7362.230000000012 [+0.58%]

Testing on Windows:
occt component :
Total MEMORY difference: 58075754 / 58088905 [-0.02%]
Total CPU difference: 18238.513712798926 / 18494.667354799 [-1.39%]
products component :
Total MEMORY difference: 17128002 / 17132478 [-0.03%]
Total CPU difference: 5526.741027599959 / 5651.245425699974 [-2.20%]

There are no differences in images found by testdiff.

mkv

2015-10-26 14:27

tester   ~0047441

Dear BugMaster,
Branch CR26711_3 is TESTED.

git

2016-04-17 14:35

administrator   ~0053198

Branch CR26711 has been deleted by kgv.

SHA-1: 454b6834af8e898899efd1b337693ea3cf7d0076

git

2016-04-17 14:35

administrator   ~0053199

Branch CR26711_1 has been deleted by kgv.

SHA-1: 021202b77816ca483fb4a7dad65359b7553c1342

git

2016-04-17 14:35

administrator   ~0053200

Branch CR26711_2 has been deleted by kgv.

SHA-1: 905d3c5a413528f451c0b5776c491af3e3bb1d5c

git

2016-04-17 14:35

administrator   ~0053201

Branch CR26711_3 has been deleted by kgv.

SHA-1: 1eae662e547d34d2e83d82beb71c3c2d9e23ee83

Related Changesets

occt: master 3c4b62a4

2015-10-21 16:06:02

kgv


Committer: bugmaster Details Diff
0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs

OpenGl_Texture::Init2DMultisample() - new method to initialize multisampled texture.
Graphic3d_RenderingParams::NbMsaaSamples - add option defining MSAA samples number.

RayTracing will keep using FBO without MSAA, however it is possible to combine
MSAA for rasterization and FSAA for RayTracing.

OpenGl_FrameBuffer constructor has been changed to do not take arguments.
OpenGl_FrameBuffer::Init() method has been extended with mandatory parameters
defining Color and Depth attachment formats
and optional parameter defining number of MSAA parameters.

Draw Harness, add option -msaa to vrenderparams.
Affected Issues
0026711
mod - src/Graphic3d/Graphic3d_RenderingParams.hxx Diff File
mod - src/OpenGl/OpenGl_Context.cxx Diff File
mod - src/OpenGl/OpenGl_Context.hxx Diff File
mod - src/OpenGl/OpenGl_FrameBuffer.cxx Diff File
mod - src/OpenGl/OpenGl_FrameBuffer.hxx Diff File
mod - src/OpenGl/OpenGl_GlFunctions.hxx Diff File
mod - src/OpenGl/OpenGl_Texture.cxx Diff File
mod - src/OpenGl/OpenGl_Texture.hxx Diff File
mod - src/OpenGl/OpenGl_View.cxx Diff File
mod - src/OpenGl/OpenGl_View.hxx Diff File
mod - src/OpenGl/OpenGl_View_Print.cxx Diff File
mod - src/OpenGl/OpenGl_View_Raytrace.cxx Diff File
mod - src/OpenGl/OpenGl_View_Redraw.cxx Diff File
mod - src/OpenGl/OpenGl_Window_1.mm Diff File
mod - src/OpenGl/OpenGl_Workspace.cxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
add - tests/v3d/glsl/msaa Diff File

Issue History

Date Modified Username Field Change
2015-09-19 16:15 kgv New Issue
2015-09-19 16:15 kgv Assigned To => kgv
2015-09-19 16:46 git Note Added: 0045932
2015-09-19 18:56 git Note Added: 0045935
2015-09-19 19:04 kgv File Added: penrose_msaa_off.png
2015-09-19 19:04 kgv File Added: penrose_msaa_8.png
2015-10-07 15:52 kgv Relationship added has duplicate 0026756
2015-10-14 10:51 kgv Note Added: 0046716
2015-10-14 10:55 kgv Note Added: 0046717
2015-10-14 10:56 kgv Description Updated
2015-10-14 11:01 kgv Note Added: 0046718
2015-10-14 11:19 kgv Note Added: 0046719
2015-10-14 12:16 kgv Note Added: 0046728
2015-10-14 12:22 kgv Note Edited: 0046728
2015-10-14 15:26 git Note Added: 0046740
2015-10-14 15:28 kgv Steps to Reproduce Updated
2015-10-14 15:39 git Note Added: 0046742
2015-10-14 15:41 kgv Note Added: 0046743
2015-10-14 15:41 kgv Assigned To kgv => san
2015-10-14 15:41 kgv Status new => resolved
2015-10-20 19:50 san Note Added: 0047241
2015-10-20 19:50 san Assigned To san => bugmaster
2015-10-20 19:50 san Status resolved => reviewed
2015-10-20 20:17 mkv Assigned To bugmaster => mkv
2015-10-20 20:30 mkv Note Added: 0047243
2015-10-20 20:30 mkv Assigned To mkv => kgv
2015-10-20 20:30 mkv Status reviewed => feedback
2015-10-20 20:43 git Note Added: 0047244
2015-10-20 20:44 kgv Note Added: 0047245
2015-10-20 20:44 kgv Assigned To kgv => bugmaster
2015-10-20 20:44 kgv Status feedback => reviewed
2015-10-20 20:48 mkv Assigned To bugmaster => mkv
2015-10-21 12:59 mkv Note Added: 0047265
2015-10-21 13:00 mkv Note Added: 0047266
2015-10-21 13:00 mkv Assigned To mkv => kgv
2015-10-21 13:00 mkv Status reviewed => assigned
2015-10-21 19:04 git Note Added: 0047301
2015-10-21 19:06 git Note Added: 0047302
2015-10-21 19:06 kgv Note Added: 0047303
2015-10-21 19:06 kgv Assigned To kgv => bugmaster
2015-10-21 19:06 kgv Status assigned => resolved
2015-10-21 19:06 kgv Status resolved => reviewed
2015-10-22 14:43 mkv Assigned To bugmaster => mkv
2015-10-22 17:49 mkv Note Added: 0047347
2015-10-22 17:49 mkv Assigned To mkv => kgv
2015-10-22 17:49 mkv Status reviewed => feedback
2015-10-22 18:23 git Note Added: 0047349
2015-10-22 18:24 kgv Note Added: 0047350
2015-10-22 18:24 kgv Assigned To kgv => bugmaster
2015-10-22 18:24 kgv Status feedback => reviewed
2015-10-22 19:31 mkv Assigned To bugmaster => mkv
2015-10-26 14:26 mkv Note Added: 0047439
2015-10-26 14:26 mkv Note Added: 0047440
2015-10-26 14:27 mkv Note Added: 0047441
2015-10-26 14:27 mkv Assigned To mkv => bugmaster
2015-10-26 14:27 mkv Status reviewed => tested
2015-10-26 14:27 mkv Test case number => v3d glsl msaa
2015-10-30 16:00 bugmaster Changeset attached => occt master 3c4b62a4
2015-10-30 16:00 bugmaster Status tested => verified
2015-10-30 16:00 bugmaster Resolution open => fixed
2015-11-02 17:49 kgv Relationship added parent of 0026834
2016-04-06 12:18 san Relationship added related to 0024324
2016-04-06 12:34 san Relationship added related to 0027360
2016-04-17 14:35 git Note Added: 0053198
2016-04-17 14:35 git Note Added: 0053199
2016-04-17 14:35 git Note Added: 0053200
2016-04-17 14:35 git Note Added: 0053201
2016-04-20 15:42 aiv Fixed in Version => 7.0.0
2016-04-20 15:51 aiv Status verified => closed
2016-06-16 11:52 kgv Relationship added related to 0027606
2016-08-09 10:12 kgv Relationship added related to 0027755
2017-04-02 16:50 kgv Relationship added parent of 0028615