asahi: Add vertex formats table
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 2 May 2021 16:40:39 +0000 (12:40 -0400)
committerAlyssa Rosenzweig <none>
Sun, 2 May 2021 21:41:22 +0000 (17:41 -0400)
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 <alyssa@rosenzweig.io>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10582>

src/asahi/lib/agx_formats.c [new file with mode: 0644]
src/asahi/lib/agx_formats.h [new file with mode: 0644]
src/asahi/lib/meson.build

diff --git a/src/asahi/lib/agx_formats.c b/src/asahi/lib/agx_formats.c
new file mode 100644 (file)
index 0000000..270448d
--- /dev/null
@@ -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 (file)
index 0000000..7ce52b9
--- /dev/null
@@ -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
index 15b151d..5860526 100644 (file)
@@ -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],