Bug 1073

Summary: Fix FBObject/GLFBODrawable: Redundancies, bind/unbind, renderbuffer depth/stencil bits
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: major CC: sgothel
Priority: ---    
Version: 2.3.0   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
84f367a73c5b16dcebfd877e82e1c2cb90ae74ce aee2343620d0426fb7275a75a95c24eb4a4ccd83 91508fb026746c8b659e29bd7e62678e6aff892a fce65d0b8887387bfb71bbfeea63bc7915163399 a7ff8b898780762b763c0b4544728067375955b6 711757aa4e087d97c3103489c47fbd7d76bcac3d e99f5060d62aad25fcc37ebf50c8f2a270c9d5df 4d8d41d32b27ab8dc6a3898511011f8b3d4f07a5 38f6915fedb765313c1f4646acf9e13dfbccef36
Workaround: ---

Description Sven Gothel 2014-09-20 21:42:27 CEST
- FBOObject : Remove redundancies
  - resetSamplingSink(..) shall only be called if required

  - resetSamplingSink(..) shall operate more simple

  - don't instantiate samplingSink early, might get re-defined 
    by fbo.setSamplingSink(..)

  - validate samplingSink passed by setSamplingSink(..)

  - Only expose dedicated init(..) and reset(..) methods,
    dropping dual-use reset(..) methods.
    This clarifies user code and state validation alot.

  - reset(..) and resetSamplingSink() shall return a boolean
    value stating whether operation has modified the instance.

  - isModified() shall be added to query whether the instances
    size, format or any attachments has been modified 
    since last sync*(), use() or resetSamplingSink() call.

- Close all FBObject bind w/ unbind
  - Ensure all bind(gl) operations at least are 
    completed by one markUnbound() for correctness

- Fix renderbuffer depth/stencil usage and format
  - Remove GLFBODrawable.FBOMODE_USE_DEPTH, 
    code shall use GLCapabilities.[get|set]DepthBits(..),
    similar to stencilBits.

    Note: Applications shall use _requested_ GLCapabilities,
    if passing caps down to the GLFBODrawable.
    Otherwise (using _chosen_ caps) we may end up in requesting
    properties not desired, e.g. stencil bits, if driver has chosen.

  - Allow generic bit count arguments for fbo.attachRenderbuffer(..)

  - Proper fallback for renderbuffer depth/stencil  bit count
Comment 1 Sven Gothel 2014-09-20 21:45:38 CEST
84f367a73c5b16dcebfd877e82e1c2cb90ae74ce

GLJPanel Cleanup: Remove initial FBO reshape; Propagate reshape only if differs from panel-size; Use pre-fetched panel-size.

++++

aee2343620d0426fb7275a75a95c24eb4a4ccd83

FBObject.reset(..): Return true if modified, otherwise false

+++
Comment 2 Sven Gothel 2014-09-20 21:46:17 CEST
91508fb026746c8b659e29bd7e62678e6aff892a

GLFBODrawableImpl: Utilize common self-contained setupFBO(..) method for FBO creation incl. Bug 1020 glClear(..) ; Fixes missing fbo.unbind(gl)

Utilize common self-contained setupFBO(..) method for FBO creation incl. Bug 1020 glClear(..)
  initialize(..) and reset(..)'s fallback code
  contained duplicated FBO setup/creation code.

  The former was updated to suite the new FBO mode bits,
  where the latter left untouched, hence was buggy.

  Now setup and creation of a single FBO has been merged into setupFBO(..).

Fixes missing fbo.unbind(gl):
  We did no issue unbind() on each fbo instance
  while adding the workaround for Bug 1020.

  Adding fbo.markUnbound() call to all fbos but the last.

  Note: This might not cause any issues, since fbo.bind(gl) tests the currently bound fbo.
Comment 3 Sven Gothel 2014-09-20 21:47:57 CEST
fce65d0b8887387bfb71bbfeea63bc7915163399

FBOobject GLEL Tests: Remove redundant detachAllColorbuffer(gl) for init call

+++

a7ff8b898780762b763c0b4544728067375955b6

StereoClientRenderer: Remove redundant FBObject.detachAllColorbuffer(gl) for init call

+++
Comment 4 Sven Gothel 2014-09-20 21:49:15 CEST
711757aa4e087d97c3103489c47fbd7d76bcac3d

- FBObject: Simplify API (init/reset)
- Only issue automatic resetSamplingSink(..) if required; 
- Fix resetSamplingSink(..), isBound(), ..

+++

- Simplify API (init/reset)
  - use new unique methods for init and reset:
    - void init(final GL gl, final int newWidth, final int newHeight, final int newSamples)
      - does not issue resetSamplingSink(..)
    - boolean reset(final GL gl, final int newWidth, final int newHeight, final int newSamples)
      - always issues resetSamplingSink(..)

  - deprecated dual-use (init/reset):
    - boolean reset(final GL gl, final int newWidth, final int newHeight)
    - boolean reset(final GL gl, int newWidth, int newHeight, int newSamples, final boolean resetSamplingSink)

- reset(..) no more creates a dummy 'samplingSink' instance if sampling > 0,
  left up to resetSamplingSink(..)

- Track 'modified' state of FBObject,
  if size, format or any attachment has been changed since last
    - use(..)
    - syncSamplingSink(..)
    - resetSamplingSink(..)

- Only issue resetSamplingSink(..) from syncSamplingSink(..)/use(..)
  if 'modified == true'

+++

- Fix setSamplingSink(..), i.e. samplingSink state handling:
  - Validated whether given samplingSink is initialized,
    throws Exception if not.

- Fix resetSamplingSink(..)
  - resets the bound state, i.e. leaves it untouched
    - also unbinds the samplingSink

  - sampleSinkDepthStencilMismatch() also returns true if
    this.depth/stencil == null, but samplingSink is not.

  - Newly created colorbuffer/-texture matches
    exiting colorbuffer's internal-format, if exists.

  - Using simplified resetSizeImpl(..) for size mismatch

  - Simplified samplingColorSink init check

- Fix isBound()
    was: 'bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)'
    fix: 'bound = bound && fbName == gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)'

- Fix detachRenderbuffer(..) validates whether detachment was successful,
  similar to detachColorbuffer(..)
Comment 5 Sven Gothel 2014-09-20 21:56:44 CEST
e99f5060d62aad25fcc37ebf50c8f2a270c9d5df

FBObject: Fix depth- and stencil bit count selection for attachRenderbuffer(..);

- Fix depth- and stencil bit count selection for attachRenderbuffer(..)
  - Add generic values: DEFAULT_BITS, REQUESTED_BITS, CHOSEN_BITS, MAXIMUM_BITS

  - Refactor depth- and stencil bit-count -> format into own method

  - Allow depth- and stencil bit-count select a higher bit-count if required (fix)

- GLFBODrawable.FBOMODE_USE_DEPTH is deprecated, using GLCapabilities.[get|set]DepthBits(..)
  - It was an oversight to introduce the bit flag in the first place,
    since we should have used the capabilities depth bit-count

- Graph Test: GLEventListenerButton shall use requested capabilities for FBO drawable.
Comment 6 Sven Gothel 2014-09-20 21:58:20 CEST
4d8d41d32b27ab8dc6a3898511011f8b3d4f07a5

- Add GLJPanelsAndGLCanvasDemoGL2Applet: 
  - Simple applet test for GLJPanel/GL2 testing (offscreen, ..)

- Clean up GL2 Gears and Teapot state enable/disable

+++

38f6915fedb765313c1f4646acf9e13dfbccef36

FBObject/GLFBODrawable: Remove deprecated methods
    
- dual-use reset(..), use dedicated init(..) and reset(..)
    
- GLFBODrawable.FBOMODE_USE_DEPTH: Use GLCapabilities.[get|set]DepthBits(int)
    Note: Applications shall use _requested_ GLCapabilities,
    if passing caps down to the GLFBODrawable.
    Otherwise (using _chosen_ caps) we may end up in requesting
    properties not desired, e.g. stencil bits, if driver has chosen.