vulkan/util: add struct vk_pipeline_cache_header
Header is defined at vkGetPipelineCacheData spec, in any vulkan version, and anv, tu and radv were using the same struct, and v3dv was about to do the same. Defining the same struct four times seemed odd, so let's define on a common place. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Acked-by: Jonathan Marek <jonathan@marek.ca> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6058>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "radv_debug.h"
|
||||
#include "radv_private.h"
|
||||
#include "radv_shader.h"
|
||||
#include "vulkan/util/vk_util.h"
|
||||
|
||||
#include "ac_nir_to_llvm.h"
|
||||
|
||||
@@ -452,20 +453,12 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device,
|
||||
return;
|
||||
}
|
||||
|
||||
struct cache_header {
|
||||
uint32_t header_size;
|
||||
uint32_t header_version;
|
||||
uint32_t vendor_id;
|
||||
uint32_t device_id;
|
||||
uint8_t uuid[VK_UUID_SIZE];
|
||||
};
|
||||
|
||||
bool
|
||||
radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
|
||||
const void *data, size_t size)
|
||||
{
|
||||
struct radv_device *device = cache->device;
|
||||
struct cache_header header;
|
||||
struct vk_pipeline_cache_header header;
|
||||
|
||||
if (size < sizeof(header))
|
||||
return false;
|
||||
@@ -569,7 +562,7 @@ VkResult radv_GetPipelineCacheData(
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||
RADV_FROM_HANDLE(radv_pipeline_cache, cache, _cache);
|
||||
struct cache_header *header;
|
||||
struct vk_pipeline_cache_header *header;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
radv_pipeline_cache_lock(cache);
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "util/disk_cache.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "vulkan/util/vk_util.h"
|
||||
|
||||
struct cache_entry_variant_info
|
||||
{
|
||||
@@ -196,22 +197,13 @@ tu_pipeline_cache_add_entry(struct tu_pipeline_cache *cache,
|
||||
tu_pipeline_cache_set_entry(cache, entry);
|
||||
}
|
||||
|
||||
struct cache_header
|
||||
{
|
||||
uint32_t header_size;
|
||||
uint32_t header_version;
|
||||
uint32_t vendor_id;
|
||||
uint32_t device_id;
|
||||
uint8_t uuid[VK_UUID_SIZE];
|
||||
};
|
||||
|
||||
static void
|
||||
tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
|
||||
const void *data,
|
||||
size_t size)
|
||||
{
|
||||
struct tu_device *device = cache->device;
|
||||
struct cache_header header;
|
||||
struct vk_pipeline_cache_header header;
|
||||
|
||||
if (size < sizeof(header))
|
||||
return;
|
||||
@@ -307,7 +299,7 @@ tu_GetPipelineCacheData(VkDevice _device,
|
||||
{
|
||||
TU_FROM_HANDLE(tu_device, device, _device);
|
||||
TU_FROM_HANDLE(tu_pipeline_cache, cache, _cache);
|
||||
struct cache_header *header;
|
||||
struct vk_pipeline_cache_header *header;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
pthread_mutex_lock(&cache->mutex);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "nir/nir_serialize.h"
|
||||
#include "anv_private.h"
|
||||
#include "nir/nir_xfb_info.h"
|
||||
#include "vulkan/util/vk_util.h"
|
||||
|
||||
struct anv_shader_bin *
|
||||
anv_shader_bin_create(struct anv_device *device,
|
||||
@@ -475,14 +476,6 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
|
||||
}
|
||||
}
|
||||
|
||||
struct cache_header {
|
||||
uint32_t header_size;
|
||||
uint32_t header_version;
|
||||
uint32_t vendor_id;
|
||||
uint32_t device_id;
|
||||
uint8_t uuid[VK_UUID_SIZE];
|
||||
};
|
||||
|
||||
static void
|
||||
anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
|
||||
const void *data, size_t size)
|
||||
@@ -496,7 +489,7 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
|
||||
struct blob_reader blob;
|
||||
blob_reader_init(&blob, data, size);
|
||||
|
||||
struct cache_header header;
|
||||
struct vk_pipeline_cache_header header;
|
||||
blob_copy_bytes(&blob, &header, sizeof(header));
|
||||
uint32_t count = blob_read_uint32(&blob);
|
||||
if (blob.overrun)
|
||||
@@ -586,8 +579,8 @@ VkResult anv_GetPipelineCacheData(
|
||||
blob_init_fixed(&blob, NULL, SIZE_MAX);
|
||||
}
|
||||
|
||||
struct cache_header header = {
|
||||
.header_size = sizeof(struct cache_header),
|
||||
struct vk_pipeline_cache_header header = {
|
||||
.header_size = sizeof(struct vk_pipeline_cache_header),
|
||||
.header_version = VK_PIPELINE_CACHE_HEADER_VERSION_ONE,
|
||||
.vendor_id = 0x8086,
|
||||
.device_id = device->info.chipset_id,
|
||||
|
@@ -212,6 +212,14 @@ uint32_t vk_get_driver_version(void);
|
||||
|
||||
uint32_t vk_get_version_override(void);
|
||||
|
||||
struct vk_pipeline_cache_header {
|
||||
uint32_t header_size;
|
||||
uint32_t header_version;
|
||||
uint32_t vendor_id;
|
||||
uint32_t device_id;
|
||||
uint8_t uuid[VK_UUID_SIZE];
|
||||
};
|
||||
|
||||
#define VK_EXT_OFFSET (1000000000UL)
|
||||
#define VK_ENUM_EXTENSION(__enum) \
|
||||
((__enum) >= VK_EXT_OFFSET ? ((((__enum) - VK_EXT_OFFSET) / 1000UL) + 1) : 0)
|
||||
|
Reference in New Issue
Block a user