Exemplo n.º 1
0
    void createAndExecuteSyncPass(NodeIds nodeIds,
                                  const RenderParams& renderParams,
                                  PipeFilter& sendHistogramFilter,
                                  Renderer& renderer,
                                  const uint32_t renderStages) const
    {
        PipeFilterT<HistogramFilter> histogramFilter("HistogramFilter",
                                                     _histogramCache,
                                                     _dataCache, _dataSource);
        histogramFilter.getPromise("Frustum").set(
            renderParams.frameInfo.frustum);
        histogramFilter.connect("Histogram", sendHistogramFilter, "Histogram");
        histogramFilter.getPromise("RelativeViewport")
            .set(renderParams.viewport);
        histogramFilter.getPromise("DataSourceRange")
            .set(renderParams.dataSourceRange);

        Pipeline renderPipeline;
        Pipeline uploadPipeline;

        PipeFilterT<RenderFilter> renderFilter("RenderFilter", _dataSource,
                                               renderer);
        setupRenderFilter(renderFilter, renderParams, renderStages);

        PipeFilter uploader =
            uploadPipeline.add<DataUploadFilter>("DataUploader", _dataCache,
                                                 _textureCache, _dataSource,
                                                 _texturePool);

        uploader.getPromise("VisibleNodes").set(nodeIds);
        uploader.getPromise("Params").set(renderParams.vrParams);
        uploader.connect("CacheObjects", renderFilter, "CacheObjects");
        uploader.connect("CacheObjects", histogramFilter, "CacheObjects");

        renderPipeline.schedule(_renderExecutor);
        uploadPipeline.schedule(_uploadExecutor);
        sendHistogramFilter.schedule(_computeExecutor);
        histogramFilter.schedule(_computeExecutor);
        renderFilter.execute();
    }
Exemplo n.º 2
0
    void renderAsync( RenderStatistics& statistics,
                      Renderer& renderer,
                      const RenderInputs& renderInputs )
    {
        tuyau::PipeFilter sendHistogramFilter = renderInputs.filters.find( "SendHistogramFilter" )->second;
        tuyau::PipeFilter preRenderFilter = renderInputs.filters.find( "PreRenderFilter" )->second;
        tuyau::PipeFilter redrawFilter = renderInputs.filters.find( "RedrawFilter" )->second;
        tuyau::PipeFilterT< HistogramFilter > histogramFilter( "HistogramFilter",
                                                        *histogramCache,
                                                        *dataCache,
                                                        renderInputs.dataSource );
        histogramFilter.getPromise( "Frustum" ).set( renderInputs.frameInfo.frustum );
        histogramFilter.connect( "Histogram", sendHistogramFilter, "Histogram" );
        histogramFilter.getPromise( "RelativeViewport" ).set( renderInputs.viewport );
        histogramFilter.getPromise( "DataSourceRange" ).set( renderInputs.dataSourceRange );
        sendHistogramFilter.getPromise( "RelativeViewport" ).set( renderInputs.viewport );
        sendHistogramFilter.getPromise( "Id" ).set( renderInputs.frameInfo.frameId );
        preRenderFilter.getPromise( "Frustum" ).set( renderInputs.frameInfo.frustum );

        tuyau::Pipeline renderPipeline;
        tuyau::Pipeline uploadPipeline;

        tuyau::PipeFilterT< RenderFilter > renderFilter( "RenderFilter",
                                                         renderInputs.dataSource,
                                                         renderer );

        tuyau::PipeFilter visibleSetGenerator =
                    renderPipeline.add< VisibleSetGeneratorFilter >(
                        "VisibleSetGenerator", renderInputs.dataSource );
        setupVisibleGeneratorFilter( visibleSetGenerator, renderInputs );

        tuyau::PipeFilter renderingSetGenerator =
                renderPipeline.add< RenderingSetGeneratorFilter< CudaTextureObject >>(
                    "RenderingSetGenerator", *cudaCache );

        visibleSetGenerator.connect( "VisibleNodes", renderingSetGenerator, "VisibleNodes" );
        renderingSetGenerator.connect( "CacheObjects", renderFilter, "CacheObjects" );
        renderingSetGenerator.connect( "NodeIds", histogramFilter, "NodeIds" );
        renderingSetGenerator.connect( "RenderingDone", redrawFilter, "RenderingDone" );
        visibleSetGenerator.connect( "VisibleNodes", preRenderFilter, "VisibleNodes" );

        tuyau::PipeFilter renderUploader =
                uploadPipeline.add< CudaRenderUploadFilter >( "RenderUploader",
                                                              *dataCache,
                                                              *cudaCache,
                                                              *texturePool,
                                                              nUploadThreads,
                                                              _uploadExecutor );

        renderUploader.getPromise( "RenderInputs" ).set( renderInputs );
        visibleSetGenerator.connect( "VisibleNodes", renderUploader, "NodeIds" );

        renderFilter.getPromise( "RenderInputs" ).set( renderInputs );
        renderFilter.getPromise( "RenderStages" ).set( RENDER_ALL );

        redrawFilter.schedule( _renderExecutor );
        renderPipeline.schedule( _renderExecutor );
        uploadPipeline.schedule( _asyncUploadExecutor );
        sendHistogramFilter.schedule( _computeExecutor );
        histogramFilter.schedule( _computeExecutor );
        preRenderFilter.execute();
        renderFilter.execute();

        const tuyau::UniqueFutureMap futures( renderingSetGenerator.getPostconditions( ));
        statistics = futures.get< RenderStatistics >( "RenderStatistics" );
    }
Exemplo n.º 3
0
    void renderAsync(const RenderParams& renderParams,
                     PipeFilter& sendHistogramFilter, Renderer& renderer,
                     NodeAvailability& availability,
                     PipeFilter& redrawFilter) const
    {
        PipeFilterT<HistogramFilter> histogramFilter("HistogramFilter",
                                                     _histogramCache,
                                                     _dataCache, _dataSource);
        histogramFilter.getPromise("Frustum").set(
            renderParams.frameInfo.frustum);
        histogramFilter.connect("Histogram", sendHistogramFilter, "Histogram");
        histogramFilter.getPromise("RelativeViewport")
            .set(renderParams.viewport);
        histogramFilter.getPromise("DataSourceRange")
            .set(renderParams.dataSourceRange);
        sendHistogramFilter.getPromise("RelativeViewport")
            .set(renderParams.viewport);
        sendHistogramFilter.getPromise("Id").set(
            renderParams.frameInfo.frameId);

        Pipeline renderPipeline;
        Pipeline uploadPipeline;

        PipeFilterT<RenderFilter> renderFilter("RenderFilter", _dataSource,
                                               renderer);

        PipeFilter visibleSetGenerator =
            renderPipeline.add<VisibleSetGeneratorFilter>("VisibleSetGenerator",
                                                          _dataSource);
        setupVisibleGeneratorFilter(visibleSetGenerator, renderParams);

        PipeFilter renderingSetGenerator =
            renderPipeline.add<RenderingSetGeneratorFilter>(
                "RenderingSetGenerator", _textureCache);

        visibleSetGenerator.connect("VisibleNodes", renderingSetGenerator,
                                    "VisibleNodes");
        renderingSetGenerator.connect("CacheObjects", renderFilter,
                                      "CacheObjects");
        renderingSetGenerator.connect("CacheObjects", histogramFilter,
                                      "CacheObjects");
        renderingSetGenerator.connect("RenderingDone", redrawFilter,
                                      "RenderingDone");

        PipeFilter uploader =
            uploadPipeline.add<DataUploadFilter>("DataUploader", _dataCache,
                                                 _textureCache, _dataSource,
                                                 _texturePool);

        visibleSetGenerator.connect("VisibleNodes", uploader, "VisibleNodes");
        visibleSetGenerator.connect("Params", uploader, "Params");
        uploader.connect("CacheObjects", redrawFilter, "CacheObjects");

        setupRenderFilter(renderFilter, renderParams, RENDER_ALL);

        redrawFilter.schedule(_renderExecutor);
        renderPipeline.schedule(_renderExecutor);
        uploadPipeline.schedule(_uploadExecutor);
        sendHistogramFilter.schedule(_computeExecutor);
        histogramFilter.schedule(_computeExecutor);
        renderFilter.execute();

        const UniqueFutureMap futures(
            renderingSetGenerator.getPostconditions());
        availability = futures.get<NodeAvailability>("NodeAvailability");
    }
Exemplo n.º 4
0
    void renderSync( RenderStatistics& statistics,
                     Renderer& renderer,
                     const RenderInputs& renderInputs )
    {

        tuyau::PipeFilter sendHistogramFilter = renderInputs.filters.find( "SendHistogramFilter" )->second;
        tuyau::PipeFilter preRenderFilter = renderInputs.filters.find( "PreRenderFilter" )->second;
        tuyau::PipeFilterT< VisibleSetGeneratorFilter > visibleSetGenerator( "VisibleSetGenerator",
                                                                      renderInputs.dataSource );
        setupVisibleGeneratorFilter( visibleSetGenerator, renderInputs );
        visibleSetGenerator.connect( "VisibleNodes", preRenderFilter, "VisibleNodes" );
        preRenderFilter.getPromise( "Frustum" ).set( renderInputs.frameInfo.frustum );
        visibleSetGenerator.execute();
        preRenderFilter.execute();

        const tuyau::UniqueFutureMap portFutures( visibleSetGenerator.getPostconditions( ));
        NodeIds nodeIdsCopy = portFutures.get< NodeIds >( "VisibleNodes" );
        DistanceOperator distanceOp( renderInputs.dataSource, renderInputs.frameInfo.frustum );
        std::sort( nodeIdsCopy.begin(), nodeIdsCopy.end(), distanceOp );

        const uint32_t maxNodesPerPass =
                texturePool->getTextureMem() / texturePool->getSlotMemSize();

        const uint32_t numberOfPasses =
                std::ceil( (float)nodeIdsCopy.size() / (float)maxNodesPerPass );

        std::unique_ptr< boost::progress_display > showProgress;
        if( numberOfPasses > 1 )
        {
            LBINFO << "Multipass rendering. Number of passes: " << numberOfPasses << std::endl;
            showProgress.reset( new boost::progress_display( numberOfPasses ));
        }

        for( uint32_t i = 0; i < numberOfPasses; ++i )
        {
            uint32_t renderStages = RENDER_FRAME;

            if( i == 0 )
                renderStages |= RENDER_BEGIN;

            if( i == numberOfPasses - 1u )
                renderStages |= RENDER_END;

            const uint32_t startIndex = i * maxNodesPerPass;
            const uint32_t endIndex = ( i + 1 ) * maxNodesPerPass;
            const NodeIds nodesPerPass( nodeIdsCopy.begin() + startIndex,
                                        endIndex > nodeIdsCopy.size() ? nodeIdsCopy.end() :
                                        nodeIdsCopy.begin() + endIndex );

            createAndExecuteSyncPass( nodesPerPass,
                                      renderInputs,
                                      renderer,
                                      renderStages );

            if( numberOfPasses > 1 )
                ++(*showProgress);
        }

        tuyau::PipeFilterT< HistogramFilter > histogramFilter( "HistogramFilter",
                                                        *histogramCache,
                                                        *dataCache,
                                                        renderInputs.dataSource );
        histogramFilter.getPromise( "NodeIds" ).set( nodeIdsCopy );
        sendHistogramFilter.getPromise( "RelativeViewport" ).set( renderInputs.viewport );
        sendHistogramFilter.getPromise( "Id" ).set( renderInputs.frameInfo.frameId );
        histogramFilter.getPromise( "Frustum" ).set( renderInputs.frameInfo.frustum );
        histogramFilter.connect( "Histogram", sendHistogramFilter, "Histogram" );
        histogramFilter.getPromise( "RelativeViewport" ).set( renderInputs.viewport );
        histogramFilter.getPromise( "DataSourceRange" ).set( renderInputs.dataSourceRange );

        histogramFilter.schedule( _computeExecutor );
        sendHistogramFilter.schedule( _computeExecutor );

        const tuyau::UniqueFutureMap futures( visibleSetGenerator.getPostconditions( ));
        statistics.nAvailable = futures.get< NodeIds >( "VisibleNodes" ).size();
        statistics.nNotAvailable = 0;
        statistics.nRenderAvailable = statistics.nAvailable;
    }