Skip to content

Commit

Permalink
Merge pull request #81356 from pkdawson/rd-compat
Browse files Browse the repository at this point in the history
Add compatibility methods for RenderingDevice BarrierMask
  • Loading branch information
YuriSizov committed Sep 27, 2023
2 parents 5f53ec9 + d80dc0f commit 54c7a26
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
3 changes: 0 additions & 3 deletions misc/extension_api_validation/4.1-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
38 changes: 38 additions & 0 deletions servers/rendering/rendering_device.compat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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::BarrierMask> RenderingDevice::_convert_barrier_mask_81356(BitField<BarrierMask> 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<BarrierMask> 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<BarrierMask> p_post_barrier) {
draw_list_end(_convert_barrier_mask_81356(p_post_barrier));
}

void RenderingDevice::_compute_list_end_bind_compat_81356(BitField<BarrierMask> p_post_barrier) {
compute_list_end(_convert_barrier_mask_81356(p_post_barrier));
}

void RenderingDevice::_barrier_bind_compat_81356(BitField<BarrierMask> p_from, BitField<BarrierMask> 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
7 changes: 7 additions & 0 deletions servers/rendering/rendering_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,13 @@ class RenderingDevice : public Object {
};

Error _reflect_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, SpirvReflectionData &r_reflection_data);

#ifndef DISABLE_DEPRECATED
BitField<BarrierMask> _convert_barrier_mask_81356(BitField<BarrierMask> p_old_barrier);
void _draw_list_end_bind_compat_81356(BitField<BarrierMask> p_post_barrier);
void _compute_list_end_bind_compat_81356(BitField<BarrierMask> p_post_barrier);
void _barrier_bind_compat_81356(BitField<BarrierMask> p_from, BitField<BarrierMask> p_to);
#endif
};

VARIANT_ENUM_CAST(RenderingDevice::DeviceType)
Expand Down

0 comments on commit 54c7a26

Please sign in to comment.