From d80dc0ff583467a1a7fe839e8263e40eec64e6b8 Mon Sep 17 00:00:00 2001 From: Patrick Dawson Date: Tue, 5 Sep 2023 22:25:59 +0200 Subject: [PATCH] Add compatibility methods for RenderingDevice BarrierMask --- .../4.1-stable.expected | 3 -- servers/rendering/rendering_device.compat.inc | 38 +++++++++++++++++++ servers/rendering/rendering_device.h | 7 ++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/misc/extension_api_validation/4.1-stable.expected b/misc/extension_api_validation/4.1-stable.expected index 19c9a28c09fe..676dcf94c710 100644 --- a/misc/extension_api_validation/4.1-stable.expected +++ b/misc/extension_api_validation/4.1-stable.expected @@ -20,12 +20,9 @@ Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/texture_r Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/buffer_update/arguments/4': default_value changed value in new API, from "7" to "32767". Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/buffer_clear/arguments/3': default_value changed value in new API, from "7" to "32767". Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/draw_list_end/arguments/0': default_value changed value in new API, from "7" to "32767". -Validate extension JSON: Error: Hash changed for 'classes/RenderingDevice/methods/draw_list_end', from 19365687 to E9B4FA8E. This means that the function has changed and no compatibility function was provided. Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/compute_list_end/arguments/0': default_value changed value in new API, from "7" to "32767". -Validate extension JSON: Error: Hash changed for 'classes/RenderingDevice/methods/compute_list_end', from 19365687 to E9B4FA8E. This means that the function has changed and no compatibility function was provided. Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/barrier/arguments/0': default_value changed value in new API, from "7" to "32767". Validate extension JSON: Error: Field 'classes/RenderingDevice/methods/barrier/arguments/1': default_value changed value in new API, from "7" to "32767". -Validate extension JSON: Error: Hash changed for 'classes/RenderingDevice/methods/barrier', from 0FE50041 to DD9E8DAB. This means that the function has changed and no compatibility function was provided. Raster barrier was split into vertex and fragment barriers for use in mobile renderer. diff --git a/servers/rendering/rendering_device.compat.inc b/servers/rendering/rendering_device.compat.inc index dc7817e66bdd..8e7beda6f31d 100644 --- a/servers/rendering/rendering_device.compat.inc +++ b/servers/rendering/rendering_device.compat.inc @@ -34,8 +34,46 @@ RID RenderingDevice::_shader_create_from_bytecode_bind_compat_79606(const Vector return shader_create_from_bytecode(p_shader_binary, RID()); } +BitField RenderingDevice::_convert_barrier_mask_81356(BitField p_old_barrier) { + if (p_old_barrier == 7) { + return BARRIER_MASK_ALL_BARRIERS; + } else if (p_old_barrier == 16) { + return BARRIER_MASK_NO_BARRIER; + } + + BitField new_barrier; + if (p_old_barrier & 1) { + new_barrier.set_flag(BARRIER_MASK_VERTEX); + } + if (p_old_barrier & 2) { + new_barrier.set_flag(BARRIER_MASK_FRAGMENT); + } + if (p_old_barrier & 4) { + new_barrier.set_flag(BARRIER_MASK_COMPUTE); + } + if (p_old_barrier & 8) { + new_barrier.set_flag(BARRIER_MASK_TRANSFER); + } + return new_barrier; +} + +void RenderingDevice::_draw_list_end_bind_compat_81356(BitField p_post_barrier) { + draw_list_end(_convert_barrier_mask_81356(p_post_barrier)); +} + +void RenderingDevice::_compute_list_end_bind_compat_81356(BitField p_post_barrier) { + compute_list_end(_convert_barrier_mask_81356(p_post_barrier)); +} + +void RenderingDevice::_barrier_bind_compat_81356(BitField p_from, BitField p_to) { + barrier(_convert_barrier_mask_81356(p_from), _convert_barrier_mask_81356(p_to)); +} + void RenderingDevice::_bind_compatibility_methods() { ClassDB::bind_compatibility_method(D_METHOD("shader_create_from_bytecode", "binary_data"), &RenderingDevice::_shader_create_from_bytecode_bind_compat_79606); + ClassDB::bind_compatibility_method(D_METHOD("draw_list_end", "post_barrier"), &RenderingDevice::_draw_list_end_bind_compat_81356, DEFVAL(7)); + ClassDB::bind_compatibility_method(D_METHOD("compute_list_end", "post_barrier"), &RenderingDevice::_compute_list_end_bind_compat_81356, DEFVAL(7)); + ClassDB::bind_compatibility_method(D_METHOD("barrier", "from", "to"), &RenderingDevice::_barrier_bind_compat_81356, DEFVAL(7), DEFVAL(7)); } #endif diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 1ade1b25c4d5..bac0f2bdb635 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -1383,6 +1383,13 @@ class RenderingDevice : public Object { }; Error _reflect_spirv(const Vector &p_spirv, SpirvReflectionData &r_reflection_data); + +#ifndef DISABLE_DEPRECATED + BitField _convert_barrier_mask_81356(BitField p_old_barrier); + void _draw_list_end_bind_compat_81356(BitField p_post_barrier); + void _compute_list_end_bind_compat_81356(BitField p_post_barrier); + void _barrier_bind_compat_81356(BitField p_from, BitField p_to); +#endif }; VARIANT_ENUM_CAST(RenderingDevice::DeviceType)