d3d11: Define enum and flags types manually

gnome.mkenums_simple() doesn't work well for GstD3D11, seems to
be confused by numeric representation of D3D11, must be a bug
in GLib or so. Just don't rely on the incomplete automagic.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2767>
This commit is contained in:
Seungha Yang 2022-07-21 05:40:45 +09:00
parent 879eb9412b
commit 32eeadb4a5
4 changed files with 75 additions and 17 deletions

View file

@ -27,7 +27,6 @@
#include <gst/gst.h>
#include <gst/d3d11/gstd3d11config.h>
#include <gst/d3d11/gstd3d11_fwd.h>
#include <gst/d3d11/gstd3d11-enumtypes.h>
#include <gst/d3d11/gstd3d11bufferpool.h>
#include <gst/d3d11/gstd3d11compile.h>
#include <gst/d3d11/gstd3d11device.h>

View file

@ -33,6 +33,68 @@ GST_DEBUG_CATEGORY_STATIC (gst_d3d11_allocator_debug);
static GstAllocator *_d3d11_memory_allocator;
GType
gst_d3d11_allocation_flags_get_type (void)
{
static gsize type = 0;
static const GFlagsValue values[] = {
{GST_D3D11_ALLOCATION_FLAG_DEFAULT, "GST_D3D11_ALLOCATION_FLAG_DEFAULT",
"default"},
{GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY,
"GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY", "texture-array"},
{0, nullptr, nullptr}
};
if (g_once_init_enter (&type)) {
GType tmp = g_flags_register_static ("GstD3D11AllocationFlags", values);
g_once_init_leave (&type, tmp);
}
return (GType) type;
}
GType
gst_d3d11_memory_transfer_get_type (void)
{
static gsize type = 0;
static const GFlagsValue values[] = {
{GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD,
"GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD", "need-download"},
{GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD,
"GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD", "need-upload"},
{0, nullptr, nullptr}
};
if (g_once_init_enter (&type)) {
GType tmp = g_flags_register_static ("GstD3D11MemoryTransfer", values);
g_once_init_leave (&type, tmp);
}
return (GType) type;
}
GType
gst_d3d11_memory_native_type_get_type (void)
{
static gsize type = 0;
static const GEnumValue values[] = {
{GST_D3D11_MEMORY_NATIVE_TYPE_INVALID,
"GST_D3D11_MEMORY_NATIVE_TYPE_INVALID", "invalid"},
{GST_D3D11_MEMORY_NATIVE_TYPE_BUFFER, "GST_D3D11_MEMORY_NATIVE_TYPE_BUFFER",
"buffer"},
{GST_D3D11_MEMORY_NATIVE_TYPE_TEXTURE_2D,
"GST_D3D11_MEMORY_NATIVE_TYPE_TEXTURE_2D", "texture-2d"},
{0, nullptr, nullptr}
};
if (g_once_init_enter (&type)) {
GType tmp = g_enum_register_static ("GstD3D11MemoryNativeType", values);
g_once_init_leave (&type, tmp);
}
return (GType) type;
}
/* GstD3D11AllocationParams */
static void gst_d3d11_allocation_params_init (GType type);
G_DEFINE_BOXED_TYPE_WITH_CODE (GstD3D11AllocationParams,

View file

@ -91,6 +91,10 @@ typedef enum
GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY = (1 << 0),
} GstD3D11AllocationFlags;
GST_D3D11_API
GType gst_d3d11_allocation_flags_get_type (void);
#define GST_TYPE_D3D11_ALLOCATION_FLAGS (gst_d3d11_allocation_flags_get_type())
/**
* GstD3D11MemoryTransfer:
* @GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD: the texture needs downloading
@ -106,6 +110,10 @@ typedef enum
GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 1)
} GstD3D11MemoryTransfer;
GST_D3D11_API
GType gst_d3d11_memory_transfer_get_type (void);
#define GST_TYPE_D3D11_MEMORY_TRANSFER (gst_d3d11_memory_transfer_get_type())
/**
* GstD3D11MemoryNativeType:
* @GST_D3D11_MEMORY_NATIVE_TYPE_INVALID: not a valid object type
@ -121,6 +129,10 @@ typedef enum
GST_D3D11_MEMORY_NATIVE_TYPE_TEXTURE_2D,
} GstD3D11MemoryNativeType;
GST_D3D11_API
GType gst_d3d11_memory_native_type_get_type (void);
#define GST_TYPE_D3D11_MEMORY_NATIVE_TYPE (gst_d3d11_memory_native_type_get_type())
struct _GstD3D11AllocationParams
{
/* Texture description per plane */

View file

@ -180,24 +180,9 @@ configure_file(
configuration: d3d11_conf,
)
d3d11_enums = gnome.mkenums_simple('gstd3d11-enumtypes',
sources : d3d11_enum_types_headers,
body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
header_prefix : '#include <gst/d3d11/d3d11-prelude.h>',
decorator: 'GST_D3D11_API',
identifier_prefix: 'GstD3D11',
symbol_prefix: 'gst_d3d11',
install_header: true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/d3d11'))
gstd3d11_c = d3d11_enums[0]
gstd3d11_h = d3d11_enums[1]
gen_sources = [gstd3d11_h]
pkg_name = 'gstreamer-d3d11-' + api_version
gstd3d11 = library('gstd3d11-' + api_version,
d3d11_sources + d3d11_enums,
d3d11_sources,
c_args : gst_plugins_bad_args + extra_c_args + extra_comm_args,
cpp_args : gst_plugins_bad_args + extra_comm_args,
include_directories : [configinc, libsinc],