intel: split driver/device UUID generators
We need Vulkan and GL to produce the same UUIDs. So move the generator from ANV to a common code that can be shared by ANV and Iris driver. v2: fix android build (Tapani) Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Rohan Garg <rohan.garg@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7025>
This commit is contained in:
parent
713386af20
commit
e9a766a8c0
|
@ -36,7 +36,8 @@ LOCAL_C_INCLUDES := \
|
|||
$(MESA_TOP)/src/gallium/include \
|
||||
$(MESA_TOP)/src/gallium/auxiliary \
|
||||
$(MESA_TOP)/src/mapi \
|
||||
$(MESA_TOP)/src/mesa
|
||||
$(MESA_TOP)/src/mesa \
|
||||
$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_git_sha1,,)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libz liblog
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ COMMON_FILES = \
|
|||
common/gen_l3_config.c \
|
||||
common/gen_l3_config.h \
|
||||
common/gen_urb_config.c \
|
||||
common/gen_sample_positions.h
|
||||
common/gen_sample_positions.h \
|
||||
common/gen_uuid.c \
|
||||
common/gen_uuid.h
|
||||
|
||||
COMPILER_FILES = \
|
||||
compiler/brw_cfg.cpp \
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright © 2020 Intel Corporation
|
||||
*
|
||||
* 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 "gen_uuid.h"
|
||||
#include "util/build_id.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
|
||||
void
|
||||
gen_uuid_compute_device_id(uint8_t *uuid,
|
||||
const struct gen_device_info *devinfo,
|
||||
const struct isl_device *isldev,
|
||||
size_t size)
|
||||
{
|
||||
struct mesa_sha1 sha1_ctx;
|
||||
uint8_t sha1[20];
|
||||
|
||||
assert(size <= sizeof(sha1));
|
||||
|
||||
/* The device UUID uniquely identifies the given device within the machine.
|
||||
* Since we never have more than one device, this doesn't need to be a real
|
||||
* UUID. However, on the off-chance that someone tries to use this to
|
||||
* cache pre-tiled images or something of the like, we use the PCI ID and
|
||||
* some bits of ISL info to ensure that this is safe.
|
||||
*/
|
||||
_mesa_sha1_init(&sha1_ctx);
|
||||
_mesa_sha1_update(&sha1_ctx, &devinfo->chipset_id,
|
||||
sizeof(devinfo->chipset_id));
|
||||
_mesa_sha1_update(&sha1_ctx, &isldev->has_bit6_swizzling,
|
||||
sizeof(isldev->has_bit6_swizzling));
|
||||
_mesa_sha1_final(&sha1_ctx, sha1);
|
||||
memcpy(uuid, sha1, size);
|
||||
}
|
||||
|
||||
void
|
||||
gen_uuid_compute_driver_id(uint8_t *uuid,
|
||||
const struct gen_device_info *devinfo,
|
||||
size_t size)
|
||||
{
|
||||
const struct build_id_note *note =
|
||||
build_id_find_nhdr_for_addr(gen_uuid_compute_driver_id);
|
||||
assert(note && "Failed to find build-id");
|
||||
|
||||
unsigned build_id_len = build_id_length(note);
|
||||
assert(build_id_len >= size && "build-id too short");
|
||||
|
||||
/* The driver UUID is used for determining sharability of images and memory
|
||||
* between two Vulkan instances in separate processes, or for
|
||||
* interoperability between Vulkan and OpenGL. People who want to * share
|
||||
* memory need to also check the device UUID so all this * needs to be is
|
||||
* the build-id.
|
||||
*/
|
||||
memcpy(uuid, build_id_data(note), size);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright © 2020 Intel Corporation
|
||||
*
|
||||
* 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 GEN_UUID_H
|
||||
#define GEN_UUID_H
|
||||
|
||||
#include "dev/gen_device_info.h"
|
||||
#include "isl/isl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void gen_uuid_compute_device_id(uint8_t *uuid,
|
||||
const struct gen_device_info *devinfo,
|
||||
const struct isl_device *isldev,
|
||||
size_t size);
|
||||
|
||||
void gen_uuid_compute_driver_id(uint8_t *uuid,
|
||||
const struct gen_device_info *devinfo,
|
||||
size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GEN_UUID_H */
|
|
@ -37,6 +37,8 @@ files_libintel_common = files(
|
|||
'gen_l3_config.h',
|
||||
'gen_urb_config.c',
|
||||
'gen_sample_positions.h',
|
||||
'gen_uuid.c',
|
||||
'gen_uuid.h',
|
||||
)
|
||||
|
||||
libintel_common = static_library(
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "vk_util.h"
|
||||
#include "common/gen_aux_map.h"
|
||||
#include "common/gen_defines.h"
|
||||
#include "common/gen_uuid.h"
|
||||
#include "compiler/glsl_types.h"
|
||||
|
||||
#include "genxml/gen7_pack.h"
|
||||
|
@ -253,26 +254,9 @@ anv_physical_device_init_uuids(struct anv_physical_device *device)
|
|||
_mesa_sha1_final(&sha1_ctx, sha1);
|
||||
memcpy(device->pipeline_cache_uuid, sha1, VK_UUID_SIZE);
|
||||
|
||||
/* The driver UUID is used for determining sharability of images and memory
|
||||
* between two Vulkan instances in separate processes. People who want to
|
||||
* share memory need to also check the device UUID (below) so all this
|
||||
* needs to be is the build-id.
|
||||
*/
|
||||
memcpy(device->driver_uuid, build_id_data(note), VK_UUID_SIZE);
|
||||
|
||||
/* The device UUID uniquely identifies the given device within the machine.
|
||||
* Since we never have more than one device, this doesn't need to be a real
|
||||
* UUID. However, on the off-chance that someone tries to use this to
|
||||
* cache pre-tiled images or something of the like, we use the PCI ID and
|
||||
* some bits of ISL info to ensure that this is safe.
|
||||
*/
|
||||
_mesa_sha1_init(&sha1_ctx);
|
||||
_mesa_sha1_update(&sha1_ctx, &device->info.chipset_id,
|
||||
sizeof(device->info.chipset_id));
|
||||
_mesa_sha1_update(&sha1_ctx, &device->isl_dev.has_bit6_swizzling,
|
||||
sizeof(device->isl_dev.has_bit6_swizzling));
|
||||
_mesa_sha1_final(&sha1_ctx, sha1);
|
||||
memcpy(device->device_uuid, sha1, VK_UUID_SIZE);
|
||||
gen_uuid_compute_driver_id(device->driver_uuid, &device->info, VK_UUID_SIZE);
|
||||
gen_uuid_compute_device_id(device->device_uuid, &device->info,
|
||||
&device->isl_dev, VK_UUID_SIZE);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue