This makes all the defines and boiler plate code use the generated source include system. This makes source hierarchy more understandable. Pull Request: https://projects.blender.org/blender/blender/pulls/146289
131 lines
4.6 KiB
Plaintext
131 lines
4.6 KiB
Plaintext
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/**
|
|
* Special header for mapping commonly defined tokens to API-specific variations.
|
|
* Where possible, this will adhere closely to base GLSL, where semantics are the same.
|
|
* However, host code shader code may need modifying to support types where necessary variations
|
|
* exist between APIs but are not expressed through the source. (e.g. distinction between depth2d
|
|
* and texture2d types in metal).
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "gpu_shader_msl_atomic.msl"
|
|
#include "gpu_shader_msl_attribute.msl"
|
|
#include "gpu_shader_msl_builtin.msl"
|
|
#include "gpu_shader_msl_image.msl"
|
|
#include "gpu_shader_msl_matrix.msl"
|
|
#include "gpu_shader_msl_matrix_legacy.msl"
|
|
#include "gpu_shader_msl_sampler.msl"
|
|
#include "gpu_shader_msl_types_legacy.msl"
|
|
|
|
/* Suppress unhelpful shader compiler warnings. */
|
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
|
#pragma clang diagnostic ignored "-Wcomment"
|
|
|
|
/* Defines generated by glsl_preprocess that contains threadgroup variables related codegen.
|
|
* See glsl_preprocess for more detail. */
|
|
#define MSL_SHARED_VARS_ARGS
|
|
#define MSL_SHARED_VARS_ASSIGN
|
|
#define MSL_SHARED_VARS_DECLARE
|
|
#define MSL_SHARED_VARS_PASS
|
|
|
|
/* int implicitly cast to bool in MSL. */
|
|
using bool32_t = int32_t;
|
|
|
|
using vec3_1010102_Unorm = uint32_t;
|
|
using vec3_1010102_Inorm = int32_t;
|
|
|
|
/* Array syntax compatibility. */
|
|
/* clang-format off */
|
|
#define float_array(...) { __VA_ARGS__ }
|
|
#define float2_array(...) { __VA_ARGS__ }
|
|
#define float3_array(...) { __VA_ARGS__ }
|
|
#define float4_array(...) { __VA_ARGS__ }
|
|
#define int_array(...) { __VA_ARGS__ }
|
|
#define int2_array(...) { __VA_ARGS__ }
|
|
#define int3_array(...) { __VA_ARGS__ }
|
|
#define int4_array(...) { __VA_ARGS__ }
|
|
#define uint_array(...) { __VA_ARGS__ }
|
|
#define uint2_array(...) { __VA_ARGS__ }
|
|
#define uint3_array(...) { __VA_ARGS__ }
|
|
#define uint4_array(...) { __VA_ARGS__ }
|
|
#define bool_array(...) { __VA_ARGS__ }
|
|
#define bool2_array(...) { __VA_ARGS__ }
|
|
#define bool3_array(...) { __VA_ARGS__ }
|
|
#define bool4_array(...) { __VA_ARGS__ }
|
|
#define ARRAY_T(type)
|
|
#define ARRAY_V(...) {__VA_ARGS__}
|
|
/* clang-format on */
|
|
|
|
#define SHADER_LIBRARY_CREATE_INFO(a)
|
|
#define VERTEX_SHADER_CREATE_INFO(a)
|
|
#define FRAGMENT_SHADER_CREATE_INFO(a)
|
|
#define COMPUTE_SHADER_CREATE_INFO(a)
|
|
|
|
#define METAL_CONSTRUCTOR_1(class_name, t1, m1) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_) : m1(m1##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_2(class_name, t1, m1, t2, m2) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_) : m1(m1##_), m2(m2##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_3(class_name, t1, m1, t2, m2, t3, m3) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_, t3 m3##_) : m1(m1##_), m2(m2##_), m3(m3##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_4(class_name, t1, m1, t2, m2, t3, m3, t4, m4) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_, t3 m3##_, t4 m4##_) \
|
|
: m1(m1##_), m2(m2##_), m3(m3##_), m4(m4##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_5(class_name, t1, m1, t2, m2, t3, m3, t4, m4, t5, m5) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_, t3 m3##_, t4 m4##_, t5 m5##_) \
|
|
: m1(m1##_), m2(m2##_), m3(m3##_), m4(m4##_), m5(m5##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_6(class_name, t1, m1, t2, m2, t3, m3, t4, m4, t5, m5, t6, m6) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_, t3 m3##_, t4 m4##_, t5 m5##_, t6 m6##_) \
|
|
: m1(m1##_), m2(m2##_), m3(m3##_), m4(m4##_), m5(m5##_), m6(m6##_){};
|
|
|
|
#define METAL_CONSTRUCTOR_7(class_name, t1, m1, t2, m2, t3, m3, t4, m4, t5, m5, t6, m6, t7, m7) \
|
|
class_name() = default; \
|
|
class_name(t1 m1##_, t2 m2##_, t3 m3##_, t4 m4##_, t5 m5##_, t6 m6##_, t7 m7##_) \
|
|
: m1(m1##_), m2(m2##_), m3(m3##_), m4(m4##_), m5(m5##_), m6(m6##_), m7(m7##_){};
|
|
|
|
#define in
|
|
#define out thread
|
|
#define inout thread
|
|
#define _in_sta
|
|
#define _in_end
|
|
#define _out_sta (&
|
|
#define _out_end )
|
|
#define _inout_sta (&
|
|
#define _inout_end )
|
|
|
|
#define shared threadgroup
|
|
#define _shared_sta (&
|
|
#define _shared_end )
|
|
|
|
/* Resource accessor. */
|
|
#define specialization_constant_get(create_info, _res) _res
|
|
#define shared_variable_get(create_info, _res) _res
|
|
#define push_constant_get(create_info, _res) _res
|
|
#define interface_get(create_info, _res) _res
|
|
#define attribute_get(create_info, _res) _res
|
|
#define buffer_get(create_info, _res) _res
|
|
#define sampler_get(create_info, _res) _res
|
|
#define image_get(create_info, _res) _res
|
|
|
|
/* Stage agnostic builtin function.
|
|
* MSL allow mixing shader stages inside the same source file.
|
|
* Leaving the calls untouched makes sure we catch invalid usage during CI testing. */
|
|
#define gpu_discard_fragment() discard
|
|
#define gpu_dfdx(x) dFdx(x)
|
|
#define gpu_dfdy(x) dFdy(x)
|
|
#define gpu_fwidth(x) fwidth(x)
|