void TransparencyManagerOITClosestArray::layersCountChanged()
 {
   if ( getShaderManager() )
   {
     unsigned int lc = getLayersCount();
     getShaderManager()->updateFragmentParameter( std::string( "sys_OITDepth" ), dp::rix::core::ContainerDataRaw( 0, &lc, sizeof(unsigned int) ) );
   }
 }
BOOST_FIXTURE_TEST_CASE(mappingFirst, myFixture)
{
  auto bank = fparamManagerInstance.getParamBank();
  auto mapping = JPetGeomMapping(bank);
  BOOST_REQUIRE_EQUAL(mapping.getLayersCount(), 3u);
  BOOST_REQUIRE_EQUAL(mapping.getLayersCount(),
                      3u); // is checking same thing 2 times was intended?
  JPetLayer layerOK(1, true, "Layer01", 42.5);
  JPetLayer layerWrong(2, true, "Layer02", 50);

  BOOST_REQUIRE_EQUAL(mapping.getLayerNumber(layerOK), 1u);
  BOOST_REQUIRE_EQUAL(mapping.getLayerNumber(layerWrong),
                      JPetGeomMapping::kBadLayerNumber);

  BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(0),
                      JPetGeomMapping::kBadSlotNumber);
  BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(1), 2u);
  BOOST_REQUIRE_EQUAL(mapping.getSlotsCount(2), 1u);

  auto sizes = mapping.getLayersSizes();
  BOOST_REQUIRE(!sizes.empty());
  BOOST_REQUIRE_EQUAL(sizes.size(), 3u);
}
//**********************************************************************
// void CCategoryTransitionProcess::validate()
// Validate This Object
//**********************************************************************
void CCategoryTransitionProcess::validate() {
  try {

    // Get our Parameters
    sPenalty  = pParameterList->getString(PARAM_PENALTY, true, "");
    dUMax  = pParameterList->getDouble(PARAM_U_MAX, true, 0.99);
    pParameterList->fillVector(vCategoryList, PARAM_FROM);
    pParameterList->fillVector(vSelectivityList, PARAM_SELECTIVITIES);
    pParameterList->fillVector(vCategoryToList, PARAM_TO);
    pParameterList->fillVector(vYearsList, PARAM_YEARS);
    pParameterList->fillVector(vLayersList, PARAM_LAYERS);

    // Base Validation
    CProcess::validate();

    // Local validation
    // Check for Duplicate Year
    map<int, int> mYears;
    foreach(int Year, vYearsList) {
      mYears[Year]++;
      if (mYears[Year] > 1)
        CError::errorDuplicate(PARAM_YEAR, boost::lexical_cast<string>(Year));
    }

    if (getCategoryCount() != getSelectivityCount())
      CError::errorListSameSize(PARAM_FROM, PARAM_SELECTIVITIES);
    if (getCategoryCount() != getCategoryToCount())
      CError::errorListSameSize(PARAM_FROM, PARAM_TO);
    if (getYearsCount() != getLayersCount())
      CError::errorListSameSize(PARAM_YEARS, PARAM_LAYERS);

    if (dUMax > ONE)
      CError::errorGreaterThan(PARAM_U_MAX, PARAM_ONE);
    if (dUMax <= TRUE_ZERO)
      CError::errorLessThanEqualTo(PARAM_U_MAX, PARAM_ZERO);

  } catch(string &Ex) {
          void TransparencyManagerOITClosestArray::beginTransparentPass( dp::rix::core::Renderer * renderer )
          {
            DP_ASSERT( renderer );

            TransparencyManager::beginTransparentPass( renderer );

            if ( !m_initializedHandles )
            {
              // create the VBO for the full screen quad
              GLfloat fullScreenQuadVertices[8] = { -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f };
              m_fullScreenQuad = dp::gl::Buffer::create(dp::gl::Buffer::CORE, GL_STATIC_DRAW, GL_ARRAY_BUFFER);
              m_fullScreenQuad->setSize(8 * sizeof(GLfloat));
              m_fullScreenQuad->update(fullScreenQuadVertices);

              dp::gl::VertexShaderSharedPtr vertexShader = dp::gl::VertexShader::create( dp::util::loadStringFromFile( dp::home() + "/media/dpfx/passThroughPosition_vs.glsl" ) );
              dp::gl::FragmentShaderSharedPtr fragmentShader = dp::gl::FragmentShader::create( dp::util::loadStringFromFile( dp::home() + "/media/dpfx/oitClosestArrayClear_fs.glsl" ) );
              m_clearProgram = dp::gl::ProgramInstance::create( dp::gl::Program::create( vertexShader, fragmentShader ) );

              // create fragment shader source
              std::string resolveFragmentCode = dp::util::loadStringFromFile( dp::home() + "/media/dpfx/oitClosestArrayResolve_fs.glsl" );
              std::ostringstream oss;
              oss << getLayersCount();
              std::unique_ptr<char[]> resolveFragmentSource( new char[resolveFragmentCode.length() + oss.str().length()] );
              sprintf( resolveFragmentSource.get(), resolveFragmentCode.c_str(), oss.str().c_str() );

              // vertexShader is the same as for m_clearProgram !
              fragmentShader = dp::gl::FragmentShader::create( resolveFragmentSource.get() );
              m_resolveProgram = dp::gl::ProgramInstance::create( dp::gl::Program::create( vertexShader, fragmentShader ) );

              m_initializedHandles = true;
            }
            if ( !m_initializedBuffers )
            {
              dp::math::Vec2ui viewportSize = getViewportSize();
              m_perFragmentCountTextureGL       = dp::gl::Texture2D::create( GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, viewportSize[0], viewportSize[1] );
              m_perFragmentIndexTextureGL       = dp::gl::Texture2D::create( GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, viewportSize[0], viewportSize[1] );
              m_perFragmentSpinLockTextureGL    = dp::gl::Texture2D::create( GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, viewportSize[0], viewportSize[1] );
              m_perFragmentSamplesAccuTextureGL = dp::gl::Texture2D::create( GL_RGBA32F, GL_RGBA, GL_FLOAT, viewportSize[0], viewportSize[1] );
              m_perFragmentSamplesAccuTextureGL->setFilterParameters( GL_NEAREST, GL_NEAREST );

              m_samplesTextureGL = dp::gl::TextureBuffer::create( GL_RG32UI, getLayersCount() * viewportSize[0] * viewportSize[1] * 2 * sizeof(GLuint), nullptr, GL_DYNAMIC_COPY );

              m_clearProgram->setImageUniform( "perFragmentCount", m_perFragmentCountTextureGL, GL_WRITE_ONLY );
              m_clearProgram->setImageUniform( "perFragmentIndex", m_perFragmentIndexTextureGL, GL_WRITE_ONLY );
              m_clearProgram->setImageUniform( "perFragmentSpinLock", m_perFragmentSpinLockTextureGL, GL_WRITE_ONLY );
              m_clearProgram->setImageUniform( "perFragmentSamplesAccu", m_perFragmentSamplesAccuTextureGL, GL_WRITE_ONLY );

              m_resolveProgram->setImageUniform( "perFragmentCount", m_perFragmentCountTextureGL, GL_READ_ONLY );
              m_resolveProgram->setImageUniform( "perFragmentSamplesAccu", m_perFragmentSamplesAccuTextureGL, GL_READ_ONLY );
              m_resolveProgram->setImageUniform( "samplesBuffer", m_samplesTextureGL, GL_READ_ONLY );

              m_initializedBuffers = true;
            }

            // clear the oit buffers
            glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
            glDepthMask( GL_FALSE );
            m_clearProgram->apply();
            drawQuad();
            glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
            glDepthMask( GL_TRUE );
            glMemoryBarrier( GL_SHADER_IMAGE_ACCESS_BARRIER_BIT );

            // settings for oit path
            glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
            glDepthMask( GL_FALSE );                              // don't use depth

            renderer->textureSetData( m_perFragmentCountTexture, dp::rix::gl::TextureDataGLTexture( m_perFragmentCountTextureGL ) );
            renderer->textureSetData( m_perFragmentIndexTexture, dp::rix::gl::TextureDataGLTexture( m_perFragmentIndexTextureGL ) );
            renderer->textureSetData( m_perFragmentSpinLockTexture, dp::rix::gl::TextureDataGLTexture( m_perFragmentSpinLockTextureGL ) );
            renderer->textureSetData( m_samplesTexture, dp::rix::gl::TextureDataGLTexture( m_samplesTextureGL ) );
            renderer->textureSetData( m_perFragmentSamplesAccuTexture, dp::rix::gl::TextureDataGLTexture( m_perFragmentSamplesAccuTextureGL ) );
          }