Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility methods for RenderingDevice BarrierMask #81356

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1383,6 +1383,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
YuriSizov marked this conversation as resolved.
Show resolved Hide resolved
};

VARIANT_ENUM_CAST(RenderingDevice::DeviceType)
Expand Down
Loading