khronos-update: Add ANDROID guards to vk_android_native_buffer.h
Avoids adding back the code after every header update. Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29621>
This commit is contained in:

committed by
Marge Bot

parent
3f9fe2dbe1
commit
5726ecae3e
@@ -13,9 +13,13 @@ def error(msg: str) -> None:
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, filename: str, url: typing.Optional[str]):
|
||||
def __init__(self, filename: str, url: typing.Optional[str],
|
||||
template: typing.Optional[str] = None, remove:
|
||||
typing.Optional[str] = None):
|
||||
self.file = pathlib.Path(filename)
|
||||
self.url = url
|
||||
self.template = template
|
||||
self.remove = remove
|
||||
|
||||
def sync(self) -> None:
|
||||
if self.url is None:
|
||||
@@ -35,12 +39,37 @@ class Source:
|
||||
else:
|
||||
content = req.content
|
||||
|
||||
with open(self.file, 'wb') as f:
|
||||
content = str(content, encoding='utf-8')
|
||||
if self.remove is not None:
|
||||
content = content.replace(self.remove, '')
|
||||
if self.template is not None:
|
||||
content = self.template % content
|
||||
|
||||
with open(self.file, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print('Done')
|
||||
|
||||
|
||||
VK_ANDROID_NATIVE_BUFFER_TEMPLATE = """\
|
||||
/* MESA: A hack to avoid #ifdefs in driver code. */
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#if ANDROID_API_LEVEL < 28
|
||||
/* buffer_handle_t was defined in the deprecated system/window.h */
|
||||
typedef const native_handle_t *buffer_handle_t;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
typedef void *buffer_handle_t;
|
||||
|
||||
#endif
|
||||
|
||||
%s\
|
||||
"""
|
||||
|
||||
# a URL of `None` means there is no upstream, because *we* are the upstream
|
||||
SOURCES = [
|
||||
{
|
||||
@@ -176,7 +205,8 @@ SOURCES = [
|
||||
Source('include/vulkan/vulkan_xcb.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vulkan/vulkan_xcb.h'),
|
||||
Source('include/vulkan/vulkan_xlib.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vulkan/vulkan_xlib.h'),
|
||||
Source('include/vulkan/vulkan_xlib_xrandr.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vulkan/vulkan_xlib_xrandr.h'),
|
||||
Source('include/vulkan/vk_android_native_buffer.h', 'https://android.googlesource.com/platform/frameworks/native/+/master/vulkan/include/vulkan/vk_android_native_buffer.h?format=TEXT'),
|
||||
Source('include/vulkan/vk_android_native_buffer.h', 'https://android.googlesource.com/platform/frameworks/native/+/master/vulkan/include/vulkan/vk_android_native_buffer.h?format=TEXT',
|
||||
template=VK_ANDROID_NATIVE_BUFFER_TEMPLATE, remove='#include <cutils/native_handle.h>\n'),
|
||||
Source('include/vk_video/vulkan_video_codec_av1std.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vk_video/vulkan_video_codec_av1std.h'),
|
||||
Source('include/vk_video/vulkan_video_codec_av1std_decode.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vk_video/vulkan_video_codec_av1std_decode.h'),
|
||||
Source('include/vk_video/vulkan_video_codec_h264std.h', 'https://github.com/KhronosGroup/Vulkan-Headers/raw/main/include/vk_video/vulkan_video_codec_h264std.h'),
|
||||
|
@@ -1,3 +1,18 @@
|
||||
/* MESA: A hack to avoid #ifdefs in driver code. */
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#if ANDROID_API_LEVEL < 28
|
||||
/* buffer_handle_t was defined in the deprecated system/window.h */
|
||||
typedef const native_handle_t *buffer_handle_t;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
typedef void *buffer_handle_t;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright 2015 The Android Open Source Project
|
||||
*
|
||||
@@ -17,20 +32,8 @@
|
||||
#ifndef __VK_ANDROID_NATIVE_BUFFER_H__
|
||||
#define __VK_ANDROID_NATIVE_BUFFER_H__
|
||||
|
||||
/* MESA: A hack to avoid #ifdefs in driver code. */
|
||||
#ifdef __ANDROID__
|
||||
#include <cutils/native_handle.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if ANDROID_API_LEVEL < 28
|
||||
/* buffer_handle_t was defined in the deprecated system/window.h */
|
||||
typedef const native_handle_t *buffer_handle_t;
|
||||
#endif
|
||||
|
||||
#else
|
||||
typedef void *buffer_handle_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user