Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a5xx/fd5_context.c
4574 views
/*1* Copyright (C) 2016 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#include "freedreno_query_acc.h"2728#include "fd5_blend.h"29#include "fd5_blitter.h"30#include "fd5_compute.h"31#include "fd5_context.h"32#include "fd5_draw.h"33#include "fd5_emit.h"34#include "fd5_gmem.h"35#include "fd5_program.h"36#include "fd5_query.h"37#include "fd5_rasterizer.h"38#include "fd5_texture.h"39#include "fd5_zsa.h"4041static void42fd5_context_destroy(struct pipe_context *pctx) in_dt43{44struct fd5_context *fd5_ctx = fd5_context(fd_context(pctx));4546u_upload_destroy(fd5_ctx->border_color_uploader);47pipe_resource_reference(&fd5_ctx->border_color_buf, NULL);4849fd_context_destroy(pctx);5051fd_bo_del(fd5_ctx->vsc_size_mem);52fd_bo_del(fd5_ctx->blit_mem);5354fd_context_cleanup_common_vbos(&fd5_ctx->base);5556free(fd5_ctx);57}5859/* clang-format off */60static const uint8_t primtypes[] = {61[PIPE_PRIM_POINTS] = DI_PT_POINTLIST,62[PIPE_PRIM_LINES] = DI_PT_LINELIST,63[PIPE_PRIM_LINE_STRIP] = DI_PT_LINESTRIP,64[PIPE_PRIM_LINE_LOOP] = DI_PT_LINELOOP,65[PIPE_PRIM_TRIANGLES] = DI_PT_TRILIST,66[PIPE_PRIM_TRIANGLE_STRIP] = DI_PT_TRISTRIP,67[PIPE_PRIM_TRIANGLE_FAN] = DI_PT_TRIFAN,68[PIPE_PRIM_MAX] = DI_PT_RECTLIST, /* internal clear blits */69};70/* clang-format on */7172struct pipe_context *73fd5_context_create(struct pipe_screen *pscreen, void *priv,74unsigned flags) disable_thread_safety_analysis75{76struct fd_screen *screen = fd_screen(pscreen);77struct fd5_context *fd5_ctx = CALLOC_STRUCT(fd5_context);78struct pipe_context *pctx;7980if (!fd5_ctx)81return NULL;8283pctx = &fd5_ctx->base.base;84pctx->screen = pscreen;8586fd5_ctx->base.dev = fd_device_ref(screen->dev);87fd5_ctx->base.screen = fd_screen(pscreen);88fd5_ctx->base.last.key = &fd5_ctx->last_key;8990pctx->destroy = fd5_context_destroy;91pctx->create_blend_state = fd5_blend_state_create;92pctx->create_rasterizer_state = fd5_rasterizer_state_create;93pctx->create_depth_stencil_alpha_state = fd5_zsa_state_create;9495fd5_draw_init(pctx);96fd5_compute_init(pctx);97fd5_gmem_init(pctx);98fd5_texture_init(pctx);99fd5_prog_init(pctx);100fd5_emit_init(pctx);101102if (!FD_DBG(NOBLIT))103fd5_ctx->base.blit = fd5_blitter_blit;104105pctx = fd_context_init(&fd5_ctx->base, pscreen, primtypes, priv, flags);106if (!pctx)107return NULL;108109util_blitter_set_texture_multisample(fd5_ctx->base.blitter, true);110111fd5_ctx->vsc_size_mem =112fd_bo_new(screen->dev, 0x1000, 0, "vsc_size");113114fd5_ctx->blit_mem =115fd_bo_new(screen->dev, 0x1000, 0, "blit");116117fd_context_setup_common_vbos(&fd5_ctx->base);118119fd5_query_context_init(pctx);120121fd5_ctx->border_color_uploader =122u_upload_create(pctx, 4096, 0, PIPE_USAGE_STREAM, 0);123124return pctx;125}126127128