예제 #1
0
S32 TSThread::getKeyframeNumber()
{
   AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeNumber: not while in transition");

   return keyNum1;
}
예제 #2
0
static void rtMemReplaceMallocAndFriends(void)
{
    struct
    {
        const char *pszName;
        PFNRT       pfnReplacement;
        PFNRT       pfnOrg;
        PFNRT      *ppfnJumpBack;
    } aApis[] =
    {
        { "free",    (PFNRT)rtMemReplacementFree,    (PFNRT)free,    (PFNRT *)&g_pfnOrgFree },
        { "realloc", (PFNRT)rtMemReplacementRealloc, (PFNRT)realloc, (PFNRT *)&g_pfnOrgRealloc },
        { "calloc",  (PFNRT)rtMemReplacementCalloc,  (PFNRT)calloc,  (PFNRT *)&g_pfnOrgCalloc },
        { "malloc",  (PFNRT)rtMemReplacementMalloc,  (PFNRT)malloc,  (PFNRT *)&g_pfnOrgMalloc },
#ifdef RT_OS_DARWIN
        { "malloc_size", (PFNRT)rtMemReplacementMallocSize,  (PFNRT)malloc_size,  (PFNRT *)&g_pfnOrgMallocSize },
#endif
    };

    /*
     * Initialize the jump backs to avoid recursivly entering this function.
     */
    for (unsigned i = 0; i < RT_ELEMENTS(aApis); i++)
        *aApis[i].ppfnJumpBack = aApis[i].pfnOrg;

    /*
     * Give the user an option to skip replacing malloc.
     */
    if (getenv("IPRT_DONT_REPLACE_MALLOC"))
        return;

    /*
     * Allocate a page for jump back code (we leak it).
     */
    uint8_t *pbExecPage = (uint8_t *)RTMemPageAlloc(PAGE_SIZE); AssertFatal(pbExecPage);
    int rc = RTMemProtect(pbExecPage, PAGE_SIZE, RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC); AssertFatalRC(rc);

    /*
     * Do the ground work.
     */
    uint8_t *pb = pbExecPage;
    for (unsigned i = 0; i < RT_ELEMENTS(aApis); i++)
    {
        /* Resolve it. */
        PFNRT pfnOrg = (PFNRT)(uintptr_t)dlsym(RTLD_DEFAULT, aApis[i].pszName);
        if (pfnOrg)
            aApis[i].pfnOrg = pfnOrg;
        else
            pfnOrg = aApis[i].pfnOrg;

        /* Figure what we can replace and how much to duplicate in the jump back code. */
# ifdef RT_ARCH_AMD64
        uint32_t         cbNeeded   = 12;
        DISCPUMODE const enmCpuMode = DISCPUMODE_64BIT;
# elif defined(RT_ARCH_X86)
        uint32_t   const cbNeeded   = 5;
        DISCPUMODE const enmCpuMode = DISCPUMODE_32BIT;
# else
#  error "Port me"
# endif
        uint32_t offJmpBack = 0;
        uint32_t cbCopy = 0;
        while (offJmpBack < cbNeeded)
        {
            DISCPUSTATE Dis;
            uint32_t cbInstr = 1;
            rc = DISInstr((void *)((uintptr_t)pfnOrg + offJmpBack), enmCpuMode, &Dis, &cbInstr); AssertFatalRC(rc);
            AssertFatal(!(Dis.pCurInstr->fOpType & (DISOPTYPE_CONTROLFLOW)));
# ifdef RT_ARCH_AMD64
#  ifdef RT_OS_DARWIN
            /* Kludge for: cmp [malloc_def_zone_state], 1; jg 2; call _malloc_initialize; 2: */
            DISQPVPARAMVAL Parm;
            if (   Dis.ModRM.Bits.Mod == 0
                && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */
                && (Dis.Param2.fUse & (DISUSE_IMMEDIATE16_SX8 | DISUSE_IMMEDIATE32_SX8 | DISUSE_IMMEDIATE64_SX8))
                && Dis.Param2.uValue == 1
                && Dis.pCurInstr->uOpcode == OP_CMP)
            {
                cbCopy = offJmpBack;

                offJmpBack += cbInstr;
                rc = DISInstr((void *)((uintptr_t)pfnOrg + offJmpBack), enmCpuMode, &Dis, &cbInstr); AssertFatalRC(rc);
                if (   Dis.pCurInstr->uOpcode == OP_JNBE
                    && Dis.Param1.uDisp.i8 == 5)
                {
                    offJmpBack += cbInstr + 5;
                    AssertFatal(offJmpBack >= cbNeeded);
                    break;
                }
            }
#  endif
            AssertFatal(!(Dis.ModRM.Bits.Mod == 0 && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */));
# endif
            offJmpBack += cbInstr;
        }
        if (!cbCopy)
            cbCopy = offJmpBack;

        /* Assemble the jump back. */
        memcpy(pb, (void *)(uintptr_t)pfnOrg, cbCopy);
        uint32_t off = cbCopy;
# ifdef RT_ARCH_AMD64
        pb[off++] = 0xff; /* jmp qword [$+8 wrt RIP] */
        pb[off++] = 0x25;
        *(uint32_t *)&pb[off] = 0;
        off += 4;
        *(uint64_t *)&pb[off] = (uintptr_t)pfnOrg + offJmpBack;
        off += 8;
        off = RT_ALIGN_32(off, 16);
# elif defined(RT_ARCH_X86)
        pb[off++] = 0xe9; /* jmp rel32 */
        *(uint32_t *)&pb[off] = (uintptr_t)pfnOrg + offJmpBack - (uintptr_t)&pb[4];
        off += 4;
        off = RT_ALIGN_32(off, 8);
# else
#  error "Port me"
# endif
        *aApis[i].ppfnJumpBack = (PFNRT)(uintptr_t)pb;
        pb += off;
    }

    /*
     * Modify the APIs.
     */
    for (unsigned i = 0; i < RT_ELEMENTS(aApis); i++)
    {
        pb = (uint8_t *)(uintptr_t)aApis[i].pfnOrg;
        rc = RTMemProtect(pb, 16, RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC); AssertFatalRC(rc);

# ifdef RT_ARCH_AMD64
        /* Assemble the LdrLoadDll patch. */
        *pb++ = 0x48; /* mov rax, qword */
        *pb++ = 0xb8;
        *(uint64_t *)pb = (uintptr_t)aApis[i].pfnReplacement;
        pb += 8;
        *pb++ = 0xff; /* jmp rax */
        *pb++ = 0xe0;
# elif defined(RT_ARCH_X86)
        *pb++ = 0xe9; /* jmp rel32 */
        *(uint32_t *)pb = (uintptr_t)aApis[i].pfnReplacement - (uintptr_t)&pb[4];
# else
#  error "Port me"
# endif
    }
}
예제 #3
0
void GFXGLShader::initHandles()
{      
   // Mark all existing handles as invalid.
   // Those that are found when parsing the descriptions will then be marked valid again.
   for ( HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter )      
      (iter->value)->setValid( false );  
   mValidHandles.clear();

   // Loop through all ConstantDescriptions, 
   // if they aren't in the HandleMap add them, if they are reinitialize them.
   for ( U32 i = 0; i < mConstants.size(); i++ )
   {
      GFXShaderConstDesc &desc = mConstants[i];            

      // Index element 1 of the name to skip the '$' we inserted earier.
      GLint loc = glGetUniformLocation(mProgram, &desc.name.c_str()[1]);

      AssertFatal(loc != -1, "");

      HandleMap::Iterator handle = mHandles.find(desc.name);
      S32 sampler = -1;
      if(desc.constType == GFXSCT_Sampler || desc.constType == GFXSCT_SamplerCube)
      {
         S32 idx = mSamplerNamesOrdered.find_next(desc.name);
         AssertFatal(idx != -1, "");
         sampler = idx; //assignedSamplerNum++;
      }
      if ( handle != mHandles.end() )
      {
         handle->value->reinit( desc, loc, sampler );         
      } 
      else 
      {
         mHandles[desc.name] = new GFXGLShaderConstHandle( this, desc, loc, sampler );      
      }
   }

   // Loop through handles once more to set their offset and calculate our
   // constBuffer size.

   if ( mConstBuffer )
      delete[] mConstBuffer;
   mConstBufferSize = 0;

   for ( HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter )
   {
      GFXGLShaderConstHandle* handle = iter->value;
      if ( handle->isValid() )
      {
      	mValidHandles.push_back(handle);
         handle->mOffset = mConstBufferSize;
         mConstBufferSize += handle->getSize();
      }
   }
   
   mConstBuffer = new U8[mConstBufferSize];
   dMemset(mConstBuffer, 0, mConstBufferSize);
   
   // Set our program so uniforms are assigned properly.
   glUseProgram(mProgram);
   // Iterate through uniforms to set sampler numbers.
   for (HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter)
   {
      GFXGLShaderConstHandle* handle = iter->value;
      if(handle->isValid() && (handle->getType() == GFXSCT_Sampler || handle->getType() == GFXSCT_SamplerCube))
      {
         // Set sampler number on our program.
         glUniform1i(handle->mLocation, handle->mSamplerNum);
         // Set sampler in constant buffer so it does not get unset later.
         dMemcpy(mConstBuffer + handle->mOffset, &handle->mSamplerNum, handle->getSize());
      }
   }
   glUseProgram(0);

   //instancing
   U32 offset = 0;
   for ( U32 i=0; i < mInstancingFormat.getElementCount(); i++ )
   {
      const GFXVertexElement &element = mInstancingFormat.getElement( i );
      
      String constName = String::ToString( "$%s", element.getSemantic().c_str() );

      HandleMap::Iterator handle = mHandles.find(constName);      
      if ( handle != mHandles.end() )
      {          
         AssertFatal(0, "");
      } 
      else 
      {
         GFXShaderConstDesc desc;
         desc.name = constName;
         desc.arraySize = 1;
         switch(element.getType())
         {
         case GFXDeclType_Float4:
            desc.constType = GFXSCT_Float4;
            break;

         default:
            desc.constType = GFXSCT_Float;
            break;
         }
         
         GFXGLShaderConstHandle *h = new GFXGLShaderConstHandle( this, desc, -1, -1 );
         h->mInstancingConstant = true;
         h->mOffset = offset;
         mHandles[constName] =  h;

         offset += element.getSizeInBytes();
         ++i;

         // If this is a matrix we will have 2 or 3 more of these
         // semantics with the same name after it.
         for ( ; i < mInstancingFormat.getElementCount(); i++ )
         {
            const GFXVertexElement &nextElement = mInstancingFormat.getElement( i );
            if ( nextElement.getSemantic() != element.getSemantic() )
            {
               i--;
               break;
            }
            ++desc.arraySize;
            if(desc.arraySize == 4 && desc.constType == GFXSCT_Float4)
            {
               desc.arraySize = 1;
               desc.constType = GFXSCT_Float4x4;
            }
            offset += nextElement.getSizeInBytes();
         }
      }

   }
}
예제 #4
0
//-----------------------------------------------------------------------------
bool FileStream::_read(const U32 i_numBytes, void *o_pBuffer)
{
   AssertFatal(0 != mStreamCaps, "FileStream::_read: the stream isn't open");
   AssertFatal(NULL != o_pBuffer || i_numBytes == 0, "FileStream::_read: NULL destination pointer with non-zero read request");

   if (!hasCapability(Stream::StreamRead))
   {
      AssertFatal(false, "FileStream::_read: file stream lacks capability");
      Stream::setStatus(IllegalCall);
      return(false);
   }

   // exit on pre-existing errors
   if (Ok != getStatus())
      return(false);

   // if a request of non-zero length was made
   if (0 != i_numBytes)
   {
      U8 *pDst = (U8 *)o_pBuffer;
      U32 readSize;
      U32 remaining = i_numBytes;
      U32 bytesRead;
      U32 blockHead;
      U32 blockTail;

      // check if the buffer has some data in it
      if (BUFFER_INVALID != mBuffHead)
      {
         // copy as much as possible from the buffer into the destination
         readSize = ((mBuffTail + 1) >= mBuffPos) ? (mBuffTail + 1 - mBuffPos) : 0;
         readSize = getMin(readSize, remaining);
         calcBlockHead(mBuffPos, &blockHead);
         dMemcpy(pDst, mBuffer + (mBuffPos - blockHead), readSize);
         // reduce the remaining amount to read
         remaining -= readSize;
         // advance the buffer pointers
         mBuffPos += readSize;
         pDst += readSize;

         if (mBuffPos > mBuffTail && remaining != 0)
         {
            flush();
            mBuffHead = BUFFER_INVALID;
            if (mEOF == true)
               Stream::setStatus(EOS);
         }
      }

      // if the request wasn't satisfied by the buffer and the file has more data
      if (false == mEOF && 0 < remaining)
      {
         // flush the buffer if its dirty, since we now need to go to disk
         if (true == mDirty)
            flush();

         // make sure we know the current read location in the underlying file
         mBuffPos = mFile->getPosition();
         calcBlockBounds(mBuffPos, &blockHead, &blockTail);

         // check if the data to be read falls within a single block
         if ((mBuffPos + remaining) <= blockTail)
         {
            // fill the buffer from disk
            if (true == fillBuffer(mBuffPos))
            {
               // copy as much as possible from the buffer to the destination
               remaining = getMin(remaining, mBuffTail - mBuffPos + 1);
               dMemcpy(pDst, mBuffer + (mBuffPos - blockHead), remaining);
               // advance the buffer pointer
               mBuffPos += remaining;
            }
            else
               return(false);
         }
         // otherwise the remaining spans multiple blocks
         else
         {
            clearBuffer();
            // read from disk directly into the destination
            bytesRead = mFile->read((char *)pDst, remaining);
            setStatus();
            // check to make sure we read as much as expected
            if (Ok == getStatus() || EOS == getStatus())
            {
               // if not, update the end-of-file status
               if (0 != bytesRead && EOS == getStatus())
               {
                  Stream::setStatus(Ok);
                  mEOF = true;
               }
            }
            else
               return(false);
         }
      }
   }
   return(true);
}
예제 #5
0
//-----------------------------------------------------------------------------
void FileStream::calcBlockHead(const U32 i_position, U32 *o_blockHead)
{
   AssertFatal(NULL != o_blockHead, "FileStream::calcBlockHead: NULL pointer passed for block head");

   *o_blockHead = i_position/BUFFER_SIZE * BUFFER_SIZE;
}
예제 #6
0
void OptimizedPolyList::plane(const U32 index)
{
   AssertFatal(index < mPlaneList.size(), "Out of bounds index!");
   mPolyList.last().plane = index;
}
예제 #7
0
Polyhedron OptimizedPolyList::toPolyhedron() const
{
   Polyhedron polyhedron;

   // Add the points, but filter out duplicates.

   Vector< S32 > pointRemap;
   pointRemap.setSize( mPoints.size() );
   pointRemap.fill( -1 );

   const U32 numPoints = mPoints.size();

   for( U32 i = 0; i < numPoints; ++ i )
   {
      bool isDuplicate = false;
      for( U32 npoint = 0; npoint < polyhedron.pointList.size(); ++ npoint )
      {
         if( npoint == i )
            continue;

         if( !polyhedron.pointList[ npoint ].equal( mPoints[ i ] ) )
            continue;

         pointRemap[ i ] = npoint;
         isDuplicate = true;
      }

      if( !isDuplicate )
      {
         pointRemap[ i ] = polyhedron.pointList.size();
         polyhedron.pointList.push_back( mPoints[ i ] );
      }
   }

   // Go through the polys and add all their edges and planes.
   // We will consolidate edges in a second pass.

   const U32 numPolys = mPolyList.size();
   for( U32 i = 0; i < numPolys; ++ i )
   {
      const Poly& poly = mPolyList[ i ];

      // Add the plane.

      const U32 polyIndex = polyhedron.planeList.size();
      polyhedron.planeList.push_back( mPlaneList[ poly.plane ] );

      // Account for polyhedrons expecting planes to
      // face inwards.

      polyhedron.planeList.last().invert();

      // Gather remapped indices according to the
      // current polygon type.

      Vector< U32 > indexList;
      switch( poly.type )
      {
         case TriangleFan:
            AssertFatal( false, "TriangleFan conversion not implemented" );
         case TriangleStrip:
            AssertFatal( false, "TriangleStrip conversion not implemented" );
         case TriangleList:
            {
               Vector< Polyhedron::Edge > tempEdges;

               // Loop over the triangles and gather all unshared edges
               // in tempEdges.  These are the exterior edges of the polygon.

               for( U32 n = poly.vertexStart; n < poly.vertexStart + poly.vertexCount; n += 3 )
               {
                  U32 indices[ 3 ];

                  // Get the remapped indices of the three vertices.

                  indices[ 0 ] = pointRemap[ mVertexList[ mIndexList[ n + 0 ] ].vertIdx ];
                  indices[ 1 ] = pointRemap[ mVertexList[ mIndexList[ n + 1 ] ].vertIdx ];
                  indices[ 2 ] = pointRemap[ mVertexList[ mIndexList[ n + 2 ] ].vertIdx ];

                  // Loop over the three edges.

                  for( U32 d = 0; d < 3; ++ d )
                  {
                     U32 index1 = indices[ d ];
                     U32 index2 = indices[ ( d + 1 ) % 3 ];

                     // See if this edge is already in the list.  If so,
                     // it's a shared edge and thus an interior one.  Remove
                     // it.

                     bool isShared = false;
                     for( U32 nedge = 0; nedge < tempEdges.size(); ++ nedge )
                     {
                        Polyhedron::Edge& edge = tempEdges[ nedge ];
                        if( ( edge.vertex[ 0 ] == index1 && edge.vertex[ 1 ] == index2 ) ||
                            ( edge.vertex[ 0 ] == index2 && edge.vertex[ 1 ] == index1 ) )
                        {
                           tempEdges.erase( nedge );

                           isShared = true;
                           break;
                        }
                     }

                     // If it wasn't in the list, add a new edge.

                     if( !isShared )
                        tempEdges.push_back(
                           Polyhedron::Edge( -1, -1, index1, index2 )
                        );
                  }
               }

               // Walk the edges and gather consecutive indices.

               U32 currentEdge = 0;
               for( U32 n = 0; n < tempEdges.size(); ++ n )
               {
                  // Add first vertex of edge.

                  indexList.push_back( tempEdges[ currentEdge ].vertex[ 0 ] );

                  // Find edge that begins at second vertex.

                  for( U32 nedge = 0; nedge < tempEdges.size(); ++ nedge )
                  {
                     if( nedge == currentEdge )
                        continue;

                     if( tempEdges[ nedge ].vertex[ 0 ] == tempEdges[ currentEdge ].vertex[ 1 ] )
                     {
                        currentEdge = nedge;
                        break;
                     }
                  }
               }
            }
      }

      // Create edges from the indices.  Indices are CCW ordered and
      // we want CW order, so step everything in reverse.

      U32 lastIndex = 0;
      for( S32 n = indexList.size() - 1; n >= 0; -- n )
      {
         polyhedron.edgeList.push_back(
            Polyhedron::Edge(
               polyIndex, 0, // face1 filled later
               indexList[ lastIndex ], indexList[ n ]
            )
         );

         lastIndex = n;
      }
   }

   // Finally, consolidate the edge list by merging all edges that
   // are shared by polygons.

   for( U32 i = 0; i < polyhedron.edgeList.size(); ++ i )
   {
      Polyhedron::Edge& edge = polyhedron.edgeList[ i ];

      // Find the corresponding duplicate edge, if any, and merge
      // it into our current edge.

      for( U32 n = i + 1; n < polyhedron.edgeList.size(); ++ n )
      {
         const Polyhedron::Edge& thisEdge = polyhedron.edgeList[ n ];

         if( ( thisEdge.vertex[ 0 ] == edge.vertex[ 1 ] &&
               thisEdge.vertex[ 1 ] == edge.vertex[ 0 ] ) ||
             ( thisEdge.vertex[ 0 ] == edge.vertex[ 0 ] &&
               thisEdge.vertex[ 1 ] == edge.vertex[ 1 ] ) )
         {
            edge.face[ 1 ] = thisEdge.face[ 0 ];
            polyhedron.edgeList.erase( n );
            break;
         }
      }
   }

   return polyhedron;
}
예제 #8
0
void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb )
{
   PROFILE_SCOPE( TSMesh_InnerRender );

   if( vertsPerFrame <= 0 ) 
      return;

   F32 meshVisibility = rdata.getFadeOverride() * mVisibility;
   if ( meshVisibility < VISIBILITY_EPSILON )
      return;

   const SceneRenderState *state = rdata.getSceneState();
   RenderPassManager *renderPass = state->getRenderPass();

   MeshRenderInst *coreRI = renderPass->allocInst<MeshRenderInst>();
   coreRI->type = RenderPassManager::RIT_Mesh;

   const MatrixF &objToWorld = GFX->getWorldMatrix();

   // Sort by the center point or the bounds.
   if ( rdata.useOriginSort() )
      coreRI->sortDistSq = ( objToWorld.getPosition() - state->getCameraPosition() ).lenSquared();
   else
   {
      Box3F rBox = mBounds;
      objToWorld.mul( rBox );
      coreRI->sortDistSq = rBox.getSqDistanceToPoint( state->getCameraPosition() );      
   }

   if (getFlags(Billboard))
   {
      Point3F camPos = state->getDiffuseCameraPosition();
      Point3F objPos;
      objToWorld.getColumn(3, &objPos);
      Point3F targetVector = camPos - objPos;
      if(getFlags(BillboardZAxis))
         targetVector.z = 0.0f;
      targetVector.normalize();
      MatrixF orient = MathUtils::createOrientFromDir(targetVector);
      orient.setPosition(objPos);
      orient.scale(objToWorld.getScale());

      coreRI->objectToWorld = renderPass->allocUniqueXform( orient );
   }
   else
      coreRI->objectToWorld = renderPass->allocUniqueXform( objToWorld );

   coreRI->worldToCamera = renderPass->allocSharedXform(RenderPassManager::View);
   coreRI->projection = renderPass->allocSharedXform(RenderPassManager::Projection);

   AssertFatal( vb.isValid(), "TSMesh::innerRender() - Got invalid vertex buffer!" );
   AssertFatal( pb.isValid(), "TSMesh::innerRender() - Got invalid primitive buffer!" );

   coreRI->vertBuff = &vb;
   coreRI->primBuff = &pb;
   coreRI->defaultKey2 = (U32) coreRI->vertBuff;

   coreRI->materialHint = rdata.getMaterialHint();

   coreRI->visibility = meshVisibility;  
   coreRI->cubemap = rdata.getCubemap();

   // NOTICE: SFXBB is removed and refraction is disabled!
   //coreRI->backBuffTex = GFX->getSfxBackBuffer();

   for ( S32 i = 0; i < primitives.size(); i++ )
   {
      const TSDrawPrimitive &draw = primitives[i];

      // We need to have a material.
      if ( draw.matIndex & TSDrawPrimitive::NoMaterial )
         continue;

#ifdef TORQUE_DEBUG
      // for inspection if you happen to be running in a debugger and can't do bit 
      // operations in your head.
      S32 triangles = draw.matIndex & TSDrawPrimitive::Triangles;
      S32 strip = draw.matIndex & TSDrawPrimitive::Strip;
      S32 fan = draw.matIndex & TSDrawPrimitive::Fan;
      S32 indexed = draw.matIndex & TSDrawPrimitive::Indexed;
      S32 type = draw.matIndex & TSDrawPrimitive::TypeMask;
      TORQUE_UNUSED(triangles);
      TORQUE_UNUSED(strip);
      TORQUE_UNUSED(fan);
      TORQUE_UNUSED(indexed);
      TORQUE_UNUSED(type);
#endif

      const U32 matIndex = draw.matIndex & TSDrawPrimitive::MaterialMask;
      BaseMatInstance *matInst = materials->getMaterialInst( matIndex );

#ifndef TORQUE_OS_MAC

      // Get the instancing material if this mesh qualifies.
      if ( meshType != SkinMeshType && pb->mPrimitiveArray[i].numVertices < smMaxInstancingVerts )
         matInst = InstancingMaterialHook::getInstancingMat( matInst );

#endif

      // If we don't have a material instance after the overload then
      // there is nothing to render... skip this primitive.
      matInst = state->getOverrideMaterial( matInst );
      if ( !matInst || !matInst->isValid())
         continue;

      // If the material needs lights then gather them
      // here once and set them on the core render inst.
      if ( matInst->isForwardLit() && !coreRI->lights[0] && rdata.getLightQuery() )
         rdata.getLightQuery()->getLights( coreRI->lights, 8 );

      MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>();
      *ri = *coreRI;

      ri->matInst = matInst;
      ri->defaultKey = matInst->getStateHint();
      ri->primBuffIndex = i;

      // Translucent materials need the translucent type.
      if ( matInst->getMaterial()->isTranslucent() )
      {
         ri->type = RenderPassManager::RIT_Translucent;
         ri->translucentSort = true;
      }

      renderPass->addInst( ri );
   }
}
예제 #9
0
bool TSMesh::buildPolyList( S32 frame, AbstractPolyList *polyList, U32 &surfaceKey, TSMaterialList *materials )
{
   S32 firstVert  = vertsPerFrame * frame, i, base = 0;

   // add the verts...
   if ( vertsPerFrame )
   {
      if ( mVertexData.isReady() )
      {
         OptimizedPolyList* opList = dynamic_cast<OptimizedPolyList*>(polyList);
         if ( opList )
         {
            base = opList->mVertexList.size();
            for ( i = 0; i < vertsPerFrame; i++ )
            {
               // Don't use vertex() method as we want to retain the original indices
               OptimizedPolyList::VertIndex vert;
               vert.vertIdx   = opList->insertPoint( mVertexData[ i + firstVert ].vert() );
               vert.normalIdx = opList->insertNormal( mVertexData[ i + firstVert ].normal() );
               vert.uv0Idx    = opList->insertUV0( mVertexData[ i + firstVert ].tvert() );
               if ( mHasTVert2 )
                  vert.uv1Idx = opList->insertUV1( mVertexData[ i + firstVert ].tvert2() );

               opList->mVertexList.push_back( vert );
            }
         }
         else
         {
            base = polyList->addPointAndNormal( mVertexData[firstVert].vert(), mVertexData[firstVert].normal() );
            for ( i = 1; i < vertsPerFrame; i++ )
            {
               polyList->addPointAndNormal( mVertexData[ i + firstVert ].vert(), mVertexData[ i + firstVert ].normal() );
            }
         }
      }
      else
      {
         OptimizedPolyList* opList = dynamic_cast<OptimizedPolyList*>(polyList);
         if ( opList )
         {
            base = opList->mVertexList.size();
            for ( i = 0; i < vertsPerFrame; i++ )
            {
               // Don't use vertex() method as we want to retain the original indices
               OptimizedPolyList::VertIndex vert;
               vert.vertIdx   = opList->insertPoint( verts[ i + firstVert ] );
               vert.normalIdx = opList->insertNormal( norms[ i + firstVert ] );
               vert.uv0Idx    = opList->insertUV0( tverts[ i + firstVert ] );
               if ( mHasTVert2 )
                  vert.uv1Idx = opList->insertUV1( tverts2[ i + firstVert ] );

               opList->mVertexList.push_back( vert );
            }
         }
         else
         {
            base = polyList->addPointAndNormal( verts[firstVert], norms[firstVert] );
            for ( i = 1; i < vertsPerFrame; i++ )
               polyList->addPointAndNormal( verts[ i + firstVert ], norms[ i + firstVert ] );
         }
      }
   }

   // add the polys...
   for ( i = 0; i < primitives.size(); i++ )
   {
      TSDrawPrimitive & draw = primitives[i];
      U32 start = draw.start;

      AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );

      U32 matIndex = draw.matIndex & TSDrawPrimitive::MaterialMask;
      BaseMatInstance* material = ( materials ? materials->getMaterialInst( matIndex ) : 0 );

      // gonna depend on what kind of primitive it is...
      if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
      {
         for ( S32 j = 0; j < draw.numElements; )
         {
            U32 idx0 = base + indices[start + j + 0];
            U32 idx1 = base + indices[start + j + 1];
            U32 idx2 = base + indices[start + j + 2];
            polyList->begin(material,surfaceKey++);
            polyList->vertex( idx0 );
            polyList->vertex( idx1 );
            polyList->vertex( idx2 );
            polyList->plane( idx0, idx1, idx2 );
            polyList->end();
            j += 3;
         }
      }
      else
      {
         AssertFatal( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip,"TSMesh::buildPolyList (2)" );

         U32 idx0 = base + indices[start + 0];
         U32 idx1;
         U32 idx2 = base + indices[start + 1];
         U32 * nextIdx = &idx1;
         for ( S32 j = 2; j < draw.numElements; j++ )
         {
            *nextIdx = idx2;
            // nextIdx = (j%2)==0 ? &idx0 : &idx1;
            nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
            idx2 = base + indices[start + j];
            if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
               continue;

            polyList->begin( material, surfaceKey++ );
            polyList->vertex( idx0 );
            polyList->vertex( idx1 );
            polyList->vertex( idx2 );
            polyList->plane( idx0, idx1, idx2 );
            polyList->end();
         }
      }
   }
   return true;
}
예제 #10
0
static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
{
   // Don't export anonymous types.
   if( !type->getTypeName()[ 0 ] )
      return;
      
   if( isExportFiltered( type ) )
      return;
      
   const char* nodeName = NULL;
   switch( type->getTypeKind() )
   {
      case EngineTypeKindPrimitive:
         nodeName = "EnginePrimitiveType";
         break;
         
      case EngineTypeKindEnum:
         nodeName = "EngineEnumType";
         break;
         
      case EngineTypeKindBitfield:
         nodeName = "EngineBitfieldType";
         break;
         
      case EngineTypeKindStruct:
         nodeName = "EngineStructType";
         break;
         
      case EngineTypeKindClass:
         nodeName = "EngineClassType";
         break;
      
      default:
         return;
   }
   
   xml->pushNewElement( nodeName );

      xml->setAttribute( "name", type->getTypeName() );
      xml->setAttribute( "size", String::ToString( type->getInstanceSize() ) );
      xml->setAttribute( "isAbstract", type->isAbstract() ? "1" : "0" );
      xml->setAttribute( "isInstantiable", type->isInstantiable() ? "1" : "0" );
      xml->setAttribute( "isDisposable", type->isDisposable() ? "1" : "0" );
      xml->setAttribute( "isSingleton", type->isSingleton() ? "1" : "0" );
      xml->setAttribute( "docs", getDocString( type ) );
      
      if( type->getSuperType() )
         xml->setAttribute( "superType", getTypeName( type->getSuperType() ) );
      
      if( type->getEnumTable() )
      {
         xml->pushNewElement( "enums" );
         
            const EngineEnumTable& table = *( type->getEnumTable() );
            const U32 numValues = table.getNumValues();
            
            for( U32 i = 0; i < numValues; ++ i )
            {
               xml->pushNewElement( "EngineEnum" );
               
                  xml->setAttribute( "name", table[ i ].getName() );
                  xml->setAttribute( "value", String::ToString( table[ i ].getInt() ) );
                  xml->setAttribute( "docs", table[ i ].getDocString() ? table[ i ].getDocString() : "" );
                  
               xml->popElement();
            }
            
         xml->popElement();
      }
      else if( type->getFieldTable() )
      {
         xml->pushNewElement( "fields" );
         
            const EngineFieldTable& table = *( type->getFieldTable() );
            const U32 numFields = table.getNumFields();
            
            for( U32 i = 0; i < numFields; ++ i )
            {
               const EngineFieldTable::Field& field = table[ i ];
               
               xml->pushNewElement( "EngineField" );
               
                  xml->setAttribute( "name", field.getName() );
                  xml->setAttribute( "type", getTypeName( field.getType() ) );
                  xml->setAttribute( "offset", String::ToString( field.getOffset() ) );
                  xml->setAttribute( "indexedSize", String::ToString( field.getNumElements() ) );
                  xml->setAttribute( "docs", field.getDocString() ? field.getDocString() : "" );
               
               xml->popElement();
            }
         
         xml->popElement();
      }
      else if( type->getPropertyTable() )
      {
         xml->pushNewElement( "properties" );
         
            const EnginePropertyTable& table = *( type->getPropertyTable() );
            const U32 numProperties = table.getNumProperties();
            U32 groupNestingDepth = 0;
            
            for( U32 i = 0; i < numProperties; ++ i )
            {
               const EnginePropertyTable::Property& property = table[ i ];
               
               if( property.isGroupBegin() )
               {
                  groupNestingDepth ++;
                  xml->pushNewElement( "EnginePropertyGroup" );
                  
                     xml->setAttribute( "name", property.getName() );
                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
                     
                     xml->pushNewElement( "properties" );
               }
               else if( property.isGroupEnd() )
               {
                  groupNestingDepth --;
                  xml->popElement();
                  xml->popElement();
               }
               else
               {
                  xml->pushNewElement( "EngineProperty" );
                  
                     xml->setAttribute( "name", property.getName() );
                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
                     xml->setAttribute( "isConstant", property.isConstant() ? "1" : "0" );
                     xml->setAttribute( "isTransient", property.isTransient() ? "1" : "0" );
                     xml->setAttribute( "isVisible", property.hideInInspectors() ? "0" : "1" );
                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
                  
                  xml->popElement();
               }
            }
         
         AssertFatal( !groupNestingDepth, "exportType - Property group nesting mismatch!" );
         xml->popElement();
      }      
      exportScope( type, xml );
      
   xml->popElement();
}
예제 #11
0
//--------------------------------------
void _StringTable::destroy()
{
   AssertFatal(StringTable != NULL, "StringTable::destroy: StringTable does not exist.");
   delete _gStringTable;
   _gStringTable = NULL;
}
예제 #12
0
static void exportFunction( const EngineFunctionInfo* function, SimXMLDocument* xml )
{
   if( isExportFiltered( function ) )
      return;
      
   xml->pushNewElement( "EngineFunction" );
      
      xml->setAttribute( "name", function->getExportName() );
      xml->setAttribute( "returnType", getTypeName( function->getReturnType() ) );
      xml->setAttribute( "symbol", function->getBindingName() );
      xml->setAttribute( "isCallback", function->isCallout() ? "1" : "0" );
      xml->setAttribute( "isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0" );
      xml->setAttribute( "docs", getDocString( function ) );
      
      xml->pushNewElement( "arguments" );
      
         const U32 numArguments = function->getNumArguments();
         const U32 numDefaultArguments = ( function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0 );
         const U32 firstDefaultArg = numArguments - numDefaultArguments;
         
         Vector< String > argumentNames = parseFunctionArgumentNames( function );
         const U32 numArgumentNames = argumentNames.size();
         
         // Accumulated offset in function argument frame vector.
         U32 argFrameOffset = 0;
         
         for( U32 i = 0; i < numArguments; ++ i )
         {
            xml->pushNewElement( "EngineFunctionArgument" );
            const EngineTypeInfo* type = function->getArgumentType( i );
            AssertFatal( type != NULL, "exportFunction - Argument cannot have type void!" );
            
            String argName;
            if( i < numArgumentNames )
               argName = argumentNames[ i ];
               
            xml->setAttribute( "name", argName );
            xml->setAttribute( "type", getTypeName( type ) );
            
            if( i >= firstDefaultArg )
            {
               String defaultValue = getDefaultArgumentValue( function, type, argFrameOffset );
               xml->setAttribute( "defaultValue", defaultValue );
            }

            xml->popElement();
            
            if( type->getTypeKind() == EngineTypeKindStruct )
               argFrameOffset += type->getInstanceSize();
            else
               argFrameOffset += type->getValueSize();
               
            #ifdef _PACK_BUG_WORKAROUNDS
            if( argFrameOffset % 4 > 0 )
               argFrameOffset += 4 - ( argFrameOffset % 4 );
            #endif
         }
         
      xml->popElement();
         
   xml->popElement();
}
예제 #13
0
static String getDefaultArgumentValue( const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 offset )
{
   String value;
   const EngineFunctionDefaultArguments* defaultArgs = function->getDefaultArguments();
   
   switch( type->getTypeKind() )
   {
      case EngineTypeKindPrimitive:
      {
         #define PRIMTYPE( tp )                                               \
            if( TYPE< tp >() == type )                                        \
            {                                                                 \
               tp val = getArgValue< tp >( defaultArgs, offset );             \
               value = String::ToString( val );                               \
            }
            
         PRIMTYPE( bool );
         PRIMTYPE( S8 );
         PRIMTYPE( U8 );
         PRIMTYPE( S32 );
         PRIMTYPE( U32 );
         PRIMTYPE( F32 );
         PRIMTYPE( F64 );
         
         //TODO: for now we store string literals in ASCII; needs to be sorted out
         if( TYPE< const char* >() == type )
         {
            const char* val = getArgValue< const char* >( defaultArgs, offset );
            value = val;
         }
            
         #undef PRIMTYPE
         break;
      }
         
      case EngineTypeKindEnum:
      {
         S32 val = getArgValue< S32 >( defaultArgs, offset );
         AssertFatal( type->getEnumTable(), "engineXMLExport - Enum type without table!" );
         
         const EngineEnumTable& table = *( type->getEnumTable() );
         const U32 numValues = table.getNumValues();
         
         for( U32 i = 0; i < numValues; ++ i )
            if( table[ i ].getInt() == val )
            {
               value = table[ i ].getName();
               break;
            }
               
         break;
      }

      case EngineTypeKindBitfield:
      {
         S32 val = getArgValue< S32 >( defaultArgs, offset );
         AssertFatal( type->getEnumTable(), "engineXMLExport - Bitfield type without table!" );
         
         const EngineEnumTable& table = *( type->getEnumTable() );
         const U32 numValues = table.getNumValues();
         
         bool isFirst = true;
         for( U32 i = 0; i < numValues; ++ i )
            if( table[ i ].getInt() & val )
            {
               if( !isFirst )
                  value += '|';
                  
               value = table[ i ].getName();
               isFirst = false;
            }

         break;
      }
      
      case EngineTypeKindStruct:
      {
         //TODO: struct type default argument values
         break;
      }
         
      case EngineTypeKindClass:
      case EngineTypeKindFunction:
      {
         // For these two kinds, we support "null" as the only valid
         // default value.
         
         const void* ptr = getArgValue< const void* >( defaultArgs, offset );
         if( !ptr )
            value = "null";
         break;
      }
      
      default:
         break;
   }
   
   return value;
}
예제 #14
0
TSThread * TSShapeInstance::getThread(S32 threadNumber)
{
   AssertFatal(threadNumber < mThreadList.size() && threadNumber>=0,"TSShapeInstance::getThread: threadNumber out of bounds.");
   return mThreadList[threadNumber];
}
예제 #15
0
//-----------------------------------------------------------------------------
rlc_op_status_t rrc_rlc_config_asn1_req (const module_id_t           enb_mod_idP,
                                         const module_id_t           ue_mod_idP,
                                         const frame_t               frameP,
                                         const eNB_flag_t            enb_flagP,
                                         const SRB_ToAddModList_t   * const srb2add_listP,
                                         const DRB_ToAddModList_t   * const drb2add_listP,
                                         const DRB_ToReleaseList_t  * const drb2release_listP
#if defined(Rel10)
                                        ,const PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP
#endif
  ) {
  //-----------------------------------------------------------------------------
  rb_id_t                rb_id           = 0;
  logical_chan_id_t      lc_id           = 0;
  DRB_Identity_t         drb_id          = 0;
  DRB_Identity_t*        pdrb_id         = NULL;
  long int               cnt             = 0;
  const SRB_ToAddMod_t  *srb_toaddmod_p  = NULL;
  const DRB_ToAddMod_t  *drb_toaddmod_p  = NULL;
  rlc_union_t           *rlc_union_p     = NULL;
  hash_key_t             key             = HASHTABLE_QUESTIONABLE_KEY_VALUE;
  hashtable_rc_t         h_rc;
#if defined(Rel10)
  int                        i, j;
  MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL;
  MBMS_SessionInfo_r9_t     *MBMS_SessionInfo_p        = NULL;
  mbms_session_id_t          mbms_session_id;
  mbms_service_id_t          mbms_service_id;
  DL_UM_RLC_t                dl_um_rlc;


#endif

  LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 \n",
          frameP,
          (enb_flagP) ? "eNB" : "UE",
          enb_mod_idP,
          ue_mod_idP);

#ifdef OAI_EMU
    if (enb_flagP) {
        AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too low (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local);
        AssertFatal ((enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too high (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
        AssertFatal (ue_mod_idP  < NB_UE_INST,
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
    } else {
        AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
        AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
            "UE module id is too low (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local);
    }
#endif
  if (srb2add_listP != NULL) {
      for (cnt=0;cnt<srb2add_listP->list.count;cnt++) {
         rb_id = srb2add_listP->list.array[cnt]->srb_Identity;
         lc_id  = rb_id + 2;

         LOG_D(RLC, "Adding SRB %d, rb_id %d\n",srb2add_listP->list.array[cnt]->srb_Identity,rb_id);
          srb_toaddmod_p = srb2add_listP->list.array[cnt];

          if (srb_toaddmod_p->rlc_Config) {
              switch (srb_toaddmod_p->rlc_Config->present) {
                  case SRB_ToAddMod__rlc_Config_PR_NOTHING:
                      break;
                  case SRB_ToAddMod__rlc_Config_PR_explicitValue:
                      switch (srb_toaddmod_p->rlc_Config->choice.explicitValue.present) {
                          case RLC_Config_PR_NOTHING:
                              break;
                          case RLC_Config_PR_am:
                              if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_AM) != NULL) {
                                  config_req_rlc_am_asn1 (
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      frameP,
                                      enb_flagP,
                                      SRB_FLAG_YES,
                                      &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.am,
                                      rb_id);
                              } else {
                                  LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n",
                                      frameP,
                                      (enb_flagP) ? "eNB" : "UE",
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      rb_id);
                              }
                              break;
                          case RLC_Config_PR_um_Bi_Directional:
                              if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) {
                                  config_req_rlc_um_asn1(
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      frameP,
                                      enb_flagP,
                                      SRB_FLAG_YES,
                                      MBMS_FLAG_NO,
                                      UNUSED_PARAM_MBMS_SESSION_ID,
                                      UNUSED_PARAM_MBMS_SERVICE_ID,
                                      &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.ul_UM_RLC,
                                      &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC,
                                      rb_id);
                              } else {
                                  LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n",
                                      frameP,
                                      (enb_flagP) ? "eNB" : "UE",
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      rb_id);
                              }
                              break;
                          case RLC_Config_PR_um_Uni_Directional_UL:
                              if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) {
                                  config_req_rlc_um_asn1(
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      frameP,
                                      enb_flagP,
                                      SRB_FLAG_YES,
                                      MBMS_FLAG_NO,
                                      UNUSED_PARAM_MBMS_SESSION_ID,
                                      UNUSED_PARAM_MBMS_SERVICE_ID,
                                      &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_UL.ul_UM_RLC,
                                      NULL,
                                      rb_id);
                              } else {
                                  LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n",
                                      frameP,
                                      (enb_flagP) ? "eNB" : "UE",
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      rb_id);
                              }
                              break;
                          case RLC_Config_PR_um_Uni_Directional_DL:
                              if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) {
                                  config_req_rlc_um_asn1(
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      frameP,
                                      enb_flagP,
                                      SRB_FLAG_YES,
                                      MBMS_FLAG_NO,
                                      UNUSED_PARAM_MBMS_SESSION_ID,
                                      UNUSED_PARAM_MBMS_SERVICE_ID,
                                      NULL,
                                      &srb_toaddmod_p->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC,
                                      rb_id);
                              } else {
                                  LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n",
                                      frameP,
                                      (enb_flagP) ? "eNB" : "UE",
                                       enb_mod_idP,
                                       ue_mod_idP,
                                       rb_id);
                              }
                              break;

                          default:
                              LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] UNKNOWN RLC CONFIG %d \n",
                                      frameP,
                                      (enb_flagP) ? "eNB" : "UE",
                                      enb_mod_idP,
                                      ue_mod_idP,
                                      srb_toaddmod_p->rlc_Config->choice.explicitValue.present);
                              break;
                      }
                      break;
                  case SRB_ToAddMod__rlc_Config_PR_defaultValue:
#warning TO DO SRB_ToAddMod__rlc_Config_PR_defaultValue
                    if (rrc_rlc_add_rlc   (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_YES, MBMS_FLAG_NO, rb_id, lc_id, RLC_MODE_UM) != NULL) {
                        config_req_rlc_um_asn1(
                            enb_mod_idP,
                            ue_mod_idP,
                            frameP,
                            enb_flagP,
                            SRB_FLAG_YES,
                            MBMS_FLAG_NO,
                            UNUSED_PARAM_MBMS_SESSION_ID,
                            UNUSED_PARAM_MBMS_SERVICE_ID,
                            NULL, // TO DO DEFAULT CONFIG
                            NULL, // TO DO DEFAULT CONFIG
                            rb_id);
                      } else {
                          LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n",
                                  frameP,
                                  (enb_flagP) ? "eNB" : "UE",
                                  enb_mod_idP,
                                  ue_mod_idP,
                                  rb_id);
                      }
                      break;
                  default:;
              }
          }
      }
  }
  if (drb2add_listP != NULL) {
      for (cnt=0;cnt<drb2add_listP->list.count;cnt++) {
          drb_toaddmod_p = drb2add_listP->list.array[cnt];

          drb_id = drb_toaddmod_p->drb_Identity;
          lc_id  = drb_id + 2;

          LOG_D(RLC, "Adding DRB %d, lc_id %d\n",drb_id,lc_id);


          if (drb_toaddmod_p->rlc_Config) {

              switch (drb_toaddmod_p->rlc_Config->present) {
                  case RLC_Config_PR_NOTHING:
                      break;
                  case RLC_Config_PR_am:
                      if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_AM) != NULL) {
                          config_req_rlc_am_asn1 (
                              enb_mod_idP,
                              ue_mod_idP,
                              frameP,
                              enb_flagP,
                              SRB_FLAG_NO,
                              &drb_toaddmod_p->rlc_Config->choice.am,
                              drb_id);
                      }
                      break;
                  case RLC_Config_PR_um_Bi_Directional:
                      if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) {
                          config_req_rlc_um_asn1(
                              enb_mod_idP,
                              ue_mod_idP,
                              frameP,
                              enb_flagP,
                              SRB_FLAG_NO,
                              MBMS_FLAG_NO,
                              UNUSED_PARAM_MBMS_SESSION_ID,
                              UNUSED_PARAM_MBMS_SERVICE_ID,
                              &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.ul_UM_RLC,
                              &drb_toaddmod_p->rlc_Config->choice.um_Bi_Directional.dl_UM_RLC,
                              drb_id);
                      }
                      break;
                  case RLC_Config_PR_um_Uni_Directional_UL:
                      if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) {
                          config_req_rlc_um_asn1(
                              enb_mod_idP,
                              ue_mod_idP,
                              frameP,
                              enb_flagP,
                              SRB_FLAG_NO,
                              MBMS_FLAG_NO,
                              UNUSED_PARAM_MBMS_SESSION_ID,
                              UNUSED_PARAM_MBMS_SERVICE_ID,
                              &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_UL.ul_UM_RLC,
                              NULL,
                              drb_id);
                      }
                      break;
                  case RLC_Config_PR_um_Uni_Directional_DL:
                      if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_NO, MBMS_FLAG_NO, drb_id, lc_id, RLC_MODE_UM) != NULL) {
                          config_req_rlc_um_asn1(
                              enb_mod_idP,
                              ue_mod_idP,
                              frameP,
                              enb_flagP,
                              SRB_FLAG_NO,
                              MBMS_FLAG_NO,
                              UNUSED_PARAM_MBMS_SESSION_ID,
                              UNUSED_PARAM_MBMS_SERVICE_ID,
                              NULL,
                              &drb_toaddmod_p->rlc_Config->choice.um_Uni_Directional_DL.dl_UM_RLC,
                              drb_id);
                      }
                      break;
                  default:
                      LOG_W(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u][RB %u] unknown drb_toaddmod_p->rlc_Config->present \n",
                              frameP,
                              (enb_flagP) ? "eNB" : "UE",
                              enb_mod_idP,
                              ue_mod_idP,
                              drb_id);
              }
          }
      }
  }
  if (drb2release_listP != NULL) {
      for (cnt=0;cnt<drb2release_listP->list.count;cnt++) {
          pdrb_id = drb2release_listP->list.array[cnt];
          rrc_rlc_remove_rlc(enb_mod_idP, ue_mod_idP, frameP, enb_flagP, SRB_FLAG_NO, MBMS_FLAG_NO, *pdrb_id);
      }
  }

#if defined(Rel10)

  if (pmch_InfoList_r9_pP != NULL) {
      for (i=0;i<pmch_InfoList_r9_pP->list.count;i++) {
          mbms_SessionInfoList_r9_p = &(pmch_InfoList_r9_pP->list.array[i]->mbms_SessionInfoList_r9);
          for (j=0;j<mbms_SessionInfoList_r9_p->list.count;j++) {
              MBMS_SessionInfo_p = mbms_SessionInfoList_r9_p->list.array[j];
              mbms_session_id    = MBMS_SessionInfo_p->sessionId_r9->buf[0];
              lc_id              = mbms_session_id;
              mbms_service_id    = MBMS_SessionInfo_p->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string

              // can set the mch_id = i
              if (enb_flagP) {
                rb_id =  (mbms_service_id * maxSessionPerPMCH ) + mbms_session_id;//+ (maxDRB + 3) * MAX_MOBILES_PER_ENB; // 1
                rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lc_id].service_id                     = mbms_service_id;
                rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lc_id].session_id                     = mbms_session_id;

                rlc_mbms_enb_set_lcid_by_rb_id(enb_mod_idP,rb_id,lc_id);
              } else {
                rb_id =  (mbms_service_id * maxSessionPerPMCH ) + mbms_session_id; // + (maxDRB + 3); // 15
                rlc_mbms_lcid2service_session_id_ue[ue_mod_idP][lc_id].service_id                    = mbms_service_id;
                rlc_mbms_lcid2service_session_id_ue[ue_mod_idP][lc_id].session_id                    = mbms_session_id;
                rlc_mbms_ue_set_lcid_by_rb_id(ue_mod_idP,rb_id,lc_id);
              }
              key = RLC_COLL_KEY_MBMS_VALUE(enb_mod_idP, ue_mod_idP, enb_flagP, mbms_service_id, mbms_session_id);

              h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
              if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) {
                  rlc_union_p = rrc_rlc_add_rlc   (
                      enb_mod_idP,
                      ue_mod_idP,
                      frameP,
                      enb_flagP,
                      SRB_FLAG_NO,
                      MBMS_FLAG_YES,
                      rb_id,
                      lc_id,
                      RLC_MODE_UM);
                  AssertFatal(rlc_union_p != NULL, "ADD MBMS RLC UM FAILED");
              }

              LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ MBMS ASN1 LC ID %u RB ID %u SESSION ID %u SERVICE ID %u\n",
                    frameP,
                    (enb_flagP) ? "eNB" : "UE",
                    enb_mod_idP,
                    ue_mod_idP,
                    lc_id,
                    rb_id,
                    mbms_session_id,
                    mbms_service_id
                   );
              dl_um_rlc.sn_FieldLength = SN_FieldLength_size5;
              dl_um_rlc.t_Reordering   = T_Reordering_ms0;

              config_req_rlc_um_asn1 (
                  enb_mod_idP,
                  ue_mod_idP,
                  frameP,
                  enb_flagP,
                  SRB_FLAG_NO,
                  MBMS_FLAG_YES,
                  mbms_session_id,
                  mbms_service_id,
                  NULL,
                  &dl_um_rlc,
                  rb_id);
          }
      }
  }
#endif

  LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 END \n",
         frameP,
         (enb_flagP) ? "eNB" : "UE",
         enb_flagP,
         enb_mod_idP,
         ue_mod_idP);
  return RLC_OP_STATUS_OK;
}
예제 #16
0
//**************************************************************************
// Multi line statement
//**************************************************************************
void MultiLine::addStatement( LangElement *elem )
{
   AssertFatal( elem, "Attempting to add empty statement" );

   mStatementList.push_back( elem );
}
예제 #17
0
//-----------------------------------------------------------------------------
rlc_op_status_t rrc_rlc_config_req   (
    const module_id_t     enb_mod_idP,
    const module_id_t     ue_mod_idP,
    const frame_t         frameP,
    const eNB_flag_t      enb_flagP,
    const srb_flag_t      srb_flagP,
    const MBMS_flag_t     mbms_flagP,
    const config_action_t actionP,
    const rb_id_t         rb_idP,
    const rlc_info_t      rlc_infoP) {
//-----------------------------------------------------------------------------
    rlc_op_status_t status;

    LOG_D(RLC, "[FRAME %05u][%s][RLC][MOD %u/%u] CONFIG_REQ for Rab %u\n",
            frameP,
            (enb_flagP) ? "eNB" : "UE",
            enb_mod_idP,
            ue_mod_idP,
            rb_idP);

#ifdef OAI_EMU
    if (enb_flagP) {
        AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too low (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local);
        AssertFatal ((enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too high (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
        AssertFatal (ue_mod_idP  < NB_UE_INST,
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
    } else {
        AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
        AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
            "UE module id is too low (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local);
    }
#endif
    AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
    switch (actionP) {

        case CONFIG_ACTION_ADD:
            if (rrc_rlc_add_rlc(enb_mod_idP, ue_mod_idP, frameP, enb_flagP, srb_flagP, MBMS_FLAG_NO, rb_idP, rb_idP, rlc_infoP.rlc_mode) != NULL) {
              return RLC_OP_STATUS_INTERNAL_ERROR;
            }
            // no break, fall to next case
        case CONFIG_ACTION_MODIFY:
            switch (rlc_infoP.rlc_mode) {
                case RLC_MODE_AM:
                    LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB AM\n",
                            frameP,
                            enb_mod_idP,
                            ue_mod_idP,
                            rb_idP);

                    config_req_rlc_am(
                        enb_mod_idP,
                        ue_mod_idP,
                        frameP,
                        enb_flagP,
                        srb_flagP,
                        &rlc_infoP.rlc.rlc_am_info,
                        rb_idP);
                    break;
                case RLC_MODE_UM:
                    LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB UM\n",
                            frameP,
                            enb_mod_idP,
                            ue_mod_idP,
                            rb_idP);
                    config_req_rlc_um(
                        enb_mod_idP,
                        ue_mod_idP,
                        frameP,
                        enb_flagP,
                        srb_flagP,
                        &rlc_infoP.rlc.rlc_um_info,
                        rb_idP);
                    break;
                case RLC_MODE_TM:
                    LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB TM\n",
                            frameP,
                            enb_mod_idP,
                            ue_mod_idP,
                            rb_idP);
                    config_req_rlc_tm(
                        enb_mod_idP,
                        ue_mod_idP,
                        frameP,
                        enb_flagP,
                        srb_flagP,
                        &rlc_infoP.rlc.rlc_tm_info,
                        rb_idP);
                    break;
                default:
                return RLC_OP_STATUS_BAD_PARAMETER;
            }
            break;

        case CONFIG_ACTION_REMOVE:
            return rrc_rlc_remove_rlc(enb_mod_idP, ue_mod_idP, frameP, enb_flagP, srb_flagP, mbms_flagP, rb_idP);
            break;
        default:
            return RLC_OP_STATUS_BAD_PARAMETER;
    }

    return RLC_OP_STATUS_OK;
}
예제 #18
0
F32 GuiGraphCtrl::getDatum( S32 plotID, S32 sample)
{
   AssertFatal(plotID > -1 && plotID < MaxPlots, "Invalid plot specified!");
   AssertFatal(sample > -1 && sample < MaxDataPoints, "Invalid sample specified!");
   return mGraphData[ plotID ][sample];
}
예제 #19
0
const PlaneF& OptimizedPolyList::getIndexedPlane(const U32 index)
{
   AssertFatal(index < mPlaneList.size(), "Out of bounds index!");
   return mPlaneList[index];
}
예제 #20
0
void GuiGraphCtrl::setGraphType( S32 plotID, GraphType graphType )
{
	AssertFatal( plotID > -1 && plotID < MaxPlots, "Invalid plot specified!" );
   mGraphType[ plotID ] = graphType;
}
예제 #21
0
void config_req_rlc_um_asn1 (
  const protocol_ctxt_t* const ctxt_pP,
  const srb_flag_t          srb_flagP,
  const MBMS_flag_t         mbms_flagP,
  const mbms_session_id_t   mbms_session_idP,
  const mbms_service_id_t   mbms_service_idP,
  const UL_UM_RLC_t       * const ul_rlc_pP,
  const DL_UM_RLC_t       * const dl_rlc_pP,
  const rb_id_t             rb_idP)
{
  uint32_t         ul_sn_FieldLength   = 0;
  uint32_t         dl_sn_FieldLength   = 0;
  uint32_t         t_Reordering        = 0;
  rlc_union_t     *rlc_union_p         = NULL;
  rlc_um_entity_t *rlc_p               = NULL;
  hash_key_t       key                 = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
  hashtable_rc_t   h_rc;

#if Rel10

  if (mbms_flagP) {
    AssertFatal(dl_rlc_pP, "No RLC UM DL config");
    AssertFatal(ul_rlc_pP == NULL, "RLC UM UL config present");
    key = RLC_COLL_KEY_MBMS_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, mbms_service_idP, mbms_session_idP);
    h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
    AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u rnti %i enb flag %u service id %u, session id %u",
                 ctxt_pP->module_id,
                 ctxt_pP->rnti,
                 ctxt_pP->enb_flag,
                 mbms_service_idP,
                 mbms_session_idP);
    rlc_p = &rlc_union_p->rlc.um;
  } else
#endif
  {
    key  = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP);
    h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
    AssertFatal (h_rc == HASH_TABLE_OK, "RLC NOT FOUND enb id %u ue id %i enb flag %u rb id %u, srb flag %u",
                 ctxt_pP->module_id,
                 ctxt_pP->rnti,
                 ctxt_pP->enb_flag,
                 rb_idP,
                 srb_flagP);
    rlc_p = &rlc_union_p->rlc.um;
  }

  //-----------------------------------------------------------------------------
  LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT"  CONFIG_REQ timer_reordering=%dms sn_field_length=   RB %u \n",
        PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p),
        (dl_rlc_pP && dl_rlc_pP->t_Reordering<31)?t_Reordering_tab[dl_rlc_pP->t_Reordering]:-1,
        rb_idP);

  rlc_um_init(ctxt_pP, rlc_p);


  if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) {
    rlc_um_set_debug_infos(ctxt_pP,rlc_p, srb_flagP, rb_idP);

    if (ul_rlc_pP != NULL) {
      switch (ul_rlc_pP->sn_FieldLength) {
      case SN_FieldLength_size5:
        ul_sn_FieldLength = 5;
        break;

      case SN_FieldLength_size10:
        ul_sn_FieldLength = 10;
        break;

      default:
        LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID UL sn_FieldLength %d, RLC NOT CONFIGURED\n",
              PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p),
              rlc_p->rb_id,
              ul_rlc_pP->sn_FieldLength);
        MSC_LOG_RX_DISCARDED_MESSAGE(
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE,
      	    NULL,
      	    0,
      	    MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ UL sn_FieldLength %u",
      	    MSC_AS_TIME_ARGS(ctxt_pP),
      	    PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, rlc_p),
      	    ul_rlc_pP->sn_FieldLength);
        return;
      }
    }

    if (dl_rlc_pP != NULL) {
      switch (dl_rlc_pP->sn_FieldLength) {
      case SN_FieldLength_size5:
        dl_sn_FieldLength = 5;
        break;

      case SN_FieldLength_size10:
        dl_sn_FieldLength = 10;
        break;

      default:
        LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID DL sn_FieldLength %d, RLC NOT CONFIGURED\n",
              PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p),
              rlc_p->rb_id,
              dl_rlc_pP->sn_FieldLength);
        MSC_LOG_RX_DISCARDED_MESSAGE(
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE,
      	    NULL,
      	    0,
      	    MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ DL sn_FieldLength %u",
      	    MSC_AS_TIME_ARGS(ctxt_pP),
      	    PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, rlc_p),
      	    dl_rlc_pP->sn_FieldLength);
        return;
      }

      if (dl_rlc_pP->t_Reordering<T_Reordering_spare1) {
        t_Reordering = t_Reordering_tab[dl_rlc_pP->t_Reordering];
      } else {
        LOG_E(RLC,PROTOCOL_RLC_UM_CTXT_FMT" [CONFIGURE] RB %u INVALID T_Reordering %d, RLC NOT CONFIGURED\n",
              PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p),
              rlc_p->rb_id,
              dl_rlc_pP->t_Reordering);

        MSC_LOG_RX_DISCARDED_MESSAGE(
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
      	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE,
      	    NULL,
      	    0,
      	    MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ t_Reord %u",
      	    MSC_AS_TIME_ARGS(ctxt_pP),
      	    PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, rlc_p),
      	    dl_rlc_pP->t_Reordering);
        return;
      }
    }

    if (ctxt_pP->enb_flag > 0) {
      rlc_um_configure(ctxt_pP,rlc_p,
                       t_Reordering,
                       ul_sn_FieldLength,
                       dl_sn_FieldLength,
                       mbms_flagP);
      MSC_LOG_RX_MESSAGE(
    	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
    	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE,
    	    NULL,
    	    0,
    	    MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ t_Reord %u rx snfl %u tx snfl %u",
    	    MSC_AS_TIME_ARGS(ctxt_pP),
    	    PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, rlc_p),
    	    t_Reordering,
    	    ul_sn_FieldLength,
    	    dl_sn_FieldLength);
    } else {

      rlc_um_configure(ctxt_pP,rlc_p,
                       t_Reordering,
                       dl_sn_FieldLength,
                       ul_sn_FieldLength,
                       mbms_flagP);
      MSC_LOG_RX_MESSAGE(
    	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RLC_ENB:MSC_RLC_UE,
    	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_RRC_ENB:MSC_RRC_UE,
    	    NULL,
    	    0,
    	    MSC_AS_TIME_FMT" "PROTOCOL_RLC_AM_MSC_FMT" CONFIG-REQ t_Reord %u rx snfl %u tx snfl %u",
    	    MSC_AS_TIME_ARGS(ctxt_pP),
    	    PROTOCOL_RLC_AM_MSC_ARGS(ctxt_pP, rlc_p),
    	    t_Reordering,
    	    dl_sn_FieldLength,
    	    ul_sn_FieldLength);
    }
  }
}
예제 #22
0
void LightFlareData::prepRender( SceneRenderState *state, LightFlareState *flareState )
{
   PROFILE_SCOPE( LightFlareData_prepRender );

   const LightInfo *lightInfo = flareState->lightInfo;

   if (  mIsZero( flareState->fullBrightness ) ||
         mIsZero( lightInfo->getBrightness() ) )
      return;

   // Figure out the element count to render.
   U32 elementCount = mElementCount;
   const bool isReflectPass = state->isReflectPass();
   if ( isReflectPass )
   {
      // Then we don't render anything this pass.
      if ( !mRenderReflectPass )
         return;

      // Find the zero distance elements which make 
      // up the corona of the light flare.
      elementCount = 0.0f;
      for ( U32 i=0; i < mElementCount; i++ )
         if ( mIsZero( mElementDist[i] ) )
            elementCount++;
   }

   // Better have something to render.
   if ( elementCount == 0 )
      return;
  
   U32 visDelta = U32_MAX;
   F32 occlusionFade = 1.0f;
   Point3F lightPosSS;
   bool lightVisible = _testVisibility( state, flareState, &visDelta, &occlusionFade, &lightPosSS );
   
   // We can only skip rendering if the light is not 
   // visible, and it has elapsed the fade out time.
   if (  mIsZero( occlusionFade ) ||
         !lightVisible && visDelta > FadeOutTime )
      return;

   const RectI &viewport = GFX->getViewport();
   Point3F oneOverViewportExtent( 1.0f / (F32)viewport.extent.x, 1.0f / (F32)viewport.extent.y, 0.0f );

   // Really convert it to screen space.
   lightPosSS.x -= viewport.point.x;
   lightPosSS.y -= viewport.point.y;
   lightPosSS *= oneOverViewportExtent;
   lightPosSS = ( lightPosSS * 2.0f ) - Point3F::One;
   lightPosSS.y = -lightPosSS.y;
   lightPosSS.z = 0.0f;

   // Take any projection offset into account so that the point where the flare's
   // elements converge is at the 'eye' point rather than the center of the viewport.
   const Point2F& projOffset = state->getCameraFrustum().getProjectionOffset();
   Point3F flareVec( -lightPosSS + Point3F(projOffset.x, projOffset.y, 0.0f) );
   const F32 flareLength = flareVec.len();
   if ( flareLength > 0.0f )
      flareVec *= 1.0f / flareLength;

   // Setup the flare quad points.
   Point3F rotatedBasePoints[4];
   dMemcpy(rotatedBasePoints, sBasePoints, sizeof( sBasePoints ));

   // Rotate the flare quad.
   F32 rot = mAcos( -1.0f * flareVec.x );
   rot *= flareVec.y > 0.0f ? -1.0f : 1.0f;
   MathUtils::vectorRotateZAxis( rot, rotatedBasePoints, 4 );

   // Here we calculate a the light source's influence on 
   // the effect's size and brightness.

   // Scale based on the current light brightness compared to its normal output.
   F32 lightSourceBrightnessScale = lightInfo->getBrightness() / flareState->fullBrightness;

   const Point3F &camPos = state->getCameraPosition();
   const Point3F &lightPos = flareState->lightMat.getPosition();   
   const bool isVectorLight = lightInfo->getType() == LightInfo::Vector;

   // Scale based on world space distance from camera to light source.
   F32 distToCamera = ( camPos - lightPos ).len();
   F32 lightSourceWSDistanceScale = isVectorLight && distToCamera > 0.0f ? 1.0f : getMin( 10.0f / distToCamera, 10.0f );

   // Scale based on screen space distance from screen position of light source to the screen center.
   F32 lightSourceSSDistanceScale = getMax( ( 1.5f - flareLength ) / 1.5f, 0.0f );

   // Scale based on recent visibility changes, fading in or out.
   F32 fadeInOutScale = 1.0f;   
   if (  lightVisible &&
         visDelta < FadeInTime && 
         flareState->occlusion > 0.0f )
      fadeInOutScale = (F32)visDelta / (F32)FadeInTime;
   else if (   !lightVisible && 
               visDelta < FadeOutTime )
      fadeInOutScale = 1.0f - (F32)visDelta / (F32)FadeOutTime;

   // This combined scale influences the size of all elements this effect renders.
   // Note we also add in a scale that is user specified in the Light.
   F32 lightSourceIntensityScale = lightSourceBrightnessScale * 
                                   lightSourceWSDistanceScale * 
                                   lightSourceSSDistanceScale * 
                                   fadeInOutScale * 
                                   flareState->scale *
                                   occlusionFade;

   if ( mIsZero( lightSourceIntensityScale ) )
      return;

   // The baseColor which modulates the color of all elements.
   //
   // These are the factors which affect the "alpha" of the flare effect.
   // Modulate more in as appropriate.
   ColorF baseColor = ColorF::WHITE * lightSourceBrightnessScale * occlusionFade;

   // Setup the vertex buffer for the maximum flare elements.
   const U32 vertCount = 4 * mElementCount;
   if (  flareState->vertBuffer.isNull() || 
         flareState->vertBuffer->mNumVerts != vertCount )
         flareState->vertBuffer.set( GFX, vertCount, GFXBufferTypeDynamic );

   GFXVertexPCT *vert = flareState->vertBuffer.lock();

   const Point2F oneOverTexSize( 1.0f / (F32)mFlareTexture.getWidth(), 1.0f / (F32)mFlareTexture.getHeight() );

   for ( U32 i = 0; i < mElementCount; i++ )
   {      
      // Skip non-zero elements for reflections.
      if ( isReflectPass && mElementDist[i] > 0.0f )
         continue;

      Point3F *basePos = mElementRotate[i] ? rotatedBasePoints : sBasePoints;

      ColorF color( baseColor * mElementTint[i] );
      if ( mElementUseLightColor[i] )
         color *= lightInfo->getColor();
      color.clamp();

      Point3F pos( lightPosSS + flareVec * mElementDist[i] * flareLength );

      const RectF &rect = mElementRect[i];
      Point3F size( rect.extent.x, rect.extent.y, 1.0f );
      size *= mElementScale[i] * mScale * lightSourceIntensityScale;

      AssertFatal( size.x >= 0.0f, "LightFlareData::prepRender - Got a negative element size?" );

      if ( size.x < 100.0f )
      {
         F32 alphaScale = mPow( size.x / 100.0f, 2 );
         color *= alphaScale;
      }

      Point2F texCoordMin, texCoordMax;
      texCoordMin = rect.point * oneOverTexSize;
      texCoordMax = ( rect.point + rect.extent ) * oneOverTexSize;          

      size.x = getMax( size.x, 1.0f );
      size.y = getMax( size.y, 1.0f );
      size *= oneOverViewportExtent;

      vert->color = color;
      vert->point = ( basePos[0] * size ) + pos;      
      vert->texCoord.set( texCoordMin.x, texCoordMax.y );
      vert++;

      vert->color = color;
      vert->point = ( basePos[1] * size ) + pos;
      vert->texCoord.set( texCoordMax.x, texCoordMax.y );
      vert++;

      vert->color = color;
      vert->point = ( basePos[2] * size ) + pos;
      vert->texCoord.set( texCoordMax.x, texCoordMin.y );
      vert++;

      vert->color = color;
      vert->point = ( basePos[3] * size ) + pos;
      vert->texCoord.set( texCoordMin.x, texCoordMin.y );
      vert++;
   }   

   flareState->vertBuffer.unlock();   

   RenderPassManager *rpm = state->getRenderPass();

   // Create and submit the render instance.   
   ParticleRenderInst *ri = rpm->allocInst<ParticleRenderInst>();
   ri->type = RenderPassManager::RIT_Particle;
   ri->vertBuff = &flareState->vertBuffer;
   ri->primBuff = &mFlarePrimBuffer;
   ri->translucentSort = true;
   ri->sortDistSq = ( lightPos - camPos ).lenSquared();
   ri->modelViewProj = &MatrixF::Identity;
   ri->bbModelViewProj = &MatrixF::Identity;
   ri->count = elementCount;
   ri->blendStyle = ParticleRenderInst::BlendGreyscale;
   ri->diffuseTex = mFlareTexture;
   ri->softnessDistance = 1.0f; 
   ri->defaultKey = ri->diffuseTex ? (uintptr_t)ri->diffuseTex : (uintptr_t)ri->vertBuff; // Sort by texture too.

   // NOTE: Offscreen partical code is currently disabled.
   ri->systemState = PSS_AwaitingHighResDraw;

   rpm->addInst( ri );
}
예제 #23
0
//-----------------------------------------------------------------------------
bool FileStream::_write(const U32 i_numBytes, const void *i_pBuffer)
{
   AssertFatal(0 != mStreamCaps, "FileStream::_write: the stream isn't open");
   AssertFatal(NULL != i_pBuffer || i_numBytes == 0, "FileStream::_write: NULL source buffer pointer on non-zero write request");

   if (!hasCapability(Stream::StreamWrite))
   {
      AssertFatal(false, "FileStream::_write: file stream lacks capability");
      Stream::setStatus(IllegalCall);
      return(false);
   }

   // exit on pre-existing errors
   if (Ok != getStatus() && EOS != getStatus())
      return(false);

   // if a request of non-zero length was made
   if (0 != i_numBytes)
   {
      U8 *pSrc = (U8 *)i_pBuffer;
      U32 writeSize;
      U32 remaining = i_numBytes;
      U32 bytesWrit;
      U32 blockHead;
      U32 blockTail;

      // check if the buffer is valid
      if (BUFFER_INVALID != mBuffHead)
      {
         // copy as much as possible from the source to the buffer
         calcBlockBounds(mBuffHead, &blockHead, &blockTail);
         writeSize = (mBuffPos > blockTail) ? 0 : blockTail - mBuffPos + 1;
         writeSize = getMin(writeSize, remaining);

         AssertFatal(0 == writeSize || (mBuffPos - blockHead) < BUFFER_SIZE, "FileStream::_write: out of bounds buffer position");
         dMemcpy(mBuffer + (mBuffPos - blockHead), pSrc, writeSize);
         // reduce the remaining amount to be written
         remaining -= writeSize;
         // advance the buffer pointers
         mBuffPos += writeSize;
         mBuffTail = getMax(mBuffTail, mBuffPos - 1);
         pSrc += writeSize;
         // mark the buffer dirty
         if (0 < writeSize)
            mDirty = true;
      }

      // if the request wasn't satisfied by the buffer
      if (0 < remaining)
      {
         // flush the buffer if its dirty, since we now need to go to disk
         if (mDirty)
            flush();

         // make sure we know the current write location in the underlying file
         mBuffPos = mFile->getPosition();
         calcBlockBounds(mBuffPos, &blockHead, &blockTail);

         // check if the data to be written falls within a single block
         if ((mBuffPos + remaining) <= blockTail)
         {
            // write the data to the buffer
            dMemcpy(mBuffer + (mBuffPos - blockHead), pSrc, remaining);
            // update the buffer pointers
            mBuffHead = mBuffPos;
            mBuffPos += remaining;
            mBuffTail = mBuffPos - 1;
            // mark the buffer dirty
            mDirty = true;
         }
         // otherwise the remaining spans multiple blocks
         else
         {
            clearBuffer();
            // write to disk directly from the source
            bytesWrit = mFile->write((char *)pSrc, remaining);
            setStatus();
            return(Ok == getStatus() || EOS == getStatus());
         }
      }
   }
   return(true);
}
예제 #24
0
const char *getData(S32 type, void *dptr, S32 index, const EnumTable *tbl, BitSet32 flag)
{
   ConsoleBaseType *cbt = ConsoleBaseType::getType(type);
   AssertFatal(cbt, "Con::getData - could not resolve type ID!");
   return cbt->getData((void *) (((const char *)dptr) + index * cbt->getTypeSize()), tbl, flag);
}
예제 #25
0
bool 
SimInterior::loadShape(const char* fileName)
{
   // setFilename returns false if the filename is invalid, OR if the filename
   //  is the same as the one already set.  In either case, we exit wo/ doing
   //  any work...
   //
   if (setFilename(fileName) == false) {
      return false;
   }
   
   // NOTE: This function is VERY poor on error checking, there are only a few
   //  asserts in ITRInstance().  Maybe restructure to be a bit more robust?
   //
   ResourceManager *rm = SimResource::get(manager);

   Resource<ITRShape> itrShape;
    
   bool missionLit;  
   // check if we need to try and find the missionlit ver
   if( rm->findFile( fileName ) )
   {
      missionLit = missionLitName();
      itrShape = rm->load( fileName);
   }
   else
   {
      if( !missionLitName() )
         return( false );
      String base = String(fileName);
      getBaseFilename( base );
      if( rm->findFile( base.c_str() ) )
         itrShape = rm->load(base.c_str());
      missionLit = false;
   }
   
   if( !bool( itrShape ) )
      return( false );

   // If we make it to here, then all is cool, nuke the old resources...
   //
   unloadResources();

   ITRInstance* pInstance = new ITRInstance(rm, itrShape, 0);
   if( missionLit )
      pInstance->setMissionLit();
   renderImage.instance = pInstance;

   // Set the geometry for the database and collision image.  Note that this
   //  is the highest level of state 0 for the interior.  May have to change
   //  the collision image geometry pointer on detail level change, probably
   //  will only change the database pointer on state switches...
   //
   updateBoundingBox();
	SimContainer* root = NULL;
   
   root = findObject(manager,SimRootContainerId,root);
	root->addObject(this);

   getInstance()->getAutoStartIDs(animatingLights);

   SimSet* pITRTimerSet = dynamic_cast<SimSet*>(manager->findObject(SimITRTimerSetId));
   if (pITRTimerSet == NULL)
      manager->addObject(new SimTimerSet(1.0f/15.0f, SimITRTimerSetId));
   bool timerSuccess = addToSet(SimITRTimerSetId);
   AssertFatal(timerSuccess == true, "Could not add to SimITRTimerSet");


   return true;
}
예제 #26
0
//-----------------------------------------------------------------------------
rlc_op_status_t rrc_rlc_remove_rlc   (
    const module_id_t enb_mod_idP,
    const module_id_t ue_mod_idP,
    const frame_t     frameP,
    const eNB_flag_t  enb_flagP,
    const srb_flag_t  srb_flagP,
    const MBMS_flag_t MBMS_flagP,
    const rb_id_t     rb_idP) {
//-----------------------------------------------------------------------------
    logical_chan_id_t      lcid            = 0;
    hash_key_t             key             = HASHTABLE_QUESTIONABLE_KEY_VALUE;
    hashtable_rc_t         h_rc;
#ifdef Rel10
    rlc_mbms_id_t         *mbms_id_p  = NULL;
#endif
#ifdef OAI_EMU
    AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
        "eNB module id is too low (%u/%d)!\n",
        enb_mod_idP,
        oai_emulation.info.first_enb_local);
    AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local),
        "eNB module id is too high (%u/%d)!\n",
        enb_mod_idP,
        oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
    if (enb_flagP) {
        AssertFatal (ue_mod_idP  < NB_UE_INST,
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
    } else {
        AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
        AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
            "UE module id is too low (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local);
    }
#endif

#ifdef Rel10
  if (MBMS_flagP == TRUE) {
      if (enb_flagP) {
          lcid = rlc_mbms_enb_get_lcid_by_rb_id(enb_mod_idP,rb_idP);
          mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid];

          rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid].service_id = 0;
          rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid].session_id = 0;
          rlc_mbms_rbid2lcid_ue[enb_mod_idP][rb_idP] = RLC_LC_UNALLOCATED;
      } else {
          lcid = rlc_mbms_ue_get_lcid_by_rb_id(ue_mod_idP,rb_idP);
          mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ue_mod_idP][lcid];

          rlc_mbms_lcid2service_session_id_eNB[ue_mod_idP][lcid].service_id = 0;
          rlc_mbms_lcid2service_session_id_eNB[ue_mod_idP][lcid].session_id = 0;
          rlc_mbms_rbid2lcid_ue[ue_mod_idP][rb_idP] = RLC_LC_UNALLOCATED;
      }
      key = RLC_COLL_KEY_MBMS_VALUE(enb_mod_idP, ue_mod_idP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id);
  } else
#endif
  {
      key = RLC_COLL_KEY_VALUE(enb_mod_idP, ue_mod_idP, enb_flagP, rb_idP, srb_flagP);
  }


    AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);

    h_rc = hashtable_remove(rlc_coll_p, key);
    if (h_rc == HASH_TABLE_OK) {
        LOG_D(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASED %s\n",
            frameP,
            (enb_flagP) ? "eNB" : "UE",
            enb_mod_idP,
            ue_mod_idP,
            (srb_flagP) ? "SRB" : "DRB",
            rb_idP,
            (srb_flagP) ? "SRB" : "DRB");
    } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) {
        LOG_W(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASE : RLC NOT FOUND %s\n",
            frameP,
            (enb_flagP) ? "eNB" : "UE",
            enb_mod_idP,
            ue_mod_idP,
            (srb_flagP) ? "SRB" : "DRB",
            rb_idP,
            (srb_flagP) ? "SRB" : "DRB");
    } else {
        LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] RELEASE : INTERNAL ERROR %s\n",
            frameP,
            (enb_flagP) ? "eNB" : "UE",
            enb_mod_idP,
            ue_mod_idP,
            (srb_flagP) ? "SRB" : "DRB",
            rb_idP,
            (srb_flagP) ? "SRB" : "DRB");    }

    return RLC_OP_STATUS_OK;
}
예제 #27
0
void GFXGLShader::initConstantDescs()
{
   mConstants.clear();
   GLint numUniforms;
   glGetProgramiv(mProgram, GL_ACTIVE_UNIFORMS, &numUniforms);
   GLint maxNameLength;
   glGetProgramiv(mProgram, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength);

   if(!maxNameLength)
      return;

   FrameTemp<GLchar> uniformName(maxNameLength);
   
   for(U32 i = 0; i < numUniforms; i++)
   {
      GLint size;
      GLenum type;
      glGetActiveUniform(mProgram, i, maxNameLength, NULL, &size, &type, uniformName);
      GFXShaderConstDesc desc;
      
      desc.name = String((char*)uniformName);
      
      // Remove array brackets from the name
      desc.name = desc.name.substr(0, desc.name.find('['));
      
      // Insert $ to match D3D behavior of having a $ prepended to parameters to main.
      desc.name.insert(0, '$');
      desc.arraySize = size;
      
      switch(type)
      {
         case GL_FLOAT:
            desc.constType = GFXSCT_Float;
            break;
         case GL_FLOAT_VEC2:
            desc.constType = GFXSCT_Float2;
            break;
         case GL_FLOAT_VEC3:
            desc.constType = GFXSCT_Float3;
            break;
         case GL_FLOAT_VEC4:
            desc.constType = GFXSCT_Float4;
            break;
         case GL_INT:
            desc.constType = GFXSCT_Int;
            break;
         case GL_INT_VEC2:
            desc.constType = GFXSCT_Int2;
            break;
         case GL_INT_VEC3:
            desc.constType = GFXSCT_Int3;
            break;
         case GL_INT_VEC4:
            desc.constType = GFXSCT_Int4;
            break;
         case GL_FLOAT_MAT2:
            desc.constType = GFXSCT_Float2x2;
            break;
         case GL_FLOAT_MAT3:
            desc.constType = GFXSCT_Float3x3;
            break;
         case GL_FLOAT_MAT4:
            desc.constType = GFXSCT_Float4x4;
            break;
         case GL_SAMPLER_1D:
         case GL_SAMPLER_2D:
         case GL_SAMPLER_3D:
         case GL_SAMPLER_1D_SHADOW:
         case GL_SAMPLER_2D_SHADOW:
            desc.constType = GFXSCT_Sampler;
            break;
         case GL_SAMPLER_CUBE:
            desc.constType = GFXSCT_SamplerCube;
            break;
         default:
            AssertFatal(false, "GFXGLShader::initConstantDescs - unrecognized uniform type");
            // If we don't recognize the constant don't add its description.
            continue;
      }
      
      mConstants.push_back(desc);
   }
}
예제 #28
0
//-----------------------------------------------------------------------------
rlc_union_t* rrc_rlc_add_rlc   (
    const module_id_t       enb_mod_idP,
    const module_id_t       ue_mod_idP,
    const frame_t           frameP,
    const eNB_flag_t        enb_flagP,
    const srb_flag_t        srb_flagP,
    const MBMS_flag_t       MBMS_flagP,
    const rb_id_t           rb_idP,
    const logical_chan_id_t chan_idP,
    const rlc_mode_t        rlc_modeP) {
//-----------------------------------------------------------------------------
  hash_key_t             key         = HASHTABLE_QUESTIONABLE_KEY_VALUE;
  hashtable_rc_t         h_rc;
  rlc_union_t           *rlc_union_p = NULL;
#ifdef Rel10
    rlc_mbms_id_t         *mbms_id_p  = NULL;
    logical_chan_id_t      lcid            = 0;
#endif

#ifdef OAI_EMU
    if (enb_flagP) {
        AssertFatal ((enb_mod_idP >= oai_emulation.info.first_enb_local) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too low (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local);
        AssertFatal ((enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)) && (oai_emulation.info.nb_enb_local > 0),
            "eNB module id is too high (%u/%d)!\n",
            enb_mod_idP,
            oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local);
        AssertFatal (ue_mod_idP  < NB_UE_INST,
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
    } else {
        AssertFatal (ue_mod_idP  < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local),
            "UE module id is too high (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local);
        AssertFatal (ue_mod_idP  >= oai_emulation.info.first_ue_local,
            "UE module id is too low (%u/%d)!\n",
            ue_mod_idP,
            oai_emulation.info.first_ue_local);
    }
#endif
    if (MBMS_flagP == FALSE) {
        AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX);
        AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC);
    }

#ifdef Rel10
  if (MBMS_flagP == TRUE) {
      if (enb_flagP) {
          lcid = rlc_mbms_enb_get_lcid_by_rb_id(enb_mod_idP,rb_idP);
          LOG_I(RLC,
                  "[Frame %05u] lcid %d = rlc_mbms_enb_get_lcid_by_rb_id(enb_mod_idP %u, rb_idP %u)\n",
                  frameP,lcid, enb_mod_idP, rb_idP);

          mbms_id_p = &rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid];

          //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid].service_id = 0;
          //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[enb_mod_idP][lcid].session_id = 0;
          //LG 2014-04-15rlc_mbms_rbid2lcid_eNB[enb_mod_idP][rb_idP] = RLC_LC_UNALLOCATED;
      } else {
          lcid = rlc_mbms_ue_get_lcid_by_rb_id(ue_mod_idP,rb_idP);
          mbms_id_p = &rlc_mbms_lcid2service_session_id_ue[ue_mod_idP][lcid];

          //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ue_mod_idP][lcid].service_id = 0;
          //LG 2014-04-15rlc_mbms_lcid2service_session_id_eNB[ue_mod_idP][lcid].session_id = 0;
          //LG 2014-04-15rlc_mbms_rbid2lcid_ue[ue_mod_idP][rb_idP] = RLC_LC_UNALLOCATED;
      }
      key = RLC_COLL_KEY_MBMS_VALUE(enb_mod_idP, ue_mod_idP, enb_flagP, mbms_id_p->service_id, mbms_id_p->session_id);
  } else
#endif
  {
      key = RLC_COLL_KEY_VALUE(enb_mod_idP, ue_mod_idP, enb_flagP, rb_idP, srb_flagP);
  }

  h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p);
  if (h_rc == HASH_TABLE_OK) {
      LOG_W(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc , already exist %s\n",
          frameP,
          (enb_flagP) ? "eNB" : "UE",
          enb_mod_idP,
          ue_mod_idP,
          (srb_flagP) ? "SRB" : "DRB",
          rb_idP,
          (srb_flagP) ? "SRB" : "DRB");
      AssertFatal(rlc_union_p->mode == rlc_modeP, "Error rrc_rlc_add_rlc , already exist but RLC mode differ");
      return rlc_union_p;
  } else if (h_rc == HASH_TABLE_KEY_NOT_EXISTS) {
      rlc_union_p = calloc(1, sizeof(rlc_union_t));
      h_rc = hashtable_insert(rlc_coll_p, key, rlc_union_p);
      if (h_rc == HASH_TABLE_OK) {
#ifdef Rel10
          if (MBMS_flagP == TRUE) {
              LOG_I(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u] RLC service id %u session id %u rrc_rlc_add_rlc\n",
                  frameP,
                  (enb_flagP) ? "eNB" : "UE",
                  enb_mod_idP,
                  ue_mod_idP,
                  mbms_id_p->service_id,
                  mbms_id_p->session_id);
          } else
#endif
          {
              LOG_I(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc  %s\n",
                  frameP,
                  (enb_flagP) ? "eNB" : "UE",
                  enb_mod_idP,
                  ue_mod_idP,
                  (srb_flagP) ? "SRB" : "DRB",
                  rb_idP,
                  (srb_flagP) ? "SRB" : "DRB");
          }
          rlc_union_p->mode = rlc_modeP;
          return rlc_union_p;
      } else {
          LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc  FAILED %s\n",
              frameP,
              (enb_flagP) ? "eNB" : "UE",
              enb_mod_idP,
              ue_mod_idP,
              (srb_flagP) ? "SRB" : "DRB",
              rb_idP,
              (srb_flagP) ? "SRB" : "DRB");
          free(rlc_union_p);
          rlc_union_p = NULL;
          return NULL;
      }
  } else {
      LOG_E(RLC, "[Frame %05u][%s][RLC_RRC][INST %u/%u][%s %u] rrc_rlc_add_rlc , INTERNAL ERROR %s\n",
          frameP,
          (enb_flagP) ? "eNB" : "UE",
          enb_mod_idP,
          ue_mod_idP,
          (srb_flagP) ? "SRB" : "DRB",
          rb_idP,
          (srb_flagP) ? "SRB" : "DRB");
  }
  return NULL;
}
예제 #29
0
char* GFXGLShader::_handleIncludes( const Torque::Path& path, FileStream *s )
{
   // TODO:  The #line pragma on GLSL takes something called a
   // "source-string-number" which it then never explains.
   //
   // Until i resolve this mystery i disabled this.
   //
   //String linePragma = String::ToString( "#line 1 \r\n");
   //U32 linePragmaLen = linePragma.length();

   U32 shaderLen = s->getStreamSize();
   char* buffer = (char*)dMalloc(shaderLen + 1);
   //dStrncpy( buffer, linePragma.c_str(), linePragmaLen );
   s->read(shaderLen, buffer);
   buffer[shaderLen] = 0;
   
   char* p = dStrstr(buffer, "#include");
   while(p)
   {
      char* q = p;
      p += 8;
      if(dIsspace(*p))
      {
         U32 n = 0;
         while(dIsspace(*p)) ++p;
         AssertFatal(*p == '"', "Bad #include directive");
         ++p;
         static char includeFile[256];
         while(*p != '"')
         {
            AssertFatal(*p != 0, "Bad #include directive");
            includeFile[n++] = *p++;
            AssertFatal(n < sizeof(includeFile), "#include directive too long");
         }
         ++p;
         includeFile[n] = 0;

         // First try it as a local file.
         Torque::Path includePath = Torque::Path::Join(path.getPath(), '/', includeFile);
         includePath = Torque::Path::CompressPath(includePath);
         
         FileStream includeStream;

         if ( !includeStream.open( includePath, Torque::FS::File::Read ) )
         {
            // Try again assuming the path is absolute 
            // and/or relative.
            includePath = String( includeFile );
            includePath = Torque::Path::CompressPath(includePath);
            if ( !includeStream.open( includePath, Torque::FS::File::Read ) )
            {
               AssertISV(false, avar("failed to open include '%s'.", includePath.getFullPath().c_str()));

               if ( smLogErrors )
                  Con::errorf( "GFXGLShader::_handleIncludes - Failed to open include '%s'.", 
                     includePath.getFullPath().c_str() );

               // Fail... don't return the buffer.
               dFree(buffer);
               return NULL;
            }
         }

         char* includedText = _handleIncludes(includePath, &includeStream);
         
         // If a sub-include fails... cleanup and return.
         if ( !includedText )
         {
            dFree(buffer);
            return NULL;
         }
         
         // TODO: Disabled till this is fixed correctly.
         //
         // Count the number of lines in the file 
         // before the include.
         /*
         U32 includeLine = 0;
         {
            char* nl = dStrstr( buffer, "\n" );
            while ( nl )
            {
               includeLine++;
               nl = dStrstr( nl, "\n" );
               if(nl) ++nl;
            }
         }
         */

         String manip(buffer);
         manip.erase(q-buffer, p-q);
         String sItx(includedText);

         // TODO: Disabled till this is fixed correctly.
         //
         // Add a new line pragma to restore the proper
         // file and line number after the include.
         //sItx += String::ToString( "\r\n#line %d \r\n", includeLine );
         
         dFree(includedText);
         manip.insert(q-buffer, sItx);
         char* manipBuf = dStrdup(manip.c_str());
         p = manipBuf + (q - buffer);
         dFree(buffer);
         buffer = manipBuf;
      }
      p = dStrstr(p, "#include");
   }
   
   return buffer;
}
예제 #30
0
S32 TSThread::getKeyframeCount()
{
   AssertFatal(!transitionData.inTransition,"TSThread::getKeyframeCount: not while in transition");

   return getSequence()->numKeyframes + 1;
}