Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a3xx/fd3_screen.c
4574 views
/*1* Copyright (C) 2013 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 "pipe/p_screen.h"27#include "util/format/u_format.h"2829#include "fd3_context.h"30#include "fd3_emit.h"31#include "fd3_format.h"32#include "fd3_resource.h"33#include "fd3_screen.h"3435#include "ir3/ir3_compiler.h"3637static bool38fd3_screen_is_format_supported(struct pipe_screen *pscreen,39enum pipe_format format,40enum pipe_texture_target target,41unsigned sample_count,42unsigned storage_sample_count, unsigned usage)43{44unsigned retval = 0;4546if ((target >= PIPE_MAX_TEXTURE_TYPES) ||47(sample_count > 1)) { /* TODO add MSAA */48DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",49util_format_name(format), target, sample_count, usage);50return false;51}5253if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))54return false;5556if ((usage & PIPE_BIND_VERTEX_BUFFER) &&57(fd3_pipe2vtx(format) != VFMT_NONE)) {58retval |= PIPE_BIND_VERTEX_BUFFER;59}6061if ((usage & PIPE_BIND_SAMPLER_VIEW) &&62(fd3_pipe2tex(format) != TFMT_NONE)) {63retval |= PIPE_BIND_SAMPLER_VIEW;64}6566if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |67PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_BLENDABLE)) &&68(fd3_pipe2color(format) != RB_NONE) &&69(fd3_pipe2tex(format) != TFMT_NONE)) {70retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |71PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);72if (!util_format_is_pure_integer(format))73retval |= usage & PIPE_BIND_BLENDABLE;74}7576if ((usage & PIPE_BIND_DEPTH_STENCIL) &&77(fd_pipe2depth(format) != (enum adreno_rb_depth_format) ~0) &&78(fd3_pipe2tex(format) != TFMT_NONE)) {79retval |= PIPE_BIND_DEPTH_STENCIL;80}8182if ((usage & PIPE_BIND_INDEX_BUFFER) &&83(fd_pipe2index(format) != (enum pc_di_index_size) ~0)) {84retval |= PIPE_BIND_INDEX_BUFFER;85}8687if (retval != usage) {88DBG("not supported: format=%s, target=%d, sample_count=%d, "89"usage=%x, retval=%x",90util_format_name(format), target, sample_count, usage, retval);91}9293return retval == usage;94}9596void97fd3_screen_init(struct pipe_screen *pscreen)98{99struct fd_screen *screen = fd_screen(pscreen);100screen->max_rts = A3XX_MAX_RENDER_TARGETS;101pscreen->context_create = fd3_context_create;102pscreen->is_format_supported = fd3_screen_is_format_supported;103fd3_emit_init_screen(pscreen);104ir3_screen_init(pscreen);105106screen->setup_slices = fd3_setup_slices;107if (FD_DBG(TTILE))108screen->tile_mode = fd3_tile_mode;109}110111112