diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_alpha_crop_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_alpha_crop_info.hh index 3f45bfbed23..c52918574fc 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_alpha_crop_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_alpha_crop_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_alpha_crop) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "lower_bound") - .push_constant(Type::IVEC2, "upper_bound") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_alpha_crop.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, lower_bound) +PUSH_CONSTANT(IVEC2, upper_bound) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_alpha_crop.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bilateral_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bilateral_blur_info.hh index 48eea13b7da..4494e4140c6 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bilateral_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bilateral_blur_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_bilateral_blur) - .local_group_size(16, 16) - .push_constant(Type::INT, "radius") - .push_constant(Type::FLOAT, "threshold") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "determinator_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_bilateral_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, radius) +PUSH_CONSTANT(FLOAT, threshold) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, determinator_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_bilateral_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_info.hh index 0c5a20fea97..32653f00828 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_info.hh @@ -5,12 +5,13 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_bokeh_blur) - .local_group_size(16, 16) - .push_constant(Type::INT, "radius") - .push_constant(Type::BOOL, "extend_bounds") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .sampler(2, ImageType::FLOAT_2D, "mask_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_bokeh_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, radius) +PUSH_CONSTANT(BOOL, extend_bounds) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +SAMPLER(2, FLOAT_2D, mask_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_bokeh_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_variable_size_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_variable_size_info.hh index 68c51b1911c..75cd0d0ac45 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_variable_size_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_blur_variable_size_info.hh @@ -5,13 +5,14 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_bokeh_blur_variable_size) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "base_size") - .push_constant(Type::INT, "search_radius") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .sampler(2, ImageType::FLOAT_2D, "size_tx") - .sampler(3, ImageType::FLOAT_2D, "mask_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_bokeh_blur_variable_size.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, base_size) +PUSH_CONSTANT(INT, search_radius) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +SAMPLER(2, FLOAT_2D, size_tx) +SAMPLER(3, FLOAT_2D, mask_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_bokeh_blur_variable_size.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_image_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_image_info.hh index 79f480256f1..9b47779bee7 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_image_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_bokeh_image_info.hh @@ -5,12 +5,13 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_bokeh_image) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "exterior_angle") - .push_constant(Type::FLOAT, "rotation") - .push_constant(Type::FLOAT, "roundness") - .push_constant(Type::FLOAT, "catadioptric") - .push_constant(Type::FLOAT, "lens_shift") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_bokeh_image.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, exterior_angle) +PUSH_CONSTANT(FLOAT, rotation) +PUSH_CONSTANT(FLOAT, roundness) +PUSH_CONSTANT(FLOAT, catadioptric) +PUSH_CONSTANT(FLOAT, lens_shift) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_bokeh_image.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_box_mask_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_box_mask_info.hh index 068ca5286e3..7f105617489 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_box_mask_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_box_mask_info.hh @@ -5,33 +5,38 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_box_mask_shared) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "domain_size") - .push_constant(Type::VEC2, "location") - .push_constant(Type::VEC2, "size") - .push_constant(Type::FLOAT, "cos_angle") - .push_constant(Type::FLOAT, "sin_angle") - .sampler(0, ImageType::FLOAT_2D, "base_mask_tx") - .sampler(1, ImageType::FLOAT_2D, "mask_value_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_mask_img") - .compute_source("compositor_box_mask.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, domain_size) +PUSH_CONSTANT(VEC2, location) +PUSH_CONSTANT(VEC2, size) +PUSH_CONSTANT(FLOAT, cos_angle) +PUSH_CONSTANT(FLOAT, sin_angle) +SAMPLER(0, FLOAT_2D, base_mask_tx) +SAMPLER(1, FLOAT_2D, mask_value_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_mask_img) +COMPUTE_SOURCE("compositor_box_mask.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_box_mask_add) - .additional_info("compositor_box_mask_shared") - .define("CMP_NODE_MASKTYPE_ADD") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_box_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_ADD") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_box_mask_subtract) - .additional_info("compositor_box_mask_shared") - .define("CMP_NODE_MASKTYPE_SUBTRACT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_box_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_SUBTRACT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_box_mask_multiply) - .additional_info("compositor_box_mask_shared") - .define("CMP_NODE_MASKTYPE_MULTIPLY") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_box_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_MULTIPLY") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_box_mask_not) - .additional_info("compositor_box_mask_shared") - .define("CMP_NODE_MASKTYPE_NOT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_box_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_NOT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_compute_preview_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_compute_preview_info.hh index 7c542b9fbb2..671f9c43a90 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_compute_preview_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_compute_preview_info.hh @@ -5,8 +5,9 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_compute_preview) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") - .compute_source("compositor_compute_preview.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, preview_img) +COMPUTE_SOURCE("compositor_compute_preview.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_convert_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_convert_info.hh index 0fd680bdc9e..d42fb8e3731 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_convert_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_convert_info.hh @@ -5,67 +5,78 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_convert_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .typedef_source("gpu_shader_compositor_type_conversion.glsl") - .compute_source("compositor_convert.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +TYPEDEF_SOURCE("gpu_shader_compositor_type_conversion.glsl") +COMPUTE_SOURCE("compositor_convert.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_float_to_float) - .additional_info("compositor_convert_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_float_to_vector) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4(vec3_from_float(value.x), 1.0)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4(vec3_from_float(value.x), 1.0)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_float_to_color) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4_from_float(value.x)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4_from_float(value.x)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_color_to_float) - .additional_info("compositor_convert_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4(float_from_vec4(value), vec3(0.0))") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4(float_from_vec4(value), vec3(0.0))") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_color_to_vector) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_color_to_color) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_float) - .additional_info("compositor_convert_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4(float_from_vec3(value.xyz), vec3(0.0))") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4(float_from_vec3(value.xyz), vec3(0.0))") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_vector) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_color) - .additional_info("compositor_convert_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4_from_vec3(value.xyz)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4_from_vec3(value.xyz)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_convert_color_to_alpha) - .additional_info("compositor_convert_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("CONVERT_EXPRESSION(value)", "vec4(value.a)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_convert_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("CONVERT_EXPRESSION(value)", "vec4(value.a)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_cryptomatte_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_cryptomatte_info.hh index 1b68a89843d..2bccba46eb3 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_cryptomatte_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_cryptomatte_info.hh @@ -5,25 +5,28 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_cryptomatte_pick) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "first_layer_tx") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_cryptomatte_pick.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, first_layer_tx) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_cryptomatte_pick.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_cryptomatte_matte) - .local_group_size(16, 16) - .push_constant(Type::INT, "identifiers_count") - .push_constant(Type::FLOAT, "identifiers", 32) - .sampler(0, ImageType::FLOAT_2D, "layer_tx") - .image(0, GPU_R16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "matte_img") - .compute_source("compositor_cryptomatte_matte.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, identifiers_count) +PUSH_CONSTANT_ARRAY(FLOAT, identifiers, 32) +SAMPLER(0, FLOAT_2D, layer_tx) +IMAGE(0, GPU_R16F, READ_WRITE, FLOAT_2D, matte_img) +COMPUTE_SOURCE("compositor_cryptomatte_matte.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_cryptomatte_image) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "matte_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_cryptomatte_image.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, matte_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_cryptomatte_image.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_defocus_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_defocus_info.hh index 6f92172a59b..36565e25a88 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_defocus_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_defocus_info.hh @@ -5,33 +5,36 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_defocus_radius_from_scale) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "scale") - .push_constant(Type::FLOAT, "max_radius") - .sampler(0, ImageType::FLOAT_2D, "radius_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "radius_img") - .compute_source("compositor_defocus_radius_from_scale.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, scale) +PUSH_CONSTANT(FLOAT, max_radius) +SAMPLER(0, FLOAT_2D, radius_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, radius_img) +COMPUTE_SOURCE("compositor_defocus_radius_from_scale.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_defocus_radius_from_depth) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "f_stop") - .push_constant(Type::FLOAT, "max_radius") - .push_constant(Type::FLOAT, "focal_length") - .push_constant(Type::FLOAT, "pixels_per_meter") - .push_constant(Type::FLOAT, "distance_to_image_of_focus") - .sampler(0, ImageType::FLOAT_2D, "depth_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "radius_img") - .compute_source("compositor_defocus_radius_from_depth.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, f_stop) +PUSH_CONSTANT(FLOAT, max_radius) +PUSH_CONSTANT(FLOAT, focal_length) +PUSH_CONSTANT(FLOAT, pixels_per_meter) +PUSH_CONSTANT(FLOAT, distance_to_image_of_focus) +SAMPLER(0, FLOAT_2D, depth_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, radius_img) +COMPUTE_SOURCE("compositor_defocus_radius_from_depth.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_defocus_blur) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "gamma_correct") - .push_constant(Type::INT, "search_radius") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .sampler(2, ImageType::FLOAT_2D, "radius_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_defocus_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, gamma_correct) +PUSH_CONSTANT(INT, search_radius) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +SAMPLER(2, FLOAT_2D, radius_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_defocus_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_deriche_gaussian_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_deriche_gaussian_blur_info.hh index e792aeb0fe4..502703d5dfd 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_deriche_gaussian_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_deriche_gaussian_blur_info.hh @@ -5,22 +5,24 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_deriche_gaussian_blur) - .local_group_size(128, 2) - .push_constant(Type::VEC4, "causal_feedforward_coefficients") - .push_constant(Type::VEC4, "non_causal_feedforward_coefficients") - .push_constant(Type::VEC4, "feedback_coefficients") - .push_constant(Type::FLOAT, "causal_boundary_coefficient") - .push_constant(Type::FLOAT, "non_causal_boundary_coefficient") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "causal_output_img") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "non_causal_output_img") - .compute_source("compositor_deriche_gaussian_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(128, 2) +PUSH_CONSTANT(VEC4, causal_feedforward_coefficients) +PUSH_CONSTANT(VEC4, non_causal_feedforward_coefficients) +PUSH_CONSTANT(VEC4, feedback_coefficients) +PUSH_CONSTANT(FLOAT, causal_boundary_coefficient) +PUSH_CONSTANT(FLOAT, non_causal_boundary_coefficient) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, causal_output_img) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D, non_causal_output_img) +COMPUTE_SOURCE("compositor_deriche_gaussian_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_deriche_gaussian_blur_sum) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "causal_input_tx") - .sampler(1, ImageType::FLOAT_2D, "non_causal_input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_deriche_gaussian_blur_sum.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, causal_input_tx) +SAMPLER(1, FLOAT_2D, non_causal_input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_deriche_gaussian_blur_sum.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_despeckle_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_despeckle_info.hh index f94bfaa7ea0..156af295157 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_despeckle_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_despeckle_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_despeckle) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "threshold") - .push_constant(Type::FLOAT, "neighbor_threshold") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "factor_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_despeckle.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, threshold) +PUSH_CONSTANT(FLOAT, neighbor_threshold) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, factor_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_despeckle.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_directional_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_directional_blur_info.hh index a1058a4e762..bd0d7a2969c 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_directional_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_directional_blur_info.hh @@ -5,14 +5,15 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_directional_blur) - .local_group_size(16, 16) - .push_constant(Type::INT, "iterations") - .push_constant(Type::VEC2, "origin") - .push_constant(Type::VEC2, "translation") - .push_constant(Type::FLOAT, "rotation_sin") - .push_constant(Type::FLOAT, "rotation_cos") - .push_constant(Type::FLOAT, "scale") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_directional_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, iterations) +PUSH_CONSTANT(VEC2, origin) +PUSH_CONSTANT(VEC2, translation) +PUSH_CONSTANT(FLOAT, rotation_sin) +PUSH_CONSTANT(FLOAT, rotation_cos) +PUSH_CONSTANT(FLOAT, scale) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_directional_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_displace_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_displace_info.hh index 4baf9ced1e5..bc0a7ca33bd 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_displace_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_displace_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_displace) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "displacement_tx") - .sampler(2, ImageType::FLOAT_2D, "x_scale_tx") - .sampler(3, ImageType::FLOAT_2D, "y_scale_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_displace.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, displacement_tx) +SAMPLER(2, FLOAT_2D, x_scale_tx) +SAMPLER(3, FLOAT_2D, y_scale_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_displace.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_double_edge_mask_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_double_edge_mask_info.hh index 049a6502d5a..b27df720c24 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_double_edge_mask_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_double_edge_mask_info.hh @@ -5,22 +5,24 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_double_edge_mask_compute_boundary) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "include_all_inner_edges") - .push_constant(Type::BOOL, "include_edges_of_image") - .sampler(0, ImageType::FLOAT_2D, "inner_mask_tx") - .sampler(1, ImageType::FLOAT_2D, "outer_mask_tx") - .image(0, GPU_RG16I, Qualifier::WRITE, ImageType::INT_2D, "inner_boundary_img") - .image(1, GPU_RG16I, Qualifier::WRITE, ImageType::INT_2D, "outer_boundary_img") - .compute_source("compositor_double_edge_mask_compute_boundary.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, include_all_inner_edges) +PUSH_CONSTANT(BOOL, include_edges_of_image) +SAMPLER(0, FLOAT_2D, inner_mask_tx) +SAMPLER(1, FLOAT_2D, outer_mask_tx) +IMAGE(0, GPU_RG16I, WRITE, INT_2D, inner_boundary_img) +IMAGE(1, GPU_RG16I, WRITE, INT_2D, outer_boundary_img) +COMPUTE_SOURCE("compositor_double_edge_mask_compute_boundary.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_double_edge_mask_compute_gradient) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "inner_mask_tx") - .sampler(1, ImageType::FLOAT_2D, "outer_mask_tx") - .sampler(2, ImageType::INT_2D, "flooded_inner_boundary_tx") - .sampler(3, ImageType::INT_2D, "flooded_outer_boundary_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_double_edge_mask_compute_gradient.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, inner_mask_tx) +SAMPLER(1, FLOAT_2D, outer_mask_tx) +SAMPLER(2, INT_2D, flooded_inner_boundary_tx) +SAMPLER(3, INT_2D, flooded_outer_boundary_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_double_edge_mask_compute_gradient.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_edge_filter_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_edge_filter_info.hh index c524a87c051..2e159f72358 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_edge_filter_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_edge_filter_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_edge_filter) - .local_group_size(16, 16) - .push_constant(Type::MAT4, "ukernel") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "factor_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_edge_filter.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(MAT4, ukernel) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, factor_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_edge_filter.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_ellipse_mask_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_ellipse_mask_info.hh index 08776540640..8247ad833ba 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_ellipse_mask_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_ellipse_mask_info.hh @@ -5,33 +5,38 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_ellipse_mask_shared) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "domain_size") - .push_constant(Type::VEC2, "location") - .push_constant(Type::VEC2, "radius") - .push_constant(Type::FLOAT, "cos_angle") - .push_constant(Type::FLOAT, "sin_angle") - .sampler(0, ImageType::FLOAT_2D, "base_mask_tx") - .sampler(1, ImageType::FLOAT_2D, "mask_value_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_mask_img") - .compute_source("compositor_ellipse_mask.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, domain_size) +PUSH_CONSTANT(VEC2, location) +PUSH_CONSTANT(VEC2, radius) +PUSH_CONSTANT(FLOAT, cos_angle) +PUSH_CONSTANT(FLOAT, sin_angle) +SAMPLER(0, FLOAT_2D, base_mask_tx) +SAMPLER(1, FLOAT_2D, mask_value_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_mask_img) +COMPUTE_SOURCE("compositor_ellipse_mask.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_ellipse_mask_add) - .additional_info("compositor_ellipse_mask_shared") - .define("CMP_NODE_MASKTYPE_ADD") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_ellipse_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_ADD") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_ellipse_mask_subtract) - .additional_info("compositor_ellipse_mask_shared") - .define("CMP_NODE_MASKTYPE_SUBTRACT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_ellipse_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_SUBTRACT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_ellipse_mask_multiply) - .additional_info("compositor_ellipse_mask_shared") - .define("CMP_NODE_MASKTYPE_MULTIPLY") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_ellipse_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_MULTIPLY") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_ellipse_mask_not) - .additional_info("compositor_ellipse_mask_shared") - .define("CMP_NODE_MASKTYPE_NOT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_ellipse_mask_shared) +DEFINE("CMP_NODE_MASKTYPE_NOT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_filter_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_filter_info.hh index 55d9784a75a..685596edcd2 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_filter_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_filter_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_filter) - .local_group_size(16, 16) - .push_constant(Type::MAT4, "ukernel") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "factor_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_filter.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(MAT4, ukernel) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, factor_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_filter.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_flip_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_flip_info.hh index 914600e26c1..9fba416e3af 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_flip_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_flip_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_flip) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "flip_x") - .push_constant(Type::BOOL, "flip_y") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_flip.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, flip_x) +PUSH_CONSTANT(BOOL, flip_y) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_flip.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_glare_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_glare_info.hh index 1b1db807bf4..dae0ecaac31 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_glare_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_glare_info.hh @@ -9,126 +9,140 @@ * ------- */ GPU_SHADER_CREATE_INFO(compositor_glare_highlights) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "threshold") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_glare_highlights.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, threshold) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_glare_highlights.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_mix) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "mix_factor") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "glare_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_glare_mix.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, mix_factor) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, glare_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_glare_mix.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* ------------ * Ghost Glare. * ------------ */ GPU_SHADER_CREATE_INFO(compositor_glare_ghost_base) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "small_ghost_tx") - .sampler(1, ImageType::FLOAT_2D, "big_ghost_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "combined_ghost_img") - .compute_source("compositor_glare_ghost_base.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, small_ghost_tx) +SAMPLER(1, FLOAT_2D, big_ghost_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, combined_ghost_img) +COMPUTE_SOURCE("compositor_glare_ghost_base.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_ghost_accumulate) - .local_group_size(16, 16) - .push_constant(Type::VEC4, "scales") - .push_constant(Type::VEC4, "color_modulators", 4) - .sampler(0, ImageType::FLOAT_2D, "input_ghost_tx") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "accumulated_ghost_img") - .compute_source("compositor_glare_ghost_accumulate.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(VEC4, scales) +PUSH_CONSTANT_ARRAY(VEC4, color_modulators, 4) +SAMPLER(0, FLOAT_2D, input_ghost_tx) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, accumulated_ghost_img) +COMPUTE_SOURCE("compositor_glare_ghost_accumulate.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* ----------- * Simple Star * ----------- */ GPU_SHADER_CREATE_INFO(compositor_glare_simple_star_horizontal_pass) - .local_group_size(16) - .push_constant(Type::INT, "iterations") - .push_constant(Type::FLOAT, "fade_factor") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "horizontal_img") - .compute_source("compositor_glare_simple_star_horizontal_pass.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +PUSH_CONSTANT(INT, iterations) +PUSH_CONSTANT(FLOAT, fade_factor) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, horizontal_img) +COMPUTE_SOURCE("compositor_glare_simple_star_horizontal_pass.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_simple_star_vertical_pass) - .local_group_size(16) - .push_constant(Type::INT, "iterations") - .push_constant(Type::FLOAT, "fade_factor") - .sampler(0, ImageType::FLOAT_2D, "horizontal_tx") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "vertical_img") - .compute_source("compositor_glare_simple_star_vertical_pass.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +PUSH_CONSTANT(INT, iterations) +PUSH_CONSTANT(FLOAT, fade_factor) +SAMPLER(0, FLOAT_2D, horizontal_tx) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, vertical_img) +COMPUTE_SOURCE("compositor_glare_simple_star_vertical_pass.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_simple_star_diagonal_pass) - .local_group_size(16) - .push_constant(Type::INT, "iterations") - .push_constant(Type::FLOAT, "fade_factor") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "diagonal_img") - .compute_source("compositor_glare_simple_star_diagonal_pass.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +PUSH_CONSTANT(INT, iterations) +PUSH_CONSTANT(FLOAT, fade_factor) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, diagonal_img) +COMPUTE_SOURCE("compositor_glare_simple_star_diagonal_pass.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_simple_star_anti_diagonal_pass) - .local_group_size(16) - .push_constant(Type::INT, "iterations") - .push_constant(Type::FLOAT, "fade_factor") - .sampler(0, ImageType::FLOAT_2D, "diagonal_tx") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "anti_diagonal_img") - .compute_source("compositor_glare_simple_star_anti_diagonal_pass.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +PUSH_CONSTANT(INT, iterations) +PUSH_CONSTANT(FLOAT, fade_factor) +SAMPLER(0, FLOAT_2D, diagonal_tx) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, anti_diagonal_img) +COMPUTE_SOURCE("compositor_glare_simple_star_anti_diagonal_pass.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* ------- * Streaks * ------- */ GPU_SHADER_CREATE_INFO(compositor_glare_streaks_filter) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "color_modulator") - .push_constant(Type::VEC3, "fade_factors") - .push_constant(Type::VEC2, "streak_vector") - .sampler(0, ImageType::FLOAT_2D, "input_streak_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_streak_img") - .compute_source("compositor_glare_streaks_filter.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, color_modulator) +PUSH_CONSTANT(VEC3, fade_factors) +PUSH_CONSTANT(VEC2, streak_vector) +SAMPLER(0, FLOAT_2D, input_streak_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_streak_img) +COMPUTE_SOURCE("compositor_glare_streaks_filter.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_streaks_accumulate) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "attenuation_factor") - .sampler(0, ImageType::FLOAT_2D, "streak_tx") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "accumulated_streaks_img") - .compute_source("compositor_glare_streaks_accumulate.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, attenuation_factor) +SAMPLER(0, FLOAT_2D, streak_tx) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, accumulated_streaks_img) +COMPUTE_SOURCE("compositor_glare_streaks_accumulate.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* ----- * Bloom * ----- */ GPU_SHADER_CREATE_INFO(compositor_glare_bloom_downsample_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_glare_bloom_downsample.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_glare_bloom_downsample.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_bloom_downsample_simple_average) - .define("SIMPLE_AVERAGE") - .additional_info("compositor_glare_bloom_downsample_shared") - .do_static_compilation(true); +DEFINE("SIMPLE_AVERAGE") +ADDITIONAL_INFO(compositor_glare_bloom_downsample_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_bloom_downsample_karis_average) - .define("KARIS_AVERAGE") - .additional_info("compositor_glare_bloom_downsample_shared") - .do_static_compilation(true); +DEFINE("KARIS_AVERAGE") +ADDITIONAL_INFO(compositor_glare_bloom_downsample_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_glare_bloom_upsample) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_glare_bloom_upsample.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_glare_bloom_upsample.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_id_mask_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_id_mask_info.hh index dbdd28d7a84..c72d1f038e6 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_id_mask_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_id_mask_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_id_mask) - .local_group_size(16, 16) - .push_constant(Type::INT, "index") - .sampler(0, ImageType::FLOAT_2D, "input_mask_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_mask_img") - .compute_source("compositor_id_mask.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, index) +SAMPLER(0, FLOAT_2D, input_mask_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_mask_img) +COMPUTE_SOURCE("compositor_id_mask.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_image_crop_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_image_crop_info.hh index bcbd1278ed7..6a2a013ee0a 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_image_crop_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_image_crop_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_image_crop) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "lower_bound") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_image_crop.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, lower_bound) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_image_crop.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_inpaint_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_inpaint_info.hh index bb2719992fb..5ffc3867837 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_inpaint_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_inpaint_info.hh @@ -5,29 +5,32 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_inpaint_compute_boundary) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RG16I, Qualifier::WRITE, ImageType::INT_2D, "boundary_img") - .compute_source("compositor_inpaint_compute_boundary.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RG16I, WRITE, INT_2D, boundary_img) +COMPUTE_SOURCE("compositor_inpaint_compute_boundary.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_inpaint_fill_region) - .local_group_size(16, 16) - .push_constant(Type::INT, "max_distance") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::INT_2D, "flooded_boundary_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "filled_region_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "distance_to_boundary_img") - .image(2, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "smoothing_radius_img") - .compute_source("compositor_inpaint_fill_region.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, max_distance) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, INT_2D, flooded_boundary_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, filled_region_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, distance_to_boundary_img) +IMAGE(2, GPU_R16F, WRITE, FLOAT_2D, smoothing_radius_img) +COMPUTE_SOURCE("compositor_inpaint_fill_region.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_inpaint_compute_region) - .local_group_size(16, 16) - .push_constant(Type::INT, "max_distance") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "inpainted_region_tx") - .sampler(2, ImageType::FLOAT_2D, "distance_to_boundary_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_inpaint_compute_region.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, max_distance) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, inpainted_region_tx) +SAMPLER(2, FLOAT_2D, distance_to_boundary_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_inpaint_compute_region.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_jump_flooding_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_jump_flooding_info.hh index 90648beac22..536ad38ef19 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_jump_flooding_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_jump_flooding_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_jump_flooding) - .local_group_size(16, 16) - .push_constant(Type::INT, "step_size") - .sampler(0, ImageType::INT_2D, "input_tx") - .image(0, GPU_RG16I, Qualifier::WRITE, ImageType::INT_2D, "output_img") - .compute_source("compositor_jump_flooding.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, step_size) +SAMPLER(0, INT_2D, input_tx) +IMAGE(0, GPU_RG16I, WRITE, INT_2D, output_img) +COMPUTE_SOURCE("compositor_jump_flooding.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_info.hh index 479c4ee94bd..748c3a321a2 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_info.hh @@ -5,53 +5,58 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_keying_extract_chroma) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_keying_extract_chroma.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_keying_extract_chroma.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_keying_replace_chroma) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "new_chroma_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_keying_replace_chroma.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, new_chroma_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_keying_replace_chroma.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_keying_compute_matte) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "key_balance") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "key_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_keying_compute_matte.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, key_balance) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, key_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_keying_compute_matte.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_keying_tweak_matte) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "compute_edges") - .push_constant(Type::BOOL, "apply_core_matte") - .push_constant(Type::BOOL, "apply_garbage_matte") - .push_constant(Type::INT, "edge_search_radius") - .push_constant(Type::FLOAT, "edge_tolerance") - .push_constant(Type::FLOAT, "black_level") - .push_constant(Type::FLOAT, "white_level") - .sampler(0, ImageType::FLOAT_2D, "input_matte_tx") - .sampler(1, ImageType::FLOAT_2D, "garbage_matte_tx") - .sampler(2, ImageType::FLOAT_2D, "core_matte_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_matte_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_edges_img") - .compute_source("compositor_keying_tweak_matte.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, compute_edges) +PUSH_CONSTANT(BOOL, apply_core_matte) +PUSH_CONSTANT(BOOL, apply_garbage_matte) +PUSH_CONSTANT(INT, edge_search_radius) +PUSH_CONSTANT(FLOAT, edge_tolerance) +PUSH_CONSTANT(FLOAT, black_level) +PUSH_CONSTANT(FLOAT, white_level) +SAMPLER(0, FLOAT_2D, input_matte_tx) +SAMPLER(1, FLOAT_2D, garbage_matte_tx) +SAMPLER(2, FLOAT_2D, core_matte_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_matte_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, output_edges_img) +COMPUTE_SOURCE("compositor_keying_tweak_matte.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_keying_compute_image) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "despill_factor") - .push_constant(Type::FLOAT, "despill_balance") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "matte_tx") - .sampler(2, ImageType::FLOAT_2D, "key_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_keying_compute_image.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, despill_factor) +PUSH_CONSTANT(FLOAT, despill_balance) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, matte_tx) +SAMPLER(2, FLOAT_2D, key_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_keying_compute_image.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_screen_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_screen_info.hh index ee1fd91e865..547a2719106 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_screen_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_keying_screen_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_keying_screen) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "smoothness") - .push_constant(Type::INT, "number_of_markers") - .storage_buf(0, Qualifier::READ, "vec2", "marker_positions[]") - .storage_buf(1, Qualifier::READ, "vec4", "marker_colors[]") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_keying_screen.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, smoothness) +PUSH_CONSTANT(INT, number_of_markers) +STORAGE_BUF(0, READ, vec2, marker_positions[]) +STORAGE_BUF(1, READ, vec4, marker_colors[]) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_keying_screen.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_kuwahara_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_kuwahara_info.hh index 9aa88260774..d4100fd57e4 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_kuwahara_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_kuwahara_info.hh @@ -5,68 +5,79 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_shared) - .local_group_size(16, 16) - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_kuwahara_classic.glsl"); +LOCAL_GROUP_SIZE(16, 16) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_kuwahara_classic.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_convolution_shared) - .additional_info("compositor_kuwahara_classic_shared") - .sampler(0, ImageType::FLOAT_2D, "input_tx"); +ADDITIONAL_INFO(compositor_kuwahara_classic_shared) +SAMPLER(0, FLOAT_2D, input_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_convolution_constant_size) - .additional_info("compositor_kuwahara_classic_convolution_shared") - .push_constant(Type::INT, "size") - .define("CONSTANT_SIZE") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_classic_convolution_shared) +PUSH_CONSTANT(INT, size) +DEFINE("CONSTANT_SIZE") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_convolution_variable_size) - .additional_info("compositor_kuwahara_classic_convolution_shared") - .sampler(1, ImageType::FLOAT_2D, "size_tx") - .define("VARIABLE_SIZE") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_classic_convolution_shared) +SAMPLER(1, FLOAT_2D, size_tx) +DEFINE("VARIABLE_SIZE") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_summed_area_table_shared) - .additional_info("compositor_kuwahara_classic_shared") - .define("SUMMED_AREA_TABLE") - .sampler(0, ImageType::FLOAT_2D, "table_tx") - .sampler(1, ImageType::FLOAT_2D, "squared_table_tx"); +ADDITIONAL_INFO(compositor_kuwahara_classic_shared) +DEFINE("SUMMED_AREA_TABLE") +SAMPLER(0, FLOAT_2D, table_tx) +SAMPLER(1, FLOAT_2D, squared_table_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_summed_area_table_constant_size) - .additional_info("compositor_kuwahara_classic_summed_area_table_shared") - .push_constant(Type::INT, "size") - .define("CONSTANT_SIZE") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_classic_summed_area_table_shared) +PUSH_CONSTANT(INT, size) +DEFINE("CONSTANT_SIZE") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_classic_summed_area_table_variable_size) - .additional_info("compositor_kuwahara_classic_summed_area_table_shared") - .sampler(2, ImageType::FLOAT_2D, "size_tx") - .define("VARIABLE_SIZE") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_classic_summed_area_table_shared) +SAMPLER(2, FLOAT_2D, size_tx) +DEFINE("VARIABLE_SIZE") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_anisotropic_compute_structure_tensor) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "structure_tensor_img") - .compute_source("compositor_kuwahara_anisotropic_compute_structure_tensor.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, structure_tensor_img) +COMPUTE_SOURCE("compositor_kuwahara_anisotropic_compute_structure_tensor.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_anisotropic_shared) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "eccentricity") - .push_constant(Type::FLOAT, "sharpness") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "structure_tensor_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_kuwahara_anisotropic.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, eccentricity) +PUSH_CONSTANT(FLOAT, sharpness) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, structure_tensor_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_kuwahara_anisotropic.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_anisotropic_constant_size) - .additional_info("compositor_kuwahara_anisotropic_shared") - .define("CONSTANT_SIZE") - .push_constant(Type::FLOAT, "size") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_anisotropic_shared) +DEFINE("CONSTANT_SIZE") +PUSH_CONSTANT(FLOAT, size) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_kuwahara_anisotropic_variable_size) - .additional_info("compositor_kuwahara_anisotropic_shared") - .define("VARIABLE_SIZE") - .sampler(2, ImageType::FLOAT_2D, "size_tx") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_kuwahara_anisotropic_shared) +DEFINE("VARIABLE_SIZE") +SAMPLER(2, FLOAT_2D, size_tx) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_map_uv_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_map_uv_info.hh index 73d87a020df..bbdd122cc26 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_map_uv_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_map_uv_info.hh @@ -5,18 +5,21 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_map_uv_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "uv_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, uv_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_map_uv_anisotropic) - .additional_info("compositor_map_uv_shared") - .push_constant(Type::FLOAT, "gradient_attenuation_factor") - .compute_source("compositor_map_uv_anisotropic.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_map_uv_shared) +PUSH_CONSTANT(FLOAT, gradient_attenuation_factor) +COMPUTE_SOURCE("compositor_map_uv_anisotropic.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_map_uv_nearest_neighbour) - .additional_info("compositor_map_uv_shared") - .compute_source("compositor_map_uv_nearest_neighbour.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_map_uv_shared) +COMPUTE_SOURCE("compositor_map_uv_nearest_neighbour.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_blur_info.hh index 0a6098b1e32..6d0035aa02a 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_blur_info.hh @@ -5,17 +5,20 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_morphological_blur_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "blurred_input_img") - .compute_source("compositor_morphological_blur.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R16F, READ_WRITE, FLOAT_2D, blurred_input_img) +COMPUTE_SOURCE("compositor_morphological_blur.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_blur_dilate) - .additional_info("compositor_morphological_blur_shared") - .define("OPERATOR(x, y)", "max(x, y)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_blur_shared) +DEFINE_VALUE("OPERATOR(x, y)", "max(x, y)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_blur_erode) - .additional_info("compositor_morphological_blur_shared") - .define("OPERATOR(x, y)", "min(x, y)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_blur_shared) +DEFINE_VALUE("OPERATOR(x, y)", "min(x, y)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_feather_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_feather_info.hh index bc777cbd9af..d45c808f6fb 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_feather_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_feather_info.hh @@ -5,19 +5,22 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_morphological_distance_feather_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_1D, "weights_tx") - .sampler(2, ImageType::FLOAT_1D, "falloffs_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_morphological_distance_feather.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_1D, weights_tx) +SAMPLER(2, FLOAT_1D, falloffs_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_morphological_distance_feather.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_distance_feather_dilate) - .additional_info("compositor_morphological_distance_feather_shared") - .define("FUNCTION(x)", "x") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_distance_feather_shared) +DEFINE_VALUE("FUNCTION(x)", "x") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_distance_feather_erode) - .additional_info("compositor_morphological_distance_feather_shared") - .define("FUNCTION(x)", "1.0 - x") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_distance_feather_shared) +DEFINE_VALUE("FUNCTION(x)", "1.0 - x") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_info.hh index 8eca47d6012..11aefeef699 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_info.hh @@ -5,20 +5,23 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_morphological_distance_shared) - .local_group_size(16, 16) - .push_constant(Type::INT, "radius") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_morphological_distance.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, radius) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_morphological_distance.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_distance_dilate) - .additional_info("compositor_morphological_distance_shared") - .define("OPERATOR(a, b)", "max(a, b)") - .define("LIMIT", "FLT_MIN") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_distance_shared) +DEFINE_VALUE("OPERATOR(a, b)", "max(a, b)") +DEFINE_VALUE("LIMIT", "FLT_MIN") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_distance_erode) - .additional_info("compositor_morphological_distance_shared") - .define("OPERATOR(a, b)", "min(a, b)") - .define("LIMIT", "FLT_MAX") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_distance_shared) +DEFINE_VALUE("OPERATOR(a, b)", "min(a, b)") +DEFINE_VALUE("LIMIT", "FLT_MAX") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_threshold_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_threshold_info.hh index cd5bad139a4..7d7d710f26e 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_threshold_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_distance_threshold_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_morphological_distance_threshold) - .local_group_size(16, 16) - .push_constant(Type::INT, "radius") - .push_constant(Type::INT, "distance") - .push_constant(Type::FLOAT, "inset") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_morphological_distance_threshold.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, radius) +PUSH_CONSTANT(INT, distance) +PUSH_CONSTANT(FLOAT, inset) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_morphological_distance_threshold.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_step_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_step_info.hh index 0d58f27b757..0b3fc35d23b 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_step_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_morphological_step_info.hh @@ -5,20 +5,23 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_morphological_step_shared) - .local_group_size(16, 16) - .push_constant(Type::INT, "radius") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_morphological_step.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, radius) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_morphological_step.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_step_dilate) - .additional_info("compositor_morphological_step_shared") - .define("OPERATOR(a, b)", "max(a, b)") - .define("LIMIT", "FLT_MIN") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_step_shared) +DEFINE_VALUE("OPERATOR(a, b)", "max(a, b)") +DEFINE_VALUE("LIMIT", "FLT_MIN") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_morphological_step_erode) - .additional_info("compositor_morphological_step_shared") - .define("OPERATOR(a, b)", "min(a, b)") - .define("LIMIT", "FLT_MAX") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_morphological_step_shared) +DEFINE_VALUE("OPERATOR(a, b)", "min(a, b)") +DEFINE_VALUE("LIMIT", "FLT_MAX") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_motion_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_motion_blur_info.hh index 446090c63a2..8f3fe0a8529 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_motion_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_motion_blur_info.hh @@ -5,22 +5,24 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_motion_blur_max_velocity_dilate) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "shutter_speed") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .storage_buf(0, Qualifier::READ_WRITE, "uint", "tile_indirection_buf[]") - .compute_source("compositor_motion_blur_max_velocity_dilate.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, shutter_speed) +SAMPLER(0, FLOAT_2D, input_tx) +STORAGE_BUF(0, READ_WRITE, uint, tile_indirection_buf[]) +COMPUTE_SOURCE("compositor_motion_blur_max_velocity_dilate.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_motion_blur) - .local_group_size(16, 16) - .push_constant(Type::INT, "samples_count") - .push_constant(Type::FLOAT, "shutter_speed") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "depth_tx") - .sampler(2, ImageType::FLOAT_2D, "velocity_tx") - .sampler(3, ImageType::FLOAT_2D, "max_velocity_tx") - .storage_buf(0, Qualifier::READ, "uint", "tile_indirection_buf[]") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_motion_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, samples_count) +PUSH_CONSTANT(FLOAT, shutter_speed) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, depth_tx) +SAMPLER(2, FLOAT_2D, velocity_tx) +SAMPLER(3, FLOAT_2D, max_velocity_tx) +STORAGE_BUF(0, READ, uint, tile_indirection_buf[]) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_motion_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_movie_distortion_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_movie_distortion_info.hh index a18504ba48f..3469a8b7823 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_movie_distortion_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_movie_distortion_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_movie_distortion) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "distortion_grid_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_movie_distortion.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, distortion_grid_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_movie_distortion.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_normalize_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_normalize_info.hh index 284f8dbfaca..21ad46b0953 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_normalize_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_normalize_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_normalize) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "minimum") - .push_constant(Type::FLOAT, "scale") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_normalize.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, minimum) +PUSH_CONSTANT(FLOAT, scale) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_normalize.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh index b0859269a99..34cecf19ca7 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh @@ -5,189 +5,210 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_parallel_reduction_shared) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "is_initial_reduction") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .compute_source("compositor_parallel_reduction.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, is_initial_reduction) +SAMPLER(0, FLOAT_2D, input_tx) +COMPUTE_SOURCE("compositor_parallel_reduction.glsl") +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- * Sum Reductions. */ GPU_SHADER_CREATE_INFO(compositor_sum_shared) - .additional_info("compositor_parallel_reduction_shared") - .define("REDUCE(lhs, rhs)", "lhs + rhs"); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +DEFINE_VALUE("REDUCE(lhs, rhs)", "lhs + rhs") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_float_shared) - .additional_info("compositor_sum_shared") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "float") - .define("IDENTITY", "0.0") - .define("LOAD(value)", "value.x"); +ADDITIONAL_INFO(compositor_sum_shared) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "0.0") +DEFINE_VALUE("LOAD(value)", "value.x") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_red) - .additional_info("compositor_sum_float_shared") - .define("INITIALIZE(value)", "value.r") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "value.r") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_green) - .additional_info("compositor_sum_float_shared") - .define("INITIALIZE(value)", "value.g") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "value.g") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_blue) - .additional_info("compositor_sum_float_shared") - .define("INITIALIZE(value)", "value.b") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "value.b") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_luminance) - .additional_info("compositor_sum_float_shared") - .push_constant(Type::VEC3, "luminance_coefficients") - .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_float_shared) +PUSH_CONSTANT(VEC3, luminance_coefficients) +DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_log_luminance) - .additional_info("compositor_sum_float_shared") - .push_constant(Type::VEC3, "luminance_coefficients") - .define("INITIALIZE(value)", "log(max(dot(value.rgb, luminance_coefficients), 1e-5))") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_float_shared) +PUSH_CONSTANT(VEC3, luminance_coefficients) +DEFINE_VALUE("INITIALIZE(value)", "log(max(dot(value.rgb, luminance_coefficients), 1e-5))") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_color) - .additional_info("compositor_sum_shared") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "vec4") - .define("IDENTITY", "vec4(0.0)") - .define("INITIALIZE(value)", "value") - .define("LOAD(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_shared) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("TYPE", "vec4") +DEFINE_VALUE("IDENTITY", "vec4(0.0)") +DEFINE_VALUE("INITIALIZE(value)", "value") +DEFINE_VALUE("LOAD(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- * Sum Of Squared Difference Reductions. */ GPU_SHADER_CREATE_INFO(compositor_sum_squared_difference_float_shared) - .additional_info("compositor_parallel_reduction_shared") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .push_constant(Type::FLOAT, "subtrahend") - .define("TYPE", "float") - .define("IDENTITY", "0.0") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "lhs + rhs"); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +PUSH_CONSTANT(FLOAT, subtrahend) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "0.0") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "lhs + rhs") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_red_squared_difference) - .additional_info("compositor_sum_squared_difference_float_shared") - .define("INITIALIZE(value)", "pow(value.r - subtrahend, 2.0)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "pow(value.r - subtrahend, 2.0)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_green_squared_difference) - .additional_info("compositor_sum_squared_difference_float_shared") - .define("INITIALIZE(value)", "pow(value.g - subtrahend, 2.0)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "pow(value.g - subtrahend, 2.0)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_blue_squared_difference) - .additional_info("compositor_sum_squared_difference_float_shared") - .define("INITIALIZE(value)", "pow(value.b - subtrahend, 2.0)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared) +DEFINE_VALUE("INITIALIZE(value)", "pow(value.b - subtrahend, 2.0)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_sum_luminance_squared_difference) - .additional_info("compositor_sum_squared_difference_float_shared") - .push_constant(Type::VEC3, "luminance_coefficients") - .define("INITIALIZE(value)", "pow(dot(value.rgb, luminance_coefficients) - subtrahend, 2.0)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared) +PUSH_CONSTANT(VEC3, luminance_coefficients) +DEFINE_VALUE("INITIALIZE(value)", "pow(dot(value.rgb, luminance_coefficients) - subtrahend, 2.0)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- * Maximum Reductions. */ GPU_SHADER_CREATE_INFO(compositor_maximum_luminance) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .push_constant(Type::VEC3, "luminance_coefficients") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MIN") - .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "max(lhs, rhs)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +TYPEDEF_SOURCE("common_math_lib.glsl") +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +PUSH_CONSTANT(VEC3, luminance_coefficients) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "FLT_MIN") +DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "max(lhs, rhs)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_maximum_float) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MIN") - .define("INITIALIZE(value)", "value.x") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "max(rhs, lhs)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +TYPEDEF_SOURCE("common_math_lib.glsl") +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "FLT_MIN") +DEFINE_VALUE("INITIALIZE(value)", "value.x") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "max(rhs, lhs)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range) - .additional_info("compositor_parallel_reduction_shared") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .push_constant(Type::FLOAT, "lower_bound") - .push_constant(Type::FLOAT, "upper_bound") - .define("TYPE", "float") - .define("IDENTITY", "lower_bound") - .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +PUSH_CONSTANT(FLOAT, lower_bound) +PUSH_CONSTANT(FLOAT, upper_bound) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "lower_bound") +DEFINE_VALUE("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- * Minimum Reductions. */ GPU_SHADER_CREATE_INFO(compositor_minimum_luminance) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .push_constant(Type::VEC3, "luminance_coefficients") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MAX") - .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "min(lhs, rhs)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +TYPEDEF_SOURCE("common_math_lib.glsl") +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +PUSH_CONSTANT(VEC3, luminance_coefficients) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "FLT_MAX") +DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "min(lhs, rhs)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_minimum_float) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MAX") - .define("INITIALIZE(value)", "value.x") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "min(rhs, lhs)") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +TYPEDEF_SOURCE("common_math_lib.glsl") +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "FLT_MAX") +DEFINE_VALUE("INITIALIZE(value)", "value.x") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "min(rhs, lhs)") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range) - .additional_info("compositor_parallel_reduction_shared") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .push_constant(Type::FLOAT, "lower_bound") - .push_constant(Type::FLOAT, "upper_bound") - .define("TYPE", "float") - .define("IDENTITY", "upper_bound") - .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_parallel_reduction_shared) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +PUSH_CONSTANT(FLOAT, lower_bound) +PUSH_CONSTANT(FLOAT, upper_bound) +DEFINE_VALUE("TYPE", "float") +DEFINE_VALUE("IDENTITY", "upper_bound") +DEFINE_VALUE("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound") +DEFINE_VALUE("LOAD(value)", "value.x") +DEFINE_VALUE("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- * Velocity Reductions. */ GPU_SHADER_CREATE_INFO(compositor_max_velocity) - .local_group_size(32, 32) - .push_constant(Type::BOOL, "is_initial_reduction") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "vec4") - .define("IDENTITY", "vec4(0.0)") - .define("INITIALIZE(value)", "value") - .define("LOAD(value)", "value") - .define("REDUCE(lhs, rhs)", - "vec4(dot(lhs.xy, lhs.xy) > dot(rhs.xy, rhs.xy) ? lhs.xy : rhs.xy," - " dot(lhs.zw, lhs.zw) > dot(rhs.zw, rhs.zw) ? lhs.zw : rhs.zw)") - .compute_source("compositor_parallel_reduction.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(32, 32) +PUSH_CONSTANT(BOOL, is_initial_reduction) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("TYPE", "vec4") +DEFINE_VALUE("IDENTITY", "vec4(0.0)") +DEFINE_VALUE("INITIALIZE(value)", "value") +DEFINE_VALUE("LOAD(value)", "value") +DEFINE_VALUE("REDUCE(lhs, rhs)", + "vec4(dot(lhs.xy, lhs.xy) > dot(rhs.xy, rhs.xy) ? lhs.xy : rhs.xy," + " dot(lhs.zw, lhs.zw) > dot(rhs.zw, rhs.zw) ? lhs.zw : rhs.zw)") +COMPUTE_SOURCE("compositor_parallel_reduction.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_pixelate_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_pixelate_info.hh index 47cc6cf4661..8df1a5ec50f 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_pixelate_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_pixelate_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_pixelate) - .local_group_size(16, 16) - .push_constant(Type::INT, "pixel_size") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_pixelate.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, pixel_size) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_pixelate.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_plane_deform_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_plane_deform_info.hh index 445896c8b06..1aacbc11796 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_plane_deform_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_plane_deform_info.hh @@ -5,35 +5,39 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_plane_deform_mask) - .local_group_size(16, 16) - .push_constant(Type::MAT4, "homography_matrix") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "mask_img") - .compute_source("compositor_plane_deform_mask.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(MAT4, homography_matrix) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, mask_img) +COMPUTE_SOURCE("compositor_plane_deform_mask.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_plane_deform) - .local_group_size(16, 16) - .push_constant(Type::MAT4, "homography_matrix") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "mask_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_plane_deform.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(MAT4, homography_matrix) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, mask_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_plane_deform.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_plane_deform_motion_blur_mask) - .local_group_size(16, 16) - .push_constant(Type::INT, "number_of_motion_blur_samples") - .uniform_buf(0, "mat4", "homography_matrices[64]") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "mask_img") - .compute_source("compositor_plane_deform_motion_blur_mask.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, number_of_motion_blur_samples) +UNIFORM_BUF(0, mat4, homography_matrices[64]) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, mask_img) +COMPUTE_SOURCE("compositor_plane_deform_motion_blur_mask.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_plane_deform_motion_blur) - .local_group_size(16, 16) - .push_constant(Type::INT, "number_of_motion_blur_samples") - .uniform_buf(0, "mat4", "homography_matrices[64]") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "mask_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_plane_deform_motion_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(INT, number_of_motion_blur_samples) +UNIFORM_BUF(0, mat4, homography_matrices[64]) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, mask_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_plane_deform_motion_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_premultiply_alpha_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_premultiply_alpha_info.hh index c698750269b..1baf1334b5b 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_premultiply_alpha_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_premultiply_alpha_info.hh @@ -5,8 +5,9 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_premultiply_alpha) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_premultiply_alpha.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_premultiply_alpha.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_projector_lens_distortion_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_projector_lens_distortion_info.hh index 1acd02baa42..5425065fbac 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_projector_lens_distortion_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_projector_lens_distortion_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_projector_lens_distortion) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "dispersion") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_projector_lens_distortion.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, dispersion) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_projector_lens_distortion.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_read_input_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_read_input_info.hh index a8e80ebb948..0aa1be33ff8 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_read_input_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_read_input_info.hh @@ -5,31 +5,36 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_read_input_shared) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "lower_bound") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .compute_source("compositor_read_input.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, lower_bound) +SAMPLER(0, FLOAT_2D, input_tx) +COMPUTE_SOURCE("compositor_read_input.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_read_input_float) - .additional_info("compositor_read_input_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("READ_EXPRESSION(input_color)", "vec4(input_color.r, vec3(0.0))") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_read_input_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("READ_EXPRESSION(input_color)", "vec4(input_color.r, vec3(0.0))") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_read_input_vector) - .additional_info("compositor_read_input_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("READ_EXPRESSION(input_color)", "input_color") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_read_input_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("READ_EXPRESSION(input_color)", "input_color") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_read_input_color) - .additional_info("compositor_read_input_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("READ_EXPRESSION(input_color)", "input_color") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_read_input_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("READ_EXPRESSION(input_color)", "input_color") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_read_input_alpha) - .additional_info("compositor_read_input_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("READ_EXPRESSION(input_color)", "vec4(input_color.a, vec3(0.0))") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_read_input_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DEFINE_VALUE("READ_EXPRESSION(input_color)", "vec4(input_color.a, vec3(0.0))") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_realize_on_domain_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_realize_on_domain_info.hh index b870d438ad3..725ba946b2f 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_realize_on_domain_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_realize_on_domain_info.hh @@ -5,45 +5,54 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_shared) - .local_group_size(16, 16) - .push_constant(Type::MAT4, "inverse_transformation") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .compute_source("compositor_realize_on_domain.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(MAT4, inverse_transformation) +SAMPLER(0, FLOAT_2D, input_tx) +COMPUTE_SOURCE("compositor_realize_on_domain.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_standard_shared) - .additional_info("compositor_realize_on_domain_shared") - .define("SAMPLER_FUNCTION", "texture"); +ADDITIONAL_INFO(compositor_realize_on_domain_shared) +DEFINE_VALUE("SAMPLER_FUNCTION", "texture") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_bicubic_shared) - .additional_info("compositor_realize_on_domain_shared") - .define("SAMPLER_FUNCTION", "texture_bicubic"); +ADDITIONAL_INFO(compositor_realize_on_domain_shared) +DEFINE_VALUE("SAMPLER_FUNCTION", "texture_bicubic") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_color) - .additional_info("compositor_realize_on_domain_standard_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_standard_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_vector) - .additional_info("compositor_realize_on_domain_standard_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_standard_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_float) - .additional_info("compositor_realize_on_domain_standard_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_standard_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_bicubic_color) - .additional_info("compositor_realize_on_domain_bicubic_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_bicubic_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_bicubic_vector) - .additional_info("compositor_realize_on_domain_bicubic_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_bicubic_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_realize_on_domain_bicubic_float) - .additional_info("compositor_realize_on_domain_bicubic_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "domain_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_realize_on_domain_bicubic_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, domain_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_scale_variable_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_scale_variable_info.hh index 327ded2efab..24d316a2f05 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_scale_variable_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_scale_variable_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_scale_variable) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "x_scale_tx") - .sampler(2, ImageType::FLOAT_2D, "y_scale_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_scale_variable.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, x_scale_tx) +SAMPLER(2, FLOAT_2D, y_scale_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_scale_variable.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_screen_lens_distortion_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_screen_lens_distortion_info.hh index e3b03f1e724..742bb2facbd 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_screen_lens_distortion_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_screen_lens_distortion_info.hh @@ -5,18 +5,21 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_screen_lens_distortion_shared) - .local_group_size(16, 16) - .push_constant(Type::VEC3, "chromatic_distortion") - .push_constant(Type::FLOAT, "scale") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_screen_lens_distortion.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(VEC3, chromatic_distortion) +PUSH_CONSTANT(FLOAT, scale) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_screen_lens_distortion.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_screen_lens_distortion) - .additional_info("compositor_screen_lens_distortion_shared") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_screen_lens_distortion_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_screen_lens_distortion_jitter) - .additional_info("compositor_screen_lens_distortion_shared") - .define("JITTER") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_screen_lens_distortion_shared) +DEFINE("JITTER") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_smaa_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_smaa_info.hh index 6b12ae4dfff..03169ab921a 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_smaa_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_smaa_info.hh @@ -5,55 +5,61 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_smaa_edge_detection) - .local_group_size(16, 16) - .define("SMAA_GLSL_3") - .define("SMAA_RT_METRICS", - "vec4(1.0 / vec2(textureSize(input_tx, 0)), vec2(textureSize(input_tx, 0)))") - .define("SMAA_LUMA_WEIGHT", "vec4(luminance_coefficients, 0.0)") - .define("SMAA_THRESHOLD", "smaa_threshold") - .define("SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR", "smaa_local_contrast_adaptation_factor") - .push_constant(Type::VEC3, "luminance_coefficients") - .push_constant(Type::FLOAT, "smaa_threshold") - .push_constant(Type::FLOAT, "smaa_local_contrast_adaptation_factor") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "edges_img") - .compute_source("compositor_smaa_edge_detection.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +DEFINE("SMAA_GLSL_3") +DEFINE_VALUE("SMAA_RT_METRICS", + "vec4(1.0 / vec2(textureSize(input_tx, 0)), vec2(textureSize(input_tx, 0)))") +DEFINE_VALUE("SMAA_LUMA_WEIGHT", "vec4(luminance_coefficients, 0.0)") +DEFINE_VALUE("SMAA_THRESHOLD", "smaa_threshold") +DEFINE_VALUE("SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR", "smaa_local_contrast_adaptation_factor") +PUSH_CONSTANT(VEC3, luminance_coefficients) +PUSH_CONSTANT(FLOAT, smaa_threshold) +PUSH_CONSTANT(FLOAT, smaa_local_contrast_adaptation_factor) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, edges_img) +COMPUTE_SOURCE("compositor_smaa_edge_detection.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_smaa_blending_weight_calculation) - .local_group_size(16, 16) - .define("SMAA_GLSL_3") - .define("SMAA_RT_METRICS", - "vec4(1.0 / vec2(textureSize(edges_tx, 0)), vec2(textureSize(edges_tx, 0)))") - .define("SMAA_CORNER_ROUNDING", "smaa_corner_rounding") - .push_constant(Type::INT, "smaa_corner_rounding") - .sampler(0, ImageType::FLOAT_2D, "edges_tx") - .sampler(1, ImageType::FLOAT_2D, "area_tx") - .sampler(2, ImageType::FLOAT_2D, "search_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "weights_img") - .compute_source("compositor_smaa_blending_weight_calculation.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +DEFINE("SMAA_GLSL_3") +DEFINE_VALUE("SMAA_RT_METRICS", + "vec4(1.0 / vec2(textureSize(edges_tx, 0)), vec2(textureSize(edges_tx, 0)))") +DEFINE_VALUE("SMAA_CORNER_ROUNDING", "smaa_corner_rounding") +PUSH_CONSTANT(INT, smaa_corner_rounding) +SAMPLER(0, FLOAT_2D, edges_tx) +SAMPLER(1, FLOAT_2D, area_tx) +SAMPLER(2, FLOAT_2D, search_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, weights_img) +COMPUTE_SOURCE("compositor_smaa_blending_weight_calculation.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_smaa_neighborhood_blending_shared) - .local_group_size(16, 16) - .define("SMAA_GLSL_3") - .define("SMAA_RT_METRICS", - "vec4(1.0 / vec2(textureSize(input_tx, 0)), vec2(textureSize(input_tx, 0)))") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .compute_source("compositor_smaa_neighborhood_blending.glsl"); +LOCAL_GROUP_SIZE(16, 16) +DEFINE("SMAA_GLSL_3") +DEFINE_VALUE("SMAA_RT_METRICS", + "vec4(1.0 / vec2(textureSize(input_tx, 0)), vec2(textureSize(input_tx, 0)))") +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +COMPUTE_SOURCE("compositor_smaa_neighborhood_blending.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_smaa_neighborhood_blending_float4) - .additional_info("compositor_smaa_neighborhood_blending_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_smaa_neighborhood_blending_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_smaa_neighborhood_blending_float2) - .additional_info("compositor_smaa_neighborhood_blending_shared") - .image(0, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_smaa_neighborhood_blending_shared) +IMAGE(0, GPU_RG16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_smaa_neighborhood_blending_float) - .additional_info("compositor_smaa_neighborhood_blending_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_smaa_neighborhood_blending_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_split_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_split_info.hh index 0529a8469f2..863e2244ac0 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_split_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_split_info.hh @@ -5,19 +5,22 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_split_shared) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "split_ratio") - .sampler(0, ImageType::FLOAT_2D, "first_image_tx") - .sampler(1, ImageType::FLOAT_2D, "second_image_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_split.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, split_ratio) +SAMPLER(0, FLOAT_2D, first_image_tx) +SAMPLER(1, FLOAT_2D, second_image_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_split.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_split_horizontal) - .additional_info("compositor_split_shared") - .define("SPLIT_HORIZONTAL") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_split_shared) +DEFINE("SPLIT_HORIZONTAL") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_split_vertical) - .additional_info("compositor_split_shared") - .define("SPLIT_VERTICAL") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_split_shared) +DEFINE("SPLIT_VERTICAL") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_summed_area_table_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_summed_area_table_info.hh index 497fd2ea86d..56937b24e26 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_summed_area_table_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_summed_area_table_info.hh @@ -5,52 +5,60 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_incomplete_prologues_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "incomplete_x_prologues_img") - .image(1, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "incomplete_y_prologues_img") - .compute_source("compositor_summed_area_table_compute_incomplete_prologues.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, incomplete_x_prologues_img) +IMAGE(1, GPU_RGBA32F, WRITE, FLOAT_2D, incomplete_y_prologues_img) +COMPUTE_SOURCE("compositor_summed_area_table_compute_incomplete_prologues.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_incomplete_prologues_identity) - .additional_info("compositor_summed_area_table_compute_incomplete_prologues_shared") - .define("OPERATION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_summed_area_table_compute_incomplete_prologues_shared) +DEFINE_VALUE("OPERATION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_incomplete_prologues_square) - .additional_info("compositor_summed_area_table_compute_incomplete_prologues_shared") - .define("OPERATION(value)", "value * value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_summed_area_table_compute_incomplete_prologues_shared) +DEFINE_VALUE("OPERATION(value)", "value * value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_complete_x_prologues) - .local_group_size(16) - .sampler(0, ImageType::FLOAT_2D, "incomplete_x_prologues_tx") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "complete_x_prologues_img") - .image(1, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "complete_x_prologues_sum_img") - .compute_source("compositor_summed_area_table_compute_complete_x_prologues.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +SAMPLER(0, FLOAT_2D, incomplete_x_prologues_tx) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, complete_x_prologues_img) +IMAGE(1, GPU_RGBA32F, WRITE, FLOAT_2D, complete_x_prologues_sum_img) +COMPUTE_SOURCE("compositor_summed_area_table_compute_complete_x_prologues.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_complete_y_prologues) - .local_group_size(16) - .sampler(0, ImageType::FLOAT_2D, "incomplete_y_prologues_tx") - .sampler(1, ImageType::FLOAT_2D, "complete_x_prologues_sum_tx") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "complete_y_prologues_img") - .compute_source("compositor_summed_area_table_compute_complete_y_prologues.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16) +SAMPLER(0, FLOAT_2D, incomplete_y_prologues_tx) +SAMPLER(1, FLOAT_2D, complete_x_prologues_sum_tx) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, complete_y_prologues_img) +COMPUTE_SOURCE("compositor_summed_area_table_compute_complete_y_prologues.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_complete_blocks_shared) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "complete_x_prologues_tx") - .sampler(2, ImageType::FLOAT_2D, "complete_y_prologues_tx") - .image(0, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_summed_area_table_compute_complete_blocks.glsl"); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, complete_x_prologues_tx) +SAMPLER(2, FLOAT_2D, complete_y_prologues_tx) +IMAGE(0, GPU_RGBA32F, READ_WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_summed_area_table_compute_complete_blocks.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_complete_blocks_identity) - .additional_info("compositor_summed_area_table_compute_complete_blocks_shared") - .define("OPERATION(value)", "value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_summed_area_table_compute_complete_blocks_shared) +DEFINE_VALUE("OPERATION(value)", "value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_summed_area_table_compute_complete_blocks_square) - .additional_info("compositor_summed_area_table_compute_complete_blocks_shared") - .define("OPERATION(value)", "value * value") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_summed_area_table_compute_complete_blocks_shared) +DEFINE_VALUE("OPERATION(value)", "value * value") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_sun_beams_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_sun_beams_info.hh index f6203e4a39f..227ec2d2639 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_sun_beams_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_sun_beams_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_sun_beams) - .local_group_size(16, 16) - .push_constant(Type::VEC2, "source") - .push_constant(Type::INT, "max_steps") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_sun_beams.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(VEC2, source) +PUSH_CONSTANT(INT, max_steps) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_sun_beams.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_info.hh index 8719e6277b1..08babaaeb74 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_symmetric_blur) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "extend_bounds") - .push_constant(Type::BOOL, "gamma_correct") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_symmetric_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, extend_bounds) +PUSH_CONSTANT(BOOL, gamma_correct) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_symmetric_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_variable_size_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_variable_size_info.hh index 76ea55d2851..af5e6626c2b 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_variable_size_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_blur_variable_size_info.hh @@ -5,12 +5,13 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_symmetric_blur_variable_size) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "extend_bounds") - .push_constant(Type::BOOL, "gamma_correct") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_2D, "weights_tx") - .sampler(2, ImageType::FLOAT_2D, "size_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_symmetric_blur_variable_size.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, extend_bounds) +PUSH_CONSTANT(BOOL, gamma_correct) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_2D, weights_tx) +SAMPLER(2, FLOAT_2D, size_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_symmetric_blur_variable_size.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_info.hh index 7a11dfad94b..7f112c6a349 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_info.hh @@ -5,25 +5,29 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_shared) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "extend_bounds") - .push_constant(Type::BOOL, "gamma_correct_input") - .push_constant(Type::BOOL, "gamma_uncorrect_output") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_1D, "weights_tx") - .compute_source("compositor_symmetric_separable_blur.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, extend_bounds) +PUSH_CONSTANT(BOOL, gamma_correct_input) +PUSH_CONSTANT(BOOL, gamma_uncorrect_output) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_1D, weights_tx) +COMPUTE_SOURCE("compositor_symmetric_separable_blur.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_float) - .additional_info("compositor_symmetric_separable_blur_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_float2) - .additional_info("compositor_symmetric_separable_blur_shared") - .image(0, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_shared) +IMAGE(0, GPU_RG16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_float4) - .additional_info("compositor_symmetric_separable_blur_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_variable_size_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_variable_size_info.hh index 1528c111b0e..162bfe51762 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_variable_size_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_symmetric_separable_blur_variable_size_info.hh @@ -5,24 +5,28 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_variable_size_shared) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "is_vertical_pass") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .sampler(1, ImageType::FLOAT_1D, "weights_tx") - .sampler(2, ImageType::FLOAT_2D, "radius_tx") - .compute_source("compositor_symmetric_separable_blur_variable_size.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, is_vertical_pass) +SAMPLER(0, FLOAT_2D, input_tx) +SAMPLER(1, FLOAT_1D, weights_tx) +SAMPLER(2, FLOAT_2D, radius_tx) +COMPUTE_SOURCE("compositor_symmetric_separable_blur_variable_size.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_variable_size_float) - .additional_info("compositor_symmetric_separable_blur_variable_size_shared") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_variable_size_shared) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_variable_size_float2) - .additional_info("compositor_symmetric_separable_blur_variable_size_shared") - .image(0, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_variable_size_shared) +IMAGE(0, GPU_RG16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_symmetric_separable_blur_variable_size_float4) - .additional_info("compositor_symmetric_separable_blur_variable_size_shared") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_symmetric_separable_blur_variable_size_shared) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_photoreceptor_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_photoreceptor_info.hh index fa8bf78bf2e..6a7668e6bc5 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_photoreceptor_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_photoreceptor_info.hh @@ -5,14 +5,15 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_tone_map_photoreceptor) - .local_group_size(16, 16) - .push_constant(Type::VEC4, "global_adaptation_level") - .push_constant(Type::FLOAT, "contrast") - .push_constant(Type::FLOAT, "intensity") - .push_constant(Type::FLOAT, "chromatic_adaptation") - .push_constant(Type::FLOAT, "light_adaptation") - .push_constant(Type::VEC3, "luminance_coefficients") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_tone_map_photoreceptor.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(VEC4, global_adaptation_level) +PUSH_CONSTANT(FLOAT, contrast) +PUSH_CONSTANT(FLOAT, intensity) +PUSH_CONSTANT(FLOAT, chromatic_adaptation) +PUSH_CONSTANT(FLOAT, light_adaptation) +PUSH_CONSTANT(VEC3, luminance_coefficients) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_tone_map_photoreceptor.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_simple_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_simple_info.hh index d5c56e22073..2dfde065581 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_simple_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_tone_map_simple_info.hh @@ -5,11 +5,12 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_tone_map_simple) - .local_group_size(16, 16) - .push_constant(Type::FLOAT, "luminance_scale") - .push_constant(Type::FLOAT, "luminance_scale_blend_factor") - .push_constant(Type::FLOAT, "inverse_gamma") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_tone_map_simple.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(FLOAT, luminance_scale) +PUSH_CONSTANT(FLOAT, luminance_scale_blend_factor) +PUSH_CONSTANT(FLOAT, inverse_gamma) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_tone_map_simple.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_van_vliet_gaussian_blur_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_van_vliet_gaussian_blur_info.hh index 9c5737257d7..243aeacc83a 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_van_vliet_gaussian_blur_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_van_vliet_gaussian_blur_info.hh @@ -5,31 +5,33 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_van_vliet_gaussian_blur) - .local_group_size(64, 4) - .push_constant(Type::VEC2, "first_feedback_coefficients") - .push_constant(Type::VEC2, "first_causal_feedforward_coefficients") - .push_constant(Type::VEC2, "first_non_causal_feedforward_coefficients") - .push_constant(Type::VEC2, "second_feedback_coefficients") - .push_constant(Type::VEC2, "second_causal_feedforward_coefficients") - .push_constant(Type::VEC2, "second_non_causal_feedforward_coefficients") - .push_constant(Type::FLOAT, "first_causal_boundary_coefficient") - .push_constant(Type::FLOAT, "first_non_causal_boundary_coefficient") - .push_constant(Type::FLOAT, "second_causal_boundary_coefficient") - .push_constant(Type::FLOAT, "second_non_causal_boundary_coefficient") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "first_causal_output_img") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "first_non_causal_output_img") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "second_causal_output_img") - .image(3, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "second_non_causal_output_img") - .compute_source("compositor_van_vliet_gaussian_blur.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(64, 4) +PUSH_CONSTANT(VEC2, first_feedback_coefficients) +PUSH_CONSTANT(VEC2, first_causal_feedforward_coefficients) +PUSH_CONSTANT(VEC2, first_non_causal_feedforward_coefficients) +PUSH_CONSTANT(VEC2, second_feedback_coefficients) +PUSH_CONSTANT(VEC2, second_causal_feedforward_coefficients) +PUSH_CONSTANT(VEC2, second_non_causal_feedforward_coefficients) +PUSH_CONSTANT(FLOAT, first_causal_boundary_coefficient) +PUSH_CONSTANT(FLOAT, first_non_causal_boundary_coefficient) +PUSH_CONSTANT(FLOAT, second_causal_boundary_coefficient) +PUSH_CONSTANT(FLOAT, second_non_causal_boundary_coefficient) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, first_causal_output_img) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D, first_non_causal_output_img) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, second_causal_output_img) +IMAGE(3, GPU_RGBA16F, WRITE, FLOAT_2D, second_non_causal_output_img) +COMPUTE_SOURCE("compositor_van_vliet_gaussian_blur.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_van_vliet_gaussian_blur_sum) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "first_causal_input_tx") - .sampler(1, ImageType::FLOAT_2D, "first_non_causal_input_tx") - .sampler(2, ImageType::FLOAT_2D, "second_causal_input_tx") - .sampler(3, ImageType::FLOAT_2D, "second_non_causal_input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_van_vliet_gaussian_blur_sum.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, first_causal_input_tx) +SAMPLER(1, FLOAT_2D, first_non_causal_input_tx) +SAMPLER(2, FLOAT_2D, second_causal_input_tx) +SAMPLER(3, FLOAT_2D, second_non_causal_input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_van_vliet_gaussian_blur_sum.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh index cf4b32d5a8e..ae9064cf0bf 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh @@ -5,25 +5,29 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_write_output_shared) - .local_group_size(16, 16) - .push_constant(Type::IVEC2, "lower_bound") - .push_constant(Type::IVEC2, "upper_bound") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("compositor_write_output.glsl"); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(IVEC2, lower_bound) +PUSH_CONSTANT(IVEC2, upper_bound) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("compositor_write_output.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_write_output) - .additional_info("compositor_write_output_shared") - .define("DIRECT_OUTPUT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_write_output_shared) +DEFINE("DIRECT_OUTPUT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_write_output_opaque) - .additional_info("compositor_write_output_shared") - .define("OPAQUE_OUTPUT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_write_output_shared) +DEFINE("OPAQUE_OUTPUT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_write_output_alpha) - .additional_info("compositor_write_output_shared") - .sampler(1, ImageType::FLOAT_2D, "alpha_tx") - .define("ALPHA_OUTPUT") - .do_static_compilation(true); +ADDITIONAL_INFO(compositor_write_output_shared) +SAMPLER(1, FLOAT_2D, alpha_tx) +DEFINE("ALPHA_OUTPUT") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_z_combine_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_z_combine_info.hh index 31043c7d354..925f01b945a 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_z_combine_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_z_combine_info.hh @@ -5,34 +5,37 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(compositor_z_combine_simple) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "use_alpha") - .sampler(0, ImageType::FLOAT_2D, "first_tx") - .sampler(1, ImageType::FLOAT_2D, "first_z_tx") - .sampler(2, ImageType::FLOAT_2D, "second_tx") - .sampler(3, ImageType::FLOAT_2D, "second_z_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "combined_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "combined_z_img") - .compute_source("compositor_z_combine_simple.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, use_alpha) +SAMPLER(0, FLOAT_2D, first_tx) +SAMPLER(1, FLOAT_2D, first_z_tx) +SAMPLER(2, FLOAT_2D, second_tx) +SAMPLER(3, FLOAT_2D, second_z_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, combined_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, combined_z_img) +COMPUTE_SOURCE("compositor_z_combine_simple.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_z_combine_compute_mask) - .local_group_size(16, 16) - .sampler(0, ImageType::FLOAT_2D, "first_z_tx") - .sampler(1, ImageType::FLOAT_2D, "second_z_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "mask_img") - .compute_source("compositor_z_combine_compute_mask.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +SAMPLER(0, FLOAT_2D, first_z_tx) +SAMPLER(1, FLOAT_2D, second_z_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, mask_img) +COMPUTE_SOURCE("compositor_z_combine_compute_mask.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(compositor_z_combine_from_mask) - .local_group_size(16, 16) - .push_constant(Type::BOOL, "use_alpha") - .sampler(0, ImageType::FLOAT_2D, "first_tx") - .sampler(1, ImageType::FLOAT_2D, "first_z_tx") - .sampler(2, ImageType::FLOAT_2D, "second_tx") - .sampler(3, ImageType::FLOAT_2D, "second_z_tx") - .sampler(4, ImageType::FLOAT_2D, "mask_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "combined_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "combined_z_img") - .compute_source("compositor_z_combine_from_mask.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16) +PUSH_CONSTANT(BOOL, use_alpha) +SAMPLER(0, FLOAT_2D, first_tx) +SAMPLER(1, FLOAT_2D, first_z_tx) +SAMPLER(2, FLOAT_2D, second_tx) +SAMPLER(3, FLOAT_2D, second_z_tx) +SAMPLER(4, FLOAT_2D, mask_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, combined_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, combined_z_img) +COMPUTE_SOURCE("compositor_z_combine_from_mask.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh b/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh index a9f3f6b90c3..37592faee9c 100644 --- a/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh +++ b/source/blender/draw/engines/basic/shaders/infos/basic_depth_info.hh @@ -11,8 +11,9 @@ * \{ */ GPU_SHADER_CREATE_INFO(basic_conservative) - .geometry_layout(PrimitiveIn::TRIANGLES, PrimitiveOut::TRIANGLE_STRIP, 3) - .geometry_source("basic_conservative_depth_geom.glsl"); +GEOMETRY_LAYOUT(PrimitiveIn::TRIANGLES, PrimitiveOut::TRIANGLE_STRIP, 3) +GEOMETRY_SOURCE("basic_conservative_depth_geom.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -21,28 +22,33 @@ GPU_SHADER_CREATE_INFO(basic_conservative) * \{ */ GPU_SHADER_CREATE_INFO(basic_mesh) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("basic_depth_vert.glsl") - .additional_info("draw_mesh"); +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("basic_depth_vert.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(basic_pointcloud) - .vertex_source("basic_depth_pointcloud_vert.glsl") - .additional_info("draw_pointcloud"); +VERTEX_SOURCE("basic_depth_pointcloud_vert.glsl") +ADDITIONAL_INFO(draw_pointcloud) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(basic_curves) - .vertex_source("basic_depth_curves_vert.glsl") - .additional_info("draw_hair"); +VERTEX_SOURCE("basic_depth_curves_vert.glsl") +ADDITIONAL_INFO(draw_hair) +GPU_SHADER_CREATE_END() /* Geometry-shader alternative paths. */ GPU_SHADER_CREATE_INFO(basic_mesh_conservative_no_geom) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("basic_depth_vert_conservative_no_geom.glsl") - .additional_info("draw_mesh"); +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("basic_depth_vert_conservative_no_geom.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(basic_pointcloud_conservative_no_geom) - .define("CONSERVATIVE_RASTER") - .vertex_source("basic_depth_pointcloud_vert.glsl") - .additional_info("draw_pointcloud"); +DEFINE("CONSERVATIVE_RASTER") +VERTEX_SOURCE("basic_depth_pointcloud_vert.glsl") +ADDITIONAL_INFO(draw_pointcloud) +GPU_SHADER_CREATE_END() /** \} */ @@ -50,22 +56,19 @@ GPU_SHADER_CREATE_INFO(basic_pointcloud_conservative_no_geom) /** \name Variations Declaration * \{ */ -#define BASIC_FINAL_VARIATION(name, ...) \ - GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); - #define BASIC_CLIPPING_VARIATIONS(prefix, ...) \ - BASIC_FINAL_VARIATION(prefix##_clipped, "drw_clipped", __VA_ARGS__) \ - BASIC_FINAL_VARIATION(prefix, __VA_ARGS__) + CREATE_INFO_VARIANT(prefix##_clipped, drw_clipped, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix, __VA_ARGS__) #define BASIC_CONSERVATIVE_VARIATIONS(prefix, ...) \ - BASIC_CLIPPING_VARIATIONS(prefix##_conservative, "basic_conservative", __VA_ARGS__) \ + BASIC_CLIPPING_VARIATIONS(prefix##_conservative, basic_conservative, __VA_ARGS__) \ BASIC_CLIPPING_VARIATIONS(prefix##_conservative_no_geom, __VA_ARGS__) \ BASIC_CLIPPING_VARIATIONS(prefix, __VA_ARGS__) #define BASIC_OBTYPE_VARIATIONS(prefix, ...) \ - BASIC_CONSERVATIVE_VARIATIONS(prefix##_mesh, "basic_mesh", __VA_ARGS__) \ - BASIC_CONSERVATIVE_VARIATIONS(prefix##_pointcloud, "basic_pointcloud", __VA_ARGS__) \ - BASIC_CLIPPING_VARIATIONS(prefix##_curves, "basic_curves", __VA_ARGS__) + BASIC_CONSERVATIVE_VARIATIONS(prefix##_mesh, basic_mesh, __VA_ARGS__) \ + BASIC_CONSERVATIVE_VARIATIONS(prefix##_pointcloud, basic_pointcloud, __VA_ARGS__) \ + BASIC_CLIPPING_VARIATIONS(prefix##_curves, basic_curves, __VA_ARGS__) /** \} */ @@ -73,8 +76,10 @@ GPU_SHADER_CREATE_INFO(basic_pointcloud_conservative_no_geom) /** \name Depth shader types. * \{ */ -GPU_SHADER_CREATE_INFO(basic_depth).fragment_source("basic_depth_frag.glsl"); +GPU_SHADER_CREATE_INFO(basic_depth) +FRAGMENT_SOURCE("basic_depth_frag.glsl") +GPU_SHADER_CREATE_END() -BASIC_OBTYPE_VARIATIONS(basic_depth, "basic_depth", "draw_globals"); +BASIC_OBTYPE_VARIATIONS(basic_depth, basic_depth, draw_globals) /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index 7ec33874e62..89707cec234 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -8,7 +8,14 @@ * language. */ -#ifndef USE_GPU_SHADER_CREATE_INFO +/* __cplusplus is true when compiling with MSL, so ensure we are not inside a shader. */ +#if defined(GPU_SHADER) || defined(GLSL_CPP_STUBS) +# define IS_CPP 0 +#else +# define IS_CPP 1 +#endif + +#if IS_CPP # pragma once # include "BLI_math_bits.h" @@ -34,13 +41,6 @@ constexpr GPUSamplerState no_filter = GPUSamplerState::default_sampler(); constexpr GPUSamplerState with_filter = {GPU_SAMPLER_FILTERING_LINEAR}; #endif -/* __cplusplus is true when compiling with MSL, so ensure we are not inside a shader. */ -#ifdef GPU_SHADER -# define IS_CPP 0 -#else -# define IS_CPP 1 -#endif - /** WORKAROUND(@fclem): This is because this file is included before common_math_lib.glsl. */ #ifndef M_PI # define EEVEE_PI diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_gbuffer_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_gbuffer_lib.glsl index ee98a9a99af..256e254c36c 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_gbuffer_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_gbuffer_lib.glsl @@ -113,7 +113,7 @@ ClosureType gbuffer_mode_to_closure_type(uint mode) * This allows for writing unit tests that read and write during the same shader invocation. * \{ */ -#ifdef GBUFFER_LOAD +#if defined(GBUFFER_LOAD) || defined(GLSL_CPP_STUBS) /* Read only shader. Use correct types and functions. */ # define samplerGBufferHeader usampler2D # define samplerGBufferClosure sampler2DArray diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh index 59f5d9222ed..7150b22a7b8 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh @@ -6,19 +6,20 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_ambient_occlusion_pass) - .define("HORIZON_OCCLUSION") - .compute_source("eevee_ambient_occlusion_pass_comp.glsl") - .local_group_size(AMBIENT_OCCLUSION_PASS_TILE_SIZE, AMBIENT_OCCLUSION_PASS_TILE_SIZE) - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "in_normal_img") - .push_constant(Type::INT, "in_normal_img_layer_index") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_ao_img") - .push_constant(Type::INT, "out_ao_img_layer_index") - .specialization_constant(Type::INT, "ao_slice_count", 2) - .specialization_constant(Type::INT, "ao_step_count", 8) - .additional_info("draw_view", - "eevee_shared", - "eevee_hiz_data", - "eevee_sampling_data", - "eevee_utility_texture", - "eevee_global_ubo") - .do_static_compilation(true); +DEFINE("HORIZON_OCCLUSION") +COMPUTE_SOURCE("eevee_ambient_occlusion_pass_comp.glsl") +LOCAL_GROUP_SIZE(AMBIENT_OCCLUSION_PASS_TILE_SIZE, AMBIENT_OCCLUSION_PASS_TILE_SIZE) +IMAGE(0, GPU_RGBA16F, READ, FLOAT_2D_ARRAY, in_normal_img) +PUSH_CONSTANT(INT, in_normal_img_layer_index) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D_ARRAY, out_ao_img) +PUSH_CONSTANT(INT, out_ao_img_layer_index) +SPECIALIZATION_CONSTANT(INT, ao_slice_count, 2) +SPECIALIZATION_CONSTANT(INT, ao_step_count, 8) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_global_ubo) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh index 9588e6f5b3b..48a7e3eb4e7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh @@ -19,148 +19,159 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_deferred_thickness_amend) - .do_static_compilation(true) - .define("GBUFFER_LOAD") - .sampler(0, ImageType::UINT_2D, "gbuf_header_tx") - .image(0, GPU_RG16, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "gbuf_normal_img") - /* Early fragment test is needed to discard fragment that do not need this processing. */ - .early_fragment_test(true) - .fragment_source("eevee_deferred_thickness_amend_frag.glsl") - .additional_info("draw_view", - "draw_fullscreen", - "eevee_sampling_data", - "eevee_shared", - "eevee_light_data", - "eevee_shadow_data", - "eevee_hiz_data"); +DO_STATIC_COMPILATION() +DEFINE("GBUFFER_LOAD") +SAMPLER(0, UINT_2D, gbuf_header_tx) +IMAGE(0, GPU_RG16, READ_WRITE, FLOAT_2D_ARRAY, gbuf_normal_img) +/* Early fragment test is needed to discard fragment that do not need this processing. */ +EARLY_FRAGMENT_TEST(true) +FRAGMENT_SOURCE("eevee_deferred_thickness_amend_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_hiz_data) +GPU_SHADER_CREATE_END() /** \} */ GPU_SHADER_CREATE_INFO(eevee_gbuffer_data) - .define("GBUFFER_LOAD") - .sampler(12, ImageType::UINT_2D, "gbuf_header_tx") - .sampler(13, ImageType::FLOAT_2D_ARRAY, "gbuf_closure_tx") - .sampler(14, ImageType::FLOAT_2D_ARRAY, "gbuf_normal_tx"); +DEFINE("GBUFFER_LOAD") +SAMPLER(12, UINT_2D, gbuf_header_tx) +SAMPLER(13, FLOAT_2D_ARRAY, gbuf_closure_tx) +SAMPLER(14, FLOAT_2D_ARRAY, gbuf_normal_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_tile_classify) - .fragment_source("eevee_deferred_tile_classify_frag.glsl") - .additional_info("eevee_shared", "draw_fullscreen") - .subpass_in(1, Type::UINT, "in_gbuffer_header", DEFERRED_GBUFFER_ROG_ID) - .typedef_source("draw_shader_shared.hh") - .push_constant(Type::INT, "current_bit") - .do_static_compilation(true); +FRAGMENT_SOURCE("eevee_deferred_tile_classify_frag.glsl") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_fullscreen) +SUBPASS_IN(1, UINT, in_gbuffer_header, DEFERRED_GBUFFER_ROG_ID) +TYPEDEF_SOURCE("draw_shader_shared.hh") +PUSH_CONSTANT(INT, current_bit) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_light) - .fragment_source("eevee_deferred_light_frag.glsl") - /* Early fragment test is needed to avoid processing background fragments. */ - .early_fragment_test(true) - .fragment_out(0, Type::VEC4, "out_combined") - /* Chaining to next pass. */ - .uimage_out(2, DEFERRED_RADIANCE_FORMAT, "direct_radiance_1_img") - .uimage_out(3, DEFERRED_RADIANCE_FORMAT, "direct_radiance_2_img") - .uimage_out(4, DEFERRED_RADIANCE_FORMAT, "direct_radiance_3_img") - /* Optimized out if use_split_indirect is false. */ - .image_out(5, RAYTRACE_RADIANCE_FORMAT, "indirect_radiance_1_img") - .image_out(6, RAYTRACE_RADIANCE_FORMAT, "indirect_radiance_2_img") - .image_out(7, RAYTRACE_RADIANCE_FORMAT, "indirect_radiance_3_img") - .specialization_constant(Type::BOOL, "use_split_indirect", false) - .specialization_constant(Type::BOOL, "use_lightprobe_eval", false) - .specialization_constant(Type::BOOL, "use_transmission", false) - .specialization_constant(Type::INT, "render_pass_shadow_id", -1) - .define("SPECIALIZED_SHADOW_PARAMS") - .specialization_constant(Type::INT, "shadow_ray_count", 1) - .specialization_constant(Type::INT, "shadow_ray_step_count", 6) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_utility_texture", - "eevee_sampling_data", - "eevee_light_data", - "eevee_shadow_data", - "eevee_hiz_data", - "eevee_lightprobe_data", - "eevee_render_pass_out", - "draw_fullscreen", - "draw_view"); +FRAGMENT_SOURCE("eevee_deferred_light_frag.glsl") +/* Early fragment test is needed to avoid processing background fragments. */ +EARLY_FRAGMENT_TEST(true) +FRAGMENT_OUT(0, VEC4, out_combined) +/* Chaining to next pass. */ +IMAGE_FREQ(2, DEFERRED_RADIANCE_FORMAT, WRITE, UINT_2D, direct_radiance_1_img, PASS) +IMAGE_FREQ(3, DEFERRED_RADIANCE_FORMAT, WRITE, UINT_2D, direct_radiance_2_img, PASS) +IMAGE_FREQ(4, DEFERRED_RADIANCE_FORMAT, WRITE, UINT_2D, direct_radiance_3_img, PASS) +/* Optimized out if use_split_indirect is false. */ +IMAGE_FREQ(5, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, indirect_radiance_1_img, PASS) +IMAGE_FREQ(6, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, indirect_radiance_2_img, PASS) +IMAGE_FREQ(7, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, indirect_radiance_3_img, PASS) +SPECIALIZATION_CONSTANT(BOOL, use_split_indirect, false) +SPECIALIZATION_CONSTANT(BOOL, use_lightprobe_eval, false) +SPECIALIZATION_CONSTANT(BOOL, use_transmission, false) +SPECIALIZATION_CONSTANT(INT, render_pass_shadow_id, -1) +DEFINE("SPECIALIZED_SHADOW_PARAMS") +SPECIALIZATION_CONSTANT(INT, shadow_ray_count, 1) +SPECIALIZATION_CONSTANT(INT, shadow_ray_step_count, 6) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_render_pass_out) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_light_single) - .additional_info("eevee_deferred_light") - .define("LIGHT_CLOSURE_EVAL_COUNT", "1") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_deferred_light) +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "1") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_light_double) - .additional_info("eevee_deferred_light") - .define("LIGHT_CLOSURE_EVAL_COUNT", "2") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_deferred_light) +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "2") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_light_triple) - .additional_info("eevee_deferred_light") - .define("LIGHT_CLOSURE_EVAL_COUNT", "3") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_deferred_light) +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "3") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_combine) - /* Early fragment test is needed to avoid processing fragments background fragments. */ - .early_fragment_test(true) - /* Inputs. */ - .sampler(2, ImageType::UINT_2D, "direct_radiance_1_tx") - .sampler(3, ImageType::UINT_2D, "direct_radiance_2_tx") - .sampler(4, ImageType::UINT_2D, "direct_radiance_3_tx") - .sampler(5, ImageType::FLOAT_2D, "indirect_radiance_1_tx") - .sampler(6, ImageType::FLOAT_2D, "indirect_radiance_2_tx") - .sampler(7, ImageType::FLOAT_2D, "indirect_radiance_3_tx") - .image(5, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "radiance_feedback_img") - .fragment_out(0, Type::VEC4, "out_combined") - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_render_pass_out", - "draw_fullscreen") - .fragment_source("eevee_deferred_combine_frag.glsl") - /* NOTE: Both light IDs have a valid specialized assignment of '-1' so only when default is - * present will we instead dynamically look-up ID from the uniform buffer. */ - .specialization_constant(Type::BOOL, "render_pass_diffuse_light_enabled", true) - .specialization_constant(Type::BOOL, "render_pass_specular_light_enabled", true) - .specialization_constant(Type::BOOL, "render_pass_normal_enabled", true) - .specialization_constant(Type::BOOL, "use_radiance_feedback", false) - .specialization_constant(Type::BOOL, "use_split_radiance", false) - .do_static_compilation(true); +/* Early fragment test is needed to avoid processing fragments background fragments. */ +EARLY_FRAGMENT_TEST(true) +/* Inputs. */ +SAMPLER(2, UINT_2D, direct_radiance_1_tx) +SAMPLER(3, UINT_2D, direct_radiance_2_tx) +SAMPLER(4, UINT_2D, direct_radiance_3_tx) +SAMPLER(5, FLOAT_2D, indirect_radiance_1_tx) +SAMPLER(6, FLOAT_2D, indirect_radiance_2_tx) +SAMPLER(7, FLOAT_2D, indirect_radiance_3_tx) +IMAGE(5, GPU_RGBA16F, READ_WRITE, FLOAT_2D, radiance_feedback_img) +FRAGMENT_OUT(0, VEC4, out_combined) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_render_pass_out) +ADDITIONAL_INFO(draw_fullscreen) +FRAGMENT_SOURCE("eevee_deferred_combine_frag.glsl") +/* NOTE: Both light IDs have a valid specialized assignment of '-1' so only when default is + * present will we instead dynamically look-up ID from the uniform buffer. */ +SPECIALIZATION_CONSTANT(BOOL, render_pass_diffuse_light_enabled, true) +SPECIALIZATION_CONSTANT(BOOL, render_pass_specular_light_enabled, true) +SPECIALIZATION_CONSTANT(BOOL, render_pass_normal_enabled, true) +SPECIALIZATION_CONSTANT(BOOL, use_radiance_feedback, false) +SPECIALIZATION_CONSTANT(BOOL, use_split_radiance, false) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_capture_eval) - /* Early fragment test is needed to avoid processing fragments without correct GBuffer data. */ - .early_fragment_test(true) - /* Inputs. */ - .fragment_out(0, Type::VEC4, "out_radiance") - .define("LIGHT_CLOSURE_EVAL_COUNT", "1") - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_utility_texture", - "eevee_sampling_data", - "eevee_light_data", - "eevee_shadow_data", - "eevee_hiz_data", - "eevee_volume_probe_data", - "draw_view", - "draw_fullscreen") - .fragment_source("eevee_deferred_capture_frag.glsl") - .do_static_compilation(true); +/* Early fragment test is needed to avoid processing fragments without correct GBuffer data. */ +EARLY_FRAGMENT_TEST(true) +/* Inputs. */ +FRAGMENT_OUT(0, VEC4, out_radiance) +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "1") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_volume_probe_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_fullscreen) +FRAGMENT_SOURCE("eevee_deferred_capture_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_deferred_planar_eval) - /* Early fragment test is needed to avoid processing fragments without correct GBuffer data. */ - .early_fragment_test(true) - /* Inputs. */ - .fragment_out(0, Type::VEC4, "out_radiance") - .define("SPHERE_PROBE") - .define("LIGHT_CLOSURE_EVAL_COUNT", "1") - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_utility_texture", - "eevee_sampling_data", - "eevee_light_data", - "eevee_lightprobe_data", - "eevee_shadow_data", - "eevee_hiz_data", - "draw_view", - "draw_fullscreen") - .fragment_source("eevee_deferred_planar_frag.glsl") - .do_static_compilation(true); +/* Early fragment test is needed to avoid processing fragments without correct GBuffer data. */ +EARLY_FRAGMENT_TEST(true) +/* Inputs. */ +FRAGMENT_OUT(0, VEC4, out_radiance) +DEFINE("SPHERE_PROBE") +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "1") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_fullscreen) +FRAGMENT_SOURCE("eevee_deferred_planar_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() #undef image_array_out #undef image_out @@ -171,11 +182,15 @@ GPU_SHADER_CREATE_INFO(eevee_deferred_planar_eval) * \{ */ GPU_SHADER_CREATE_INFO(eevee_debug_gbuffer) - .do_static_compilation(true) - .fragment_out(0, Type::VEC4, "out_color_add", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_color_mul", DualBlend::SRC_1) - .push_constant(Type::INT, "debug_mode") - .fragment_source("eevee_debug_gbuffer_frag.glsl") - .additional_info("draw_view", "draw_fullscreen", "eevee_shared", "eevee_gbuffer_data"); +DO_STATIC_COMPILATION() +FRAGMENT_OUT_DUAL(0, VEC4, out_color_add, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_color_mul, SRC_1) +PUSH_CONSTANT(INT, debug_mode) +FRAGMENT_SOURCE("eevee_debug_gbuffer_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh index 1ebf21e44bb..bd8814b44c7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh @@ -10,70 +10,81 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_bokeh_lut) - .do_static_compilation(true) - .local_group_size(DOF_BOKEH_LUT_SIZE, DOF_BOKEH_LUT_SIZE) - .additional_info("eevee_shared", "draw_view") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .image(0, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_gather_lut_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_scatter_lut_img") - .image(2, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_resolve_lut_img") - .compute_source("eevee_depth_of_field_bokeh_lut_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_BOKEH_LUT_SIZE, DOF_BOKEH_LUT_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +IMAGE(0, GPU_RG16F, WRITE, FLOAT_2D, out_gather_lut_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, out_scatter_lut_img) +IMAGE(2, GPU_R16F, WRITE, FLOAT_2D, out_resolve_lut_img) +COMPUTE_SOURCE("eevee_depth_of_field_bokeh_lut_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_setup) - .do_static_compilation(true) - .local_group_size(DOF_DEFAULT_GROUP_SIZE, DOF_DEFAULT_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .sampler(0, ImageType::FLOAT_2D, "color_tx") - .sampler(1, ImageType::DEPTH_2D, "depth_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_img") - .compute_source("eevee_depth_of_field_setup_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_DEFAULT_GROUP_SIZE, DOF_DEFAULT_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +SAMPLER(0, FLOAT_2D, color_tx) +SAMPLER(1, DEPTH_2D, depth_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, out_coc_img) +COMPUTE_SOURCE("eevee_depth_of_field_setup_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_stabilize) - .do_static_compilation(true) - .local_group_size(DOF_STABILIZE_GROUP_SIZE, DOF_STABILIZE_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view", "eevee_velocity_camera") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .sampler(0, ImageType::FLOAT_2D, "coc_tx") - .sampler(1, ImageType::FLOAT_2D, "color_tx") - .sampler(2, ImageType::FLOAT_2D, "velocity_tx") - .sampler(3, ImageType::FLOAT_2D, "in_history_tx") - .sampler(4, ImageType::DEPTH_2D, "depth_tx") - .push_constant(Type::BOOL, "u_use_history") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_img") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_history_img") - .compute_source("eevee_depth_of_field_stabilize_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_STABILIZE_GROUP_SIZE, DOF_STABILIZE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_velocity_camera) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +SAMPLER(0, FLOAT_2D, coc_tx) +SAMPLER(1, FLOAT_2D, color_tx) +SAMPLER(2, FLOAT_2D, velocity_tx) +SAMPLER(3, FLOAT_2D, in_history_tx) +SAMPLER(4, DEPTH_2D, depth_tx) +PUSH_CONSTANT(BOOL, u_use_history) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, out_coc_img) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, out_history_img) +COMPUTE_SOURCE("eevee_depth_of_field_stabilize_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_downsample) - .do_static_compilation(true) - .local_group_size(DOF_DEFAULT_GROUP_SIZE, DOF_DEFAULT_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view") - .sampler(0, ImageType::FLOAT_2D, "color_tx") - .sampler(1, ImageType::FLOAT_2D, "coc_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .compute_source("eevee_depth_of_field_downsample_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_DEFAULT_GROUP_SIZE, DOF_DEFAULT_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +SAMPLER(0, FLOAT_2D, color_tx) +SAMPLER(1, FLOAT_2D, coc_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +COMPUTE_SOURCE("eevee_depth_of_field_downsample_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce) - .do_static_compilation(true) - .local_group_size(DOF_REDUCE_GROUP_SIZE, DOF_REDUCE_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .sampler(0, ImageType::FLOAT_2D, "downsample_tx") - .storage_buf(0, Qualifier::WRITE, "ScatterRect", "scatter_fg_list_buf[]") - .storage_buf(1, Qualifier::WRITE, "ScatterRect", "scatter_bg_list_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "DrawCommand", "scatter_fg_indirect_buf") - .storage_buf(3, Qualifier::READ_WRITE, "DrawCommand", "scatter_bg_indirect_buf") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "inout_color_lod0_img") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod1_img") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod2_img") - .image(3, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_lod3_img") - .image(4, GPU_R16F, Qualifier::READ, ImageType::FLOAT_2D, "in_coc_lod0_img") - .image(5, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod1_img") - .image(6, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod2_img") - .image(7, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_coc_lod3_img") - .compute_source("eevee_depth_of_field_reduce_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_REDUCE_GROUP_SIZE, DOF_REDUCE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +SAMPLER(0, FLOAT_2D, downsample_tx) +STORAGE_BUF(0, WRITE, ScatterRect, scatter_fg_list_buf[]) +STORAGE_BUF(1, WRITE, ScatterRect, scatter_bg_list_buf[]) +STORAGE_BUF(2, READ_WRITE, DrawCommand, scatter_fg_indirect_buf) +STORAGE_BUF(3, READ_WRITE, DrawCommand, scatter_bg_indirect_buf) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, inout_color_lod0_img) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_lod1_img) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_lod2_img) +IMAGE(3, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_lod3_img) +IMAGE(4, GPU_R16F, READ, FLOAT_2D, in_coc_lod0_img) +IMAGE(5, GPU_R16F, WRITE, FLOAT_2D, out_coc_lod1_img) +IMAGE(6, GPU_R16F, WRITE, FLOAT_2D, out_coc_lod2_img) +IMAGE(7, GPU_R16F, WRITE, FLOAT_2D, out_coc_lod3_img) +COMPUTE_SOURCE("eevee_depth_of_field_reduce_comp.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -82,36 +93,44 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_reduce) * \{ */ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_flatten) - .do_static_compilation(true) - .local_group_size(DOF_TILES_FLATTEN_GROUP_SIZE, DOF_TILES_FLATTEN_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view") - .sampler(0, ImageType::FLOAT_2D, "coc_tx") - .image(2, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_fg_img") - .image(3, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_bg_img") - .compute_source("eevee_depth_of_field_tiles_flatten_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_TILES_FLATTEN_GROUP_SIZE, DOF_TILES_FLATTEN_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +SAMPLER(0, FLOAT_2D, coc_tx) +IMAGE(2, GPU_R11F_G11F_B10F, WRITE, FLOAT_2D, out_tiles_fg_img) +IMAGE(3, GPU_R11F_G11F_B10F, WRITE, FLOAT_2D, out_tiles_bg_img) +COMPUTE_SOURCE("eevee_depth_of_field_tiles_flatten_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate) - .additional_info("eevee_shared", "draw_view", "eevee_depth_of_field_tiles_common") - .local_group_size(DOF_TILES_DILATE_GROUP_SIZE, DOF_TILES_DILATE_GROUP_SIZE) - .image(2, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_fg_img") - .image(3, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_bg_img") - .push_constant(Type::INT, "ring_count") - .push_constant(Type::INT, "ring_width_multiplier") - .compute_source("eevee_depth_of_field_tiles_dilate_comp.glsl"); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_depth_of_field_tiles_common) +LOCAL_GROUP_SIZE(DOF_TILES_DILATE_GROUP_SIZE, DOF_TILES_DILATE_GROUP_SIZE) +IMAGE(2, GPU_R11F_G11F_B10F, WRITE, FLOAT_2D, out_tiles_fg_img) +IMAGE(3, GPU_R11F_G11F_B10F, WRITE, FLOAT_2D, out_tiles_bg_img) +PUSH_CONSTANT(INT, ring_count) +PUSH_CONSTANT(INT, ring_width_multiplier) +COMPUTE_SOURCE("eevee_depth_of_field_tiles_dilate_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minabs) - .do_static_compilation(true) - .define("DILATE_MODE_MIN_MAX", "false") - .additional_info("eevee_depth_of_field_tiles_dilate"); +DO_STATIC_COMPILATION() +DEFINE_VALUE("DILATE_MODE_MIN_MAX", "false") +ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_dilate_minmax) - .do_static_compilation(true) - .define("DILATE_MODE_MIN_MAX", "true") - .additional_info("eevee_depth_of_field_tiles_dilate"); +DO_STATIC_COMPILATION() +DEFINE_VALUE("DILATE_MODE_MIN_MAX", "true") +ADDITIONAL_INFO(eevee_depth_of_field_tiles_dilate) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_common) - .image(0, GPU_R11F_G11F_B10F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_fg_img") - .image(1, GPU_R11F_G11F_B10F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_bg_img"); +IMAGE(0, GPU_R11F_G11F_B10F, READ, FLOAT_2D, in_tiles_fg_img) +IMAGE(1, GPU_R11F_G11F_B10F, READ, FLOAT_2D, in_tiles_bg_img) +GPU_SHADER_CREATE_END() /** \} */ @@ -120,30 +139,33 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_tiles_common) * \{ */ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_no_lut) - .define("DOF_BOKEH_TEXTURE", "false") - /** - * WORKAROUND(@fclem): This is to keep the code as is for now. The bokeh_lut_tx is referenced - * even if not used after optimization. But we don't want to include it in the create infos. - */ - .define("bokeh_lut_tx", "color_tx"); +DEFINE_VALUE("DOF_BOKEH_TEXTURE", "false") +/** + * WORKAROUND(@fclem): This is to keep the code as is for now. The bokeh_lut_tx is referenced + * even if not used after optimization. But we don't want to include it in the create infos. + */ +DEFINE_VALUE("bokeh_lut_tx", "color_tx") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_lut) - .define("DOF_BOKEH_TEXTURE", "true") - .sampler(5, ImageType::FLOAT_2D, "bokeh_lut_tx"); +DEFINE_VALUE("DOF_BOKEH_TEXTURE", "true") +SAMPLER(5, FLOAT_2D, bokeh_lut_tx) +GPU_SHADER_CREATE_END() -GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background).define("DOF_FOREGROUND_PASS", "false"); -GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground).define("DOF_FOREGROUND_PASS", "true"); - -#define EEVEE_DOF_FINAL_VARIATION(name, ...) \ - GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); +GPU_SHADER_CREATE_INFO(eevee_depth_of_field_background) +DEFINE_VALUE("DOF_FOREGROUND_PASS", "false") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground) +DEFINE_VALUE("DOF_FOREGROUND_PASS", "true") +GPU_SHADER_CREATE_END() #define EEVEE_DOF_LUT_VARIATIONS(prefix, ...) \ - EEVEE_DOF_FINAL_VARIATION(prefix##_lut, "eevee_depth_of_field_lut", __VA_ARGS__) \ - EEVEE_DOF_FINAL_VARIATION(prefix##_no_lut, "eevee_depth_of_field_no_lut", __VA_ARGS__) + CREATE_INFO_VARIANT(prefix##_lut, eevee_depth_of_field_lut, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_no_lut, eevee_depth_of_field_no_lut, __VA_ARGS__) #define EEVEE_DOF_GROUND_VARIATIONS(name, ...) \ - EEVEE_DOF_LUT_VARIATIONS(name##_background, "eevee_depth_of_field_background", __VA_ARGS__) \ - EEVEE_DOF_LUT_VARIATIONS(name##_foreground, "eevee_depth_of_field_foreground", __VA_ARGS__) + EEVEE_DOF_LUT_VARIATIONS(name##_background, eevee_depth_of_field_background, __VA_ARGS__) \ + EEVEE_DOF_LUT_VARIATIONS(name##_foreground, eevee_depth_of_field_foreground, __VA_ARGS__) /** \} */ @@ -152,39 +174,44 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_foreground).define("DOF_FOREGROUND_P * \{ */ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather_common) - .additional_info("eevee_shared", - "draw_view", - "eevee_depth_of_field_tiles_common", - "eevee_sampling_data") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .local_group_size(DOF_GATHER_GROUP_SIZE, DOF_GATHER_GROUP_SIZE) - .sampler(0, ImageType::FLOAT_2D, "color_tx") - .sampler(1, ImageType::FLOAT_2D, "color_bilinear_tx") - .sampler(2, ImageType::FLOAT_2D, "coc_tx") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .image(3, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_weight_img"); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_depth_of_field_tiles_common) +ADDITIONAL_INFO(eevee_sampling_data) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +LOCAL_GROUP_SIZE(DOF_GATHER_GROUP_SIZE, DOF_GATHER_GROUP_SIZE) +SAMPLER(0, FLOAT_2D, color_tx) +SAMPLER(1, FLOAT_2D, color_bilinear_tx) +SAMPLER(2, FLOAT_2D, coc_tx) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +IMAGE(3, GPU_R16F, WRITE, FLOAT_2D, out_weight_img) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_gather) - .image(4, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_occlusion_img") - .compute_source("eevee_depth_of_field_gather_comp.glsl") - .additional_info("eevee_depth_of_field_gather_common"); +IMAGE(4, GPU_RG16F, WRITE, FLOAT_2D, out_occlusion_img) +COMPUTE_SOURCE("eevee_depth_of_field_gather_comp.glsl") +ADDITIONAL_INFO(eevee_depth_of_field_gather_common) +GPU_SHADER_CREATE_END() -EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, "eevee_depth_of_field_gather") +EEVEE_DOF_GROUND_VARIATIONS(eevee_depth_of_field_gather, eevee_depth_of_field_gather) GPU_SHADER_CREATE_INFO(eevee_depth_of_field_hole_fill) - .do_static_compilation(true) - .compute_source("eevee_depth_of_field_hole_fill_comp.glsl") - .additional_info("eevee_depth_of_field_gather_common", "eevee_depth_of_field_no_lut"); +DO_STATIC_COMPILATION() +COMPUTE_SOURCE("eevee_depth_of_field_hole_fill_comp.glsl") +ADDITIONAL_INFO(eevee_depth_of_field_gather_common) +ADDITIONAL_INFO(eevee_depth_of_field_no_lut) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter) - .do_static_compilation(true) - .local_group_size(DOF_FILTER_GROUP_SIZE, DOF_FILTER_GROUP_SIZE) - .additional_info("eevee_shared") - .sampler(0, ImageType::FLOAT_2D, "color_tx") - .sampler(1, ImageType::FLOAT_2D, "weight_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .image(1, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_weight_img") - .compute_source("eevee_depth_of_field_filter_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DOF_FILTER_GROUP_SIZE, DOF_FILTER_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +SAMPLER(0, FLOAT_2D, color_tx) +SAMPLER(1, FLOAT_2D, weight_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +IMAGE(1, GPU_R16F, WRITE, FLOAT_2D, out_weight_img) +COMPUTE_SOURCE("eevee_depth_of_field_filter_comp.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -192,34 +219,39 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_filter) /** \name Scatter * \{ */ -GPU_SHADER_INTERFACE_INFO(eevee_depth_of_field_scatter_flat_iface, "interp_flat") - /** Colors, weights, and Circle of confusion radii for the 4 pixels to scatter. */ - .flat(Type::VEC4, "color_and_coc1") - .flat(Type::VEC4, "color_and_coc2") - .flat(Type::VEC4, "color_and_coc3") - .flat(Type::VEC4, "color_and_coc4") - /** Scaling factor for the bokeh distance. */ - .flat(Type::FLOAT, "distance_scale"); -GPU_SHADER_INTERFACE_INFO(eevee_depth_of_field_scatter_noperspective_iface, "interp_noperspective") - /** Sprite pixel position with origin at sprite center. In pixels. */ - .no_perspective(Type::VEC2, "rect_uv1") - .no_perspective(Type::VEC2, "rect_uv2") - .no_perspective(Type::VEC2, "rect_uv3") - .no_perspective(Type::VEC2, "rect_uv4"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_flat_iface, interp_flat) +/** Colors, weights, and Circle of confusion radii for the 4 pixels to scatter. */ +FLAT(VEC4, color_and_coc1) +FLAT(VEC4, color_and_coc2) +FLAT(VEC4, color_and_coc3) +FLAT(VEC4, color_and_coc4) +/** Scaling factor for the bokeh distance. */ +FLAT(FLOAT, distance_scale) +GPU_SHADER_NAMED_INTERFACE_END(interp_flat) +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_depth_of_field_scatter_noperspective_iface, + interp_noperspective) +/** Sprite pixel position with origin at sprite center. In pixels. */ +NO_PERSPECTIVE(VEC2, rect_uv1) +NO_PERSPECTIVE(VEC2, rect_uv2) +NO_PERSPECTIVE(VEC2, rect_uv3) +NO_PERSPECTIVE(VEC2, rect_uv4) +GPU_SHADER_NAMED_INTERFACE_END(interp_noperspective) GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter) - .do_static_compilation(true) - .additional_info("eevee_shared", "draw_view") - .sampler(0, ImageType::FLOAT_2D, "occlusion_tx") - .sampler(1, ImageType::FLOAT_2D, "bokeh_lut_tx") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .storage_buf(0, Qualifier::READ, "ScatterRect", "scatter_list_buf[]") - .fragment_out(0, Type::VEC4, "out_color") - .push_constant(Type::BOOL, "use_bokeh_lut") - .vertex_out(eevee_depth_of_field_scatter_flat_iface) - .vertex_out(eevee_depth_of_field_scatter_noperspective_iface) - .vertex_source("eevee_depth_of_field_scatter_vert.glsl") - .fragment_source("eevee_depth_of_field_scatter_frag.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +SAMPLER(0, FLOAT_2D, occlusion_tx) +SAMPLER(1, FLOAT_2D, bokeh_lut_tx) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +STORAGE_BUF(0, READ, ScatterRect, scatter_list_buf[]) +FRAGMENT_OUT(0, VEC4, out_color) +PUSH_CONSTANT(BOOL, use_bokeh_lut) +VERTEX_OUT(eevee_depth_of_field_scatter_flat_iface) +VERTEX_OUT(eevee_depth_of_field_scatter_noperspective_iface) +VERTEX_SOURCE("eevee_depth_of_field_scatter_vert.glsl") +FRAGMENT_SOURCE("eevee_depth_of_field_scatter_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -228,26 +260,27 @@ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_scatter) * \{ */ GPU_SHADER_CREATE_INFO(eevee_depth_of_field_resolve) - .define("DOF_RESOLVE_PASS", "true") - .local_group_size(DOF_RESOLVE_GROUP_SIZE, DOF_RESOLVE_GROUP_SIZE) - .specialization_constant(Type::BOOL, "do_debug_color", false) - .additional_info("eevee_shared", - "draw_view", - "eevee_depth_of_field_tiles_common", - "eevee_sampling_data") - .uniform_buf(6, "DepthOfFieldData", "dof_buf") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .sampler(1, ImageType::FLOAT_2D, "color_tx") - .sampler(2, ImageType::FLOAT_2D, "color_bg_tx") - .sampler(3, ImageType::FLOAT_2D, "color_fg_tx") - .sampler(4, ImageType::FLOAT_2D, "color_hole_fill_tx") - .sampler(7, ImageType::FLOAT_2D, "weight_bg_tx") - .sampler(8, ImageType::FLOAT_2D, "weight_fg_tx") - .sampler(9, ImageType::FLOAT_2D, "weight_hole_fill_tx") - .sampler(10, ImageType::FLOAT_2D, "stable_color_tx") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .compute_source("eevee_depth_of_field_resolve_comp.glsl"); +DEFINE_VALUE("DOF_RESOLVE_PASS", "true") +LOCAL_GROUP_SIZE(DOF_RESOLVE_GROUP_SIZE, DOF_RESOLVE_GROUP_SIZE) +SPECIALIZATION_CONSTANT(BOOL, do_debug_color, false) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_depth_of_field_tiles_common) +ADDITIONAL_INFO(eevee_sampling_data) +UNIFORM_BUF(6, DepthOfFieldData, dof_buf) +SAMPLER(0, DEPTH_2D, depth_tx) +SAMPLER(1, FLOAT_2D, color_tx) +SAMPLER(2, FLOAT_2D, color_bg_tx) +SAMPLER(3, FLOAT_2D, color_fg_tx) +SAMPLER(4, FLOAT_2D, color_hole_fill_tx) +SAMPLER(7, FLOAT_2D, weight_bg_tx) +SAMPLER(8, FLOAT_2D, weight_fg_tx) +SAMPLER(9, FLOAT_2D, weight_hole_fill_tx) +SAMPLER(10, FLOAT_2D, stable_color_tx) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +COMPUTE_SOURCE("eevee_depth_of_field_resolve_comp.glsl") +GPU_SHADER_CREATE_END() -EEVEE_DOF_LUT_VARIATIONS(eevee_depth_of_field_resolve, "eevee_depth_of_field_resolve") +EEVEE_DOF_LUT_VARIATIONS(eevee_depth_of_field_resolve, eevee_depth_of_field_resolve) /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh index ff50517b566..091e80993a0 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh @@ -6,117 +6,131 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_film_base) - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .sampler(1, ImageType::FLOAT_2D, "combined_tx") - .sampler(2, ImageType::FLOAT_2D, "vector_tx") - .sampler(3, ImageType::FLOAT_2D_ARRAY, "rp_color_tx") - .sampler(4, ImageType::FLOAT_2D_ARRAY, "rp_value_tx") - /* Color History for TAA needs to be sampler to leverage bilinear sampling. */ - .sampler(5, ImageType::FLOAT_2D, "in_combined_tx") - .sampler(6, ImageType::FLOAT_2D, "cryptomatte_tx") - .image(0, GPU_R32F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "in_weight_img") - .image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") - .specialization_constant(Type::UINT, "enabled_categories", 0) - .specialization_constant(Type::INT, "samples_len", 0) - .specialization_constant(Type::BOOL, "use_reprojection", false) - .specialization_constant(Type::INT, "scaling_factor", 1) - .specialization_constant(Type::INT, "combined_id", 0) - .specialization_constant(Type::INT, "display_id", -1) - .specialization_constant(Type::INT, "normal_id", -1) - .additional_info("eevee_shared") - .additional_info("eevee_global_ubo") - .additional_info("eevee_velocity_camera") - .additional_info("draw_view"); +SAMPLER(0, DEPTH_2D, depth_tx) +SAMPLER(1, FLOAT_2D, combined_tx) +SAMPLER(2, FLOAT_2D, vector_tx) +SAMPLER(3, FLOAT_2D_ARRAY, rp_color_tx) +SAMPLER(4, FLOAT_2D_ARRAY, rp_value_tx) +/* Color History for TAA needs to be sampler to leverage bilinear sampling. */ +SAMPLER(5, FLOAT_2D, in_combined_tx) +SAMPLER(6, FLOAT_2D, cryptomatte_tx) +IMAGE(0, GPU_R32F, READ, FLOAT_2D_ARRAY, in_weight_img) +IMAGE(1, GPU_R32F, WRITE, FLOAT_2D_ARRAY, out_weight_img) +SPECIALIZATION_CONSTANT(UINT, enabled_categories, 0) +SPECIALIZATION_CONSTANT(INT, samples_len, 0) +SPECIALIZATION_CONSTANT(BOOL, use_reprojection, false) +SPECIALIZATION_CONSTANT(INT, scaling_factor, 1) +SPECIALIZATION_CONSTANT(INT, combined_id, 0) +SPECIALIZATION_CONSTANT(INT, display_id, -1) +SPECIALIZATION_CONSTANT(INT, normal_id, -1) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_velocity_camera) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_film) - /* Color History for TAA needs to be sampler to leverage bilinear sampling. */ - //.image(2, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "in_combined_img") - .image(3, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_combined_img") - .image(4, GPU_R32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "depth_img") - .image(5, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "color_accum_img") - .image(6, GPU_R16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "value_accum_img") - .image(7, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "cryptomatte_img") - .additional_info("eevee_film_base"); +/* Color History for TAA needs to be sampler to leverage bilinear sampling. */ +// IMAGE(2, GPU_RGBA16F, READ, FLOAT_2D, in_combined_img) +IMAGE(3, GPU_RGBA16F, WRITE, FLOAT_2D, out_combined_img) +IMAGE(4, GPU_R32F, READ_WRITE, FLOAT_2D, depth_img) +IMAGE(5, GPU_RGBA16F, READ_WRITE, FLOAT_2D_ARRAY, color_accum_img) +IMAGE(6, GPU_R16F, READ_WRITE, FLOAT_2D_ARRAY, value_accum_img) +IMAGE(7, GPU_RGBA32F, READ_WRITE, FLOAT_2D_ARRAY, cryptomatte_img) +ADDITIONAL_INFO(eevee_film_base) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_film_frag) - .do_static_compilation(true) - .fragment_out(0, Type::VEC4, "out_color") - .fragment_source("eevee_film_frag.glsl") - .additional_info("draw_fullscreen", "eevee_film") - .depth_write(DepthWrite::ANY); +DO_STATIC_COMPILATION() +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_SOURCE("eevee_film_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_film) +DEPTH_WRITE(DepthWrite::ANY) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_film_comp) - .do_static_compilation(true) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .compute_source("eevee_film_comp.glsl") - .additional_info("eevee_film"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +COMPUTE_SOURCE("eevee_film_comp.glsl") +ADDITIONAL_INFO(eevee_film) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_film_cryptomatte_post) - .do_static_compilation(true) - .image(0, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "cryptomatte_img") - .push_constant(Type::INT, "cryptomatte_layer_len") - .push_constant(Type::INT, "cryptomatte_samples_per_layer") - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .compute_source("eevee_film_cryptomatte_post_comp.glsl") - .additional_info("eevee_global_ubo", "eevee_shared"); +DO_STATIC_COMPILATION() +IMAGE(0, GPU_RGBA32F, READ_WRITE, FLOAT_2D_ARRAY, cryptomatte_img) +PUSH_CONSTANT(INT, cryptomatte_layer_len) +PUSH_CONSTANT(INT, cryptomatte_samples_per_layer) +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +COMPUTE_SOURCE("eevee_film_cryptomatte_post_comp.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_shared) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_film_copy_frag) - .do_static_compilation(true) - .image(3, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "out_combined_img") - .image(4, GPU_R32F, Qualifier::READ, ImageType::FLOAT_2D, "depth_img") - .image(5, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "color_accum_img") - .image(6, GPU_R16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "value_accum_img") - .image(7, GPU_RGBA32F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "cryptomatte_img") - .depth_write(DepthWrite::ANY) - .fragment_out(0, Type::VEC4, "out_color") - .fragment_source("eevee_film_copy_frag.glsl") - .define("FILM_COPY") - .additional_info("draw_fullscreen", "eevee_film_base"); +DO_STATIC_COMPILATION() +IMAGE(3, GPU_RGBA16F, READ, FLOAT_2D, out_combined_img) +IMAGE(4, GPU_R32F, READ, FLOAT_2D, depth_img) +IMAGE(5, GPU_RGBA16F, READ, FLOAT_2D_ARRAY, color_accum_img) +IMAGE(6, GPU_R16F, READ, FLOAT_2D_ARRAY, value_accum_img) +IMAGE(7, GPU_RGBA32F, READ, FLOAT_2D_ARRAY, cryptomatte_img) +DEPTH_WRITE(DepthWrite::ANY) +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_SOURCE("eevee_film_copy_frag.glsl") +DEFINE("FILM_COPY") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_film_base) +GPU_SHADER_CREATE_END() /* The combined pass is stored into its own 2D texture with a format of GPU_RGBA16F. */ GPU_SHADER_CREATE_INFO(eevee_film_pass_convert_combined) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .push_constant(Type::IVEC2, "offset") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("eevee_film_pass_convert_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +PUSH_CONSTANT(IVEC2, offset) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("eevee_film_pass_convert_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* The depth pass is stored into its own 2D texture with a format of GPU_R32F. */ GPU_SHADER_CREATE_INFO(eevee_film_pass_convert_depth) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .push_constant(Type::IVEC2, "offset") - .sampler(0, ImageType::FLOAT_2D, "input_tx") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("eevee_film_pass_convert_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +PUSH_CONSTANT(IVEC2, offset) +SAMPLER(0, FLOAT_2D, input_tx) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("eevee_film_pass_convert_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Value passes are stored in a slice of a 2D texture array with a format of GPU_R16F. */ GPU_SHADER_CREATE_INFO(eevee_film_pass_convert_value) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .push_constant(Type::IVEC2, "offset") - .define("IS_ARRAY_INPUT") - .sampler(0, ImageType::FLOAT_2D_ARRAY, "input_tx") - .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("eevee_film_pass_convert_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +PUSH_CONSTANT(IVEC2, offset) +DEFINE("IS_ARRAY_INPUT") +SAMPLER(0, FLOAT_2D_ARRAY, input_tx) +IMAGE(0, GPU_R16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("eevee_film_pass_convert_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Color passes are stored in a slice of a 2D texture array with a format of GPU_RGBA16F. */ GPU_SHADER_CREATE_INFO(eevee_film_pass_convert_color) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .push_constant(Type::IVEC2, "offset") - .define("IS_ARRAY_INPUT") - .sampler(0, ImageType::FLOAT_2D_ARRAY, "input_tx") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("eevee_film_pass_convert_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +PUSH_CONSTANT(IVEC2, offset) +DEFINE("IS_ARRAY_INPUT") +SAMPLER(0, FLOAT_2D_ARRAY, input_tx) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("eevee_film_pass_convert_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Cryptomatte passes are stored in a slice of a 2D texture array with a format of GPU_RGBA32F. */ GPU_SHADER_CREATE_INFO(eevee_film_pass_convert_cryptomatte) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .push_constant(Type::IVEC2, "offset") - .define("IS_ARRAY_INPUT") - .sampler(0, ImageType::FLOAT_2D_ARRAY, "input_tx") - .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .compute_source("eevee_film_pass_convert_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +PUSH_CONSTANT(IVEC2, offset) +DEFINE("IS_ARRAY_INPUT") +SAMPLER(0, FLOAT_2D_ARRAY, input_tx) +IMAGE(0, GPU_RGBA32F, WRITE, FLOAT_2D, output_img) +COMPUTE_SOURCE("eevee_film_pass_convert_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh index 697cd5ce0ad..751b2f20631 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh @@ -6,37 +6,44 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_hiz_data) - .sampler(HIZ_TEX_SLOT, ImageType::FLOAT_2D, "hiz_tx") - .additional_info("eevee_global_ubo"); +SAMPLER(HIZ_TEX_SLOT, FLOAT_2D, hiz_tx) +ADDITIONAL_INFO(eevee_global_ubo) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_hiz_update_base) - .local_group_size(FILM_GROUP_SIZE, FILM_GROUP_SIZE) - .storage_buf(0, Qualifier::READ_WRITE, "uint", "finished_tile_counter") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_0") - .image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_1") - .image(2, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_2") - .image(3, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_3") - .image(4, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_4") - .image(5, GPU_R32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "out_mip_5") - .image(6, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_mip_6") - .specialization_constant(Type::BOOL, "update_mip_0", true) - .compute_source("eevee_hiz_update_comp.glsl"); +LOCAL_GROUP_SIZE(FILM_GROUP_SIZE, FILM_GROUP_SIZE) +STORAGE_BUF(0, READ_WRITE, uint, finished_tile_counter) +IMAGE(0, GPU_R32F, WRITE, FLOAT_2D, out_mip_0) +IMAGE(1, GPU_R32F, WRITE, FLOAT_2D, out_mip_1) +IMAGE(2, GPU_R32F, WRITE, FLOAT_2D, out_mip_2) +IMAGE(3, GPU_R32F, WRITE, FLOAT_2D, out_mip_3) +IMAGE(4, GPU_R32F, WRITE, FLOAT_2D, out_mip_4) +IMAGE(5, GPU_R32F, READ_WRITE, FLOAT_2D, out_mip_5) +IMAGE(6, GPU_R32F, WRITE, FLOAT_2D, out_mip_6) +SPECIALIZATION_CONSTANT(BOOL, update_mip_0, true) +COMPUTE_SOURCE("eevee_hiz_update_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_hiz_update) - .do_static_compilation(true) - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .additional_info("eevee_hiz_update_base"); +DO_STATIC_COMPILATION() +SAMPLER(0, DEPTH_2D, depth_tx) +ADDITIONAL_INFO(eevee_hiz_update_base) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_hiz_update_layer) - .do_static_compilation(true) - .define("HIZ_LAYER") - .sampler(1, ImageType::DEPTH_2D_ARRAY, "depth_layered_tx") - .push_constant(Type::INT, "layer_id") - .additional_info("eevee_hiz_update_base"); +DO_STATIC_COMPILATION() +DEFINE("HIZ_LAYER") +SAMPLER(1, DEPTH_2D_ARRAY, depth_layered_tx) +PUSH_CONSTANT(INT, layer_id) +ADDITIONAL_INFO(eevee_hiz_update_base) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_hiz_debug) - .do_static_compilation(true) - .fragment_out(0, Type::VEC4, "out_debug_color_add", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_debug_color_mul", DualBlend::SRC_1) - .fragment_source("eevee_hiz_debug_frag.glsl") - .additional_info("eevee_shared", "eevee_hiz_data", "draw_fullscreen"); +DO_STATIC_COMPILATION() +FRAGMENT_OUT_DUAL(0, VEC4, out_debug_color_add, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_debug_color_mul, SRC_1) +FRAGMENT_SOURCE("eevee_hiz_debug_frag.glsl") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh index 31b14c05ca2..14d884da5f3 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh @@ -10,10 +10,11 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_light_data) - .storage_buf(LIGHT_CULL_BUF_SLOT, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(LIGHT_BUF_SLOT, Qualifier::READ, "LightData", "light_buf[]") - .storage_buf(LIGHT_ZBIN_BUF_SLOT, Qualifier::READ, "uint", "light_zbin_buf[]") - .storage_buf(LIGHT_TILE_BUF_SLOT, Qualifier::READ, "uint", "light_tile_buf[]"); +STORAGE_BUF(LIGHT_CULL_BUF_SLOT, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(LIGHT_BUF_SLOT, READ, LightData, light_buf[]) +STORAGE_BUF(LIGHT_ZBIN_BUF_SLOT, READ, uint, light_zbin_buf[]) +STORAGE_BUF(LIGHT_TILE_BUF_SLOT, READ, uint, light_tile_buf[]) +GPU_SHADER_CREATE_END() /** \} */ @@ -22,55 +23,68 @@ GPU_SHADER_CREATE_INFO(eevee_light_data) * \{ */ GPU_SHADER_CREATE_INFO(eevee_light_culling_select) - .do_static_compilation(true) - .additional_info("eevee_shared", "draw_view", "draw_view_culling") - .local_group_size(CULLING_SELECT_GROUP_SIZE) - .storage_buf(0, Qualifier::READ_WRITE, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ, "LightData", "in_light_buf[]") - .storage_buf(2, Qualifier::WRITE, "LightData", "out_light_buf[]") - .storage_buf(3, Qualifier::WRITE, "float", "out_zdist_buf[]") - .storage_buf(4, Qualifier::WRITE, "uint", "out_key_buf[]") - .uniform_buf(0, "LightData", "sunlight_buf") - .compute_source("eevee_light_culling_select_comp.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +LOCAL_GROUP_SIZE(CULLING_SELECT_GROUP_SIZE) +STORAGE_BUF(0, READ_WRITE, LightCullingData, light_cull_buf) +STORAGE_BUF(1, READ, LightData, in_light_buf[]) +STORAGE_BUF(2, WRITE, LightData, out_light_buf[]) +STORAGE_BUF(3, WRITE, float, out_zdist_buf[]) +STORAGE_BUF(4, WRITE, uint, out_key_buf[]) +UNIFORM_BUF(0, LightData, sunlight_buf) +COMPUTE_SOURCE("eevee_light_culling_select_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_light_culling_sort) - .do_static_compilation(true) - .additional_info("eevee_shared", "draw_view") - .storage_buf(0, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ, "LightData", "in_light_buf[]") - .storage_buf(2, Qualifier::WRITE, "LightData", "out_light_buf[]") - .storage_buf(3, Qualifier::READ, "float", "in_zdist_buf[]") - .storage_buf(4, Qualifier::READ, "uint", "in_key_buf[]") - .local_group_size(CULLING_SORT_GROUP_SIZE) - .compute_source("eevee_light_culling_sort_comp.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +STORAGE_BUF(0, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(1, READ, LightData, in_light_buf[]) +STORAGE_BUF(2, WRITE, LightData, out_light_buf[]) +STORAGE_BUF(3, READ, float, in_zdist_buf[]) +STORAGE_BUF(4, READ, uint, in_key_buf[]) +LOCAL_GROUP_SIZE(CULLING_SORT_GROUP_SIZE) +COMPUTE_SOURCE("eevee_light_culling_sort_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_light_culling_zbin) - .do_static_compilation(true) - .additional_info("eevee_shared", "draw_view") - .local_group_size(CULLING_ZBIN_GROUP_SIZE) - .storage_buf(0, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ, "LightData", "light_buf[]") - .storage_buf(2, Qualifier::WRITE, "uint", "out_zbin_buf[]") - .compute_source("eevee_light_culling_zbin_comp.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +LOCAL_GROUP_SIZE(CULLING_ZBIN_GROUP_SIZE) +STORAGE_BUF(0, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(1, READ, LightData, light_buf[]) +STORAGE_BUF(2, WRITE, uint, out_zbin_buf[]) +COMPUTE_SOURCE("eevee_light_culling_zbin_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_light_culling_tile) - .do_static_compilation(true) - .additional_info("eevee_shared", "draw_view", "draw_view_culling") - .local_group_size(CULLING_TILE_GROUP_SIZE) - .storage_buf(0, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ, "LightData", "light_buf[]") - .storage_buf(2, Qualifier::WRITE, "uint", "out_light_tile_buf[]") - .compute_source("eevee_light_culling_tile_comp.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +LOCAL_GROUP_SIZE(CULLING_TILE_GROUP_SIZE) +STORAGE_BUF(0, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(1, READ, LightData, light_buf[]) +STORAGE_BUF(2, WRITE, uint, out_light_tile_buf[]) +COMPUTE_SOURCE("eevee_light_culling_tile_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_light_shadow_setup) - .do_static_compilation(true) - .additional_info("eevee_shared", "eevee_sampling_data", "eevee_global_ubo") - .local_group_size(CULLING_SELECT_GROUP_SIZE) - .storage_buf(0, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ_WRITE, "LightData", "light_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(3, Qualifier::READ_WRITE, "ShadowTileMapClip", "tilemaps_clip_buf[]") - .compute_source("eevee_light_shadow_setup_comp.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_global_ubo) +LOCAL_GROUP_SIZE(CULLING_SELECT_GROUP_SIZE) +STORAGE_BUF(0, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(1, READ_WRITE, LightData, light_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(3, READ_WRITE, ShadowTileMapClip, tilemaps_clip_buf[]) +COMPUTE_SOURCE("eevee_light_shadow_setup_comp.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -79,11 +93,15 @@ GPU_SHADER_CREATE_INFO(eevee_light_shadow_setup) * \{ */ GPU_SHADER_CREATE_INFO(eevee_light_culling_debug) - .do_static_compilation(true) - .fragment_out(0, Type::VEC4, "out_debug_color_add", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_debug_color_mul", DualBlend::SRC_1) - .fragment_source("eevee_light_culling_debug_frag.glsl") - .additional_info( - "eevee_shared", "draw_view", "draw_fullscreen", "eevee_light_data", "eevee_hiz_data"); +DO_STATIC_COMPILATION() +FRAGMENT_OUT_DUAL(0, VEC4, out_debug_color_add, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_debug_color_mul, SRC_1) +FRAGMENT_SOURCE("eevee_light_culling_debug_frag.glsl") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_hiz_data) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_sphere_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_sphere_info.hh index c54e42d0166..d046954a462 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_sphere_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_sphere_info.hh @@ -10,103 +10,111 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_data) - .define("SPHERE_PROBE") - .uniform_buf(SPHERE_PROBE_BUF_SLOT, - "SphereProbeData", - "lightprobe_sphere_buf[SPHERE_PROBE_MAX]") - .sampler(SPHERE_PROBE_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "lightprobe_spheres_tx"); +DEFINE("SPHERE_PROBE") +UNIFORM_BUF(SPHERE_PROBE_BUF_SLOT, SphereProbeData, lightprobe_sphere_buf[SPHERE_PROBE_MAX]) +SAMPLER(SPHERE_PROBE_TEX_SLOT, FLOAT_2D_ARRAY, lightprobe_spheres_tx) +GPU_SHADER_CREATE_END() /* Sample cubemap and remap into an octahedral texture. */ GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_remap) - .local_group_size(SPHERE_PROBE_REMAP_GROUP_SIZE, SPHERE_PROBE_REMAP_GROUP_SIZE) - .specialization_constant(Type::BOOL, "extract_sh", true) - .specialization_constant(Type::BOOL, "extract_sun", true) - .push_constant(Type::IVEC4, "probe_coord_packed") - .push_constant(Type::IVEC4, "write_coord_packed") - .push_constant(Type::IVEC4, "world_coord_packed") - .sampler(0, ImageType::FLOAT_CUBE, "cubemap_tx") - .sampler(1, ImageType::FLOAT_2D_ARRAY, "atlas_tx") - .storage_buf(0, Qualifier::WRITE, "SphereProbeHarmonic", "out_sh[]") - .storage_buf(1, Qualifier::WRITE, "SphereProbeSunLight", "out_sun[]") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "atlas_img") - .compute_source("eevee_lightprobe_sphere_remap_comp.glsl") - .additional_info("eevee_shared", "eevee_global_ubo") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SPHERE_PROBE_REMAP_GROUP_SIZE, SPHERE_PROBE_REMAP_GROUP_SIZE) +SPECIALIZATION_CONSTANT(BOOL, extract_sh, true) +SPECIALIZATION_CONSTANT(BOOL, extract_sun, true) +PUSH_CONSTANT(IVEC4, probe_coord_packed) +PUSH_CONSTANT(IVEC4, write_coord_packed) +PUSH_CONSTANT(IVEC4, world_coord_packed) +SAMPLER(0, FLOAT_CUBE, cubemap_tx) +SAMPLER(1, FLOAT_2D_ARRAY, atlas_tx) +STORAGE_BUF(0, WRITE, SphereProbeHarmonic, out_sh[]) +STORAGE_BUF(1, WRITE, SphereProbeSunLight, out_sun[]) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D_ARRAY, atlas_img) +COMPUTE_SOURCE("eevee_lightprobe_sphere_remap_comp.glsl") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_irradiance) - .local_group_size(SPHERE_PROBE_SH_GROUP_SIZE) - .push_constant(Type::IVEC3, "probe_remap_dispatch_size") - .storage_buf(0, Qualifier::READ, "SphereProbeHarmonic", "in_sh[]") - .storage_buf(1, Qualifier::WRITE, "SphereProbeHarmonic", "out_sh") - .additional_info("eevee_shared") - .do_static_compilation(true) - .compute_source("eevee_lightprobe_sphere_irradiance_comp.glsl"); +LOCAL_GROUP_SIZE(SPHERE_PROBE_SH_GROUP_SIZE) +PUSH_CONSTANT(IVEC3, probe_remap_dispatch_size) +STORAGE_BUF(0, READ, SphereProbeHarmonic, in_sh[]) +STORAGE_BUF(1, WRITE, SphereProbeHarmonic, out_sh) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +COMPUTE_SOURCE("eevee_lightprobe_sphere_irradiance_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_sunlight) - .local_group_size(SPHERE_PROBE_SH_GROUP_SIZE) - .push_constant(Type::IVEC3, "probe_remap_dispatch_size") - .storage_buf(0, Qualifier::READ, "SphereProbeSunLight", "in_sun[]") - .storage_buf(1, Qualifier::WRITE, "LightData", "sunlight_buf") - .additional_info("eevee_shared") - .do_static_compilation(true) - .compute_source("eevee_lightprobe_sphere_sunlight_comp.glsl"); +LOCAL_GROUP_SIZE(SPHERE_PROBE_SH_GROUP_SIZE) +PUSH_CONSTANT(IVEC3, probe_remap_dispatch_size) +STORAGE_BUF(0, READ, SphereProbeSunLight, in_sun[]) +STORAGE_BUF(1, WRITE, LightData, sunlight_buf) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +COMPUTE_SOURCE("eevee_lightprobe_sphere_sunlight_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_select) - .local_group_size(SPHERE_PROBE_SELECT_GROUP_SIZE) - .storage_buf(0, - Qualifier::READ_WRITE, - "SphereProbeData", - "lightprobe_sphere_buf[SPHERE_PROBE_MAX]") - .push_constant(Type::INT, "lightprobe_sphere_count") - .additional_info("eevee_shared", - "eevee_sampling_data", - "eevee_global_ubo", - "eevee_volume_probe_data") - .compute_source("eevee_lightprobe_sphere_select_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SPHERE_PROBE_SELECT_GROUP_SIZE) +STORAGE_BUF(0, READ_WRITE, SphereProbeData, lightprobe_sphere_buf[SPHERE_PROBE_MAX]) +PUSH_CONSTANT(INT, lightprobe_sphere_count) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_volume_probe_data) +COMPUTE_SOURCE("eevee_lightprobe_sphere_select_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_sphere_convolve) - .local_group_size(SPHERE_PROBE_GROUP_SIZE, SPHERE_PROBE_GROUP_SIZE) - .additional_info("eevee_shared") - .push_constant(Type::IVEC4, "probe_coord_packed") - .push_constant(Type::IVEC4, "write_coord_packed") - .push_constant(Type::IVEC4, "read_coord_packed") - .push_constant(Type::INT, "read_lod") - .sampler(0, ImageType::FLOAT_CUBE, "cubemap_tx") - .sampler(1, ImageType::FLOAT_2D_ARRAY, "in_atlas_mip_tx") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_atlas_mip_img") - .compute_source("eevee_lightprobe_sphere_convolve_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SPHERE_PROBE_GROUP_SIZE, SPHERE_PROBE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +PUSH_CONSTANT(IVEC4, probe_coord_packed) +PUSH_CONSTANT(IVEC4, write_coord_packed) +PUSH_CONSTANT(IVEC4, read_coord_packed) +PUSH_CONSTANT(INT, read_lod) +SAMPLER(0, FLOAT_CUBE, cubemap_tx) +SAMPLER(1, FLOAT_2D_ARRAY, in_atlas_mip_tx) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D_ARRAY, out_atlas_mip_img) +COMPUTE_SOURCE("eevee_lightprobe_sphere_convolve_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_sphere_iface, "") - .smooth(Type::VEC3, "P") - .smooth(Type::VEC2, "lP") - .flat(Type::INT, "probe_index"); +GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_sphere_iface) +SMOOTH(VEC3, P) +SMOOTH(VEC2, lP) +FLAT(INT, probe_index) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_display_lightprobe_sphere) - .additional_info("eevee_shared", "draw_view", "eevee_lightprobe_sphere_data") - .storage_buf(0, Qualifier::READ, "SphereProbeDisplayData", "display_data_buf[]") - .vertex_source("eevee_display_lightprobe_sphere_vert.glsl") - .vertex_out(eevee_display_lightprobe_sphere_iface) - .fragment_source("eevee_display_lightprobe_sphere_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +STORAGE_BUF(0, READ, SphereProbeDisplayData, display_data_buf[]) +VERTEX_SOURCE("eevee_display_lightprobe_sphere_vert.glsl") +VERTEX_OUT(eevee_display_lightprobe_sphere_iface) +FRAGMENT_SOURCE("eevee_display_lightprobe_sphere_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_planar_iface, "") - .flat(Type::VEC3, "probe_normal") - .flat(Type::INT, "probe_index"); +GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_planar_iface) +FLAT(VEC3, probe_normal) +FLAT(INT, probe_index) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_display_lightprobe_planar) - .push_constant(Type::IVEC4, "world_coord_packed") - .additional_info("eevee_shared", - "draw_view", - "eevee_lightprobe_planar_data", - "eevee_lightprobe_sphere_data") - .storage_buf(0, Qualifier::READ, "PlanarProbeDisplayData", "display_data_buf[]") - .vertex_source("eevee_display_lightprobe_planar_vert.glsl") - .vertex_out(eevee_display_lightprobe_planar_iface) - .fragment_source("eevee_display_lightprobe_planar_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .do_static_compilation(true); +PUSH_CONSTANT(IVEC4, world_coord_packed) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_lightprobe_planar_data) +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +STORAGE_BUF(0, READ, PlanarProbeDisplayData, display_data_buf[]) +VERTEX_SOURCE("eevee_display_lightprobe_planar_vert.glsl") +VERTEX_OUT(eevee_display_lightprobe_planar_iface) +FRAGMENT_SOURCE("eevee_display_lightprobe_planar_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_volume_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_volume_info.hh index 948ffffaee3..3221e6a465c 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_volume_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lightprobe_volume_info.hh @@ -9,57 +9,66 @@ /** \name Display * \{ */ -GPU_SHADER_INTERFACE_INFO(eevee_debug_surfel_iface, "") - .smooth(Type::VEC3, "P") - .flat(Type::INT, "surfel_index"); +GPU_SHADER_INTERFACE_INFO(eevee_debug_surfel_iface) +SMOOTH(VEC3, P) +FLAT(INT, surfel_index) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_debug_surfels) - .additional_info("eevee_shared", "draw_view") - .vertex_source("eevee_debug_surfels_vert.glsl") - .vertex_out(eevee_debug_surfel_iface) - .fragment_source("eevee_debug_surfels_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .storage_buf(0, Qualifier::READ, "Surfel", "surfels_buf[]") - .push_constant(Type::FLOAT, "debug_surfel_radius") - .push_constant(Type::INT, "debug_mode") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +VERTEX_SOURCE("eevee_debug_surfels_vert.glsl") +VERTEX_OUT(eevee_debug_surfel_iface) +FRAGMENT_SOURCE("eevee_debug_surfels_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +STORAGE_BUF(0, READ, Surfel, surfels_buf[]) +PUSH_CONSTANT(FLOAT, debug_surfel_radius) +PUSH_CONSTANT(INT, debug_mode) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_debug_irradiance_grid_iface, "") - .smooth(Type::VEC4, "interp_color"); +GPU_SHADER_INTERFACE_INFO(eevee_debug_irradiance_grid_iface) +SMOOTH(VEC4, interp_color) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_debug_irradiance_grid) - .additional_info("eevee_shared", "draw_view") - .fragment_out(0, Type::VEC4, "out_color") - .vertex_out(eevee_debug_irradiance_grid_iface) - .sampler(0, ImageType::FLOAT_3D, "debug_data_tx") - .push_constant(Type::MAT4, "grid_mat") - .push_constant(Type::INT, "debug_mode") - .push_constant(Type::FLOAT, "debug_value") - .vertex_source("eevee_debug_irradiance_grid_vert.glsl") - .fragment_source("eevee_debug_irradiance_grid_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +FRAGMENT_OUT(0, VEC4, out_color) +VERTEX_OUT(eevee_debug_irradiance_grid_iface) +SAMPLER(0, FLOAT_3D, debug_data_tx) +PUSH_CONSTANT(MAT4, grid_mat) +PUSH_CONSTANT(INT, debug_mode) +PUSH_CONSTANT(FLOAT, debug_value) +VERTEX_SOURCE("eevee_debug_irradiance_grid_vert.glsl") +FRAGMENT_SOURCE("eevee_debug_irradiance_grid_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_volume_iface, "") - .smooth(Type::VEC2, "lP") - .flat(Type::IVEC3, "cell"); +GPU_SHADER_INTERFACE_INFO(eevee_display_lightprobe_volume_iface) +SMOOTH(VEC2, lP) +FLAT(IVEC3, cell) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_display_lightprobe_volume) - .additional_info("eevee_shared", "draw_view") - .vertex_source("eevee_display_lightprobe_volume_vert.glsl") - .vertex_out(eevee_display_lightprobe_volume_iface) - .fragment_source("eevee_display_lightprobe_volume_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .push_constant(Type::FLOAT, "sphere_radius") - .push_constant(Type::IVEC3, "grid_resolution") - .push_constant(Type::MAT4, "grid_to_world") - .push_constant(Type::MAT4, "world_to_grid") - .push_constant(Type::BOOL, "display_validity") - .sampler(0, ImageType::FLOAT_3D, "irradiance_a_tx") - .sampler(1, ImageType::FLOAT_3D, "irradiance_b_tx") - .sampler(2, ImageType::FLOAT_3D, "irradiance_c_tx") - .sampler(3, ImageType::FLOAT_3D, "irradiance_d_tx") - .sampler(4, ImageType::FLOAT_3D, "validity_tx") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +VERTEX_SOURCE("eevee_display_lightprobe_volume_vert.glsl") +VERTEX_OUT(eevee_display_lightprobe_volume_iface) +FRAGMENT_SOURCE("eevee_display_lightprobe_volume_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +PUSH_CONSTANT(FLOAT, sphere_radius) +PUSH_CONSTANT(IVEC3, grid_resolution) +PUSH_CONSTANT(MAT4, grid_to_world) +PUSH_CONSTANT(MAT4, world_to_grid) +PUSH_CONSTANT(BOOL, display_validity) +SAMPLER(0, FLOAT_3D, irradiance_a_tx) +SAMPLER(1, FLOAT_3D, irradiance_b_tx) +SAMPLER(2, FLOAT_3D, irradiance_c_tx) +SAMPLER(3, FLOAT_3D, irradiance_d_tx) +SAMPLER(4, FLOAT_3D, validity_tx) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -68,100 +77,117 @@ GPU_SHADER_CREATE_INFO(eevee_display_lightprobe_volume) * \{ */ GPU_SHADER_CREATE_INFO(eevee_surfel_common) - .storage_buf(SURFEL_BUF_SLOT, Qualifier::READ_WRITE, "Surfel", "surfel_buf[]") - .storage_buf(CAPTURE_BUF_SLOT, Qualifier::READ, "CaptureInfoData", "capture_info_buf"); +STORAGE_BUF(SURFEL_BUF_SLOT, READ_WRITE, Surfel, surfel_buf[]) +STORAGE_BUF(CAPTURE_BUF_SLOT, READ, CaptureInfoData, capture_info_buf) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surfel_light) - .define("LIGHT_ITER_FORCE_NO_CULLING") - .define("LIGHT_CLOSURE_EVAL_COUNT", "1") - .local_group_size(SURFEL_GROUP_SIZE) - .additional_info("eevee_shared", - "draw_view", - "eevee_global_ubo", - "eevee_utility_texture", - "eevee_surfel_common", - "eevee_light_data", - "eevee_shadow_data") - .compute_source("eevee_surfel_light_comp.glsl") - .do_static_compilation(true); +DEFINE("LIGHT_ITER_FORCE_NO_CULLING") +DEFINE_VALUE("LIGHT_CLOSURE_EVAL_COUNT", "1") +LOCAL_GROUP_SIZE(SURFEL_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_shadow_data) +COMPUTE_SOURCE("eevee_surfel_light_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surfel_cluster_build) - .local_group_size(SURFEL_GROUP_SIZE) - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .additional_info("eevee_shared", "eevee_surfel_common", "draw_view") - .image(0, GPU_R32I, Qualifier::READ_WRITE, ImageType::INT_3D_ATOMIC, "cluster_list_img") - .compute_source("eevee_surfel_cluster_build_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SURFEL_GROUP_SIZE) +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(draw_view) +IMAGE(0, GPU_R32I, READ_WRITE, INT_3D_ATOMIC, cluster_list_img) +COMPUTE_SOURCE("eevee_surfel_cluster_build_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surfel_list_build) - .local_group_size(SURFEL_GROUP_SIZE) - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .additional_info("eevee_shared", "eevee_surfel_common", "draw_view") - .storage_buf(0, Qualifier::READ_WRITE, "int", "list_start_buf[]") - .storage_buf(6, Qualifier::READ_WRITE, "SurfelListInfoData", "list_info_buf") - .compute_source("eevee_surfel_list_build_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SURFEL_GROUP_SIZE) +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(draw_view) +STORAGE_BUF(0, READ_WRITE, int, list_start_buf[]) +STORAGE_BUF(6, READ_WRITE, SurfelListInfoData, list_info_buf) +COMPUTE_SOURCE("eevee_surfel_list_build_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surfel_list_sort) - .local_group_size(SURFEL_LIST_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_surfel_common", "draw_view") - .storage_buf(0, Qualifier::READ_WRITE, "int", "list_start_buf[]") - .storage_buf(6, Qualifier::READ, "SurfelListInfoData", "list_info_buf") - .compute_source("eevee_surfel_list_sort_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SURFEL_LIST_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(draw_view) +STORAGE_BUF(0, READ_WRITE, int, list_start_buf[]) +STORAGE_BUF(6, READ, SurfelListInfoData, list_info_buf) +COMPUTE_SOURCE("eevee_surfel_list_sort_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surfel_ray) - .local_group_size(SURFEL_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_surfel_common", - "eevee_lightprobe_sphere_data", - "draw_view") - .push_constant(Type::INT, "radiance_src") - .push_constant(Type::INT, "radiance_dst") - .compute_source("eevee_surfel_ray_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(SURFEL_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +ADDITIONAL_INFO(draw_view) +PUSH_CONSTANT(INT, radiance_src) +PUSH_CONSTANT(INT, radiance_dst) +COMPUTE_SOURCE("eevee_surfel_ray_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_bounds) - .do_static_compilation(true) - .local_group_size(IRRADIANCE_BOUNDS_GROUP_SIZE) - .storage_buf(0, Qualifier::READ_WRITE, "CaptureInfoData", "capture_info_buf") - .storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .push_constant(Type::INT, "resource_len") - .typedef_source("draw_shader_shared.hh") - .additional_info("eevee_shared") - .compute_source("eevee_lightprobe_volume_bounds_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(IRRADIANCE_BOUNDS_GROUP_SIZE) +STORAGE_BUF(0, READ_WRITE, CaptureInfoData, capture_info_buf) +STORAGE_BUF(1, READ, ObjectBounds, bounds_buf[]) +PUSH_CONSTANT(INT, resource_len) +TYPEDEF_SOURCE("draw_shader_shared.hh") +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_lightprobe_volume_bounds_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_ray) - .local_group_size(IRRADIANCE_GRID_GROUP_SIZE, - IRRADIANCE_GRID_GROUP_SIZE, - IRRADIANCE_GRID_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_surfel_common", - "eevee_lightprobe_sphere_data", - "draw_view") - .push_constant(Type::INT, "radiance_src") - .storage_buf(0, Qualifier::READ, "int", "list_start_buf[]") - .storage_buf(6, Qualifier::READ, "SurfelListInfoData", "list_info_buf") - .image(0, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "irradiance_L0_img") - .image(1, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "irradiance_L1_a_img") - .image(2, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "irradiance_L1_b_img") - .image(3, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "irradiance_L1_c_img") - .image(4, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_3D, "virtual_offset_img") - .image(5, GPU_R32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "validity_img") - .compute_source("eevee_lightprobe_volume_ray_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(IRRADIANCE_GRID_GROUP_SIZE, + IRRADIANCE_GRID_GROUP_SIZE, + IRRADIANCE_GRID_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +ADDITIONAL_INFO(draw_view) +PUSH_CONSTANT(INT, radiance_src) +STORAGE_BUF(0, READ, int, list_start_buf[]) +STORAGE_BUF(6, READ, SurfelListInfoData, list_info_buf) +IMAGE(0, GPU_RGBA32F, READ_WRITE, FLOAT_3D, irradiance_L0_img) +IMAGE(1, GPU_RGBA32F, READ_WRITE, FLOAT_3D, irradiance_L1_a_img) +IMAGE(2, GPU_RGBA32F, READ_WRITE, FLOAT_3D, irradiance_L1_b_img) +IMAGE(3, GPU_RGBA32F, READ_WRITE, FLOAT_3D, irradiance_L1_c_img) +IMAGE(4, GPU_RGBA16F, READ, FLOAT_3D, virtual_offset_img) +IMAGE(5, GPU_R32F, READ_WRITE, FLOAT_3D, validity_img) +COMPUTE_SOURCE("eevee_lightprobe_volume_ray_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_offset) - .local_group_size(IRRADIANCE_GRID_GROUP_SIZE, - IRRADIANCE_GRID_GROUP_SIZE, - IRRADIANCE_GRID_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_surfel_common", "draw_view") - .storage_buf(0, Qualifier::READ, "int", "list_start_buf[]") - .storage_buf(6, Qualifier::READ, "SurfelListInfoData", "list_info_buf") - .image(0, GPU_R32I, Qualifier::READ, ImageType::INT_3D_ATOMIC, "cluster_list_img") - .image(1, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "virtual_offset_img") - .compute_source("eevee_lightprobe_volume_offset_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(IRRADIANCE_GRID_GROUP_SIZE, + IRRADIANCE_GRID_GROUP_SIZE, + IRRADIANCE_GRID_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_surfel_common) +ADDITIONAL_INFO(draw_view) +STORAGE_BUF(0, READ, int, list_start_buf[]) +STORAGE_BUF(6, READ, SurfelListInfoData, list_info_buf) +IMAGE(0, GPU_R32I, READ, INT_3D_ATOMIC, cluster_list_img) +IMAGE(1, GPU_RGBA16F, READ_WRITE, FLOAT_3D, virtual_offset_img) +COMPUTE_SOURCE("eevee_lightprobe_volume_offset_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -170,65 +196,71 @@ GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_offset) * \{ */ GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_world) - .local_group_size(IRRADIANCE_GRID_BRICK_SIZE, - IRRADIANCE_GRID_BRICK_SIZE, - IRRADIANCE_GRID_BRICK_SIZE) - .define("IRRADIANCE_GRID_UPLOAD") - .additional_info("eevee_shared", "eevee_global_ubo") - .push_constant(Type::INT, "grid_index") - .storage_buf(0, Qualifier::READ, "uint", "bricks_infos_buf[]") - .storage_buf(1, Qualifier::READ, "SphereProbeHarmonic", "harmonic_buf") - .uniform_buf(0, "VolumeProbeData", "grids_infos_buf[IRRADIANCE_GRID_MAX]") - .image(0, VOLUME_PROBE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_3D, "irradiance_atlas_img") - .compute_source("eevee_lightprobe_volume_world_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(IRRADIANCE_GRID_BRICK_SIZE, + IRRADIANCE_GRID_BRICK_SIZE, + IRRADIANCE_GRID_BRICK_SIZE) +DEFINE("IRRADIANCE_GRID_UPLOAD") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +PUSH_CONSTANT(INT, grid_index) +STORAGE_BUF(0, READ, uint, bricks_infos_buf[]) +STORAGE_BUF(1, READ, SphereProbeHarmonic, harmonic_buf) +UNIFORM_BUF(0, VolumeProbeData, grids_infos_buf[IRRADIANCE_GRID_MAX]) +IMAGE(0, VOLUME_PROBE_FORMAT, WRITE, FLOAT_3D, irradiance_atlas_img) +COMPUTE_SOURCE("eevee_lightprobe_volume_world_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_volume_load) - .local_group_size(IRRADIANCE_GRID_BRICK_SIZE, - IRRADIANCE_GRID_BRICK_SIZE, - IRRADIANCE_GRID_BRICK_SIZE) - .define("IRRADIANCE_GRID_UPLOAD") - .additional_info("eevee_shared", "eevee_global_ubo") - .push_constant(Type::MAT4, "grid_local_to_world") - .push_constant(Type::INT, "grid_index") - .push_constant(Type::INT, "grid_start_index") - .push_constant(Type::FLOAT, "validity_threshold") - .push_constant(Type::FLOAT, "dilation_threshold") - .push_constant(Type::FLOAT, "dilation_radius") - .push_constant(Type::FLOAT, "grid_intensity_factor") - .uniform_buf(0, "VolumeProbeData", "grids_infos_buf[IRRADIANCE_GRID_MAX]") - .storage_buf(0, Qualifier::READ, "uint", "bricks_infos_buf[]") - .sampler(0, ImageType::FLOAT_3D, "irradiance_a_tx") - .sampler(1, ImageType::FLOAT_3D, "irradiance_b_tx") - .sampler(2, ImageType::FLOAT_3D, "irradiance_c_tx") - .sampler(3, ImageType::FLOAT_3D, "irradiance_d_tx") - .sampler(4, ImageType::FLOAT_3D, "visibility_a_tx") - .sampler(5, ImageType::FLOAT_3D, "visibility_b_tx") - .sampler(6, ImageType::FLOAT_3D, "visibility_c_tx") - .sampler(7, ImageType::FLOAT_3D, "visibility_d_tx") - .sampler(8, ImageType::FLOAT_3D, "irradiance_atlas_tx") - .sampler(9, ImageType::FLOAT_3D, "validity_tx") - .image(0, VOLUME_PROBE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_3D, "irradiance_atlas_img") - .compute_source("eevee_lightprobe_volume_load_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(IRRADIANCE_GRID_BRICK_SIZE, + IRRADIANCE_GRID_BRICK_SIZE, + IRRADIANCE_GRID_BRICK_SIZE) +DEFINE("IRRADIANCE_GRID_UPLOAD") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +PUSH_CONSTANT(MAT4, grid_local_to_world) +PUSH_CONSTANT(INT, grid_index) +PUSH_CONSTANT(INT, grid_start_index) +PUSH_CONSTANT(FLOAT, validity_threshold) +PUSH_CONSTANT(FLOAT, dilation_threshold) +PUSH_CONSTANT(FLOAT, dilation_radius) +PUSH_CONSTANT(FLOAT, grid_intensity_factor) +UNIFORM_BUF(0, VolumeProbeData, grids_infos_buf[IRRADIANCE_GRID_MAX]) +STORAGE_BUF(0, READ, uint, bricks_infos_buf[]) +SAMPLER(0, FLOAT_3D, irradiance_a_tx) +SAMPLER(1, FLOAT_3D, irradiance_b_tx) +SAMPLER(2, FLOAT_3D, irradiance_c_tx) +SAMPLER(3, FLOAT_3D, irradiance_d_tx) +SAMPLER(4, FLOAT_3D, visibility_a_tx) +SAMPLER(5, FLOAT_3D, visibility_b_tx) +SAMPLER(6, FLOAT_3D, visibility_c_tx) +SAMPLER(7, FLOAT_3D, visibility_d_tx) +SAMPLER(8, FLOAT_3D, irradiance_atlas_tx) +SAMPLER(9, FLOAT_3D, validity_tx) +IMAGE(0, VOLUME_PROBE_FORMAT, WRITE, FLOAT_3D, irradiance_atlas_img) +COMPUTE_SOURCE("eevee_lightprobe_volume_load_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_probe_data) - .uniform_buf(IRRADIANCE_GRID_BUF_SLOT, - "VolumeProbeData", - "grids_infos_buf[IRRADIANCE_GRID_MAX]") - /* NOTE: Use uint instead of IrradianceBrickPacked because Metal needs to know the exact type. - */ - .storage_buf(IRRADIANCE_BRICK_BUF_SLOT, Qualifier::READ, "uint", "bricks_infos_buf[]") - .sampler(VOLUME_PROBE_TEX_SLOT, ImageType::FLOAT_3D, "irradiance_atlas_tx") - .define("IRRADIANCE_GRID_SAMPLING"); +UNIFORM_BUF(IRRADIANCE_GRID_BUF_SLOT, VolumeProbeData, grids_infos_buf[IRRADIANCE_GRID_MAX]) +/* NOTE: Use uint instead of IrradianceBrickPacked because Metal needs to know the exact type. + */ +STORAGE_BUF(IRRADIANCE_BRICK_BUF_SLOT, READ, uint, bricks_infos_buf[]) +SAMPLER(VOLUME_PROBE_TEX_SLOT, FLOAT_3D, irradiance_atlas_tx) +DEFINE("IRRADIANCE_GRID_SAMPLING") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_data) - .additional_info("eevee_lightprobe_sphere_data", "eevee_volume_probe_data"); +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +ADDITIONAL_INFO(eevee_volume_probe_data) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_lightprobe_planar_data) - .define("SPHERE_PROBE") - .uniform_buf(PLANAR_PROBE_BUF_SLOT, "PlanarProbeData", "probe_planar_buf[PLANAR_PROBE_MAX]") - .sampler(PLANAR_PROBE_RADIANCE_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "planar_radiance_tx") - .sampler(PLANAR_PROBE_DEPTH_TEX_SLOT, ImageType::DEPTH_2D_ARRAY, "planar_depth_tx"); +DEFINE("SPHERE_PROBE") +UNIFORM_BUF(PLANAR_PROBE_BUF_SLOT, PlanarProbeData, probe_planar_buf[PLANAR_PROBE_MAX]) +SAMPLER(PLANAR_PROBE_RADIANCE_TEX_SLOT, FLOAT_2D_ARRAY, planar_radiance_tx) +SAMPLER(PLANAR_PROBE_DEPTH_TEX_SLOT, DEPTH_2D_ARRAY, planar_depth_tx) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lookdev_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lookdev_info.hh index 04055507428..d56e6fb841d 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lookdev_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lookdev_info.hh @@ -5,19 +5,21 @@ #include "eevee_defines.hh" #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(eevee_lookdev_display_iface, "") - .smooth(Type::VEC2, "uv_coord") - .flat(Type::UINT, "sphere_id"); +GPU_SHADER_INTERFACE_INFO(eevee_lookdev_display_iface) +SMOOTH(VEC2, uv_coord) +FLAT(UINT, sphere_id) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(eevee_lookdev_display) - .vertex_source("eevee_lookdev_display_vert.glsl") - .vertex_out(eevee_lookdev_display_iface) - .push_constant(Type::VEC2, "viewportSize") - .push_constant(Type::VEC2, "invertedViewportSize") - .push_constant(Type::IVEC2, "anchor") - .sampler(0, ImageType::FLOAT_2D, "metallic_tx") - .sampler(1, ImageType::FLOAT_2D, "diffuse_tx") - .fragment_out(0, Type::VEC4, "out_color") - .fragment_source("eevee_lookdev_display_frag.glsl") - .depth_write(DepthWrite::ANY) - .do_static_compilation(true); +VERTEX_SOURCE("eevee_lookdev_display_vert.glsl") +VERTEX_OUT(eevee_lookdev_display_iface) +PUSH_CONSTANT(VEC2, viewportSize) +PUSH_CONSTANT(VEC2, invertedViewportSize) +PUSH_CONSTANT(IVEC2, anchor) +SAMPLER(0, FLOAT_2D, metallic_tx) +SAMPLER(1, FLOAT_2D, diffuse_tx) +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_SOURCE("eevee_lookdev_display_frag.glsl") +DEPTH_WRITE(DepthWrite::ANY) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lut_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lut_info.hh index 421f1fd65e4..16c838a1ace 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lut_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_lut_info.hh @@ -5,10 +5,11 @@ #include "eevee_defines.hh" GPU_SHADER_CREATE_INFO(eevee_lut) - .local_group_size(LUT_WORKGROUP_SIZE, LUT_WORKGROUP_SIZE, 1) - .push_constant(Type::INT, "table_type") - .push_constant(Type::IVEC3, "table_extent") - .image(0, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "table_img") - .additional_info("eevee_shared") - .compute_source("eevee_lut_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(LUT_WORKGROUP_SIZE, LUT_WORKGROUP_SIZE, 1) +PUSH_CONSTANT(INT, table_type) +PUSH_CONSTANT(IVEC3, table_extent) +IMAGE(0, GPU_RGBA32F, READ_WRITE, FLOAT_3D, table_img) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_lut_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh index 6850ef64f99..b025a2d7ec5 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh @@ -11,28 +11,34 @@ /* TODO(@fclem): This is a bit out of place at the moment. */ GPU_SHADER_CREATE_INFO(eevee_shared) - .typedef_source("eevee_defines.hh") - .typedef_source("eevee_shader_shared.hh"); +TYPEDEF_SOURCE("eevee_defines.hh") +TYPEDEF_SOURCE("eevee_shader_shared.hh") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_global_ubo) - .uniform_buf(UNIFORM_BUF_SLOT, "UniformData", "uniform_buf"); +UNIFORM_BUF(UNIFORM_BUF_SLOT, UniformData, uniform_buf) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_sampling_data) - .define("EEVEE_SAMPLING_DATA") - .additional_info("eevee_shared") - .storage_buf(SAMPLING_BUF_SLOT, Qualifier::READ, "SamplingData", "sampling_buf"); +DEFINE("EEVEE_SAMPLING_DATA") +ADDITIONAL_INFO(eevee_shared) +STORAGE_BUF(SAMPLING_BUF_SLOT, READ, SamplingData, sampling_buf) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_utility_texture) - .define("EEVEE_UTILITY_TX") - .sampler(RBUFS_UTILITY_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "utility_tx"); +DEFINE("EEVEE_UTILITY_TX") +SAMPLER(RBUFS_UTILITY_TEX_SLOT, FLOAT_2D_ARRAY, utility_tx) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_clip_plane_iface, "clip_interp") - .smooth(Type::FLOAT, "clip_distance"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_clip_plane_iface, clip_interp) +SMOOTH(FLOAT, clip_distance) +GPU_SHADER_NAMED_INTERFACE_END(clip_interp) GPU_SHADER_CREATE_INFO(eevee_clip_plane) - .vertex_out(eevee_clip_plane_iface) - .uniform_buf(CLIP_PLANE_BUF, "ClipPlaneData", "clip_plane") - .define("MAT_CLIP_PLANE"); +VERTEX_OUT(eevee_clip_plane_iface) +UNIFORM_BUF(CLIP_PLANE_BUF, ClipPlaneData, clip_plane) +DEFINE("MAT_CLIP_PLANE") +GPU_SHADER_CREATE_END() /** \} */ @@ -41,100 +47,111 @@ GPU_SHADER_CREATE_INFO(eevee_clip_plane) * \{ */ /* Common interface */ -GPU_SHADER_INTERFACE_INFO(eevee_surf_iface, "interp") - /* World Position. */ - .smooth(Type::VEC3, "P") - /* World Normal. */ - .smooth(Type::VEC3, "N"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_iface, interp) +/* World Position. */ +SMOOTH(VEC3, P) +/* World Normal. */ +SMOOTH(VEC3, N) +GPU_SHADER_NAMED_INTERFACE_END(interp) GPU_SHADER_CREATE_INFO(eevee_geom_mesh) - .additional_info("eevee_shared") - .define("MAT_GEOM_MESH") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .vertex_source("eevee_geom_mesh_vert.glsl") - .vertex_out(eevee_surf_iface) - .additional_info("draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_id_varying", - "draw_view"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_MESH") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +VERTEX_SOURCE("eevee_geom_mesh_vert.glsl") +VERTEX_OUT(eevee_surf_iface) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_surf_point_cloud_iface, "point_cloud_interp") - .smooth(Type::FLOAT, "radius") - .smooth(Type::VEC3, "position"); -GPU_SHADER_INTERFACE_INFO(eevee_surf_point_cloud_flat_iface, "point_cloud_interp_flat") - .flat(Type::INT, "id"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_point_cloud_iface, point_cloud_interp) +SMOOTH(FLOAT, radius) +SMOOTH(VEC3, position) +GPU_SHADER_NAMED_INTERFACE_END(point_cloud_interp) +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_point_cloud_flat_iface, point_cloud_interp_flat) +FLAT(INT, id) +GPU_SHADER_NAMED_INTERFACE_END(point_cloud_interp_flat) GPU_SHADER_CREATE_INFO(eevee_geom_point_cloud) - .additional_info("eevee_shared") - .define("MAT_GEOM_POINT_CLOUD") - .vertex_source("eevee_geom_point_cloud_vert.glsl") - .vertex_out(eevee_surf_iface) - .vertex_out(eevee_surf_point_cloud_iface) - .vertex_out(eevee_surf_point_cloud_flat_iface) - .additional_info("draw_pointcloud_new", - "draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_id_varying", - "draw_view"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_POINT_CLOUD") +VERTEX_SOURCE("eevee_geom_point_cloud_vert.glsl") +VERTEX_OUT(eevee_surf_iface) +VERTEX_OUT(eevee_surf_point_cloud_iface) +VERTEX_OUT(eevee_surf_point_cloud_flat_iface) +ADDITIONAL_INFO(draw_pointcloud_new) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_geom_volume) - .additional_info("eevee_shared") - .define("MAT_GEOM_VOLUME") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(eevee_surf_iface) - .vertex_source("eevee_geom_volume_vert.glsl") - .additional_info("draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_id_varying", - "draw_volume_infos", - "draw_view"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_VOLUME") +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(eevee_surf_iface) +VERTEX_SOURCE("eevee_geom_volume_vert.glsl") +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_volume_infos) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_geom_gpencil) - .additional_info("eevee_shared") - .define("MAT_GEOM_GPENCIL") - .vertex_source("eevee_geom_gpencil_vert.glsl") - .vertex_out(eevee_surf_iface) - .additional_info("draw_gpencil_new", - "draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_id_varying", - "draw_resource_id_new"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_GPENCIL") +VERTEX_SOURCE("eevee_geom_gpencil_vert.glsl") +VERTEX_OUT(eevee_surf_iface) +ADDITIONAL_INFO(draw_gpencil_new) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_resource_id_new) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_surf_curve_iface, "curve_interp") - .smooth(Type::VEC2, "barycentric_coords") - .smooth(Type::VEC3, "tangent") - .smooth(Type::VEC3, "binormal") - .smooth(Type::FLOAT, "time") - .smooth(Type::FLOAT, "time_width") - .smooth(Type::FLOAT, "thickness"); -GPU_SHADER_INTERFACE_INFO(eevee_surf_curve_flat_iface, "curve_interp_flat") - .flat(Type::INT, "strand_id"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_curve_iface, curve_interp) +SMOOTH(VEC2, barycentric_coords) +SMOOTH(VEC3, tangent) +SMOOTH(VEC3, binormal) +SMOOTH(FLOAT, time) +SMOOTH(FLOAT, time_width) +SMOOTH(FLOAT, thickness) +GPU_SHADER_NAMED_INTERFACE_END(curve_interp) +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_curve_flat_iface, curve_interp_flat) +FLAT(INT, strand_id) +GPU_SHADER_NAMED_INTERFACE_END(curve_interp_flat) GPU_SHADER_CREATE_INFO(eevee_geom_curves) - .additional_info("eevee_shared") - .define("MAT_GEOM_CURVES") - .vertex_source("eevee_geom_curves_vert.glsl") - .vertex_out(eevee_surf_iface) - .vertex_out(eevee_surf_curve_iface) - .vertex_out(eevee_surf_curve_flat_iface) - .additional_info("draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_id_varying", - "draw_view", - "draw_hair_new", - "draw_curves_infos"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_CURVES") +VERTEX_SOURCE("eevee_geom_curves_vert.glsl") +VERTEX_OUT(eevee_surf_iface) +VERTEX_OUT(eevee_surf_curve_iface) +VERTEX_OUT(eevee_surf_curve_flat_iface) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_hair_new) +ADDITIONAL_INFO(draw_curves_infos) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_geom_world) - .additional_info("eevee_shared") - .define("MAT_GEOM_WORLD") - .builtins(BuiltinBits::VERTEX_ID) - .vertex_source("eevee_geom_world_vert.glsl") - .vertex_out(eevee_surf_iface) - .additional_info("draw_modelmat_new", - "draw_object_infos_new", /* Unused, but allow debug compilation. */ - "draw_resource_id_varying", - "draw_view"); +ADDITIONAL_INFO(eevee_shared) +DEFINE("MAT_GEOM_WORLD") +BUILTINS(BuiltinBits::VERTEX_ID) +VERTEX_SOURCE("eevee_geom_world_vert.glsl") +VERTEX_OUT(eevee_surf_iface) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) /* Unused, but allow debug compilation. */ +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /** \} */ @@ -148,152 +165,161 @@ GPU_SHADER_CREATE_INFO(eevee_geom_world) image(slot, format, qualifier, ImageType::FLOAT_2D_ARRAY, name, Frequency::PASS) GPU_SHADER_CREATE_INFO(eevee_render_pass_out) - .define("MAT_RENDER_PASS_SUPPORT") - .additional_info("eevee_global_ubo") - .image_array_out(RBUFS_COLOR_SLOT, Qualifier::WRITE, GPU_RGBA16F, "rp_color_img") - .image_array_out(RBUFS_VALUE_SLOT, Qualifier::WRITE, GPU_R16F, "rp_value_img"); +DEFINE("MAT_RENDER_PASS_SUPPORT") +ADDITIONAL_INFO(eevee_global_ubo) +IMAGE_FREQ(RBUFS_COLOR_SLOT, GPU_RGBA16F, WRITE, FLOAT_2D, rp_color_img, PASS) +IMAGE_FREQ(RBUFS_VALUE_SLOT, GPU_R16F, WRITE, FLOAT_2D, rp_value_img, PASS) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_cryptomatte_out) - .storage_buf(CRYPTOMATTE_BUF_SLOT, Qualifier::READ, "vec2", "cryptomatte_object_buf[]") - .image_out(RBUFS_CRYPTOMATTE_SLOT, Qualifier::WRITE, GPU_RGBA32F, "rp_cryptomatte_img"); +STORAGE_BUF(CRYPTOMATTE_BUF_SLOT, READ, vec2, cryptomatte_object_buf[]) +IMAGE_FREQ(RBUFS_CRYPTOMATTE_SLOT, GPU_RGBA32F, WRITE, FLOAT_2D, rp_cryptomatte_img, PASS) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_deferred_base) - .define("MAT_DEFERRED") - .define("GBUFFER_WRITE") - /* NOTE: This removes the possibility of using gl_FragDepth. */ - .early_fragment_test(true) - /* Direct output. (Emissive, Holdout) */ - .fragment_out(0, Type::VEC4, "out_radiance") - .fragment_out(1, Type::UINT, "out_gbuf_header", DualBlend::NONE, DEFERRED_GBUFFER_ROG_ID) - .fragment_out(2, Type::VEC2, "out_gbuf_normal") - .fragment_out(3, Type::VEC4, "out_gbuf_closure1") - .fragment_out(4, Type::VEC4, "out_gbuf_closure2") - /* Everything is stored inside a two layered target, one for each format. This is to fit the - * limitation of the number of images we can bind on a single shader. */ - .image_array_out(GBUF_CLOSURE_SLOT, Qualifier::WRITE, GPU_RGB10_A2, "out_gbuf_closure_img") - .image_array_out(GBUF_NORMAL_SLOT, Qualifier::WRITE, GPU_RG16, "out_gbuf_normal_img") - .additional_info("eevee_global_ubo", - "eevee_utility_texture", - /* Added at runtime because of test shaders not having `node_tree`. */ - // "eevee_render_pass_out", - // "eevee_cryptomatte_out", - "eevee_sampling_data", - "eevee_hiz_data"); +DEFINE("MAT_DEFERRED") +DEFINE("GBUFFER_WRITE") +/* NOTE: This removes the possibility of using gl_FragDepth. */ +EARLY_FRAGMENT_TEST(true) +/* Direct output. (Emissive, Holdout) */ +FRAGMENT_OUT(0, VEC4, out_radiance) +FRAGMENT_OUT_ROG(1, UINT, out_gbuf_header, DEFERRED_GBUFFER_ROG_ID) +FRAGMENT_OUT(2, VEC2, out_gbuf_normal) +FRAGMENT_OUT(3, VEC4, out_gbuf_closure1) +FRAGMENT_OUT(4, VEC4, out_gbuf_closure2) +/* Everything is stored inside a two layered target, one for each format. This is to fit the + * limitation of the number of images we can bind on a single shader. */ +IMAGE_FREQ(GBUF_CLOSURE_SLOT, GPU_RGB10_A2, WRITE, FLOAT_2D, out_gbuf_closure_img, PASS) +IMAGE_FREQ(GBUF_NORMAL_SLOT, GPU_RG16, WRITE, FLOAT_2D, out_gbuf_normal_img, PASS) +/* Added at runtime because of test shaders not having `node_tree`. */ +// ADDITIONAL_INFO(eevee_render_pass_out) +// ADDITIONAL_INFO(eevee_cryptomatte_out) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_hiz_data) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_deferred) - .fragment_source("eevee_surf_deferred_frag.glsl") - .additional_info("eevee_surf_deferred_base"); +FRAGMENT_SOURCE("eevee_surf_deferred_frag.glsl") +ADDITIONAL_INFO(eevee_surf_deferred_base) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_deferred_hybrid) - .fragment_source("eevee_surf_hybrid_frag.glsl") - .additional_info("eevee_surf_deferred_base", - "eevee_light_data", - "eevee_lightprobe_data", - "eevee_shadow_data"); +FRAGMENT_SOURCE("eevee_surf_hybrid_frag.glsl") +ADDITIONAL_INFO(eevee_surf_deferred_base) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_shadow_data) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_forward) - .define("MAT_FORWARD") - /* Early fragment test is needed for render passes support for forward surfaces. */ - /* NOTE: This removes the possibility of using gl_FragDepth. */ - .early_fragment_test(true) - .fragment_out(0, Type::VEC4, "out_radiance", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_transmittance", DualBlend::SRC_1) - .fragment_source("eevee_surf_forward_frag.glsl") - .additional_info("eevee_global_ubo", - "eevee_light_data", - "eevee_lightprobe_data", - "eevee_utility_texture", - "eevee_sampling_data", - "eevee_shadow_data", - "eevee_hiz_data", - "eevee_volume_lib" - /* Optionally added depending on the material. */ - // "eevee_render_pass_out", - // "eevee_cryptomatte_out", - ); +DEFINE("MAT_FORWARD") +/* Early fragment test is needed for render passes support for forward surfaces. */ +/* NOTE: This removes the possibility of using gl_FragDepth. */ +EARLY_FRAGMENT_TEST(true) +FRAGMENT_OUT_DUAL(0, VEC4, out_radiance, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_transmittance, SRC_1) +FRAGMENT_SOURCE("eevee_surf_forward_frag.glsl") +/* Optionally added depending on the material. */ +// ADDITIONAL_INFO(eevee_render_pass_out) +// ADDITIONAL_INFO(eevee_cryptomatte_out) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_volume_lib) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_capture) - .define("MAT_CAPTURE") - .storage_buf(SURFEL_BUF_SLOT, Qualifier::WRITE, "Surfel", "surfel_buf[]") - .storage_buf(CAPTURE_BUF_SLOT, Qualifier::READ_WRITE, "CaptureInfoData", "capture_info_buf") - .push_constant(Type::BOOL, "is_double_sided") - .fragment_source("eevee_surf_capture_frag.glsl") - .additional_info("eevee_global_ubo", "eevee_utility_texture"); +DEFINE("MAT_CAPTURE") +STORAGE_BUF(SURFEL_BUF_SLOT, WRITE, Surfel, surfel_buf[]) +STORAGE_BUF(CAPTURE_BUF_SLOT, READ_WRITE, CaptureInfoData, capture_info_buf) +PUSH_CONSTANT(BOOL, is_double_sided) +FRAGMENT_SOURCE("eevee_surf_capture_frag.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_utility_texture) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_depth) - .define("MAT_DEPTH") - .fragment_source("eevee_surf_depth_frag.glsl") - .additional_info("eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture"); +DEFINE("MAT_DEPTH") +FRAGMENT_SOURCE("eevee_surf_depth_frag.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_utility_texture) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_world) - .push_constant(Type::FLOAT, "world_opacity_fade") - .push_constant(Type::FLOAT, "world_background_blur") - .push_constant(Type::IVEC4, "world_coord_packed") - .early_fragment_test(true) - .fragment_out(0, Type::VEC4, "out_background") - .fragment_source("eevee_surf_world_frag.glsl") - .additional_info("eevee_global_ubo", - "eevee_lightprobe_sphere_data", - "eevee_volume_probe_data", - "eevee_sampling_data", - /* Optionally added depending on the material. */ - // "eevee_render_pass_out", - // "eevee_cryptomatte_out", - "eevee_utility_texture"); +PUSH_CONSTANT(FLOAT, world_opacity_fade) +PUSH_CONSTANT(FLOAT, world_background_blur) +PUSH_CONSTANT(IVEC4, world_coord_packed) +EARLY_FRAGMENT_TEST(true) +FRAGMENT_OUT(0, VEC4, out_background) +FRAGMENT_SOURCE("eevee_surf_world_frag.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_lightprobe_sphere_data) +ADDITIONAL_INFO(eevee_volume_probe_data) +ADDITIONAL_INFO(eevee_sampling_data) +/* Optionally added depending on the material. */ +// ADDITIONAL_INFO(eevee_render_pass_out) +// ADDITIONAL_INFO(eevee_cryptomatte_out) +ADDITIONAL_INFO(eevee_utility_texture) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_renderpass_clear) - .fragment_out(0, Type::VEC4, "out_background") - .fragment_source("eevee_renderpass_clear_frag.glsl") - .additional_info("draw_fullscreen", - "eevee_global_ubo", - "eevee_render_pass_out", - "eevee_cryptomatte_out", - "eevee_shared") - .do_static_compilation(true); +FRAGMENT_OUT(0, VEC4, out_background) +FRAGMENT_SOURCE("eevee_renderpass_clear_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_render_pass_out) +ADDITIONAL_INFO(eevee_cryptomatte_out) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_surf_shadow_atomic_iface, "shadow_iface") - .flat(Type::INT, "shadow_view_id"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_shadow_atomic_iface, shadow_iface) +FLAT(INT, shadow_view_id) +GPU_SHADER_NAMED_INTERFACE_END(shadow_iface) -GPU_SHADER_INTERFACE_INFO(eevee_surf_shadow_clipping_iface, "shadow_clip") - .smooth(Type::VEC3, "position") - .smooth(Type::VEC3, "vector"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_surf_shadow_clipping_iface, shadow_clip) +SMOOTH(VEC3, position) +SMOOTH(VEC3, vector) +GPU_SHADER_NAMED_INTERFACE_END(shadow_clip) GPU_SHADER_CREATE_INFO(eevee_surf_shadow) - .define("DRW_VIEW_LEN", STRINGIFY(SHADOW_VIEW_MAX)) - .define("MAT_SHADOW") - .builtins(BuiltinBits::VIEWPORT_INDEX) - .vertex_out(eevee_surf_shadow_clipping_iface) - .storage_buf(SHADOW_RENDER_VIEW_BUF_SLOT, - Qualifier::READ, - "ShadowRenderView", - "render_view_buf[SHADOW_VIEW_MAX]") - .fragment_source("eevee_surf_shadow_frag.glsl") - .additional_info("eevee_global_ubo", "eevee_utility_texture", "eevee_sampling_data"); +DEFINE_VALUE("DRW_VIEW_LEN", STRINGIFY(SHADOW_VIEW_MAX)) +DEFINE("MAT_SHADOW") +BUILTINS(BuiltinBits::VIEWPORT_INDEX) +VERTEX_OUT(eevee_surf_shadow_clipping_iface) +STORAGE_BUF(SHADOW_RENDER_VIEW_BUF_SLOT, READ, ShadowRenderView, render_view_buf[SHADOW_VIEW_MAX]) +FRAGMENT_SOURCE("eevee_surf_shadow_frag.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_sampling_data) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_shadow_atomic) - .additional_info("eevee_surf_shadow") - .define("SHADOW_UPDATE_ATOMIC_RASTER") - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .vertex_out(eevee_surf_shadow_atomic_iface) - .storage_buf(SHADOW_RENDER_MAP_BUF_SLOT, - Qualifier::READ, - "uint", - "render_map_buf[SHADOW_RENDER_MAP_SIZE]") - .image(SHADOW_ATLAS_IMG_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_2D_ARRAY_ATOMIC, - "shadow_atlas_img"); +ADDITIONAL_INFO(eevee_surf_shadow) +DEFINE("SHADOW_UPDATE_ATOMIC_RASTER") +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +VERTEX_OUT(eevee_surf_shadow_atomic_iface) +STORAGE_BUF(SHADOW_RENDER_MAP_BUF_SLOT, READ, uint, render_map_buf[SHADOW_RENDER_MAP_SIZE]) +IMAGE(SHADOW_ATLAS_IMG_SLOT, GPU_R32UI, READ_WRITE, UINT_2D_ARRAY_ATOMIC, shadow_atlas_img) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_shadow_tbdr) - .additional_info("eevee_surf_shadow") - .define("SHADOW_UPDATE_TBDR") - .builtins(BuiltinBits::LAYER) - /* Use greater depth write to avoid loosing the early Z depth test but ensure correct fragment - * ordering after slope bias. */ - .depth_write(DepthWrite::GREATER) - /* F32 color attachment for on-tile depth accumulation without atomics. */ - .fragment_out(0, Type::FLOAT, "out_depth", DualBlend::NONE, SHADOW_ROG_ID); +ADDITIONAL_INFO(eevee_surf_shadow) +DEFINE("SHADOW_UPDATE_TBDR") +BUILTINS(BuiltinBits::LAYER) +/* Use greater depth write to avoid loosing the early Z depth test but ensure correct fragment + * ordering after slope bias. */ +DEPTH_WRITE(DepthWrite::GREATER) +/* F32 color attachment for on-tile depth accumulation without atomics. */ +FRAGMENT_OUT_ROG(0, FLOAT, out_depth, SHADOW_ROG_ID) +GPU_SHADER_CREATE_END() #undef image_out #undef image_array_out @@ -305,66 +331,39 @@ GPU_SHADER_CREATE_INFO(eevee_surf_shadow_tbdr) * \{ */ GPU_SHADER_CREATE_INFO(eevee_surf_volume) - .define("MAT_VOLUME") - /* Only the front fragments have to be invoked. */ - .early_fragment_test(true) - .image(VOLUME_PROP_SCATTERING_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ_WRITE, - ImageType::FLOAT_3D, - "out_scattering_img") - .image(VOLUME_PROP_EXTINCTION_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ_WRITE, - ImageType::FLOAT_3D, - "out_extinction_img") - .image(VOLUME_PROP_EMISSION_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ_WRITE, - ImageType::FLOAT_3D, - "out_emissive_img") - .image(VOLUME_PROP_PHASE_IMG_SLOT, - GPU_R16F, - Qualifier::READ_WRITE, - ImageType::FLOAT_3D, - "out_phase_img") - .image(VOLUME_PROP_PHASE_WEIGHT_IMG_SLOT, - GPU_R16F, - Qualifier::READ_WRITE, - ImageType::FLOAT_3D, - "out_phase_weight_img") - .image(VOLUME_OCCUPANCY_SLOT, - GPU_R32UI, - Qualifier::READ, - ImageType::UINT_3D_ATOMIC, - "occupancy_img") - .fragment_source("eevee_surf_volume_frag.glsl") - .additional_info("draw_modelmat_new_common", - "draw_view", - "eevee_shared", - "eevee_global_ubo", - "eevee_sampling_data", - "eevee_utility_texture"); +DEFINE("MAT_VOLUME") +/* Only the front fragments have to be invoked. */ +EARLY_FRAGMENT_TEST(true) +IMAGE( + VOLUME_PROP_SCATTERING_IMG_SLOT, GPU_R11F_G11F_B10F, READ_WRITE, FLOAT_3D, out_scattering_img) +IMAGE( + VOLUME_PROP_EXTINCTION_IMG_SLOT, GPU_R11F_G11F_B10F, READ_WRITE, FLOAT_3D, out_extinction_img) +IMAGE(VOLUME_PROP_EMISSION_IMG_SLOT, GPU_R11F_G11F_B10F, READ_WRITE, FLOAT_3D, out_emissive_img) +IMAGE(VOLUME_PROP_PHASE_IMG_SLOT, GPU_R16F, READ_WRITE, FLOAT_3D, out_phase_img) +IMAGE(VOLUME_PROP_PHASE_WEIGHT_IMG_SLOT, GPU_R16F, READ_WRITE, FLOAT_3D, out_phase_weight_img) +IMAGE(VOLUME_OCCUPANCY_SLOT, GPU_R32UI, READ, UINT_3D_ATOMIC, occupancy_img) +FRAGMENT_SOURCE("eevee_surf_volume_frag.glsl") +ADDITIONAL_INFO(draw_modelmat_new_common) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_utility_texture) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_surf_occupancy) - .define("MAT_OCCUPANCY") - /* All fragments need to be invoked even if we write to the depth buffer. */ - .early_fragment_test(false) - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .push_constant(Type::BOOL, "use_fast_method") - .image(VOLUME_HIT_DEPTH_SLOT, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_3D, "hit_depth_img") - .image(VOLUME_HIT_COUNT_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_2D_ATOMIC, - "hit_count_img") - .image(VOLUME_OCCUPANCY_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_3D_ATOMIC, - "occupancy_img") - .fragment_source("eevee_surf_occupancy_frag.glsl") - .additional_info("eevee_global_ubo", "eevee_sampling_data"); +DEFINE("MAT_OCCUPANCY") +/* All fragments need to be invoked even if we write to the depth buffer. */ +EARLY_FRAGMENT_TEST(false) +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +PUSH_CONSTANT(BOOL, use_fast_method) +IMAGE(VOLUME_HIT_DEPTH_SLOT, GPU_R32F, WRITE, FLOAT_3D, hit_depth_img) +IMAGE(VOLUME_HIT_COUNT_SLOT, GPU_R32UI, READ_WRITE, UINT_2D_ATOMIC, hit_count_img) +IMAGE(VOLUME_OCCUPANCY_SLOT, GPU_R32UI, READ_WRITE, UINT_3D_ATOMIC, occupancy_img) +FRAGMENT_SOURCE("eevee_surf_occupancy_frag.glsl") +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +GPU_SHADER_CREATE_END() /** \} */ @@ -378,34 +377,32 @@ GPU_SHADER_CREATE_INFO(eevee_surf_occupancy) /* Stub functions defined by the material evaluation. */ GPU_SHADER_CREATE_INFO(eevee_material_stub) - .define("EEVEE_MATERIAL_STUBS") - /* Dummy uniform buffer to detect overlap with material node-tree. */ - .uniform_buf(0, "int", "node_tree"); - -# define EEVEE_MAT_FINAL_VARIATION(name, ...) \ - GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); +DEFINE("EEVEE_MATERIAL_STUBS") +/* Dummy uniform buffer to detect overlap with material node-tree. */ +UNIFORM_BUF(0, int, node_tree) +GPU_SHADER_CREATE_END() # define EEVEE_MAT_GEOM_VARIATIONS(prefix, ...) \ - EEVEE_MAT_FINAL_VARIATION(prefix##_world, "eevee_geom_world", __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_world, eevee_geom_world, __VA_ARGS__) \ /* Turned off until dependency on common_view/math_lib are sorted out. */ \ - /* EEVEE_MAT_FINAL_VARIATION(prefix##_gpencil, "eevee_geom_gpencil", __VA_ARGS__) */ \ - EEVEE_MAT_FINAL_VARIATION(prefix##_curves, "eevee_geom_curves", __VA_ARGS__) \ - EEVEE_MAT_FINAL_VARIATION(prefix##_mesh, "eevee_geom_mesh", __VA_ARGS__) \ - EEVEE_MAT_FINAL_VARIATION(prefix##_point_cloud, "eevee_geom_point_cloud", __VA_ARGS__) \ - EEVEE_MAT_FINAL_VARIATION(prefix##_volume, "eevee_geom_volume", __VA_ARGS__) + /* CREATE_INFO_VARIANT(prefix##_gpencil, eevee_geom_gpencil, __VA_ARGS__) */ \ + CREATE_INFO_VARIANT(prefix##_curves, eevee_geom_curves, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_mesh, eevee_geom_mesh, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_point_cloud, eevee_geom_point_cloud, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_volume, eevee_geom_volume, __VA_ARGS__) # define EEVEE_MAT_PIPE_VARIATIONS(name, ...) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_world, "eevee_surf_world", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_depth, "eevee_surf_depth", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_deferred, "eevee_surf_deferred", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_forward, "eevee_surf_forward", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_capture, "eevee_surf_capture", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_volume, "eevee_surf_volume", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_occupancy, "eevee_surf_occupancy", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_shadow_atomic, "eevee_surf_shadow_atomic", __VA_ARGS__) \ - EEVEE_MAT_GEOM_VARIATIONS(name##_shadow_tbdr, "eevee_surf_shadow_tbdr", __VA_ARGS__) + EEVEE_MAT_GEOM_VARIATIONS(name##_world, eevee_surf_world, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_depth, eevee_surf_depth, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_deferred, eevee_surf_deferred, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_forward, eevee_surf_forward, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_capture, eevee_surf_capture, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_volume, eevee_surf_volume, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_occupancy, eevee_surf_occupancy, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_shadow_atomic, eevee_surf_shadow_atomic, __VA_ARGS__) \ + EEVEE_MAT_GEOM_VARIATIONS(name##_shadow_tbdr, eevee_surf_shadow_tbdr, __VA_ARGS__) -EEVEE_MAT_PIPE_VARIATIONS(eevee_surface, "eevee_material_stub") +EEVEE_MAT_PIPE_VARIATIONS(eevee_surface, eevee_material_stub) #endif diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh index 883a57814cb..abccab4170c 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh @@ -6,43 +6,52 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_motion_blur_tiles_flatten) - .local_group_size(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view", "eevee_velocity_camera") - .uniform_buf(6, "MotionBlurData", "motion_blur_buf") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_tiles_img") - .compute_source("eevee_motion_blur_flatten_comp.glsl"); +LOCAL_GROUP_SIZE(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_velocity_camera) +UNIFORM_BUF(6, MotionBlurData, motion_blur_buf) +SAMPLER(0, DEPTH_2D, depth_tx) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D, out_tiles_img) +COMPUTE_SOURCE("eevee_motion_blur_flatten_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_motion_blur_tiles_flatten_rg) - .do_static_compilation(true) - .define("FLATTEN_RG") - .image(0, GPU_RG16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "velocity_img") - .additional_info("eevee_motion_blur_tiles_flatten"); +DO_STATIC_COMPILATION() +DEFINE("FLATTEN_RG") +IMAGE(0, GPU_RG16F, READ_WRITE, FLOAT_2D, velocity_img) +ADDITIONAL_INFO(eevee_motion_blur_tiles_flatten) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_motion_blur_tiles_flatten_rgba) - .do_static_compilation(true) - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "velocity_img") - .additional_info("eevee_motion_blur_tiles_flatten"); +DO_STATIC_COMPILATION() +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, velocity_img) +ADDITIONAL_INFO(eevee_motion_blur_tiles_flatten) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_motion_blur_tiles_dilate) - .do_static_compilation(true) - .local_group_size(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) - .additional_info("eevee_shared") - /* NOTE: See MotionBlurTileIndirection. */ - .storage_buf(0, Qualifier::READ_WRITE, "uint", "tile_indirection_buf[]") - .image(1, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_img") - .compute_source("eevee_motion_blur_dilate_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +/* NOTE: See MotionBlurTileIndirection. */ +STORAGE_BUF(0, READ_WRITE, uint, tile_indirection_buf[]) +IMAGE(1, GPU_RGBA16F, READ, FLOAT_2D, in_tiles_img) +COMPUTE_SOURCE("eevee_motion_blur_dilate_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_motion_blur_gather) - .do_static_compilation(true) - .local_group_size(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view", "eevee_sampling_data") - .uniform_buf(6, "MotionBlurData", "motion_blur_buf") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .sampler(1, ImageType::FLOAT_2D, "velocity_tx") - .sampler(2, ImageType::FLOAT_2D, "in_color_tx") - /* NOTE: See MotionBlurTileIndirection. */ - .storage_buf(0, Qualifier::READ, "uint", "tile_indirection_buf[]") - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "in_tiles_img") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_color_img") - .compute_source("eevee_motion_blur_gather_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(MOTION_BLUR_GROUP_SIZE, MOTION_BLUR_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_sampling_data) +UNIFORM_BUF(6, MotionBlurData, motion_blur_buf) +SAMPLER(0, DEPTH_2D, depth_tx) +SAMPLER(1, FLOAT_2D, velocity_tx) +SAMPLER(2, FLOAT_2D, in_color_tx) +/* NOTE: See MotionBlurTileIndirection. */ +STORAGE_BUF(0, READ, uint, tile_indirection_buf[]) +IMAGE(0, GPU_RGBA16F, READ, FLOAT_2D, in_tiles_img) +IMAGE(1, GPU_RGBA16F, WRITE, FLOAT_2D, out_color_img) +COMPUTE_SOURCE("eevee_motion_blur_gather_comp.glsl") +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh index efaeb4d722e..27e06e702b5 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh @@ -10,265 +10,280 @@ /** \name Shadow pipeline * \{ */ -/* NOTE(Metal): As this is implemented using a fundamental data type, this needs to be specified - * explicitly as uint for code generation, as the MSLShaderGenerator needs to be able to - * distinguish between classes and fundamental types during code generation. */ -#define SHADOW_TILE_DATA_PACKED "uint" -#define SHADOW_PAGE_PACKED "uint" - GPU_SHADER_CREATE_INFO(eevee_shadow_clipmap_clear) - .do_static_compilation(true) - .local_group_size(SHADOW_CLIPMAP_GROUP_SIZE) - .storage_buf(0, Qualifier::WRITE, "ShadowTileMapClip", "tilemaps_clip_buf[]") - .push_constant(Type::INT, "tilemaps_clip_buf_len") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_clipmap_clear_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_CLIPMAP_GROUP_SIZE) +STORAGE_BUF(0, WRITE, ShadowTileMapClip, tilemaps_clip_buf[]) +PUSH_CONSTANT(INT, tilemaps_clip_buf_len) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_clipmap_clear_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_bounds) - .do_static_compilation(true) - .local_group_size(SHADOW_BOUNDS_GROUP_SIZE) - .storage_buf(LIGHT_BUF_SLOT, Qualifier::READ_WRITE, "LightData", "light_buf[]") - .storage_buf(LIGHT_CULL_BUF_SLOT, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(4, Qualifier::READ, "uint", "casters_id_buf[]") - .storage_buf(5, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(6, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .storage_buf(7, Qualifier::READ_WRITE, "ShadowTileMapClip", "tilemaps_clip_buf[]") - .push_constant(Type::INT, "resource_len") - .typedef_source("draw_shader_shared.hh") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_tilemap_bounds_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_BOUNDS_GROUP_SIZE) +STORAGE_BUF(LIGHT_BUF_SLOT, READ_WRITE, LightData, light_buf[]) +STORAGE_BUF(LIGHT_CULL_BUF_SLOT, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(4, READ, uint, casters_id_buf[]) +STORAGE_BUF(5, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(6, READ, ObjectBounds, bounds_buf[]) +STORAGE_BUF(7, READ_WRITE, ShadowTileMapClip, tilemaps_clip_buf[]) +PUSH_CONSTANT(INT, resource_len) +TYPEDEF_SOURCE("draw_shader_shared.hh") +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_tilemap_bounds_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_init) - .do_static_compilation(true) - .local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) - .storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowTileMapClip", "tilemaps_clip_buf[]") - .storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_tilemap_init_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) +STORAGE_BUF(0, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowTileMapClip, tilemaps_clip_buf[]) +STORAGE_BUF(4, READ_WRITE, uvec2, pages_cached_buf[]) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_tilemap_init_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tag_update) - .do_static_compilation(true) - .local_group_size(1, 1, 1) - .storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(5, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .storage_buf(6, Qualifier::READ, "uint", "resource_ids_buf[]") - .additional_info("eevee_shared", "draw_view", "draw_view_culling") - .compute_source("eevee_shadow_tag_update_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(1, 1, 1) +STORAGE_BUF(0, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(5, READ, ObjectBounds, bounds_buf[]) +STORAGE_BUF(6, READ, uint, resource_ids_buf[]) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +COMPUTE_SOURCE("eevee_shadow_tag_update_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_opaque) - .do_static_compilation(true) - .local_group_size(SHADOW_DEPTH_SCAN_GROUP_SIZE, SHADOW_DEPTH_SCAN_GROUP_SIZE) - .storage_buf(5, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(6, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .push_constant(Type::IVEC2, "input_depth_extent") - .additional_info( - "eevee_shared", "draw_view", "draw_view_culling", "eevee_hiz_data", "eevee_light_data") - .compute_source("eevee_shadow_tag_usage_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_DEPTH_SCAN_GROUP_SIZE, SHADOW_DEPTH_SCAN_GROUP_SIZE) +STORAGE_BUF(5, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(6, READ_WRITE, uint, tiles_buf[]) +PUSH_CONSTANT(IVEC2, input_depth_extent) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_light_data) +COMPUTE_SOURCE("eevee_shadow_tag_usage_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_surfels) - .do_static_compilation(true) - .local_group_size(SURFEL_GROUP_SIZE) - .storage_buf(6, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(7, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .push_constant(Type::INT, "directional_level") - .additional_info("eevee_shared", - "draw_view", - "draw_view_culling", - "eevee_light_data", - "eevee_global_ubo", - "eevee_surfel_common") - .compute_source("eevee_shadow_tag_usage_surfels_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SURFEL_GROUP_SIZE) +STORAGE_BUF(6, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(7, READ_WRITE, uint, tiles_buf[]) +PUSH_CONSTANT(INT, directional_level) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_surfel_common) +COMPUTE_SOURCE("eevee_shadow_tag_usage_surfels_comp.glsl") +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(eevee_shadow_tag_transparent_iface, "interp") - .smooth(Type::VEC3, "P") - .smooth(Type::VEC3, "vP"); -GPU_SHADER_INTERFACE_INFO(eevee_shadow_tag_transparent_flat_iface, "interp_flat") - .flat(Type::VEC3, "ls_aabb_min") - .flat(Type::VEC3, "ls_aabb_max"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_shadow_tag_transparent_iface, interp) +SMOOTH(VEC3, P) +SMOOTH(VEC3, vP) +GPU_SHADER_NAMED_INTERFACE_END(interp) +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_shadow_tag_transparent_flat_iface, interp_flat) +FLAT(VEC3, ls_aabb_min) +FLAT(VEC3, ls_aabb_max) +GPU_SHADER_NAMED_INTERFACE_END(interp_flat) GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_transparent) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .storage_buf(4, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .storage_buf(5, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(6, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .push_constant(Type::IVEC2, "fb_resolution") - .push_constant(Type::INT, "fb_lod") - .vertex_out(eevee_shadow_tag_transparent_iface) - .vertex_out(eevee_shadow_tag_transparent_flat_iface) - .additional_info("eevee_shared", - "draw_resource_id_varying", - "draw_view", - "draw_view_culling", - "draw_modelmat_new", - "eevee_hiz_data", - "eevee_light_data") - .vertex_source("eevee_shadow_tag_usage_vert.glsl") - .fragment_source("eevee_shadow_tag_usage_frag.glsl"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +STORAGE_BUF(4, READ, ObjectBounds, bounds_buf[]) +STORAGE_BUF(5, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(6, READ_WRITE, uint, tiles_buf[]) +PUSH_CONSTANT(IVEC2, fb_resolution) +PUSH_CONSTANT(INT, fb_lod) +VERTEX_OUT(eevee_shadow_tag_transparent_iface) +VERTEX_OUT(eevee_shadow_tag_transparent_flat_iface) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_light_data) +VERTEX_SOURCE("eevee_shadow_tag_usage_vert.glsl") +FRAGMENT_SOURCE("eevee_shadow_tag_usage_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_volume) - .do_static_compilation(true) - .local_group_size(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) - .storage_buf(4, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(5, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .additional_info("eevee_volume_properties_data", - "eevee_shared", - "draw_view", - "draw_view_culling", - "eevee_hiz_data", - "eevee_light_data", - "eevee_sampling_data") - .compute_source("eevee_shadow_tag_usage_volume_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) +STORAGE_BUF(4, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(5, READ_WRITE, uint, tiles_buf[]) +ADDITIONAL_INFO(eevee_volume_properties_data) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_sampling_data) +COMPUTE_SOURCE("eevee_shadow_tag_usage_volume_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_page_mask) - .do_static_compilation(true) - .local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) - .push_constant(Type::INT, "max_view_per_tilemap") - .storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_page_mask_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) +PUSH_CONSTANT(INT, max_view_per_tilemap) +STORAGE_BUF(0, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_page_mask_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_page_free) - .do_static_compilation(true) - .local_group_size(SHADOW_TILEMAP_LOD0_LEN) - .storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf") - .storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]") - .storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_page_free_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_LOD0_LEN) +STORAGE_BUF(0, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowPagesInfoData, pages_infos_buf) +STORAGE_BUF(3, READ_WRITE, uint, pages_free_buf[]) +STORAGE_BUF(4, READ_WRITE, uvec2, pages_cached_buf[]) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_page_free_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_page_defrag) - .do_static_compilation(true) - .local_group_size(1) - .typedef_source("draw_shader_shared.hh") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf") - .storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]") - .storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]") - .storage_buf(5, Qualifier::WRITE, "DispatchCommand", "clear_dispatch_buf") - .storage_buf(6, Qualifier::WRITE, "DrawCommand", "tile_draw_buf") - .storage_buf(7, Qualifier::READ_WRITE, "ShadowStatistics", "statistics_buf") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_page_defrag_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(1) +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowPagesInfoData, pages_infos_buf) +STORAGE_BUF(3, READ_WRITE, uint, pages_free_buf[]) +STORAGE_BUF(4, READ_WRITE, uvec2, pages_cached_buf[]) +STORAGE_BUF(5, WRITE, DispatchCommand, clear_dispatch_buf) +STORAGE_BUF(6, WRITE, DrawCommand, tile_draw_buf) +STORAGE_BUF(7, READ_WRITE, ShadowStatistics, statistics_buf) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_page_defrag_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_page_allocate) - .do_static_compilation(true) - .local_group_size(SHADOW_TILEMAP_LOD0_LEN) - .typedef_source("draw_shader_shared.hh") - .storage_buf(0, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf") - .storage_buf(3, Qualifier::READ_WRITE, "uint", "pages_free_buf[]") - .storage_buf(4, Qualifier::READ_WRITE, "uvec2", "pages_cached_buf[]") - .storage_buf(6, Qualifier::READ_WRITE, "ShadowStatistics", "statistics_buf") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_page_allocate_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_LOD0_LEN) +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(0, READ_WRITE, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowPagesInfoData, pages_infos_buf) +STORAGE_BUF(3, READ_WRITE, uint, pages_free_buf[]) +STORAGE_BUF(4, READ_WRITE, uvec2, pages_cached_buf[]) +STORAGE_BUF(6, READ_WRITE, ShadowStatistics, statistics_buf) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_page_allocate_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_finalize) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) - .storage_buf(0, Qualifier::READ, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(1, Qualifier::READ, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ShadowPagesInfoData", "pages_infos_buf") - .storage_buf(3, Qualifier::READ_WRITE, "ShadowStatistics", "statistics_buf") - .storage_buf(4, Qualifier::WRITE, "ViewMatrices", "view_infos_buf[SHADOW_VIEW_MAX]") - .storage_buf(5, Qualifier::WRITE, "ShadowRenderView", "render_view_buf[SHADOW_VIEW_MAX]") - .storage_buf(6, Qualifier::READ, "ShadowTileMapClip", "tilemaps_clip_buf[]") - .image(0, GPU_R32UI, Qualifier::WRITE, ImageType::UINT_2D, "tilemaps_img") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_tilemap_finalize_comp.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) +STORAGE_BUF(0, READ, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(1, READ, uint, tiles_buf[]) +STORAGE_BUF(2, READ_WRITE, ShadowPagesInfoData, pages_infos_buf) +STORAGE_BUF(3, READ_WRITE, ShadowStatistics, statistics_buf) +STORAGE_BUF(4, WRITE, ViewMatrices, view_infos_buf[SHADOW_VIEW_MAX]) +STORAGE_BUF(5, WRITE, ShadowRenderView, render_view_buf[SHADOW_VIEW_MAX]) +STORAGE_BUF(6, READ, ShadowTileMapClip, tilemaps_clip_buf[]) +IMAGE(0, GPU_R32UI, WRITE, UINT_2D, tilemaps_img) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_tilemap_finalize_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_rendermap) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) - .storage_buf(0, Qualifier::READ_WRITE, "ShadowStatistics", "statistics_buf") - .storage_buf(1, Qualifier::READ, "ShadowRenderView", "render_view_buf[SHADOW_VIEW_MAX]") - .storage_buf(2, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .storage_buf(3, Qualifier::READ_WRITE, "DispatchCommand", "clear_dispatch_buf") - .storage_buf(4, Qualifier::READ_WRITE, "DrawCommand", "tile_draw_buf") - .storage_buf(5, Qualifier::WRITE, SHADOW_PAGE_PACKED, "dst_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .storage_buf(6, Qualifier::WRITE, SHADOW_PAGE_PACKED, "src_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .storage_buf(7, Qualifier::WRITE, SHADOW_PAGE_PACKED, "render_map_buf[SHADOW_RENDER_MAP_SIZE]") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_tilemap_rendermap_comp.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) +STORAGE_BUF(0, READ_WRITE, ShadowStatistics, statistics_buf) +STORAGE_BUF(1, READ, ShadowRenderView, render_view_buf[SHADOW_VIEW_MAX]) +STORAGE_BUF(2, READ_WRITE, uint, tiles_buf[]) +STORAGE_BUF(3, READ_WRITE, DispatchCommand, clear_dispatch_buf) +STORAGE_BUF(4, READ_WRITE, DrawCommand, tile_draw_buf) +STORAGE_BUF(5, WRITE, uint, dst_coord_buf[SHADOW_RENDER_MAP_SIZE]) +STORAGE_BUF(6, WRITE, uint, src_coord_buf[SHADOW_RENDER_MAP_SIZE]) +STORAGE_BUF(7, WRITE, uint, render_map_buf[SHADOW_RENDER_MAP_SIZE]) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_tilemap_rendermap_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_tilemap_amend) - .do_static_compilation(true) - .local_group_size(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) - .image(0, GPU_R32UI, Qualifier::READ_WRITE, ImageType::UINT_2D, "tilemaps_img") - .storage_buf(LIGHT_CULL_BUF_SLOT, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(LIGHT_BUF_SLOT, Qualifier::READ_WRITE, "LightData", "light_buf[]") - /* The call bind_resources(lights) also uses LIGHT_ZBIN_BUF_SLOT and LIGHT_TILE_BUF_SLOT. */ - .storage_buf(4, Qualifier::READ, "ShadowTileMapData", "tilemaps_buf[]") - .additional_info("eevee_shared", "draw_view") - .compute_source("eevee_shadow_tilemap_amend_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_TILEMAP_RES, SHADOW_TILEMAP_RES) +IMAGE(0, GPU_R32UI, READ_WRITE, UINT_2D, tilemaps_img) +STORAGE_BUF(LIGHT_CULL_BUF_SLOT, READ, LightCullingData, light_cull_buf) +STORAGE_BUF(LIGHT_BUF_SLOT, READ_WRITE, LightData, light_buf[]) +/* The call bind_resources(lights) also uses LIGHT_ZBIN_BUF_SLOT and LIGHT_TILE_BUF_SLOT. */ +STORAGE_BUF(4, READ, ShadowTileMapData, tilemaps_buf[]) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(draw_view) +COMPUTE_SOURCE("eevee_shadow_tilemap_amend_comp.glsl") +GPU_SHADER_CREATE_END() /* AtomicMin clear implementation. */ GPU_SHADER_CREATE_INFO(eevee_shadow_page_clear) - .do_static_compilation(true) - .local_group_size(SHADOW_PAGE_CLEAR_GROUP_SIZE, SHADOW_PAGE_CLEAR_GROUP_SIZE) - .storage_buf(2, Qualifier::READ, "ShadowPagesInfoData", "pages_infos_buf") - .storage_buf(6, Qualifier::READ, SHADOW_PAGE_PACKED, "dst_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .additional_info("eevee_shared") - .compute_source("eevee_shadow_page_clear_comp.glsl") - .image(SHADOW_ATLAS_IMG_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_2D_ARRAY_ATOMIC, - "shadow_atlas_img"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SHADOW_PAGE_CLEAR_GROUP_SIZE, SHADOW_PAGE_CLEAR_GROUP_SIZE) +STORAGE_BUF(2, READ, ShadowPagesInfoData, pages_infos_buf) +STORAGE_BUF(6, READ, uint, dst_coord_buf[SHADOW_RENDER_MAP_SIZE]) +ADDITIONAL_INFO(eevee_shared) +COMPUTE_SOURCE("eevee_shadow_page_clear_comp.glsl") +IMAGE(SHADOW_ATLAS_IMG_SLOT, GPU_R32UI, READ_WRITE, UINT_2D_ARRAY_ATOMIC, shadow_atlas_img) +GPU_SHADER_CREATE_END() /* TBDR clear implementation. */ GPU_SHADER_CREATE_INFO(eevee_shadow_page_tile_clear) - .do_static_compilation(true) - .define("PASS_CLEAR") - .additional_info("eevee_shared") - .builtins(BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER) - .storage_buf(8, Qualifier::READ, SHADOW_PAGE_PACKED, "src_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .vertex_source("eevee_shadow_page_tile_vert.glsl") - .fragment_source("eevee_shadow_page_tile_frag.glsl") - .fragment_out(0, Type::FLOAT, "out_tile_depth", DualBlend::NONE, SHADOW_ROG_ID); +DO_STATIC_COMPILATION() +DEFINE("PASS_CLEAR") +ADDITIONAL_INFO(eevee_shared) +BUILTINS(BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER) +STORAGE_BUF(8, READ, uint, src_coord_buf[SHADOW_RENDER_MAP_SIZE]) +VERTEX_SOURCE("eevee_shadow_page_tile_vert.glsl") +FRAGMENT_SOURCE("eevee_shadow_page_tile_frag.glsl") +FRAGMENT_OUT_ROG(0, FLOAT, out_tile_depth, SHADOW_ROG_ID) +GPU_SHADER_CREATE_END() #ifdef APPLE /* Metal supports USHORT which saves a bit of performance here. */ -# define PAGE_Z_TYPE Type::USHORT +# define PAGE_Z_TYPE USHORT #else -# define PAGE_Z_TYPE Type::UINT +# define PAGE_Z_TYPE UINT #endif /* Interface for passing precalculated values in accumulation vertex to frag. */ -GPU_SHADER_INTERFACE_INFO(eevee_shadow_page_tile_store_noperspective_iface, "interp_noperspective") - .no_perspective(Type::VEC2, "out_texel_xy"); -GPU_SHADER_INTERFACE_INFO(eevee_shadow_page_tile_store_flat_iface, "interp_flat") - .flat(PAGE_Z_TYPE, "out_page_z"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_shadow_page_tile_store_noperspective_iface, + interp_noperspective) +NO_PERSPECTIVE(VEC2, out_texel_xy) +GPU_SHADER_NAMED_INTERFACE_END(interp_noperspective) +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_shadow_page_tile_store_flat_iface, interp_flat) +FLAT(PAGE_Z_TYPE, out_page_z) +GPU_SHADER_NAMED_INTERFACE_END(interp_flat) #undef PAGE_Z_TYPE /* 2nd tile pass to store shadow depths in atlas. */ GPU_SHADER_CREATE_INFO(eevee_shadow_page_tile_store) - .do_static_compilation(true) - .define("PASS_DEPTH_STORE") - .additional_info("eevee_shared") - .builtins(BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER) - .storage_buf(7, Qualifier::READ, SHADOW_PAGE_PACKED, "dst_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .storage_buf(8, Qualifier::READ, SHADOW_PAGE_PACKED, "src_coord_buf[SHADOW_RENDER_MAP_SIZE]") - .subpass_in(0, Type::FLOAT, "in_tile_depth", SHADOW_ROG_ID) - .image(SHADOW_ATLAS_IMG_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_2D_ARRAY, - "shadow_atlas_img") - .vertex_out(eevee_shadow_page_tile_store_noperspective_iface) - .vertex_out(eevee_shadow_page_tile_store_flat_iface) - .vertex_source("eevee_shadow_page_tile_vert.glsl") - .fragment_source("eevee_shadow_page_tile_frag.glsl"); +DO_STATIC_COMPILATION() +DEFINE("PASS_DEPTH_STORE") +ADDITIONAL_INFO(eevee_shared) +BUILTINS(BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER) +STORAGE_BUF(7, READ, uint, dst_coord_buf[SHADOW_RENDER_MAP_SIZE]) +STORAGE_BUF(8, READ, uint, src_coord_buf[SHADOW_RENDER_MAP_SIZE]) +SUBPASS_IN(0, FLOAT, in_tile_depth, SHADOW_ROG_ID) +IMAGE(SHADOW_ATLAS_IMG_SLOT, GPU_R32UI, READ_WRITE, UINT_2D_ARRAY, shadow_atlas_img) +VERTEX_OUT(eevee_shadow_page_tile_store_noperspective_iface) +VERTEX_OUT(eevee_shadow_page_tile_store_flat_iface) +VERTEX_SOURCE("eevee_shadow_page_tile_vert.glsl") +FRAGMENT_SOURCE("eevee_shadow_page_tile_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -277,16 +292,18 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_tile_store) * \{ */ GPU_SHADER_CREATE_INFO(eevee_shadow_data) - /* SHADOW_READ_ATOMIC macro indicating shadow functions should use `usampler2DArrayAtomic` as - * the atlas type. */ - .define("SHADOW_READ_ATOMIC") - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .sampler(SHADOW_ATLAS_TEX_SLOT, ImageType::UINT_2D_ARRAY_ATOMIC, "shadow_atlas_tx") - .sampler(SHADOW_TILEMAPS_TEX_SLOT, ImageType::UINT_2D, "shadow_tilemaps_tx"); +/* SHADOW_READ_ATOMIC macro indicating shadow functions should use `usampler2DArrayAtomic` as + * the atlas type. */ +DEFINE("SHADOW_READ_ATOMIC") +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +SAMPLER(SHADOW_ATLAS_TEX_SLOT, UINT_2D_ARRAY_ATOMIC, shadow_atlas_tx) +SAMPLER(SHADOW_TILEMAPS_TEX_SLOT, UINT_2D, shadow_tilemaps_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_shadow_data_non_atomic) - .sampler(SHADOW_ATLAS_TEX_SLOT, ImageType::UINT_2D_ARRAY, "shadow_atlas_tx") - .sampler(SHADOW_TILEMAPS_TEX_SLOT, ImageType::UINT_2D, "shadow_tilemaps_tx"); +SAMPLER(SHADOW_ATLAS_TEX_SLOT, UINT_2D_ARRAY, shadow_atlas_tx) +SAMPLER(SHADOW_TILEMAPS_TEX_SLOT, UINT_2D, shadow_tilemaps_tx) +GPU_SHADER_CREATE_END() /** \} */ @@ -295,17 +312,21 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_data_non_atomic) * \{ */ GPU_SHADER_CREATE_INFO(eevee_shadow_debug) - .do_static_compilation(true) - .additional_info("eevee_shared") - .storage_buf(5, Qualifier::READ, "ShadowTileMapData", "tilemaps_buf[]") - .storage_buf(6, Qualifier::READ, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .fragment_out(0, Type::VEC4, "out_color_add", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_color_mul", DualBlend::SRC_1) - .push_constant(Type::INT, "debug_mode") - .push_constant(Type::INT, "debug_tilemap_index") - .depth_write(DepthWrite::ANY) - .fragment_source("eevee_shadow_debug_frag.glsl") - .additional_info( - "draw_fullscreen", "draw_view", "eevee_hiz_data", "eevee_light_data", "eevee_shadow_data"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(eevee_shared) +STORAGE_BUF(5, READ, ShadowTileMapData, tilemaps_buf[]) +STORAGE_BUF(6, READ, uint, tiles_buf[]) +FRAGMENT_OUT_DUAL(0, VEC4, out_color_add, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_color_mul, SRC_1) +PUSH_CONSTANT(INT, debug_mode) +PUSH_CONSTANT(INT, debug_tilemap_index) +DEPTH_WRITE(DepthWrite::ANY) +FRAGMENT_SOURCE("eevee_shadow_debug_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_shadow_data) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh index acf011bbac7..9cbf7912e55 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh @@ -6,32 +6,34 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_subsurface_setup) - .do_static_compilation(true) - .local_group_size(SUBSURFACE_GROUP_SIZE, SUBSURFACE_GROUP_SIZE) - .typedef_source("draw_shader_shared.hh") - .additional_info("draw_view", "eevee_shared", "eevee_gbuffer_data") - .sampler(2, ImageType::DEPTH_2D, "depth_tx") - .image(0, DEFERRED_RADIANCE_FORMAT, Qualifier::READ, ImageType::UINT_2D, "direct_light_img") - .image(1, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "indirect_light_img") - .image(2, SUBSURFACE_OBJECT_ID_FORMAT, Qualifier::WRITE, ImageType::UINT_2D, "object_id_img") - .image(3, SUBSURFACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "radiance_img") - .storage_buf(0, Qualifier::WRITE, "uint", "convolve_tile_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, "DispatchCommand", "convolve_dispatch_buf") - .compute_source("eevee_subsurface_setup_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SUBSURFACE_GROUP_SIZE, SUBSURFACE_GROUP_SIZE) +TYPEDEF_SOURCE("draw_shader_shared.hh") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +SAMPLER(2, DEPTH_2D, depth_tx) +IMAGE(0, DEFERRED_RADIANCE_FORMAT, READ, UINT_2D, direct_light_img) +IMAGE(1, RAYTRACE_RADIANCE_FORMAT, READ, FLOAT_2D, indirect_light_img) +IMAGE(2, SUBSURFACE_OBJECT_ID_FORMAT, WRITE, UINT_2D, object_id_img) +IMAGE(3, SUBSURFACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, radiance_img) +STORAGE_BUF(0, WRITE, uint, convolve_tile_buf[]) +STORAGE_BUF(1, READ_WRITE, DispatchCommand, convolve_dispatch_buf) +COMPUTE_SOURCE("eevee_subsurface_setup_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_subsurface_convolve) - .do_static_compilation(true) - .local_group_size(SUBSURFACE_GROUP_SIZE, SUBSURFACE_GROUP_SIZE) - .additional_info("draw_view", "eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo") - .sampler(2, ImageType::FLOAT_2D, "radiance_tx") - .sampler(3, ImageType::DEPTH_2D, "depth_tx") - .sampler(4, ImageType::UINT_2D, "object_id_tx") - .storage_buf(0, Qualifier::READ, "uint", "tiles_coord_buf[]") - .image( - 0, DEFERRED_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::UINT_2D, "out_direct_light_img") - .image(1, - RAYTRACE_RADIANCE_FORMAT, - Qualifier::WRITE, - ImageType::FLOAT_2D, - "out_indirect_light_img") - .compute_source("eevee_subsurface_convolve_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(SUBSURFACE_GROUP_SIZE, SUBSURFACE_GROUP_SIZE) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +SAMPLER(2, FLOAT_2D, radiance_tx) +SAMPLER(3, DEPTH_2D, depth_tx) +SAMPLER(4, UINT_2D, object_id_tx) +STORAGE_BUF(0, READ, uint, tiles_coord_buf[]) +IMAGE(0, DEFERRED_RADIANCE_FORMAT, WRITE, UINT_2D, out_direct_light_img) +IMAGE(1, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, out_indirect_light_img) +COMPUTE_SOURCE("eevee_subsurface_convolve_comp.glsl") +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh index bc892fed142..ff2a2acd6a7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh @@ -15,242 +15,266 @@ image(slot, format, Qualifier::READ, type, name, Frequency::PASS) GPU_SHADER_CREATE_INFO(eevee_ray_tile_classify) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo") - .typedef_source("draw_shader_shared.hh") - .image_out(0, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_raytrace_denoise_img") - .image_out(1, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_raytrace_tracing_img") - .image_out(2, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_horizon_denoise_img") - .image_out(3, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_horizon_tracing_img") - .compute_source("eevee_ray_tile_classify_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +TYPEDEF_SOURCE("draw_shader_shared.hh") +IMAGE_FREQ(0, RAYTRACE_TILEMASK_FORMAT, WRITE, UINT_2D_ARRAY, tile_raytrace_denoise_img, PASS) +IMAGE_FREQ(1, RAYTRACE_TILEMASK_FORMAT, WRITE, UINT_2D_ARRAY, tile_raytrace_tracing_img, PASS) +IMAGE_FREQ(2, RAYTRACE_TILEMASK_FORMAT, WRITE, UINT_2D_ARRAY, tile_horizon_denoise_img, PASS) +IMAGE_FREQ(3, RAYTRACE_TILEMASK_FORMAT, WRITE, UINT_2D_ARRAY, tile_horizon_tracing_img, PASS) +COMPUTE_SOURCE("eevee_ray_tile_classify_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_tile_compact) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_global_ubo") - .typedef_source("draw_shader_shared.hh") - .image_in(0, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_raytrace_denoise_img") - .image_in(1, RAYTRACE_TILEMASK_FORMAT, ImageType::UINT_2D_ARRAY, "tile_raytrace_tracing_img") - .storage_buf(0, Qualifier::READ_WRITE, "DispatchCommand", "raytrace_tracing_dispatch_buf") - .storage_buf(1, Qualifier::READ_WRITE, "DispatchCommand", "raytrace_denoise_dispatch_buf") - .storage_buf(4, Qualifier::WRITE, "uint", "raytrace_tracing_tiles_buf[]") - .storage_buf(5, Qualifier::WRITE, "uint", "raytrace_denoise_tiles_buf[]") - .specialization_constant(Type::INT, "closure_index", 0) - .specialization_constant(Type::INT, "resolution_scale", 2) - .compute_source("eevee_ray_tile_compact_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +TYPEDEF_SOURCE("draw_shader_shared.hh") +IMAGE_FREQ(0, RAYTRACE_TILEMASK_FORMAT, READ, UINT_2D_ARRAY, tile_raytrace_denoise_img, PASS) +IMAGE_FREQ(1, RAYTRACE_TILEMASK_FORMAT, READ, UINT_2D_ARRAY, tile_raytrace_tracing_img, PASS) +STORAGE_BUF(0, READ_WRITE, DispatchCommand, raytrace_tracing_dispatch_buf) +STORAGE_BUF(1, READ_WRITE, DispatchCommand, raytrace_denoise_dispatch_buf) +STORAGE_BUF(4, WRITE, uint, raytrace_tracing_tiles_buf[]) +STORAGE_BUF(5, WRITE, uint, raytrace_denoise_tiles_buf[]) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +SPECIALIZATION_CONSTANT(INT, resolution_scale, 2) +COMPUTE_SOURCE("eevee_ray_tile_compact_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_generate) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "eevee_sampling_data", - "draw_view", - "eevee_utility_texture") - .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_ray_data_img") - .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_generate_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_utility_texture) +IMAGE(0, GPU_RGBA16F, WRITE, FLOAT_2D, out_ray_data_img) +STORAGE_BUF(4, READ, uint, tiles_coord_buf[]) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_generate_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_trace_fallback) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "draw_view", - "eevee_sampling_data", - "eevee_lightprobe_data") - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "ray_data_img") - .image(1, RAYTRACE_RAYTIME_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_time_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_radiance_img") - .sampler(1, ImageType::DEPTH_2D, "depth_tx") - .storage_buf(5, Qualifier::READ, "uint", "tiles_coord_buf[]") - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_trace_fallback_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +IMAGE(0, GPU_RGBA16F, READ, FLOAT_2D, ray_data_img) +IMAGE(1, RAYTRACE_RAYTIME_FORMAT, WRITE, FLOAT_2D, ray_time_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, ray_radiance_img) +SAMPLER(1, DEPTH_2D, depth_tx) +STORAGE_BUF(5, READ, uint, tiles_coord_buf[]) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_trace_fallback_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_trace_planar) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .define("PLANAR_PROBES") - .additional_info("eevee_shared", - "eevee_global_ubo", - "eevee_sampling_data", - "eevee_gbuffer_data", - "draw_view", - "eevee_lightprobe_data", - "eevee_lightprobe_planar_data") - .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "ray_data_img") - .image(1, RAYTRACE_RAYTIME_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_time_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_radiance_img") - .sampler(2, ImageType::DEPTH_2D, "depth_tx") - .storage_buf(5, Qualifier::READ, "uint", "tiles_coord_buf[]") - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_trace_planar_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +DEFINE("PLANAR_PROBES") +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_lightprobe_planar_data) +IMAGE(0, GPU_RGBA16F, READ_WRITE, FLOAT_2D, ray_data_img) +IMAGE(1, RAYTRACE_RAYTIME_FORMAT, WRITE, FLOAT_2D, ray_time_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, ray_radiance_img) +SAMPLER(2, DEPTH_2D, depth_tx) +STORAGE_BUF(5, READ, uint, tiles_coord_buf[]) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_trace_planar_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_trace_screen) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_global_ubo", - "eevee_sampling_data", - "eevee_gbuffer_data", - "draw_view", - "eevee_hiz_data", - "eevee_lightprobe_data") - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "ray_data_img") - .image(1, RAYTRACE_RAYTIME_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_time_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_radiance_img") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .sampler(1, ImageType::FLOAT_2D, "radiance_front_tx") - .sampler(2, ImageType::FLOAT_2D, "radiance_back_tx") - .sampler(4, ImageType::FLOAT_2D, "hiz_front_tx") - .sampler(5, ImageType::FLOAT_2D, "hiz_back_tx") - .storage_buf(5, Qualifier::READ, "uint", "tiles_coord_buf[]") - .compute_source("eevee_ray_trace_screen_comp.glsl") - /* Metal: Provide compiler with hint to tune per-thread resource allocation. */ - .mtl_max_total_threads_per_threadgroup(400) - .specialization_constant(Type::BOOL, "trace_refraction", true) - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_trace_screen_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +IMAGE(0, GPU_RGBA16F, READ, FLOAT_2D, ray_data_img) +IMAGE(1, RAYTRACE_RAYTIME_FORMAT, WRITE, FLOAT_2D, ray_time_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, ray_radiance_img) +SAMPLER(0, DEPTH_2D, depth_tx) +SAMPLER(1, FLOAT_2D, radiance_front_tx) +SAMPLER(2, FLOAT_2D, radiance_back_tx) +SAMPLER(4, FLOAT_2D, hiz_front_tx) +SAMPLER(5, FLOAT_2D, hiz_back_tx) +STORAGE_BUF(5, READ, uint, tiles_coord_buf[]) +COMPUTE_SOURCE("eevee_ray_trace_screen_comp.glsl") +/* Metal: Provide compiler with hint to tune per-thread resource allocation. */ +MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(400) +SPECIALIZATION_CONSTANT(BOOL, trace_refraction, true) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_trace_screen_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_denoise_spatial) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "eevee_sampling_data", - "draw_view", - "eevee_utility_texture") - .sampler(3, ImageType::DEPTH_2D, "depth_tx") - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D, "ray_data_img") - .image(1, RAYTRACE_RAYTIME_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "ray_time_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "ray_radiance_img") - .image(3, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_radiance_img") - .image(4, RAYTRACE_VARIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_variance_img") - .image(5, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_hit_depth_img") - .image(6, RAYTRACE_TILEMASK_FORMAT, Qualifier::READ, ImageType::UINT_2D_ARRAY, "tile_mask_img") - .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - /* Metal: Provide compiler with hint to tune per-thread resource allocation. */ - .mtl_max_total_threads_per_threadgroup(316) - .specialization_constant(Type::INT, "raytrace_resolution_scale", 2) - .specialization_constant(Type::BOOL, "skip_denoise", false) - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_denoise_spatial_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_utility_texture) +SAMPLER(3, DEPTH_2D, depth_tx) +IMAGE(0, GPU_RGBA16F, READ, FLOAT_2D, ray_data_img) +IMAGE(1, RAYTRACE_RAYTIME_FORMAT, READ, FLOAT_2D, ray_time_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, READ, FLOAT_2D, ray_radiance_img) +IMAGE(3, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, out_radiance_img) +IMAGE(4, RAYTRACE_VARIANCE_FORMAT, WRITE, FLOAT_2D, out_variance_img) +IMAGE(5, GPU_R32F, WRITE, FLOAT_2D, out_hit_depth_img) +IMAGE(6, RAYTRACE_TILEMASK_FORMAT, READ, UINT_2D_ARRAY, tile_mask_img) +STORAGE_BUF(4, READ, uint, tiles_coord_buf[]) +/* Metal: Provide compiler with hint to tune per-thread resource allocation. */ +MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(316) +SPECIALIZATION_CONSTANT(INT, raytrace_resolution_scale, 2) +SPECIALIZATION_CONSTANT(BOOL, skip_denoise, false) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_denoise_spatial_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_denoise_temporal) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_global_ubo", "draw_view") - .sampler(0, ImageType::FLOAT_2D, "radiance_history_tx") - .sampler(1, ImageType::FLOAT_2D, "variance_history_tx") - .sampler(2, ImageType::UINT_2D_ARRAY, "tilemask_history_tx") - .sampler(3, ImageType::DEPTH_2D, "depth_tx") - .image(0, GPU_R32F, Qualifier::READ, ImageType::FLOAT_2D, "hit_depth_img") - .image(1, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_radiance_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_radiance_img") - .image(3, RAYTRACE_VARIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_variance_img") - .image(4, RAYTRACE_VARIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_variance_img") - .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .compute_source("eevee_ray_denoise_temporal_comp.glsl") - /* Metal: Provide compiler with hint to tune per-thread resource allocation. */ - .mtl_max_total_threads_per_threadgroup(512) - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_denoise_temporal_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_view) +SAMPLER(0, FLOAT_2D, radiance_history_tx) +SAMPLER(1, FLOAT_2D, variance_history_tx) +SAMPLER(2, UINT_2D_ARRAY, tilemask_history_tx) +SAMPLER(3, DEPTH_2D, depth_tx) +IMAGE(0, GPU_R32F, READ, FLOAT_2D, hit_depth_img) +IMAGE(1, RAYTRACE_RADIANCE_FORMAT, READ, FLOAT_2D, in_radiance_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, out_radiance_img) +IMAGE(3, RAYTRACE_VARIANCE_FORMAT, READ, FLOAT_2D, in_variance_img) +IMAGE(4, RAYTRACE_VARIANCE_FORMAT, WRITE, FLOAT_2D, out_variance_img) +STORAGE_BUF(4, READ, uint, tiles_coord_buf[]) +COMPUTE_SOURCE("eevee_ray_denoise_temporal_comp.glsl") +/* Metal: Provide compiler with hint to tune per-thread resource allocation. */ +MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(512) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_denoise_temporal_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_ray_denoise_bilateral) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "eevee_sampling_data", - "draw_view") - .sampler(1, ImageType::DEPTH_2D, "depth_tx") - .image(1, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_radiance_img") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_radiance_img") - .image(3, RAYTRACE_VARIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_variance_img") - .image(6, RAYTRACE_TILEMASK_FORMAT, Qualifier::READ, ImageType::UINT_2D_ARRAY, "tile_mask_img") - .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .specialization_constant(Type::INT, "closure_index", 0) - .compute_source("eevee_ray_denoise_bilateral_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(draw_view) +SAMPLER(1, DEPTH_2D, depth_tx) +IMAGE(1, RAYTRACE_RADIANCE_FORMAT, READ, FLOAT_2D, in_radiance_img) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, out_radiance_img) +IMAGE(3, RAYTRACE_VARIANCE_FORMAT, READ, FLOAT_2D, in_variance_img) +IMAGE(6, RAYTRACE_TILEMASK_FORMAT, READ, UINT_2D_ARRAY, tile_mask_img) +STORAGE_BUF(4, READ, uint, tiles_coord_buf[]) +SPECIALIZATION_CONSTANT(INT, closure_index, 0) +COMPUTE_SOURCE("eevee_ray_denoise_bilateral_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_horizon_setup) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "draw_view") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .sampler(1, ImageType::FLOAT_2D, "in_radiance_tx") - .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_radiance_img") - .image(3, GPU_RGB10_A2, Qualifier::WRITE, ImageType::FLOAT_2D, "out_normal_img") - .compute_source("eevee_horizon_setup_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_view) +SAMPLER(0, DEPTH_2D, depth_tx) +SAMPLER(1, FLOAT_2D, in_radiance_tx) +IMAGE(2, RAYTRACE_RADIANCE_FORMAT, WRITE, FLOAT_2D, out_radiance_img) +IMAGE(3, GPU_RGB10_A2, WRITE, FLOAT_2D, out_normal_img) +COMPUTE_SOURCE("eevee_horizon_setup_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_horizon_scan) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "eevee_sampling_data", - "eevee_utility_texture", - "eevee_hiz_data", - "draw_view") - .specialization_constant(Type::INT, "fast_gi_slice_count", 2) - .specialization_constant(Type::INT, "fast_gi_step_count", 8) - .specialization_constant(Type::BOOL, "fast_gi_ao_only", false) - .sampler(0, ImageType::FLOAT_2D, "screen_radiance_tx") - .sampler(1, ImageType::FLOAT_2D, "screen_normal_tx") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "horizon_radiance_0_img") - .image(3, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "horizon_radiance_1_img") - .image(4, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "horizon_radiance_2_img") - .image(5, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "horizon_radiance_3_img") - .storage_buf(7, Qualifier::READ, "uint", "tiles_coord_buf[]") - /* Metal: Provide compiler with hint to tune per-thread resource allocation. */ - .mtl_max_total_threads_per_threadgroup(400) - .compute_source("eevee_horizon_scan_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(draw_view) +SPECIALIZATION_CONSTANT(INT, fast_gi_slice_count, 2) +SPECIALIZATION_CONSTANT(INT, fast_gi_step_count, 8) +SPECIALIZATION_CONSTANT(BOOL, fast_gi_ao_only, false) +SAMPLER(0, FLOAT_2D, screen_radiance_tx) +SAMPLER(1, FLOAT_2D, screen_normal_tx) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, horizon_radiance_0_img) +IMAGE(3, GPU_RGBA8, WRITE, FLOAT_2D, horizon_radiance_1_img) +IMAGE(4, GPU_RGBA8, WRITE, FLOAT_2D, horizon_radiance_2_img) +IMAGE(5, GPU_RGBA8, WRITE, FLOAT_2D, horizon_radiance_3_img) +STORAGE_BUF(7, READ, uint, tiles_coord_buf[]) +/* Metal: Provide compiler with hint to tune per-thread resource allocation. */ +MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(400) +COMPUTE_SOURCE("eevee_horizon_scan_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_horizon_denoise) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info( - "eevee_shared", "eevee_global_ubo", "eevee_sampling_data", "eevee_hiz_data", "draw_view") - .sampler(2, ImageType::FLOAT_2D, "in_sh_0_tx") - .sampler(4, ImageType::FLOAT_2D, "in_sh_1_tx") - .sampler(5, ImageType::FLOAT_2D, "in_sh_2_tx") - .sampler(6, ImageType::FLOAT_2D, "in_sh_3_tx") - .sampler(7, ImageType::FLOAT_2D, "screen_normal_tx") - .image(2, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_sh_0_img") - .image(3, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "out_sh_1_img") - .image(4, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "out_sh_2_img") - .image(5, GPU_RGBA8, Qualifier::WRITE, ImageType::FLOAT_2D, "out_sh_3_img") - .storage_buf(7, Qualifier::READ, "uint", "tiles_coord_buf[]") - .compute_source("eevee_horizon_denoise_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_hiz_data) +ADDITIONAL_INFO(draw_view) +SAMPLER(2, FLOAT_2D, in_sh_0_tx) +SAMPLER(4, FLOAT_2D, in_sh_1_tx) +SAMPLER(5, FLOAT_2D, in_sh_2_tx) +SAMPLER(6, FLOAT_2D, in_sh_3_tx) +SAMPLER(7, FLOAT_2D, screen_normal_tx) +IMAGE(2, GPU_RGBA16F, WRITE, FLOAT_2D, out_sh_0_img) +IMAGE(3, GPU_RGBA8, WRITE, FLOAT_2D, out_sh_1_img) +IMAGE(4, GPU_RGBA8, WRITE, FLOAT_2D, out_sh_2_img) +IMAGE(5, GPU_RGBA8, WRITE, FLOAT_2D, out_sh_3_img) +STORAGE_BUF(7, READ, uint, tiles_coord_buf[]) +COMPUTE_SOURCE("eevee_horizon_denoise_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_horizon_resolve) - .do_static_compilation(true) - .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", - "eevee_gbuffer_data", - "eevee_global_ubo", - "eevee_sampling_data", - "eevee_lightprobe_data", - "draw_view") - .sampler(1, ImageType::DEPTH_2D, "depth_tx") - .sampler(2, ImageType::FLOAT_2D, "horizon_radiance_0_tx") - .sampler(3, ImageType::FLOAT_2D, "horizon_radiance_1_tx") - .sampler(4, ImageType::FLOAT_2D, "horizon_radiance_2_tx") - .sampler(5, ImageType::FLOAT_2D, "horizon_radiance_3_tx") - .sampler(8, ImageType::FLOAT_2D, "screen_normal_tx") - .image(3, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "closure0_img") - .image(4, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "closure1_img") - .image(5, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "closure2_img") - .storage_buf(7, Qualifier::READ, "uint", "tiles_coord_buf[]") - /* Metal: Provide compiler with hint to tune per-thread resource allocation. */ - .mtl_max_total_threads_per_threadgroup(400) - .compute_source("eevee_horizon_resolve_comp.glsl"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_gbuffer_data) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(draw_view) +SAMPLER(1, DEPTH_2D, depth_tx) +SAMPLER(2, FLOAT_2D, horizon_radiance_0_tx) +SAMPLER(3, FLOAT_2D, horizon_radiance_1_tx) +SAMPLER(4, FLOAT_2D, horizon_radiance_2_tx) +SAMPLER(5, FLOAT_2D, horizon_radiance_3_tx) +SAMPLER(8, FLOAT_2D, screen_normal_tx) +IMAGE(3, RAYTRACE_RADIANCE_FORMAT, READ_WRITE, FLOAT_2D, closure0_img) +IMAGE(4, RAYTRACE_RADIANCE_FORMAT, READ_WRITE, FLOAT_2D, closure1_img) +IMAGE(5, RAYTRACE_RADIANCE_FORMAT, READ_WRITE, FLOAT_2D, closure2_img) +STORAGE_BUF(7, READ, uint, tiles_coord_buf[]) +/* Metal: Provide compiler with hint to tune per-thread resource allocation. */ +MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(400) +COMPUTE_SOURCE("eevee_horizon_resolve_comp.glsl") +GPU_SHADER_CREATE_END() #undef image_out #undef image_in diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh index ae8937e301d..4886ee77149 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh @@ -14,38 +14,39 @@ /* Pass world space deltas to the fragment shader. * This is to make sure that the resulting motion vectors are valid even with displacement. */ -GPU_SHADER_INTERFACE_INFO(eevee_velocity_surface_iface, "motion") - .smooth(Type::VEC3, "prev") - .smooth(Type::VEC3, "next"); +GPU_SHADER_NAMED_INTERFACE_INFO(eevee_velocity_surface_iface, motion) +SMOOTH(VEC3, prev) +SMOOTH(VEC3, next) +GPU_SHADER_NAMED_INTERFACE_END(motion) GPU_SHADER_CREATE_INFO(eevee_velocity_camera) - .define("VELOCITY_CAMERA") - .uniform_buf(VELOCITY_CAMERA_PREV_BUF, "CameraData", "camera_prev") - .uniform_buf(VELOCITY_CAMERA_CURR_BUF, "CameraData", "camera_curr") - .uniform_buf(VELOCITY_CAMERA_NEXT_BUF, "CameraData", "camera_next"); +DEFINE("VELOCITY_CAMERA") +UNIFORM_BUF(VELOCITY_CAMERA_PREV_BUF, CameraData, camera_prev) +UNIFORM_BUF(VELOCITY_CAMERA_CURR_BUF, CameraData, camera_curr) +UNIFORM_BUF(VELOCITY_CAMERA_NEXT_BUF, CameraData, camera_next) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_velocity_geom) - .define("MAT_VELOCITY") - .storage_buf(VELOCITY_OBJ_PREV_BUF_SLOT, Qualifier::READ, "mat4", "velocity_obj_prev_buf[]") - .storage_buf(VELOCITY_OBJ_NEXT_BUF_SLOT, Qualifier::READ, "mat4", "velocity_obj_next_buf[]") - .storage_buf(VELOCITY_GEO_PREV_BUF_SLOT, Qualifier::READ, "vec4", "velocity_geo_prev_buf[]") - .storage_buf(VELOCITY_GEO_NEXT_BUF_SLOT, Qualifier::READ, "vec4", "velocity_geo_next_buf[]") - .storage_buf(VELOCITY_INDIRECTION_BUF_SLOT, - Qualifier::READ, - "VelocityIndex", - "velocity_indirection_buf[]") - .vertex_out(eevee_velocity_surface_iface) - .fragment_out(0, Type::VEC4, "out_velocity") - .additional_info("eevee_velocity_camera"); +DEFINE("MAT_VELOCITY") +STORAGE_BUF(VELOCITY_OBJ_PREV_BUF_SLOT, READ, mat4, velocity_obj_prev_buf[]) +STORAGE_BUF(VELOCITY_OBJ_NEXT_BUF_SLOT, READ, mat4, velocity_obj_next_buf[]) +STORAGE_BUF(VELOCITY_GEO_PREV_BUF_SLOT, READ, vec4, velocity_geo_prev_buf[]) +STORAGE_BUF(VELOCITY_GEO_NEXT_BUF_SLOT, READ, vec4, velocity_geo_next_buf[]) +STORAGE_BUF(VELOCITY_INDIRECTION_BUF_SLOT, READ, VelocityIndex, velocity_indirection_buf[]) +VERTEX_OUT(eevee_velocity_surface_iface) +FRAGMENT_OUT(0, VEC4, out_velocity) +ADDITIONAL_INFO(eevee_velocity_camera) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_vertex_copy) - .compute_source("eevee_vertex_copy_comp.glsl") - .local_group_size(VERTEX_COPY_GROUP_SIZE) - .storage_buf(0, Qualifier::READ, "float", "in_buf[]") - .storage_buf(1, Qualifier::WRITE, "vec4", "out_buf[]") - .push_constant(Type::INT, "start_offset") - .push_constant(Type::INT, "vertex_stride") - .push_constant(Type::INT, "vertex_count") - .do_static_compilation(true); +COMPUTE_SOURCE("eevee_vertex_copy_comp.glsl") +LOCAL_GROUP_SIZE(VERTEX_COPY_GROUP_SIZE) +STORAGE_BUF(0, READ, float, in_buf[]) +STORAGE_BUF(1, WRITE, vec4, out_buf[]) +PUSH_CONSTANT(INT, start_offset) +PUSH_CONSTANT(INT, vertex_stride) +PUSH_CONSTANT(INT, vertex_count) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh index e3d55fc6cec..d49d0a27267 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh @@ -8,100 +8,88 @@ /* Used for shaders that need the final accumulated volume transmittance and scattering. */ GPU_SHADER_CREATE_INFO(eevee_volume_lib) - .additional_info("eevee_shared", "eevee_global_ubo", "draw_view") - .sampler(VOLUME_SCATTERING_TEX_SLOT, ImageType::FLOAT_3D, "volume_scattering_tx") - .sampler(VOLUME_TRANSMITTANCE_TEX_SLOT, ImageType::FLOAT_3D, "volume_transmittance_tx"); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_view) +SAMPLER(VOLUME_SCATTERING_TEX_SLOT, FLOAT_3D, volume_scattering_tx) +SAMPLER(VOLUME_TRANSMITTANCE_TEX_SLOT, FLOAT_3D, volume_transmittance_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_properties_data) - .additional_info("eevee_global_ubo") - .image(VOLUME_PROP_SCATTERING_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ, - ImageType::FLOAT_3D, - "in_scattering_img") - .image(VOLUME_PROP_EXTINCTION_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ, - ImageType::FLOAT_3D, - "in_extinction_img") - .image(VOLUME_PROP_EMISSION_IMG_SLOT, - GPU_R11F_G11F_B10F, - Qualifier::READ, - ImageType::FLOAT_3D, - "in_emission_img") - .image( - VOLUME_PROP_PHASE_IMG_SLOT, GPU_R16F, Qualifier::READ, ImageType::FLOAT_3D, "in_phase_img") - .image(VOLUME_PROP_PHASE_WEIGHT_IMG_SLOT, - GPU_R16F, - Qualifier::READ, - ImageType::FLOAT_3D, - "in_phase_weight_img"); +ADDITIONAL_INFO(eevee_global_ubo) +IMAGE(VOLUME_PROP_SCATTERING_IMG_SLOT, GPU_R11F_G11F_B10F, READ, FLOAT_3D, in_scattering_img) +IMAGE(VOLUME_PROP_EXTINCTION_IMG_SLOT, GPU_R11F_G11F_B10F, READ, FLOAT_3D, in_extinction_img) +IMAGE(VOLUME_PROP_EMISSION_IMG_SLOT, GPU_R11F_G11F_B10F, READ, FLOAT_3D, in_emission_img) +IMAGE(VOLUME_PROP_PHASE_IMG_SLOT, GPU_R16F, READ, FLOAT_3D, in_phase_img) +IMAGE(VOLUME_PROP_PHASE_WEIGHT_IMG_SLOT, GPU_R16F, READ, FLOAT_3D, in_phase_weight_img) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_scatter) - .local_group_size(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) - .additional_info("eevee_shared") - .additional_info("eevee_global_ubo") - .additional_info("draw_resource_id_varying") - .additional_info("draw_view") - .additional_info("eevee_light_data") - .additional_info("eevee_lightprobe_data") - .additional_info("eevee_shadow_data") - .additional_info("eevee_sampling_data") - .additional_info("eevee_utility_texture") - .additional_info("eevee_volume_properties_data") - .sampler(0, ImageType::FLOAT_3D, "scattering_history_tx") - .sampler(1, ImageType::FLOAT_3D, "extinction_history_tx") - .image(5, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_scattering_img") - .image(6, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_extinction_img") - .compute_source("eevee_volume_scatter_comp.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_light_data) +ADDITIONAL_INFO(eevee_lightprobe_data) +ADDITIONAL_INFO(eevee_shadow_data) +ADDITIONAL_INFO(eevee_sampling_data) +ADDITIONAL_INFO(eevee_utility_texture) +ADDITIONAL_INFO(eevee_volume_properties_data) +SAMPLER(0, FLOAT_3D, scattering_history_tx) +SAMPLER(1, FLOAT_3D, extinction_history_tx) +IMAGE(5, GPU_R11F_G11F_B10F, WRITE, FLOAT_3D, out_scattering_img) +IMAGE(6, GPU_R11F_G11F_B10F, WRITE, FLOAT_3D, out_extinction_img) +COMPUTE_SOURCE("eevee_volume_scatter_comp.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_scatter_with_lights) - .additional_info("eevee_volume_scatter") - .define("VOLUME_LIGHTING") - .define("VOLUME_IRRADIANCE") - .define("VOLUME_SHADOW") - .sampler(9, ImageType::FLOAT_3D, "extinction_tx") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_volume_scatter) +DEFINE("VOLUME_LIGHTING") +DEFINE("VOLUME_IRRADIANCE") +DEFINE("VOLUME_SHADOW") +SAMPLER(9, FLOAT_3D, extinction_tx) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_occupancy_convert) - .additional_info("eevee_shared", "eevee_global_ubo", "draw_fullscreen") - .builtins(BuiltinBits::TEXTURE_ATOMIC) - .image(VOLUME_HIT_DEPTH_SLOT, GPU_R32F, Qualifier::READ, ImageType::FLOAT_3D, "hit_depth_img") - .image(VOLUME_HIT_COUNT_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_2D, - "hit_count_img") - .image(VOLUME_OCCUPANCY_SLOT, - GPU_R32UI, - Qualifier::READ_WRITE, - ImageType::UINT_3D_ATOMIC, - "occupancy_img") - .fragment_source("eevee_occupancy_convert_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_fullscreen) +BUILTINS(BuiltinBits::TEXTURE_ATOMIC) +IMAGE(VOLUME_HIT_DEPTH_SLOT, GPU_R32F, READ, FLOAT_3D, hit_depth_img) +IMAGE(VOLUME_HIT_COUNT_SLOT, GPU_R32UI, READ_WRITE, UINT_2D, hit_count_img) +IMAGE(VOLUME_OCCUPANCY_SLOT, GPU_R32UI, READ_WRITE, UINT_3D_ATOMIC, occupancy_img) +FRAGMENT_SOURCE("eevee_occupancy_convert_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_integration) - .additional_info("eevee_shared", "eevee_global_ubo", "draw_view") - .additional_info("eevee_sampling_data") - .compute_source("eevee_volume_integration_comp.glsl") - .local_group_size(VOLUME_INTEGRATION_GROUP_SIZE, VOLUME_INTEGRATION_GROUP_SIZE, 1) - /* Inputs. */ - .sampler(0, ImageType::FLOAT_3D, "in_scattering_tx") - .sampler(1, ImageType::FLOAT_3D, "in_extinction_tx") - /* Outputs. */ - .image(0, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_scattering_img") - .image(1, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_transmittance_img") - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_global_ubo) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(eevee_sampling_data) +COMPUTE_SOURCE("eevee_volume_integration_comp.glsl") +LOCAL_GROUP_SIZE(VOLUME_INTEGRATION_GROUP_SIZE, VOLUME_INTEGRATION_GROUP_SIZE, 1) +/* Inputs. */ +SAMPLER(0, FLOAT_3D, in_scattering_tx) +SAMPLER(1, FLOAT_3D, in_extinction_tx) +/* Outputs. */ +IMAGE(0, GPU_R11F_G11F_B10F, WRITE, FLOAT_3D, out_scattering_img) +IMAGE(1, GPU_R11F_G11F_B10F, WRITE, FLOAT_3D, out_transmittance_img) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_volume_resolve) - .additional_info("eevee_shared") - .additional_info("eevee_volume_lib") - .additional_info("draw_fullscreen") - .additional_info("eevee_render_pass_out") - .additional_info("eevee_hiz_data") - .fragment_source("eevee_volume_resolve_frag.glsl") - .fragment_out(0, Type::VEC4, "out_radiance", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_transmittance", DualBlend::SRC_1) - /** TODO(Miguel Pozo): Volume RenderPasses. */ - .do_static_compilation(true); +ADDITIONAL_INFO(eevee_shared) +ADDITIONAL_INFO(eevee_volume_lib) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(eevee_render_pass_out) +ADDITIONAL_INFO(eevee_hiz_data) +FRAGMENT_SOURCE("eevee_volume_resolve_frag.glsl") +FRAGMENT_OUT_DUAL(0, VEC4, out_radiance, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_transmittance, SRC_1) +/** TODO(Miguel Pozo): Volume RenderPasses. */ +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh index f3231e79e50..9e547aa8dfa 100644 --- a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh +++ b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_info.hh @@ -10,49 +10,53 @@ /** \name GPencil Object rendering * \{ */ -GPU_SHADER_INTERFACE_INFO(gpencil_geometry_iface, "gp_interp") - .smooth(Type::VEC4, "color_mul") - .smooth(Type::VEC4, "color_add") - .smooth(Type::VEC3, "pos") - .smooth(Type::VEC2, "uv"); -GPU_SHADER_INTERFACE_INFO(gpencil_geometry_flat_iface, "gp_interp_flat") - .flat(Type::VEC2, "aspect") - .flat(Type::VEC4, "sspos") - .flat(Type::UINT, "mat_flag") - .flat(Type::FLOAT, "depth"); -GPU_SHADER_INTERFACE_INFO(gpencil_geometry_noperspective_iface, "gp_interp_noperspective") - .no_perspective(Type::VEC2, "thickness") - .no_perspective(Type::FLOAT, "hardness"); +GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_iface, gp_interp) +SMOOTH(VEC4, color_mul) +SMOOTH(VEC4, color_add) +SMOOTH(VEC3, pos) +SMOOTH(VEC2, uv) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp) +GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_flat_iface, gp_interp_flat) +FLAT(VEC2, aspect) +FLAT(VEC4, sspos) +FLAT(UINT, mat_flag) +FLAT(FLOAT, depth) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_flat) +GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_geometry_noperspective_iface, gp_interp_noperspective) +NO_PERSPECTIVE(VEC2, thickness) +NO_PERSPECTIVE(FLOAT, hardness) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective) GPU_SHADER_CREATE_INFO(gpencil_geometry) - .do_static_compilation(true) - .define("GP_LIGHT") - .typedef_source("gpencil_defines.h") - .sampler(2, ImageType::FLOAT_2D, "gpFillTexture") - .sampler(3, ImageType::FLOAT_2D, "gpStrokeTexture") - .sampler(4, ImageType::DEPTH_2D, "gpSceneDepthTexture") - .sampler(5, ImageType::FLOAT_2D, "gpMaskTexture") - .uniform_buf(4, "gpMaterial", "gp_materials[GPENCIL_MATERIAL_BUFFER_LEN]", Frequency::BATCH) - .uniform_buf(3, "gpLight", "gp_lights[GPENCIL_LIGHT_BUFFER_LEN]", Frequency::BATCH) - .push_constant(Type::VEC2, "viewportSize") - /* Per Object */ - .push_constant(Type::VEC3, "gpNormal") - .push_constant(Type::BOOL, "gpStrokeOrder3d") - .push_constant(Type::INT, "gpMaterialOffset") - /* Per Layer */ - .push_constant(Type::FLOAT, "gpVertexColorOpacity") - .push_constant(Type::VEC4, "gpLayerTint") - .push_constant(Type::FLOAT, "gpLayerOpacity") - .push_constant(Type::FLOAT, "gpStrokeIndexOffset") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "revealColor") - .vertex_out(gpencil_geometry_iface) - .vertex_out(gpencil_geometry_flat_iface) - .vertex_out(gpencil_geometry_noperspective_iface) - .vertex_source("gpencil_vert.glsl") - .fragment_source("gpencil_frag.glsl") - .depth_write(DepthWrite::ANY) - .additional_info("draw_gpencil"); +DO_STATIC_COMPILATION() +DEFINE("GP_LIGHT") +TYPEDEF_SOURCE("gpencil_defines.h") +SAMPLER(2, FLOAT_2D, gpFillTexture) +SAMPLER(3, FLOAT_2D, gpStrokeTexture) +SAMPLER(4, DEPTH_2D, gpSceneDepthTexture) +SAMPLER(5, FLOAT_2D, gpMaskTexture) +UNIFORM_BUF_FREQ(4, gpMaterial, gp_materials[GPENCIL_MATERIAL_BUFFER_LEN], BATCH) +UNIFORM_BUF_FREQ(3, gpLight, gp_lights[GPENCIL_LIGHT_BUFFER_LEN], BATCH) +PUSH_CONSTANT(VEC2, viewportSize) +/* Per Object */ +PUSH_CONSTANT(VEC3, gpNormal) +PUSH_CONSTANT(BOOL, gpStrokeOrder3d) +PUSH_CONSTANT(INT, gpMaterialOffset) +/* Per Layer */ +PUSH_CONSTANT(FLOAT, gpVertexColorOpacity) +PUSH_CONSTANT(VEC4, gpLayerTint) +PUSH_CONSTANT(FLOAT, gpLayerOpacity) +PUSH_CONSTANT(FLOAT, gpStrokeIndexOffset) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, revealColor) +VERTEX_OUT(gpencil_geometry_iface) +VERTEX_OUT(gpencil_geometry_flat_iface) +VERTEX_OUT(gpencil_geometry_noperspective_iface) +VERTEX_SOURCE("gpencil_vert.glsl") +FRAGMENT_SOURCE("gpencil_frag.glsl") +DEPTH_WRITE(DepthWrite::ANY) +ADDITIONAL_INFO(draw_gpencil) +GPU_SHADER_CREATE_END() /** \} */ @@ -61,35 +65,38 @@ GPU_SHADER_CREATE_INFO(gpencil_geometry) * \{ */ GPU_SHADER_CREATE_INFO(gpencil_layer_blend) - .do_static_compilation(true) - .sampler(0, ImageType::FLOAT_2D, "colorBuf") - .sampler(1, ImageType::FLOAT_2D, "revealBuf") - .sampler(2, ImageType::FLOAT_2D, "maskBuf") - .push_constant(Type::INT, "blendMode") - .push_constant(Type::FLOAT, "blendOpacity") - /* Reminder: This is considered SRC color in blend equations. - * Same operation on all buffers. */ - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "fragRevealage") - .fragment_source("gpencil_layer_blend_frag.glsl") - .additional_info("draw_fullscreen"); +DO_STATIC_COMPILATION() +SAMPLER(0, FLOAT_2D, colorBuf) +SAMPLER(1, FLOAT_2D, revealBuf) +SAMPLER(2, FLOAT_2D, maskBuf) +PUSH_CONSTANT(INT, blendMode) +PUSH_CONSTANT(FLOAT, blendOpacity) +/* Reminder: This is considered SRC color in blend equations. + * Same operation on all buffers. */ +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, fragRevealage) +FRAGMENT_SOURCE("gpencil_layer_blend_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_mask_invert) - .do_static_compilation(true) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "fragRevealage") - .fragment_source("gpencil_mask_invert_frag.glsl") - .additional_info("draw_fullscreen"); +DO_STATIC_COMPILATION() +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, fragRevealage) +FRAGMENT_SOURCE("gpencil_mask_invert_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_depth_merge) - .do_static_compilation(true) - .push_constant(Type::VEC4, "gpModelMatrix", 4) - .push_constant(Type::BOOL, "strokeOrder3d") - .sampler(0, ImageType::DEPTH_2D, "depthBuf") - .vertex_source("gpencil_depth_merge_vert.glsl") - .fragment_source("gpencil_depth_merge_frag.glsl") - .depth_write(DepthWrite::ANY) - .additional_info("draw_view"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT_ARRAY(VEC4, gpModelMatrix, 4) +PUSH_CONSTANT(BOOL, strokeOrder3d) +SAMPLER(0, DEPTH_2D, depthBuf) +VERTEX_SOURCE("gpencil_depth_merge_vert.glsl") +FRAGMENT_SOURCE("gpencil_depth_merge_frag.glsl") +DEPTH_WRITE(DepthWrite::ANY) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /** \} */ @@ -97,53 +104,58 @@ GPU_SHADER_CREATE_INFO(gpencil_depth_merge) /** \name Anti-Aliasing * \{ */ -GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface, "") - .smooth(Type::VEC2, "uvs") - .smooth(Type::VEC2, "pixcoord") - .smooth(Type::VEC4, "offset[3]"); +GPU_SHADER_INTERFACE_INFO(gpencil_antialiasing_iface) +SMOOTH(VEC2, uvs) +SMOOTH(VEC2, pixcoord) +SMOOTH(VEC4, offset[3]) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpencil_antialiasing) - .define("SMAA_GLSL_3") - .define("SMAA_RT_METRICS", "viewportMetrics") - .define("SMAA_PRESET_HIGH") - .define("SMAA_LUMA_WEIGHT", "float4(lumaWeight, lumaWeight, lumaWeight, 0.0)") - .define("SMAA_NO_DISCARD") - .vertex_out(gpencil_antialiasing_iface) - .push_constant(Type::VEC4, "viewportMetrics") - .push_constant(Type::FLOAT, "lumaWeight") - .vertex_source("gpencil_antialiasing_vert.glsl") - .fragment_source("gpencil_antialiasing_frag.glsl"); +DEFINE("SMAA_GLSL_3") +DEFINE_VALUE("SMAA_RT_METRICS", "viewportMetrics") +DEFINE("SMAA_PRESET_HIGH") +DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(lumaWeight, lumaWeight, lumaWeight, 0.0)") +DEFINE("SMAA_NO_DISCARD") +VERTEX_OUT(gpencil_antialiasing_iface) +PUSH_CONSTANT(VEC4, viewportMetrics) +PUSH_CONSTANT(FLOAT, lumaWeight) +VERTEX_SOURCE("gpencil_antialiasing_vert.glsl") +FRAGMENT_SOURCE("gpencil_antialiasing_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_0) - .define("SMAA_STAGE", "0") - .sampler(0, ImageType::FLOAT_2D, "colorTex") - .sampler(1, ImageType::FLOAT_2D, "revealTex") - .fragment_out(0, Type::VEC2, "out_edges") - .additional_info("gpencil_antialiasing") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "0") +SAMPLER(0, FLOAT_2D, colorTex) +SAMPLER(1, FLOAT_2D, revealTex) +FRAGMENT_OUT(0, VEC2, out_edges) +ADDITIONAL_INFO(gpencil_antialiasing) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_1) - .define("SMAA_STAGE", "1") - .sampler(0, ImageType::FLOAT_2D, "edgesTex") - .sampler(1, ImageType::FLOAT_2D, "areaTex") - .sampler(2, ImageType::FLOAT_2D, "searchTex") - .fragment_out(0, Type::VEC4, "out_weights") - .additional_info("gpencil_antialiasing") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "1") +SAMPLER(0, FLOAT_2D, edgesTex) +SAMPLER(1, FLOAT_2D, areaTex) +SAMPLER(2, FLOAT_2D, searchTex) +FRAGMENT_OUT(0, VEC4, out_weights) +ADDITIONAL_INFO(gpencil_antialiasing) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_antialiasing_stage_2) - .define("SMAA_STAGE", "2") - .sampler(0, ImageType::FLOAT_2D, "colorTex") - .sampler(1, ImageType::FLOAT_2D, "revealTex") - .sampler(2, ImageType::FLOAT_2D, "blendTex") - .push_constant(Type::FLOAT, "mixFactor") - .push_constant(Type::FLOAT, "taaAccumulatedWeight") - .push_constant(Type::BOOL, "doAntiAliasing") - .push_constant(Type::BOOL, "onlyAlpha") - /* Reminder: Blending func is `fragRevealage * DST + fragColor`. */ - .fragment_out(0, Type::VEC4, "out_color", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "out_reveal", DualBlend::SRC_1) - .additional_info("gpencil_antialiasing") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "2") +SAMPLER(0, FLOAT_2D, colorTex) +SAMPLER(1, FLOAT_2D, revealTex) +SAMPLER(2, FLOAT_2D, blendTex) +PUSH_CONSTANT(FLOAT, mixFactor) +PUSH_CONSTANT(FLOAT, taaAccumulatedWeight) +PUSH_CONSTANT(BOOL, doAntiAliasing) +PUSH_CONSTANT(BOOL, onlyAlpha) +/* Reminder: Blending func is `fragRevealage * DST + fragColor`. */ +FRAGMENT_OUT_DUAL(0, VEC4, out_color, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, out_reveal, SRC_1) +ADDITIONAL_INFO(gpencil_antialiasing) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_vfx_info.hh b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_vfx_info.hh index bdfa7228e1e..5bf7d6bbbfd 100644 --- a/source/blender/draw/engines/gpencil/shaders/infos/gpencil_vfx_info.hh +++ b/source/blender/draw/engines/gpencil/shaders/infos/gpencil_vfx_info.hh @@ -5,92 +5,109 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpencil_fx_common) - .sampler(0, ImageType::FLOAT_2D, "colorBuf") - .sampler(1, ImageType::FLOAT_2D, "revealBuf") - /* Reminder: This is considered SRC color in blend equations. - * Same operation on all buffers. */ - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "fragRevealage") - .fragment_source("gpencil_vfx_frag.glsl"); +SAMPLER(0, FLOAT_2D, colorBuf) +SAMPLER(1, FLOAT_2D, revealBuf) +/* Reminder: This is considered SRC color in blend equations. + * Same operation on all buffers. */ +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, fragRevealage) +FRAGMENT_SOURCE("gpencil_vfx_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_composite) - .do_static_compilation(true) - .define("COMPOSITE") - .push_constant(Type::BOOL, "isFirstPass") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("COMPOSITE") +PUSH_CONSTANT(BOOL, isFirstPass) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_colorize) - .do_static_compilation(true) - .define("COLORIZE") - .push_constant(Type::VEC3, "lowColor") - .push_constant(Type::VEC3, "highColor") - .push_constant(Type::FLOAT, "factor") - .push_constant(Type::INT, "mode") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("COLORIZE") +PUSH_CONSTANT(VEC3, lowColor) +PUSH_CONSTANT(VEC3, highColor) +PUSH_CONSTANT(FLOAT, factor) +PUSH_CONSTANT(INT, mode) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_blur) - .do_static_compilation(true) - .define("BLUR") - .push_constant(Type::VEC2, "offset") - .push_constant(Type::INT, "sampCount") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("BLUR") +PUSH_CONSTANT(VEC2, offset) +PUSH_CONSTANT(INT, sampCount) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_transform) - .do_static_compilation(true) - .define("TRANSFORM") - .push_constant(Type::VEC2, "axisFlip") - .push_constant(Type::VEC2, "waveDir") - .push_constant(Type::VEC2, "waveOffset") - .push_constant(Type::FLOAT, "wavePhase") - .push_constant(Type::VEC2, "swirlCenter") - .push_constant(Type::FLOAT, "swirlAngle") - .push_constant(Type::FLOAT, "swirlRadius") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("TRANSFORM") +PUSH_CONSTANT(VEC2, axisFlip) +PUSH_CONSTANT(VEC2, waveDir) +PUSH_CONSTANT(VEC2, waveOffset) +PUSH_CONSTANT(FLOAT, wavePhase) +PUSH_CONSTANT(VEC2, swirlCenter) +PUSH_CONSTANT(FLOAT, swirlAngle) +PUSH_CONSTANT(FLOAT, swirlRadius) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_glow) - .do_static_compilation(true) - .define("GLOW") - .push_constant(Type::VEC4, "glowColor") - .push_constant(Type::VEC2, "offset") - .push_constant(Type::INT, "sampCount") - .push_constant(Type::VEC4, "threshold") - .push_constant(Type::BOOL, "firstPass") - .push_constant(Type::BOOL, "glowUnder") - .push_constant(Type::INT, "blendMode") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("GLOW") +PUSH_CONSTANT(VEC4, glowColor) +PUSH_CONSTANT(VEC2, offset) +PUSH_CONSTANT(INT, sampCount) +PUSH_CONSTANT(VEC4, threshold) +PUSH_CONSTANT(BOOL, firstPass) +PUSH_CONSTANT(BOOL, glowUnder) +PUSH_CONSTANT(INT, blendMode) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_rim) - .do_static_compilation(true) - .define("RIM") - .push_constant(Type::VEC2, "blurDir") - .push_constant(Type::VEC2, "uvOffset") - .push_constant(Type::VEC3, "rimColor") - .push_constant(Type::VEC3, "maskColor") - .push_constant(Type::INT, "sampCount") - .push_constant(Type::INT, "blendMode") - .push_constant(Type::BOOL, "isFirstPass") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("RIM") +PUSH_CONSTANT(VEC2, blurDir) +PUSH_CONSTANT(VEC2, uvOffset) +PUSH_CONSTANT(VEC3, rimColor) +PUSH_CONSTANT(VEC3, maskColor) +PUSH_CONSTANT(INT, sampCount) +PUSH_CONSTANT(INT, blendMode) +PUSH_CONSTANT(BOOL, isFirstPass) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_shadow) - .do_static_compilation(true) - .define("SHADOW") - .push_constant(Type::VEC4, "shadowColor") - .push_constant(Type::VEC2, "uvRotX") - .push_constant(Type::VEC2, "uvRotY") - .push_constant(Type::VEC2, "uvOffset") - .push_constant(Type::VEC2, "blurDir") - .push_constant(Type::VEC2, "waveDir") - .push_constant(Type::VEC2, "waveOffset") - .push_constant(Type::FLOAT, "wavePhase") - .push_constant(Type::INT, "sampCount") - .push_constant(Type::BOOL, "isFirstPass") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("SHADOW") +PUSH_CONSTANT(VEC4, shadowColor) +PUSH_CONSTANT(VEC2, uvRotX) +PUSH_CONSTANT(VEC2, uvRotY) +PUSH_CONSTANT(VEC2, uvOffset) +PUSH_CONSTANT(VEC2, blurDir) +PUSH_CONSTANT(VEC2, waveDir) +PUSH_CONSTANT(VEC2, waveOffset) +PUSH_CONSTANT(FLOAT, wavePhase) +PUSH_CONSTANT(INT, sampCount) +PUSH_CONSTANT(BOOL, isFirstPass) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpencil_fx_pixelize) - .do_static_compilation(true) - .define("PIXELIZE") - .push_constant(Type::VEC2, "targetPixelSize") - .push_constant(Type::VEC2, "targetPixelOffset") - .push_constant(Type::VEC2, "accumOffset") - .push_constant(Type::INT, "sampCount") - .additional_info("gpencil_fx_common", "draw_fullscreen"); +DO_STATIC_COMPILATION() +DEFINE("PIXELIZE") +PUSH_CONSTANT(VEC2, targetPixelSize) +PUSH_CONSTANT(VEC2, targetPixelOffset) +PUSH_CONSTANT(VEC2, accumOffset) +PUSH_CONSTANT(INT, sampCount) +ADDITIONAL_INFO(gpencil_fx_common) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/image/shaders/infos/engine_image_info.hh b/source/blender/draw/engines/image/shaders/infos/engine_image_info.hh index 16b80a8a453..65b054c1515 100644 --- a/source/blender/draw/engines/image/shaders/infos/engine_image_info.hh +++ b/source/blender/draw/engines/image/shaders/infos/engine_image_info.hh @@ -4,33 +4,39 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(image_engine_color_iface, "").smooth(Type::VEC2, "uv_screen"); +GPU_SHADER_INTERFACE_INFO(image_engine_color_iface) +SMOOTH(VEC2, uv_screen) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(image_engine_color_shader) - .vertex_in(0, Type::IVEC2, "pos") - .vertex_out(image_engine_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::VEC4, "shuffle") - .push_constant(Type::VEC2, "farNearDistances") - .push_constant(Type::IVEC2, "offset") - .push_constant(Type::INT, "drawFlags") - .push_constant(Type::BOOL, "imgPremultiplied") - .sampler(0, ImageType::FLOAT_2D, "imageTexture") - .sampler(1, ImageType::DEPTH_2D, "depth_texture") - .vertex_source("image_engine_color_vert.glsl") - .fragment_source("image_engine_color_frag.glsl") - .additional_info("draw_modelmat") - .do_static_compilation(true); +VERTEX_IN(0, IVEC2, pos) +VERTEX_OUT(image_engine_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(VEC4, shuffle) +PUSH_CONSTANT(VEC2, farNearDistances) +PUSH_CONSTANT(IVEC2, offset) +PUSH_CONSTANT(INT, drawFlags) +PUSH_CONSTANT(BOOL, imgPremultiplied) +SAMPLER(0, FLOAT_2D, imageTexture) +SAMPLER(1, DEPTH_2D, depth_texture) +VERTEX_SOURCE("image_engine_color_vert.glsl") +FRAGMENT_SOURCE("image_engine_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(image_engine_depth_iface, "").smooth(Type::VEC2, "uv_image"); +GPU_SHADER_INTERFACE_INFO(image_engine_depth_iface) +SMOOTH(VEC2, uv_image) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(image_engine_depth_shader) - .vertex_in(0, Type::IVEC2, "pos") - .vertex_in(1, Type::VEC2, "uv") - .vertex_out(image_engine_depth_iface) - .push_constant(Type::VEC4, "min_max_uv") - .vertex_source("image_engine_depth_vert.glsl") - .fragment_source("image_engine_depth_frag.glsl") - .additional_info("draw_modelmat") - .depth_write(DepthWrite::ANY) - .do_static_compilation(true); +VERTEX_IN(0, IVEC2, pos) +VERTEX_IN(1, VEC2, uv) +VERTEX_OUT(image_engine_depth_iface) +PUSH_CONSTANT(VEC4, min_max_uv) +VERTEX_SOURCE("image_engine_depth_vert.glsl") +FRAGMENT_SOURCE("image_engine_depth_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +DEPTH_WRITE(DepthWrite::ANY) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_antialiasing_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_antialiasing_info.hh index 2baa3d9ef27..11004b510ba 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_antialiasing_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_antialiasing_info.hh @@ -5,20 +5,23 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(overlay_antialiasing) - .do_static_compilation(true) - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .sampler(1, ImageType::FLOAT_2D, "colorTex") - .sampler(2, ImageType::FLOAT_2D, "lineTex") - .push_constant(Type::BOOL, "doSmoothLines") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_antialiasing_frag.glsl") - .additional_info("draw_fullscreen", "draw_globals"); +DO_STATIC_COMPILATION() +SAMPLER(0, DEPTH_2D, depthTex) +SAMPLER(1, FLOAT_2D, colorTex) +SAMPLER(2, FLOAT_2D, lineTex) +PUSH_CONSTANT(BOOL, doSmoothLines) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_antialiasing_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_xray_fade) - .do_static_compilation(true) - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .sampler(1, ImageType::DEPTH_2D, "xrayDepthTex") - .push_constant(Type::FLOAT, "opacity") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_xray_fade_frag.glsl") - .additional_info("draw_fullscreen"); +DO_STATIC_COMPILATION() +SAMPLER(0, DEPTH_2D, depthTex) +SAMPLER(1, DEPTH_2D, xrayDepthTex) +PUSH_CONSTANT(FLOAT, opacity) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_xray_fade_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh index 591c33a07d6..32d92e87c0b 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh @@ -5,58 +5,72 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(overlay_frag_output) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput"); +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_wire_iface, "") - .flat(Type::VEC4, "finalColor") - .flat(Type::VEC2, "edgeStart") - .no_perspective(Type::VEC2, "edgePos"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_wire_iface) +FLAT(VEC4, finalColor) +FLAT(VEC2, edgeStart) +NO_PERSPECTIVE(VEC2, edgePos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_common) - .push_constant(Type::FLOAT, "alpha") - .additional_info("draw_view"); +PUSH_CONSTANT(FLOAT, alpha) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /* -------------------------------------------------------------------- */ /** \name Armature Sphere * \{ */ GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline) - .do_static_compilation(true) - .vertex_in(0, Type::VEC2, "pos") - /* Per instance. */ - .vertex_in(1, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_sphere_outline_vert.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC2, pos) +/* Per instance. */ +VERTEX_IN(1, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_sphere_outline_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_sphere_outline_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_sphere_outline", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_sphere_outline) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_sphere_solid_iface, "") - .flat(Type::VEC3, "finalStateColor") - .flat(Type::VEC3, "finalBoneColor") - .flat(Type::MAT4, "sphereMatrix") - .smooth(Type::VEC3, "viewPosition"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_sphere_solid_iface) +FLAT(VEC3, finalStateColor) +FLAT(VEC3, finalBoneColor) +FLAT(MAT4, sphereMatrix) +SMOOTH(VEC3, viewPosition) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid) - .do_static_compilation(true) - .vertex_in(0, Type::VEC2, "pos") - /* Per instance. */ - .vertex_in(1, Type::VEC4, "color") - .vertex_in(2, Type::MAT4, "inst_obmat") - .depth_write(DepthWrite::GREATER) - .vertex_out(overlay_armature_sphere_solid_iface) - .vertex_source("overlay_armature_sphere_solid_vert.glsl") - .fragment_source("overlay_armature_sphere_solid_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals") - .depth_write(DepthWrite::ANY); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC2, pos) +/* Per instance. */ +VERTEX_IN(1, VEC4, color) +VERTEX_IN(2, MAT4, inst_obmat) +DEPTH_WRITE(DepthWrite::GREATER) +VERTEX_OUT(overlay_armature_sphere_solid_iface) +VERTEX_SOURCE("overlay_armature_sphere_solid_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_sphere_solid_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +DEPTH_WRITE(DepthWrite::ANY) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_sphere_solid", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_sphere_solid) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -64,153 +78,186 @@ GPU_SHADER_CREATE_INFO(overlay_armature_sphere_solid_clipped) /** \name Armature Shapes * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_iface, "geom_in") - .smooth(Type::VEC4, "pPos") - .smooth(Type::VEC3, "vPos") - .smooth(Type::VEC2, "ssPos") - .smooth(Type::VEC4, "vColSize"); -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_flat_iface, "geom_flat_in") - .flat(Type::INT, "inverted"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_outline_iface, geom_in) +SMOOTH(VEC4, pPos) +SMOOTH(VEC3, vPos) +SMOOTH(VEC2, ssPos) +SMOOTH(VEC4, vColSize) +GPU_SHADER_NAMED_INTERFACE_END(geom_in) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_outline_flat_iface, geom_flat_in) +FLAT(INT, inverted) +GPU_SHADER_NAMED_INTERFACE_END(geom_flat_in) -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_no_geom_iface, "") - .flat(Type::VEC4, "finalColor") - .flat(Type::VEC2, "edgeStart") - .no_perspective(Type::VEC2, "edgePos"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_outline_no_geom_iface) +FLAT(VEC4, finalColor) +FLAT(VEC2, edgeStart) +NO_PERSPECTIVE(VEC2, edgePos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - /* Per instance. */ - .vertex_in(3, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_shape_outline_iface) - .vertex_out(overlay_armature_shape_outline_flat_iface) - .geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2) - .geometry_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_shape_outline_vert.glsl") - .geometry_source("overlay_armature_shape_outline_geom.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +/* Per instance. */ +VERTEX_IN(3, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_shape_outline_iface) +VERTEX_OUT(overlay_armature_shape_outline_flat_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2) +GEOMETRY_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_shape_outline_vert.glsl") +GEOMETRY_SOURCE("overlay_armature_shape_outline_geom.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - /* Per instance. */ - .vertex_in(3, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_shape_outline_no_geom_iface) - .vertex_source("overlay_armature_shape_outline_vert_no_geom.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +/* Per instance. */ +VERTEX_IN(3, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_shape_outline_no_geom_iface) +VERTEX_SOURCE("overlay_armature_shape_outline_vert_no_geom.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_next) - .do_static_compilation(true) - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "mat4", "data_buf[]") - .push_constant(Type::IVEC2, "gpu_attr_0") - .vertex_out(overlay_armature_shape_outline_no_geom_iface) - .vertex_source("overlay_armature_shape_outline_next_vert.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", - "overlay_armature_common", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +STORAGE_BUF(1, READ, mat4, data_buf[]) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +VERTEX_OUT(overlay_armature_shape_outline_no_geom_iface) +VERTEX_SOURCE("overlay_armature_shape_outline_next_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_shape_outline", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_shape_outline) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_outline_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .additional_info("overlay_armature_shape_outline_no_geom", "drw_clipped"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_shape_outline_no_geom) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_solid_iface, "") - .smooth(Type::VEC4, "finalColor") - .flat(Type::INT, "inverted"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_solid_iface) +SMOOTH(VEC4, finalColor) +FLAT(INT, inverted) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_solid) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - /* Per instance. */ - .vertex_in(2, Type::MAT4, "inst_obmat") - .depth_write(DepthWrite::GREATER) - .vertex_out(overlay_armature_shape_solid_iface) - .vertex_source("overlay_armature_shape_solid_vert.glsl") - .fragment_source("overlay_armature_shape_solid_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +/* Per instance. */ +VERTEX_IN(2, MAT4, inst_obmat) +DEPTH_WRITE(DepthWrite::GREATER) +VERTEX_OUT(overlay_armature_shape_solid_iface) +VERTEX_SOURCE("overlay_armature_shape_solid_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_shape_solid_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_solid_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_shape_solid", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_shape_solid) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_next_iface, "") - .flat(Type::VEC4, "finalColor") - .flat(Type::FLOAT, "wire_width") - .no_perspective(Type::FLOAT, "edgeCoord"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_next_iface) +FLAT(VEC4, finalColor) +FLAT(FLOAT, wire_width) +NO_PERSPECTIVE(FLOAT, edgeCoord) +GPU_SHADER_INTERFACE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_iface, "geometry_in") - .flat(Type::VEC4, "finalColor") - .flat(Type::FLOAT, "wire_width"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_iface, geometry_in) +FLAT(VEC4, finalColor) +FLAT(FLOAT, wire_width) +GPU_SHADER_NAMED_INTERFACE_END(geometry_in) -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_geom_iface, "geometry_out") - .flat(Type::VEC4, "finalColor") - .flat(Type::FLOAT, "wire_width"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_geom_iface, geometry_out) +FLAT(VEC4, finalColor) +FLAT(FLOAT, wire_width) +GPU_SHADER_NAMED_INTERFACE_END(geometry_out) -GPU_SHADER_INTERFACE_INFO(overlay_armature_shape_wire_geom_noperspective_iface, - "geometry_noperspective_out") - .no_perspective(Type::FLOAT, "edgeCoord"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_armature_shape_wire_geom_noperspective_iface, + geometry_noperspective_out) +NO_PERSPECTIVE(FLOAT, edgeCoord) +GPU_SHADER_NAMED_INTERFACE_END(geometry_noperspective_out) GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire) - .do_static_compilation(true) - .push_constant(Type::BOOL, "do_smooth_wire") - .vertex_in(0, Type::VEC3, "pos") - /* Per instance. */ - .vertex_in(2, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_shape_wire_iface) - .vertex_source("overlay_armature_shape_wire_vert.glsl") - .geometry_out(overlay_armature_shape_wire_geom_iface) - .geometry_out(overlay_armature_shape_wire_geom_noperspective_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) - .geometry_source("overlay_armature_shape_wire_geom.glsl") - .fragment_source("overlay_armature_shape_wire_frag.glsl") - .typedef_source("overlay_shader_shared.h") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(BOOL, do_smooth_wire) +VERTEX_IN(0, VEC3, pos) +/* Per instance. */ +VERTEX_IN(2, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_shape_wire_iface) +VERTEX_SOURCE("overlay_armature_shape_wire_vert.glsl") +GEOMETRY_OUT(overlay_armature_shape_wire_geom_iface) +GEOMETRY_OUT(overlay_armature_shape_wire_geom_noperspective_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) +GEOMETRY_SOURCE("overlay_armature_shape_wire_geom.glsl") +FRAGMENT_SOURCE("overlay_armature_shape_wire_frag.glsl") +TYPEDEF_SOURCE("overlay_shader_shared.h") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_shape_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_shape_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .push_constant(Type::BOOL, "do_smooth_wire") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(2, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_shape_wire_vert_no_geom.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .typedef_source("overlay_shader_shared.h") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +PUSH_CONSTANT(BOOL, do_smooth_wire) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(2, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_shape_wire_vert_no_geom.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +TYPEDEF_SOURCE("overlay_shader_shared.h") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_next) - .do_static_compilation(true) - .define("NO_GEOM") - .push_constant(Type::BOOL, "do_smooth_wire") - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "mat4", "data_buf[]") - .push_constant(Type::IVEC2, "gpu_attr_0") - .define("inst_obmat", "data_buf[gl_InstanceID]") - .vertex_out(overlay_armature_shape_wire_next_iface) - .vertex_source("overlay_armature_shape_wire_next_vert.glsl") - .fragment_source("overlay_armature_shape_wire_frag.glsl") - .typedef_source("overlay_shader_shared.h") - .additional_info("overlay_frag_output", - "overlay_armature_common", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("NO_GEOM") +PUSH_CONSTANT(BOOL, do_smooth_wire) +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +STORAGE_BUF(1, READ, mat4, data_buf[]) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +DEFINE_VALUE("inst_obmat", "data_buf[gl_InstanceID]") +VERTEX_OUT(overlay_armature_shape_wire_next_iface) +VERTEX_SOURCE("overlay_armature_shape_wire_next_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_shape_wire_frag.glsl") +TYPEDEF_SOURCE("overlay_shader_shared.h") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() /** \} */ @@ -219,49 +266,59 @@ GPU_SHADER_CREATE_INFO(overlay_armature_shape_wire_next) * \{ */ GPU_SHADER_CREATE_INFO(overlay_armature_envelope_outline) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC2, "pos0") - .vertex_in(1, Type::VEC2, "pos1") - .vertex_in(2, Type::VEC2, "pos2") - /* Per instance. */ - .vertex_in(3, Type::VEC4, "headSphere") - .vertex_in(4, Type::VEC4, "tailSphere") - .vertex_in(5, Type::VEC4, "outlineColorSize") - .vertex_in(6, Type::VEC3, "xAxis") - .vertex_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_envelope_outline_vert.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC2, pos0) +VERTEX_IN(1, VEC2, pos1) +VERTEX_IN(2, VEC2, pos2) +/* Per instance. */ +VERTEX_IN(3, VEC4, headSphere) +VERTEX_IN(4, VEC4, tailSphere) +VERTEX_IN(5, VEC4, outlineColorSize) +VERTEX_IN(6, VEC3, xAxis) +VERTEX_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_envelope_outline_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_envelope_outline_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_envelope_outline", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_envelope_outline) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_armature_envelope_solid_iface, "") - .flat(Type::VEC3, "finalStateColor") - .flat(Type::VEC3, "finalBoneColor") - .smooth(Type::VEC3, "normalView"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_envelope_solid_iface) +FLAT(VEC3, finalStateColor) +FLAT(VEC3, finalBoneColor) +SMOOTH(VEC3, normalView) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - /* Per instance. Assumed to be in world coordinate already. */ - .vertex_in(1, Type::VEC4, "headSphere") - .vertex_in(2, Type::VEC4, "tailSphere") - .vertex_in(3, Type::VEC3, "xAxis") - .vertex_in(4, Type::VEC3, "stateColor") - .vertex_in(5, Type::VEC3, "boneColor") - .vertex_out(overlay_armature_envelope_solid_iface) - .push_constant(Type::BOOL, "isDistance") - .vertex_source("overlay_armature_envelope_solid_vert.glsl") - .fragment_source("overlay_armature_envelope_solid_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +/* Per instance. Assumed to be in world coordinate already. */ +VERTEX_IN(1, VEC4, headSphere) +VERTEX_IN(2, VEC4, tailSphere) +VERTEX_IN(3, VEC3, xAxis) +VERTEX_IN(4, VEC3, stateColor) +VERTEX_IN(5, VEC3, boneColor) +VERTEX_OUT(overlay_armature_envelope_solid_iface) +PUSH_CONSTANT(BOOL, isDistance) +VERTEX_SOURCE("overlay_armature_envelope_solid_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_envelope_solid_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_envelope_solid", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_envelope_solid) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -269,34 +326,40 @@ GPU_SHADER_CREATE_INFO(overlay_armature_envelope_solid_clipped) /** \name Armature Stick * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_armature_stick_iface, "") - .no_perspective(Type::FLOAT, "colorFac") - .flat(Type::VEC4, "finalWireColor") - .flat(Type::VEC4, "finalInnerColor"); +GPU_SHADER_INTERFACE_INFO(overlay_armature_stick_iface) +NO_PERSPECTIVE(FLOAT, colorFac) +FLAT(VEC4, finalWireColor) +FLAT(VEC4, finalInnerColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_armature_stick) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - /* Bone aligned screen space. */ - .vertex_in(0, Type::VEC2, "pos") - .vertex_in(1, Type::UINT, "flag") - /* Per instance. Assumed to be in world coordinate already. */ - .vertex_in(2, Type::VEC3, "boneStart") - .vertex_in(3, Type::VEC3, "boneEnd") - /* alpha encode if we do wire. If 0.0 we don't. */ - .vertex_in(4, Type::VEC4, "wireColor") - .vertex_in(5, Type::VEC4, "boneColor") - .vertex_in(6, Type::VEC4, "headColor") - .vertex_in(7, Type::VEC4, "tailColor") - .define("do_wire", "(wireColor.a > 0.0)") - .vertex_out(overlay_armature_stick_iface) - .vertex_source("overlay_armature_stick_vert.glsl") - .fragment_source("overlay_armature_stick_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +/* Bone aligned screen space. */ +VERTEX_IN(0, VEC2, pos) +VERTEX_IN(1, UINT, flag) +/* Per instance. Assumed to be in world coordinate already. */ +VERTEX_IN(2, VEC3, boneStart) +VERTEX_IN(3, VEC3, boneEnd) +/* alpha encode if we do wire. If 0.0 we don't. */ +VERTEX_IN(4, VEC4, wireColor) +VERTEX_IN(5, VEC4, boneColor) +VERTEX_IN(6, VEC4, headColor) +VERTEX_IN(7, VEC4, tailColor) +DEFINE_VALUE("do_wire", "(wireColor.a > 0.0)") +VERTEX_OUT(overlay_armature_stick_iface) +VERTEX_SOURCE("overlay_armature_stick_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_stick_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_stick_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_stick", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_stick) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -305,20 +368,25 @@ GPU_SHADER_CREATE_INFO(overlay_armature_stick_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_armature_dof) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC2, "pos") - /* Per instance. Assumed to be in world coordinate already. */ - .vertex_in(1, Type::VEC4, "color") - .vertex_in(2, Type::MAT4, "inst_obmat") - .vertex_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_dof_vert.glsl") - .fragment_source("overlay_armature_dof_solid_frag.glsl") - .additional_info("overlay_frag_output", "overlay_armature_common", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC2, pos) +/* Per instance. Assumed to be in world coordinate already. */ +VERTEX_IN(1, VEC4, color) +VERTEX_IN(2, MAT4, inst_obmat) +VERTEX_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_dof_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_dof_solid_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(overlay_armature_common) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_dof_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_dof", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_dof) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -327,18 +395,23 @@ GPU_SHADER_CREATE_INFO(overlay_armature_dof_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_armature_wire) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - .push_constant(Type::FLOAT, "alpha") - .vertex_out(overlay_armature_wire_iface) - .vertex_source("overlay_armature_wire_vert.glsl") - .fragment_source("overlay_armature_wire_frag.glsl") - .additional_info("overlay_frag_output", "draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +PUSH_CONSTANT(FLOAT, alpha) +VERTEX_OUT(overlay_armature_wire_iface) +VERTEX_SOURCE("overlay_armature_wire_vert.glsl") +FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") +ADDITIONAL_INFO(overlay_frag_output) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_armature_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_armature_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_armature_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_background_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_background_info.hh index 44774e24ebc..d5f15e27f8b 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_background_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_background_info.hh @@ -5,21 +5,24 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(overlay_background) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .sampler(0, ImageType::FLOAT_2D, "colorBuffer") - .sampler(1, ImageType::DEPTH_2D, "depthBuffer") - .push_constant(Type::INT, "bgType") - .push_constant(Type::VEC4, "colorOverride") - .fragment_source("overlay_background_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .additional_info("draw_fullscreen", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +SAMPLER(0, FLOAT_2D, colorBuffer) +SAMPLER(1, DEPTH_2D, depthBuffer) +PUSH_CONSTANT(INT, bgType) +PUSH_CONSTANT(VEC4, colorOverride) +FRAGMENT_SOURCE("overlay_background_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_clipbound) - .do_static_compilation(true) - .push_constant(Type::VEC4, "ucolor") - .push_constant(Type::VEC3, "boundbox", 8) - .vertex_source("overlay_clipbound_vert.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_view"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(VEC4, ucolor) +PUSH_CONSTANT_ARRAY(VEC3, boundbox, 8) +VERTEX_SOURCE("overlay_clipbound_vert.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh index cae4916f9f5..1f743291447 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh @@ -4,310 +4,368 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(overlay_edit_flat_color_iface, "").flat(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_smooth_color_iface, "").smooth(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_nopersp_color_iface, "") - .no_perspective(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_flat_color_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() +GPU_SHADER_INTERFACE_INFO(overlay_edit_smooth_color_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() +GPU_SHADER_INTERFACE_INFO(overlay_edit_nopersp_color_iface) +NO_PERSPECTIVE(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() /* -------------------------------------------------------------------- */ /** \name Edit Mesh * \{ */ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common) - .define("blender_srgb_to_framebuffer_space(a)", "a") - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::BOOL, "wireShading") - .push_constant(Type::BOOL, "selectFace") - .push_constant(Type::BOOL, "selectEdge") - .push_constant(Type::FLOAT, "alpha") - .push_constant(Type::FLOAT, "retopologyOffset") - .push_constant(Type::IVEC4, "dataMask") - .additional_info("draw_globals"); +DEFINE_VALUE("blender_srgb_to_framebuffer_space(a)", "a") +SAMPLER(0, DEPTH_2D, depthTex) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(BOOL, wireShading) +PUSH_CONSTANT(BOOL, selectFace) +PUSH_CONSTANT(BOOL, selectEdge) +PUSH_CONSTANT(FLOAT, alpha) +PUSH_CONSTANT(FLOAT, retopologyOffset) +PUSH_CONSTANT(IVEC4, dataMask) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common_no_geom) - .metal_backend_only(true) - .define("blender_srgb_to_framebuffer_space(a)", "a") - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::BOOL, "wireShading") - .push_constant(Type::BOOL, "selectFace") - .push_constant(Type::BOOL, "selectEdge") - .push_constant(Type::FLOAT, "alpha") - .push_constant(Type::FLOAT, "retopologyOffset") - .push_constant(Type::IVEC4, "dataMask") - .vertex_source("overlay_edit_mesh_vert_no_geom.glsl") - .additional_info("draw_globals"); +METAL_BACKEND_ONLY() +DEFINE_VALUE("blender_srgb_to_framebuffer_space(a)", "a") +SAMPLER(0, DEPTH_2D, depthTex) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(BOOL, wireShading) +PUSH_CONSTANT(BOOL, selectFace) +PUSH_CONSTANT(BOOL, selectEdge) +PUSH_CONSTANT(FLOAT, alpha) +PUSH_CONSTANT(FLOAT, retopologyOffset) +PUSH_CONSTANT(IVEC4, dataMask) +VERTEX_SOURCE("overlay_edit_mesh_vert_no_geom.glsl") +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_mesh_depth) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::FLOAT, "retopologyOffset") - .vertex_source("overlay_edit_mesh_depth_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(FLOAT, retopologyOffset) +VERTEX_SOURCE("overlay_edit_mesh_depth_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_depth_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_depth", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_depth) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface, "") - .smooth(Type::VEC4, "finalColor") - .smooth(Type::FLOAT, "vertexCrease"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface) +SMOOTH(VEC4, finalColor) +SMOOTH(FLOAT, vertexCrease) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert) - .do_static_compilation(true) - .builtins(BuiltinBits::POINT_SIZE) - .define("VERT") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_in(2, Type::VEC3, "vnor") - .vertex_source("overlay_edit_mesh_vert.glsl") - .vertex_out(overlay_edit_mesh_vert_iface) - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_modelmat", "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +BUILTINS(BuiltinBits::POINT_SIZE) +DEFINE("VERT") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_IN(2, VEC3, vnor) +VERTEX_SOURCE("overlay_edit_mesh_vert.glsl") +VERTEX_OUT(overlay_edit_mesh_vert_iface) +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert_next) - .do_static_compilation(true) - .builtins(BuiltinBits::POINT_SIZE) - .define("VERT") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_in(2, Type::VEC3, "vnor") - .vertex_source("overlay_edit_mesh_vertex_vert.glsl") - .vertex_out(overlay_edit_mesh_vert_iface) - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +BUILTINS(BuiltinBits::POINT_SIZE) +DEFINE("VERT") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_IN(2, VEC3, vnor) +VERTEX_SOURCE("overlay_edit_mesh_vertex_vert.glsl") +VERTEX_OUT(overlay_edit_mesh_vert_iface) +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_iface, "geometry_in") - .smooth(Type::VEC4, "finalColor_") - .smooth(Type::VEC4, "finalColorOuter_") - .smooth(Type::UINT, "selectOverride_"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_iface, geometry_in) +SMOOTH(VEC4, finalColor_) +SMOOTH(VEC4, finalColorOuter_) +SMOOTH(UINT, selectOverride_) +GPU_SHADER_NAMED_INTERFACE_END(geometry_in) -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_geom_iface, "geometry_out") - .smooth(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_geom_flat_iface, "geometry_flat_out") - .flat(Type::VEC4, "finalColorOuter"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_geom_noperspective_iface, - "geometry_noperspective_out") - .no_perspective(Type::FLOAT, "edgeCoord"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_geom_iface, geometry_out) +SMOOTH(VEC4, finalColor) +GPU_SHADER_NAMED_INTERFACE_END(geometry_out) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_geom_flat_iface, geometry_flat_out) +FLAT(VEC4, finalColorOuter) +GPU_SHADER_NAMED_INTERFACE_END(geometry_flat_out) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_mesh_edge_geom_noperspective_iface, + geometry_noperspective_out) +NO_PERSPECTIVE(FLOAT, edgeCoord) +GPU_SHADER_NAMED_INTERFACE_END(geometry_noperspective_out) GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge) - .do_static_compilation(true) - .define("EDGE") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_in(2, Type::VEC3, "vnor") - .push_constant(Type::BOOL, "do_smooth_wire") - .vertex_source("overlay_edit_mesh_vert.glsl") - .vertex_out(overlay_edit_mesh_edge_iface) - .geometry_out(overlay_edit_mesh_edge_geom_iface) - .geometry_out(overlay_edit_mesh_edge_geom_flat_iface) - .geometry_out(overlay_edit_mesh_edge_geom_noperspective_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) - .geometry_source("overlay_edit_mesh_geom.glsl") - .fragment_source("overlay_edit_mesh_frag.glsl") - .additional_info("draw_modelmat", "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("EDGE") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_IN(2, VEC3, vnor) +PUSH_CONSTANT(BOOL, do_smooth_wire) +VERTEX_SOURCE("overlay_edit_mesh_vert.glsl") +VERTEX_OUT(overlay_edit_mesh_edge_iface) +GEOMETRY_OUT(overlay_edit_mesh_edge_geom_iface) +GEOMETRY_OUT(overlay_edit_mesh_edge_geom_flat_iface) +GEOMETRY_OUT(overlay_edit_mesh_edge_geom_noperspective_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) +GEOMETRY_SOURCE("overlay_edit_mesh_geom.glsl") +FRAGMENT_SOURCE("overlay_edit_mesh_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() /* The Non-Geometry shader variant passes directly to fragment. */ #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .define("EDGE") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UCHAR4, "data") - .vertex_in(2, Type::VEC3_101010I2, "vnor") - .push_constant(Type::BOOL, "do_smooth_wire") - .vertex_out(overlay_edit_mesh_edge_geom_iface) - .vertex_out(overlay_edit_mesh_edge_geom_flat_iface) - .vertex_out(overlay_edit_mesh_edge_geom_noperspective_iface) - .fragment_source("overlay_edit_mesh_frag.glsl") - .additional_info("draw_modelmat", "overlay_edit_mesh_common_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +DEFINE("EDGE") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UCHAR4, data) +VERTEX_IN(2, VEC3_101010I2, vnor) +PUSH_CONSTANT(BOOL, do_smooth_wire) +VERTEX_OUT(overlay_edit_mesh_edge_geom_iface) +VERTEX_OUT(overlay_edit_mesh_edge_geom_flat_iface) +VERTEX_OUT(overlay_edit_mesh_edge_geom_noperspective_iface) +FRAGMENT_SOURCE("overlay_edit_mesh_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(overlay_edit_mesh_common_no_geom) +GPU_SHADER_CREATE_END() #endif /* Vertex Pull version for overlay next. */ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_next) - .do_static_compilation(true) - .define("EDGE") - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "uint", "vnor[]", Frequency::GEOMETRY) - .storage_buf(2, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC2, "gpu_attr_1") - .push_constant(Type::IVEC2, "gpu_attr_2") - .push_constant(Type::BOOL, "do_smooth_wire") - .push_constant(Type::BOOL, "use_vertex_selection") - .vertex_out(overlay_edit_mesh_edge_geom_iface) - .vertex_out(overlay_edit_mesh_edge_geom_flat_iface) - .vertex_out(overlay_edit_mesh_edge_geom_noperspective_iface) - .vertex_source("overlay_edit_mesh_edge_vert.glsl") - .fragment_source("overlay_edit_mesh_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "gpu_index_load", - "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("EDGE") +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +STORAGE_BUF_FREQ(1, READ, uint, vnor[], GEOMETRY) +STORAGE_BUF_FREQ(2, READ, uint, data[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC2, gpu_attr_1) +PUSH_CONSTANT(IVEC2, gpu_attr_2) +PUSH_CONSTANT(BOOL, do_smooth_wire) +PUSH_CONSTANT(BOOL, use_vertex_selection) +VERTEX_OUT(overlay_edit_mesh_edge_geom_iface) +VERTEX_OUT(overlay_edit_mesh_edge_geom_flat_iface) +VERTEX_OUT(overlay_edit_mesh_edge_geom_noperspective_iface) +VERTEX_SOURCE("overlay_edit_mesh_edge_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_mesh_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat) - .do_static_compilation(true) - .define("FLAT") - .additional_info("overlay_edit_mesh_edge"); +DO_STATIC_COMPILATION() +DEFINE("FLAT") +ADDITIONAL_INFO(overlay_edit_mesh_edge) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .define("FLAT") - .additional_info("overlay_edit_mesh_edge_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +DEFINE("FLAT") +ADDITIONAL_INFO(overlay_edit_mesh_edge_no_geom) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face) - .do_static_compilation(true) - .define("FACE") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_source("overlay_edit_mesh_vert.glsl") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_modelmat", "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("FACE") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_SOURCE("overlay_edit_mesh_vert.glsl") +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_next) - .do_static_compilation(true) - .define("FACE") - .define("vnor", "vec3(0.0)") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_source("overlay_edit_mesh_face_vert.glsl") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("FACE") +DEFINE_VALUE("vnor", "vec3(0.0)") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_SOURCE("overlay_edit_mesh_face_vert.glsl") +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot) - .do_static_compilation(true) - .define("FACEDOT") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_in(2, Type::VEC4, "norAndFlag") - .define("vnor", "norAndFlag.xyz") - .vertex_source("overlay_edit_mesh_vert.glsl") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_modelmat", "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("FACEDOT") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_IN(2, VEC4, norAndFlag) +DEFINE_VALUE("vnor", "norAndFlag.xyz") +VERTEX_SOURCE("overlay_edit_mesh_vert.glsl") +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot_next) - .do_static_compilation(true) - .define("FACEDOT") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UVEC4, "data") - .vertex_in(2, Type::VEC4, "norAndFlag") - .define("vnor", "norAndFlag.xyz") - .vertex_source("overlay_edit_mesh_facedot_vert.glsl") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "overlay_edit_mesh_common"); +DO_STATIC_COMPILATION() +DEFINE("FACEDOT") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UVEC4, data) +VERTEX_IN(2, VEC4, norAndFlag) +DEFINE_VALUE("vnor", "norAndFlag.xyz") +VERTEX_SOURCE("overlay_edit_mesh_facedot_vert.glsl") +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(overlay_edit_mesh_common) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal) - .do_static_compilation(true) - .define("WORKAROUND_INDEX_LOAD_INCLUDE") - /* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */ - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC2, "gpu_attr_1") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "lnor") - .vertex_in(2, Type::VEC4, "vnor") - .vertex_in(3, Type::VEC4, "norAndFlag") - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .push_constant(Type::FLOAT, "normalSize") - .push_constant(Type::FLOAT, "normalScreenSize") - .push_constant(Type::FLOAT, "alpha") - .push_constant(Type::BOOL, "isConstantScreenSizeNormals") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_mesh_normal_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_modelmat_instanced_attr", "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("WORKAROUND_INDEX_LOAD_INCLUDE") +/* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */ +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC2, gpu_attr_1) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, lnor) +VERTEX_IN(2, VEC4, vnor) +VERTEX_IN(3, VEC4, norAndFlag) +SAMPLER(0, DEPTH_2D, depthTex) +PUSH_CONSTANT(FLOAT, normalSize) +PUSH_CONSTANT(FLOAT, normalScreenSize) +PUSH_CONSTANT(FLOAT, alpha) +PUSH_CONSTANT(BOOL, isConstantScreenSizeNormals) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_mesh_normal_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_modelmat_instanced_attr) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_analysis_iface, "").smooth(Type::VEC4, "weightColor"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_analysis_iface) +SMOOTH(VEC4, weightColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_analysis) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "weight") - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_out(overlay_edit_mesh_analysis_iface) - .vertex_source("overlay_edit_mesh_analysis_vert.glsl") - .fragment_source("overlay_edit_mesh_analysis_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, weight) +SAMPLER(0, FLOAT_1D, weightTex) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_OUT(overlay_edit_mesh_analysis_iface) +VERTEX_SOURCE("overlay_edit_mesh_analysis_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_mesh_analysis_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "size") - .vertex_in(2, Type::VEC3, "local_pos") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_mesh_skin_root_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_modelmat_instanced_attr", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, size) +VERTEX_IN(2, VEC3, local_pos) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_mesh_skin_root_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_modelmat_instanced_attr) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_vert", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_vert) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_edge", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_edge) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_edge_no_geom", "drw_clipped"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_edge_no_geom) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_edge_flat", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_edge_flat) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_edge_flat_no_geom", "drw_clipped"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_edge_flat_no_geom) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_face", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_face) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_facedot", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_facedot) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_normal_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_normal", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_normal) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_analysis_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_analysis", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_analysis) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_mesh_skin_root", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_mesh_skin_root) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -315,162 +373,188 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_skin_root_clipped) /** \name Edit UV * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_iface, "geom_in").smooth(Type::FLOAT, "selectionFac"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_flat_iface, "geom_flat_in") - .flat(Type::VEC2, "stippleStart"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_noperspective_iface, "geom_noperspective_in") - .no_perspective(Type::VEC2, "stipplePos"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_iface, geom_in) +SMOOTH(FLOAT, selectionFac) +GPU_SHADER_NAMED_INTERFACE_END(geom_in) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_flat_iface, geom_flat_in) +FLAT(VEC2, stippleStart) +GPU_SHADER_NAMED_INTERFACE_END(geom_flat_in) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_noperspective_iface, geom_noperspective_in) +NO_PERSPECTIVE(VEC2, stipplePos) +GPU_SHADER_NAMED_INTERFACE_END(geom_noperspective_in) -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_geom_iface, "geom_out") - .smooth(Type::FLOAT, "selectionFac"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_geom_flat_iface, "geom_flat_out") - .flat(Type::VEC2, "stippleStart"); -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_geom_noperspective_iface, "geom_noperspective_out") - .no_perspective(Type::FLOAT, "edgeCoord") - .no_perspective(Type::VEC2, "stipplePos"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_iface, geom_out) +SMOOTH(FLOAT, selectionFac) +GPU_SHADER_NAMED_INTERFACE_END(geom_out) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_flat_iface, geom_flat_out) +FLAT(VEC2, stippleStart) +GPU_SHADER_NAMED_INTERFACE_END(geom_flat_out) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_uv_geom_noperspective_iface, geom_noperspective_out) +NO_PERSPECTIVE(FLOAT, edgeCoord) +NO_PERSPECTIVE(VEC2, stipplePos) +GPU_SHADER_NAMED_INTERFACE_END(geom_noperspective_out) GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_common) - .vertex_in(0, Type::VEC2, "au") - .vertex_in(1, Type::INT, "flag") - .push_constant(Type::INT, "lineStyle") - .push_constant(Type::BOOL, "doSmoothWire") - .push_constant(Type::FLOAT, "alpha") - .push_constant(Type::FLOAT, "dashLength") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_edit_uv_edges_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +VERTEX_IN(0, VEC2, au) +VERTEX_IN(1, INT, flag) +PUSH_CONSTANT(INT, lineStyle) +PUSH_CONSTANT(BOOL, doSmoothWire) +PUSH_CONSTANT(FLOAT, alpha) +PUSH_CONSTANT(FLOAT, dashLength) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges) - .additional_info("overlay_edit_uv_edges_common") - .do_static_compilation(true) - .vertex_out(overlay_edit_uv_iface) - .vertex_out(overlay_edit_uv_flat_iface) - .vertex_out(overlay_edit_uv_noperspective_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) - .geometry_out(overlay_edit_uv_geom_iface) - .geometry_out(overlay_edit_uv_geom_flat_iface) - .geometry_out(overlay_edit_uv_geom_noperspective_iface) - .vertex_source("overlay_edit_uv_edges_vert.glsl") - .geometry_source("overlay_edit_uv_edges_geom.glsl"); +ADDITIONAL_INFO(overlay_edit_uv_edges_common) +DO_STATIC_COMPILATION() +VERTEX_OUT(overlay_edit_uv_iface) +VERTEX_OUT(overlay_edit_uv_flat_iface) +VERTEX_OUT(overlay_edit_uv_noperspective_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) +GEOMETRY_OUT(overlay_edit_uv_geom_iface) +GEOMETRY_OUT(overlay_edit_uv_geom_flat_iface) +GEOMETRY_OUT(overlay_edit_uv_geom_noperspective_iface) +VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl") +GEOMETRY_SOURCE("overlay_edit_uv_edges_geom.glsl") +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_no_geom) - .metal_backend_only(true) - .additional_info("overlay_edit_uv_edges_common") - .do_static_compilation(true) - .vertex_out(overlay_edit_uv_geom_iface) - .vertex_out(overlay_edit_uv_geom_flat_iface) - .vertex_out(overlay_edit_uv_geom_noperspective_iface) - .vertex_source("overlay_edit_uv_edges_vert_no_geom.glsl"); +METAL_BACKEND_ONLY() +ADDITIONAL_INFO(overlay_edit_uv_edges_common) +DO_STATIC_COMPILATION() +VERTEX_OUT(overlay_edit_uv_geom_iface) +VERTEX_OUT(overlay_edit_uv_geom_flat_iface) +VERTEX_OUT(overlay_edit_uv_geom_noperspective_iface) +VERTEX_SOURCE("overlay_edit_uv_edges_vert_no_geom.glsl") +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_select) - .do_static_compilation(true) - .define("USE_EDGE_SELECT") - .additional_info("overlay_edit_uv_edges"); +DO_STATIC_COMPILATION() +DEFINE("USE_EDGE_SELECT") +ADDITIONAL_INFO(overlay_edit_uv_edges) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_next_iface, "") - .smooth(Type::FLOAT, "selectionFac") - .flat(Type::VEC2, "stippleStart") - .no_perspective(Type::FLOAT, "edgeCoord") - .no_perspective(Type::VEC2, "stipplePos"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_next_iface) +SMOOTH(FLOAT, selectionFac) +FLAT(VEC2, stippleStart) +NO_PERSPECTIVE(FLOAT, edgeCoord) +NO_PERSPECTIVE(VEC2, stipplePos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_next) - .do_static_compilation(true) - .storage_buf(0, Qualifier::READ, "float", "au[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC2, "gpu_attr_1") - .push_constant(Type::INT, "lineStyle") - .push_constant(Type::BOOL, "doSmoothWire") - .push_constant(Type::FLOAT, "alpha") - .push_constant(Type::FLOAT, "dashLength") - .specialization_constant(Type::BOOL, "use_edge_select", false) - .vertex_out(overlay_edit_uv_next_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_edges_next_vert.glsl") - .fragment_source("overlay_edit_uv_edges_next_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +STORAGE_BUF_FREQ(0, READ, float, au[], GEOMETRY) +STORAGE_BUF_FREQ(1, READ, uint, data[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC2, gpu_attr_1) +PUSH_CONSTANT(INT, lineStyle) +PUSH_CONSTANT(BOOL, doSmoothWire) +PUSH_CONSTANT(FLOAT, alpha) +PUSH_CONSTANT(FLOAT, dashLength) +SPECIALIZATION_CONSTANT(BOOL, use_edge_select, false) +VERTEX_OUT(overlay_edit_uv_next_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_edges_next_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_faces) - .do_static_compilation(true) - .vertex_in(0, Type::VEC2, "au") - .vertex_in(1, Type::UINT, "flag") - .push_constant(Type::FLOAT, "uvOpacity") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_faces_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC2, au) +VERTEX_IN(1, UINT, flag) +PUSH_CONSTANT(FLOAT, uvOpacity) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_faces_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_face_dots) - .do_static_compilation(true) - .vertex_in(0, Type::VEC2, "au") - .vertex_in(1, Type::UINT, "flag") - .push_constant(Type::FLOAT, "pointSize") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_face_dots_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC2, au) +VERTEX_IN(1, UINT, flag) +PUSH_CONSTANT(FLOAT, pointSize) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_face_dots_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_vert_iface, "") - .smooth(Type::VEC4, "fillColor") - .smooth(Type::VEC4, "outlineColor") - .smooth(Type::VEC4, "radii"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_vert_iface) +SMOOTH(VEC4, fillColor) +SMOOTH(VEC4, outlineColor) +SMOOTH(VEC4, radii) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_verts) - .do_static_compilation(true) - .vertex_in(0, Type::VEC2, "au") - .vertex_in(1, Type::UINT, "flag") - .push_constant(Type::FLOAT, "pointSize") - .push_constant(Type::FLOAT, "outlineWidth") - .push_constant(Type::VEC4, "color") - .vertex_out(overlay_edit_uv_vert_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_verts_vert.glsl") - .fragment_source("overlay_edit_uv_verts_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC2, au) +VERTEX_IN(1, UINT, flag) +PUSH_CONSTANT(FLOAT, pointSize) +PUSH_CONSTANT(FLOAT, outlineWidth) +PUSH_CONSTANT(VEC4, color) +VERTEX_OUT(overlay_edit_uv_vert_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_verts_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_uv_verts_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_tiled_image_borders) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_tiled_image_borders_vert.glsl") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl") +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(edit_uv_image_iface, "").smooth(Type::VEC2, "uvs"); +GPU_SHADER_INTERFACE_INFO(edit_uv_image_iface) +SMOOTH(VEC2, uvs) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_stencil_image) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(edit_uv_image_iface) - .vertex_source("overlay_edit_uv_image_vert.glsl") - .sampler(0, ImageType::FLOAT_2D, "imgTexture") - .push_constant(Type::BOOL, "imgPremultiplied") - .push_constant(Type::BOOL, "imgAlphaBlend") - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_image_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(edit_uv_image_iface) +VERTEX_SOURCE("overlay_edit_uv_image_vert.glsl") +SAMPLER(0, FLOAT_2D, imgTexture) +PUSH_CONSTANT(BOOL, imgPremultiplied) +PUSH_CONSTANT(BOOL, imgAlphaBlend) +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_image_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_mask_image) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(edit_uv_image_iface) - .sampler(0, ImageType::FLOAT_2D, "imgTexture") - .push_constant(Type::VEC4, "color") - .push_constant(Type::FLOAT, "opacity") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_image_vert.glsl") - .fragment_source("overlay_edit_uv_image_mask_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(edit_uv_image_iface) +SAMPLER(0, FLOAT_2D, imgTexture) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(FLOAT, opacity) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_image_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_uv_image_mask_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() /** \} */ @@ -479,27 +563,34 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_mask_image) * \{ */ GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching) - .vertex_in(0, Type::VEC2, "pos") - .push_constant(Type::VEC2, "aspect") - .push_constant(Type::FLOAT, "stretch_opacity") - .vertex_out(overlay_edit_nopersp_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_stretching_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .push_constant(Type::FLOAT, "totalAreaRatio"); +VERTEX_IN(0, VEC2, pos) +PUSH_CONSTANT(VEC2, aspect) +PUSH_CONSTANT(FLOAT, stretch_opacity) +VERTEX_OUT(overlay_edit_nopersp_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_stretching_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +PUSH_CONSTANT(FLOAT, totalAreaRatio) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_area) - .do_static_compilation(true) - .vertex_in(1, Type::FLOAT, "ratio") - .push_constant(Type::FLOAT, "totalAreaRatio") - .additional_info("overlay_edit_uv_stretching", "draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(1, FLOAT, ratio) +PUSH_CONSTANT(FLOAT, totalAreaRatio) +ADDITIONAL_INFO(overlay_edit_uv_stretching) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_angle) - .do_static_compilation(true) - .define("STRETCH_ANGLE") - .vertex_in(1, Type::VEC2, "uv_angles") - .vertex_in(2, Type::FLOAT, "angle") - .additional_info("overlay_edit_uv_stretching", "draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("STRETCH_ANGLE") +VERTEX_IN(1, VEC2, uv_angles) +VERTEX_IN(2, FLOAT, angle) +ADDITIONAL_INFO(overlay_edit_uv_stretching) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() /** \} */ @@ -507,127 +598,148 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_angle) /** \name Edit Curve * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type::UINT, "flag"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_edit_curve_handle_iface, vert) +FLAT(UINT, flag) +GPU_SHADER_NAMED_INTERFACE_END(vert) GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_out(overlay_edit_curve_handle_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10) - .geometry_out(overlay_edit_smooth_color_iface) - .push_constant(Type::BOOL, "showCurveHandles") - .push_constant(Type::INT, "curveHandleDisplay") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_handle_vert.glsl") - .geometry_source("overlay_edit_curve_handle_geom.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_OUT(overlay_edit_curve_handle_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10) +GEOMETRY_OUT(overlay_edit_smooth_color_iface) +PUSH_CONSTANT(BOOL, showCurveHandles) +PUSH_CONSTANT(INT, curveHandleDisplay) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_handle_vert.glsl") +GEOMETRY_SOURCE("overlay_edit_curve_handle_geom.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - /* NOTE: Color already in Linear space. Which is what we want. */ - .define("srgbTarget", "false") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_out(overlay_edit_smooth_color_iface) - .push_constant(Type::BOOL, "showCurveHandles") - .push_constant(Type::INT, "curveHandleDisplay") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_handle_vert_no_geom.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +/* NOTE: Color already in Linear space. Which is what we want. */ +DEFINE_VALUE("srgbTarget", "false") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_OUT(overlay_edit_smooth_color_iface) +PUSH_CONSTANT(BOOL, showCurveHandles) +PUSH_CONSTANT(INT, curveHandleDisplay) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_handle_vert_no_geom.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_next) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC2, "gpu_attr_1") - .vertex_out(overlay_edit_smooth_color_iface) - .push_constant(Type::BOOL, "showCurveHandles") - .push_constant(Type::INT, "curveHandleDisplay") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_handle_next_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +STORAGE_BUF_FREQ(1, READ, uint, data[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC2, gpu_attr_1) +VERTEX_OUT(overlay_edit_smooth_color_iface) +PUSH_CONSTANT(BOOL, showCurveHandles) +PUSH_CONSTANT(INT, curveHandleDisplay) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_handle_next_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_curve_handle", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_curve_handle) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #ifdef WITH_METAL_BACKEND GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .additional_info("overlay_edit_curve_handle_no_geom", "drw_clipped"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_curve_handle_no_geom) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() #endif GPU_SHADER_CREATE_INFO(overlay_edit_curve_point) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_out(overlay_edit_flat_color_iface) - .push_constant(Type::BOOL, "showCurveHandles") - .push_constant(Type::INT, "curveHandleDisplay") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_point_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_OUT(overlay_edit_flat_color_iface) +PUSH_CONSTANT(BOOL, showCurveHandles) +PUSH_CONSTANT(INT, curveHandleDisplay) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curve_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_curve_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_curve_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curve_wire) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .vertex_in(2, Type::VEC3, "tan") - .vertex_in(3, Type::FLOAT, "rad") - .push_constant(Type::FLOAT, "normalSize") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_wire_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_modelmat", "draw_resource_id_uniform", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +VERTEX_IN(2, VEC3, tan) +VERTEX_IN(3, FLOAT, rad) +PUSH_CONSTANT(FLOAT, normalSize) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_wire_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id_uniform) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curve_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_curve_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_curve_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curve_normals) - .do_static_compilation(true) - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .storage_buf(1, Qualifier::READ, "float", "rad[]", Frequency::GEOMETRY) - .storage_buf(2, Qualifier::READ, "uint", "nor[]", Frequency::GEOMETRY) - .storage_buf(3, Qualifier::READ, "uint", "tan[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC2, "gpu_attr_1") - .push_constant(Type::IVEC2, "gpu_attr_2") - .push_constant(Type::IVEC2, "gpu_attr_3") - .push_constant(Type::FLOAT, "normalSize") - .push_constant(Type::BOOL, "use_hq_normals") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curve_wire_next_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +STORAGE_BUF_FREQ(1, READ, float, rad[], GEOMETRY) +STORAGE_BUF_FREQ(2, READ, uint, nor[], GEOMETRY) +STORAGE_BUF_FREQ(3, READ, uint, tan[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC2, gpu_attr_1) +PUSH_CONSTANT(IVEC2, gpu_attr_2) +PUSH_CONSTANT(IVEC2, gpu_attr_3) +PUSH_CONSTANT(FLOAT, normalSize) +PUSH_CONSTANT(BOOL, use_hq_normals) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curve_wire_next_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() /** \} */ @@ -635,26 +747,31 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_normals) /** \name Edit Curves * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_edit_curves_handle_iface, "") - .smooth(Type::VEC4, "finalColor") - .smooth(Type::VEC4, "leftColor"); +GPU_SHADER_INTERFACE_INFO(overlay_edit_curves_handle_iface) +SMOOTH(VEC4, finalColor) +SMOOTH(VEC4, leftColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_in(2, Type::FLOAT, "selection") - .vertex_out(overlay_edit_curves_handle_iface) - .uniform_buf(0, "int", "curvesInfoBlock[4]") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_curves_handle_vert.glsl") - .fragment_source("overlay_edit_curves_handle_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_IN(2, FLOAT, selection) +VERTEX_OUT(overlay_edit_curves_handle_iface) +UNIFORM_BUF(0, int, curvesInfoBlock[4]) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_curves_handle_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_curves_handle_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_curves_handle", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_curves_handle) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -663,33 +780,41 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curves_handle_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_lattice_point_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_lattice_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_lattice_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_lattice_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "weight") - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .vertex_out(overlay_edit_smooth_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_lattice_wire_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, weight) +SAMPLER(0, FLOAT_1D, weightTex) +VERTEX_OUT(overlay_edit_smooth_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_lattice_wire_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_lattice_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_lattice_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -698,38 +823,46 @@ GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "selection") - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .push_constant(Type::BOOL, "useWeight") - .push_constant(Type::BOOL, "useGreasePencil") - .vertex_out(overlay_edit_smooth_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_particle_strand_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, selection) +SAMPLER(0, FLOAT_1D, weightTex) +PUSH_CONSTANT(BOOL, useWeight) +PUSH_CONSTANT(BOOL, useGreasePencil) +VERTEX_OUT(overlay_edit_smooth_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_particle_strand_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_particle_strand", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_particle_strand) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_particle_point) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "selection") - .vertex_out(overlay_edit_flat_color_iface) - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .push_constant(Type::BOOL, "useWeight") - .push_constant(Type::BOOL, "useGreasePencil") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_particle_point_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, selection) +VERTEX_OUT(overlay_edit_flat_color_iface) +SAMPLER(0, FLOAT_1D, weightTex) +PUSH_CONSTANT(BOOL, useWeight) +PUSH_CONSTANT(BOOL, useGreasePencil) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_particle_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_particle_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_particle_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_particle_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -738,61 +871,73 @@ GPU_SHADER_CREATE_INFO(overlay_edit_particle_point_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_edit_gpencil) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::INT, "ma") - .vertex_in(2, Type::UINT, "vflag") - .vertex_in(3, Type::FLOAT, "weight") - .push_constant(Type::FLOAT, "normalSize") - .push_constant(Type::BOOL, "doMultiframe") - .push_constant(Type::BOOL, "doStrokeEndpoints") - .push_constant(Type::BOOL, "hideSelect") - .push_constant(Type::BOOL, "doWeightColor") - .push_constant(Type::FLOAT, "gpEditOpacity") - .push_constant(Type::VEC4, "gpEditColor") - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_gpencil_vert.glsl") - .additional_info("draw_mesh", "draw_globals"); +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, INT, ma) +VERTEX_IN(2, UINT, vflag) +VERTEX_IN(3, FLOAT, weight) +PUSH_CONSTANT(FLOAT, normalSize) +PUSH_CONSTANT(BOOL, doMultiframe) +PUSH_CONSTANT(BOOL, doStrokeEndpoints) +PUSH_CONSTANT(BOOL, hideSelect) +PUSH_CONSTANT(BOOL, doWeightColor) +PUSH_CONSTANT(FLOAT, gpEditOpacity) +PUSH_CONSTANT(VEC4, gpEditColor) +SAMPLER(0, FLOAT_1D, weightTex) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_gpencil_vert.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_wire) - .do_static_compilation(true) - .vertex_out(overlay_edit_smooth_color_iface) - .fragment_source("overlay_varying_color.glsl") - .additional_info("overlay_edit_gpencil"); +DO_STATIC_COMPILATION() +VERTEX_OUT(overlay_edit_smooth_color_iface) +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(overlay_edit_gpencil) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_gpencil_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_gpencil_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_point) - .do_static_compilation(true) - .define("USE_POINTS") - .vertex_out(overlay_edit_flat_color_iface) - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("overlay_edit_gpencil"); +DO_STATIC_COMPILATION() +DEFINE("USE_POINTS") +VERTEX_OUT(overlay_edit_flat_color_iface) +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(overlay_edit_gpencil) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_gpencil_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_gpencil_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /* TODO(fclem): Refactor this to take list of point instead of drawing 1 point per drawcall. */ GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::UINT, "data") - .vertex_out(overlay_edit_flat_color_iface) - .push_constant(Type::VEC3, "pPosition") - .push_constant(Type::FLOAT, "pSize") - .push_constant(Type::VEC4, "pColor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_gpencil_guide_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, UINT, data) +VERTEX_OUT(overlay_edit_flat_color_iface) +PUSH_CONSTANT(VEC3, pPosition) +PUSH_CONSTANT(FLOAT, pSize) +PUSH_CONSTANT(VEC4, pColor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_gpencil_guide_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_edit_gpencil_guide_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_edit_gpencil_guide_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -803,79 +948,92 @@ GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_depth_only) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("overlay_depth_only_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("overlay_depth_only_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_depth_only_clipped) - .do_static_compilation(true) - .additional_info("overlay_depth_only", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_depth_only) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_depth_mesh) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("basic_depth_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_globals", "draw_view", "draw_modelmat_new", "draw_resource_handle_new"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("basic_depth_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_globals) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_depth_mesh_conservative) - .do_static_compilation(true) - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .vertex_source("overlay_depth_only_mesh_conservative_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_globals", - "draw_view", - "draw_modelmat_new", - "gpu_index_load", - "draw_resource_handle_new"); +DO_STATIC_COMPILATION() +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +VERTEX_SOURCE("overlay_depth_only_mesh_conservative_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_globals) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_depth_only_gpencil_flat_iface, "gp_interp_flat") - .flat(Type::VEC2, "aspect") - .flat(Type::VEC4, "sspos"); -GPU_SHADER_INTERFACE_INFO(overlay_depth_only_gpencil_noperspective_iface, - "gp_interp_noperspective") - .no_perspective(Type::VEC2, "thickness") - .no_perspective(Type::FLOAT, "hardness"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_depth_only_gpencil_flat_iface, gp_interp_flat) +FLAT(VEC2, aspect) +FLAT(VEC4, sspos) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_flat) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_depth_only_gpencil_noperspective_iface, + gp_interp_noperspective) +NO_PERSPECTIVE(VEC2, thickness) +NO_PERSPECTIVE(FLOAT, hardness) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective) GPU_SHADER_CREATE_INFO(overlay_depth_gpencil) - .do_static_compilation(true) - .typedef_source("gpencil_shader_shared.h") - .vertex_out(overlay_depth_only_gpencil_flat_iface) - .vertex_out(overlay_depth_only_gpencil_noperspective_iface) - .vertex_source("overlay_depth_only_gpencil_vert.glsl") - .fragment_source("overlay_depth_only_gpencil_frag.glsl") - .depth_write(DepthWrite::ANY) - .push_constant(Type::BOOL, "gpStrokeOrder3d") /* TODO(fclem): Move to a GPencil object UBO. */ - .push_constant(Type::VEC4, "gpDepthPlane") /* TODO(fclem): Move to a GPencil object UBO. */ - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "draw_globals", - "draw_gpencil_new", - "draw_object_infos_new"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("gpencil_shader_shared.h") +VERTEX_OUT(overlay_depth_only_gpencil_flat_iface) +VERTEX_OUT(overlay_depth_only_gpencil_noperspective_iface) +VERTEX_SOURCE("overlay_depth_only_gpencil_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_gpencil_frag.glsl") +DEPTH_WRITE(DepthWrite::ANY) +PUSH_CONSTANT(BOOL, gpStrokeOrder3d) /* TODO(fclem): Move to a GPencil object UBO. */ +PUSH_CONSTANT(VEC4, gpDepthPlane) /* TODO(fclem): Move to a GPencil object UBO. */ +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_globals) +ADDITIONAL_INFO(draw_gpencil_new) +ADDITIONAL_INFO(draw_object_infos_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_depth_pointcloud) - .do_static_compilation(true) - .vertex_source("basic_depth_pointcloud_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_pointcloud_new", - "draw_globals", - "draw_view", - "draw_modelmat_new", - "draw_resource_handle_new"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("basic_depth_pointcloud_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_pointcloud_new) +ADDITIONAL_INFO(draw_globals) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_depth_curves) - .do_static_compilation(true) - .vertex_source("basic_depth_curves_vert.glsl") - .fragment_source("overlay_depth_only_frag.glsl") - .additional_info("draw_hair_new", - "draw_globals", - "draw_view", - "draw_modelmat_new", - "draw_resource_handle_new"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("basic_depth_curves_vert.glsl") +FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") +ADDITIONAL_INFO(draw_hair_new) +ADDITIONAL_INFO(draw_globals) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() /** \} */ @@ -884,28 +1042,34 @@ GPU_SHADER_CREATE_INFO(overlay_depth_curves) * \{ */ GPU_SHADER_CREATE_INFO(overlay_uniform_color) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_depth_only_vert.glsl") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_depth_only_vert.glsl") +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud) - .do_static_compilation(true) - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_pointcloud_only_vert.glsl") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_pointcloud"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_pointcloud_only_vert.glsl") +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_pointcloud) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_uniform_color_clipped) - .do_static_compilation(true) - .additional_info("overlay_uniform_color", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_uniform_color) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_uniform_color_pointcloud_clipped) - .do_static_compilation(true) - .additional_info("overlay_uniform_color_pointcloud", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_uniform_color_pointcloud) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh index dfbba926343..c4aba12ca50 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh @@ -8,38 +8,46 @@ /** \name Extra shapes * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_extra_iface, "") - .no_perspective(Type::VEC2, "edgePos") - .flat(Type::VEC2, "edgeStart") - .flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_extra_iface) +NO_PERSPECTIVE(VEC2, edgePos) +FLAT(VEC2, edgeStart) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_extra) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::INT, "vclass") - /* Instance attributes. */ - .vertex_in(2, Type::VEC4, "color") - .vertex_in(3, Type::MAT4, "inst_obmat") - .vertex_out(overlay_extra_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_extra_vert.glsl") - .fragment_source("overlay_extra_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, INT, vclass) +/* Instance attributes. */ +VERTEX_IN(2, VEC4, color) +VERTEX_IN(3, MAT4, inst_obmat) +VERTEX_OUT(overlay_extra_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_extra_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_select) - .do_static_compilation(true) - .define("SELECT_EDGES") - .additional_info("overlay_extra"); +DO_STATIC_COMPILATION() +DEFINE("SELECT_EDGES") +ADDITIONAL_INFO(overlay_extra) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_select_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_select", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_select) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -47,22 +55,28 @@ GPU_SHADER_CREATE_INFO(overlay_extra_select_clipped) /** \name Irradiance Grid * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_extra_grid_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_extra_grid_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_extra_grid) - .do_static_compilation(true) - .sampler(0, ImageType::DEPTH_2D, "depthBuffer") - .push_constant(Type::MAT4, "gridModelMatrix") - .push_constant(Type::BOOL, "isTransform") - .vertex_out(overlay_extra_grid_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_extra_lightprobe_grid_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +SAMPLER(0, DEPTH_2D, depthBuffer) +PUSH_CONSTANT(MAT4, gridModelMatrix) +PUSH_CONSTANT(BOOL, isTransform) +VERTEX_OUT(overlay_extra_grid_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_extra_lightprobe_grid_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_grid_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_grid", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_grid) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -71,20 +85,24 @@ GPU_SHADER_CREATE_INFO(overlay_extra_grid_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_extra_groundline) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - /* Instance attributes. */ - .vertex_in(1, Type::VEC3, "inst_pos") - .vertex_out(overlay_extra_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_extra_groundline_vert.glsl") - .fragment_source("overlay_extra_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +/* Instance attributes. */ +VERTEX_IN(1, VEC3, inst_pos) +VERTEX_OUT(overlay_extra_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_extra_groundline_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_groundline_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_groundline", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_groundline) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -92,45 +110,56 @@ GPU_SHADER_CREATE_INFO(overlay_extra_groundline_clipped) /** \name Extra wires * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_extra_wire_iface, "") - .no_perspective(Type::VEC2, "stipple_coord") - .flat(Type::VEC2, "stipple_start") - .flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_extra_wire_iface) +NO_PERSPECTIVE(VEC2, stipple_coord) +FLAT(VEC2, stipple_start) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - /* If colorid is equal to 0 (i.e: Not specified) use color attribute and stippling. */ - .vertex_in(2, Type::INT, "colorid") - .vertex_out(overlay_extra_wire_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_extra_wire_vert.glsl") - .fragment_source("overlay_extra_wire_frag.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +/* If colorid is equal to 0 (i.e: Not specified) use color attribute and stippling. */ +VERTEX_IN(2, INT, colorid) +VERTEX_OUT(overlay_extra_wire_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_extra_wire_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_wire_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire_select) - .do_static_compilation(true) - .define("SELECT_EDGES") - .additional_info("overlay_extra_wire"); +DO_STATIC_COMPILATION() +DEFINE("SELECT_EDGES") +ADDITIONAL_INFO(overlay_extra_wire) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire_object) - .do_static_compilation(true) - .define("OBJECT_WIRE") - .additional_info("overlay_extra_wire"); +DO_STATIC_COMPILATION() +DEFINE("OBJECT_WIRE") +ADDITIONAL_INFO(overlay_extra_wire) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire_select_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_wire_select", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_wire_select) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire_object_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_wire_object", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_wire_object) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -138,43 +167,54 @@ GPU_SHADER_CREATE_INFO(overlay_extra_wire_clipped) /** \name Extra points * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_extra_point_iface, "") - .flat(Type::VEC4, "radii") - .flat(Type::VEC4, "fillColor") - .flat(Type::VEC4, "outlineColor"); +GPU_SHADER_INTERFACE_INFO(overlay_extra_point_iface) +FLAT(VEC4, radii) +FLAT(VEC4, fillColor) +FLAT(VEC4, outlineColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_extra_point) - .do_static_compilation(true) - /* TODO(fclem): Move the vertex shader to Overlay engine and remove this bypass. */ - .define("blender_srgb_to_framebuffer_space(a)", "a") - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::VEC4, "ucolor") - .vertex_out(overlay_extra_point_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_extra_point_vert.glsl") - .fragment_source("overlay_point_varying_color_varying_outline_aa_frag.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +/* TODO(fclem): Move the vertex shader to Overlay engine and remove this bypass. */ +DEFINE_VALUE("blender_srgb_to_framebuffer_space(a)", "a") +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(VEC4, ucolor) +VERTEX_OUT(overlay_extra_point_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_extra_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_varying_outline_aa_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_extra_loose_point_iface, "").smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_extra_loose_point_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_extra_loose_point) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "vertex_color") - .vertex_out(overlay_extra_loose_point_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_extra_loose_point_vert.glsl") - .fragment_source("overlay_extra_loose_point_frag.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, vertex_color) +VERTEX_OUT(overlay_extra_loose_point_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_extra_loose_point_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_loose_point_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_extra_loose_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_extra_loose_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_extra_loose_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -182,90 +222,110 @@ GPU_SHADER_CREATE_INFO(overlay_extra_loose_point_clipped) /** \name Motion Path * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_motion_path_line_iface, "interp").smooth(Type::VEC4, "color"); -GPU_SHADER_INTERFACE_INFO(overlay_motion_path_line_flat_iface, "interp_flat") - .flat(Type::VEC2, "ss_pos"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_motion_path_line_iface, interp) +SMOOTH(VEC4, color) +GPU_SHADER_NAMED_INTERFACE_END(interp) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_motion_path_line_flat_iface, interp_flat) +FLAT(VEC2, ss_pos) +GPU_SHADER_NAMED_INTERFACE_END(interp_flat) GPU_SHADER_CREATE_INFO(overlay_motion_path_line) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::IVEC4, "mpathLineSettings") - .push_constant(Type::BOOL, "selected") - .push_constant(Type::VEC3, "customColorPre") - .push_constant(Type::VEC3, "customColorPost") - .push_constant(Type::INT, "lineThickness") /* In pixels. */ - .push_constant(Type::MAT4, "camera_space_matrix") - .vertex_out(overlay_motion_path_line_iface) - .vertex_out(overlay_motion_path_line_flat_iface) - .geometry_out(overlay_motion_path_line_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_motion_path_line_vert.glsl") - .geometry_source("overlay_motion_path_line_geom.glsl") - .fragment_source("overlay_motion_path_line_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(IVEC4, mpathLineSettings) +PUSH_CONSTANT(BOOL, selected) +PUSH_CONSTANT(VEC3, customColorPre) +PUSH_CONSTANT(VEC3, customColorPost) +PUSH_CONSTANT(INT, lineThickness) /* In pixels. */ +PUSH_CONSTANT(MAT4, camera_space_matrix) +VERTEX_OUT(overlay_motion_path_line_iface) +VERTEX_OUT(overlay_motion_path_line_flat_iface) +GEOMETRY_OUT(overlay_motion_path_line_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_motion_path_line_vert.glsl") +GEOMETRY_SOURCE("overlay_motion_path_line_geom.glsl") +FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_line_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::IVEC4, "mpathLineSettings") - .push_constant(Type::BOOL, "selected") - .push_constant(Type::VEC3, "customColorPre") - .push_constant(Type::VEC3, "customColorPost") - .push_constant(Type::INT, "lineThickness") /* In pixels. */ - .vertex_out(overlay_motion_path_line_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_motion_path_line_vert_no_geom.glsl") - .fragment_source("overlay_motion_path_line_frag.glsl") - .additional_info("draw_view", "draw_globals"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(IVEC4, mpathLineSettings) +PUSH_CONSTANT(BOOL, selected) +PUSH_CONSTANT(VEC3, customColorPre) +PUSH_CONSTANT(VEC3, customColorPost) +PUSH_CONSTANT(INT, lineThickness) /* In pixels. */ +VERTEX_OUT(overlay_motion_path_line_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_motion_path_line_vert_no_geom.glsl") +FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_line_next) - .do_static_compilation(true) - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .push_constant(Type::IVEC4, "mpathLineSettings") - .push_constant(Type::BOOL, "selected") - .push_constant(Type::VEC3, "customColorPre") - .push_constant(Type::VEC3, "customColorPost") - .push_constant(Type::INT, "lineThickness") /* In pixels. */ - .push_constant(Type::MAT4, "camera_space_matrix") - .vertex_out(overlay_motion_path_line_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_motion_path_line_next_vert.glsl") - .fragment_source("overlay_motion_path_line_frag.glsl") - .additional_info("draw_view", "gpu_index_load", "draw_globals"); +DO_STATIC_COMPILATION() +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +PUSH_CONSTANT(IVEC4, mpathLineSettings) +PUSH_CONSTANT(BOOL, selected) +PUSH_CONSTANT(VEC3, customColorPre) +PUSH_CONSTANT(VEC3, customColorPost) +PUSH_CONSTANT(INT, lineThickness) /* In pixels. */ +PUSH_CONSTANT(MAT4, camera_space_matrix) +VERTEX_OUT(overlay_motion_path_line_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_motion_path_line_next_vert.glsl") +FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_line_clipped) - .do_static_compilation(true) - .additional_info("overlay_motion_path_line", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_motion_path_line) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_line_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .additional_info("overlay_motion_path_line_no_geom", "drw_clipped"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_motion_path_line_no_geom) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_motion_path_point_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_motion_path_point_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_point) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::INT, "flag") - .push_constant(Type::IVEC4, "mpathPointSettings") - .push_constant(Type::BOOL, "showKeyFrames") - .push_constant(Type::VEC3, "customColorPre") - .push_constant(Type::VEC3, "customColorPost") - .push_constant(Type::MAT4, "camera_space_matrix") - .vertex_out(overlay_motion_path_point_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_motion_path_point_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, INT, flag) +PUSH_CONSTANT(IVEC4, mpathPointSettings) +PUSH_CONSTANT(BOOL, showKeyFrames) +PUSH_CONSTANT(VEC3, customColorPre) +PUSH_CONSTANT(VEC3, customColorPost) +PUSH_CONSTANT(MAT4, camera_space_matrix) +VERTEX_OUT(overlay_motion_path_point_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_motion_path_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_motion_path_point_clipped) - .do_static_compilation(true) - .additional_info("overlay_motion_path_point", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_motion_path_point) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -273,26 +333,31 @@ GPU_SHADER_CREATE_INFO(overlay_motion_path_point_clipped) /** \name Image Empty * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_image_iface, "").smooth(Type::VEC2, "uvs"); +GPU_SHADER_INTERFACE_INFO(overlay_image_iface) +SMOOTH(VEC2, uvs) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_image) - .do_static_compilation(true) - .push_constant(Type::BOOL, "depthSet") - .push_constant(Type::BOOL, "isCameraBackground") - .push_constant(Type::BOOL, "imgPremultiplied") - .push_constant(Type::BOOL, "imgAlphaBlend") - .push_constant(Type::VEC4, "ucolor") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(overlay_image_iface) - .sampler(0, ImageType::FLOAT_2D, "imgTexture") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_image_vert.glsl") - .fragment_source("overlay_image_frag.glsl") - .additional_info("draw_mesh"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(BOOL, depthSet) +PUSH_CONSTANT(BOOL, isCameraBackground) +PUSH_CONSTANT(BOOL, imgPremultiplied) +PUSH_CONSTANT(BOOL, imgAlphaBlend) +PUSH_CONSTANT(VEC4, ucolor) +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(overlay_image_iface) +SAMPLER(0, FLOAT_2D, imgTexture) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_image_vert.glsl") +FRAGMENT_SOURCE("overlay_image_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_image_clipped) - .do_static_compilation(true) - .additional_info("overlay_image", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_image) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -301,22 +366,26 @@ GPU_SHADER_CREATE_INFO(overlay_image_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas) - .do_static_compilation(true) - .vertex_out(overlay_extra_iface) - .push_constant(Type::VEC4, "color") - .push_constant(Type::VEC3, "xAxis") - .push_constant(Type::VEC3, "yAxis") - .push_constant(Type::VEC3, "origin") - .push_constant(Type::INT, "halfLineCount") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_edit_gpencil_canvas_vert.glsl") - .fragment_source("overlay_extra_frag.glsl") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_OUT(overlay_extra_iface) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(VEC3, xAxis) +PUSH_CONSTANT(VEC3, yAxis) +PUSH_CONSTANT(VEC3, origin) +PUSH_CONSTANT(INT, halfLineCount) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_edit_gpencil_canvas_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_frag.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas_clipped) - .do_static_compilation(true) - .additional_info("overlay_gpencil_canvas", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_gpencil_canvas) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -324,77 +393,94 @@ GPU_SHADER_CREATE_INFO(overlay_gpencil_canvas_clipped) /** \name Particle * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_particle_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_particle_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_particle) - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .push_constant(Type::VEC4, "ucolor") /* Draw-size packed in alpha. */ - .vertex_in(0, Type::VEC3, "part_pos") - .vertex_in(1, Type::VEC4, "part_rot") - .vertex_in(2, Type::FLOAT, "part_val") - .vertex_out(overlay_particle_iface) - .vertex_source("overlay_particle_vert.glsl") - .additional_info("draw_globals"); +SAMPLER(0, FLOAT_1D, weightTex) +PUSH_CONSTANT(VEC4, ucolor) /* Draw-size packed in alpha. */ +VERTEX_IN(0, VEC3, part_pos) +VERTEX_IN(1, VEC4, part_rot) +VERTEX_IN(2, FLOAT, part_val) +VERTEX_OUT(overlay_particle_iface) +VERTEX_SOURCE("overlay_particle_vert.glsl") +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_dot) - .do_static_compilation(true) - .define("USE_DOTS") - .define("vclass", "0") - .define("pos", "vec3(0.0)") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .fragment_source("overlay_particle_frag.glsl") - .additional_info("overlay_particle", "draw_mesh"); +DO_STATIC_COMPILATION() +DEFINE("USE_DOTS") +DEFINE_VALUE("vclass", "0") +DEFINE_VALUE("pos", "vec3(0.0)") +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +FRAGMENT_SOURCE("overlay_particle_frag.glsl") +ADDITIONAL_INFO(overlay_particle) +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_dot_clipped) - .do_static_compilation(true) - .additional_info("overlay_particle_dot", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_particle_dot) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_shape) - .do_static_compilation(true) - /* Instantiated Attrs. */ - .vertex_in(3, Type::VEC3, "pos") - .vertex_in(4, Type::INT, "vclass") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("overlay_varying_color.glsl") - .additional_info("overlay_particle", "draw_modelmat", "draw_resource_id_uniform"); +DO_STATIC_COMPILATION() +/* Instantiated Attrs. */ +VERTEX_IN(3, VEC3, pos) +VERTEX_IN(4, INT, vclass) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(overlay_particle) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id_uniform) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_shape_next) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .sampler(0, ImageType::FLOAT_1D, "weightTex") - .push_constant(Type::VEC4, "ucolor") /* Draw-size packed in alpha. */ - .push_constant(Type::INT, "shape_type") - /* Use first attribute to only bind one buffer. */ - .storage_buf(0, Qualifier::READ, "ParticlePointData", "part_pos[]", Frequency::GEOMETRY) - .vertex_out(overlay_extra_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_particle_shape_vert.glsl") - .fragment_source("overlay_particle_shape_frag.glsl") - .additional_info("draw_view", "draw_modelmat_new", "draw_resource_handle_new", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +SAMPLER(0, FLOAT_1D, weightTex) +PUSH_CONSTANT(VEC4, ucolor) /* Draw-size packed in alpha. */ +PUSH_CONSTANT(INT, shape_type) +/* Use first attribute to only bind one buffer. */ +STORAGE_BUF_FREQ(0, READ, ParticlePointData, part_pos[], GEOMETRY) +VERTEX_OUT(overlay_extra_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_particle_shape_vert.glsl") +FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_hair_next) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .push_constant(Type::INT, "colorType") - .push_constant(Type::BOOL, "isTransform") - .push_constant(Type::BOOL, "useColoring") - .vertex_out(overlay_extra_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_source("overlay_particle_hair_vert.glsl") - .fragment_source("overlay_particle_shape_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_object_infos_new", - "draw_resource_handle_new", - "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +PUSH_CONSTANT(INT, colorType) +PUSH_CONSTANT(BOOL, isTransform) +PUSH_CONSTANT(BOOL, useColoring) +VERTEX_OUT(overlay_extra_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_SOURCE("overlay_particle_hair_vert.glsl") +FRAGMENT_SOURCE("overlay_particle_shape_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_particle_shape_clipped) - .do_static_compilation(true) - .additional_info("overlay_particle_shape", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_particle_shape) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_facing_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_facing_info.hh index 075b82017e8..1b9188727df 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_facing_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_facing_info.hh @@ -5,13 +5,17 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(overlay_facing) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("overlay_facing_vert.glsl") - .fragment_source("overlay_facing_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .additional_info("draw_mesh", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("overlay_facing_vert.glsl") +FRAGMENT_SOURCE("overlay_facing_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_facing_clipped) - .do_static_compilation(true) - .additional_info("overlay_facing", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_facing) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_grid_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_grid_info.hh index ad85f5ceccb..47b34ee010a 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_grid_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_grid_info.hh @@ -5,37 +5,43 @@ #include "gpu_shader_create_info.hh" /* We use the normalized local position to avoid precision loss during interpolation. */ -GPU_SHADER_INTERFACE_INFO(overlay_grid_iface, "").smooth(Type::VEC3, "local_pos"); +GPU_SHADER_INTERFACE_INFO(overlay_grid_iface) +SMOOTH(VEC3, local_pos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_grid) - .do_static_compilation(true) - .typedef_source("overlay_shader_shared.h") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(overlay_grid_iface) - .fragment_out(0, Type::VEC4, "out_color") - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .uniform_buf(3, "OVERLAY_GridData", "grid_buf") - .push_constant(Type::VEC3, "plane_axes") - .push_constant(Type::INT, "grid_flag") - .vertex_source("overlay_grid_vert.glsl") - .fragment_source("overlay_grid_frag.glsl") - .additional_info("draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("overlay_shader_shared.h") +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(overlay_grid_iface) +FRAGMENT_OUT(0, VEC4, out_color) +SAMPLER(0, DEPTH_2D, depth_tx) +UNIFORM_BUF(3, OVERLAY_GridData, grid_buf) +PUSH_CONSTANT(VEC3, plane_axes) +PUSH_CONSTANT(INT, grid_flag) +VERTEX_SOURCE("overlay_grid_vert.glsl") +FRAGMENT_SOURCE("overlay_grid_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_grid_background) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .sampler(0, ImageType::DEPTH_2D, "depthBuffer") - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_tiled_image_borders_vert.glsl") - .fragment_source("overlay_grid_background_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +SAMPLER(0, DEPTH_2D, depthBuffer) +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl") +FRAGMENT_SOURCE("overlay_grid_background_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_grid_image) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_edit_uv_tiled_image_borders_vert.glsl") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_edit_uv_tiled_image_borders_vert.glsl") +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh index f064727b569..ee7312dfced 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh @@ -8,115 +8,147 @@ /** \name Outline Pre-pass * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_outline_prepass_iface, "interp").flat(Type::UINT, "ob_id"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_iface, interp) +FLAT(UINT, ob_id) +GPU_SHADER_NAMED_INTERFACE_END(interp) GPU_SHADER_CREATE_INFO(overlay_outline_prepass) - .push_constant(Type::BOOL, "isTransform") - .vertex_out(overlay_outline_prepass_iface) - /* Using uint because 16bit uint can contain more ids than int. */ - .fragment_out(0, Type::UINT, "out_object_id") - .fragment_source("overlay_outline_prepass_frag.glsl") - .additional_info("draw_globals"); +PUSH_CONSTANT(BOOL, isTransform) +VERTEX_OUT(overlay_outline_prepass_iface) +/* Using uint because 16bit uint can contain more ids than int. */ +FRAGMENT_OUT(0, UINT, out_object_id) +FRAGMENT_SOURCE("overlay_outline_prepass_frag.glsl") +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_mesh) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_source("overlay_outline_prepass_vert.glsl") - .additional_info("draw_mesh", "draw_resource_handle", "overlay_outline_prepass") - .additional_info("draw_object_infos"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_SOURCE("overlay_outline_prepass_vert.glsl") +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_resource_handle) +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_object_infos) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_mesh_clipped) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass_mesh", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass_mesh) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_outline_prepass_wire_iface, "vert").flat(Type::VEC3, "pos"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_wire_iface, vert) +FLAT(VEC3, pos) +GPU_SHADER_NAMED_INTERFACE_END(vert) GPU_SHADER_CREATE_INFO(overlay_outline_prepass_curves) - .do_static_compilation(true) - .vertex_source("overlay_outline_prepass_curves_vert.glsl") - .additional_info("draw_hair", "draw_resource_handle", "overlay_outline_prepass") - .additional_info("draw_object_infos"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_outline_prepass_curves_vert.glsl") +ADDITIONAL_INFO(draw_hair) +ADDITIONAL_INFO(draw_resource_handle) +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_object_infos) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_curves_clipped) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass_curves", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass_curves) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass", - "draw_object_infos", - "draw_mesh", - "draw_resource_handle") - .vertex_in(0, Type::VEC3, "pos") - .define("USE_GEOM") - .vertex_out(overlay_outline_prepass_wire_iface) - .geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2) - .geometry_out(overlay_outline_prepass_iface) - .vertex_source("overlay_outline_prepass_vert.glsl") - .geometry_source("overlay_outline_prepass_geom.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_object_infos) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_resource_handle) +VERTEX_IN(0, VEC3, pos) +DEFINE("USE_GEOM") +VERTEX_OUT(overlay_outline_prepass_wire_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2) +GEOMETRY_OUT(overlay_outline_prepass_iface) +VERTEX_SOURCE("overlay_outline_prepass_vert.glsl") +GEOMETRY_SOURCE("overlay_outline_prepass_geom.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_next) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass", - "draw_view", - "draw_mesh_new", - "draw_object_infos_new", - "draw_resource_handle_new", - "gpu_index_load") - .storage_buf(0, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .vertex_source("overlay_outline_prepass_wire_vert.glsl"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_mesh_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +VERTEX_SOURCE("overlay_outline_prepass_wire_vert.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .additional_info("overlay_outline_prepass", - "draw_object_infos", - "draw_mesh", - "draw_resource_handle") - .vertex_source("overlay_outline_prepass_vert_no_geom.glsl"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_object_infos) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_resource_handle) +VERTEX_SOURCE("overlay_outline_prepass_vert_no_geom.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_clipped) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass_wire", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass_wire) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_outline_prepass_gpencil_flat_iface, "gp_interp_flat") - .flat(Type::VEC2, "aspect") - .flat(Type::VEC4, "sspos"); -GPU_SHADER_INTERFACE_INFO(overlay_outline_prepass_gpencil_noperspective_iface, - "gp_interp_noperspective") - .no_perspective(Type::VEC2, "thickness") - .no_perspective(Type::FLOAT, "hardness"); +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_gpencil_flat_iface, gp_interp_flat) +FLAT(VEC2, aspect) +FLAT(VEC4, sspos) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_flat) +GPU_SHADER_NAMED_INTERFACE_INFO(overlay_outline_prepass_gpencil_noperspective_iface, + gp_interp_noperspective) +NO_PERSPECTIVE(VEC2, thickness) +NO_PERSPECTIVE(FLOAT, hardness) +GPU_SHADER_NAMED_INTERFACE_END(gp_interp_noperspective) GPU_SHADER_CREATE_INFO(overlay_outline_prepass_gpencil) - .do_static_compilation(true) - .push_constant(Type::BOOL, "isTransform") - .vertex_out(overlay_outline_prepass_iface) - .vertex_out(overlay_outline_prepass_gpencil_flat_iface) - .vertex_out(overlay_outline_prepass_gpencil_noperspective_iface) - .vertex_source("overlay_outline_prepass_gpencil_vert.glsl") - .push_constant(Type::BOOL, "gpStrokeOrder3d") /* TODO(fclem): Move to a GPencil object UBO. */ - .push_constant(Type::VEC4, "gpDepthPlane") /* TODO(fclem): Move to a GPencil object UBO. */ - /* Using uint because 16bit uint can contain more ids than int. */ - .fragment_out(0, Type::UINT, "out_object_id") - .fragment_source("overlay_outline_prepass_gpencil_frag.glsl") - .depth_write(DepthWrite::ANY) - .additional_info("draw_gpencil", "draw_resource_handle", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(BOOL, isTransform) +VERTEX_OUT(overlay_outline_prepass_iface) +VERTEX_OUT(overlay_outline_prepass_gpencil_flat_iface) +VERTEX_OUT(overlay_outline_prepass_gpencil_noperspective_iface) +VERTEX_SOURCE("overlay_outline_prepass_gpencil_vert.glsl") +PUSH_CONSTANT(BOOL, gpStrokeOrder3d) /* TODO(fclem): Move to a GPencil object UBO. */ +PUSH_CONSTANT(VEC4, gpDepthPlane) /* TODO(fclem): Move to a GPencil object UBO. */ +/* Using uint because 16bit uint can contain more ids than int. */ +FRAGMENT_OUT(0, UINT, out_object_id) +FRAGMENT_SOURCE("overlay_outline_prepass_gpencil_frag.glsl") +DEPTH_WRITE(DepthWrite::ANY) +ADDITIONAL_INFO(draw_gpencil) +ADDITIONAL_INFO(draw_resource_handle) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_gpencil_clipped) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass_gpencil", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass_gpencil) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud) - .do_static_compilation(true) - .vertex_source("overlay_outline_prepass_pointcloud_vert.glsl") - .additional_info("draw_pointcloud", "draw_resource_handle", "overlay_outline_prepass") - .additional_info("draw_object_infos"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_outline_prepass_pointcloud_vert.glsl") +ADDITIONAL_INFO(draw_pointcloud) +ADDITIONAL_INFO(draw_resource_handle) +ADDITIONAL_INFO(overlay_outline_prepass) +ADDITIONAL_INFO(draw_object_infos) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud_clipped) - .do_static_compilation(true) - .additional_info("overlay_outline_prepass_pointcloud", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_outline_prepass_pointcloud) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() /** \} */ @@ -125,17 +157,20 @@ GPU_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud_clipped) * \{ */ GPU_SHADER_CREATE_INFO(overlay_outline_detect) - .do_static_compilation(true) - .push_constant(Type::FLOAT, "alphaOcclu") - .push_constant(Type::BOOL, "isXrayWires") - .push_constant(Type::BOOL, "doAntiAliasing") - .push_constant(Type::BOOL, "doThickOutlines") - .sampler(0, ImageType::UINT_2D, "outlineId") - .sampler(1, ImageType::DEPTH_2D, "outlineDepth") - .sampler(2, ImageType::DEPTH_2D, "sceneDepth") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .fragment_source("overlay_outline_detect_frag.glsl") - .additional_info("draw_fullscreen", "draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(FLOAT, alphaOcclu) +PUSH_CONSTANT(BOOL, isXrayWires) +PUSH_CONSTANT(BOOL, doAntiAliasing) +PUSH_CONSTANT(BOOL, doThickOutlines) +SAMPLER(0, UINT_2D, outlineId) +SAMPLER(1, DEPTH_2D, outlineDepth) +SAMPLER(2, DEPTH_2D, sceneDepth) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +FRAGMENT_SOURCE("overlay_outline_detect_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_paint_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_paint_info.hh index 37d882c44ba..22c1ad5cd5b 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_paint_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_paint_info.hh @@ -11,19 +11,21 @@ * \{ */ GPU_SHADER_CREATE_INFO(overlay_paint_face) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "nor") /* Select flag on the 4th component. */ - .push_constant(Type::VEC4, "ucolor") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_face_vert.glsl") - .fragment_source("overlay_uniform_color_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, nor) /* Select flag on the 4th component. */ +PUSH_CONSTANT(VEC4, ucolor) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_face_vert.glsl") +FRAGMENT_SOURCE("overlay_uniform_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_face_clipped) - .additional_info("overlay_paint_face") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_face) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -33,22 +35,27 @@ GPU_SHADER_CREATE_INFO(overlay_paint_face_clipped) * Used for vertex selection mode in Weight and Vertex Paint. * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_overlay_paint_point_iface, "").smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_overlay_paint_point_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_paint_point) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "nor") /* Select flag on the 4th component. */ - .vertex_out(overlay_overlay_paint_point_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_point_vert.glsl") - .fragment_source("overlay_point_varying_color_frag.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, nor) /* Select flag on the 4th component. */ +VERTEX_OUT(overlay_overlay_paint_point_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_point_vert.glsl") +FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_point_clipped) - .additional_info("overlay_paint_point") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_point) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -58,27 +65,31 @@ GPU_SHADER_CREATE_INFO(overlay_paint_point_clipped) * Used in Texture Paint mode for the Stencil Image Masking. * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_paint_texture_iface, "").smooth(Type::VEC2, "uv_interp"); +GPU_SHADER_INTERFACE_INFO(overlay_paint_texture_iface) +SMOOTH(VEC2, uv_interp) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_paint_texture) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC2, "mu") /* Masking uv map. */ - .vertex_out(overlay_paint_texture_iface) - .sampler(0, ImageType::FLOAT_2D, "maskImage") - .push_constant(Type::VEC3, "maskColor") - .push_constant(Type::FLOAT, "opacity") /* `1.0` by default. */ - .push_constant(Type::BOOL, "maskInvertStencil") - .push_constant(Type::BOOL, "maskImagePremultiplied") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_texture_vert.glsl") - .fragment_source("overlay_paint_texture_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC2, mu) /* Masking uv map. */ +VERTEX_OUT(overlay_paint_texture_iface) +SAMPLER(0, FLOAT_2D, maskImage) +PUSH_CONSTANT(VEC3, maskColor) +PUSH_CONSTANT(FLOAT, opacity) /* `1.0` by default. */ +PUSH_CONSTANT(BOOL, maskInvertStencil) +PUSH_CONSTANT(BOOL, maskImagePremultiplied) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_texture_vert.glsl") +FRAGMENT_SOURCE("overlay_paint_texture_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_texture_clipped) - .additional_info("overlay_paint_texture") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_texture) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -88,24 +99,28 @@ GPU_SHADER_CREATE_INFO(overlay_paint_texture_clipped) * It should be used to draw a Vertex Paint overlay. But it is currently unreachable. * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_paint_vertcol_iface, "").smooth(Type::VEC3, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_paint_vertcol_iface) +SMOOTH(VEC3, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_paint_vertcol) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "ac") /* Active color. */ - .vertex_out(overlay_paint_vertcol_iface) - .push_constant(Type::FLOAT, "opacity") /* `1.0` by default. */ - .push_constant(Type::BOOL, "useAlphaBlend") /* `false` by default. */ - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_vertcol_vert.glsl") - .fragment_source("overlay_paint_vertcol_frag.glsl") - .additional_info("draw_modelmat"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, ac) /* Active color. */ +VERTEX_OUT(overlay_paint_vertcol_iface) +PUSH_CONSTANT(FLOAT, opacity) /* `1.0` by default. */ +PUSH_CONSTANT(BOOL, useAlphaBlend) /* `false` by default. */ +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_vertcol_vert.glsl") +FRAGMENT_SOURCE("overlay_paint_vertcol_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_vertcol_clipped) - .additional_info("overlay_paint_vertcol") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_vertcol) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -116,39 +131,45 @@ GPU_SHADER_CREATE_INFO(overlay_paint_vertcol_clipped) * `overlay paint weight` is for wireframe display mode. * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_paint_weight_iface, "") - .smooth(Type::VEC2, "weight_interp") /* (weight, alert) */ - .smooth(Type::FLOAT, "color_fac"); +GPU_SHADER_INTERFACE_INFO(overlay_paint_weight_iface) +SMOOTH(VEC2, weight_interp) /* (weight, alert) */ +SMOOTH(FLOAT, color_fac) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_paint_weight) - .do_static_compilation(true) - .vertex_in(0, Type::FLOAT, "weight") - .vertex_in(1, Type::VEC3, "pos") - .vertex_in(2, Type::VEC3, "nor") - .vertex_out(overlay_paint_weight_iface) - .sampler(0, ImageType::FLOAT_1D, "colorramp") - .push_constant(Type::FLOAT, "opacity") /* `1.0` by default. */ - .push_constant(Type::BOOL, "drawContours") /* `false` by default. */ - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_weight_vert.glsl") - .fragment_source("overlay_paint_weight_frag.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, FLOAT, weight) +VERTEX_IN(1, VEC3, pos) +VERTEX_IN(2, VEC3, nor) +VERTEX_OUT(overlay_paint_weight_iface) +SAMPLER(0, FLOAT_1D, colorramp) +PUSH_CONSTANT(FLOAT, opacity) /* `1.0` by default. */ +PUSH_CONSTANT(BOOL, drawContours) /* `false` by default. */ +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_weight_vert.glsl") +FRAGMENT_SOURCE("overlay_paint_weight_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_weight_fake_shading) - .additional_info("overlay_paint_weight") - .define("FAKE_SHADING") - .push_constant(Type::VEC3, "light_dir") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_weight) +DEFINE("FAKE_SHADING") +PUSH_CONSTANT(VEC3, light_dir) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_weight_clipped) - .additional_info("overlay_paint_weight") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_weight) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_weight_fake_shading_clipped) - .additional_info("overlay_paint_weight_fake_shading") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_weight_fake_shading) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -159,22 +180,27 @@ GPU_SHADER_CREATE_INFO(overlay_paint_weight_fake_shading_clipped) * paint modes. * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_paint_wire_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_paint_wire_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_paint_wire) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "nor") /* flag stored in w */ - .vertex_out(overlay_paint_wire_iface) - .push_constant(Type::BOOL, "useSelect") - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_paint_wire_vert.glsl") - .fragment_source("overlay_varying_color.glsl") - .additional_info("draw_modelmat", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, nor) /* flag stored in w */ +VERTEX_OUT(overlay_paint_wire_iface) +PUSH_CONSTANT(BOOL, useSelect) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_paint_wire_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_paint_wire_clipped) - .additional_info("overlay_paint_vertcol") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(overlay_paint_vertcol) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index 55758b3c410..4dba29d13af 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -4,41 +4,52 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_selection_iface, "") - .smooth(Type::FLOAT, "mask_weight"); +GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_selection_iface) +SMOOTH(FLOAT, mask_weight) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection) - .do_static_compilation(true) - .push_constant(Type::BOOL, "is_point_domain") - .push_constant(Type::FLOAT, "selection_opacity") - .sampler(1, ImageType::FLOAT_BUFFER, "selection_tx") - .vertex_out(overlay_sculpt_curves_selection_iface) - .vertex_source("overlay_sculpt_curves_selection_vert.glsl") - .fragment_source("overlay_sculpt_curves_selection_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .additional_info("draw_hair", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(BOOL, is_point_domain) +PUSH_CONSTANT(FLOAT, selection_opacity) +SAMPLER(1, FLOAT_BUFFER, selection_tx) +VERTEX_OUT(overlay_sculpt_curves_selection_iface) +VERTEX_SOURCE("overlay_sculpt_curves_selection_vert.glsl") +FRAGMENT_SOURCE("overlay_sculpt_curves_selection_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +ADDITIONAL_INFO(draw_hair) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection_clipped) - .do_static_compilation(true) - .additional_info("overlay_sculpt_curves_selection", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_sculpt_curves_selection) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_cage_iface, "") - .no_perspective(Type::VEC2, "edgePos") - .flat(Type::VEC2, "edgeStart") - .smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_cage_iface) +NO_PERSPECTIVE(VEC2, edgePos) +FLAT(VEC2, edgeStart) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_cage) - .do_static_compilation(true) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "selection") - .vertex_out(overlay_sculpt_curves_cage_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .push_constant(Type::FLOAT, "opacity") - .vertex_source("overlay_sculpt_curves_cage_vert.glsl") - .fragment_source("overlay_extra_frag.glsl") - .additional_info("draw_modelmat", "draw_view", "draw_globals"); +DO_STATIC_COMPILATION() +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, FLOAT, selection) +VERTEX_OUT(overlay_sculpt_curves_cage_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +PUSH_CONSTANT(FLOAT, opacity) +VERTEX_SOURCE("overlay_sculpt_curves_cage_vert.glsl") +FRAGMENT_SOURCE("overlay_extra_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_cage_clipped) - .do_static_compilation(true) - .additional_info("overlay_sculpt_curves_cage", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_sculpt_curves_cage) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh index 4767563265d..28f737c2cc6 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_info.hh @@ -4,24 +4,30 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(overlay_sculpt_mask_iface, "") - .flat(Type::VEC3, "faceset_color") - .smooth(Type::FLOAT, "mask_color") - .smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_sculpt_mask_iface) +FLAT(VEC3, faceset_color) +SMOOTH(FLOAT, mask_color) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_mask) - .do_static_compilation(true) - .push_constant(Type::FLOAT, "maskOpacity") - .push_constant(Type::FLOAT, "faceSetsOpacity") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "fset") - .vertex_in(2, Type::FLOAT, "msk") - .vertex_out(overlay_sculpt_mask_iface) - .vertex_source("overlay_sculpt_mask_vert.glsl") - .fragment_source("overlay_sculpt_mask_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .additional_info("draw_mesh", "draw_object_infos", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(FLOAT, maskOpacity) +PUSH_CONSTANT(FLOAT, faceSetsOpacity) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, fset) +VERTEX_IN(2, FLOAT, msk) +VERTEX_OUT(overlay_sculpt_mask_iface) +VERTEX_SOURCE("overlay_sculpt_mask_vert.glsl") +FRAGMENT_SOURCE("overlay_sculpt_mask_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_object_infos) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_sculpt_mask_clipped) - .do_static_compilation(true) - .additional_info("overlay_sculpt_mask", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_sculpt_mask) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh index 14b45ab1953..dde4663d503 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_viewer_attribute_info.hh @@ -4,65 +4,86 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(overlay_viewer_attribute_iface, "").smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_viewer_attribute_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() -GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_common).push_constant(Type::FLOAT, "opacity"); +GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_common) +PUSH_CONSTANT(FLOAT, opacity) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_mesh) - .do_static_compilation(true) - .vertex_source("overlay_viewer_attribute_mesh_vert.glsl") - .fragment_source("overlay_viewer_attribute_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "attribute_value") - .vertex_out(overlay_viewer_attribute_iface) - .additional_info("overlay_viewer_attribute_common", "draw_mesh"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_viewer_attribute_mesh_vert.glsl") +FRAGMENT_SOURCE("overlay_viewer_attribute_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, attribute_value) +VERTEX_OUT(overlay_viewer_attribute_iface) +ADDITIONAL_INFO(overlay_viewer_attribute_common) +ADDITIONAL_INFO(draw_mesh) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_mesh_clipped) - .do_static_compilation(true) - .additional_info("overlay_viewer_attribute_mesh", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_viewer_attribute_mesh) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud) - .do_static_compilation(true) - .vertex_source("overlay_viewer_attribute_pointcloud_vert.glsl") - .fragment_source("overlay_viewer_attribute_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .fragment_out(1, Type::VEC4, "lineOutput") - .sampler(3, ImageType::FLOAT_BUFFER, "attribute_tx") - .vertex_out(overlay_viewer_attribute_iface) - .additional_info("overlay_viewer_attribute_common", "draw_pointcloud"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_viewer_attribute_pointcloud_vert.glsl") +FRAGMENT_SOURCE("overlay_viewer_attribute_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_OUT(1, VEC4, lineOutput) +SAMPLER(3, FLOAT_BUFFER, attribute_tx) +VERTEX_OUT(overlay_viewer_attribute_iface) +ADDITIONAL_INFO(overlay_viewer_attribute_common) +ADDITIONAL_INFO(draw_pointcloud) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_pointcloud_clipped) - .do_static_compilation(true) - .additional_info("overlay_viewer_attribute_pointcloud", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_viewer_attribute_pointcloud) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve) - .do_static_compilation(true) - .vertex_source("overlay_viewer_attribute_curve_vert.glsl") - .fragment_source("overlay_viewer_attribute_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .fragment_out(1, Type::VEC4, "lineOutput") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "attribute_value") - .vertex_out(overlay_viewer_attribute_iface) - .additional_info("overlay_viewer_attribute_common", "draw_modelmat", "draw_resource_id"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_viewer_attribute_curve_vert.glsl") +FRAGMENT_SOURCE("overlay_viewer_attribute_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_OUT(1, VEC4, lineOutput) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, attribute_value) +VERTEX_OUT(overlay_viewer_attribute_iface) +ADDITIONAL_INFO(overlay_viewer_attribute_common) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curve_clipped) - .do_static_compilation(true) - .additional_info("overlay_viewer_attribute_curve", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_viewer_attribute_curve) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves) - .do_static_compilation(true) - .vertex_source("overlay_viewer_attribute_curves_vert.glsl") - .fragment_source("overlay_viewer_attribute_frag.glsl") - .fragment_out(0, Type::VEC4, "out_color") - .fragment_out(1, Type::VEC4, "lineOutput") - .sampler(0, ImageType::FLOAT_BUFFER, "color_tx") - .push_constant(Type::BOOL, "is_point_domain") - .vertex_out(overlay_viewer_attribute_iface) - .additional_info("overlay_viewer_attribute_common", "draw_hair"); +DO_STATIC_COMPILATION() +VERTEX_SOURCE("overlay_viewer_attribute_curves_vert.glsl") +FRAGMENT_SOURCE("overlay_viewer_attribute_frag.glsl") +FRAGMENT_OUT(0, VEC4, out_color) +FRAGMENT_OUT(1, VEC4, lineOutput) +SAMPLER(0, FLOAT_BUFFER, color_tx) +PUSH_CONSTANT(BOOL, is_point_domain) +VERTEX_OUT(overlay_viewer_attribute_iface) +ADDITIONAL_INFO(overlay_viewer_attribute_common) +ADDITIONAL_INFO(draw_hair) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_viewer_attribute_curves_clipped) - .do_static_compilation(true) - .additional_info("overlay_viewer_attribute_curves", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_viewer_attribute_curves) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_volume_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_volume_info.hh index f368ce00318..2bd30a709ed 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_volume_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_volume_info.hh @@ -8,45 +8,54 @@ /** \name Volume Velocity * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_volume_velocity_iface, "").smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_volume_velocity_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_volume_velocity) - .sampler(0, ImageType::FLOAT_3D, "velocityX") - .sampler(1, ImageType::FLOAT_3D, "velocityY") - .sampler(2, ImageType::FLOAT_3D, "velocityZ") - .push_constant(Type::FLOAT, "displaySize") - .push_constant(Type::FLOAT, "slicePosition") - .push_constant(Type::INT, "sliceAxis") - .push_constant(Type::BOOL, "scaleWithMagnitude") - .push_constant(Type::BOOL, "isCellCentered") - /* FluidDomainSettings.cell_size */ - .push_constant(Type::VEC3, "cellSize") - /* FluidDomainSettings.p0 */ - .push_constant(Type::VEC3, "domainOriginOffset") - /* FluidDomainSettings.res_min */ - .push_constant(Type::IVEC3, "adaptiveCellOffset") - .push_constant(Type::INT, "in_select_id") - .vertex_out(overlay_volume_velocity_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_volume_velocity_vert.glsl") - .fragment_source("overlay_varying_color.glsl"); +SAMPLER(0, FLOAT_3D, velocityX) +SAMPLER(1, FLOAT_3D, velocityY) +SAMPLER(2, FLOAT_3D, velocityZ) +PUSH_CONSTANT(FLOAT, displaySize) +PUSH_CONSTANT(FLOAT, slicePosition) +PUSH_CONSTANT(INT, sliceAxis) +PUSH_CONSTANT(BOOL, scaleWithMagnitude) +PUSH_CONSTANT(BOOL, isCellCentered) +/* FluidDomainSettings.cell_size */ +PUSH_CONSTANT(VEC3, cellSize) +/* FluidDomainSettings.p0 */ +PUSH_CONSTANT(VEC3, domainOriginOffset) +/* FluidDomainSettings.res_min */ +PUSH_CONSTANT(IVEC3, adaptiveCellOffset) +PUSH_CONSTANT(INT, in_select_id) +VERTEX_OUT(overlay_volume_velocity_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_volume_velocity_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_velocity_streamline) - .do_static_compilation(true) - .additional_info("draw_volume", "overlay_volume_velocity"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_velocity) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_velocity_mac) - .do_static_compilation(true) - .define("USE_MAC") - .push_constant(Type::BOOL, "drawMACX") - .push_constant(Type::BOOL, "drawMACY") - .push_constant(Type::BOOL, "drawMACZ") - .additional_info("draw_volume", "overlay_volume_velocity"); +DO_STATIC_COMPILATION() +DEFINE("USE_MAC") +PUSH_CONSTANT(BOOL, drawMACX) +PUSH_CONSTANT(BOOL, drawMACY) +PUSH_CONSTANT(BOOL, drawMACZ) +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_velocity) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle) - .do_static_compilation(true) - .define("USE_NEEDLE") - .additional_info("draw_volume", "overlay_volume_velocity"); +DO_STATIC_COMPILATION() +DEFINE("USE_NEEDLE") +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_velocity) +GPU_SHADER_CREATE_END() /** \} */ @@ -54,44 +63,53 @@ GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle) /** \name Volume Grid-Lines * \{ */ -GPU_SHADER_INTERFACE_INFO(overlay_volume_gridlines_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(overlay_volume_gridlines_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_volume_gridlines) - .push_constant(Type::FLOAT, "slicePosition") - .push_constant(Type::INT, "sliceAxis") - /* FluidDomainSettings.res */ - .push_constant(Type::IVEC3, "volumeSize") - /* FluidDomainSettings.cell_size */ - .push_constant(Type::VEC3, "cellSize") - /* FluidDomainSettings.p0 */ - .push_constant(Type::VEC3, "domainOriginOffset") - /* FluidDomainSettings.res_min */ - .push_constant(Type::IVEC3, "adaptiveCellOffset") - .push_constant(Type::INT, "in_select_id") - .vertex_out(overlay_volume_gridlines_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("overlay_volume_gridlines_vert.glsl") - .fragment_source("overlay_varying_color.glsl"); +PUSH_CONSTANT(FLOAT, slicePosition) +PUSH_CONSTANT(INT, sliceAxis) +/* FluidDomainSettings.res */ +PUSH_CONSTANT(IVEC3, volumeSize) +/* FluidDomainSettings.cell_size */ +PUSH_CONSTANT(VEC3, cellSize) +/* FluidDomainSettings.p0 */ +PUSH_CONSTANT(VEC3, domainOriginOffset) +/* FluidDomainSettings.res_min */ +PUSH_CONSTANT(IVEC3, adaptiveCellOffset) +PUSH_CONSTANT(INT, in_select_id) +VERTEX_OUT(overlay_volume_gridlines_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("overlay_volume_gridlines_vert.glsl") +FRAGMENT_SOURCE("overlay_varying_color.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flat) - .do_static_compilation(true) - .additional_info("draw_volume", "overlay_volume_gridlines"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_gridlines) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flags) - .do_static_compilation(true) - .define("SHOW_FLAGS") - .sampler(0, ImageType::UINT_3D, "flagTexture") - .additional_info("draw_volume", "overlay_volume_gridlines"); +DO_STATIC_COMPILATION() +DEFINE("SHOW_FLAGS") +SAMPLER(0, UINT_3D, flagTexture) +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_gridlines) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_range) - .do_static_compilation(true) - .define("SHOW_RANGE") - .push_constant(Type::FLOAT, "lowerBound") - .push_constant(Type::FLOAT, "upperBound") - .push_constant(Type::VEC4, "rangeColor") - .push_constant(Type::INT, "cellFilter") - .sampler(0, ImageType::UINT_3D, "flagTexture") - .sampler(1, ImageType::FLOAT_3D, "fieldTexture") - .additional_info("draw_volume", "overlay_volume_gridlines"); +DO_STATIC_COMPILATION() +DEFINE("SHOW_RANGE") +PUSH_CONSTANT(FLOAT, lowerBound) +PUSH_CONSTANT(FLOAT, upperBound) +PUSH_CONSTANT(VEC4, rangeColor) +PUSH_CONSTANT(INT, cellFilter) +SAMPLER(0, UINT_3D, flagTexture) +SAMPLER(1, FLOAT_3D, fieldTexture) +ADDITIONAL_INFO(draw_volume) +ADDITIONAL_INFO(overlay_volume_gridlines) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh index 62732a05730..1e44ffe6c47 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh @@ -4,113 +4,129 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(overlay_wireframe_iface, "") - .smooth(Type::VEC4, "finalColor") - .flat(Type::VEC2, "edgeStart") - .no_perspective(Type::VEC2, "edgePos"); +GPU_SHADER_INTERFACE_INFO(overlay_wireframe_iface) +SMOOTH(VEC4, finalColor) +FLAT(VEC2, edgeStart) +NO_PERSPECTIVE(VEC2, edgePos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe) - .do_static_compilation(true) - .push_constant(Type::FLOAT, "wireStepParam") - .push_constant(Type::FLOAT, "wireOpacity") - .push_constant(Type::BOOL, "useColoring") - .push_constant(Type::BOOL, "isTransform") - .push_constant(Type::INT, "colorType") - .push_constant(Type::BOOL, "isHair") - .push_constant(Type::MAT4, "hairDupliMatrix") - /* Scene Depth texture copy for manual depth test. */ - .sampler(0, ImageType::DEPTH_2D, "depthTex") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .vertex_in(2, Type::FLOAT, "wd") /* wire-data. */ - .vertex_out(overlay_wireframe_iface) - .vertex_source("overlay_wireframe_vert.glsl") - .fragment_source("overlay_wireframe_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .depth_write(DepthWrite::ANY) - .additional_info("draw_mesh", "draw_object_infos", "draw_globals"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(FLOAT, wireStepParam) +PUSH_CONSTANT(FLOAT, wireOpacity) +PUSH_CONSTANT(BOOL, useColoring) +PUSH_CONSTANT(BOOL, isTransform) +PUSH_CONSTANT(INT, colorType) +PUSH_CONSTANT(BOOL, isHair) +PUSH_CONSTANT(MAT4, hairDupliMatrix) +/* Scene Depth texture copy for manual depth test. */ +SAMPLER(0, DEPTH_2D, depthTex) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +VERTEX_IN(2, FLOAT, wd) /* wire-data. */ +VERTEX_OUT(overlay_wireframe_iface) +VERTEX_SOURCE("overlay_wireframe_vert.glsl") +FRAGMENT_SOURCE("overlay_wireframe_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +DEPTH_WRITE(DepthWrite::ANY) +ADDITIONAL_INFO(draw_mesh) +ADDITIONAL_INFO(draw_object_infos) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_curve) - .do_static_compilation(true) - .define("CURVES") - .push_constant(Type::FLOAT, "wireOpacity") - .push_constant(Type::BOOL, "useColoring") - .push_constant(Type::BOOL, "isTransform") - .push_constant(Type::INT, "colorType") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(overlay_wireframe_iface) - .vertex_source("overlay_wireframe_vert.glsl") - .fragment_source("overlay_wireframe_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "draw_object_infos_new", - "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("CURVES") +PUSH_CONSTANT(FLOAT, wireOpacity) +PUSH_CONSTANT(BOOL, useColoring) +PUSH_CONSTANT(BOOL, isTransform) +PUSH_CONSTANT(INT, colorType) +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(overlay_wireframe_iface) +VERTEX_SOURCE("overlay_wireframe_vert.glsl") +FRAGMENT_SOURCE("overlay_wireframe_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(overlay_wireframe_points_iface, "") - .flat(Type::VEC4, "finalColor") - .flat(Type::VEC4, "finalColorInner"); +GPU_SHADER_INTERFACE_INFO(overlay_wireframe_points_iface) +FLAT(VEC4, finalColor) +FLAT(VEC4, finalColorInner) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_points) - .do_static_compilation(true) - .define("POINTS") - .push_constant(Type::BOOL, "useColoring") - .push_constant(Type::BOOL, "isTransform") - .push_constant(Type::INT, "colorType") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(overlay_wireframe_points_iface) - .vertex_source("overlay_wireframe_vert.glsl") - .fragment_source("overlay_wireframe_frag.glsl") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_out(1, Type::VEC4, "lineOutput") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "draw_object_infos_new", - "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("POINTS") +PUSH_CONSTANT(BOOL, useColoring) +PUSH_CONSTANT(BOOL, isTransform) +PUSH_CONSTANT(INT, colorType) +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(overlay_wireframe_points_iface) +VERTEX_SOURCE("overlay_wireframe_vert.glsl") +FRAGMENT_SOURCE("overlay_wireframe_frag.glsl") +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_OUT(1, VEC4, lineOutput) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_clipped) - .do_static_compilation(true) - .additional_info("overlay_wireframe", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_wireframe) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_custom_depth) - .do_static_compilation(true) - .define("CUSTOM_DEPTH_BIAS") - .additional_info("overlay_wireframe"); +DO_STATIC_COMPILATION() +DEFINE("CUSTOM_DEPTH_BIAS") +ADDITIONAL_INFO(overlay_wireframe) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_custom_depth_clipped) - .do_static_compilation(true) - .additional_info("overlay_wireframe_custom_depth", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_wireframe_custom_depth) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_select) - .do_static_compilation(true) - .define("SELECT_EDGES") - .additional_info("overlay_wireframe"); +DO_STATIC_COMPILATION() +DEFINE("SELECT_EDGES") +ADDITIONAL_INFO(overlay_wireframe) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_select_clipped) - .do_static_compilation(true) - .additional_info("overlay_wireframe_select", "drw_clipped"); +DO_STATIC_COMPILATION() +ADDITIONAL_INFO(overlay_wireframe_select) +ADDITIONAL_INFO(drw_clipped) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(overlay_wireframe_uv) - .do_static_compilation(true) - .define("WIREFRAME") - .storage_buf(0, Qualifier::READ, "float", "au[]", Frequency::GEOMETRY) - .push_constant(Type::IVEC2, "gpu_attr_0") - .define("lineStyle", "4" /* OVERLAY_UV_LINE_STYLE_SHADOW */) - .define("dashLength", "1" /* Not used by this line style */) - .define("use_edge_select", "false") - .push_constant(Type::BOOL, "doSmoothWire") - .push_constant(Type::FLOAT, "alpha") - .vertex_out(overlay_edit_uv_next_iface) - .fragment_out(0, Type::VEC4, "fragColor") - /* Note: Reuse edit mode shader as it is mostly the same. */ - .vertex_source("overlay_edit_uv_edges_next_vert.glsl") - .fragment_source("overlay_edit_uv_edges_next_frag.glsl") - .additional_info("draw_view", - "draw_modelmat_new", - "draw_resource_handle_new", - "gpu_index_load", - "draw_globals"); +DO_STATIC_COMPILATION() +DEFINE("WIREFRAME") +STORAGE_BUF_FREQ(0, READ, float, au[], GEOMETRY) +PUSH_CONSTANT(IVEC2, gpu_attr_0) +DEFINE_VALUE("lineStyle", "4" /* OVERLAY_UV_LINE_STYLE_SHADOW */) +DEFINE_VALUE("dashLength", "1" /* Not used by this line style */) +DEFINE_VALUE("use_edge_select", "false") +PUSH_CONSTANT(BOOL, doSmoothWire) +PUSH_CONSTANT(FLOAT, alpha) +VERTEX_OUT(overlay_edit_uv_next_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +/* Note: Reuse edit mode shader as it is mostly the same. */ +VERTEX_SOURCE("overlay_edit_uv_edges_next_vert.glsl") +FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_globals) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/select/shaders/infos/select_id_info.hh b/source/blender/draw/engines/select/shaders/infos/select_id_info.hh index c90167d9727..b2c30fda0ab 100644 --- a/source/blender/draw/engines/select/shaders/infos/select_id_info.hh +++ b/source/blender/draw/engines/select/shaders/infos/select_id_info.hh @@ -9,60 +9,68 @@ /** \name Select ID for Edit Mesh Selection * \{ */ -GPU_SHADER_INTERFACE_INFO(select_id_iface, "").flat(Type::INT, "select_id"); +GPU_SHADER_INTERFACE_INFO(select_id_iface) +FLAT(INT, select_id) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(select_id_flat) - .push_constant(Type::FLOAT, "sizeVertex") - .push_constant(Type::INT, "offset") - .push_constant(Type::FLOAT, "retopologyOffset") - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::INT, "index") - .vertex_out(select_id_iface) - .fragment_out(0, Type::UINT, "fragColor") - .vertex_source("select_id_vert.glsl") - .fragment_source("select_id_frag.glsl") - .additional_info("draw_modelmat") - .do_static_compilation(true); +PUSH_CONSTANT(FLOAT, sizeVertex) +PUSH_CONSTANT(INT, offset) +PUSH_CONSTANT(FLOAT, retopologyOffset) +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, INT, index) +VERTEX_OUT(select_id_iface) +FRAGMENT_OUT(0, UINT, fragColor) +VERTEX_SOURCE("select_id_vert.glsl") +FRAGMENT_SOURCE("select_id_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(select_id_uniform) - .define("UNIFORM_ID") - .push_constant(Type::FLOAT, "sizeVertex") - .push_constant(Type::INT, "select_id") - .push_constant(Type::FLOAT, "retopologyOffset") - .vertex_in(0, Type::VEC3, "pos") - .fragment_out(0, Type::UINT, "fragColor") - .vertex_source("select_id_vert.glsl") - .fragment_source("select_id_frag.glsl") - .additional_info("draw_modelmat") - .do_static_compilation(true); +DEFINE("UNIFORM_ID") +PUSH_CONSTANT(FLOAT, sizeVertex) +PUSH_CONSTANT(INT, select_id) +PUSH_CONSTANT(FLOAT, retopologyOffset) +VERTEX_IN(0, VEC3, pos) +FRAGMENT_OUT(0, UINT, fragColor) +VERTEX_SOURCE("select_id_vert.glsl") +FRAGMENT_SOURCE("select_id_frag.glsl") +ADDITIONAL_INFO(draw_modelmat) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(select_id_flat_clipped) - .additional_info("select_id_flat") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(select_id_flat) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(select_id_uniform_clipped) - .additional_info("select_id_uniform") - .additional_info("drw_clipped") - .do_static_compilation(true); +ADDITIONAL_INFO(select_id_uniform) +ADDITIONAL_INFO(drw_clipped) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Used to patch overlay shaders. */ GPU_SHADER_CREATE_INFO(select_id_patch) - .typedef_source("select_shader_shared.hh") - .vertex_out(select_id_iface) - /* Need to make sure the depth & stencil comparison runs before the fragment shader. */ - .early_fragment_test(true) - .uniform_buf(SELECT_DATA, "SelectInfoData", "select_info_buf") - /* Select IDs for instanced draw-calls not using #PassMain. */ - .storage_buf(SELECT_ID_IN, Qualifier::READ, "int", "in_select_buf[]") - /* Stores the result of the whole selection drawing. Content depends on selection mode. */ - .storage_buf(SELECT_ID_OUT, Qualifier::READ_WRITE, "uint", "out_select_buf[]"); +TYPEDEF_SOURCE("select_shader_shared.hh") +VERTEX_OUT(select_id_iface) +/* Need to make sure the depth & stencil comparison runs before the fragment shader. */ +EARLY_FRAGMENT_TEST(true) +UNIFORM_BUF(SELECT_DATA, SelectInfoData, select_info_buf) +/* Select IDs for instanced draw-calls not using #PassMain. */ +STORAGE_BUF(SELECT_ID_IN, READ, int, in_select_buf[]) +/* Stores the result of the whole selection drawing. Content depends on selection mode. */ +STORAGE_BUF(SELECT_ID_OUT, READ_WRITE, uint, out_select_buf[]) +GPU_SHADER_CREATE_END() /** \} */ GPU_SHADER_CREATE_INFO(select_debug_fullscreen) - .additional_info("draw_fullscreen") - .fragment_source("select_debug_frag.glsl") - .sampler(0, ImageType::UINT_2D, "image") - .fragment_out(0, Type::VEC4, "fragColor") - .do_static_compilation(true); +ADDITIONAL_INFO(draw_fullscreen) +FRAGMENT_SOURCE("select_debug_frag.glsl") +SAMPLER(0, UINT_2D, image) +FRAGMENT_OUT(0, VEC4, fragColor) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh index d44c29abf1a..4e7e20d6602 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh @@ -10,69 +10,76 @@ * \{ */ GPU_SHADER_CREATE_INFO(workbench_composite) - .sampler(3, ImageType::DEPTH_2D, "depth_tx") - .sampler(4, ImageType::FLOAT_2D, "normal_tx") - .sampler(5, ImageType::FLOAT_2D, "material_tx") - .uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") - .typedef_source("workbench_shader_shared.h") - .push_constant(Type::BOOL, "forceShadowing") - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("workbench_composite_frag.glsl") - .additional_info("draw_fullscreen", "draw_view"); +SAMPLER(3, DEPTH_2D, depth_tx) +SAMPLER(4, FLOAT_2D, normal_tx) +SAMPLER(5, FLOAT_2D, material_tx) +UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data) +TYPEDEF_SOURCE("workbench_shader_shared.h") +PUSH_CONSTANT(BOOL, forceShadowing) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("workbench_composite_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /* Lighting */ -GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_studio).define("WORKBENCH_LIGHTING_STUDIO"); +GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_studio) +DEFINE("WORKBENCH_LIGHTING_STUDIO") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_matcap) - .define("WORKBENCH_LIGHTING_MATCAP") - .sampler(WB_MATCAP_SLOT, ImageType::FLOAT_2D_ARRAY, "matcap_tx"); +DEFINE("WORKBENCH_LIGHTING_MATCAP") +SAMPLER(WB_MATCAP_SLOT, FLOAT_2D_ARRAY, matcap_tx) +GPU_SHADER_CREATE_END() -GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_flat).define("WORKBENCH_LIGHTING_FLAT"); +GPU_SHADER_CREATE_INFO(workbench_resolve_opaque_flat) +DEFINE("WORKBENCH_LIGHTING_FLAT") +GPU_SHADER_CREATE_END() /* Effects */ GPU_SHADER_CREATE_INFO(workbench_resolve_curvature) - .define("WORKBENCH_CURVATURE") - .sampler(6, ImageType::UINT_2D, "object_id_tx"); +DEFINE("WORKBENCH_CURVATURE") +SAMPLER(6, UINT_2D, object_id_tx) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_resolve_cavity) - .define("WORKBENCH_CAVITY") - /* TODO(@pragma37): GPU_SAMPLER_EXTEND_MODE_REPEAT is set in CavityEffect, - * it doesn't work here? */ - .sampler(7, ImageType::FLOAT_2D, "jitter_tx") - .uniform_buf(5, "vec4", "cavity_samples[512]"); +DEFINE("WORKBENCH_CAVITY") +/* TODO(@pragma37): GPU_SAMPLER_EXTEND_MODE_REPEAT is set in CavityEffect, + * it doesn't work here? */ +SAMPLER(7, FLOAT_2D, jitter_tx) +UNIFORM_BUF(5, vec4, cavity_samples[512]) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_resolve_shadow) - .define("WORKBENCH_SHADOW") - .sampler(8, ImageType::UINT_2D, "stencil_tx"); +DEFINE("WORKBENCH_SHADOW") +SAMPLER(8, UINT_2D, stencil_tx) +GPU_SHADER_CREATE_END() /* Variations */ -#define WORKBENCH_FINAL_VARIATION(name, ...) \ - GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); - #define WORKBENCH_RESOLVE_SHADOW_VARIATION(prefix, ...) \ - WORKBENCH_FINAL_VARIATION(prefix##_shadow, "workbench_resolve_shadow", __VA_ARGS__) \ - WORKBENCH_FINAL_VARIATION(prefix##_no_shadow, __VA_ARGS__) + CREATE_INFO_VARIANT(prefix##_shadow, workbench_resolve_shadow, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_no_shadow, __VA_ARGS__) #define WORKBENCH_CURVATURE_VARIATIONS(prefix, ...) \ WORKBENCH_RESOLVE_SHADOW_VARIATION( \ - prefix##_curvature, "workbench_resolve_curvature", __VA_ARGS__) \ + prefix##_curvature, workbench_resolve_curvature, __VA_ARGS__) \ WORKBENCH_RESOLVE_SHADOW_VARIATION(prefix##_no_curvature, __VA_ARGS__) #define WORKBENCH_CAVITY_VARIATIONS(prefix, ...) \ - WORKBENCH_CURVATURE_VARIATIONS(prefix##_cavity, "workbench_resolve_cavity", __VA_ARGS__) \ + WORKBENCH_CURVATURE_VARIATIONS(prefix##_cavity, workbench_resolve_cavity, __VA_ARGS__) \ WORKBENCH_CURVATURE_VARIATIONS(prefix##_no_cavity, __VA_ARGS__) #define WORKBENCH_LIGHTING_VARIATIONS(prefix, ...) \ WORKBENCH_CAVITY_VARIATIONS( \ - prefix##_opaque_studio, "workbench_resolve_opaque_studio", __VA_ARGS__) \ + prefix##_opaque_studio, workbench_resolve_opaque_studio, __VA_ARGS__) \ WORKBENCH_CAVITY_VARIATIONS( \ - prefix##_opaque_matcap, "workbench_resolve_opaque_matcap", __VA_ARGS__) \ - WORKBENCH_CAVITY_VARIATIONS(prefix##_opaque_flat, "workbench_resolve_opaque_flat", __VA_ARGS__) + prefix##_opaque_matcap, workbench_resolve_opaque_matcap, __VA_ARGS__) \ + WORKBENCH_CAVITY_VARIATIONS(prefix##_opaque_flat, workbench_resolve_opaque_flat, __VA_ARGS__) -WORKBENCH_LIGHTING_VARIATIONS(workbench_resolve, "workbench_composite"); +WORKBENCH_LIGHTING_VARIATIONS(workbench_resolve, workbench_composite) #undef WORKBENCH_FINAL_VARIATION #undef WORKBENCH_CURVATURE_VARIATIONS diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_depth_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_depth_info.hh index 2d471595090..a5c93de9087 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_depth_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_depth_info.hh @@ -5,20 +5,23 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(workbench_merge_depth) - .sampler(0, ImageType::DEPTH_2D, "depth_tx") - .fragment_source("workbench_merge_depth_frag.glsl") - .additional_info("draw_fullscreen") - .depth_write(DepthWrite::ANY) - .do_static_compilation(true); +SAMPLER(0, DEPTH_2D, depth_tx) +FRAGMENT_SOURCE("workbench_merge_depth_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +DEPTH_WRITE(DepthWrite::ANY) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_overlay_depth) - .fragment_source("workbench_overlay_depth_frag.glsl") - .additional_info("draw_fullscreen") - .depth_write(DepthWrite::ANY) - .do_static_compilation(true); +FRAGMENT_SOURCE("workbench_overlay_depth_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +DEPTH_WRITE(DepthWrite::ANY) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_extract_stencil) - .fragment_out(0, Type::UINT, "out_stencil_value") - .fragment_source("workbench_extract_stencil.glsl") - .additional_info("draw_fullscreen") - .do_static_compilation(true); +FRAGMENT_OUT(0, UINT, out_stencil_value) +FRAGMENT_SOURCE("workbench_extract_stencil.glsl") +ADDITIONAL_INFO(draw_fullscreen) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh index 54cf7d85535..1f3cac83cc9 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh @@ -9,12 +9,13 @@ * \{ */ GPU_SHADER_CREATE_INFO(workbench_taa) - .sampler(0, ImageType::FLOAT_2D, "colorBuffer") - .push_constant(Type::FLOAT, "samplesWeights", 9) - .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("workbench_effect_taa_frag.glsl") - .additional_info("draw_fullscreen") - .do_static_compilation(true); +SAMPLER(0, FLOAT_2D, colorBuffer) +PUSH_CONSTANT_ARRAY(FLOAT, samplesWeights, 9) +FRAGMENT_OUT(0, VEC4, fragColor) +FRAGMENT_SOURCE("workbench_effect_taa_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -22,46 +23,51 @@ GPU_SHADER_CREATE_INFO(workbench_taa) /** \name SMAA * \{ */ -GPU_SHADER_INTERFACE_INFO(workbench_smaa_iface, "") - .smooth(Type::VEC2, "uvs") - .smooth(Type::VEC2, "pixcoord") - .smooth(Type::VEC4, "offset[3]"); +GPU_SHADER_INTERFACE_INFO(workbench_smaa_iface) +SMOOTH(VEC2, uvs) +SMOOTH(VEC2, pixcoord) +SMOOTH(VEC4, offset[3]) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(workbench_smaa) - .define("SMAA_GLSL_3") - .define("SMAA_RT_METRICS", "viewportMetrics") - .define("SMAA_PRESET_HIGH") - .define("SMAA_LUMA_WEIGHT", "float4(1.0, 1.0, 1.0, 1.0)") - .define("SMAA_NO_DISCARD") - .vertex_out(workbench_smaa_iface) - .push_constant(Type::VEC4, "viewportMetrics") - .vertex_source("workbench_effect_smaa_vert.glsl") - .fragment_source("workbench_effect_smaa_frag.glsl"); +DEFINE("SMAA_GLSL_3") +DEFINE_VALUE("SMAA_RT_METRICS", "viewportMetrics") +DEFINE("SMAA_PRESET_HIGH") +DEFINE_VALUE("SMAA_LUMA_WEIGHT", "float4(1.0, 1.0, 1.0, 1.0)") +DEFINE("SMAA_NO_DISCARD") +VERTEX_OUT(workbench_smaa_iface) +PUSH_CONSTANT(VEC4, viewportMetrics) +VERTEX_SOURCE("workbench_effect_smaa_vert.glsl") +FRAGMENT_SOURCE("workbench_effect_smaa_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_smaa_stage_0) - .define("SMAA_STAGE", "0") - .sampler(0, ImageType::FLOAT_2D, "colorTex") - .fragment_out(0, Type::VEC2, "out_edges") - .additional_info("workbench_smaa") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "0") +SAMPLER(0, FLOAT_2D, colorTex) +FRAGMENT_OUT(0, VEC2, out_edges) +ADDITIONAL_INFO(workbench_smaa) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_smaa_stage_1) - .define("SMAA_STAGE", "1") - .sampler(0, ImageType::FLOAT_2D, "edgesTex") - .sampler(1, ImageType::FLOAT_2D, "areaTex") - .sampler(2, ImageType::FLOAT_2D, "searchTex") - .fragment_out(0, Type::VEC4, "out_weights") - .additional_info("workbench_smaa") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "1") +SAMPLER(0, FLOAT_2D, edgesTex) +SAMPLER(1, FLOAT_2D, areaTex) +SAMPLER(2, FLOAT_2D, searchTex) +FRAGMENT_OUT(0, VEC4, out_weights) +ADDITIONAL_INFO(workbench_smaa) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_smaa_stage_2) - .define("SMAA_STAGE", "2") - .sampler(0, ImageType::FLOAT_2D, "colorTex") - .sampler(1, ImageType::FLOAT_2D, "blendTex") - .push_constant(Type::FLOAT, "mixFactor") - .push_constant(Type::FLOAT, "taaAccumulatedWeight") - .fragment_out(0, Type::VEC4, "out_color") - .additional_info("workbench_smaa") - .do_static_compilation(true); +DEFINE_VALUE("SMAA_STAGE", "2") +SAMPLER(0, FLOAT_2D, colorTex) +SAMPLER(1, FLOAT_2D, blendTex) +PUSH_CONSTANT(FLOAT, mixFactor) +PUSH_CONSTANT(FLOAT, taaAccumulatedWeight) +FRAGMENT_OUT(0, VEC4, out_color) +ADDITIONAL_INFO(workbench_smaa) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_dof_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_dof_info.hh index a7ef011e6ca..7ba5b44cc0c 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_dof_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_dof_info.hh @@ -5,54 +5,60 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(workbench_effect_dof) - /* TODO(fclem): Split resources per stage. */ - .sampler(0, ImageType::FLOAT_2D, "inputCocTex") - .sampler(1, ImageType::FLOAT_2D, "maxCocTilesTex") - .sampler(2, ImageType::FLOAT_2D, "sceneColorTex") - .sampler(3, ImageType::FLOAT_2D, "sceneDepthTex") - .sampler(4, ImageType::FLOAT_2D, "backgroundTex") - .sampler(5, ImageType::FLOAT_2D, "halfResColorTex") - .sampler(6, ImageType::FLOAT_2D, "blurTex") - .sampler(7, ImageType::FLOAT_2D, "noiseTex") - .push_constant(Type::VEC2, "invertedViewportSize") - .push_constant(Type::VEC2, "nearFar") - .push_constant(Type::VEC3, "dofParams") - .push_constant(Type::FLOAT, "noiseOffset") - .fragment_source("workbench_effect_dof_frag.glsl") - .additional_info("draw_fullscreen") - .additional_info("draw_view"); +/* TODO(fclem): Split resources per stage. */ +SAMPLER(0, FLOAT_2D, inputCocTex) +SAMPLER(1, FLOAT_2D, maxCocTilesTex) +SAMPLER(2, FLOAT_2D, sceneColorTex) +SAMPLER(3, FLOAT_2D, sceneDepthTex) +SAMPLER(4, FLOAT_2D, backgroundTex) +SAMPLER(5, FLOAT_2D, halfResColorTex) +SAMPLER(6, FLOAT_2D, blurTex) +SAMPLER(7, FLOAT_2D, noiseTex) +PUSH_CONSTANT(VEC2, invertedViewportSize) +PUSH_CONSTANT(VEC2, nearFar) +PUSH_CONSTANT(VEC3, dofParams) +PUSH_CONSTANT(FLOAT, noiseOffset) +FRAGMENT_SOURCE("workbench_effect_dof_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_effect_dof_prepare) - .define("PREPARE") - .fragment_out(0, Type::VEC4, "halfResColor") - .fragment_out(1, Type::VEC2, "normalizedCoc") - .additional_info("workbench_effect_dof") - .do_static_compilation(true); +DEFINE("PREPARE") +FRAGMENT_OUT(0, VEC4, halfResColor) +FRAGMENT_OUT(1, VEC2, normalizedCoc) +ADDITIONAL_INFO(workbench_effect_dof) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_effect_dof_downsample) - .define("DOWNSAMPLE") - .fragment_out(0, Type::VEC4, "outColor") - .fragment_out(1, Type::VEC2, "outCocs") - .additional_info("workbench_effect_dof") - .do_static_compilation(true); +DEFINE("DOWNSAMPLE") +FRAGMENT_OUT(0, VEC4, outColor) +FRAGMENT_OUT(1, VEC2, outCocs) +ADDITIONAL_INFO(workbench_effect_dof) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur1) - .define("BLUR1") - .define("NUM_SAMPLES", "49") - .uniform_buf(1, "vec4", "samples[49]") - .fragment_out(0, Type::VEC4, "blurColor") - .additional_info("workbench_effect_dof") - .do_static_compilation(true); +DEFINE("BLUR1") +DEFINE_VALUE("NUM_SAMPLES", "49") +UNIFORM_BUF(1, vec4, samples[49]) +FRAGMENT_OUT(0, VEC4, blurColor) +ADDITIONAL_INFO(workbench_effect_dof) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_effect_dof_blur2) - .define("BLUR2") - .fragment_out(0, Type::VEC4, "finalColor") - .additional_info("workbench_effect_dof") - .do_static_compilation(true); +DEFINE("BLUR2") +FRAGMENT_OUT(0, VEC4, finalColor) +ADDITIONAL_INFO(workbench_effect_dof) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_effect_dof_resolve) - .define("RESOLVE") - .fragment_out(0, Type::VEC4, "finalColorAdd", DualBlend::SRC_0) - .fragment_out(0, Type::VEC4, "finalColorMul", DualBlend::SRC_1) - .additional_info("workbench_effect_dof") - .do_static_compilation(true); +DEFINE("RESOLVE") +FRAGMENT_OUT_DUAL(0, VEC4, finalColorAdd, SRC_0) +FRAGMENT_OUT_DUAL(0, VEC4, finalColorMul, SRC_1) +ADDITIONAL_INFO(workbench_effect_dof) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh index e820dbfd120..39248506eef 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh @@ -5,10 +5,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(workbench_effect_outline) - .typedef_source("workbench_shader_shared.h") - .fragment_source("workbench_effect_outline_frag.glsl") - .sampler(0, ImageType::UINT_2D, "objectIdBuffer") - .uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") - .fragment_out(0, Type::VEC4, "fragColor") - .additional_info("draw_fullscreen") - .do_static_compilation(true); +TYPEDEF_SOURCE("workbench_shader_shared.h") +FRAGMENT_SOURCE("workbench_effect_outline_frag.glsl") +SAMPLER(0, UINT_2D, objectIdBuffer) +UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data) +FRAGMENT_OUT(0, VEC4, fragColor) +ADDITIONAL_INFO(draw_fullscreen) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh index c4408a37264..592361a2b47 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_prepass_info.hh @@ -10,27 +10,31 @@ * \{ */ GPU_SHADER_CREATE_INFO(workbench_mesh) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .vertex_in(2, Type::VEC4, "ac") - .vertex_in(3, Type::VEC2, "au") - .vertex_source("workbench_prepass_vert.glsl") - .additional_info("draw_modelmat_new_with_custom_id", "draw_resource_handle_new"); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +VERTEX_IN(2, VEC4, ac) +VERTEX_IN(3, VEC2, au) +VERTEX_SOURCE("workbench_prepass_vert.glsl") +ADDITIONAL_INFO(draw_modelmat_new_with_custom_id) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_curves) - .sampler(WB_CURVES_COLOR_SLOT, ImageType::FLOAT_BUFFER, "ac", Frequency::BATCH) - .sampler(WB_CURVES_UV_SLOT, ImageType::FLOAT_BUFFER, "au", Frequency::BATCH) - .push_constant(Type::INT, "emitter_object_id") - .vertex_source("workbench_prepass_hair_vert.glsl") - .additional_info("draw_modelmat_new_with_custom_id", - "draw_resource_handle_new", - "draw_hair_new"); +SAMPLER_FREQ(WB_CURVES_COLOR_SLOT, FLOAT_BUFFER, ac, BATCH) +SAMPLER_FREQ(WB_CURVES_UV_SLOT, FLOAT_BUFFER, au, BATCH) +PUSH_CONSTANT(INT, emitter_object_id) +VERTEX_SOURCE("workbench_prepass_hair_vert.glsl") +ADDITIONAL_INFO(draw_modelmat_new_with_custom_id) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_hair_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_pointcloud) - .vertex_source("workbench_prepass_pointcloud_vert.glsl") - .additional_info("draw_modelmat_new_with_custom_id", - "draw_resource_handle_new", - "draw_pointcloud_new"); +VERTEX_SOURCE("workbench_prepass_pointcloud_vert.glsl") +ADDITIONAL_INFO(draw_modelmat_new_with_custom_id) +ADDITIONAL_INFO(draw_resource_handle_new) +ADDITIONAL_INFO(draw_pointcloud_new) +GPU_SHADER_CREATE_END() /** \} */ @@ -38,11 +42,16 @@ GPU_SHADER_CREATE_INFO(workbench_pointcloud) /** \name Lighting Type (only for transparent) * \{ */ -GPU_SHADER_CREATE_INFO(workbench_lighting_flat).define("WORKBENCH_LIGHTING_FLAT"); -GPU_SHADER_CREATE_INFO(workbench_lighting_studio).define("WORKBENCH_LIGHTING_STUDIO"); +GPU_SHADER_CREATE_INFO(workbench_lighting_flat) +DEFINE("WORKBENCH_LIGHTING_FLAT") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(workbench_lighting_studio) +DEFINE("WORKBENCH_LIGHTING_STUDIO") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_lighting_matcap) - .define("WORKBENCH_LIGHTING_MATCAP") - .sampler(WB_MATCAP_SLOT, ImageType::FLOAT_2D_ARRAY, "matcap_tx"); +DEFINE("WORKBENCH_LIGHTING_MATCAP") +SAMPLER(WB_MATCAP_SLOT, FLOAT_2D_ARRAY, matcap_tx) +GPU_SHADER_CREATE_END() /** \} */ @@ -50,38 +59,44 @@ GPU_SHADER_CREATE_INFO(workbench_lighting_matcap) /** \name Material Interface * \{ */ -GPU_SHADER_INTERFACE_INFO(workbench_material_iface, "") - .smooth(Type::VEC3, "normal_interp") - .smooth(Type::VEC3, "color_interp") - .smooth(Type::FLOAT, "alpha_interp") - .smooth(Type::VEC2, "uv_interp") - .flat(Type::INT, "object_id") - .flat(Type::FLOAT, "_roughness") - .flat(Type::FLOAT, "metallic"); +GPU_SHADER_INTERFACE_INFO(workbench_material_iface) +SMOOTH(VEC3, normal_interp) +SMOOTH(VEC3, color_interp) +SMOOTH(FLOAT, alpha_interp) +SMOOTH(VEC2, uv_interp) +FLAT(INT, object_id) +FLAT(FLOAT, _roughness) +FLAT(FLOAT, metallic) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(workbench_color_material) - .define("WORKBENCH_COLOR_MATERIAL") - .storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]"); +DEFINE("WORKBENCH_COLOR_MATERIAL") +STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[]) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_color_texture) - .define("WORKBENCH_COLOR_TEXTURE") - .define("WORKBENCH_TEXTURE_IMAGE_ARRAY") - .define("WORKBENCH_COLOR_MATERIAL") - .storage_buf(WB_MATERIAL_SLOT, Qualifier::READ, "vec4", "materials_data[]") - .sampler(WB_TEXTURE_SLOT, ImageType::FLOAT_2D, "imageTexture", Frequency::BATCH) - .sampler(WB_TILE_ARRAY_SLOT, ImageType::FLOAT_2D_ARRAY, "imageTileArray", Frequency::BATCH) - .sampler(WB_TILE_DATA_SLOT, ImageType::FLOAT_1D_ARRAY, "imageTileData", Frequency::BATCH) - .push_constant(Type::BOOL, "isImageTile") - .push_constant(Type::BOOL, "imagePremult") - .push_constant(Type::FLOAT, "imageTransparencyCutoff"); +DEFINE("WORKBENCH_COLOR_TEXTURE") +DEFINE("WORKBENCH_TEXTURE_IMAGE_ARRAY") +DEFINE("WORKBENCH_COLOR_MATERIAL") +STORAGE_BUF(WB_MATERIAL_SLOT, READ, vec4, materials_data[]) +SAMPLER_FREQ(WB_TEXTURE_SLOT, FLOAT_2D, imageTexture, BATCH) +SAMPLER_FREQ(WB_TILE_ARRAY_SLOT, FLOAT_2D_ARRAY, imageTileArray, BATCH) +SAMPLER_FREQ(WB_TILE_DATA_SLOT, FLOAT_1D_ARRAY, imageTileData, BATCH) +PUSH_CONSTANT(BOOL, isImageTile) +PUSH_CONSTANT(BOOL, imagePremult) +PUSH_CONSTANT(FLOAT, imageTransparencyCutoff) +GPU_SHADER_CREATE_END() -GPU_SHADER_CREATE_INFO(workbench_color_vertex).define("WORKBENCH_COLOR_VERTEX"); +GPU_SHADER_CREATE_INFO(workbench_color_vertex) +DEFINE("WORKBENCH_COLOR_VERTEX") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_prepass) - .define("WORKBENCH_NEXT") - .uniform_buf(WB_WORLD_SLOT, "WorldData", "world_data") - .vertex_out(workbench_material_iface) - .additional_info("draw_view"); +DEFINE("WORKBENCH_NEXT") +UNIFORM_BUF(WB_WORLD_SLOT, WorldData, world_data) +VERTEX_OUT(workbench_material_iface) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /** \} */ @@ -90,21 +105,23 @@ GPU_SHADER_CREATE_INFO(workbench_prepass) * \{ */ GPU_SHADER_CREATE_INFO(workbench_transparent_accum) - /* NOTE: Blending will be skipped on objectId because output is a - * non-normalized integer buffer. */ - .fragment_out(0, Type::VEC4, "out_transparent_accum") - .fragment_out(1, Type::VEC4, "out_revealage_accum") - .fragment_out(2, Type::UINT, "out_object_id") - .push_constant(Type::BOOL, "forceShadowing") - .typedef_source("workbench_shader_shared.h") - .fragment_source("workbench_transparent_accum_frag.glsl"); +/* NOTE: Blending will be skipped on objectId because output is a + * non-normalized integer buffer. */ +FRAGMENT_OUT(0, VEC4, out_transparent_accum) +FRAGMENT_OUT(1, VEC4, out_revealage_accum) +FRAGMENT_OUT(2, UINT, out_object_id) +PUSH_CONSTANT(BOOL, forceShadowing) +TYPEDEF_SOURCE("workbench_shader_shared.h") +FRAGMENT_SOURCE("workbench_transparent_accum_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_opaque) - .fragment_out(0, Type::VEC4, "out_material") - .fragment_out(1, Type::VEC2, "out_normal") - .fragment_out(2, Type::UINT, "out_object_id") - .typedef_source("workbench_shader_shared.h") - .fragment_source("workbench_prepass_frag.glsl"); +FRAGMENT_OUT(0, VEC4, out_material) +FRAGMENT_OUT(1, VEC2, out_normal) +FRAGMENT_OUT(2, UINT, out_object_id) +TYPEDEF_SOURCE("workbench_shader_shared.h") +FRAGMENT_SOURCE("workbench_prepass_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -112,37 +129,40 @@ GPU_SHADER_CREATE_INFO(workbench_opaque) /** \name Variations Declaration * \{ */ -GPU_SHADER_CREATE_INFO(workbench_flat).define("WORKBENCH_SHADING_FLAT"); -GPU_SHADER_CREATE_INFO(workbench_studio).define("WORKBENCH_SHADING_STUDIO"); -GPU_SHADER_CREATE_INFO(workbench_matcap).define("WORKBENCH_SHADING_MATCAP"); - -#define WORKBENCH_FINAL_VARIATION(name, ...) \ - GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); +GPU_SHADER_CREATE_INFO(workbench_flat) +DEFINE("WORKBENCH_SHADING_FLAT") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(workbench_studio) +DEFINE("WORKBENCH_SHADING_STUDIO") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(workbench_matcap) +DEFINE("WORKBENCH_SHADING_MATCAP") +GPU_SHADER_CREATE_END() #define WORKBENCH_CLIPPING_VARIATIONS(prefix, ...) \ - WORKBENCH_FINAL_VARIATION(prefix##_clip, "drw_clipped", __VA_ARGS__) \ - WORKBENCH_FINAL_VARIATION(prefix##_no_clip, __VA_ARGS__) + CREATE_INFO_VARIANT(prefix##_clip, drw_clipped, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_no_clip, __VA_ARGS__) #define WORKBENCH_COLOR_VARIATIONS(prefix, ...) \ - WORKBENCH_CLIPPING_VARIATIONS(prefix##_material, "workbench_color_material", __VA_ARGS__) \ - WORKBENCH_CLIPPING_VARIATIONS(prefix##_texture, "workbench_color_texture", __VA_ARGS__) \ - WORKBENCH_CLIPPING_VARIATIONS(prefix##_vertex, "workbench_color_vertex", __VA_ARGS__) + WORKBENCH_CLIPPING_VARIATIONS(prefix##_material, workbench_color_material, __VA_ARGS__) \ + WORKBENCH_CLIPPING_VARIATIONS(prefix##_texture, workbench_color_texture, __VA_ARGS__) \ + WORKBENCH_CLIPPING_VARIATIONS(prefix##_vertex, workbench_color_vertex, __VA_ARGS__) #define WORKBENCH_SHADING_VARIATIONS(prefix, ...) \ - WORKBENCH_COLOR_VARIATIONS(prefix##_flat, "workbench_lighting_flat", __VA_ARGS__) \ - WORKBENCH_COLOR_VARIATIONS(prefix##_studio, "workbench_lighting_studio", __VA_ARGS__) \ - WORKBENCH_COLOR_VARIATIONS(prefix##_matcap, "workbench_lighting_matcap", __VA_ARGS__) + WORKBENCH_COLOR_VARIATIONS(prefix##_flat, workbench_lighting_flat, __VA_ARGS__) \ + WORKBENCH_COLOR_VARIATIONS(prefix##_studio, workbench_lighting_studio, __VA_ARGS__) \ + WORKBENCH_COLOR_VARIATIONS(prefix##_matcap, workbench_lighting_matcap, __VA_ARGS__) #define WORKBENCH_PIPELINE_VARIATIONS(prefix, ...) \ - WORKBENCH_SHADING_VARIATIONS(prefix##_transparent, "workbench_transparent_accum", __VA_ARGS__) \ - WORKBENCH_SHADING_VARIATIONS(prefix##_opaque, "workbench_opaque", __VA_ARGS__) + WORKBENCH_SHADING_VARIATIONS(prefix##_transparent, workbench_transparent_accum, __VA_ARGS__) \ + WORKBENCH_SHADING_VARIATIONS(prefix##_opaque, workbench_opaque, __VA_ARGS__) #define WORKBENCH_GEOMETRY_VARIATIONS(prefix, ...) \ - WORKBENCH_PIPELINE_VARIATIONS(prefix##_mesh, "workbench_mesh", __VA_ARGS__) \ - WORKBENCH_PIPELINE_VARIATIONS(prefix##_curves, "workbench_curves", __VA_ARGS__) \ - WORKBENCH_PIPELINE_VARIATIONS(prefix##_ptcloud, "workbench_pointcloud", __VA_ARGS__) + WORKBENCH_PIPELINE_VARIATIONS(prefix##_mesh, workbench_mesh, __VA_ARGS__) \ + WORKBENCH_PIPELINE_VARIATIONS(prefix##_curves, workbench_curves, __VA_ARGS__) \ + WORKBENCH_PIPELINE_VARIATIONS(prefix##_ptcloud, workbench_pointcloud, __VA_ARGS__) -WORKBENCH_GEOMETRY_VARIATIONS(workbench_prepass, "workbench_prepass"); +WORKBENCH_GEOMETRY_VARIATIONS(workbench_prepass, workbench_prepass) #undef WORKBENCH_FINAL_VARIATION #undef WORKBENCH_CLIPPING_VARIATIONS diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index 7494bb46c73..0606d621b7f 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -11,41 +11,46 @@ * \{ */ GPU_SHADER_CREATE_INFO(workbench_shadow_common) - .storage_buf(3, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY) - /* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */ - .push_constant(Type::IVEC2, "gpu_attr_3") - .uniform_buf(1, "ShadowPassData", "pass_data") - .typedef_source("workbench_shader_shared.h") - .additional_info("gpu_index_load") - .additional_info("draw_view") - .additional_info("draw_modelmat_new") - .additional_info("draw_resource_handle_new"); +STORAGE_BUF_FREQ(3, READ, float, pos[], GEOMETRY) +/* WORKAROUND: Needed to support OpenSubdiv vertex format. Should be removed. */ +PUSH_CONSTANT(IVEC2, gpu_attr_3) +UNIFORM_BUF(1, ShadowPassData, pass_data) +TYPEDEF_SOURCE("workbench_shader_shared.h") +ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_common) - .local_group_size(DRW_VISIBILITY_GROUP_SIZE) - .define("DRW_VIEW_LEN", "64") - .storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .uniform_buf(2, "ExtrudedFrustum", "extruded_frustum") - .push_constant(Type::INT, "resource_len") - .push_constant(Type::INT, "view_len") - .push_constant(Type::INT, "visibility_word_per_draw") - .push_constant(Type::BOOL, "force_fail_method") - .push_constant(Type::VEC3, "shadow_direction") - .typedef_source("workbench_shader_shared.h") - .compute_source("workbench_shadow_visibility_comp.glsl") - .additional_info("draw_view", "draw_view_culling"); +LOCAL_GROUP_SIZE(DRW_VISIBILITY_GROUP_SIZE) +DEFINE_VALUE("DRW_VIEW_LEN", "64") +STORAGE_BUF(0, READ, ObjectBounds, bounds_buf[]) +UNIFORM_BUF(2, ExtrudedFrustum, extruded_frustum) +PUSH_CONSTANT(INT, resource_len) +PUSH_CONSTANT(INT, view_len) +PUSH_CONSTANT(INT, visibility_word_per_draw) +PUSH_CONSTANT(BOOL, force_fail_method) +PUSH_CONSTANT(VEC3, shadow_direction) +TYPEDEF_SOURCE("workbench_shader_shared.h") +COMPUTE_SOURCE("workbench_shadow_visibility_comp.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_dynamic_pass_type) - .additional_info("workbench_shadow_visibility_compute_common") - .define("DYNAMIC_PASS_SELECTION") - .storage_buf(1, Qualifier::READ_WRITE, "uint", "pass_visibility_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "uint", "fail_visibility_buf[]") - .do_static_compilation(true); +ADDITIONAL_INFO(workbench_shadow_visibility_compute_common) +DEFINE("DYNAMIC_PASS_SELECTION") +STORAGE_BUF(1, READ_WRITE, uint, pass_visibility_buf[]) +STORAGE_BUF(2, READ_WRITE, uint, fail_visibility_buf[]) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_static_pass_type) - .additional_info("workbench_shadow_visibility_compute_common") - .storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") - .do_static_compilation(true); +ADDITIONAL_INFO(workbench_shadow_visibility_compute_common) +STORAGE_BUF(1, READ_WRITE, uint, visibility_buf[]) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /** \} */ @@ -54,11 +59,13 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_visibility_compute_static_pass_type) * \{ */ GPU_SHADER_CREATE_INFO(workbench_shadow_no_debug) - .fragment_source("gpu_shader_depth_only_frag.glsl"); +FRAGMENT_SOURCE("gpu_shader_depth_only_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_shadow_debug) - .fragment_out(0, Type::VEC4, "out_debug_color") - .fragment_source("workbench_shadow_debug_frag.glsl"); +FRAGMENT_OUT(0, VEC4, out_debug_color) +FRAGMENT_SOURCE("workbench_shadow_debug_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -68,47 +75,55 @@ GPU_SHADER_CREATE_INFO(workbench_shadow_debug) #define WORKBENCH_SHADOW_VARIATIONS(common, prefix, suffix, ...) \ GPU_SHADER_CREATE_INFO(prefix##_pass_manifold_no_caps##suffix) \ - .define("SHADOW_PASS") \ - .vertex_source("workbench_shadow_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); \ + DEFINE("SHADOW_PASS") \ + VERTEX_SOURCE("workbench_shadow_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() \ +\ GPU_SHADER_CREATE_INFO(prefix##_pass_no_manifold_no_caps##suffix) \ - .define("SHADOW_PASS") \ - .define("DOUBLE_MANIFOLD") \ - .vertex_source("workbench_shadow_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); \ + DEFINE("SHADOW_PASS") \ + DEFINE("DOUBLE_MANIFOLD") \ + VERTEX_SOURCE("workbench_shadow_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() \ +\ GPU_SHADER_CREATE_INFO(prefix##_fail_manifold_caps##suffix) \ - .define("SHADOW_FAIL") \ - .vertex_source("workbench_shadow_caps_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); \ + DEFINE("SHADOW_FAIL") \ + VERTEX_SOURCE("workbench_shadow_caps_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() \ +\ GPU_SHADER_CREATE_INFO(prefix##_fail_manifold_no_caps##suffix) \ - .define("SHADOW_FAIL") \ - .vertex_source("workbench_shadow_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); \ + DEFINE("SHADOW_FAIL") \ + VERTEX_SOURCE("workbench_shadow_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() \ +\ GPU_SHADER_CREATE_INFO(prefix##_fail_no_manifold_caps##suffix) \ - .define("SHADOW_FAIL") \ - .define("DOUBLE_MANIFOLD") \ - .vertex_source("workbench_shadow_caps_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); \ + DEFINE("SHADOW_FAIL") \ + DEFINE("DOUBLE_MANIFOLD") \ + VERTEX_SOURCE("workbench_shadow_caps_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() \ +\ GPU_SHADER_CREATE_INFO(prefix##_fail_no_manifold_no_caps##suffix) \ - .define("SHADOW_FAIL") \ - .define("DOUBLE_MANIFOLD") \ - .vertex_source("workbench_shadow_vert.glsl") \ - .additional_info(common, __VA_ARGS__) \ - .do_static_compilation(true); + DEFINE("SHADOW_FAIL") \ + DEFINE("DOUBLE_MANIFOLD") \ + VERTEX_SOURCE("workbench_shadow_vert.glsl") \ + ADDITIONAL_INFO_EXPAND(common, __VA_ARGS__) \ + DO_STATIC_COMPILATION() \ + GPU_SHADER_CREATE_END() -WORKBENCH_SHADOW_VARIATIONS("workbench_shadow_common", - workbench_shadow, - , - "workbench_shadow_no_debug") +WORKBENCH_SHADOW_VARIATIONS(workbench_shadow_common, workbench_shadow, , workbench_shadow_no_debug) -WORKBENCH_SHADOW_VARIATIONS("workbench_shadow_common", +WORKBENCH_SHADOW_VARIATIONS(workbench_shadow_common, workbench_shadow, _debug, - "workbench_shadow_debug") + workbench_shadow_debug) /** \} */ diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_transparent_resolve_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_transparent_resolve_info.hh index 94cffe3fc4c..bef6beb997c 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_transparent_resolve_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_transparent_resolve_info.hh @@ -5,9 +5,10 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(workbench_transparent_resolve) - .fragment_out(0, Type::VEC4, "fragColor") - .sampler(0, ImageType::FLOAT_2D, "transparentAccum") - .sampler(1, ImageType::FLOAT_2D, "transparentRevealage") - .fragment_source("workbench_transparent_resolve_frag.glsl") - .additional_info("draw_fullscreen") - .do_static_compilation(true); +FRAGMENT_OUT(0, VEC4, fragColor) +SAMPLER(0, FLOAT_2D, transparentAccum) +SAMPLER(1, FLOAT_2D, transparentRevealage) +FRAGMENT_SOURCE("workbench_transparent_resolve_frag.glsl") +ADDITIONAL_INFO(draw_fullscreen) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_volume_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_volume_info.hh index bf367c9828b..9b3272d177c 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_volume_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_volume_info.hh @@ -9,22 +9,26 @@ * \{ */ GPU_SHADER_CREATE_INFO(workbench_volume_common) - .vertex_in(0, Type::VEC3, "pos") - .fragment_out(0, Type::VEC4, "fragColor") - .sampler(0, ImageType::DEPTH_2D, "depthBuffer") - .sampler(1, ImageType::FLOAT_3D, "densityTexture") - .push_constant(Type::INT, "samplesLen") - .push_constant(Type::FLOAT, "noiseOfs") - .push_constant(Type::FLOAT, "stepLength") - .push_constant(Type::FLOAT, "densityScale") - .push_constant(Type::BOOL, "do_depth_test") - .vertex_source("workbench_volume_vert.glsl") - .fragment_source("workbench_volume_frag.glsl"); +VERTEX_IN(0, VEC3, pos) +FRAGMENT_OUT(0, VEC4, fragColor) +SAMPLER(0, DEPTH_2D, depthBuffer) +SAMPLER(1, FLOAT_3D, densityTexture) +PUSH_CONSTANT(INT, samplesLen) +PUSH_CONSTANT(FLOAT, noiseOfs) +PUSH_CONSTANT(FLOAT, stepLength) +PUSH_CONSTANT(FLOAT, densityScale) +PUSH_CONSTANT(BOOL, do_depth_test) +VERTEX_SOURCE("workbench_volume_vert.glsl") +FRAGMENT_SOURCE("workbench_volume_frag.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_volume) - .define("WORKBENCH_NEXT") - .sampler(6, ImageType::UINT_2D, "stencil_tx") - .additional_info("workbench_volume_common", "draw_object_infos_new", "draw_view"); +DEFINE("WORKBENCH_NEXT") +SAMPLER(6, UINT_2D, stencil_tx) +ADDITIONAL_INFO(workbench_volume_common) +ADDITIONAL_INFO(draw_object_infos_new) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /** \} */ /* -------------------------------------------------------------------- */ @@ -32,23 +36,29 @@ GPU_SHADER_CREATE_INFO(workbench_volume) * \{ */ GPU_SHADER_CREATE_INFO(workbench_volume_smoke_common) - .define("VOLUME_SMOKE") - .sampler(2, ImageType::FLOAT_3D, "flameTexture") - .sampler(3, ImageType::FLOAT_1D, "flameColorTexture") - .additional_info("draw_resource_id_varying"); +DEFINE("VOLUME_SMOKE") +SAMPLER(2, FLOAT_3D, flameTexture) +SAMPLER(3, FLOAT_1D, flameColorTexture) +ADDITIONAL_INFO(draw_resource_id_varying) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_volume_object_common) - .define("VOLUME_OBJECT") - .push_constant(Type::MAT4, "volumeTextureToObject") - /* FIXME(fclem): This overflow the push_constant limit. */ - .push_constant(Type::MAT4, "volumeObjectToTexture") - .additional_info("draw_resource_id_varying"); +DEFINE("VOLUME_OBJECT") +PUSH_CONSTANT(MAT4, volumeTextureToObject) +/* FIXME(fclem): This overflow the push_constant limit. */ +PUSH_CONSTANT(MAT4, volumeObjectToTexture) +ADDITIONAL_INFO(draw_resource_id_varying) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_volume_smoke) - .additional_info("workbench_volume_smoke_common", "draw_modelmat_new"); +ADDITIONAL_INFO(workbench_volume_smoke_common) +ADDITIONAL_INFO(draw_modelmat_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_volume_object) - .additional_info("workbench_volume_object_common", "draw_volume_new"); +ADDITIONAL_INFO(workbench_volume_object_common) +ADDITIONAL_INFO(draw_volume_new) +GPU_SHADER_CREATE_END() /** \} */ @@ -57,17 +67,19 @@ GPU_SHADER_CREATE_INFO(workbench_volume_object) * \{ */ GPU_SHADER_CREATE_INFO(workbench_volume_coba) - .define("USE_COBA") - .sampler(4, ImageType::UINT_3D, "flagTexture") - .sampler(5, ImageType::FLOAT_1D, "transferTexture") - .push_constant(Type::BOOL, "showPhi") - .push_constant(Type::BOOL, "showFlags") - .push_constant(Type::BOOL, "showPressure") - .push_constant(Type::FLOAT, "gridScale"); +DEFINE("USE_COBA") +SAMPLER(4, UINT_3D, flagTexture) +SAMPLER(5, FLOAT_1D, transferTexture) +PUSH_CONSTANT(BOOL, showPhi) +PUSH_CONSTANT(BOOL, showFlags) +PUSH_CONSTANT(BOOL, showPressure) +PUSH_CONSTANT(FLOAT, gridScale) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(workbench_volume_no_coba) - .sampler(4, ImageType::FLOAT_3D, "shadowTexture") - .push_constant(Type::VEC3, "activeColor"); +SAMPLER(4, FLOAT_3D, shadowTexture) +PUSH_CONSTANT(VEC3, activeColor) +GPU_SHADER_CREATE_END() /** \} */ @@ -75,9 +87,15 @@ GPU_SHADER_CREATE_INFO(workbench_volume_no_coba) /** \name Sampling variation * \{ */ -GPU_SHADER_CREATE_INFO(workbench_volume_linear).define("USE_TRILINEAR"); -GPU_SHADER_CREATE_INFO(workbench_volume_cubic).define("USE_TRICUBIC"); -GPU_SHADER_CREATE_INFO(workbench_volume_closest).define("USE_CLOSEST"); +GPU_SHADER_CREATE_INFO(workbench_volume_linear) +DEFINE("USE_TRILINEAR") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(workbench_volume_cubic) +DEFINE("USE_TRICUBIC") +GPU_SHADER_CREATE_END() +GPU_SHADER_CREATE_INFO(workbench_volume_closest) +DEFINE("USE_CLOSEST") +GPU_SHADER_CREATE_END() /** \} */ @@ -85,14 +103,17 @@ GPU_SHADER_CREATE_INFO(workbench_volume_closest).define("USE_CLOSEST"); /** \name Slice variation * \{ */ -GPU_SHADER_INTERFACE_INFO(workbench_volume_iface, "").smooth(Type::VEC3, "localPos"); +GPU_SHADER_INTERFACE_INFO(workbench_volume_iface) +SMOOTH(VEC3, localPos) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(workbench_volume_slice) - .define("VOLUME_SLICE") - .vertex_in(1, Type::VEC3, "uvs") - .vertex_out(workbench_volume_iface) - .push_constant(Type::INT, "sliceAxis") /* -1 is no slice. */ - .push_constant(Type::FLOAT, "slicePosition"); +DEFINE("VOLUME_SLICE") +VERTEX_IN(1, VEC3, uvs) +VERTEX_OUT(workbench_volume_iface) +PUSH_CONSTANT(INT, sliceAxis) /* -1 is no slice. */ +PUSH_CONSTANT(FLOAT, slicePosition) +GPU_SHADER_CREATE_END() /** \} */ @@ -101,26 +122,22 @@ GPU_SHADER_CREATE_INFO(workbench_volume_slice) * \{ */ #define WORKBENCH_VOLUME_SLICE_VARIATIONS(prefix, ...) \ - GPU_SHADER_CREATE_INFO(prefix##_slice) \ - .additional_info("workbench_volume_slice", __VA_ARGS__) \ - .do_static_compilation(true); \ - GPU_SHADER_CREATE_INFO(prefix##_no_slice) \ - .additional_info(__VA_ARGS__) \ - .do_static_compilation(true); + CREATE_INFO_VARIANT(prefix##_slice, workbench_volume_slice, __VA_ARGS__) \ + CREATE_INFO_VARIANT(prefix##_no_slice, __VA_ARGS__) #define WORKBENCH_VOLUME_COBA_VARIATIONS(prefix, ...) \ - WORKBENCH_VOLUME_SLICE_VARIATIONS(prefix##_coba, "workbench_volume_coba", __VA_ARGS__) \ - WORKBENCH_VOLUME_SLICE_VARIATIONS(prefix##_no_coba, "workbench_volume_no_coba", __VA_ARGS__) + WORKBENCH_VOLUME_SLICE_VARIATIONS(prefix##_coba, workbench_volume_coba, __VA_ARGS__) \ + WORKBENCH_VOLUME_SLICE_VARIATIONS(prefix##_no_coba, workbench_volume_no_coba, __VA_ARGS__) #define WORKBENCH_VOLUME_INTERP_VARIATIONS(prefix, ...) \ - WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_linear, "workbench_volume_linear", __VA_ARGS__) \ - WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_cubic, "workbench_volume_cubic", __VA_ARGS__) \ - WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_closest, "workbench_volume_closest", __VA_ARGS__) + WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_linear, workbench_volume_linear, __VA_ARGS__) \ + WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_cubic, workbench_volume_cubic, __VA_ARGS__) \ + WORKBENCH_VOLUME_COBA_VARIATIONS(prefix##_closest, workbench_volume_closest, __VA_ARGS__) #define WORKBENCH_VOLUME_SMOKE_VARIATIONS(prefix, ...) \ - WORKBENCH_VOLUME_INTERP_VARIATIONS(prefix##_smoke, "workbench_volume_smoke", __VA_ARGS__) \ - WORKBENCH_VOLUME_INTERP_VARIATIONS(prefix##_object, "workbench_volume_object", __VA_ARGS__) + WORKBENCH_VOLUME_INTERP_VARIATIONS(prefix##_smoke, workbench_volume_smoke, __VA_ARGS__) \ + WORKBENCH_VOLUME_INTERP_VARIATIONS(prefix##_object, workbench_volume_object, __VA_ARGS__) -WORKBENCH_VOLUME_SMOKE_VARIATIONS(workbench_volume, "workbench_volume") +WORKBENCH_VOLUME_SMOKE_VARIATIONS(workbench_volume, workbench_volume) /** \} */ diff --git a/source/blender/draw/intern/draw_shader_shared.hh b/source/blender/draw/intern/draw_shader_shared.hh index 6203c06984d..3eb2243c145 100644 --- a/source/blender/draw/intern/draw_shader_shared.hh +++ b/source/blender/draw/intern/draw_shader_shared.hh @@ -59,7 +59,7 @@ struct ObjectRef; /** \name Views * \{ */ -#ifndef DRW_VIEW_LEN +#if !defined(DRW_VIEW_LEN) && !defined(GLSL_CPP_STUBS) /* Single-view case (default). */ # define drw_view_id 0 # define DRW_VIEW_LEN 1 diff --git a/source/blender/draw/intern/shaders/draw_debug_info.hh b/source/blender/draw/intern/shaders/draw_debug_info.hh index 64684c770f1..454f42c0724 100644 --- a/source/blender/draw/intern/shaders/draw_debug_info.hh +++ b/source/blender/draw/intern/shaders/draw_debug_info.hh @@ -12,21 +12,25 @@ * \{ */ GPU_SHADER_CREATE_INFO(draw_debug_print) - .define("DRW_DEBUG_PRINT") - .typedef_source("draw_shader_shared.hh") - .storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ_WRITE, "uint", "drw_debug_print_buf[]"); +DEFINE("DRW_DEBUG_PRINT") +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(DRW_DEBUG_PRINT_SLOT, READ_WRITE, uint, drw_debug_print_buf[]) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface, "").flat(Type::UINT, "char_index"); +GPU_SHADER_INTERFACE_INFO(draw_debug_print_display_iface) +FLAT(UINT, char_index) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(draw_debug_print_display) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .storage_buf(DRW_DEBUG_PRINT_SLOT, Qualifier::READ, "uint", "drw_debug_print_buf[]") - .vertex_out(draw_debug_print_display_iface) - .fragment_out(0, Type::VEC4, "out_color") - .push_constant(Type::VEC2, "viewport_size") - .vertex_source("draw_debug_print_display_vert.glsl") - .fragment_source("draw_debug_print_display_frag.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(DRW_DEBUG_PRINT_SLOT, READ, uint, drw_debug_print_buf[]) +VERTEX_OUT(draw_debug_print_display_iface) +FRAGMENT_OUT(0, VEC4, out_color) +PUSH_CONSTANT(VEC2, viewport_size) +VERTEX_SOURCE("draw_debug_print_display_vert.glsl") +FRAGMENT_SOURCE("draw_debug_print_display_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -37,23 +41,24 @@ GPU_SHADER_CREATE_INFO(draw_debug_print_display) * \{ */ GPU_SHADER_CREATE_INFO(draw_debug_draw) - .define("DRW_DEBUG_DRAW") - .typedef_source("draw_shader_shared.hh") - .storage_buf(DRW_DEBUG_DRAW_SLOT, - Qualifier::READ_WRITE, - "DRWDebugVert", - "drw_debug_verts_buf[]"); +DEFINE("DRW_DEBUG_DRAW") +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(DRW_DEBUG_DRAW_SLOT, READ_WRITE, DRWDebugVert, drw_debug_verts_buf[]) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(draw_debug_draw_display_iface, "interp").flat(Type::VEC4, "color"); +GPU_SHADER_NAMED_INTERFACE_INFO(draw_debug_draw_display_iface, interp) +FLAT(VEC4, color) +GPU_SHADER_NAMED_INTERFACE_END(interp) GPU_SHADER_CREATE_INFO(draw_debug_draw_display) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .storage_buf(DRW_DEBUG_DRAW_SLOT, Qualifier::READ, "DRWDebugVert", "drw_debug_verts_buf[]") - .vertex_out(draw_debug_draw_display_iface) - .fragment_out(0, Type::VEC4, "out_color") - .push_constant(Type::MAT4, "persmat") - .vertex_source("draw_debug_draw_display_vert.glsl") - .fragment_source("draw_debug_draw_display_frag.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(DRW_DEBUG_DRAW_SLOT, READ, DRWDebugVert, drw_debug_verts_buf[]) +VERTEX_OUT(draw_debug_draw_display_iface) +FRAGMENT_OUT(0, VEC4, out_color) +PUSH_CONSTANT(MAT4, persmat) +VERTEX_SOURCE("draw_debug_draw_display_vert.glsl") +FRAGMENT_SOURCE("draw_debug_draw_display_frag.glsl") +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/intern/shaders/draw_fullscreen_info.hh b/source/blender/draw/intern/shaders/draw_fullscreen_info.hh index a78192b568e..e117f80c2b5 100644 --- a/source/blender/draw/intern/shaders/draw_fullscreen_info.hh +++ b/source/blender/draw/intern/shaders/draw_fullscreen_info.hh @@ -4,8 +4,11 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(fullscreen_iface, "").smooth(Type::VEC4, "uvcoordsvar"); +GPU_SHADER_INTERFACE_INFO(fullscreen_iface) +SMOOTH(VEC4, uvcoordsvar) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(draw_fullscreen) - .vertex_out(fullscreen_iface) - .vertex_source("common_fullscreen_vert.glsl"); +VERTEX_OUT(fullscreen_iface) +VERTEX_SOURCE("common_fullscreen_vert.glsl") +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/intern/shaders/draw_hair_refine_info.hh b/source/blender/draw/intern/shaders/draw_hair_refine_info.hh index 81d0b6ab1ae..d6b7afd1fd2 100644 --- a/source/blender/draw/intern/shaders/draw_hair_refine_info.hh +++ b/source/blender/draw/intern/shaders/draw_hair_refine_info.hh @@ -9,21 +9,22 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(draw_hair_refine_compute) - .local_group_size(1, 1) - .storage_buf(0, Qualifier::WRITE, "vec4", "posTime[]") - .sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer") - .sampler(1, ImageType::UINT_BUFFER, "hairStrandBuffer") - .sampler(2, ImageType::UINT_BUFFER, "hairStrandSegBuffer") - .push_constant(Type::MAT4, "hairDupliMatrix") - .push_constant(Type::BOOL, "hairCloseTip") - .push_constant(Type::FLOAT, "hairRadShape") - .push_constant(Type::FLOAT, "hairRadTip") - .push_constant(Type::FLOAT, "hairRadRoot") - .push_constant(Type::INT, "hairThicknessRes") - .push_constant(Type::INT, "hairStrandsRes") - .push_constant(Type::INT, "hairStrandOffset") - .compute_source("common_hair_refine_comp.glsl") - .define("HAIR_PHASE_SUBDIV") - .define("HAIR_SHADER") - .define("DRW_HAIR_INFO") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1, 1) +STORAGE_BUF(0, WRITE, vec4, posTime[]) +SAMPLER(0, FLOAT_BUFFER, hairPointBuffer) +SAMPLER(1, UINT_BUFFER, hairStrandBuffer) +SAMPLER(2, UINT_BUFFER, hairStrandSegBuffer) +PUSH_CONSTANT(MAT4, hairDupliMatrix) +PUSH_CONSTANT(BOOL, hairCloseTip) +PUSH_CONSTANT(FLOAT, hairRadShape) +PUSH_CONSTANT(FLOAT, hairRadTip) +PUSH_CONSTANT(FLOAT, hairRadRoot) +PUSH_CONSTANT(INT, hairThicknessRes) +PUSH_CONSTANT(INT, hairStrandsRes) +PUSH_CONSTANT(INT, hairStrandOffset) +COMPUTE_SOURCE("common_hair_refine_comp.glsl") +DEFINE("HAIR_PHASE_SUBDIV") +DEFINE("HAIR_SHADER") +DEFINE("DRW_HAIR_INFO") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/intern/shaders/draw_object_infos_info.hh b/source/blender/draw/intern/shaders/draw_object_infos_info.hh index 91497b459b3..38d0dc9cde0 100644 --- a/source/blender/draw/intern/shaders/draw_object_infos_info.hh +++ b/source/blender/draw/intern/shaders/draw_object_infos_info.hh @@ -6,46 +6,49 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(draw_object_infos) - .typedef_source("draw_shader_shared.hh") - .define("OBINFO_LIB") - .define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") - .define("ObjectInfo", "(drw_infos[resource_id].infos)") - .define("ObjectColor", "(drw_infos[resource_id].ob_color)") - .uniform_buf(DRW_OBJ_INFOS_UBO_SLOT, - "ObjectInfos", - "drw_infos[DRW_RESOURCE_CHUNK_LEN]", - Frequency::BATCH); +TYPEDEF_SOURCE("draw_shader_shared.hh") +DEFINE("OBINFO_LIB") +DEFINE_VALUE("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") +DEFINE_VALUE("ObjectInfo", "(drw_infos[resource_id].infos)") +DEFINE_VALUE("ObjectColor", "(drw_infos[resource_id].ob_color)") +UNIFORM_BUF_FREQ(DRW_OBJ_INFOS_UBO_SLOT, ObjectInfos, drw_infos[DRW_RESOURCE_CHUNK_LEN], BATCH) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_volume_infos) - .typedef_source("draw_shader_shared.hh") - .define("VOLUME_INFO_LIB") - .uniform_buf(DRW_OBJ_DATA_INFO_UBO_SLOT, "VolumeInfos", "drw_volume", Frequency::BATCH); +TYPEDEF_SOURCE("draw_shader_shared.hh") +DEFINE("VOLUME_INFO_LIB") +UNIFORM_BUF_FREQ(DRW_OBJ_DATA_INFO_UBO_SLOT, VolumeInfos, drw_volume, BATCH) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_curves_infos) - .typedef_source("draw_shader_shared.hh") - .uniform_buf(DRW_OBJ_DATA_INFO_UBO_SLOT, "CurvesInfos", "drw_curves", Frequency::BATCH); +TYPEDEF_SOURCE("draw_shader_shared.hh") +UNIFORM_BUF_FREQ(DRW_OBJ_DATA_INFO_UBO_SLOT, CurvesInfos, drw_curves, BATCH) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_layer_attributes) - .typedef_source("draw_shader_shared.hh") - .define("VLATTR_LIB") - .uniform_buf(DRW_LAYER_ATTR_UBO_SLOT, - "LayerAttribute", - "drw_layer_attrs[DRW_RESOURCE_CHUNK_LEN]", - Frequency::BATCH); +TYPEDEF_SOURCE("draw_shader_shared.hh") +DEFINE("VLATTR_LIB") +UNIFORM_BUF_FREQ(DRW_LAYER_ATTR_UBO_SLOT, + LayerAttribute, + drw_layer_attrs[DRW_RESOURCE_CHUNK_LEN], + BATCH) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_object_infos_new) - .typedef_source("draw_shader_shared.hh") - .define("OBINFO_LIB") - .define("OBINFO_NEW") - .define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") - .define("ObjectInfo", "(drw_infos[resource_id].infos)") - .define("ObjectColor", "(drw_infos[resource_id].ob_color)") - .storage_buf(DRW_OBJ_INFOS_SLOT, Qualifier::READ, "ObjectInfos", "drw_infos[]"); +TYPEDEF_SOURCE("draw_shader_shared.hh") +DEFINE("OBINFO_LIB") +DEFINE("OBINFO_NEW") +DEFINE_VALUE("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)") +DEFINE_VALUE("ObjectInfo", "(drw_infos[resource_id].infos)") +DEFINE_VALUE("ObjectColor", "(drw_infos[resource_id].ob_color)") +STORAGE_BUF(DRW_OBJ_INFOS_SLOT, READ, ObjectInfos, drw_infos[]) +GPU_SHADER_CREATE_END() /** \note Requires draw_object_infos_new. */ GPU_SHADER_CREATE_INFO(draw_object_attribute_new) - .define("OBATTR_LIB") - .define("ObjectAttributeStart", "(drw_infos[resource_id].orco_mul_bias[0].w)") - .define("ObjectAttributeLen", "(drw_infos[resource_id].orco_mul_bias[1].w)") - .storage_buf(DRW_OBJ_ATTR_SLOT, Qualifier::READ, "ObjectAttribute", "drw_attrs[]") - .additional_info("draw_object_infos_new"); +DEFINE("OBATTR_LIB") +DEFINE_VALUE("ObjectAttributeStart", "(drw_infos[resource_id].orco_mul_bias[0].w)") +DEFINE_VALUE("ObjectAttributeLen", "(drw_infos[resource_id].orco_mul_bias[1].w)") +STORAGE_BUF(DRW_OBJ_ATTR_SLOT, READ, ObjectAttribute, drw_attrs[]) +ADDITIONAL_INFO(draw_object_infos_new) +GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/intern/shaders/draw_view_info.hh b/source/blender/draw/intern/shaders/draw_view_info.hh index ac9a5e5c696..ed06cdda886 100644 --- a/source/blender/draw/intern/shaders/draw_view_info.hh +++ b/source/blender/draw/intern/shaders/draw_view_info.hh @@ -14,31 +14,37 @@ * \{ */ /* Standard way. Use gpu_InstanceIndex to index the object data. */ -GPU_SHADER_CREATE_INFO(draw_resource_id).define("DYNAMIC_RESOURCE_ID"); +GPU_SHADER_CREATE_INFO(draw_resource_id) +DEFINE("DYNAMIC_RESOURCE_ID") +GPU_SHADER_CREATE_END() /** * Used if the resource index needs to be passed to the fragment shader. * IMPORTANT: Vertex and Geometry shaders need to use PASS_RESOURCE_ID in main(). */ -GPU_SHADER_INTERFACE_INFO(draw_resource_id_iface, "drw_ResourceID_iface") - .flat(Type::INT, "resource_index"); +GPU_SHADER_NAMED_INTERFACE_INFO(draw_resource_id_iface, drw_ResourceID_iface) +FLAT(INT, resource_index) +GPU_SHADER_NAMED_INTERFACE_END(drw_ResourceID_iface) GPU_SHADER_CREATE_INFO(draw_resource_id_varying) - .vertex_out(draw_resource_id_iface) - .geometry_out(draw_resource_id_iface); /* Used if needed. */ +VERTEX_OUT(draw_resource_id_iface) +GEOMETRY_OUT(draw_resource_id_iface) +GPU_SHADER_CREATE_END() /* Used if needed. */ /* Variation used when drawing multiple instances for one object. */ GPU_SHADER_CREATE_INFO(draw_resource_id_uniform) - .define("UNIFORM_RESOURCE_ID") - .push_constant(Type::INT, "drw_ResourceID"); +DEFINE("UNIFORM_RESOURCE_ID") +PUSH_CONSTANT(INT, drw_ResourceID) +GPU_SHADER_CREATE_END() /** * Declare a resource handle that identify a unique object. * Requires draw_resource_id[_uniform]. */ GPU_SHADER_CREATE_INFO(draw_resource_handle) - .define("resource_handle (drw_resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)") - .push_constant(Type::INT, "drw_resourceChunk"); +DEFINE_VALUE("resource_handle", "(drw_resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)") +PUSH_CONSTANT(INT, drw_resourceChunk) +GPU_SHADER_CREATE_END() /** \} */ @@ -47,36 +53,38 @@ GPU_SHADER_CREATE_INFO(draw_resource_handle) * \{ */ GPU_SHADER_CREATE_INFO(draw_view) - .uniform_buf(DRW_VIEW_UBO_SLOT, "ViewMatrices", "drw_view_[DRW_VIEW_LEN]", Frequency::PASS) - .define("DRAW_VIEW_CREATE_INFO") - .define("drw_view", "drw_view_[drw_view_id]") - .typedef_source("draw_shader_shared.hh"); +UNIFORM_BUF_FREQ(DRW_VIEW_UBO_SLOT, ViewMatrices, drw_view_[DRW_VIEW_LEN], PASS) +DEFINE("DRAW_VIEW_CREATE_INFO") +DEFINE_VALUE("drw_view", "drw_view_[drw_view_id]") +TYPEDEF_SOURCE("draw_shader_shared.hh") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_view_culling) - .uniform_buf(DRW_VIEW_CULLING_UBO_SLOT, "ViewCullingData", "drw_view_culling_[DRW_VIEW_LEN]") - .define("DRW_VIEW_CULLING_INFO") - .define("drw_view_culling", "drw_view_culling_[drw_view_id]") - .typedef_source("draw_shader_shared.hh"); +UNIFORM_BUF(DRW_VIEW_CULLING_UBO_SLOT, ViewCullingData, drw_view_culling_[DRW_VIEW_LEN]) +DEFINE("DRW_VIEW_CULLING_INFO") +DEFINE_VALUE("drw_view_culling", "drw_view_culling_[drw_view_id]") +TYPEDEF_SOURCE("draw_shader_shared.hh") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_modelmat) - .uniform_buf(DRW_OBJ_MAT_UBO_SLOT, - "ObjectMatrices", - "drw_matrices[DRW_RESOURCE_CHUNK_LEN]", - Frequency::BATCH) - .define("ModelMatrix", "(drw_matrices[resource_id].model)") - .define("ModelMatrixInverse", "(drw_matrices[resource_id].model_inverse)") - .additional_info("draw_view"); +UNIFORM_BUF_FREQ(DRW_OBJ_MAT_UBO_SLOT, ObjectMatrices, drw_matrices[DRW_RESOURCE_CHUNK_LEN], BATCH) +DEFINE_VALUE("ModelMatrix", "(drw_matrices[resource_id].model)") +DEFINE_VALUE("ModelMatrixInverse", "(drw_matrices[resource_id].model_inverse)") +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_modelmat_legacy) - .define("DRW_LEGACY_MODEL_MATRIX") - .push_constant(Type::MAT4, "ModelMatrix") - .push_constant(Type::MAT4, "ModelMatrixInverse") - .additional_info("draw_view"); +DEFINE("DRW_LEGACY_MODEL_MATRIX") +PUSH_CONSTANT(MAT4, ModelMatrix) +PUSH_CONSTANT(MAT4, ModelMatrixInverse) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_modelmat_instanced_attr) - .push_constant(Type::MAT4, "ModelMatrix") - .push_constant(Type::MAT4, "ModelMatrixInverse") - .additional_info("draw_view"); +PUSH_CONSTANT(MAT4, ModelMatrix) +PUSH_CONSTANT(MAT4, ModelMatrixInverse) +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() /** \} */ @@ -85,9 +93,10 @@ GPU_SHADER_CREATE_INFO(draw_modelmat_instanced_attr) * \{ */ GPU_SHADER_CREATE_INFO(drw_clipped) - /* TODO(fclem): Move to engine side. */ - .uniform_buf(DRW_CLIPPING_UBO_SLOT, "vec4", "drw_clipping_[6]", Frequency::PASS) - .define("USE_WORLD_CLIP_PLANES"); +/* TODO(fclem): Move to engine side. */ +UNIFORM_BUF_FREQ(DRW_CLIPPING_UBO_SLOT, vec4, drw_clipping_[6], PASS) +DEFINE("USE_WORLD_CLIP_PLANES") +GPU_SHADER_CREATE_END() /** \} */ @@ -96,8 +105,9 @@ GPU_SHADER_CREATE_INFO(drw_clipped) * \{ */ GPU_SHADER_CREATE_INFO(draw_globals) - .typedef_source("draw_common_shader_shared.hh") - .uniform_buf(7, "GlobalsUboStorage", "globalsBlock", Frequency::PASS); +TYPEDEF_SOURCE("draw_common_shader_shared.hh") +UNIFORM_BUF_FREQ(7, GlobalsUboStorage, globalsBlock, PASS) +GPU_SHADER_CREATE_END() /** \} */ @@ -105,80 +115,102 @@ GPU_SHADER_CREATE_INFO(draw_globals) /** \name Geometry Type * \{ */ -GPU_SHADER_CREATE_INFO(draw_mesh).additional_info("draw_modelmat", "draw_resource_id"); +GPU_SHADER_CREATE_INFO(draw_mesh) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id) +GPU_SHADER_CREATE_END() -GPU_SHADER_CREATE_INFO(draw_mesh_new).additional_info("draw_modelmat_new", "draw_resource_id"); +GPU_SHADER_CREATE_INFO(draw_mesh_new) +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_id) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_hair) - .define("HAIR_SHADER") - .define("DRW_HAIR_INFO") - .sampler(15, ImageType::FLOAT_BUFFER, "hairPointBuffer") - /* TODO(@fclem): Pack these into one UBO. */ - .push_constant(Type::INT, "hairStrandsRes") - .push_constant(Type::INT, "hairThicknessRes") - .push_constant(Type::FLOAT, "hairRadRoot") - .push_constant(Type::FLOAT, "hairRadTip") - .push_constant(Type::FLOAT, "hairRadShape") - .push_constant(Type::BOOL, "hairCloseTip") - .push_constant(Type::INT, "hairStrandOffset") - .push_constant(Type::MAT4, "hairDupliMatrix") - .additional_info("draw_modelmat", "draw_resource_id"); +DEFINE("HAIR_SHADER") +DEFINE("DRW_HAIR_INFO") +SAMPLER(15, FLOAT_BUFFER, hairPointBuffer) +/* TODO(@fclem): Pack these into one UBO. */ +PUSH_CONSTANT(INT, hairStrandsRes) +PUSH_CONSTANT(INT, hairThicknessRes) +PUSH_CONSTANT(FLOAT, hairRadRoot) +PUSH_CONSTANT(FLOAT, hairRadTip) +PUSH_CONSTANT(FLOAT, hairRadShape) +PUSH_CONSTANT(BOOL, hairCloseTip) +PUSH_CONSTANT(INT, hairStrandOffset) +PUSH_CONSTANT(MAT4, hairDupliMatrix) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_hair_new) - .define("HAIR_SHADER") - .define("DRW_HAIR_INFO") - .sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer") - /* TODO(@fclem): Pack these into one UBO. */ - .push_constant(Type::INT, "hairStrandsRes") - .push_constant(Type::INT, "hairThicknessRes") - .push_constant(Type::FLOAT, "hairRadRoot") - .push_constant(Type::FLOAT, "hairRadTip") - .push_constant(Type::FLOAT, "hairRadShape") - .push_constant(Type::BOOL, "hairCloseTip") - .push_constant(Type::INT, "hairStrandOffset") - .push_constant(Type::MAT4, "hairDupliMatrix"); +DEFINE("HAIR_SHADER") +DEFINE("DRW_HAIR_INFO") +SAMPLER(0, FLOAT_BUFFER, hairPointBuffer) +/* TODO(@fclem): Pack these into one UBO. */ +PUSH_CONSTANT(INT, hairStrandsRes) +PUSH_CONSTANT(INT, hairThicknessRes) +PUSH_CONSTANT(FLOAT, hairRadRoot) +PUSH_CONSTANT(FLOAT, hairRadTip) +PUSH_CONSTANT(FLOAT, hairRadShape) +PUSH_CONSTANT(BOOL, hairCloseTip) +PUSH_CONSTANT(INT, hairStrandOffset) +PUSH_CONSTANT(MAT4, hairDupliMatrix) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_pointcloud) - .sampler(0, ImageType::FLOAT_BUFFER, "ptcloud_pos_rad_tx", Frequency::BATCH) - .define("POINTCLOUD_SHADER") - .define("DRW_POINTCLOUD_INFO") - .additional_info("draw_modelmat_instanced_attr", "draw_resource_id_uniform"); +SAMPLER_FREQ(0, FLOAT_BUFFER, ptcloud_pos_rad_tx, BATCH) +DEFINE("POINTCLOUD_SHADER") +DEFINE("DRW_POINTCLOUD_INFO") +ADDITIONAL_INFO(draw_modelmat_instanced_attr) +ADDITIONAL_INFO(draw_resource_id_uniform) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_pointcloud_new) - .sampler(0, ImageType::FLOAT_BUFFER, "ptcloud_pos_rad_tx", Frequency::BATCH) - .define("POINTCLOUD_SHADER") - .define("DRW_POINTCLOUD_INFO"); +SAMPLER_FREQ(0, FLOAT_BUFFER, ptcloud_pos_rad_tx, BATCH) +DEFINE("POINTCLOUD_SHADER") +DEFINE("DRW_POINTCLOUD_INFO") +GPU_SHADER_CREATE_END() -GPU_SHADER_CREATE_INFO(draw_volume).additional_info("draw_modelmat", "draw_resource_id_uniform"); +GPU_SHADER_CREATE_INFO(draw_volume) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_resource_id_uniform) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_volume_new) - .additional_info("draw_modelmat_new", "draw_resource_handle_new"); +ADDITIONAL_INFO(draw_modelmat_new) +ADDITIONAL_INFO(draw_resource_handle_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_gpencil) - .typedef_source("gpencil_shader_shared.h") - .define("DRW_GPENCIL_INFO") - .sampler(0, ImageType::FLOAT_BUFFER, "gp_pos_tx") - .sampler(1, ImageType::FLOAT_BUFFER, "gp_col_tx") - /* Per Object */ - .push_constant(Type::FLOAT, "gpThicknessScale") /* TODO(fclem): Replace with object info. */ - .push_constant(Type::FLOAT, "gpThicknessWorldScale") /* TODO(fclem): Same as above. */ - .define("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") - /* Per Layer */ - .push_constant(Type::FLOAT, "gpThicknessOffset") - .additional_info("draw_modelmat", "draw_object_infos"); +TYPEDEF_SOURCE("gpencil_shader_shared.h") +DEFINE("DRW_GPENCIL_INFO") +SAMPLER(0, FLOAT_BUFFER, gp_pos_tx) +SAMPLER(1, FLOAT_BUFFER, gp_col_tx) +/* Per Object */ +PUSH_CONSTANT(FLOAT, gpThicknessScale) /* TODO(fclem): Replace with object info. */ +PUSH_CONSTANT(FLOAT, gpThicknessWorldScale) /* TODO(fclem): Same as above. */ +DEFINE_VALUE("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") +/* Per Layer */ +PUSH_CONSTANT(FLOAT, gpThicknessOffset) +ADDITIONAL_INFO(draw_modelmat) +ADDITIONAL_INFO(draw_object_infos) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_gpencil_new) - .typedef_source("gpencil_shader_shared.h") - .define("DRW_GPENCIL_INFO") - .sampler(0, ImageType::FLOAT_BUFFER, "gp_pos_tx") - .sampler(1, ImageType::FLOAT_BUFFER, "gp_col_tx") - /* Per Object */ - .push_constant(Type::FLOAT, "gpThicknessScale") /* TODO(fclem): Replace with object info. */ - .push_constant(Type::FLOAT, "gpThicknessWorldScale") /* TODO(fclem): Same as above. */ - .define("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") - /* Per Layer */ - .push_constant(Type::FLOAT, "gpThicknessOffset") - .additional_info("draw_resource_id_varying", "draw_view", "draw_object_infos_new"); +TYPEDEF_SOURCE("gpencil_shader_shared.h") +DEFINE("DRW_GPENCIL_INFO") +SAMPLER(0, FLOAT_BUFFER, gp_pos_tx) +SAMPLER(1, FLOAT_BUFFER, gp_col_tx) +/* Per Object */ +PUSH_CONSTANT(FLOAT, gpThicknessScale) /* TODO(fclem): Replace with object info. */ +PUSH_CONSTANT(FLOAT, gpThicknessWorldScale) /* TODO(fclem): Same as above. */ +DEFINE_VALUE("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)") +/* Per Layer */ +PUSH_CONSTANT(FLOAT, gpThicknessOffset) +ADDITIONAL_INFO(draw_resource_id_varying) +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_object_infos_new) +GPU_SHADER_CREATE_END() /** \} */ @@ -187,51 +219,56 @@ GPU_SHADER_CREATE_INFO(draw_gpencil_new) * \{ */ GPU_SHADER_CREATE_INFO(draw_resource_finalize) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .define("DRAW_FINALIZE_SHADER") - .local_group_size(DRW_FINALIZE_GROUP_SIZE) - .storage_buf(0, Qualifier::READ, "ObjectMatrices", "matrix_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, "ObjectBounds", "bounds_buf[]") - .storage_buf(2, Qualifier::READ_WRITE, "ObjectInfos", "infos_buf[]") - .push_constant(Type::INT, "resource_len") - .compute_source("draw_resource_finalize_comp.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +DEFINE("DRAW_FINALIZE_SHADER") +LOCAL_GROUP_SIZE(DRW_FINALIZE_GROUP_SIZE) +STORAGE_BUF(0, READ, ObjectMatrices, matrix_buf[]) +STORAGE_BUF(1, READ_WRITE, ObjectBounds, bounds_buf[]) +STORAGE_BUF(2, READ_WRITE, ObjectInfos, infos_buf[]) +PUSH_CONSTANT(INT, resource_len) +COMPUTE_SOURCE("draw_resource_finalize_comp.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_view_finalize) - .do_static_compilation(true) - .local_group_size(DRW_VIEW_MAX) - .define("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) - .storage_buf(0, Qualifier::READ_WRITE, "ViewCullingData", "view_culling_buf[DRW_VIEW_LEN]") - .compute_source("draw_view_finalize_comp.glsl") - .additional_info("draw_view"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DRW_VIEW_MAX) +DEFINE_VALUE("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) +STORAGE_BUF(0, READ_WRITE, ViewCullingData, view_culling_buf[DRW_VIEW_LEN]) +COMPUTE_SOURCE("draw_view_finalize_comp.glsl") +ADDITIONAL_INFO(draw_view) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_visibility_compute) - .do_static_compilation(true) - .local_group_size(DRW_VISIBILITY_GROUP_SIZE) - .define("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) - .storage_buf(0, Qualifier::READ, "ObjectBounds", "bounds_buf[]") - .storage_buf(1, Qualifier::READ_WRITE, "uint", "visibility_buf[]") - .push_constant(Type::INT, "resource_len") - .push_constant(Type::INT, "view_len") - .push_constant(Type::INT, "visibility_word_per_draw") - .compute_source("draw_visibility_comp.glsl") - .additional_info("draw_view", "draw_view_culling"); +DO_STATIC_COMPILATION() +LOCAL_GROUP_SIZE(DRW_VISIBILITY_GROUP_SIZE) +DEFINE_VALUE("DRW_VIEW_LEN", STRINGIFY(DRW_VIEW_MAX)) +STORAGE_BUF(0, READ, ObjectBounds, bounds_buf[]) +STORAGE_BUF(1, READ_WRITE, uint, visibility_buf[]) +PUSH_CONSTANT(INT, resource_len) +PUSH_CONSTANT(INT, view_len) +PUSH_CONSTANT(INT, visibility_word_per_draw) +COMPUTE_SOURCE("draw_visibility_comp.glsl") +ADDITIONAL_INFO(draw_view) +ADDITIONAL_INFO(draw_view_culling) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_command_generate) - .do_static_compilation(true) - .typedef_source("draw_shader_shared.hh") - .typedef_source("draw_command_shared.hh") - .local_group_size(DRW_COMMAND_GROUP_SIZE) - .storage_buf(0, Qualifier::READ_WRITE, "DrawGroup", "group_buf[]") - .storage_buf(1, Qualifier::READ, "uint", "visibility_buf[]") - .storage_buf(2, Qualifier::READ, "DrawPrototype", "prototype_buf[]") - .storage_buf(3, Qualifier::WRITE, "DrawCommand", "command_buf[]") - .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::WRITE, "uint", "resource_id_buf[]") - .push_constant(Type::INT, "prototype_len") - .push_constant(Type::INT, "visibility_word_per_draw") - .push_constant(Type::INT, "view_shift") - .push_constant(Type::BOOL, "use_custom_ids") - .compute_source("draw_command_generate_comp.glsl"); +DO_STATIC_COMPILATION() +TYPEDEF_SOURCE("draw_shader_shared.hh") +TYPEDEF_SOURCE("draw_command_shared.hh") +LOCAL_GROUP_SIZE(DRW_COMMAND_GROUP_SIZE) +STORAGE_BUF(0, READ_WRITE, DrawGroup, group_buf[]) +STORAGE_BUF(1, READ, uint, visibility_buf[]) +STORAGE_BUF(2, READ, DrawPrototype, prototype_buf[]) +STORAGE_BUF(3, WRITE, DrawCommand, command_buf[]) +STORAGE_BUF(DRW_RESOURCE_ID_SLOT, WRITE, uint, resource_id_buf[]) +PUSH_CONSTANT(INT, prototype_len) +PUSH_CONSTANT(INT, visibility_word_per_draw) +PUSH_CONSTANT(INT, view_shift) +PUSH_CONSTANT(BOOL, use_custom_ids) +COMPUTE_SOURCE("draw_command_generate_comp.glsl") +GPU_SHADER_CREATE_END() /** \} */ @@ -241,35 +278,41 @@ GPU_SHADER_CREATE_INFO(draw_command_generate) * \{ */ GPU_SHADER_CREATE_INFO(draw_resource_id_new) - .define("UNIFORM_RESOURCE_ID_NEW") - /* TODO (Miguel Pozo): This is an int for compatibility. - * It should become uint once the "Next" ports are complete. */ - .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::READ, "int", "resource_id_buf[]") - .define("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID]"); +DEFINE("UNIFORM_RESOURCE_ID_NEW") +/* TODO (Miguel Pozo): This is an int for compatibility. + * It should become uint once the "Next" ports are complete. */ +STORAGE_BUF(DRW_RESOURCE_ID_SLOT, READ, int, resource_id_buf[]) +DEFINE_VALUE("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID]") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_new) - .define("UNIFORM_RESOURCE_ID_NEW") - .define("WITH_CUSTOM_IDS") - .storage_buf(DRW_RESOURCE_ID_SLOT, Qualifier::READ, "int2", "resource_id_buf[]") - .define("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].x") - .define("drw_CustomID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].y"); +DEFINE("UNIFORM_RESOURCE_ID_NEW") +DEFINE("WITH_CUSTOM_IDS") +STORAGE_BUF(DRW_RESOURCE_ID_SLOT, READ, int2, resource_id_buf[]) +DEFINE_VALUE("drw_ResourceID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].x") +DEFINE_VALUE("drw_CustomID", "resource_id_buf[gpu_BaseInstance + gl_InstanceID].y") +GPU_SHADER_CREATE_END() /** * Workaround the lack of gl_BaseInstance by binding the resource_id_buf as vertex buf. */ GPU_SHADER_CREATE_INFO(draw_resource_id_fallback) - .define("UNIFORM_RESOURCE_ID_NEW") - .vertex_in(15, Type::INT, "drw_ResourceID"); +DEFINE("UNIFORM_RESOURCE_ID_NEW") +VERTEX_IN(15, INT, drw_ResourceID) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_fallback) - .define("UNIFORM_RESOURCE_ID_NEW") - .define("WITH_CUSTOM_IDS") - .vertex_in(15, Type::IVEC2, "vertex_in_drw_ResourceID") - .define("drw_ResourceID", "vertex_in_drw_ResourceID.x") - .define("drw_CustomID", "vertex_in_drw_ResourceID.y"); +DEFINE("UNIFORM_RESOURCE_ID_NEW") +DEFINE("WITH_CUSTOM_IDS") +VERTEX_IN(15, IVEC2, vertex_in_drw_ResourceID) +DEFINE_VALUE("drw_ResourceID", "vertex_in_drw_ResourceID.x") +DEFINE_VALUE("drw_CustomID", "vertex_in_drw_ResourceID.y") +GPU_SHADER_CREATE_END() /** TODO mask view id bits. */ -GPU_SHADER_CREATE_INFO(draw_resource_handle_new).define("resource_handle", "drw_ResourceID"); +GPU_SHADER_CREATE_INFO(draw_resource_handle_new) +DEFINE_VALUE("resource_handle", "drw_ResourceID") +GPU_SHADER_CREATE_END() /** \} */ @@ -278,19 +321,24 @@ GPU_SHADER_CREATE_INFO(draw_resource_handle_new).define("resource_handle", "drw_ * \{ */ GPU_SHADER_CREATE_INFO(draw_modelmat_new_common) - .typedef_source("draw_shader_shared.hh") - .storage_buf(DRW_OBJ_MAT_SLOT, Qualifier::READ, "ObjectMatrices", "drw_matrix_buf[]") - .define("DRAW_MODELMAT_CREATE_INFO") - .define("drw_ModelMatrixInverse", "drw_matrix_buf[resource_id].model_inverse") - .define("drw_ModelMatrix", "drw_matrix_buf[resource_id].model") - /* TODO For compatibility with old shaders. To be removed. */ - .define("ModelMatrixInverse", "drw_ModelMatrixInverse") - .define("ModelMatrix", "drw_ModelMatrix"); +TYPEDEF_SOURCE("draw_shader_shared.hh") +STORAGE_BUF(DRW_OBJ_MAT_SLOT, READ, ObjectMatrices, drw_matrix_buf[]) +DEFINE("DRAW_MODELMAT_CREATE_INFO") +DEFINE_VALUE("drw_ModelMatrixInverse", "drw_matrix_buf[resource_id].model_inverse") +DEFINE_VALUE("drw_ModelMatrix", "drw_matrix_buf[resource_id].model") +/* TODO For compatibility with old shaders. To be removed. */ +DEFINE_VALUE("ModelMatrixInverse", "drw_ModelMatrixInverse") +DEFINE_VALUE("ModelMatrix", "drw_ModelMatrix") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_modelmat_new) - .additional_info("draw_modelmat_new_common", "draw_resource_id_new"); +ADDITIONAL_INFO(draw_modelmat_new_common) +ADDITIONAL_INFO(draw_resource_id_new) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(draw_modelmat_new_with_custom_id) - .additional_info("draw_modelmat_new_common", "draw_resource_with_custom_id_new"); +ADDITIONAL_INFO(draw_modelmat_new_common) +ADDITIONAL_INFO(draw_resource_with_custom_id_new) +GPU_SHADER_CREATE_END() /** \} */ diff --git a/source/blender/draw/intern/shaders/draw_view_lib.glsl b/source/blender/draw/intern/shaders/draw_view_lib.glsl index fdb2e6488ab..18bc535d727 100644 --- a/source/blender/draw/intern/shaders/draw_view_lib.glsl +++ b/source/blender/draw/intern/shaders/draw_view_lib.glsl @@ -4,7 +4,7 @@ #pragma once -#ifndef DRAW_VIEW_CREATE_INFO +#if !defined(DRAW_VIEW_CREATE_INFO) && !defined(GLSL_CPP_STUBS) # error Missing draw_view additional create info on shader create info #endif diff --git a/source/blender/gpu/GPU_shader_shared_utils.hh b/source/blender/gpu/GPU_shader_shared_utils.hh index 5fe801e44e1..7308a53cf51 100644 --- a/source/blender/gpu/GPU_shader_shared_utils.hh +++ b/source/blender/gpu/GPU_shader_shared_utils.hh @@ -28,7 +28,15 @@ * NOTE: You can use bool type using bool32_t a int boolean type matching the GLSL type. */ -#ifdef GPU_SHADER +#ifdef GLSL_CPP_STUBS +# pragma once +using bool32_t = bool; +/** Packed types are needed for MSL which have different alignment rules for float3. */ +using packed_float3 = float3; +using packed_int3 = int3; +using packed_uint3 = uint3; + +#elif defined(GPU_SHADER) /* Silence macros when compiling for shaders. */ # define BLI_STATIC_ASSERT(cond, msg) # define BLI_STATIC_ASSERT_ALIGN(type_, align_) diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index 7e7e71348d3..7ad3156282a 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -24,6 +24,7 @@ #include "gpu_shader_create_info_private.hh" #include "gpu_shader_dependency_private.hh" +#undef GPU_SHADER_NAMED_INTERFACE_INFO #undef GPU_SHADER_INTERFACE_INFO #undef GPU_SHADER_CREATE_INFO @@ -446,8 +447,14 @@ void gpu_shader_create_info_init() g_create_infos = new CreateInfoDictionnary(); g_interfaces = new InterfaceDictionnary(); -#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name) \ - StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface, _inst_name); \ +#define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \ + StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface, #_inst_name); \ + StageInterfaceInfo &_interface = *ptr_##_interface; \ + g_interfaces->add_new(#_interface, ptr_##_interface); \ + _interface + +#define GPU_SHADER_INTERFACE_INFO(_interface) \ + StageInterfaceInfo *ptr_##_interface = new StageInterfaceInfo(#_interface); \ StageInterfaceInfo &_interface = *ptr_##_interface; \ g_interfaces->add_new(#_interface, ptr_##_interface); \ _interface diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index c7e10447e97..eadb6116a29 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -15,6 +15,7 @@ #include "BLI_hash.hh" #include "BLI_string_ref.hh" +#include "BLI_utildefines_variadic.h" #include "BLI_vector.hh" #include "GPU_common_types.hh" #include "GPU_material.hh" @@ -38,14 +39,242 @@ namespace blender::gpu::shader { -/* Helps intellisense / auto-completion. */ -#ifndef GPU_SHADER_CREATE_INFO -# define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name) \ +#if defined(GLSL_CPP_STUBS) +# define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \ + namespace _interface { \ + struct { +# define GPU_SHADER_NAMED_INTERFACE_END(_inst_name) \ + } \ + _inst_name; \ + } + +# define GPU_SHADER_INTERFACE_INFO(_interface) namespace _interface { +# define GPU_SHADER_INTERFACE_END() } + +# define GPU_SHADER_CREATE_INFO(_info) \ + namespace _info { \ + namespace gl_VertexShader { \ + } \ + namespace gl_FragmentShader { \ + } \ + namespace gl_ComputeShader { \ + } +# define GPU_SHADER_CREATE_END() } + +# define SHADER_LIBRARY_CREATE_INFO(_info) using namespace _info; +# define VERTEX_SHADER_CREATE_INFO(_info) \ + using namespace ::gl_VertexShader; \ + using namespace _info::gl_VertexShader; \ + using namespace _info; +# define FRAGMENT_SHADER_CREATE_INFO(_info) \ + using namespace ::gl_FragmentShader; \ + using namespace _info::gl_FragmentShader; \ + using namespace _info; +# define COMPUTE_SHADER_CREATE_INFO(_info) \ + using namespace ::gl_ComputeShader; \ + using namespace _info::gl_ComputeShader; \ + using namespace _info; + +#elif !defined(GPU_SHADER_CREATE_INFO) +/* Helps intellisense / auto-completion inside info files. */ +# define GPU_SHADER_NAMED_INTERFACE_INFO(_interface, _inst_name) \ StageInterfaceInfo _interface(#_interface, _inst_name); \ _interface +# define GPU_SHADER_INTERFACE_INFO(_interface) \ + StageInterfaceInfo _interface(#_interface); \ + _interface # define GPU_SHADER_CREATE_INFO(_info) \ ShaderCreateInfo _info(#_info); \ _info + +# define GPU_SHADER_NAMED_INTERFACE_END(_inst_name) ; +# define GPU_SHADER_INTERFACE_END() ; +# define GPU_SHADER_CREATE_END() ; + +#endif + +#ifndef GLSL_CPP_STUBS +# define SMOOTH(type, name) .smooth(Type::type, #name) +# define FLAT(type, name) .flat(Type::type, #name) +# define NO_PERSPECTIVE(type, name) .no_perspective(Type::type, #name) + +/* LOCAL_GROUP_SIZE(int size_x, int size_y = -1, int size_z = -1) */ +# define LOCAL_GROUP_SIZE(...) .local_group_size(__VA_ARGS__) + +# define VERTEX_IN(slot, type, name) .vertex_in(slot, Type::type, #name) +# define VERTEX_OUT(stage_interface) .vertex_out(stage_interface) +/* TO REMOVE. */ +# define GEOMETRY_LAYOUT(...) .geometry_layout(__VA_ARGS__) +# define GEOMETRY_OUT(stage_interface) .geometry_out(stage_interface) + +# define SUBPASS_IN(slot, type, name, rog) .subpass_in(slot, Type::type, #name, rog) + +# define FRAGMENT_OUT(slot, type, name) .fragment_out(slot, Type::type, #name) +# define FRAGMENT_OUT_DUAL(slot, type, name, blend) \ + .fragment_out(slot, Type::type, #name, DualBlend::blend) +# define FRAGMENT_OUT_ROG(slot, type, name, rog) \ + .fragment_out(slot, Type::type, #name, DualBlend::NONE, rog) + +# define EARLY_FRAGMENT_TEST(enable) .early_fragment_test(enable) +# define DEPTH_WRITE(value) .depth_write(value) + +# define SPECIALIZATION_CONSTANT(type, name, default_value) \ + .specialization_constant(Type::type, #name, default_value) + +# define PUSH_CONSTANT(type, name) .push_constant(Type::type, #name) +# define PUSH_CONSTANT_ARRAY(type, name, array_size) .push_constant(Type::type, #name, array_size) + +# define UNIFORM_BUF(slot, type_name, name) .uniform_buf(slot, #type_name, #name) +# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) \ + .uniform_buf(slot, #type_name, #name, Frequency::freq) + +# define STORAGE_BUF(slot, qualifiers, type_name, name) \ + .storage_buf(slot, Qualifier::qualifiers, STRINGIFY(type_name), #name) +# define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq) \ + .storage_buf(slot, Qualifier::qualifiers, STRINGIFY(type_name), #name, Frequency::freq) + +# define SAMPLER(slot, type, name) .sampler(slot, ImageType::type, #name) +# define SAMPLER_FREQ(slot, type, name, freq) \ + .sampler(slot, ImageType::type, #name, Frequency::freq) + +# define IMAGE(slot, format, qualifiers, type, name) \ + .image(slot, format, Qualifier::qualifiers, ImageType::type, #name) +# define IMAGE_FREQ(slot, format, qualifiers, type, name, freq) \ + .image(slot, format, Qualifier::qualifiers, ImageType::type, #name, Frequency::freq) + +# define BUILTINS(builtin) .builtins(builtin) + +# define VERTEX_SOURCE(filename) .vertex_source(filename) +# define GEOMETRY_SOURCE(filename) .geometry_source(filename) +# define FRAGMENT_SOURCE(filename) .fragment_source(filename) +# define COMPUTE_SOURCE(filename) .compute_source(filename) + +# define DEFINE(name) .define(name) +# define DEFINE_VALUE(name, value) .define(name, value) + +# define DO_STATIC_COMPILATION() .do_static_compilation(true) +# define AUTO_RESOURCE_LOCATION() .auto_resource_location(true) + +/* TO REMOVE. */ +# define METAL_BACKEND_ONLY() .metal_backend_only(true) + +# define ADDITIONAL_INFO(info_name) .additional_info(#info_name) +# define TYPEDEF_SOURCE(filename) .typedef_source(filename) + +# define MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(value) \ + .mtl_max_total_threads_per_threadgroup(value) + +#else + +# define READ const +# define WRITE +# define READ_WRITE + +# define _FLOAT_BUFFER(T) T##Buffer +# define _FLOAT_1D(T) T##1D +# define _FLOAT_1D_ARRAY(T) T##1DArray +# define _FLOAT_2D(T) T##2D +# define _FLOAT_2D_ARRAY(T) T##2DArray +# define _FLOAT_3D(T) T##3D +# define _FLOAT_CUBE(T) T##Cube +# define _FLOAT_CUBE_ARRAY(T) T##CubeArray +# define _INT_BUFFER(T) i##T##Buffer +# define _INT_1D(T) i##T##1D +# define _INT_1D_ARRAY(T) i##T##1DArray +# define _INT_2D(T) i##T##2D +# define _INT_2D_ARRAY(T) i##T##2DArray +# define _INT_3D(T) i##T##3D +# define _INT_CUBE(T) i##T##Cube +# define _INT_CUBE_ARRAY(T) i##T##CubeArray +# define _UINT_BUFFER(T) u##T##Buffer +# define _UINT_1D(T) u##T##1D +# define _UINT_1D_ARRAY(T) u##T##1DArray +# define _UINT_2D(T) u##T##2D +# define _UINT_2D_ARRAY(T) u##T##2DArray +# define _UINT_3D(T) u##T##3D +# define _UINT_CUBE(T) u##T##Cube +# define _UINT_CUBE_ARRAY(T) u##T##CubeArray +# define _SHADOW_2D(T) T##2DShadow +# define _SHADOW_2D_ARRAY(T) T##2DArrayShadow +# define _SHADOW_CUBE(T) T##CubeShadow +# define _SHADOW_CUBE_ARRAY(T) T##CubeArrayShadow +# define _DEPTH_2D(T) T##2D +# define _DEPTH_2D_ARRAY(T) T##2DArray +# define _DEPTH_CUBE(T) T##Cube +# define _DEPTH_CUBE_ARRAY(T) T##CubeArray + +# define SMOOTH(type, name) type name = {}; +# define FLAT(type, name) type name = {}; +# define NO_PERSPECTIVE(type, name) type name = {}; + +/* LOCAL_GROUP_SIZE(int size_x, int size_y = -1, int size_z = -1) */ +# define LOCAL_GROUP_SIZE(...) + +# define VERTEX_IN(slot, type, name) \ + namespace gl_VertexShader { \ + const type name = {}; \ + } +# define VERTEX_OUT(stage_interface) using namespace stage_interface; +/* TO REMOVE. */ +# define GEOMETRY_LAYOUT(...) +# define GEOMETRY_OUT(stage_interface) using namespace stage_interface; + +# define SUBPASS_IN(slot, type, name, rog) const type name = {}; + +# define FRAGMENT_OUT(slot, type, name) \ + namespace gl_FragmentShader { \ + type name; \ + } +# define FRAGMENT_OUT_DUAL(slot, type, name, blend) \ + namespace gl_FragmentShader { \ + type name; \ + } +# define FRAGMENT_OUT_ROG(slot, type, name, rog) \ + namespace gl_FragmentShader { \ + type name; \ + } + +# define EARLY_FRAGMENT_TEST(enable) +# define DEPTH_WRITE(value) + +# define SPECIALIZATION_CONSTANT(type, name, default_value) constexpr type name = {}; + +# define PUSH_CONSTANT(type, name) const type name = {}; +# define PUSH_CONSTANT_ARRAY(type, name, array_size) const type name[array_size] = {}; + +# define UNIFORM_BUF(slot, type_name, name) const type_name name = {}; +# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) const type_name name = {}; + +# define STORAGE_BUF(slot, qualifiers, type_name, name) qualifiers type_name name = {}; +# define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq) qualifiers type_name name = {}; + +# define SAMPLER(slot, type, name) _##type(sampler) name; +# define SAMPLER_FREQ(slot, type, name, freq) _##type(sampler) name; + +# define IMAGE(slot, format, qualifiers, type, name) qualifiers _##type(image) name; +# define IMAGE_FREQ(slot, format, qualifiers, type, name, freq) qualifiers _##type(image) name; + +# define BUILTINS(builtin) + +# define VERTEX_SOURCE(filename) +# define GEOMETRY_SOURCE(filename) +# define FRAGMENT_SOURCE(filename) +# define COMPUTE_SOURCE(filename) + +# define DEFINE(name) +# define DEFINE_VALUE(name, value) + +# define DO_STATIC_COMPILATION() +# define AUTO_RESOURCE_LOCATION() + +/* TO REMOVE. */ +# define METAL_BACKEND_ONLY() + +# define ADDITIONAL_INFO(info_name) using namespace info_name; +# define TYPEDEF_SOURCE(filename) + +# define MTL_MAX_TOTAL_THREADS_PER_THREADGROUP(value) \ + .mtl_max_total_threads_per_threadgroup(value) #endif /* All of these functions is a bit out of place */ @@ -326,7 +555,7 @@ struct StageInterfaceInfo { /** List of all members of the interface. */ Vector inouts; - StageInterfaceInfo(const char *name_, const char *instance_name_) + StageInterfaceInfo(const char *name_, const char *instance_name_ = "") : name(name_), instance_name(instance_name_){}; ~StageInterfaceInfo(){}; @@ -1166,3 +1395,17 @@ template<> struct DefaultHash + +/* -------------------------------------------------------------------- */ +/** \name Vector Types + * \{ */ + +template struct VecBase {}; + +template struct VecOp { + using VecT = VecBase; + + T &operator[](int) {} + const T &operator[](int) const {} + + VecT operator+() const {} + VecT operator-() const {} + + VecT operator+(VecT) const {} + VecT operator-(VecT) const {} + VecT operator/(VecT) const {} + VecT operator*(VecT) const {} + + VecT operator+=(VecT) const {} + VecT operator-=(VecT) const {} + VecT operator/=(VecT) const {} + VecT operator*=(VecT) const {} + + VecT operator+(T) const {} + VecT operator-(T) const {} + VecT operator/(T) const {} + VecT operator*(T) const {} + + VecT operator+=(T) const {} + VecT operator-=(T) const {} + VecT operator/=(T) const {} + VecT operator*=(T) const {} + + friend VecT operator+(T, VecT) {} + friend VecT operator-(T, VecT) {} + friend VecT operator/(T, VecT) {} + friend VecT operator*(T, VecT) {} + +#define INT_OP \ + template> * = nullptr> + + INT_OP VecT operator%(VecT) const {} + INT_OP VecT operator&(VecT) const {} + INT_OP VecT operator|(VecT) const {} + INT_OP VecT operator^(VecT) const {} + + INT_OP VecT operator%=(VecT) const {} + INT_OP VecT operator&=(VecT) const {} + INT_OP VecT operator|=(VecT) const {} + INT_OP VecT operator^=(VecT) const {} + + INT_OP VecT operator%(T) const {} + INT_OP VecT operator&(T) const {} + INT_OP VecT operator|(T) const {} + INT_OP VecT operator^(T) const {} + + INT_OP VecT operator%=(T) const {} + INT_OP VecT operator&=(T) const {} + INT_OP VecT operator|=(T) const {} + INT_OP VecT operator^=(T) const {} + + INT_OP friend VecT operator%(T, VecT) {} + INT_OP friend VecT operator&(T, VecT) {} + INT_OP friend VecT operator|(T, VecT) {} + INT_OP friend VecT operator^(T, VecT) {} + +#undef INT_OP +}; + +template struct VecSwizzle2 { + static VecBase &xx, &xy, &yx, &yy; + static VecBase &xxx, &xxy, &xyx, &xyy, &yxx, &yxy, &yyx, &yyy; + static VecBase &xxxx, &xxxy, &xxyx, &xxyy, &xyxx, &xyxy, &xyyx, &xyyy, &yxxx, &yxxy, &yxyx, + &yxyy, &yyxx, &yyxy, &yyyx, &yyyy; +}; + +template struct ColSwizzle2 { + static VecBase &rr, &rg, &gr, ≫ + static VecBase &rrr, &rrg, &rgr, &rgg, &grr, &grg, &ggr, ⋙ + static VecBase &rrrr, &rrrg, &rrgr, &rrgg, &rgrr, &rgrg, &rggr, &rggg, &grrr, &grrg, &grgr, + &grgg, &ggrr, &ggrg, &gggr, &gggg; +}; + +template struct VecSwizzle3 : VecSwizzle2 { + static VecBase &xz, &yz, &zx, &zy, &zz, &zw; + static VecBase &xxz, &xyz, &xzx, &xzy, &xzz, &yxz, &yyz, &yzx, &yzy, &yzz, &zxx, &zxy, + &zxz, &zyx, &zyy, &zyz, &zzx, &zzy, &zzz; + static VecBase &xxxz, &xxyz, &xxzx, &xxzy, &xxzz, &xyxz, &xyyz, &xyzx, &xyzy, &xyzz, &xzxx, + &xzxy, &xzxz, &xzyx, &xzyy, &xzyz, &xzzx, &xzzy, &xzzz, &yxxz, &yxyz, &yxzx, &yxzy, &yxzz, + &yyxz, &yyyz, &yyzx, &yyzy, &yyzz, &yzxx, &yzxy, &yzxz, &yzyx, &yzyy, &yzyz, &yzzx, &yzzy, + &yzzz, &zxxx, &zxxy, &zxxz, &zxyx, &zxyy, &zxyz, &zxzx, &zxzy, &zxzz, &zyxx, &zyxy, &zyxz, + &zyyx, &zyyy, &zyyz, &zyzx, &zyzy, &zyzz, &zzxx, &zzxy, &zzxz, &zzyx, &zzyy, &zzyz, &zzzx, + &zzzy, &zzzz; +}; + +template struct ColSwizzle3 : ColSwizzle2 { + static VecBase &rb, &gb, &br, &bg, &bb, &bw; + static VecBase &rrb, &rgb, &rbr, &rbg, &rbb, &grb, &ggb, &gbr, &gbg, &gbb, &brr, &brg, + &brb, &bgr, &bgg, &bgb, &bbr, &bbg, &bbb; + static VecBase &rrrb, &rrgb, &rrbr, &rrbg, &rrbb, &rgrb, &rggb, &rgbr, &rgbg, &rgbb, &rbrr, + &rbrg, &rbrb, &rbgr, &rbgg, &rbgb, &rbbr, &rbbg, &rbbb, &grrb, &grgb, &grbr, &grbg, &grbb, + &ggrb, &gggb, &ggbr, &ggbg, &ggbb, &gbrr, &gbrg, &gbrb, &gbgr, &gbgg, &gbgb, &gbbr, &gbbg, + &gbbb, &brrr, &brrg, &brrb, &brgr, &brgg, &brgb, &brbr, &brbg, &brbb, &bgrr, &bgrg, &bgrb, + &bggr, &bggg, &bggb, &bgbr, &bgbg, &bgbb, &bbrr, &bbrg, &bbrb, &bbgr, &bbgg, &bbgb, &bbbr, + &bbbg, &bbbb; +}; + +template struct VecSwizzle4 : VecSwizzle3 { + static VecBase &xw, &yw, &wx, &wy, &wz, &ww; + static VecBase &xxw, &xyw, &xzw, &xwx, &xwy, &xwz, &xww, &yxw, &yyw, &yzw, &ywx, &ywy, + &ywz, &yww, &zxw, &zyw, &zzw, &zwx, &zwy, &zwz, &zww, &wxx, &wxy, &wxz, &wxw, &wyx, &wyy, + &wyz, &wyw, &wzx, &wzy, &wzz, &wzw, &wwx, &wwy, &wwz, &www; + static VecBase &xxxw, &xxyw, &xxzw, &xxwx, &xxwy, &xxwz, &xxww, &xyxw, &xyyw, &xyzw, &xywx, + &xywy, &xywz, &xyww, &xzxw, &xzyw, &xzzw, &xzwx, &xzwy, &xzwz, &xzww, &xwxx, &xwxy, &xwxz, + &xwxw, &xwyx, &xwyy, &xwyz, &xwyw, &xwzx, &xwzy, &xwzz, &xwzw, &xwwx, &xwwy, &xwwz, &xwww, + &yxxw, &yxyw, &yxzw, &yxwx, &yxwy, &yxwz, &yxww, &yyxw, &yyyw, &yyzw, &yywx, &yywy, &yywz, + &yyww, &yzxw, &yzyw, &yzzw, &yzwx, &yzwy, &yzwz, &yzww, &ywxx, &ywxy, &ywxz, &ywxw, &ywyx, + &ywyy, &ywyz, &ywyw, &ywzx, &ywzy, &ywzz, &ywzw, &ywwx, &ywwy, &ywwz, &ywww, &zxxw, &zxyw, + &zxzw, &zxwx, &zxwy, &zxwz, &zxww, &zyxw, &zyyw, &zyzw, &zywx, &zywy, &zywz, &zyww, &zzxw, + &zzyw, &zzzw, &zzwx, &zzwy, &zzwz, &zzww, &zwxx, &zwxy, &zwxz, &zwxw, &zwyx, &zwyy, &zwyz, + &zwyw, &zwzx, &zwzy, &zwzz, &zwzw, &zwwx, &zwwy, &zwwz, &zwww, &wxxx, &wxxy, &wxxz, &wxxw, + &wxyx, &wxyy, &wxyz, &wxyw, &wxzx, &wxzy, &wxzz, &wxzw, &wxwx, &wxwy, &wxwz, &wxww, &wyxx, + &wyxy, &wyxz, &wyxw, &wyyx, &wyyy, &wyyz, &wyyw, &wyzx, &wyzy, &wyzz, &wyzw, &wywx, &wywy, + &wywz, &wyww, &wzxx, &wzxy, &wzxz, &wzxw, &wzyx, &wzyy, &wzyz, &wzyw, &wzzx, &wzzy, &wzzz, + &wzzw, &wzwx, &wzwy, &wzwz, &wzww, &wwxx, &wwxy, &wwxz, &wwxw, &wwyx, &wwyy, &wwyz, &wwyw, + &wwzx, &wwzy, &wwzz, &wwzw, &wwwx, &wwwy, &wwwz, &wwww; +}; + +template struct ColSwizzle4 : ColSwizzle3 { + static VecBase &ra, &ga, &ar, &ag, &ab, &aa; + static VecBase &rra, &rga, &rba, &rar, &rag, &rab, &raa, &gra, &gga, &gba, &gar, &gag, + &gab, &gaa, &bra, &bga, &bba, &bar, &bag, &bab, &baa, &arr, &arg, &arb, &ara, &agr, &agg, + &agb, &aga, &abr, &abg, &abb, &aba, &aar, &aag, &aab, &aaa; + static VecBase &rrra, &rrga, &rrba, &rrar, &rrag, &rrab, &rraa, &rgra, &rgga, &rgba, &rgar, + &rgag, &rgab, &rgaa, &rbra, &rbga, &rbba, &rbar, &rbag, &rbab, &rbaa, &rarr, &rarg, &rarb, + &rara, &ragr, &ragg, &ragb, &raga, &rabr, &rabg, &rabb, &raba, &raar, &raag, &raab, &raaa, + &grra, &grga, &grba, &grar, &grag, &grab, &graa, &ggra, &ggga, &ggba, &ggar, &ggag, &ggab, + &ggaa, &gbra, &gbga, &gbba, &gbar, &gbag, &gbab, &gbaa, &garr, &garg, &garb, &gara, &gagr, + &gagg, &gagb, &gaga, &gabr, &gabg, &gabb, &gaba, &gaar, &gaag, &gaab, &gaaa, &brra, &brga, + &brba, &brar, &brag, &brab, &braa, &bgra, &bgga, &bgba, &bgar, &bgag, &bgab, &bgaa, &bbra, + &bbga, &bbba, &bbar, &bbag, &bbab, &bbaa, &barr, &barg, &barb, &bara, &bagr, &bagg, &bagb, + &baga, &babr, &babg, &babb, &baba, &baar, &baag, &baab, &baaa, &arrr, &arrg, &arrb, &arra, + &argr, &argg, &argb, &arga, &arbr, &arbg, &arbb, &arba, &arar, &arag, &arab, &araa, &agrr, + &agrg, &agrb, &agra, &aggr, &aggg, &aggb, &agga, &agbr, &agbg, &agbb, &agba, &agar, &agag, + &agab, &agaa, &abrr, &abrg, &abrb, &abra, &abgr, &abgg, &abgb, &abga, &abbr, &abbg, &abbb, + &abba, &abar, &abag, &abab, &abaa, &aarr, &aarg, &aarb, &aara, &aagr, &aagg, &aagb, &aaga, + &aabr, &aabg, &aabb, &aaba, &aaar, &aaag, &aaab, &aaaa; +}; + +template struct VecBase { + VecBase() = default; + template explicit VecBase(VecBase) {} + VecBase(T) {} + + operator T() {} +}; + +template struct VecBase : VecOp, VecSwizzle2, ColSwizzle2 { + T x, y; + T r, g; + + VecBase() = default; + template explicit VecBase(VecBase) {} + explicit VecBase(T) {} + explicit VecBase(T, T) {} +}; + +template struct VecBase : VecOp, VecSwizzle3, ColSwizzle3 { + T x, y, z; + T r, g, b; + + VecBase() = default; + template explicit VecBase(VecBase) {} + explicit VecBase(T) {} + explicit VecBase(T, T, T) {} + explicit VecBase(VecBase, T) {} + explicit VecBase(T, VecBase) {} +}; + +template struct VecBase : VecOp, VecSwizzle4, ColSwizzle4 { + T x, y, z, w; + T r, g, b, a; + + VecBase() = default; + template explicit VecBase(VecBase) {} + explicit VecBase(T) {} + explicit VecBase(T, T, T, T) {} + explicit VecBase(VecBase, T, T) {} + explicit VecBase(T, VecBase, T) {} + explicit VecBase(T, T, VecBase) {} + explicit VecBase(VecBase, VecBase) {} + explicit VecBase(VecBase, T) {} + explicit VecBase(T, VecBase) {} +}; + +/* Boolean vectors do not have operators and are not convertible from other types. */ + +template<> struct VecBase : VecSwizzle2 { + bool x, y; + + VecBase() = default; + explicit VecBase(bool) {} + explicit VecBase(bool, bool) {} +}; + +template<> struct VecBase : VecSwizzle3 { + bool x, y, z; + + VecBase() = default; + explicit VecBase(bool) {} + explicit VecBase(bool, bool, bool) {} + explicit VecBase(VecBase, bool) {} + explicit VecBase(bool, VecBase) {} +}; + +template<> struct VecBase : VecSwizzle4 { + bool x, y, z, w; + + VecBase() = default; + explicit VecBase(bool) {} + explicit VecBase(bool, bool, bool, bool) {} + explicit VecBase(VecBase, bool, bool) {} + explicit VecBase(bool, VecBase, bool) {} + explicit VecBase(bool, bool, VecBase) {} + explicit VecBase(VecBase, VecBase) {} + explicit VecBase(VecBase, bool) {} + explicit VecBase(bool, VecBase) {} +}; + +using uint = unsigned int; + +using float2 = VecBase; +using float3 = VecBase; +using float4 = VecBase; + +using uint2 = VecBase; +using uint3 = VecBase; +using uint4 = VecBase; + +using int2 = VecBase; +using int3 = VecBase; +using int4 = VecBase; + +using bool2 = VecBase; +using bool3 = VecBase; +using bool4 = VecBase; + +using vec2 = float2; +using vec3 = float3; +using vec4 = float4; + +using ivec2 = int2; +using ivec3 = int3; +using ivec4 = int4; + +using uvec2 = uint2; +using uvec3 = uint3; +using uvec4 = uint4; + +using bvec2 = bool2; +using bvec3 = bool3; +using bvec4 = bool4; + +using FLOAT = float; +using VEC2 = float2; +using VEC3 = float3; +using VEC4 = float4; + +using INT = int; +using IVEC2 = int2; +using IVEC3 = int3; +using IVEC4 = int4; + +using UINT = uint; +using UVEC2 = uint2; +using UVEC3 = uint3; +using UVEC4 = uint4; + +using BOOL = bool; +using BVEC2 = bool2; +using BVEC3 = bool3; +using BVEC4 = bool4; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Matrix Types + * \{ */ + +template struct MatBase {}; + +template struct MatOp { + using MatT = MatBase; + using ColT = VecBase; + using RowT = VecBase; + + ColT &operator[](int) {} + const ColT &operator[](int) const {} + + MatT operator*(MatT) const {} + + friend ColT operator*(RowT, MatT) {} + friend RowT operator*(MatT, ColT) {} +}; + +template struct MatBase<2, R> : MatOp<2, R> { + using T = double; + using ColT = VecBase; + ColT x, y; + + MatBase() = default; + explicit MatBase(T) {} + explicit MatBase(T, T, T, T) {} + explicit MatBase(ColT, ColT) {} + template explicit MatBase(const MatBase &) {} +}; + +template struct MatBase<3, R> : MatOp<3, R> { + using T = double; + using ColT = VecBase; + ColT x, y, z; + + MatBase() = default; + explicit MatBase(T) {} + explicit MatBase(T, T, T, T, T, T, T, T, T) {} + explicit MatBase(ColT, ColT, ColT) {} + template explicit MatBase(const MatBase &) {} +}; + +template struct MatBase<4, R> : MatOp<4, R> { + using T = double; + using ColT = VecBase; + ColT x, y, z, w; + + MatBase() = default; + explicit MatBase(T) {} + explicit MatBase(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) {} + explicit MatBase(ColT, ColT, ColT, ColT) {} + template explicit MatBase(const MatBase &) {} +}; + +using float2x2 = MatBase<2, 2>; +using float2x3 = MatBase<2, 3>; +using float2x4 = MatBase<2, 4>; +using float3x2 = MatBase<3, 2>; +using float3x3 = MatBase<3, 3>; +using float3x4 = MatBase<3, 4>; +using float4x2 = MatBase<4, 2>; +using float4x3 = MatBase<4, 3>; +using float4x4 = MatBase<4, 4>; + +using mat2x2 = float2x2; +using mat2x3 = float2x3; +using mat2x4 = float2x4; +using mat3x2 = float3x2; +using mat3x3 = float3x3; +using mat3x4 = float3x4; +using mat4x2 = float4x2; +using mat4x3 = float4x3; +using mat4x4 = float4x4; + +using mat2 = float2x2; +using mat3 = float3x3; +using mat4 = float4x4; + +using MAT4 = float4x4; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Sampler Types + * \{ */ + +template struct SamplerBase { + static constexpr int coord_dim = Dimensions + int(Cube) + int(Array); + static constexpr int deriv_dim = Dimensions + int(Cube); + static constexpr int extent_dim = Dimensions + int(Array); + + using int_coord_type = VecBase; + using flt_coord_type = VecBase; + using derivative_type = VecBase; + using data_vec_type = VecBase; + using size_vec_type = VecBase; +}; + +#define TEX_TEMPLATE \ + template + +TEX_TEMPLATE SizeVec textureSize(T, int) {} +TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) {} +TEX_TEMPLATE DataVec texelFetchOffset(T, IntCoord, int, IntCoord) {} +TEX_TEMPLATE DataVec texture(T, FltCoord, double bias = 0.0) {} +TEX_TEMPLATE DataVec textureGather(T, FltCoord) {} +TEX_TEMPLATE DataVec textureGrad(T, FltCoord, DerivVec, DerivVec) {} +TEX_TEMPLATE DataVec textureLod(T, FltCoord, double) {} + +#undef TEX_TEMPLATE + +using samplerBuffer = SamplerBase; +using sampler1D = SamplerBase; +using sampler2D = SamplerBase; +using sampler3D = SamplerBase; +using isamplerBuffer = SamplerBase; +using isampler1D = SamplerBase; +using isampler2D = SamplerBase; +using isampler3D = SamplerBase; +using usamplerBuffer = SamplerBase; +using usampler1D = SamplerBase; +using usampler2D = SamplerBase; +using usampler3D = SamplerBase; + +using sampler1DArray = SamplerBase; +using sampler2DArray = SamplerBase; +using isampler1DArray = SamplerBase; +using isampler2DArray = SamplerBase; +using usampler1DArray = SamplerBase; +using usampler2DArray = SamplerBase; + +using samplerCube = SamplerBase; +using isamplerCube = SamplerBase; +using usamplerCube = SamplerBase; + +using samplerCubeArray = SamplerBase; +using isamplerCubeArray = SamplerBase; +using usamplerCubeArray = SamplerBase; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Image Types + * \{ */ + +template struct ImageBase { + static constexpr int coord_dim = Dimensions + int(Array); + + using int_coord_type = VecBase; + using data_vec_type = VecBase; + using size_vec_type = VecBase; +}; + +#define IMG_TEMPLATE \ + template + +IMG_TEMPLATE SizeVec imageSize(T) {} +IMG_TEMPLATE DataVec imageLoad(T, IntCoord) {} +IMG_TEMPLATE void imageStore(T, IntCoord, DataVec) {} +IMG_TEMPLATE void imageFence(T) {} +#define imageLoadFast imageLoad +#define imageStoreFast imageStore + +IMG_TEMPLATE uint imageAtomicAdd(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicMin(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicMax(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicAnd(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicXor(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicExchange(T, IntCoord, uint); +IMG_TEMPLATE uint imageAtomicCompSwap(T, IntCoord, uint, uint); + +#undef IMG_TEMPLATE + +using image1D = ImageBase; +using image2D = ImageBase; +using image3D = ImageBase; +using iimage1D = ImageBase; +using iimage2D = ImageBase; +using iimage3D = ImageBase; +using uimage1D = ImageBase; +using uimage2D = ImageBase; +using uimage3D = ImageBase; + +using image1DArray = ImageBase; +using image2DArray = ImageBase; +using iimage1DArray = ImageBase; +using iimage2DArray = ImageBase; +using uimage1DArray = ImageBase; +using uimage2DArray = ImageBase; + +/* Forbid Cube and cube arrays. Bind them as 3D textures instead. */ + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Builtin Functions + * \{ */ + +/* Some compilers complain about lack of return values. Keep it short. */ +#define RET \ + { \ + return {}; \ + } + +template VecBase greaterThan(VecBase, VecBase) RET; +template VecBase lessThan(VecBase, VecBase) RET; +template VecBase lessThanEqual(VecBase, VecBase) RET; +template VecBase greaterThanEqual(VecBase, VecBase) RET; +template VecBase equal(VecBase, VecBase) RET; +template VecBase notEqual(VecBase, VecBase) RET; +template bool any(VecBase) RET; +template bool all(VecBase) RET; +/* `not` is a C++ keyword that aliases the `!` operator. Simply overload it. */ +template VecBase operator!(VecBase) RET; + +template VecBase bitCount(VecBase) RET; +template VecBase bitCount(VecBase) RET; +template VecBase bitfieldExtract(VecBase, int, int) RET; +template VecBase bitfieldExtract(VecBase, int, int) RET; +template VecBase bitfieldInsert(VecBase, VecBase, int, int) RET; +template VecBase bitfieldInsert(VecBase, VecBase, int, int) RET; +template VecBase bitfieldReverse(VecBase) RET; +template VecBase bitfieldReverse(VecBase) RET; +int bitCount(int) RET; +int bitCount(uint) RET; +int bitfieldExtract(int) RET; +int bitfieldExtract(uint) RET; +int bitfieldInsert(int) RET; +int bitfieldInsert(uint) RET; +int bitfieldReverse(int) RET; +int bitfieldReverse(uint) RET; + +template VecBase findLSB(VecBase) RET; +template VecBase findLSB(VecBase) RET; +template VecBase findMSB(VecBase) RET; +template VecBase findMSB(VecBase) RET; +int findMSB(int) RET; +int findMSB(uint) RET; + +/* Math Functions. */ +template T abs(T) RET; +template T clamp(T, T, T) RET; +template T max(T, T) RET; +template T min(T, T) RET; +template T sign(T) RET; +template T clamp(T, U, U) RET; +template T max(T, U) RET; +template T min(T, U) RET; +/* TODO(fclem): These should be restricted to floats. */ +template T ceil(T) RET; +template T exp(T) RET; +template T exp2(T) RET; +template T floor(T) RET; +template T fma(T, T, T) RET; +template T fract(T) RET; +template T frexp(T, T) RET; +template T inversesqrt(T) RET; +template T isinf(T) RET; +template T isnan(T) RET; +template T log(T) RET; +template T log2(T) RET; +template T mod(T, double); +template T mod(T, T); +template T modf(T, T); +template T pow(T, T) RET; +template T round(T) RET; +template T smoothstep(T, T, T) RET; +template T sqrt(T) RET; +template T step(T) RET; +template T trunc(T) RET; +template T ldexp(T, U) RET; +double smoothstep(double, double, double) RET; + +template T acos(T) RET; +template T acosh(T) RET; +template T asin(T) RET; +template T asinh(T) RET; +template T atan(T, T) RET; +template T atan(T) RET; +template T atanh(T) RET; +template T cos(T) RET; +template T cosh(T) RET; +template T sin(T) RET; +template T sinh(T) RET; +template T tan(T) RET; +template T tanh(T) RET; + +template T degrees(T) RET; +template T radians(T) RET; + +/* Declared explicitely to avoid type errors. */ +double mix(double, double, double) RET; +template VecBase mix(VecBase, VecBase, double) RET; +template VecBase mix(VecBase, VecBase, VecBase) RET; + +#define select(A, B, C) mix(A, B, C) + +VecBase cross(VecBase, VecBase) RET; +template float dot(VecBase, VecBase) RET; +template float distance(VecBase, VecBase) RET; +template float length(VecBase) RET; +template VecBase normalize(VecBase) RET; + +template VecBase floatBitsToInt(VecBase) RET; +template VecBase floatBitsToUint(VecBase) RET; +template VecBase intBitsToFloat(VecBase) RET; +template VecBase uintBitsToFloat(VecBase) RET; +int floatBitsToInt(double) RET; +uint floatBitsToUint(double) RET; +double intBitsToFloat(int) RET; +double uintBitsToFloat(uint) RET; + +namespace gl_FragmentShader { +/* Derivative functions. */ +template T dFdx(T) RET; +template T dFdy(T) RET; +template T fwidth(T) RET; +} // namespace gl_FragmentShader + +/* Geometric functions. */ +template float faceforward(VecBase, VecBase, VecBase) RET; +template float reflect(VecBase, VecBase) RET; +template float refract(VecBase, VecBase, double) RET; + +/* Atomic operations. */ +int atomicAdd(int &, int) RET; +int atomicAnd(int &, int) RET; +int atomicOr(int &, int) RET; +int atomicXor(int &, int) RET; +int atomicMin(int &, int) RET; +int atomicMax(int &, int) RET; +int atomicExchange(int &, int) RET; +int atomicCompSwap(int &, int, int) RET; +uint atomicAdd(uint &, uint) RET; +uint atomicAnd(uint &, uint) RET; +uint atomicOr(uint &, uint) RET; +uint atomicXor(uint &, uint) RET; +uint atomicMin(uint &, uint) RET; +uint atomicMax(uint &, uint) RET; +uint atomicExchange(uint &, uint) RET; +uint atomicCompSwap(uint &, uint, uint) RET; + +/* Packing functions. */ +uint packHalf2x16(float2) RET; +uint packUnorm2x16(float2) RET; +uint packSnorm2x16(float2) RET; +uint packUnorm4x8(float4) RET; +uint packSnorm4x8(float4) RET; +float2 unpackHalf2x16(uint) RET; +float2 unpackUnorm2x16(uint) RET; +float2 unpackSnorm2x16(uint) RET; +float4 unpackUnorm4x8(uint) RET; +float4 unpackSnorm4x8(uint) RET; + +/* Matrices functions. */ +template float determinant(MatBase) RET; +template MatBase inverse(MatBase) RET; +template MatBase transpose(MatBase) RET; + +/* TODO(fclem): Should be in a lib instead of being impemented by each backend. */ +bool is_zero(vec2) RET; +bool is_zero(vec3) RET; +bool is_zero(vec4) RET; + +#undef RET + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Special Variables + * \{ */ + +namespace gl_VertexShader { + +const int gl_VertexID = 0; +const int gl_InstanceID = 0; +const int gl_BaseVertex = 0; +const int gl_BaseInstance = 0; +float4 gl_Position = float4(0); +double gl_PointSize = 0; +float gl_ClipDistance[6] = {0}; +int gpu_Layer = 0; +int gpu_ViewportIndex = 0; + +} // namespace gl_VertexShader + +namespace gl_FragmentShader { + +const float4 gl_FragCoord = float4(0); +const bool gl_FrontFacing = true; +const float2 gl_PointCoord = float2(0); +const int gl_PrimitiveID = 0; +float gl_FragDepth = 0; +const float gl_ClipDistance[6] = {0}; +const int gpu_Layer = 0; +const int gpu_ViewportIndex = 0; + +} // namespace gl_FragmentShader + +namespace gl_ComputeShader { + +const uint3 gl_NumWorkGroups; +constexpr uint3 gl_WorkGroupSize; +const uint3 gl_WorkGroupID; +const uint3 gl_LocalInvocationID; +const uint3 gl_GlobalInvocationID; +const uint gl_LocalInvocationIndex; + +} // namespace gl_ComputeShader + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Keywords + * \{ */ + +/* Note: Cannot easily mutate them. Pass every by copy for now. */ + +/* Pass argument by reference. */ +#define inout +/* Pass argument by reference but only write to it. Its initial value is undefined. */ +#define out +/* Pass argument by copy (default). */ +#define in + +/* Discards the output of the current fragment shader invocation and halts its execution. */ +#define discard + +/* Decorate a variable in global scope that is common to all threads in a threadgroup. */ +#define shared + +namespace gl_ComputeShader { +void barrier() {} +void memoryBarrier() {} +void memoryBarrierShared() {} +void memoryBarrierImage() {} +void memoryBarrierBuffer() {} +void groupMemoryBarrier() {} +} // namespace gl_ComputeShader + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Compatibility + * \{ */ + +/* 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__ } +/* clang-format on */ + +/** \} */ + +#define GLSL_CPP_STUBS + +/* Include all shader shared files to that custom type definitions are available when create infos + * macros are included. Include them here so that only including this file is needed. */ +#include "GPU_shader_shared.hh" +#include "draw_common_shader_shared.hh" +#include "draw_shader_shared.hh" +#include "eevee_shader_shared.hh" +#include "overlay_shader_shared.h" +#include "select_shader_shared.hh" +#include "workbench_shader_shared.h" + +/* Include all create infos here so that they don't need to be individually included + * inside shaders. */ +#include "draw_debug_info.hh" +#include "draw_fullscreen_info.hh" +#include "draw_hair_refine_info.hh" +#include "draw_object_infos_info.hh" +#include "draw_view_info.hh" +#include "infos/basic_depth_info.hh" +#include "infos/compositor_alpha_crop_info.hh" +#include "infos/compositor_bilateral_blur_info.hh" +#include "infos/compositor_bokeh_blur_info.hh" +#include "infos/compositor_bokeh_blur_variable_size_info.hh" +#include "infos/compositor_bokeh_image_info.hh" +#include "infos/compositor_box_mask_info.hh" +#include "infos/compositor_compute_preview_info.hh" +#include "infos/compositor_convert_info.hh" +#include "infos/compositor_cryptomatte_info.hh" +#include "infos/compositor_defocus_info.hh" +#include "infos/compositor_deriche_gaussian_blur_info.hh" +#include "infos/compositor_despeckle_info.hh" +#include "infos/compositor_directional_blur_info.hh" +#include "infos/compositor_displace_info.hh" +#include "infos/compositor_double_edge_mask_info.hh" +#include "infos/compositor_edge_filter_info.hh" +#include "infos/compositor_ellipse_mask_info.hh" +#include "infos/compositor_filter_info.hh" +#include "infos/compositor_flip_info.hh" +#include "infos/compositor_glare_info.hh" +#include "infos/compositor_id_mask_info.hh" +#include "infos/compositor_image_crop_info.hh" +#include "infos/compositor_inpaint_info.hh" +#include "infos/compositor_jump_flooding_info.hh" +#include "infos/compositor_keying_info.hh" +#include "infos/compositor_keying_screen_info.hh" +#include "infos/compositor_kuwahara_info.hh" +#include "infos/compositor_map_uv_info.hh" +#include "infos/compositor_morphological_blur_info.hh" +#include "infos/compositor_morphological_distance_feather_info.hh" +#include "infos/compositor_morphological_distance_info.hh" +#include "infos/compositor_morphological_distance_threshold_info.hh" +#include "infos/compositor_morphological_step_info.hh" +#include "infos/compositor_motion_blur_info.hh" +#include "infos/compositor_movie_distortion_info.hh" +#include "infos/compositor_normalize_info.hh" +#include "infos/compositor_parallel_reduction_info.hh" +#include "infos/compositor_pixelate_info.hh" +#include "infos/compositor_plane_deform_info.hh" +#include "infos/compositor_premultiply_alpha_info.hh" +#include "infos/compositor_projector_lens_distortion_info.hh" +#include "infos/compositor_read_input_info.hh" +#include "infos/compositor_realize_on_domain_info.hh" +#include "infos/compositor_scale_variable_info.hh" +#include "infos/compositor_screen_lens_distortion_info.hh" +#include "infos/compositor_smaa_info.hh" +#include "infos/compositor_split_info.hh" +#include "infos/compositor_summed_area_table_info.hh" +#include "infos/compositor_sun_beams_info.hh" +#include "infos/compositor_symmetric_blur_info.hh" +#include "infos/compositor_symmetric_blur_variable_size_info.hh" +#include "infos/compositor_symmetric_separable_blur_info.hh" +#include "infos/compositor_symmetric_separable_blur_variable_size_info.hh" +#include "infos/compositor_tone_map_photoreceptor_info.hh" +#include "infos/compositor_tone_map_simple_info.hh" +#include "infos/compositor_van_vliet_gaussian_blur_info.hh" +#include "infos/compositor_write_output_info.hh" +#include "infos/compositor_z_combine_info.hh" +#include "infos/eevee_ambient_occlusion_info.hh" +#include "infos/eevee_deferred_info.hh" +#include "infos/eevee_depth_of_field_info.hh" +#include "infos/eevee_film_info.hh" +#include "infos/eevee_hiz_info.hh" +#include "infos/eevee_light_culling_info.hh" +#include "infos/eevee_lightprobe_sphere_info.hh" +#include "infos/eevee_lightprobe_volume_info.hh" +#include "infos/eevee_lookdev_info.hh" +#include "infos/eevee_lut_info.hh" +#include "infos/eevee_material_info.hh" +#include "infos/eevee_motion_blur_info.hh" +#include "infos/eevee_shadow_info.hh" +#include "infos/eevee_subsurface_info.hh" +#include "infos/eevee_tracing_info.hh" +#include "infos/eevee_velocity_info.hh" +#include "infos/eevee_volume_info.hh" +#include "infos/engine_image_info.hh" +#include "infos/gpencil_info.hh" +#include "infos/gpencil_vfx_info.hh" +#include "infos/gpu_clip_planes_info.hh" +#include "infos/gpu_index_load_info.hh" +#include "infos/gpu_shader_2D_area_borders_info.hh" +#include "infos/gpu_shader_2D_checker_info.hh" +#include "infos/gpu_shader_2D_diag_stripes_info.hh" +#include "infos/gpu_shader_2D_image_desaturate_color_info.hh" +#include "infos/gpu_shader_2D_image_info.hh" +#include "infos/gpu_shader_2D_image_overlays_merge_info.hh" +#include "infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh" +#include "infos/gpu_shader_2D_image_rect_color_info.hh" +#include "infos/gpu_shader_2D_image_shuffle_color_info.hh" +#include "infos/gpu_shader_2D_nodelink_info.hh" +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh" +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh" +#include "infos/gpu_shader_2D_point_varying_size_varying_color_info.hh" +#include "infos/gpu_shader_2D_widget_info.hh" +#include "infos/gpu_shader_3D_depth_only_info.hh" +#include "infos/gpu_shader_3D_flat_color_info.hh" +#include "infos/gpu_shader_3D_image_info.hh" +#include "infos/gpu_shader_3D_point_info.hh" +#include "infos/gpu_shader_3D_polyline_info.hh" +#include "infos/gpu_shader_3D_smooth_color_info.hh" +#include "infos/gpu_shader_3D_uniform_color_info.hh" +#include "infos/gpu_shader_gpencil_stroke_info.hh" +#include "infos/gpu_shader_icon_info.hh" +#include "infos/gpu_shader_index_info.hh" +#include "infos/gpu_shader_instance_varying_color_varying_size_info.hh" +#include "infos/gpu_shader_keyframe_shape_info.hh" +#include "infos/gpu_shader_line_dashed_uniform_color_info.hh" +#include "infos/gpu_shader_print_info.hh" +#include "infos/gpu_shader_sequencer_info.hh" +#include "infos/gpu_shader_simple_lighting_info.hh" +#include "infos/gpu_shader_text_info.hh" +#include "infos/gpu_srgb_to_framebuffer_space_info.hh" +#include "infos/overlay_antialiasing_info.hh" +#include "infos/overlay_armature_info.hh" +#include "infos/overlay_background_info.hh" +#include "infos/overlay_edit_mode_info.hh" +#include "infos/overlay_extra_info.hh" +#include "infos/overlay_facing_info.hh" +#include "infos/overlay_grid_info.hh" +#include "infos/overlay_outline_info.hh" +#include "infos/overlay_paint_info.hh" +#include "infos/overlay_sculpt_curves_info.hh" +#include "infos/overlay_sculpt_info.hh" +#include "infos/overlay_viewer_attribute_info.hh" +#include "infos/overlay_volume_info.hh" +#include "infos/overlay_wireframe_info.hh" +#include "infos/select_id_info.hh" +#include "infos/workbench_composite_info.hh" +#include "infos/workbench_depth_info.hh" +#include "infos/workbench_effect_antialiasing_info.hh" +#include "infos/workbench_effect_dof_info.hh" +#include "infos/workbench_effect_outline_info.hh" +#include "infos/workbench_prepass_info.hh" +#include "infos/workbench_shadow_info.hh" +#include "infos/workbench_transparent_resolve_info.hh" +#include "infos/workbench_volume_info.hh" diff --git a/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl b/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl index 1a5c80c8341..ebdd5247698 100644 --- a/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl @@ -10,6 +10,10 @@ * the rounded corner, and the rectangle sides. */ +#include "gpu_glsl_cpp_stubs.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_icon) + void main() { /* Sample texture with LOD BIAS. Used instead of custom LOD bias in GPU_SAMPLER_CUSTOM_ICON. */ diff --git a/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl b/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl index 8250a0181b9..537fcba28e9 100644 --- a/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl @@ -7,6 +7,10 @@ * does not need any vertex input (producing less call to immBegin/End) */ +#include "gpu_glsl_cpp_stubs.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_icon) + void main() { vec2 uv; diff --git a/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh index ef116419f45..9462e50c213 100644 --- a/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh @@ -9,6 +9,7 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_clip_planes) - .uniform_buf(1, "GPUClipPlanes", "clipPlanes", Frequency::PASS) - .typedef_source("GPU_shader_shared.hh") - .define("USE_WORLD_CLIP_PLANES"); +UNIFORM_BUF_FREQ(1, GPUClipPlanes, clipPlanes, PASS) +TYPEDEF_SOURCE("GPU_shader_shared.hh") +DEFINE("USE_WORLD_CLIP_PLANES") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_index_load_info.hh b/source/blender/gpu/shaders/infos/gpu_index_load_info.hh index ce73be6691a..fc189f9863d 100644 --- a/source/blender/gpu/shaders/infos/gpu_index_load_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_index_load_info.hh @@ -11,9 +11,9 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_index_load) - .push_constant(Type::BOOL, "gpu_index_no_buffer") - .push_constant(Type::BOOL, "gpu_index_16bit") - .push_constant(Type::INT, "gpu_index_base_index") - .storage_buf( - GPU_SSBO_INDEX_BUF_SLOT, Qualifier::READ, "uint", "gpu_index_buf[]", Frequency::GEOMETRY) - .define("GPU_INDEX_LOAD"); +PUSH_CONSTANT(BOOL, gpu_index_no_buffer) +PUSH_CONSTANT(BOOL, gpu_index_16bit) +PUSH_CONSTANT(INT, gpu_index_base_index) +STORAGE_BUF_FREQ(GPU_SSBO_INDEX_BUF_SLOT, READ, uint, gpu_index_buf[], GEOMETRY) +DEFINE("GPU_INDEX_LOAD") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_interface_info.hh b/source/blender/gpu/shaders/infos/gpu_interface_info.hh index 8b53f08dabb..0b021d472c0 100644 --- a/source/blender/gpu/shaders/infos/gpu_interface_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_interface_info.hh @@ -10,15 +10,36 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(flat_color_iface, "").flat(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(no_perspective_color_iface, "").no_perspective(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(smooth_color_iface, "").smooth(Type::VEC4, "finalColor"); -GPU_SHADER_INTERFACE_INFO(smooth_tex_coord_interp_iface, "").smooth(Type::VEC2, "texCoord_interp"); -GPU_SHADER_INTERFACE_INFO(smooth_radii_iface, "").smooth(Type::VEC2, "radii"); -GPU_SHADER_INTERFACE_INFO(smooth_radii_outline_iface, "").smooth(Type::VEC4, "radii"); -GPU_SHADER_INTERFACE_INFO(flat_color_smooth_tex_coord_interp_iface, "") - .flat(Type::VEC4, "finalColor") - .smooth(Type::VEC2, "texCoord_interp"); -GPU_SHADER_INTERFACE_INFO(smooth_icon_interp_iface, "") - .smooth(Type::VEC2, "texCoord_interp") - .smooth(Type::VEC2, "mask_coord_interp"); +GPU_SHADER_INTERFACE_INFO(flat_color_iface) +FLAT(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(no_perspective_color_iface) +NO_PERSPECTIVE(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(smooth_color_iface) +SMOOTH(VEC4, finalColor) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(smooth_tex_coord_interp_iface) +SMOOTH(VEC2, texCoord_interp) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(smooth_radii_iface) +SMOOTH(VEC2, radii) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(smooth_radii_outline_iface) +SMOOTH(VEC4, radii) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(flat_color_smooth_tex_coord_interp_iface) +FLAT(VEC4, finalColor) +SMOOTH(VEC2, texCoord_interp) +GPU_SHADER_INTERFACE_END() + +GPU_SHADER_INTERFACE_INFO(smooth_icon_interp_iface) +SMOOTH(VEC2, texCoord_interp) +SMOOTH(VEC2, mask_coord_interp) +GPU_SHADER_INTERFACE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh index 2e8c30ba2d2..c53229e3127 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh @@ -8,17 +8,20 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(smooth_uv_iface, "").smooth(Type::VEC2, "uv"); +GPU_SHADER_INTERFACE_INFO(smooth_uv_iface) +SMOOTH(VEC2, uv) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_area_borders) - .vertex_in(0, Type::VEC2, "pos") - .vertex_out(smooth_uv_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "rect") - .push_constant(Type::VEC4, "color") - .push_constant(Type::FLOAT, "scale") - .push_constant(Type::INT, "cornerLen") - .vertex_source("gpu_shader_2D_area_borders_vert.glsl") - .fragment_source("gpu_shader_2D_area_borders_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_OUT(smooth_uv_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, rect) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(FLOAT, scale) +PUSH_CONSTANT(INT, cornerLen) +VERTEX_SOURCE("gpu_shader_2D_area_borders_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_area_borders_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh index 42303fdf51a..84e82a7c3fa 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh @@ -9,12 +9,13 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_checker) - .vertex_in(0, Type::VEC2, "pos") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color1") - .push_constant(Type::VEC4, "color2") - .push_constant(Type::INT, "size") - .vertex_source("gpu_shader_2D_vert.glsl") - .fragment_source("gpu_shader_checker_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color1) +PUSH_CONSTANT(VEC4, color2) +PUSH_CONSTANT(INT, size) +VERTEX_SOURCE("gpu_shader_2D_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_checker_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh index 89e7e20e4c7..53ef9b3ec3b 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh @@ -9,13 +9,14 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_diag_stripes) - .vertex_in(0, Type::VEC2, "pos") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color1") - .push_constant(Type::VEC4, "color2") - .push_constant(Type::INT, "size1") - .push_constant(Type::INT, "size2") - .vertex_source("gpu_shader_2D_vert.glsl") - .fragment_source("gpu_shader_diag_stripes_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color1) +PUSH_CONSTANT(VEC4, color2) +PUSH_CONSTANT(INT, size1) +PUSH_CONSTANT(INT, size2) +VERTEX_SOURCE("gpu_shader_2D_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_diag_stripes_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh index cfa9ae9641e..4cded825133 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh @@ -9,8 +9,9 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_desaturate_color) - .additional_info("gpu_shader_2D_image_common") - .push_constant(Type::VEC4, "color") - .push_constant(Type::FLOAT, "factor") - .fragment_source("gpu_shader_image_desaturate_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_2D_image_common) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(FLOAT, factor) +FRAGMENT_SOURCE("gpu_shader_image_desaturate_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh index a3b1d8006e7..7bfafb4d2b5 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh @@ -10,10 +10,11 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_common) - .vertex_in(0, Type::VEC2, "pos") - .vertex_in(1, Type::VEC2, "texCoord") - .vertex_out(smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .sampler(0, ImageType::FLOAT_2D, "image") - .vertex_source("gpu_shader_2D_image_vert.glsl"); +VERTEX_IN(0, VEC2, pos) +VERTEX_IN(1, VEC2, texCoord) +VERTEX_OUT(smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +SAMPLER(0, FLOAT_2D, image) +VERTEX_SOURCE("gpu_shader_2D_image_vert.glsl") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh index 2720f745822..230719e268f 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh @@ -10,29 +10,31 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge) - .vertex_in(0, Type::VEC2, "pos") - .vertex_in(1, Type::VEC2, "texCoord") - .vertex_out(smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::BOOL, "display_transform") - .push_constant(Type::BOOL, "overlay") - .push_constant(Type::BOOL, "use_hdr") - /* Sampler slots should match OCIO's. */ - .sampler(0, ImageType::FLOAT_2D, "image_texture") - .sampler(1, ImageType::FLOAT_2D, "overlays_texture") - .vertex_source("gpu_shader_2D_image_vert.glsl") - .fragment_source("gpu_shader_image_overlays_merge_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_IN(1, VEC2, texCoord) +VERTEX_OUT(smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(BOOL, display_transform) +PUSH_CONSTANT(BOOL, overlay) +PUSH_CONSTANT(BOOL, use_hdr) +/* Sampler slots should match OCIO's. */ +SAMPLER(0, FLOAT_2D, image_texture) +SAMPLER(1, FLOAT_2D, overlays_texture) +VERTEX_SOURCE("gpu_shader_2D_image_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_image_overlays_merge_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Cycles display driver fallback shader. */ GPU_SHADER_CREATE_INFO(gpu_shader_cycles_display_fallback) - .vertex_in(0, Type::VEC2, "pos") - .vertex_in(1, Type::VEC2, "texCoord") - .vertex_out(smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::VEC2, "fullscreen") - .sampler(0, ImageType::FLOAT_2D, "image_texture") - .vertex_source("gpu_shader_display_fallback_vert.glsl") - .fragment_source("gpu_shader_display_fallback_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_IN(1, VEC2, texCoord) +VERTEX_OUT(smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(VEC2, fullscreen) +SAMPLER(0, FLOAT_2D, image_texture) +VERTEX_SOURCE("gpu_shader_display_fallback_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_display_fallback_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh index 314b535d254..435efcba121 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh @@ -9,13 +9,14 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_stereo_merge) - .vertex_in(0, Type::VEC2, "pos") - .fragment_out(0, Type::VEC4, "overlayColor") - .fragment_out(1, Type::VEC4, "imageColor") - .sampler(0, ImageType::FLOAT_2D, "imageTexture") - .sampler(1, ImageType::FLOAT_2D, "overlayTexture") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::INT, "stereoDisplaySettings") - .vertex_source("gpu_shader_2D_vert.glsl") - .fragment_source("gpu_shader_image_overlays_stereo_merge_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +FRAGMENT_OUT(0, VEC4, overlayColor) +FRAGMENT_OUT(1, VEC4, imageColor) +SAMPLER(0, FLOAT_2D, imageTexture) +SAMPLER(1, FLOAT_2D, overlayTexture) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(INT, stereoDisplaySettings) +VERTEX_SOURCE("gpu_shader_2D_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_image_overlays_stereo_merge_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh index a472e9bbb3a..42e863bca1e 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh @@ -10,13 +10,14 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_rect_color) - .vertex_out(smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - .push_constant(Type::VEC4, "rect_icon") - .push_constant(Type::VEC4, "rect_geom") - .sampler(0, ImageType::FLOAT_2D, "image") - .vertex_source("gpu_shader_2D_image_rect_vert.glsl") - .fragment_source("gpu_shader_image_color_frag.glsl") - .do_static_compilation(true); +VERTEX_OUT(smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(VEC4, rect_icon) +PUSH_CONSTANT(VEC4, rect_geom) +SAMPLER(0, FLOAT_2D, image) +VERTEX_SOURCE("gpu_shader_2D_image_rect_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_image_color_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh index 146d4ff2570..13c28ae0b44 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh @@ -9,8 +9,9 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_shuffle_color) - .additional_info("gpu_shader_2D_image_common") - .push_constant(Type::VEC4, "color") - .push_constant(Type::VEC4, "shuffle") - .fragment_source("gpu_shader_image_shuffle_color_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_2D_image_common) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(VEC4, shuffle) +FRAGMENT_SOURCE("gpu_shader_image_shuffle_color_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh index 4b434d4edc2..c63d32f1038 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh @@ -8,53 +8,56 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(nodelink_iface, "") - .smooth(Type::VEC4, "finalColor") - .smooth(Type::VEC2, "lineUV") - .flat(Type::FLOAT, "lineLength") - .flat(Type::FLOAT, "lineThickness") - .flat(Type::FLOAT, "dashLength") - .flat(Type::FLOAT, "dashFactor") - .flat(Type::INT, "hasBackLink") - .flat(Type::FLOAT, "dashAlpha") - .flat(Type::INT, "isMainLine") - .flat(Type::FLOAT, "aspect"); +GPU_SHADER_INTERFACE_INFO(nodelink_iface) +SMOOTH(VEC4, finalColor) +SMOOTH(VEC2, lineUV) +FLAT(FLOAT, lineLength) +FLAT(FLOAT, lineThickness) +FLAT(FLOAT, dashLength) +FLAT(FLOAT, dashFactor) +FLAT(INT, hasBackLink) +FLAT(FLOAT, dashAlpha) +FLAT(INT, isMainLine) +FLAT(FLOAT, aspect) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_nodelink) - .vertex_in(0, Type::VEC2, "uv") - .vertex_in(1, Type::VEC2, "pos") - .vertex_in(2, Type::VEC2, "expand") - .vertex_out(nodelink_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .uniform_buf(0, "NodeLinkData", "node_link_data", Frequency::PASS) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_2D_nodelink_vert.glsl") - .fragment_source("gpu_shader_2D_nodelink_frag.glsl") - .typedef_source("GPU_shader_shared.hh") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, uv) +VERTEX_IN(1, VEC2, pos) +VERTEX_IN(2, VEC2, expand) +VERTEX_OUT(nodelink_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +UNIFORM_BUF_FREQ(0, NodeLinkData, node_link_data, PASS) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_2D_nodelink_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_nodelink_frag.glsl") +TYPEDEF_SOURCE("GPU_shader_shared.hh") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_nodelink_inst) - .vertex_in(0, Type::VEC2, "uv") - .vertex_in(1, Type::VEC2, "pos") - .vertex_in(2, Type::VEC2, "expand") - .vertex_in(3, Type::VEC2, "P0") - .vertex_in(4, Type::VEC2, "P1") - .vertex_in(5, Type::VEC2, "P2") - .vertex_in(6, Type::VEC2, "P3") - .vertex_in(7, Type::UVEC4, "colid_doarrow") - .vertex_in(8, Type::VEC4, "start_color") - .vertex_in(9, Type::VEC4, "end_color") - .vertex_in(10, Type::UVEC2, "domuted") - .vertex_in(11, Type::FLOAT, "dim_factor") - .vertex_in(12, Type::FLOAT, "thickness") - .vertex_in(13, Type::VEC3, "dash_params") - .vertex_in(14, Type::INT, "has_back_link") - .vertex_out(nodelink_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .uniform_buf(0, "NodeLinkInstanceData", "node_link_data", Frequency::PASS) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_2D_nodelink_vert.glsl") - .fragment_source("gpu_shader_2D_nodelink_frag.glsl") - .typedef_source("GPU_shader_shared.hh") - .define("USE_INSTANCE") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, uv) +VERTEX_IN(1, VEC2, pos) +VERTEX_IN(2, VEC2, expand) +VERTEX_IN(3, VEC2, P0) +VERTEX_IN(4, VEC2, P1) +VERTEX_IN(5, VEC2, P2) +VERTEX_IN(6, VEC2, P3) +VERTEX_IN(7, UVEC4, colid_doarrow) +VERTEX_IN(8, VEC4, start_color) +VERTEX_IN(9, VEC4, end_color) +VERTEX_IN(10, UVEC2, domuted) +VERTEX_IN(11, FLOAT, dim_factor) +VERTEX_IN(12, FLOAT, thickness) +VERTEX_IN(13, VEC3, dash_params) +VERTEX_IN(14, INT, has_back_link) +VERTEX_OUT(nodelink_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +UNIFORM_BUF_FREQ(0, NodeLinkInstanceData, node_link_data, PASS) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_2D_nodelink_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_nodelink_frag.glsl") +TYPEDEF_SOURCE("GPU_shader_shared.hh") +DEFINE("USE_INSTANCE") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh index b2592296eb2..73da34416b0 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh @@ -10,13 +10,14 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_aa) - .vertex_in(0, Type::VEC2, "pos") - .vertex_out(smooth_radii_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - .push_constant(Type::FLOAT, "size") - .vertex_source("gpu_shader_2D_point_uniform_size_aa_vert.glsl") - .fragment_source("gpu_shader_point_uniform_color_aa_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_OUT(smooth_radii_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(FLOAT, size) +VERTEX_SOURCE("gpu_shader_2D_point_uniform_size_aa_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_point_uniform_color_aa_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh index c99c89dba31..9b4c549eacb 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh @@ -10,14 +10,15 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_outline_aa) - .vertex_in(0, Type::VEC2, "pos") - .vertex_out(smooth_radii_outline_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - .push_constant(Type::VEC4, "outlineColor") - .push_constant(Type::FLOAT, "size") - .push_constant(Type::FLOAT, "outlineWidth") - .vertex_source("gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl") - .fragment_source("gpu_shader_point_uniform_color_outline_aa_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_OUT(smooth_radii_outline_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(VEC4, outlineColor) +PUSH_CONSTANT(FLOAT, size) +PUSH_CONSTANT(FLOAT, outlineWidth) +VERTEX_SOURCE("gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_point_uniform_color_outline_aa_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh index 5578a987ec0..582af0f1d20 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh @@ -10,12 +10,13 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_varying_size_varying_color) - .vertex_in(0, Type::VEC2, "pos") - .vertex_in(1, Type::FLOAT, "size") - .vertex_in(2, Type::VEC4, "color") - .vertex_out(smooth_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_2D_point_varying_size_varying_color_vert.glsl") - .fragment_source("gpu_shader_point_varying_color_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_IN(1, FLOAT, size) +VERTEX_IN(2, VEC4, color) +VERTEX_OUT(smooth_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_2D_point_varying_size_varying_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_point_varying_color_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh index b7cd0419807..4375d4cc22e 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh @@ -9,57 +9,63 @@ #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(gpu_widget_iface, "") - .flat(Type::FLOAT, "discardFac") - .flat(Type::FLOAT, "lineWidth") - .flat(Type::VEC2, "outRectSize") - .flat(Type::VEC4, "borderColor") - .flat(Type::VEC4, "embossColor") - .flat(Type::VEC4, "outRoundCorners") - .no_perspective(Type::FLOAT, "butCo") - .no_perspective(Type::VEC2, "uvInterp") - .no_perspective(Type::VEC4, "innerColor"); +GPU_SHADER_INTERFACE_INFO(gpu_widget_iface) +FLAT(FLOAT, discardFac) +FLAT(FLOAT, lineWidth) +FLAT(VEC2, outRectSize) +FLAT(VEC4, borderColor) +FLAT(VEC4, embossColor) +FLAT(VEC4, outRoundCorners) +NO_PERSPECTIVE(FLOAT, butCo) +NO_PERSPECTIVE(VEC2, uvInterp) +NO_PERSPECTIVE(VEC4, innerColor) +GPU_SHADER_INTERFACE_END() /* TODO(fclem): Share with C code. */ #define MAX_PARAM 12 #define MAX_INSTANCE 6 GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_shared) - .define("MAX_PARAM", STRINGIFY(MAX_PARAM)) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC3, "checkerColorAndSize") - .vertex_out(gpu_widget_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("gpu_shader_2D_widget_base_vert.glsl") - .fragment_source("gpu_shader_2D_widget_base_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space"); +DEFINE_VALUE("MAX_PARAM", STRINGIFY(MAX_PARAM)) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC3, checkerColorAndSize) +VERTEX_OUT(gpu_widget_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("gpu_shader_2D_widget_base_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_widget_base_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_base) - .do_static_compilation(true) - /* gl_InstanceID is supposed to be 0 if not drawing instances, but this seems - * to be violated in some drivers. For example, macOS 10.15.4 and Intel Iris - * causes #78307 when using gl_InstanceID outside of instance. */ - .define("widgetID", "0") - .push_constant(Type::VEC4, "parameters", MAX_PARAM) - .additional_info("gpu_shader_2D_widget_shared"); +DO_STATIC_COMPILATION() +/* gl_InstanceID is supposed to be 0 if not drawing instances, but this seems + * to be violated in some drivers. For example, macOS 10.15.4 and Intel Iris + * causes #78307 when using gl_InstanceID outside of instance. */ +DEFINE_VALUE("widgetID", "0") +PUSH_CONSTANT_ARRAY(VEC4, parameters, MAX_PARAM) +ADDITIONAL_INFO(gpu_shader_2D_widget_shared) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_base_inst) - .do_static_compilation(true) - .define("widgetID", "gl_InstanceID") - .push_constant(Type::VEC4, "parameters", (MAX_PARAM * MAX_INSTANCE)) - .additional_info("gpu_shader_2D_widget_shared"); +DO_STATIC_COMPILATION() +DEFINE_VALUE("widgetID", "gl_InstanceID") +PUSH_CONSTANT_ARRAY(VEC4, parameters, (MAX_PARAM * MAX_INSTANCE)) +ADDITIONAL_INFO(gpu_shader_2D_widget_shared) +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(gpu_widget_shadow_iface, "") - .smooth(Type::FLOAT, "shadowFalloff") - .smooth(Type::FLOAT, "innerMask"); +GPU_SHADER_INTERFACE_INFO(gpu_widget_shadow_iface) +SMOOTH(FLOAT, shadowFalloff) +SMOOTH(FLOAT, innerMask) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_shadow) - .do_static_compilation(true) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "parameters", 4) - .push_constant(Type::FLOAT, "alpha") - .vertex_in(0, Type::UINT, "vflag") - .vertex_out(gpu_widget_shadow_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("gpu_shader_2D_widget_shadow_vert.glsl") - .fragment_source("gpu_shader_2D_widget_shadow_frag.glsl"); +DO_STATIC_COMPILATION() +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT_ARRAY(VEC4, parameters, 4) +PUSH_CONSTANT(FLOAT, alpha) +VERTEX_IN(0, UINT, vflag) +VERTEX_OUT(gpu_widget_shadow_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("gpu_shader_2D_widget_shadow_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_widget_shadow_frag.glsl") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh index 795b557ce1d..4566e7decf5 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh @@ -10,14 +10,16 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_depth_only) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(flat_color_iface) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_3D_vert.glsl") - .fragment_source("gpu_shader_depth_only_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(flat_color_iface) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_3D_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_depth_only_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_depth_only_clipped) - .additional_info("gpu_shader_3D_depth_only") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_depth_only) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh index eb0479f78c7..2adef85f16b 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh @@ -10,17 +10,19 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_flat_color) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - .vertex_out(flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_3D_flat_color_vert.glsl") - .fragment_source("gpu_shader_flat_color_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +VERTEX_OUT(flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_3D_flat_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_flat_color_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_flat_color_clipped) - .additional_info("gpu_shader_3D_flat_color") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_flat_color) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh index 0ba73b91a5c..34780456701 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh @@ -10,21 +10,24 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_image_common) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC2, "texCoord") - .vertex_out(smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .sampler(0, ImageType::FLOAT_2D, "image") - .vertex_source("gpu_shader_3D_image_vert.glsl"); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC2, texCoord) +VERTEX_OUT(smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +SAMPLER(0, FLOAT_2D, image) +VERTEX_SOURCE("gpu_shader_3D_image_vert.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_image) - .additional_info("gpu_shader_3D_image_common") - .fragment_source("gpu_shader_image_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_image_common) +FRAGMENT_SOURCE("gpu_shader_image_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_image_color) - .additional_info("gpu_shader_3D_image_common") - .push_constant(Type::VEC4, "color") - .fragment_source("gpu_shader_image_color_frag.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_image_common) +PUSH_CONSTANT(VEC4, color) +FRAGMENT_SOURCE("gpu_shader_image_color_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh index cc3f340edb9..6897b437f21 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh @@ -9,29 +9,32 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_varying_size_varying_color) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - .vertex_in(2, Type::FLOAT, "size") - .vertex_out(smooth_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_3D_point_varying_size_varying_color_vert.glsl") - .fragment_source("gpu_shader_point_varying_color_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +VERTEX_IN(2, FLOAT, size) +VERTEX_OUT(smooth_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_3D_point_varying_size_varying_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_point_varying_color_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(smooth_radii_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - .push_constant(Type::FLOAT, "size") - .vertex_source("gpu_shader_3D_point_uniform_size_aa_vert.glsl") - .fragment_source("gpu_shader_point_uniform_color_aa_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(smooth_radii_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(FLOAT, size) +VERTEX_SOURCE("gpu_shader_3D_point_uniform_size_aa_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_point_uniform_color_aa_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa_clipped) - .additional_info("gpu_shader_3D_point_uniform_size_uniform_color_aa") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh index 4e80ccfde2f..53114f110e7 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh @@ -9,97 +9,109 @@ #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_iface, "interp") - .smooth(Type::VEC4, "final_color") - .smooth(Type::FLOAT, "clip"); +GPU_SHADER_NAMED_INTERFACE_INFO(gpu_shader_3D_polyline_iface, interp) +SMOOTH(VEC4, final_color) +SMOOTH(FLOAT, clip) +GPU_SHADER_NAMED_INTERFACE_END(interp) -GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_noperspective_iface, "interp_noperspective") - .no_perspective(Type::FLOAT, "smoothline"); +GPU_SHADER_NAMED_INTERFACE_INFO(gpu_shader_3D_polyline_noperspective_iface, interp_noperspective) +NO_PERSPECTIVE(FLOAT, smoothline) +GPU_SHADER_NAMED_INTERFACE_END(interp_noperspective) GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline) - .define("SMOOTH_WIDTH", "1.0") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC2, "viewportSize") - .push_constant(Type::FLOAT, "lineWidth") - .push_constant(Type::BOOL, "lineSmooth") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(gpu_shader_3D_polyline_iface) - .vertex_out(gpu_shader_3D_polyline_noperspective_iface) - .geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) - .geometry_out(gpu_shader_3D_polyline_iface) - .geometry_out(gpu_shader_3D_polyline_noperspective_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("gpu_shader_3D_polyline_vert.glsl") - .geometry_source("gpu_shader_3D_polyline_geom.glsl") - .fragment_source("gpu_shader_3D_polyline_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space"); +DEFINE_VALUE("SMOOTH_WIDTH", "1.0") +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC2, viewportSize) +PUSH_CONSTANT(FLOAT, lineWidth) +PUSH_CONSTANT(BOOL, lineSmooth) +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(gpu_shader_3D_polyline_iface) +VERTEX_OUT(gpu_shader_3D_polyline_noperspective_iface) +GEOMETRY_LAYOUT(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4) +GEOMETRY_OUT(gpu_shader_3D_polyline_iface) +GEOMETRY_OUT(gpu_shader_3D_polyline_noperspective_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("gpu_shader_3D_polyline_vert.glsl") +GEOMETRY_SOURCE("gpu_shader_3D_polyline_geom.glsl") +FRAGMENT_SOURCE("gpu_shader_3D_polyline_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_no_geom) - .define("SMOOTH_WIDTH", "1.0") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC2, "viewportSize") - .push_constant(Type::FLOAT, "lineWidth") - .push_constant(Type::BOOL, "lineSmooth") - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(gpu_shader_3D_polyline_iface) - .vertex_out(gpu_shader_3D_polyline_noperspective_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("gpu_shader_3D_polyline_vert_no_geom.glsl") - .fragment_source("gpu_shader_3D_polyline_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space"); +DEFINE_VALUE("SMOOTH_WIDTH", "1.0") +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC2, viewportSize) +PUSH_CONSTANT(FLOAT, lineWidth) +PUSH_CONSTANT(BOOL, lineSmooth) +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(gpu_shader_3D_polyline_iface) +VERTEX_OUT(gpu_shader_3D_polyline_noperspective_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("gpu_shader_3D_polyline_vert_no_geom.glsl") +FRAGMENT_SOURCE("gpu_shader_3D_polyline_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color) - .do_static_compilation(true) - .define("UNIFORM") - .push_constant(Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline"); +DO_STATIC_COMPILATION() +DEFINE("UNIFORM") +PUSH_CONSTANT(VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .define("UNIFORM") - .push_constant(Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +DEFINE("UNIFORM") +PUSH_CONSTANT(VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline_no_geom) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color_clipped) - .do_static_compilation(true) - /* TODO(fclem): Put in a UBO to fit the 128byte requirement. */ - .push_constant(Type::MAT4, "ModelMatrix") - .push_constant(Type::VEC4, "ClipPlane") - .define("CLIP") - .additional_info("gpu_shader_3D_polyline_uniform_color"); +DO_STATIC_COMPILATION() +/* TODO(fclem): Put in a UBO to fit the 128byte requirement. */ +PUSH_CONSTANT(MAT4, ModelMatrix) +PUSH_CONSTANT(VEC4, ClipPlane) +DEFINE("CLIP") +ADDITIONAL_INFO(gpu_shader_3D_polyline_uniform_color) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color_clipped_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - /* TODO(fclem): Put in an UBO to fit the 128byte requirement. */ - .push_constant(Type::MAT4, "ModelMatrix") - .push_constant(Type::VEC4, "ClipPlane") - .define("CLIP") - .additional_info("gpu_shader_3D_polyline_uniform_color_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +/* TODO(fclem): Put in an UBO to fit the 128byte requirement. */ +PUSH_CONSTANT(MAT4, ModelMatrix) +PUSH_CONSTANT(VEC4, ClipPlane) +DEFINE("CLIP") +ADDITIONAL_INFO(gpu_shader_3D_polyline_uniform_color_no_geom) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_flat_color) - .do_static_compilation(true) - .define("FLAT") - .vertex_in(1, Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline"); +DO_STATIC_COMPILATION() +DEFINE("FLAT") +VERTEX_IN(1, VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_flat_color_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .define("FLAT") - .vertex_in(1, Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +DEFINE("FLAT") +VERTEX_IN(1, VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline_no_geom) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_smooth_color) - .do_static_compilation(true) - .define("SMOOTH") - .vertex_in(1, Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline"); +DO_STATIC_COMPILATION() +DEFINE("SMOOTH") +VERTEX_IN(1, VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_smooth_color_no_geom) - .metal_backend_only(true) - .do_static_compilation(true) - .define("SMOOTH") - .vertex_in(1, Type::VEC4, "color") - .additional_info("gpu_shader_3D_polyline_no_geom"); +METAL_BACKEND_ONLY() +DO_STATIC_COMPILATION() +DEFINE("SMOOTH") +VERTEX_IN(1, VEC4, color) +ADDITIONAL_INFO(gpu_shader_3D_polyline_no_geom) +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh index d860be2909c..d5989786fb3 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh @@ -10,17 +10,19 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - .vertex_out(smooth_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_3D_smooth_color_vert.glsl") - .fragment_source("gpu_shader_3D_smooth_color_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +VERTEX_OUT(smooth_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_3D_smooth_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_3D_smooth_color_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color_clipped) - .additional_info("gpu_shader_3D_smooth_color") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_smooth_color) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh index ff55abdc2b4..0a347628f51 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh @@ -9,30 +9,33 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_uniform_color) - .vertex_in(0, Type::VEC3, "pos") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - .vertex_source("gpu_shader_3D_vert.glsl") - .fragment_source("gpu_shader_uniform_color_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +VERTEX_SOURCE("gpu_shader_3D_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_uniform_color_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_uniform_color_clipped) - .additional_info("gpu_shader_3D_uniform_color") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_3D_uniform_color) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Confusing naming convention. But this is a version with only one local clip plane. */ GPU_SHADER_CREATE_INFO(gpu_shader_3D_clipped_uniform_color) - .vertex_in(0, Type::VEC3, "pos") - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "color") - /* TODO(@fclem): Put those two to one UBO. */ - .push_constant(Type::MAT4, "ModelMatrix") - .push_constant(Type::VEC4, "ClipPlane") - .vertex_source("gpu_shader_3D_clipped_uniform_color_vert.glsl") - .fragment_source("gpu_shader_uniform_color_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, color) +/* TODO(@fclem): Put those two to one UBO. */ +PUSH_CONSTANT(MAT4, ModelMatrix) +PUSH_CONSTANT(VEC4, ClipPlane) +VERTEX_SOURCE("gpu_shader_3D_clipped_uniform_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_uniform_color_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh index 9e922b857f6..3adbb5b81a8 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh @@ -8,39 +8,44 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(gpencil_stroke_vert_iface, "geometry_in") - .smooth(Type::VEC4, "finalColor") - .smooth(Type::FLOAT, "finalThickness"); -GPU_SHADER_INTERFACE_INFO(gpencil_stroke_geom_iface, "geometry_out") - .smooth(Type::VEC4, "mColor") - .smooth(Type::VEC2, "mTexCoord"); +GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_stroke_vert_iface, geometry_in) +SMOOTH(VEC4, finalColor) +SMOOTH(FLOAT, finalThickness) +GPU_SHADER_NAMED_INTERFACE_END(geometry_in) +GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_stroke_geom_iface, geometry_out) +SMOOTH(VEC4, mColor) +SMOOTH(VEC2, mTexCoord) +GPU_SHADER_NAMED_INTERFACE_END(geometry_out) GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke_base) - .vertex_in(0, Type::VEC4, "color") - .vertex_in(1, Type::VEC3, "pos") - .vertex_in(2, Type::FLOAT, "thickness") - .vertex_out(gpencil_stroke_vert_iface) - .fragment_out(0, Type::VEC4, "fragColor") +VERTEX_IN(0, VEC4, color) +VERTEX_IN(1, VEC3, pos) +VERTEX_IN(2, FLOAT, thickness) +VERTEX_OUT(gpencil_stroke_vert_iface) +FRAGMENT_OUT(0, VEC4, fragColor) - .uniform_buf(0, "GPencilStrokeData", "gpencil_stroke_data") +UNIFORM_BUF(0, GPencilStrokeData, gpencil_stroke_data) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::MAT4, "ProjectionMatrix") - .fragment_source("gpu_shader_gpencil_stroke_frag.glsl") - .typedef_source("GPU_shader_shared.hh"); +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(MAT4, ProjectionMatrix) +FRAGMENT_SOURCE("gpu_shader_gpencil_stroke_frag.glsl") +TYPEDEF_SOURCE("GPU_shader_shared.hh") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke) - .additional_info("gpu_shader_gpencil_stroke_base") - .geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::TRIANGLE_STRIP, 13) - .geometry_out(gpencil_stroke_geom_iface) - .vertex_source("gpu_shader_gpencil_stroke_vert.glsl") - .geometry_source("gpu_shader_gpencil_stroke_geom.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_shader_gpencil_stroke_base) +GEOMETRY_LAYOUT(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::TRIANGLE_STRIP, 13) +GEOMETRY_OUT(gpencil_stroke_geom_iface) +VERTEX_SOURCE("gpu_shader_gpencil_stroke_vert.glsl") +GEOMETRY_SOURCE("gpu_shader_gpencil_stroke_geom.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke_no_geom) - .metal_backend_only(true) - .define("USE_GEOMETRY_IFACE_COLOR") - .additional_info("gpu_shader_gpencil_stroke_base") - .vertex_out(gpencil_stroke_geom_iface) - .vertex_source("gpu_shader_gpencil_stroke_vert_no_geom.glsl") - .do_static_compilation(true); +METAL_BACKEND_ONLY() +DEFINE("USE_GEOMETRY_IFACE_COLOR") +ADDITIONAL_INFO(gpu_shader_gpencil_stroke_base) +VERTEX_OUT(gpencil_stroke_geom_iface) +VERTEX_SOURCE("gpu_shader_gpencil_stroke_vert_no_geom.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh index a4995cc28c0..27cdc063cf7 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh @@ -10,26 +10,28 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_icon) - .define("DO_CORNER_MASKING") - .vertex_out(smooth_icon_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC4, "finalColor") - .push_constant(Type::VEC4, "rect_icon") - .push_constant(Type::VEC4, "rect_geom") - .push_constant(Type::FLOAT, "text_width") - .sampler(0, ImageType::FLOAT_2D, "image") - .vertex_source("gpu_shader_icon_vert.glsl") - .fragment_source("gpu_shader_icon_frag.glsl") - .do_static_compilation(true); +DEFINE("DO_CORNER_MASKING") +VERTEX_OUT(smooth_icon_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC4, finalColor) +PUSH_CONSTANT(VEC4, rect_icon) +PUSH_CONSTANT(VEC4, rect_geom) +PUSH_CONSTANT(FLOAT, text_width) +SAMPLER(0, FLOAT_2D, image) +VERTEX_SOURCE("gpu_shader_icon_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_icon_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_icon_multi) - .vertex_in(0, Type::VEC2, "pos") - .vertex_out(flat_color_smooth_tex_coord_interp_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .uniform_buf(0, "MultiIconCallData", "multi_icon_data") - .sampler(0, ImageType::FLOAT_2D, "image") - .typedef_source("GPU_shader_shared.hh") - .vertex_source("gpu_shader_icon_multi_vert.glsl") - .fragment_source("gpu_shader_icon_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC2, pos) +VERTEX_OUT(flat_color_smooth_tex_coord_interp_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +UNIFORM_BUF(0, MultiIconCallData, multi_icon_data) +SAMPLER(0, FLOAT_2D, image) +TYPEDEF_SOURCE("GPU_shader_shared.hh") +VERTEX_SOURCE("gpu_shader_icon_multi_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_icon_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh index 4204416b032..51faa169441 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh @@ -10,25 +10,28 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_index_2d_array_points) - .local_group_size(16, 16, 1) - .push_constant(Type::INT, "elements_per_curve") - .push_constant(Type::INT, "ncurves") - .storage_buf(0, Qualifier::WRITE, "uint", "out_indices[]") - .compute_source("gpu_shader_index_2d_array_points.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16, 1) +PUSH_CONSTANT(INT, elements_per_curve) +PUSH_CONSTANT(INT, ncurves) +STORAGE_BUF(0, WRITE, uint, out_indices[]) +COMPUTE_SOURCE("gpu_shader_index_2d_array_points.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_index_2d_array_lines) - .local_group_size(16, 16, 1) - .push_constant(Type::INT, "elements_per_curve") - .push_constant(Type::INT, "ncurves") - .storage_buf(0, Qualifier::WRITE, "uint", "out_indices[]") - .compute_source("gpu_shader_index_2d_array_lines.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16, 1) +PUSH_CONSTANT(INT, elements_per_curve) +PUSH_CONSTANT(INT, ncurves) +STORAGE_BUF(0, WRITE, uint, out_indices[]) +COMPUTE_SOURCE("gpu_shader_index_2d_array_lines.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_index_2d_array_tris) - .local_group_size(16, 16, 1) - .push_constant(Type::INT, "elements_per_curve") - .push_constant(Type::INT, "ncurves") - .storage_buf(0, Qualifier::WRITE, "uint", "out_indices[]") - .compute_source("gpu_shader_index_2d_array_tris.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(16, 16, 1) +PUSH_CONSTANT(INT, elements_per_curve) +PUSH_CONSTANT(INT, ncurves) +STORAGE_BUF(0, WRITE, uint, out_indices[]) +COMPUTE_SOURCE("gpu_shader_index_2d_array_tris.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh index 844f5f4d982..d21e6257dcb 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh @@ -10,14 +10,15 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_instance_varying_color_varying_size) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") - .vertex_in(2, Type::FLOAT, "size") - .vertex_in(3, Type::MAT4, "InstanceModelMatrix") - .vertex_out(flat_color_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ViewProjectionMatrix") - .vertex_source("gpu_shader_instance_variying_size_variying_color_vert.glsl") - .fragment_source("gpu_shader_flat_color_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC4, color) +VERTEX_IN(2, FLOAT, size) +VERTEX_IN(3, MAT4, InstanceModelMatrix) +VERTEX_OUT(flat_color_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ViewProjectionMatrix) +VERTEX_SOURCE("gpu_shader_instance_variying_size_variying_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_flat_color_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh index 96280efab44..a8fa31d6c75 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh @@ -8,25 +8,27 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(keyframe_shape_iface, "") - .flat(Type::VEC4, "finalColor") - .flat(Type::VEC4, "finalOutlineColor") - .flat(Type::VEC4, "radii") - .flat(Type::VEC4, "thresholds") - .flat(Type::UINT, "finalFlags"); +GPU_SHADER_INTERFACE_INFO(keyframe_shape_iface) +FLAT(VEC4, finalColor) +FLAT(VEC4, finalOutlineColor) +FLAT(VEC4, radii) +FLAT(VEC4, thresholds) +FLAT(UINT, finalFlags) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_keyframe_shape) - .typedef_source("GPU_shader_shared.hh") - .vertex_in(0, Type::VEC4, "color") - .vertex_in(1, Type::VEC4, "outlineColor") - .vertex_in(2, Type::VEC2, "pos") - .vertex_in(3, Type::FLOAT, "size") - .vertex_in(4, Type::UINT, "flags") - .vertex_out(keyframe_shape_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC2, "ViewportSize") - .push_constant(Type::FLOAT, "outline_scale") - .vertex_source("gpu_shader_keyframe_shape_vert.glsl") - .fragment_source("gpu_shader_keyframe_shape_frag.glsl") - .do_static_compilation(true); +TYPEDEF_SOURCE("GPU_shader_shared.hh") +VERTEX_IN(0, VEC4, color) +VERTEX_IN(1, VEC4, outlineColor) +VERTEX_IN(2, VEC2, pos) +VERTEX_IN(3, FLOAT, size) +VERTEX_IN(4, UINT, flags) +VERTEX_OUT(keyframe_shape_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC2, ViewportSize) +PUSH_CONSTANT(FLOAT, outline_scale) +VERTEX_SOURCE("gpu_shader_keyframe_shape_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_keyframe_shape_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh index 4909e36e1cc..6c0ed1d687a 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh @@ -10,29 +10,32 @@ #include "gpu_shader_create_info.hh" /* We leverage hardware interpolation to compute distance along the line. */ -GPU_SHADER_INTERFACE_INFO(gpu_shader_line_dashed_interface, "") - .no_perspective(Type::VEC2, "stipple_start") /* In screen space */ - .flat(Type::VEC2, "stipple_pos"); /* In screen space */ +GPU_SHADER_INTERFACE_INFO(gpu_shader_line_dashed_interface) +NO_PERSPECTIVE(VEC2, stipple_start) /* In screen space */ +FLAT(VEC2, stipple_pos) +GPU_SHADER_INTERFACE_END() /* In screen space */ GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(flat_color_iface) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::VEC2, "viewport_size") - .push_constant(Type::FLOAT, "dash_width") - .push_constant(Type::FLOAT, "udash_factor") /* if > 1.0, solid line. */ - /* TODO(fclem): Remove this. And decide to discard if color2 alpha is 0. */ - .push_constant(Type::INT, "colors_len") /* Enabled if > 0, 1 for solid line. */ - .push_constant(Type::VEC4, "color") - .push_constant(Type::VEC4, "color2") - .vertex_out(gpu_shader_line_dashed_interface) - .fragment_out(0, Type::VEC4, "fragColor") - .vertex_source("gpu_shader_3D_line_dashed_uniform_color_vert.glsl") - .fragment_source("gpu_shader_2D_line_dashed_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_OUT(flat_color_iface) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(VEC2, viewport_size) +PUSH_CONSTANT(FLOAT, dash_width) +PUSH_CONSTANT(FLOAT, udash_factor) /* if > 1.0, solid line. */ +/* TODO(fclem): Remove this. And decide to discard if color2 alpha is 0. */ +PUSH_CONSTANT(INT, colors_len) /* Enabled if > 0, 1 for solid line. */ +PUSH_CONSTANT(VEC4, color) +PUSH_CONSTANT(VEC4, color2) +VERTEX_OUT(gpu_shader_line_dashed_interface) +FRAGMENT_OUT(0, VEC4, fragColor) +VERTEX_SOURCE("gpu_shader_3D_line_dashed_uniform_color_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_2D_line_dashed_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color_clipped) - .push_constant(Type::MAT4, "ModelMatrix") - .additional_info("gpu_shader_3D_line_dashed_uniform_color") - .additional_info("gpu_clip_planes") - .do_static_compilation(true); +PUSH_CONSTANT(MAT4, ModelMatrix) +ADDITIONAL_INFO(gpu_shader_3D_line_dashed_uniform_color) +ADDITIONAL_INFO(gpu_clip_planes) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh index 37defa7d433..b8462d05a2b 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh @@ -9,7 +9,7 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_print) - .storage_buf( - GPU_SHADER_PRINTF_SLOT, Qualifier::READ_WRITE, "uint", "gpu_print_buf[]", Frequency::PASS) - .define("GPU_SHADER_PRINTF_MAX_CAPACITY", STRINGIFY(GPU_SHADER_PRINTF_MAX_CAPACITY)) - .define("GPU_PRINT"); +STORAGE_BUF_FREQ(GPU_SHADER_PRINTF_SLOT, READ_WRITE, uint, gpu_print_buf[], PASS) +DEFINE_VALUE("GPU_SHADER_PRINTF_MAX_CAPACITY", STRINGIFY(GPU_SHADER_PRINTF_MAX_CAPACITY)) +DEFINE("GPU_PRINT") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh index ae3f5616123..a7f22cd8aed 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh @@ -9,34 +9,38 @@ #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(gpu_seq_strip_iface, "") - .no_perspective(Type::VEC2, "co_interp") - .flat(Type::UINT, "strip_id"); +GPU_SHADER_INTERFACE_INFO(gpu_seq_strip_iface) +NO_PERSPECTIVE(VEC2, co_interp) +FLAT(UINT, strip_id) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_sequencer_strips) - .vertex_out(gpu_seq_strip_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .uniform_buf(0, "SeqStripDrawData", "strip_data[GPU_SEQ_STRIP_DRAW_DATA_LEN]") - .uniform_buf(1, "SeqContextDrawData", "context_data") - .typedef_source("GPU_shader_shared.hh") - .vertex_source("gpu_shader_sequencer_strips_vert.glsl") - .fragment_source("gpu_shader_sequencer_strips_frag.glsl") - .do_static_compilation(true); +VERTEX_OUT(gpu_seq_strip_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +UNIFORM_BUF(0, SeqStripDrawData, strip_data[GPU_SEQ_STRIP_DRAW_DATA_LEN]) +UNIFORM_BUF(1, SeqContextDrawData, context_data) +TYPEDEF_SOURCE("GPU_shader_shared.hh") +VERTEX_SOURCE("gpu_shader_sequencer_strips_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_sequencer_strips_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() -GPU_SHADER_INTERFACE_INFO(gpu_seq_thumb_iface, "") - .no_perspective(Type::VEC2, "pos_interp") - .no_perspective(Type::VEC2, "texCoord_interp") - .flat(Type::UINT, "thumb_id"); +GPU_SHADER_INTERFACE_INFO(gpu_seq_thumb_iface) +NO_PERSPECTIVE(VEC2, pos_interp) +NO_PERSPECTIVE(VEC2, texCoord_interp) +FLAT(UINT, thumb_id) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_sequencer_thumbs) - .vertex_out(gpu_seq_thumb_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .uniform_buf(0, "SeqStripThumbData", "thumb_data[GPU_SEQ_STRIP_DRAW_DATA_LEN]") - .uniform_buf(1, "SeqContextDrawData", "context_data") - .sampler(0, ImageType::FLOAT_2D, "image") - .typedef_source("GPU_shader_shared.hh") - .vertex_source("gpu_shader_sequencer_thumbs_vert.glsl") - .fragment_source("gpu_shader_sequencer_thumbs_frag.glsl") - .do_static_compilation(true); +VERTEX_OUT(gpu_seq_thumb_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +UNIFORM_BUF(0, SeqStripThumbData, thumb_data[GPU_SEQ_STRIP_DRAW_DATA_LEN]) +UNIFORM_BUF(1, SeqContextDrawData, context_data) +SAMPLER(0, FLOAT_2D, image) +TYPEDEF_SOURCE("GPU_shader_shared.hh") +VERTEX_SOURCE("gpu_shader_sequencer_thumbs_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_sequencer_thumbs_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh index 403f4f79ab1..997c15a6a2a 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh @@ -8,17 +8,20 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(smooth_normal_iface, "").smooth(Type::VEC3, "normal"); +GPU_SHADER_INTERFACE_INFO(smooth_normal_iface) +SMOOTH(VEC3, normal) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_simple_lighting) - .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC3, "nor") - .vertex_out(smooth_normal_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .uniform_buf(0, "SimpleLightingData", "simple_lighting_data", Frequency::PASS) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::MAT3, "NormalMatrix") - .typedef_source("GPU_shader_shared.hh") - .vertex_source("gpu_shader_3D_normal_vert.glsl") - .fragment_source("gpu_shader_simple_lighting_frag.glsl") - .do_static_compilation(true); +VERTEX_IN(0, VEC3, pos) +VERTEX_IN(1, VEC3, nor) +VERTEX_OUT(smooth_normal_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +UNIFORM_BUF_FREQ(0, SimpleLightingData, simple_lighting_data, PASS) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(MAT3, NormalMatrix) +TYPEDEF_SOURCE("GPU_shader_shared.hh") +VERTEX_SOURCE("gpu_shader_3D_normal_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_simple_lighting_frag.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh index f490f304fb7..216a122dab4 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh @@ -10,137 +10,159 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_test) - .typedef_source("GPU_shader_shared.hh") - .fragment_out(0, Type::UVEC4, "out_test") - .additional_info("draw_fullscreen"); +TYPEDEF_SOURCE("GPU_shader_shared.hh") +FRAGMENT_OUT(0, UVEC4, out_test) +ADDITIONAL_INFO(draw_fullscreen) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_math_test) - .fragment_source("gpu_math_test.glsl") - .additional_info("gpu_shader_test") - .do_static_compilation(true); +FRAGMENT_SOURCE("gpu_math_test.glsl") +ADDITIONAL_INFO(gpu_shader_test) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_1d_test) - .local_group_size(1) - .image(1, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_1D, "img_output") - .compute_source("gpu_compute_1d_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +IMAGE(1, GPU_RGBA32F, WRITE, FLOAT_1D, img_output) +COMPUTE_SOURCE("gpu_compute_1d_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_2d_test) - .local_group_size(1, 1) - .image(1, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "img_output") - .compute_source("gpu_compute_2d_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1, 1) +IMAGE(1, GPU_RGBA32F, WRITE, FLOAT_2D, img_output) +COMPUTE_SOURCE("gpu_compute_2d_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_ibo_test) - .local_group_size(1) - .storage_buf(0, Qualifier::WRITE, "uint", "out_indices[]") - .compute_source("gpu_compute_ibo_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +STORAGE_BUF(0, WRITE, uint, out_indices[]) +COMPUTE_SOURCE("gpu_compute_ibo_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_vbo_test) - .local_group_size(1) - .storage_buf(0, Qualifier::WRITE, "vec4", "out_positions[]") - .compute_source("gpu_compute_vbo_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +STORAGE_BUF(0, WRITE, vec4, out_positions[]) +COMPUTE_SOURCE("gpu_compute_vbo_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_ssbo_test) - .local_group_size(1) - .storage_buf(0, Qualifier::WRITE, "int", "data_out[]") - .compute_source("gpu_compute_ssbo_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +STORAGE_BUF(0, WRITE, int, data_out[]) +COMPUTE_SOURCE("gpu_compute_ssbo_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_ssbo_binding_test) - .local_group_size(1) - .storage_buf(0, Qualifier::WRITE, "int", "data0[]") - .storage_buf(1, Qualifier::WRITE, "int", "data1[]") - .compute_source("gpu_compute_dummy_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +STORAGE_BUF(0, WRITE, int, data0[]) +STORAGE_BUF(1, WRITE, int, data1[]) +COMPUTE_SOURCE("gpu_compute_dummy_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Push constants. */ GPU_SHADER_CREATE_INFO(gpu_push_constants_base_test) - .local_group_size(1) - .storage_buf(0, Qualifier::WRITE, "float", "data_out[]") - .compute_source("gpu_push_constants_test.glsl"); +LOCAL_GROUP_SIZE(1) +STORAGE_BUF(0, WRITE, float, data_out[]) +COMPUTE_SOURCE("gpu_push_constants_test.glsl") +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_push_constants_test) - .additional_info("gpu_push_constants_base_test") - .push_constant(Type::FLOAT, "float_in") - .push_constant(Type::VEC2, "vec2_in") - .push_constant(Type::VEC3, "vec3_in") - .push_constant(Type::VEC4, "vec4_in") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_push_constants_base_test) +PUSH_CONSTANT(FLOAT, float_in) +PUSH_CONSTANT(VEC2, vec2_in) +PUSH_CONSTANT(VEC3, vec3_in) +PUSH_CONSTANT(VEC4, vec4_in) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Push constants size test. */ GPU_SHADER_CREATE_INFO(gpu_push_constants_128bytes_test) - .additional_info("gpu_push_constants_test") - .push_constant(Type::FLOAT, "filler", 20) - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_push_constants_test) +PUSH_CONSTANT_ARRAY(FLOAT, filler, 20) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_push_constants_256bytes_test) - .additional_info("gpu_push_constants_128bytes_test") - .push_constant(Type::FLOAT, "filler2", 32) - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_push_constants_128bytes_test) +PUSH_CONSTANT_ARRAY(FLOAT, filler2, 32) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_push_constants_512bytes_test) - .additional_info("gpu_push_constants_256bytes_test") - .push_constant(Type::FLOAT, "filler3", 64) - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_push_constants_256bytes_test) +PUSH_CONSTANT_ARRAY(FLOAT, filler3, 64) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_push_constants_8192bytes_test) - .additional_info("gpu_push_constants_512bytes_test") - .push_constant(Type::FLOAT, "filler4", 1920) - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_push_constants_512bytes_test) +PUSH_CONSTANT_ARRAY(FLOAT, filler4, 1920) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_buffer_texture_test) - .local_group_size(1) - .sampler(0, ImageType::FLOAT_BUFFER, "bufferTexture") - .storage_buf(0, Qualifier::WRITE, "float", "data_out[]") - .compute_source("gpu_buffer_texture_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +SAMPLER(0, FLOAT_BUFFER, bufferTexture) +STORAGE_BUF(0, WRITE, float, data_out[]) +COMPUTE_SOURCE("gpu_buffer_texture_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* Specialization constants. */ GPU_SHADER_CREATE_INFO(gpu_specialization_constants_base_test) - .storage_buf(0, Qualifier::WRITE, "int", "data_out[]") - .specialization_constant(Type::FLOAT, "float_in", 2) - .specialization_constant(Type::UINT, "uint_in", 3) - .specialization_constant(Type::INT, "int_in", 4) - .specialization_constant(Type::BOOL, "bool_in", true); +STORAGE_BUF(0, WRITE, int, data_out[]) +SPECIALIZATION_CONSTANT(FLOAT, float_in, 2) +SPECIALIZATION_CONSTANT(UINT, uint_in, 3) +SPECIALIZATION_CONSTANT(INT, int_in, 4) +SPECIALIZATION_CONSTANT(BOOL, bool_in, true) +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_compute_specialization_test) - .local_group_size(1) - .additional_info("gpu_specialization_constants_base_test") - .compute_source("gpu_specialization_test.glsl") - .do_static_compilation(true); +LOCAL_GROUP_SIZE(1) +ADDITIONAL_INFO(gpu_specialization_constants_base_test) +COMPUTE_SOURCE("gpu_specialization_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(gpu_graphic_specialization_test) - .additional_info("gpu_specialization_constants_base_test") - .vertex_source("gpu_specialization_test.glsl") - .fragment_source("gpu_specialization_test.glsl") - .do_static_compilation(true); +ADDITIONAL_INFO(gpu_specialization_constants_base_test) +VERTEX_SOURCE("gpu_specialization_test.glsl") +FRAGMENT_SOURCE("gpu_specialization_test.glsl") +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() /* EEVEE test. */ GPU_SHADER_CREATE_INFO(eevee_shadow_test) - .fragment_source("eevee_shadow_test.glsl") - .additional_info("gpu_shader_test") - .additional_info("eevee_shared") - .do_static_compilation(true); +FRAGMENT_SOURCE("eevee_shadow_test.glsl") +ADDITIONAL_INFO(gpu_shader_test) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_occupancy_test) - .fragment_source("eevee_occupancy_test.glsl") - .additional_info("gpu_shader_test") - .additional_info("eevee_shared") - .do_static_compilation(true); +FRAGMENT_SOURCE("eevee_occupancy_test.glsl") +ADDITIONAL_INFO(gpu_shader_test) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_gbuffer_normal_test) - .fragment_source("eevee_gbuffer_normal_test.glsl") - .additional_info("gpu_shader_test") - .additional_info("eevee_shared") - .do_static_compilation(true); +FRAGMENT_SOURCE("eevee_gbuffer_normal_test.glsl") +ADDITIONAL_INFO(gpu_shader_test) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() GPU_SHADER_CREATE_INFO(eevee_gbuffer_closure_test) - .fragment_source("eevee_gbuffer_closure_test.glsl") - .additional_info("gpu_shader_test") - .additional_info("eevee_shared") - .do_static_compilation(true); +FRAGMENT_SOURCE("eevee_gbuffer_closure_test.glsl") +ADDITIONAL_INFO(gpu_shader_test) +ADDITIONAL_INFO(eevee_shared) +DO_STATIC_COMPILATION() +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh index b12d5000c87..3592858243c 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh @@ -8,26 +8,26 @@ #include "gpu_shader_create_info.hh" -GPU_SHADER_INTERFACE_INFO(text_iface, "") - .flat(Type::VEC4, "color_flat") - .no_perspective(Type::VEC2, "texCoord_interp") - .flat(Type::INT, "glyph_offset") - .flat(Type::UINT, "glyph_flags") - .flat(Type::IVEC2, "glyph_dim"); +GPU_SHADER_INTERFACE_INFO(text_iface) +FLAT(VEC4, color_flat) +NO_PERSPECTIVE(VEC2, texCoord_interp) +FLAT(INT, glyph_offset) +FLAT(UINT, glyph_flags) +FLAT(IVEC2, glyph_dim) +GPU_SHADER_INTERFACE_END() GPU_SHADER_CREATE_INFO(gpu_shader_text) - .vertex_in(0, Type::VEC4, "pos") - .vertex_in(1, Type::VEC4, "col") - .vertex_in(2, Type ::IVEC2, "glyph_size") - .vertex_in(3, Type ::INT, "offset") - .vertex_in(4, Type ::UINT, "flags") - .vertex_out(text_iface) - .fragment_out(0, Type::VEC4, "fragColor") - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .push_constant(Type::INT, "glyph_tex_width_mask") - .push_constant(Type::INT, "glyph_tex_width_shift") - .sampler(0, ImageType::FLOAT_2D, "glyph", Frequency::PASS) - .vertex_source("gpu_shader_text_vert.glsl") - .fragment_source("gpu_shader_text_frag.glsl") - .additional_info("gpu_srgb_to_framebuffer_space") - .do_static_compilation(true); +VERTEX_IN(0, VEC4, pos) +VERTEX_IN(1, VEC4, col) +VERTEX_IN(2, IVEC2, glyph_size) +VERTEX_IN(3, INT, offset) +VERTEX_IN(4, UINT, flags) +VERTEX_OUT(text_iface) +FRAGMENT_OUT(0, VEC4, fragColor) +PUSH_CONSTANT(MAT4, ModelViewProjectionMatrix) +PUSH_CONSTANT(INT, glyph_tex_width_mask) +PUSH_CONSTANT(INT, glyph_tex_width_shift) +SAMPLER_FREQ(0, FLOAT_2D, glyph, PASS) +VERTEX_SOURCE("gpu_shader_text_vert.glsl") +FRAGMENT_SOURCE("gpu_shader_text_frag.glsl") +ADDITIONAL_INFO(gpu_srgb_to_framebuffer_space) DO_STATIC_COMPILATION() GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh b/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh index 37ff2f958b8..62030deda70 100644 --- a/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh @@ -9,5 +9,6 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_srgb_to_framebuffer_space) - .push_constant(Type::BOOL, "srgbTarget") - .define("blender_srgb_to_framebuffer_space(a) a"); +PUSH_CONSTANT(BOOL, srgbTarget) +DEFINE("blender_srgb_to_framebuffer_space(a) a") +GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/metal/mtl_shader_defines.msl b/source/blender/gpu/shaders/metal/mtl_shader_defines.msl index f605da8baa5..f4d1d400ba3 100644 --- a/source/blender/gpu/shaders/metal/mtl_shader_defines.msl +++ b/source/blender/gpu/shaders/metal/mtl_shader_defines.msl @@ -2529,3 +2529,28 @@ mat3x4 MAT3x4(mat2 m) #define MAT2 MAT2x2 #define MAT3 MAT3x3 #define MAT4 MAT4x4 + +/* 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__ } +/* 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) diff --git a/source/blender/gpu/shaders/opengl/glsl_shader_defines.glsl b/source/blender/gpu/shaders/opengl/glsl_shader_defines.glsl index 29413d63605..e6f377a4cee 100644 --- a/source/blender/gpu/shaders/opengl/glsl_shader_defines.glsl +++ b/source/blender/gpu/shaders/opengl/glsl_shader_defines.glsl @@ -103,3 +103,26 @@ bool is_zero(vec4 A) { return all(equal(A, vec4(0.0))); } + +/* Array syntax compatibility. */ +#define float_array float[] +#define float2_array vec2[] +#define float3_array vec3[] +#define float4_array vec4[] +#define int_array int[] +#define int2_array int2[] +#define int3_array int3[] +#define int4_array int4[] +#define uint_array uint[] +#define uint2_array uint2[] +#define uint3_array uint3[] +#define uint4_array uint4[] +#define bool_array bool[] +#define bool2_array bool2[] +#define bool3_array bool3[] +#define bool4_array bool4[] + +#define SHADER_LIBRARY_CREATE_INFO(a) +#define VERTEX_SHADER_CREATE_INFO(a) +#define FRAGMENT_SHADER_CREATE_INFO(a) +#define COMPUTE_SHADER_CREATE_INFO(a)