Example #1
0
void Filter::PrintProfilingInfo() const
{
    auto misc = TotalTime - RenderTime - CompileTime;
    
    printf("%s: T(%.1fms) R(%.1fms=%.1f%%) Cpl(%.1fms=%.1f%%) M(%.1fms=%.1f%%)\n",
           Name.c_str(),
           GetTimeMsec(TotalTime),
           GetTimeMsec(RenderTime),
           RenderTime * 100.0f / TotalTime,
           GetTimeMsec(CompileTime),
           CompileTime * 100.0f / TotalTime,
           GetTimeMsec(misc),
           misc * 100.0f / TotalTime);
}
Example #2
0
List<BoundingBox> SWTHelperGPU::StrokeWidthTransform(const cv::Mat &input)
{
    glFinish();
    auto startTime = now();
    
    DisableIrrelvantState();
    glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE);
    
    int width  = input.size().width;
    int height = input.size().height;
    // Create a Texture from the input
    Ptr<Texture> texture = textureFromImage<cv::Vec3f>(input);
    
    List< Ptr<Texture> > textures;
    
    /*for(int i = 0; i < 14; ++i)
        textures.push_back( New<Texture>(width, height, GL_RGBA, GL_FLOAT) );
    
    for(int i = 0; i < 14; ++i)
        textures[i].reset();
    */
    
    // Create the framebuffer attachments
    auto colorf       = New<Texture>(GL_RGBA,          width, height, GL_RGBA,          GL_FLOAT);
    auto depthStencil = New<Texture>(GL_DEPTH_STENCIL, width, height, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
    //Ptr<RenderBuffer> depthStencil = New<RenderBuffer>(width, height, RenderBufferType::DepthStencil);
    
    // Create and setup framebuffer
    FrameBuffer frameBuffer(colorf);
    //frameBuffer.SetDepthStencil(depthStencil);
    
    // Create a full-screen rect
    DrawableRect rect(-1, -1, 1, 1);
    GraphicsDevice::SetDefaultBuffers(rect.VertexBuffer, rect.IndexBuffer);
    GraphicsDevice::UseDefaultBuffers();
    
    frameBuffer.Bind();

    auto textRegionsFilter = New<TextRegionsFilter>(texture);
    textRegionsFilter->DoLoadShaderPrograms();
    
    glFinish();
    auto setupTime = now() - startTime;
    
    ApplyPass(textRegionsFilter);
    
    //FrameBuffer::GetCurrentlyBound()->Print(RenderBufferType::Stencil);
    
    glFinish();
    auto totalTime = now() - startTime;
    
    auto misc = totalTime - renderTime - setupTime;
    
    printf("\n");
    printf("Total time: %.1fms\n",           GetTimeMsec(totalTime));
    printf("Setup time: %.1fms (%.1f%%)\n",  GetTimeMsec(setupTime),  setupTime  * 100.0f / totalTime);
    printf("Render time: %.1fms (%.1f%%)\n", GetTimeMsec(renderTime), renderTime * 100.0f / totalTime);
    printf("Misc time: %.1fms (%.1f%%)\n",   GetTimeMsec(misc),       misc       * 100.0f / totalTime);
    printf("Textures: Active %i Peak %i\n",  Texture::ActiveTextureCount, Texture::PeakTextureCount);
    
    return textRegionsFilter->ExtractedBoundingBoxes;
}
Example #3
0
void MyConnection::OnConnect(Connection* connection)
{
    if (!Server->Pids.Acquire(Id))
    {
        Logger.Warning("FIXME: Too many players not handled");
    }

    Logger.Info((int)Id, ": Connect");

    TCPSetPlayerId.CallSender = connection->TCPCallSender;
    TCPAddPlayer.CallSender = connection->TCPCallSender;
    TCPRemovePlayer.CallSender = connection->TCPCallSender;
    UDPPositionUpdate.CallSender = connection->UDPCallSender;

    connection->Router.Set<C2SLoginT>(C2SLoginID, [connection, this](std::string name)
    {
        Logger.Info((int)Id, ": User login '", name, "'");

        {
            Locker locker(PlayerDataLock);
            Name = name;
        }

        this->Server->InsertConnection(this);

        this->Server->Broadcast(this, &MyConnection::TCPAddPlayer,
            Id, name);

        // Send them the whole player list
        {
            ReadLocker locker;
            const auto& connections = this->Server->GetConnections(locker);

            for (auto& connection : connections)
                TCPAddPlayer(connection->Id, connection->GetName());
        }

        connection->Router.Set<C2SPositionUpdateT>(C2SPositionUpdateID, [this](u16 timestamp, PlayerPosition position)
        {
            Locker locker(PlayerDataLock);
            if (!PositionData.HasPosition)
            {
                Logger.Info((int)Id, ": Received player position for the first time");
                PositionData.HasPosition = true;
            }

            const u64 nowMsec = GetTimeMsec();
            const u64 localSentTimeMsec = ReconstructMsec(nowMsec, timestamp);
            int delayMsec = (int)((s64)nowMsec - (s64)localSentTimeMsec);
            // This data is used to avoid rebroadcasting data after a given timeout

            PositionData.Position = position;
            PositionData.PositionTimestamp15 = timestamp;
            PositionData.PositionMsec = localSentTimeMsec;

            Logger.Info((int)Id, ": Received player position with one-way-delay=", delayMsec);

            this->Server->BroadcastTracker.Update(this, position.x, position.y);
        });
    });

    TCPSetPlayerId(Id);
}