From 0ad6bacb730a36bd2234e4f4be44220f9e241d05 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 2 May 2021 12:40:39 -0400 Subject: [PATCH] asahi: Add vertex formats table This all gets lowers anyway so it's not entirely clear if this is the best approach, but these map formats that have native device_load encodings. (and don't need shader unpack code) Signed-off-by: Alyssa Rosenzweig Acked-by: Jason Ekstrand Acked-by: Bas Nieuwenhuizen Part-of: --- src/asahi/lib/agx_formats.c | 60 +++++++++++++++++++++++++++++++++++++ src/asahi/lib/agx_formats.h | 33 ++++++++++++++++++++ src/asahi/lib/meson.build | 3 +- 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/asahi/lib/agx_formats.c create mode 100644 src/asahi/lib/agx_formats.h diff --git a/src/asahi/lib/agx_formats.c b/src/asahi/lib/agx_formats.c new file mode 100644 index 00000000000..270448dad6c --- /dev/null +++ b/src/asahi/lib/agx_formats.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2021 Alyssa Rosenzweig + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "agx_formats.h" + +const enum agx_format +agx_vertex_format[PIPE_FORMAT_COUNT] = { + [PIPE_FORMAT_R32_FLOAT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32_SINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32_UINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32_FLOAT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32_SINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32_UINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32_FLOAT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32_UINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32_SINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32A32_FLOAT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32A32_UINT] = AGX_FORMAT_I32, + [PIPE_FORMAT_R32G32B32A32_SINT] = AGX_FORMAT_I32, + + [PIPE_FORMAT_R8_UNORM] = AGX_FORMAT_U8NORM, + [PIPE_FORMAT_R8G8_UNORM] = AGX_FORMAT_U8NORM, + [PIPE_FORMAT_R8G8B8_UNORM] = AGX_FORMAT_U8NORM, + [PIPE_FORMAT_R8G8B8A8_UNORM] = AGX_FORMAT_U8NORM, + + [PIPE_FORMAT_R8_SNORM] = AGX_FORMAT_S8NORM, + [PIPE_FORMAT_R8G8_SNORM] = AGX_FORMAT_S8NORM, + [PIPE_FORMAT_R8G8B8_SNORM] = AGX_FORMAT_S8NORM, + [PIPE_FORMAT_R8G8B8A8_SNORM] = AGX_FORMAT_S8NORM, + + [PIPE_FORMAT_R16_UNORM] = AGX_FORMAT_U16NORM, + [PIPE_FORMAT_R16G16_UNORM] = AGX_FORMAT_U16NORM, + [PIPE_FORMAT_R16G16B16_UNORM] = AGX_FORMAT_U16NORM, + [PIPE_FORMAT_R16G16B16A16_UNORM] = AGX_FORMAT_U16NORM, + + [PIPE_FORMAT_R16_SNORM] = AGX_FORMAT_S16NORM, + [PIPE_FORMAT_R16G16_SNORM] = AGX_FORMAT_S16NORM, + [PIPE_FORMAT_R16G16B16_SNORM] = AGX_FORMAT_S16NORM, + [PIPE_FORMAT_R16G16B16A16_SNORM] = AGX_FORMAT_S16NORM, +}; diff --git a/src/asahi/lib/agx_formats.h b/src/asahi/lib/agx_formats.h new file mode 100644 index 00000000000..7ce52b91b3d --- /dev/null +++ b/src/asahi/lib/agx_formats.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 Alyssa Rosenzweig + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef __AGX_FORMATS_H_ +#define __AGX_FORMATS_H_ + +#include "util/format/u_format.h" +#include "asahi/compiler/agx_compile.h" + +extern const enum agx_format agx_vertex_format[PIPE_FORMAT_COUNT]; + +#endif diff --git a/src/asahi/lib/meson.build b/src/asahi/lib/meson.build index 15b151dcbe6..5860526b4b9 100644 --- a/src/asahi/lib/meson.build +++ b/src/asahi/lib/meson.build @@ -23,6 +23,7 @@ dep_iokit = dependency('IOKit', required : false) libasahi_lib_files = files( 'agx_device.c', + 'agx_formats.c', 'pool.c', 'tiling.c', ) @@ -47,7 +48,7 @@ idep_agx_pack = declare_dependency( libasahi_lib = static_library( 'asahi_lib', [libasahi_lib_files, agx_pack], - include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_asahi], c_args : [no_override_init_args], gnu_symbol_visibility : 'hidden', dependencies: [dep_libdrm, idep_nir, dep_iokit],