[PATCH vkd3d 2/4] vkd3d-shader: Introduce vkd3d_shader_preprocess().

Henri Verbeet hverbeet at gmail.com
Fri Sep 25 07:59:51 CDT 2020


On Fri, 25 Sep 2020 at 03:00, Zebediah Figura <zfigura at codeweavers.com> wrote:
> +/**
> + * A single preprocessor macro, passed as part of struct
> + * vkd3d_shader_preprocess_info.
> + */
> +struct vkd3d_shader_macro
> +{
> +    /**
> +     * A null-terminated string containing the name of a macro. This macro must
> +     * not be a parameterized (i.e. function-like) macro. If the macro name is
> +     * invalid (for example, if it does not consist solely of alphanumeric
> +     * characters), it will be ignored.
> +     */
Alphanumeric is perhaps not a great term (e.g. "۱۲۳" or "é" would
typically not be considered alphanumeric here), but in any case, I
think the definition should be that it's a valid macro identifier in
the source language. At the same time, if it's not a valid macro name
in the source, it would effectively be ignored anyway, because if an
invalid name existed in the source compilation should fail.

> +struct vkd3d_shader_preprocess_info
> +{
> +    /** Must be set to VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO. */
> +    enum vkd3d_shader_structure_type type;
> +    /** Optional pointer to a structure containing further parameters. */
> +    const void *next;
> +
> +    /**
> +     * Pointer to an array of predefined macros. Each macro in this array will
> +     * be expanded as if a corresponding #define statement were prepended to the
> +     * source code.
> +     *
> +     * If the same macro is specified multiple itmes, only the first value is
> +     * used.
> +     */
"times"

> +    /**
> +     * Optional pointer to a callback function, which will be called in order to
> +     * evaluate \#include directives. The function receives parameters
> +     * corresponding to the directive's arguments, and should return the
> +     * complete text of the included file.
> +     *
> +     * If this field is set to NULL, or if this structure is omitted,
> +     * vkd3d-shader will emit a compilation error if any \#include directives
> +     * are evaluated.
> +     *
> +     * If this field is set to NULL, the \ref pfn_close_include field must also
> +     * be set to NULL.
> +     */
> +    PFN_vkd3d_shader_open_include pfn_open_include;
I think this is fine, but it would also be reasonable to provide a
default implementation that tries to open and read the file. Should
there be a way for PFN_vkd3d_shader_open_include to pass an error
string to its caller? (Which could then in turn add it to the compiler
output.)



More information about the wine-devel mailing list