Fix shader compiler asan out of bounds

This commit is contained in:
dzil123 2022-11-16 06:33:40 -08:00 committed by Relintai
parent 37c50b6f21
commit 298be38336
3 changed files with 28 additions and 0 deletions

View File

@ -1680,6 +1680,9 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_USAMPLER3D: {
// Not implemented in GLES2
} break;
default: {
}
}
p_param_list->push_back(pi);

View File

@ -926,6 +926,8 @@ String ShaderLanguage::get_datatype_name(DataType p_type) {
return "samplerExternalOES";
case TYPE_STRUCT:
return "struct";
default: {
}
}
return "";
@ -2701,6 +2703,8 @@ Variant ShaderLanguage::constant_value_to_variant(const Vector<ShaderLanguage::C
break;
case ShaderLanguage::TYPE_VOID:
break;
default: {
}
}
return value;
}
@ -2786,8 +2790,18 @@ ShaderLanguage::DataType ShaderLanguage::get_scalar_type(DataType p_type) {
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_INT,
TYPE_UINT,
TYPE_FLOAT,
TYPE_FLOAT,
TYPE_VOID,
};
static_assert(sizeof(scalar_types) / sizeof(*scalar_types) == TYPE_MAX, "get_scalar_type must be updated if DataType is updated");
return scalar_types[p_type];
}
@ -2817,8 +2831,18 @@ int ShaderLanguage::get_cardinality(DataType p_type) {
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
};
static_assert(sizeof(cardinality_table) / sizeof(*cardinality_table) == TYPE_MAX, "get_cardinality must be updated if DataType is updated");
return cardinality_table[p_type];
}

View File

@ -210,6 +210,7 @@ public:
TYPE_SAMPLERCUBE,
TYPE_SAMPLEREXT,
TYPE_STRUCT,
TYPE_MAX,
};
enum DataPrecision {