Example #1
0
struct pipe_context *
vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
{
    struct vc4_screen *screen = vc4_screen(pscreen);
    struct vc4_context *vc4;

    /* Prevent dumping of the shaders built during context setup. */
    uint32_t saved_shaderdb_flag = vc4_debug & VC4_DEBUG_SHADERDB;
    vc4_debug &= ~VC4_DEBUG_SHADERDB;

    vc4 = rzalloc(NULL, struct vc4_context);
    if (!vc4)
        return NULL;
    struct pipe_context *pctx = &vc4->base;

    vc4->screen = screen;

    pctx->screen = pscreen;
    pctx->priv = priv;
    pctx->destroy = vc4_context_destroy;
    pctx->flush = vc4_pipe_flush;
    pctx->invalidate_resource = vc4_invalidate_resource;

    vc4_draw_init(pctx);
    vc4_state_init(pctx);
    vc4_program_init(pctx);
    vc4_query_init(pctx);
    vc4_resource_context_init(pctx);

    vc4_job_init(vc4);

    vc4->fd = screen->fd;

    util_slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
                     16, UTIL_SLAB_SINGLETHREADED);
    vc4->blitter = util_blitter_create(pctx);
    if (!vc4->blitter)
        goto fail;

    vc4->primconvert = util_primconvert_create(pctx,
                       (1 << PIPE_PRIM_QUADS) - 1);
    if (!vc4->primconvert)
        goto fail;

    vc4->uploader = u_upload_create(pctx, 16 * 1024,
                                    PIPE_BIND_INDEX_BUFFER,
                                    PIPE_USAGE_STREAM);

    vc4_debug |= saved_shaderdb_flag;

    vc4->sample_mask = (1 << VC4_MAX_SAMPLES) - 1;

    return &vc4->base;

fail:
    pctx->destroy(pctx);
    return NULL;
}
Example #2
0
struct pipe_context *
vc4_context_create(struct pipe_screen *pscreen, void *priv)
{
        struct vc4_screen *screen = vc4_screen(pscreen);
        struct vc4_context *vc4;

        /* Prevent dumping of the shaders built during context setup. */
        uint32_t saved_shaderdb_flag = vc4_debug & VC4_DEBUG_SHADERDB;
        vc4_debug &= ~VC4_DEBUG_SHADERDB;

        vc4 = rzalloc(NULL, struct vc4_context);
        if (vc4 == NULL)
                return NULL;
        struct pipe_context *pctx = &vc4->base;

        vc4->screen = screen;

        pctx->screen = pscreen;
        pctx->priv = priv;
        pctx->destroy = vc4_context_destroy;
        pctx->flush = vc4_pipe_flush;

        vc4_draw_init(pctx);
        vc4_state_init(pctx);
        vc4_program_init(pctx);
        vc4_query_init(pctx);
        vc4_resource_context_init(pctx);

        vc4_init_cl(vc4, &vc4->bcl);
        vc4_init_cl(vc4, &vc4->rcl);
        vc4_init_cl(vc4, &vc4->shader_rec);
        vc4_init_cl(vc4, &vc4->bo_handles);

        vc4->dirty = ~0;
        vc4->fd = screen->fd;

        util_slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
                         16, UTIL_SLAB_SINGLETHREADED);
        vc4->blitter = util_blitter_create(pctx);
        if (!vc4->blitter)
                goto fail;

        vc4->primconvert = util_primconvert_create(pctx,
                                                   (1 << PIPE_PRIM_QUADS) - 1);
        if (!vc4->primconvert)
                goto fail;

        vc4_debug |= saved_shaderdb_flag;

        return &vc4->base;

fail:
        pctx->destroy(pctx);
        return NULL;
}