Example #1
0
//---------------------------------------------------------------------------//
  void GpuBufferGL4::unlock()
  {
    // Don't unlock persistently mapped resources
    if (isLockedPersistent() && isLocked())
    {
      return;
    }

    ASSERT(isLocked(), "Tried to unlock and unlocked buffer");
    _unlock(getBufferIndex());

    m_clStateInfos.isLocked = false;
    m_clStateInfos.isLockedPersistent = false;
  }
Example #2
0
void LoopLayer::input(uint64_t clockFrame, float signal)
{
  if (recording) {
    write(getBufferIndex(clockFrame), signal);
  }
}
Example #3
0
//---------------------------------------------------------------------------//
  void* GpuBufferGL4::lock( GpuResoruceLockOption eLockOption, 
    uint uOffsetElements /* = 0u */, uint uNumElements /* = 0u */ )
  {
    const GLuint uLockOptionsGL = Internal::mapLockOption(eLockOption);

    // We always keep persistently locked buffers locked for its entire lifetime, so just return the
    // cached and appropriately offset pointer here
    if ((uLockOptionsGL & GL_MAP_PERSISTENT_BIT) > 0 && isLocked())
    {
      if (m_eMultiBufferStrategy == MultiBufferingStrategy::NONE ||
          m_eMultiBufferStrategy == MultiBufferingStrategy::BUFFERS)
      {
        return m_pCachedLockPtr;
      }
      else  // MultiBufferingStrategy::OFFSETS
      {
        return static_cast<uint8*>(m_pCachedLockPtr) + (MultiBuffering::getCurrentBufferIndex() * m_clParameters.uTotalSizeBytes);
      }
    }

    if (uNumElements == 0u )
    {
      if (m_eMultiBufferStrategy == MultiBufferingStrategy::NONE || m_eMultiBufferStrategy == MultiBufferingStrategy::BUFFERS)
      {
        uNumElements = m_clParameters.uNumElements;
      }
      else
      {
        uNumElements = m_clParameters.uNumElements * MultiBuffering::kGpuMultiBufferingCount;
      }
    }
    
    ASSERT(isValid(), "Tried to lock an uninitialized buffer");
    ASSERT(!isLocked(), "Buffer is already locked");
    ASSERT(uOffsetElements < m_clParameters.uNumElements, "Invalid lock-range provided");

    const uint offsetBytes = uOffsetElements * m_clParameters.uElementSizeBytes;
    const uint rangeBytes = uNumElements * m_clParameters.uElementSizeBytes;
    
    GLint origBoundBuffer;
    glGetIntegerv(m_clParameters.eBindingQueryType, &origBoundBuffer);
    glBindBuffer(m_clParameters.eInitialBufferTargetGL, getGLhandle());

    m_pCachedLockPtr = glMapBufferRange(m_clParameters.eInitialBufferTargetGL, 
         offsetBytes, rangeBytes, uLockOptionsGL);

    glBindBuffer(m_clParameters.eInitialBufferTargetGL, origBoundBuffer);

    ASSERT(m_pCachedLockPtr, "Buffer-lock failed");
    m_clStateInfos.isLocked = true;
    if ((uLockOptionsGL & GL_MAP_PERSISTENT_BIT) > 0u)
    {
      m_clStateInfos.isLockedPersistent = true;
    }

    void* returnPtr = m_pCachedLockPtr;

    if (m_eMultiBufferStrategy == MultiBufferingStrategy::OFFSETS)
    {
      returnPtr = static_cast<uint8*>(returnPtr) + (getBufferIndex() * m_clParameters.uTotalSizeBytes);
    }

    return returnPtr;
  }
Example #4
0
float LoopLayer::read(uint64_t clockFrame)
{
  return buffer[getBufferIndex(clockFrame)] * mul;
}