Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a4xx/fd4_screen.c
4574 views
/*1* Copyright (C) 2014 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 "fd4_context.h"30#include "fd4_emit.h"31#include "fd4_format.h"32#include "fd4_resource.h"33#include "fd4_screen.h"3435#include "ir3/ir3_compiler.h"3637static bool38fd4_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(fd4_pipe2vtx(format) != VFMT4_NONE)) {58retval |= PIPE_BIND_VERTEX_BUFFER;59}6061if ((usage & PIPE_BIND_SAMPLER_VIEW) &&62(fd4_pipe2tex(format) != TFMT4_NONE) &&63(target == PIPE_BUFFER || util_format_get_blocksize(format) != 12)) {64retval |= PIPE_BIND_SAMPLER_VIEW;65}6667if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |68PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) &&69(fd4_pipe2color(format) != RB4_NONE) &&70(fd4_pipe2tex(format) != TFMT4_NONE)) {71retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |72PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);73}7475/* For ARB_framebuffer_no_attachments: */76if ((usage & PIPE_BIND_RENDER_TARGET) && (format == PIPE_FORMAT_NONE)) {77retval |= usage & PIPE_BIND_RENDER_TARGET;78}7980if ((usage & PIPE_BIND_DEPTH_STENCIL) &&81(fd4_pipe2depth(format) != (enum a4xx_depth_format) ~0) &&82(fd4_pipe2tex(format) != TFMT4_NONE)) {83retval |= PIPE_BIND_DEPTH_STENCIL;84}8586if ((usage & PIPE_BIND_INDEX_BUFFER) &&87(fd_pipe2index(format) != (enum pc_di_index_size) ~0)) {88retval |= PIPE_BIND_INDEX_BUFFER;89}9091if (retval != usage) {92DBG("not supported: format=%s, target=%d, sample_count=%d, "93"usage=%x, retval=%x",94util_format_name(format), target, sample_count, usage, retval);95}9697return retval == usage;98}99100void101fd4_screen_init(struct pipe_screen *pscreen)102{103struct fd_screen *screen = fd_screen(pscreen);104screen->max_rts = A4XX_MAX_RENDER_TARGETS;105screen->setup_slices = fd4_setup_slices;106pscreen->context_create = fd4_context_create;107pscreen->is_format_supported = fd4_screen_is_format_supported;108fd4_emit_init_screen(pscreen);109ir3_screen_init(pscreen);110}111112113