1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2013 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 "pipe/p_screen.h" 28bf215546Sopenharmony_ci#include "util/format/u_format.h" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "fd3_context.h" 31bf215546Sopenharmony_ci#include "fd3_emit.h" 32bf215546Sopenharmony_ci#include "fd3_format.h" 33bf215546Sopenharmony_ci#include "fd3_resource.h" 34bf215546Sopenharmony_ci#include "fd3_screen.h" 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#include "ir3/ir3_compiler.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_cistatic bool 39bf215546Sopenharmony_cifd3_screen_is_format_supported(struct pipe_screen *pscreen, 40bf215546Sopenharmony_ci enum pipe_format format, 41bf215546Sopenharmony_ci enum pipe_texture_target target, 42bf215546Sopenharmony_ci unsigned sample_count, 43bf215546Sopenharmony_ci unsigned storage_sample_count, unsigned usage) 44bf215546Sopenharmony_ci{ 45bf215546Sopenharmony_ci unsigned retval = 0; 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci if ((target >= PIPE_MAX_TEXTURE_TYPES) || 48bf215546Sopenharmony_ci (sample_count > 1)) { /* TODO add MSAA */ 49bf215546Sopenharmony_ci DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x", 50bf215546Sopenharmony_ci util_format_name(format), target, sample_count, usage); 51bf215546Sopenharmony_ci return false; 52bf215546Sopenharmony_ci } 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci if (MAX2(1, sample_count) != MAX2(1, storage_sample_count)) 55bf215546Sopenharmony_ci return false; 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci if ((usage & PIPE_BIND_VERTEX_BUFFER) && 58bf215546Sopenharmony_ci (fd3_pipe2vtx(format) != VFMT_NONE)) { 59bf215546Sopenharmony_ci retval |= PIPE_BIND_VERTEX_BUFFER; 60bf215546Sopenharmony_ci } 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci if ((usage & PIPE_BIND_SAMPLER_VIEW) && 63bf215546Sopenharmony_ci (fd3_pipe2tex(format) != TFMT_NONE)) { 64bf215546Sopenharmony_ci retval |= PIPE_BIND_SAMPLER_VIEW; 65bf215546Sopenharmony_ci } 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | 68bf215546Sopenharmony_ci PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_BLENDABLE)) && 69bf215546Sopenharmony_ci (fd3_pipe2color(format) != RB_NONE) && 70bf215546Sopenharmony_ci (fd3_pipe2tex(format) != TFMT_NONE)) { 71bf215546Sopenharmony_ci retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | 72bf215546Sopenharmony_ci PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); 73bf215546Sopenharmony_ci if (!util_format_is_pure_integer(format)) 74bf215546Sopenharmony_ci retval |= usage & PIPE_BIND_BLENDABLE; 75bf215546Sopenharmony_ci } 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_ci if ((usage & PIPE_BIND_DEPTH_STENCIL) && 78bf215546Sopenharmony_ci (fd_pipe2depth(format) != (enum adreno_rb_depth_format) ~0) && 79bf215546Sopenharmony_ci (fd3_pipe2tex(format) != TFMT_NONE)) { 80bf215546Sopenharmony_ci retval |= PIPE_BIND_DEPTH_STENCIL; 81bf215546Sopenharmony_ci } 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci if ((usage & PIPE_BIND_INDEX_BUFFER) && 84bf215546Sopenharmony_ci (fd_pipe2index(format) != (enum pc_di_index_size) ~0)) { 85bf215546Sopenharmony_ci retval |= PIPE_BIND_INDEX_BUFFER; 86bf215546Sopenharmony_ci } 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci if (retval != usage) { 89bf215546Sopenharmony_ci DBG("not supported: format=%s, target=%d, sample_count=%d, " 90bf215546Sopenharmony_ci "usage=%x, retval=%x", 91bf215546Sopenharmony_ci util_format_name(format), target, sample_count, usage, retval); 92bf215546Sopenharmony_ci } 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci return retval == usage; 95bf215546Sopenharmony_ci} 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci/* clang-format off */ 98bf215546Sopenharmony_cistatic const enum pc_di_primtype primtypes[] = { 99bf215546Sopenharmony_ci [PIPE_PRIM_POINTS] = DI_PT_POINTLIST, 100bf215546Sopenharmony_ci [PIPE_PRIM_LINES] = DI_PT_LINELIST, 101bf215546Sopenharmony_ci [PIPE_PRIM_LINE_STRIP] = DI_PT_LINESTRIP, 102bf215546Sopenharmony_ci [PIPE_PRIM_LINE_LOOP] = DI_PT_LINELOOP, 103bf215546Sopenharmony_ci [PIPE_PRIM_TRIANGLES] = DI_PT_TRILIST, 104bf215546Sopenharmony_ci [PIPE_PRIM_TRIANGLE_STRIP] = DI_PT_TRISTRIP, 105bf215546Sopenharmony_ci [PIPE_PRIM_TRIANGLE_FAN] = DI_PT_TRIFAN, 106bf215546Sopenharmony_ci [PIPE_PRIM_MAX] = DI_PT_RECTLIST, /* internal clear blits */ 107bf215546Sopenharmony_ci}; 108bf215546Sopenharmony_ci/* clang-format on */ 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_civoid 111bf215546Sopenharmony_cifd3_screen_init(struct pipe_screen *pscreen) 112bf215546Sopenharmony_ci{ 113bf215546Sopenharmony_ci struct fd_screen *screen = fd_screen(pscreen); 114bf215546Sopenharmony_ci screen->max_rts = A3XX_MAX_RENDER_TARGETS; 115bf215546Sopenharmony_ci pscreen->context_create = fd3_context_create; 116bf215546Sopenharmony_ci pscreen->is_format_supported = fd3_screen_is_format_supported; 117bf215546Sopenharmony_ci fd3_emit_init_screen(pscreen); 118bf215546Sopenharmony_ci ir3_screen_init(pscreen); 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci screen->setup_slices = fd3_setup_slices; 121bf215546Sopenharmony_ci if (FD_DBG(TTILE)) 122bf215546Sopenharmony_ci screen->tile_mode = fd3_tile_mode; 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ci screen->primtypes = primtypes; 125bf215546Sopenharmony_ci} 126