Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a2xx/fd2_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 "fd2_context.h"30#include "fd2_emit.h"31#include "fd2_resource.h"32#include "fd2_screen.h"33#include "fd2_util.h"3435static bool36fd2_screen_is_format_supported(struct pipe_screen *pscreen,37enum pipe_format format,38enum pipe_texture_target target,39unsigned sample_count,40unsigned storage_sample_count, unsigned usage)41{42unsigned retval = 0;4344if ((target >= PIPE_MAX_TEXTURE_TYPES) ||45(sample_count > 1)) { /* TODO add MSAA */46DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",47util_format_name(format), target, sample_count, usage);48return false;49}5051if (MAX2(1, sample_count) != MAX2(1, storage_sample_count))52return false;5354if ((usage & PIPE_BIND_RENDER_TARGET) &&55fd2_pipe2color(format) != (enum a2xx_colorformatx) ~0) {56retval |= PIPE_BIND_RENDER_TARGET;57}5859if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_VERTEX_BUFFER)) &&60!util_format_is_srgb(format) && !util_format_is_pure_integer(format) &&61fd2_pipe2surface(format).format != FMT_INVALID) {62retval |= usage & PIPE_BIND_VERTEX_BUFFER;63/* the only npot blocksize supported texture format is R32G32B32_FLOAT */64if (util_is_power_of_two_or_zero(util_format_get_blocksize(format)) ||65format == PIPE_FORMAT_R32G32B32_FLOAT)66retval |= usage & PIPE_BIND_SAMPLER_VIEW;67}6869if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |70PIPE_BIND_SCANOUT | PIPE_BIND_SHARED)) &&71(fd2_pipe2color(format) != (enum a2xx_colorformatx) ~0)) {72retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET |73PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);74}7576if ((usage & PIPE_BIND_DEPTH_STENCIL) &&77(fd_pipe2depth(format) != (enum adreno_rb_depth_format) ~0)) {78retval |= PIPE_BIND_DEPTH_STENCIL;79}8081if ((usage & PIPE_BIND_INDEX_BUFFER) &&82(fd_pipe2index(format) != (enum pc_di_index_size) ~0)) {83retval |= PIPE_BIND_INDEX_BUFFER;84}8586if (retval != usage) {87DBG("not supported: format=%s, target=%d, sample_count=%d, "88"usage=%x, retval=%x",89util_format_name(format), target, sample_count, usage, retval);90}9192return retval == usage;93}9495void96fd2_screen_init(struct pipe_screen *pscreen)97{98struct fd_screen *screen = fd_screen(pscreen);99100screen->max_rts = 1;101pscreen->context_create = fd2_context_create;102pscreen->is_format_supported = fd2_screen_is_format_supported;103104screen->setup_slices = fd2_setup_slices;105if (FD_DBG(TTILE))106screen->tile_mode = fd2_tile_mode;107108fd2_emit_init_screen(pscreen);109}110111112