aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guest/BUILD.gn13
-rw-r--r--guest/OpenglSystemCommon/HostConnection.cpp2
-rw-r--r--guest/mesa-gn/src/BUILD.gn6
-rw-r--r--guest/mesa-gn/src/c11/BUILD.gn33
-rw-r--r--guest/mesa-gn/src/util/BUILD.gn34
-rw-r--r--guest/mesa-gn/src/util/format/BUILD.gn183
-rwxr-xr-xguest/mesa-gn/src/util/format/gn_script_wrapper.sh29
-rw-r--r--guest/mesa-gn/src/vulkan/runtime/BUILD.gn8
-rw-r--r--guest/vulkan/gfxstream_vk_device.cpp10
-rw-r--r--guest/vulkan/gfxstream_vk_wsi_stub.cpp22
-rw-r--r--host/vulkan/VkCommonOperations.cpp2
11 files changed, 333 insertions, 9 deletions
diff --git a/guest/BUILD.gn b/guest/BUILD.gn
index 553cf636..15121745 100644
--- a/guest/BUILD.gn
+++ b/guest/BUILD.gn
@@ -73,7 +73,7 @@ config("gfxstream_vk_entrypoints_config") {
include_dirs = [ "$target_gen_dir" ]
}
-python_action("gfxstream_vk_entrypoints_header") {
+python_action("gfxstream_vk_entrypoints") {
public_configs = [ ":gfxstream_vk_entrypoints_config" ]
binary_label = ":vk_entrypoints_gen_bin"
@@ -81,7 +81,7 @@ python_action("gfxstream_vk_entrypoints_header") {
sources = [ mesa_vk_xml ]
h_file = "$target_gen_dir/gfxstream_vk_entrypoints.h"
- c_file = "$target_gen_dir/placeholder.c"
+ c_file = "$target_gen_dir/gfxstream_vk_entrypoints.c"
outputs = [
h_file,
@@ -130,7 +130,7 @@ source_set("goldfish_srcs") {
"//zircon/system/ulib/zxio",
]
- deps = [ ":gfxstream_vk_entrypoints_header" ]
+ deps = [ ":gfxstream_vk_entrypoints" ]
defines = [
"QEMU_PIPE_PATH=\"/loader-gpu-devices/class/goldfish-pipe/000\"",
@@ -142,11 +142,12 @@ loadable_module("libvulkan_gfxstream") {
configs += [ ":common_config" ]
deps = [
- ":gfxstream_vk_entrypoints_header",
+ ":gfxstream_vk_entrypoints",
"$mesa_build_root/src/vulkan/runtime",
]
sources = [
+ "$target_gen_dir/gfxstream_vk_entrypoints.c",
"GoldfishAddressSpace/AddressSpaceStream.cpp",
"GoldfishAddressSpace/VirtioGpuAddressSpaceStream.cpp",
"OpenglCodecCommon/ChecksumCalculator.cpp",
@@ -219,6 +220,8 @@ loadable_module("libvulkan_gfxstream") {
"qemupipe/qemu_pipe_guest.cpp",
"renderControl_enc/renderControl_enc.cpp",
"renderControl_enc/renderControl_enc.h",
+ "vulkan/gfxstream_vk_device.cpp",
+ "vulkan/gfxstream_vk_wsi_stub.cpp",
"vulkan_enc/CommandBufferStagingStream.cpp",
"vulkan_enc/CommandBufferStagingStream.h",
"vulkan_enc/DescriptorSetVirtualization.cpp",
@@ -237,6 +240,8 @@ loadable_module("libvulkan_gfxstream") {
"vulkan_enc/VulkanStreamGuest.h",
"vulkan_enc/func_table.cpp",
"vulkan_enc/func_table.h",
+ "vulkan_enc/gfxstream_vk_private.cpp",
+ "vulkan_enc/gfxstream_vk_private.h",
"vulkan_enc/goldfish_vk_counting_guest.cpp",
"vulkan_enc/goldfish_vk_counting_guest.h",
"vulkan_enc/goldfish_vk_deepcopy_guest.cpp",
diff --git a/guest/OpenglSystemCommon/HostConnection.cpp b/guest/OpenglSystemCommon/HostConnection.cpp
index b82cab0b..b56d9133 100644
--- a/guest/OpenglSystemCommon/HostConnection.cpp
+++ b/guest/OpenglSystemCommon/HostConnection.cpp
@@ -207,7 +207,7 @@ std::unique_ptr<HostConnection> HostConnection::connect(enum VirtGpuCapset capse
switch (connType) {
case HOST_CONNECTION_ADDRESS_SPACE: {
-#if defined(__ANDROID__) || defined(__Fuchsia__)
+#if defined(__ANDROID__)
auto stream = createGoldfishAddressSpaceStream(STREAM_BUFFER_SIZE, getGlobalHealthMonitor());
if (!stream) {
ALOGE("Failed to create AddressSpaceStream for host connection\n");
diff --git a/guest/mesa-gn/src/BUILD.gn b/guest/mesa-gn/src/BUILD.gn
index 54a8987a..2b7312e1 100644
--- a/guest/mesa-gn/src/BUILD.gn
+++ b/guest/mesa-gn/src/BUILD.gn
@@ -26,6 +26,11 @@ config("common_config") {
mesa_version = "unknown"
defines = [
+ # Pretend to be Linux for now so we avoid the need to
+ # introduce DETECT_OS_FUCHSIA into mesa.
+ "DETECT_OS_LINUX=1",
+ "DETECT_OS_UNIX=1",
+ "HAVE_PROGRAM_INVOCATION_NAME=1",
"HAVE_ENDIAN_H=1",
"HAVE_PTHREAD=1",
"HAVE_STRUCT_TIMESPEC=1",
@@ -73,5 +78,6 @@ config("common_config") {
"-Wno-int-in-bool-context",
"-Wno-conversion",
"-Wno-deprecated-anon-enum-enum-conversion",
+ "-Wno-strict-prototypes",
]
}
diff --git a/guest/mesa-gn/src/c11/BUILD.gn b/guest/mesa-gn/src/c11/BUILD.gn
new file mode 100644
index 00000000..d893c492
--- /dev/null
+++ b/guest/mesa-gn/src/c11/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright 2024 Google, LLC
+#
+# 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.
+
+import("../../mesa.gni")
+
+c11 = "$mesa_source_root/src/c11"
+
+config("c11_config") {
+ include_dirs = [ "$mesa_source_root/src" ]
+}
+
+mesa_source_set("c11") {
+ configs = [ ":c11_config" ]
+ sources = [ "$c11/impl/time.c" ]
+}
diff --git a/guest/mesa-gn/src/util/BUILD.gn b/guest/mesa-gn/src/util/BUILD.gn
index fb23e6cc..9c99c6e6 100644
--- a/guest/mesa-gn/src/util/BUILD.gn
+++ b/guest/mesa-gn/src/util/BUILD.gn
@@ -21,6 +21,8 @@
import("../../mesa.gni")
+util = "$mesa_source_root/src/util"
+
config("util_public_config") {
include_dirs = [
"$mesa_source_root/src",
@@ -28,7 +30,37 @@ config("util_public_config") {
]
}
-# Add source files here as necessary
mesa_source_set("util") {
public_configs = [ ":util_public_config" ]
+ public_deps = [
+ "$mesa_build_root/include:c_compat",
+ "format",
+ ]
+ deps = [ "$mesa_build_root/src/c11" ]
+ sources = [
+ "$util/hash_table.c",
+ "$util/hash_table.h",
+ "$util/log.c",
+ "$util/log.h",
+ "$util/os_misc.c",
+ "$util/os_misc.h",
+ "$util/os_time.c",
+ "$util/os_time.h",
+ "$util/ralloc.c",
+ "$util/ralloc.h",
+ "$util/simple_mtx.c",
+ "$util/simple_mtx.h",
+ "$util/sparse_array.c",
+ "$util/sparse_array.h",
+ "$util/u_call_once.c",
+ "$util/u_call_once.h",
+ "$util/u_debug.c",
+ "$util/u_debug.h",
+ "$util/u_dynarray.c",
+ "$util/u_dynarray.h",
+ "$util/u_printf.c",
+ "$util/u_printf.h",
+ "$util/u_process.c",
+ "$util/u_process.h",
+ ]
}
diff --git a/guest/mesa-gn/src/util/format/BUILD.gn b/guest/mesa-gn/src/util/format/BUILD.gn
new file mode 100644
index 00000000..7d38599e
--- /dev/null
+++ b/guest/mesa-gn/src/util/format/BUILD.gn
@@ -0,0 +1,183 @@
+# Copyright 2024 Google, LLC
+#
+# 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.
+
+import("//build/python/python_binary.gni")
+import("../../../mesa.gni")
+
+format = "$mesa_source_root/src/util/format"
+
+config("format_config") {
+ include_dirs = [
+ "$format",
+ "$target_gen_dir",
+ ]
+}
+
+mesa_source_set("format") {
+ public_configs = [ "..:util_public_config" ]
+ configs = [ ":format_config" ]
+ public_deps = [ "$mesa_build_root/include:c_compat" ]
+ sources = [
+ "$format/u_format.c",
+ "$format/u_format.h",
+ "$format/u_format_bptc.c",
+ "$format/u_format_etc.c",
+ "$format/u_format_fxt1.c",
+ "$format/u_format_latc.c",
+ "$format/u_format_other.c",
+ "$format/u_format_rgtc.c",
+ "$format/u_format_s3tc.c",
+ "$format/u_format_tests.c",
+ "$format/u_format_yuv.c",
+ "$format/u_format_zs.c",
+ "$target_gen_dir/u_format_table.c",
+ ]
+ deps = [
+ ":u_format_pack_h",
+ ":u_format_table_c",
+ ]
+}
+
+# Executes a python script and writes its output to a file.
+#
+# Example
+#
+# mesa_python_stdout_to_file_action("opcodes.c") {
+# output = "opcodes.c"
+# script = "opcodes_c.py"
+# sources = [ "opcodes_lib.py" ]
+# libraries = [ "//third_party/mako" ]
+# }
+#
+# Parameters
+#
+# script (required)
+# The .py file that will be interpreted.
+# Type: path
+#
+# output (required)
+# Path to the output file. Assumed to be relative to ${target_gen_dir}.
+# Type: path
+#
+# sources (optional)
+# Extra .py source files script imports.
+# Type: list(path)
+# Default: empty list
+#
+# libraries (optional)
+# Paths to python_libraries script imports.
+# Type: list(string)
+# Default: empty list
+#
+# args (optional)
+# Arguments to pass to the script.
+# Type: list(str)
+# Default: empty list
+#
+# deps
+# inputs
+# testonly
+# visibility
+template("mesa_python_stdout_to_file_action") {
+ assert(defined(invoker.script), "script is required")
+ assert(defined(invoker.output), "output is required")
+
+ py_binary_target = "${target_name}_py_binary"
+ python_binary(py_binary_target) {
+ forward_variables_from(invoker,
+ [
+ "sources",
+ "testonly",
+ ])
+ main_source = invoker.script
+ if (defined(invoker.libraries)) {
+ deps = invoker.libraries
+ }
+ visibility = [ ":*" ]
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ "inputs",
+ ])
+
+ script = "gn_script_wrapper.sh"
+ outputs = [ "${target_gen_dir}/${invoker.output}" ]
+
+ py_binary = get_target_outputs(":${py_binary_target}")
+ assert(py_binary == [ py_binary[0] ],
+ "${py_binary_target} should only have one output")
+ py_binary = py_binary[0]
+ sources = [ py_binary ]
+
+ # Ensure scripts can import other scripts in the same directory
+ # Note - I'm not sure why the ../ is necessary.
+ python_path =
+ rebase_path(get_label_info(target_name, "dir") + "/..", root_build_dir)
+
+ args = [
+ rebase_path(python_exe_src, root_build_dir),
+
+ # TODO(jayzhuang): remove this arg after migrating mesa_python_action.
+ python_path,
+ rebase_path(outputs[0], root_build_dir),
+ rebase_path(py_binary, root_build_dir),
+ ]
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+
+ deps = [ ":${py_binary_target}" ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+}
+
+u_format_csv = "$format/u_format.csv"
+
+mesa_python_stdout_to_file_action("u_format_pack_h") {
+ output = "u_format_pack.h"
+ script = "$format/u_format_table.py"
+ sources = [
+ "$format/u_format_pack.py",
+ "$format/u_format_parse.py",
+ ]
+ inputs = [ u_format_csv ]
+ args = [
+ rebase_path(u_format_csv, root_build_dir),
+ "--header",
+ ]
+}
+
+mesa_python_stdout_to_file_action("u_format_table_c") {
+ output = "u_format_table.c"
+ script = "$format/u_format_table.py"
+ sources = [
+ "$format/u_format_pack.py",
+ "$format/u_format_parse.py",
+ ]
+ inputs = [ u_format_csv ]
+ args = [ rebase_path(u_format_csv, root_build_dir) ]
+}
diff --git a/guest/mesa-gn/src/util/format/gn_script_wrapper.sh b/guest/mesa-gn/src/util/format/gn_script_wrapper.sh
new file mode 100755
index 00000000..0e4a98df
--- /dev/null
+++ b/guest/mesa-gn/src/util/format/gn_script_wrapper.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Executes the given python executable with PYTHONPATH set and captures
+# its output in a file. The first PYTHON_ARG should probably be the path
+# to a python script that writes something to stdout.
+# This is to let GN use the mesa python scripts that write headers to stdout,
+# and to support a custom PYTHONPATH.
+
+USAGE="Usage: $0 PYTHON_EXE PYTHONPATH OUT_FILE [PYTHON_ARGS...]"
+
+if [[ "$#" -lt "3" ]]; then
+ echo "${USAGE}" 1>&2;
+ exit 1
+fi
+
+PYTHON_EXE=${1}
+shift
+PYTHONPATH=${1}
+shift
+OUT=${1}
+shift
+
+# -S to decrease start-up time by not looking for site packages.
+env PYTHONPATH="${PYTHONPATH}" "${PYTHON_EXE}" -S "$@" > ${OUT}
+exit $?
diff --git a/guest/mesa-gn/src/vulkan/runtime/BUILD.gn b/guest/mesa-gn/src/vulkan/runtime/BUILD.gn
index 765fc578..b646e38e 100644
--- a/guest/mesa-gn/src/vulkan/runtime/BUILD.gn
+++ b/guest/mesa-gn/src/vulkan/runtime/BUILD.gn
@@ -55,8 +55,12 @@ mesa_source_set("runtime") {
]
sources = [
+ "$runtime/rmv/vk_rmv_common.c",
+ "$runtime/rmv/vk_rmv_common.h",
"$runtime/vk_buffer.c",
"$runtime/vk_buffer.h",
+ "$runtime/vk_buffer_view.c",
+ "$runtime/vk_buffer_view.h",
"$runtime/vk_cmd_copy.c",
"$runtime/vk_cmd_enqueue.c",
"$runtime/vk_command_buffer.c",
@@ -77,6 +81,8 @@ mesa_source_set("runtime") {
"$runtime/vk_descriptors.h",
"$runtime/vk_device.c",
"$runtime/vk_device.h",
+ "$runtime/vk_device_memory.c",
+ "$runtime/vk_device_memory.h",
"$runtime/vk_fence.c",
"$runtime/vk_fence.h",
"$runtime/vk_framebuffer.c",
@@ -93,6 +99,8 @@ mesa_source_set("runtime") {
"$runtime/vk_object.h",
"$runtime/vk_physical_device.c",
"$runtime/vk_physical_device.h",
+ "$runtime/vk_query_pool.c",
+ "$runtime/vk_query_pool.h",
"$runtime/vk_queue.c",
"$runtime/vk_queue.h",
"$runtime/vk_render_pass.c",
diff --git a/guest/vulkan/gfxstream_vk_device.cpp b/guest/vulkan/gfxstream_vk_device.cpp
index d095583c..d6df9053 100644
--- a/guest/vulkan/gfxstream_vk_device.cpp
+++ b/guest/vulkan/gfxstream_vk_device.cpp
@@ -38,7 +38,7 @@
namespace {
static bool instance_extension_table_initialized = false;
-static struct vk_instance_extension_table gfxstream_vk_instance_extensions_supported = {0};
+static struct vk_instance_extension_table gfxstream_vk_instance_extensions_supported = {};
// Provided by Mesa components only; never encoded/decoded through gfxstream
static const char* const kMesaOnlyInstanceExtension[] = {
@@ -172,15 +172,17 @@ static void get_device_extensions(VkPhysicalDevice physDevInternal,
static VkResult gfxstream_vk_physical_device_init(
struct gfxstream_vk_physical_device* physical_device, struct gfxstream_vk_instance* instance,
VkPhysicalDevice internal_object) {
- struct vk_device_extension_table supported_extensions = {0};
+ struct vk_device_extension_table supported_extensions = {};
get_device_extensions(internal_object, &supported_extensions);
struct vk_physical_device_dispatch_table dispatch_table;
memset(&dispatch_table, 0, sizeof(struct vk_physical_device_dispatch_table));
vk_physical_device_dispatch_table_from_entrypoints(
&dispatch_table, &gfxstream_vk_physical_device_entrypoints, false);
+#if !defined(__Fuchsia__)
vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
&wsi_physical_device_entrypoints, false);
+#endif
// Initialize the mesa object
VkResult result = vk_physical_device_init(&physical_device->vk, &instance->vk,
@@ -340,7 +342,9 @@ VkResult gfxstream_vk_CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
memset(&dispatch_table, 0, sizeof(struct vk_instance_dispatch_table));
vk_instance_dispatch_table_from_entrypoints(&dispatch_table, &gfxstream_vk_instance_entrypoints,
false);
+#if !defined(__Fuchsia__)
vk_instance_dispatch_table_from_entrypoints(&dispatch_table, &wsi_instance_entrypoints, false);
+#endif
result = vk_instance_init(&instance->vk, get_instance_extensions(), &dispatch_table,
pCreateInfo, pAllocator);
@@ -466,7 +470,9 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
memset(&dispatch_table, 0, sizeof(struct vk_device_dispatch_table));
vk_device_dispatch_table_from_entrypoints(&dispatch_table, &gfxstream_vk_device_entrypoints,
false);
+#if !defined(__Fuchsia__)
vk_device_dispatch_table_from_entrypoints(&dispatch_table, &wsi_device_entrypoints, false);
+#endif
result = vk_device_init(&gfxstream_device->vk, &gfxstream_physicalDevice->vk,
&dispatch_table, pCreateInfo, pMesaAllocator);
diff --git a/guest/vulkan/gfxstream_vk_wsi_stub.cpp b/guest/vulkan/gfxstream_vk_wsi_stub.cpp
new file mode 100644
index 00000000..f523a4c2
--- /dev/null
+++ b/guest/vulkan/gfxstream_vk_wsi_stub.cpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "gfxstream_vk_entrypoints.h"
+#include "gfxstream_vk_private.h"
+
+VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device) {
+ return VK_SUCCESS;
+}
+
+void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device) {}
diff --git a/host/vulkan/VkCommonOperations.cpp b/host/vulkan/VkCommonOperations.cpp
index 990ceaa1..1f5e56bb 100644
--- a/host/vulkan/VkCommonOperations.cpp
+++ b/host/vulkan/VkCommonOperations.cpp
@@ -1622,7 +1622,7 @@ bool importExternalMemoryDedicatedImage(VulkanDispatch* vk, VkDevice targetDevic
VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
&dedicatedInfo,
VK_EXT_MEMORY_HANDLE_TYPE_BIT,
- info->externalHandle,
+ dupExternalMemory(info->externalHandle),
};
#endif
VkMemoryAllocateInfo allocInfo = {