Enhances a shader uniform limit warning
This commit is contained in:
parent
13d25f9980
commit
bd61d8f80c
|
@ -7596,8 +7596,16 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
int uniform_buffer_size = 0;
|
int uniform_buffer_size = 0;
|
||||||
int max_uniform_buffer_size = 0;
|
int max_uniform_buffer_size = 0;
|
||||||
if (RenderingDevice::get_singleton()) {
|
int uniform_buffer_exceeded_line = -1;
|
||||||
max_uniform_buffer_size = RenderingDevice::get_singleton()->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE);
|
|
||||||
|
bool check_device_limit_warnings = false;
|
||||||
|
{
|
||||||
|
RenderingDevice *device = RenderingDevice::get_singleton();
|
||||||
|
if (device != nullptr) {
|
||||||
|
check_device_limit_warnings = check_warnings && HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED_FLAG);
|
||||||
|
|
||||||
|
max_uniform_buffer_size = device->limit_get(RenderingDevice::LIMIT_MAX_UNIFORM_BUFFER_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL;
|
ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL;
|
||||||
|
@ -8001,6 +8009,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) {
|
if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) {
|
||||||
uniform2.order = uniforms++;
|
uniform2.order = uniforms++;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (check_device_limit_warnings) {
|
||||||
if (uniform2.array_size > 0) {
|
if (uniform2.array_size > 0) {
|
||||||
int size = get_datatype_size(uniform2.type) * uniform2.array_size;
|
int size = get_datatype_size(uniform2.type) * uniform2.array_size;
|
||||||
int m = (16 * uniform2.array_size);
|
int m = (16 * uniform2.array_size);
|
||||||
|
@ -8011,6 +8020,11 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
} else {
|
} else {
|
||||||
uniform_buffer_size += get_datatype_size(uniform2.type);
|
uniform_buffer_size += get_datatype_size(uniform2.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uniform_buffer_exceeded_line == -1 && uniform_buffer_size > max_uniform_buffer_size) {
|
||||||
|
uniform_buffer_exceeded_line = tk_line;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9022,11 +9036,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (HAS_WARNING(ShaderWarning::DEVICE_LIMIT_EXCEEDED) && (uniform_buffer_size > max_uniform_buffer_size)) {
|
if (check_device_limit_warnings && uniform_buffer_exceeded_line != -1) {
|
||||||
Vector<Variant> args;
|
_add_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, uniform_buffer_exceeded_line, "uniform buffer", { uniform_buffer_size, max_uniform_buffer_size });
|
||||||
args.push_back(uniform_buffer_size);
|
|
||||||
args.push_back(max_uniform_buffer_size);
|
|
||||||
_add_global_warning(ShaderWarning::DEVICE_LIMIT_EXCEEDED, "uniform buffer", args);
|
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
return OK;
|
return OK;
|
||||||
|
|
Loading…
Reference in New Issue