1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci * 23bf215546Sopenharmony_ci * Authors: 24bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 25bf215546Sopenharmony_ci */ 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "freedreno_query_acc.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "fd5_blend.h" 30bf215546Sopenharmony_ci#include "fd5_blitter.h" 31bf215546Sopenharmony_ci#include "fd5_compute.h" 32bf215546Sopenharmony_ci#include "fd5_context.h" 33bf215546Sopenharmony_ci#include "fd5_draw.h" 34bf215546Sopenharmony_ci#include "fd5_emit.h" 35bf215546Sopenharmony_ci#include "fd5_gmem.h" 36bf215546Sopenharmony_ci#include "fd5_program.h" 37bf215546Sopenharmony_ci#include "fd5_query.h" 38bf215546Sopenharmony_ci#include "fd5_rasterizer.h" 39bf215546Sopenharmony_ci#include "fd5_texture.h" 40bf215546Sopenharmony_ci#include "fd5_zsa.h" 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_cistatic void 43bf215546Sopenharmony_cifd5_context_destroy(struct pipe_context *pctx) in_dt 44bf215546Sopenharmony_ci{ 45bf215546Sopenharmony_ci struct fd5_context *fd5_ctx = fd5_context(fd_context(pctx)); 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci u_upload_destroy(fd5_ctx->border_color_uploader); 48bf215546Sopenharmony_ci pipe_resource_reference(&fd5_ctx->border_color_buf, NULL); 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci fd_context_destroy(pctx); 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci fd_bo_del(fd5_ctx->vsc_size_mem); 53bf215546Sopenharmony_ci fd_bo_del(fd5_ctx->blit_mem); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci fd_context_cleanup_common_vbos(&fd5_ctx->base); 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci free(fd5_ctx); 58bf215546Sopenharmony_ci} 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_cistruct pipe_context * 61bf215546Sopenharmony_cifd5_context_create(struct pipe_screen *pscreen, void *priv, 62bf215546Sopenharmony_ci unsigned flags) disable_thread_safety_analysis 63bf215546Sopenharmony_ci{ 64bf215546Sopenharmony_ci struct fd_screen *screen = fd_screen(pscreen); 65bf215546Sopenharmony_ci struct fd5_context *fd5_ctx = CALLOC_STRUCT(fd5_context); 66bf215546Sopenharmony_ci struct pipe_context *pctx; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci if (!fd5_ctx) 69bf215546Sopenharmony_ci return NULL; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci pctx = &fd5_ctx->base.base; 72bf215546Sopenharmony_ci pctx->screen = pscreen; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci fd5_ctx->base.flags = flags; 75bf215546Sopenharmony_ci fd5_ctx->base.dev = fd_device_ref(screen->dev); 76bf215546Sopenharmony_ci fd5_ctx->base.screen = fd_screen(pscreen); 77bf215546Sopenharmony_ci fd5_ctx->base.last.key = &fd5_ctx->last_key; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci pctx->destroy = fd5_context_destroy; 80bf215546Sopenharmony_ci pctx->create_blend_state = fd5_blend_state_create; 81bf215546Sopenharmony_ci pctx->create_rasterizer_state = fd5_rasterizer_state_create; 82bf215546Sopenharmony_ci pctx->create_depth_stencil_alpha_state = fd5_zsa_state_create; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci fd5_draw_init(pctx); 85bf215546Sopenharmony_ci fd5_compute_init(pctx); 86bf215546Sopenharmony_ci fd5_gmem_init(pctx); 87bf215546Sopenharmony_ci fd5_texture_init(pctx); 88bf215546Sopenharmony_ci fd5_prog_init(pctx); 89bf215546Sopenharmony_ci fd5_emit_init(pctx); 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci if (!FD_DBG(NOBLIT)) 92bf215546Sopenharmony_ci fd5_ctx->base.blit = fd5_blitter_blit; 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci pctx = fd_context_init(&fd5_ctx->base, pscreen, priv, flags); 95bf215546Sopenharmony_ci if (!pctx) 96bf215546Sopenharmony_ci return NULL; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci util_blitter_set_texture_multisample(fd5_ctx->base.blitter, true); 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci fd5_ctx->vsc_size_mem = 101bf215546Sopenharmony_ci fd_bo_new(screen->dev, 0x1000, 0, "vsc_size"); 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci fd5_ctx->blit_mem = 104bf215546Sopenharmony_ci fd_bo_new(screen->dev, 0x1000, 0, "blit"); 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_ci fd_context_setup_common_vbos(&fd5_ctx->base); 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci fd5_query_context_init(pctx); 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_ci fd5_ctx->border_color_uploader = 111bf215546Sopenharmony_ci u_upload_create(pctx, 4096, 0, PIPE_USAGE_STREAM, 0); 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ci return pctx; 114bf215546Sopenharmony_ci} 115