1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fixing retrospective code for specialisation constants

This commit is contained in:
Bastiaan Olij
2022-03-01 00:10:33 +11:00
parent 6716af9f83
commit fe5bb06df9

View File

@@ -4763,19 +4763,22 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve
for (uint32_t j = 0; j < sc_count; j++) { for (uint32_t j = 0; j < sc_count; j++) {
int32_t existing = -1; int32_t existing = -1;
RenderingDeviceVulkanShaderBinarySpecializationConstant sconst; RenderingDeviceVulkanShaderBinarySpecializationConstant sconst;
sconst.constant_id = spec_constants[j]->constant_id; SpvReflectSpecializationConstant *spc = spec_constants[j];
switch (spec_constants[j]->constant_type) {
sconst.constant_id = spc->constant_id;
sconst.int_value = 0.0; // clear previous value JIC
switch (spc->constant_type) {
case SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL: { case SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL: {
sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL;
sconst.bool_value = spec_constants[j]->default_value.int_bool_value != 0; sconst.bool_value = spc->default_value.int_bool_value != 0;
} break; } break;
case SPV_REFLECT_SPECIALIZATION_CONSTANT_INT: { case SPV_REFLECT_SPECIALIZATION_CONSTANT_INT: {
sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT;
sconst.int_value = spec_constants[j]->default_value.int_bool_value; sconst.int_value = spc->default_value.int_bool_value;
} break; } break;
case SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT: { case SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT: {
sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT; sconst.type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT;
sconst.float_value = spec_constants[j]->default_value.float_value; sconst.float_value = spc->default_value.float_value;
} break; } break;
} }
sconst.stage_flags = 1 << p_spirv[i].shader_stage; sconst.stage_flags = 1 << p_spirv[i].shader_stage;