From fd0dab96666f09e382468013cc39a79b550c7fed Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 22 Jan 2023 12:06:22 +0100 Subject: Function for enabling hardware acceleration (doesn't enable hardware acceleration yet) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 1 + TODO | 1 - libglitter.h | 94 ++++++++++++++++++++++++++++++++++++++++ libglitter_enable_acceleration.c | 17 ++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 libglitter_enable_acceleration.c diff --git a/Makefile b/Makefile index b2e5614..3afe4af 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ OBJ =\ libglitter_compose_uint32.o\ libglitter_compose_uint64.o\ libglitter_compose_uint8.o\ + libglitter_enable_acceleration.o\ libglitter_desaturate_double.o\ libglitter_desaturate_float.o\ libglitter_create_render_context.o\ diff --git a/TODO b/TODO index 786000c..438b612 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ -Add support for GPU-acceleration Add man pages Add tests diff --git a/libglitter.h b/libglitter.h index 7e2a1ea..4e339e7 100644 --- a/libglitter.h +++ b/libglitter.h @@ -6,6 +6,62 @@ #include +/** + * The application will use `double`-typed rasters + */ +#define LIBGLITTER_FEATURE_DOUBLE_TYPE UINT64_C(0x0000000000000001) + +/** + * The application will use `float`-typed rasters + */ +#define LIBGLITTER_FEATURE_FLOAT_TYPE UINT64_C(0x0000000000000002) + +/** + * The application will use `uint64_t`-typed rasters + */ +#define LIBGLITTER_FEATURE_UINT64_TYPE UINT64_C(0x0000000000000004) + +/** + * The application will use `uint32_t`-typed rasters + */ +#define LIBGLITTER_FEATURE_UINT32_TYPE UINT64_C(0x0000000000000008) + +/** + * The application will use `uint16_t`-typed rasters + */ +#define LIBGLITTER_FEATURE_UINT16_TYPE UINT64_C(0x0000000000000010) + +/** + * The application will use `uint8_t`-typed rasters + */ +#define LIBGLITTER_FEATURE_UINT8_TYPE UINT64_C(0x0000000000000020) + +/** + * The allocation will use at least one of the functions + * `libglitter_compose_double`, + * `libglitter_compose_float`, + * `libglitter_compose_uint64`, + * `libglitter_compose_uint32`, + * `libglitter_compose_uint16`, and + * `libglitter_compose_uint8` + */ +#define LIBGLITTER_FEATURE_COMPOSE UINT64_C(0x0000000000000040) + +/** + * The allocation will use at least one of the functions + * `libglitter_desaturate_double`, and + * `libglitter_desaturate_float` + */ +#define LIBGLITTER_FEATURE_DESATURATION UINT64_C(0x0000000000000080) + +/** + * The allocation will use at least one of the functions + * `libglitter_colour_space_convert_rasters_double`, and + * `libglitter_colour_space_convert_rasters_float` + */ +#define LIBGLITTER_FEATURE_COLOUR_SPACE UINT64_C(0x0000000000000100) + + /** * The CIE xyY values of the D65 illuminant */ @@ -22,6 +78,44 @@ typedef struct libglitter_render_context LIBGLITTER_RENDER_CONTEXT; +/** + * Attempt to enable hardware acceleration + * + * Currently this function doesn't do anything but call the + * callback function and return 0; it is provided for application + * to use know and get hardware acceleration when it is implemented + * + * @param features Set of features to enable hardware acceleration + * for, unrecognised bits are silently ignored. + * Recognised bit values are: + * - LIBGLITTER_FEATURE_DOUBLE_TYPE, + * - LIBGLITTER_FEATURE_FLOAT_TYPE, + * - LIBGLITTER_FEATURE_UINT64_TYPE, + * - LIBGLITTER_FEATURE_UINT32_TYPE, + * - LIBGLITTER_FEATURE_UINT16_TYPE, + * - LIBGLITTER_FEATURE_UINT8_TYPE, + * - LIBGLITTER_FEATURE_COMPOSE, + * - LIBGLITTER_FEATURE_DESATURATION, and + * - LIBGLITTER_FEATURE_COLOUR_SPACE. + * @param async Whether the function shall return immediately + * rather than when complete + * @param callback Callback function that is called at function + * completion, the first argument will be either + * 1 on success with hardware acceleration enabled, + * 0 on success without hardware acceleration enabled, + * or -1 on failure; the second argument will be 0 + * on success or an error code on failure; the third + * argument will be `userdata`. This argument may + * also be `NULL` if no callback function shall be + * called + * @param userdata User-specific data to pass into `callback`, may be `NULL` + * @return 1 on success with hardware acceleration enabled, + * 0 on success without hardware acceleration enabled, + * or -1 on failure + */ +int libglitter_enable_acceleration(uint64_t, int, void (*)(int, int, void *), void *); + + /** * Create a render context for an input raster's specifications * diff --git a/libglitter_enable_acceleration.c b/libglitter_enable_acceleration.c new file mode 100644 index 0000000..f012da9 --- /dev/null +++ b/libglitter_enable_acceleration.c @@ -0,0 +1,17 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +int +libglitter_enable_acceleration(uint64_t features, int async, void (*callback)(int r, int e, void *u), void *userdata) +{ + (void) features; + (void) async; + + /* TODO add support for hardware acceleration */ + + if (callback) + callback(0, 0, userdata); + + return 0; +} -- cgit v1.2.3-70-g09d2