mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Validate varying count when compiling shaders
This avoids crashing on devices when a number of varyings greater than the device limit is used. For now this accurately prints an error when compiling the shader, but the error text only pops up in the editor if the number of user varyings is above the limit.
This commit is contained in:
@@ -631,6 +631,28 @@ public:
|
||||
int array_size = 0;
|
||||
TkPos tkpos;
|
||||
|
||||
uint32_t get_size() const {
|
||||
uint32_t size = 1;
|
||||
if (array_size > 0) {
|
||||
size = (uint32_t)array_size;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TYPE_MAT2:
|
||||
size *= 2;
|
||||
break;
|
||||
case TYPE_MAT3:
|
||||
size *= 3;
|
||||
break;
|
||||
case TYPE_MAT4:
|
||||
size *= 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
Varying() {}
|
||||
};
|
||||
|
||||
@@ -1022,6 +1044,7 @@ private:
|
||||
String current_uniform_subgroup_name;
|
||||
|
||||
VaryingFunctionNames varying_function_names;
|
||||
uint32_t base_varying_index = 0;
|
||||
|
||||
TkPos _get_tkpos() {
|
||||
TkPos tkp;
|
||||
@@ -1217,6 +1240,7 @@ public:
|
||||
HashSet<String> shader_types;
|
||||
GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr;
|
||||
bool is_include = false;
|
||||
uint32_t base_varying_index = 0;
|
||||
};
|
||||
|
||||
Error compile(const String &p_code, const ShaderCompileInfo &p_info);
|
||||
|
||||
Reference in New Issue
Block a user