Fix texture samplers to not being last in the property list
This commit is contained in:
parent
88d9325065
commit
e41048e16e
|
@ -586,11 +586,7 @@ void ShaderData::get_shader_uniform_list(List<PropertyInfo> *p_param_list) const
|
||||||
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (E.value.texture_order >= 0) {
|
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.prop_order));
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.texture_order + 100000));
|
|
||||||
} else {
|
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.order));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int uniform_count = filtered_uniforms.size();
|
int uniform_count = filtered_uniforms.size();
|
||||||
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
||||||
|
@ -640,7 +636,7 @@ bool ShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return uniforms[p_param].texture_order >= 0;
|
return uniforms[p_param].is_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -719,7 +715,7 @@ void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguag
|
||||||
bool uses_global_buffer = false;
|
bool uses_global_buffer = false;
|
||||||
|
|
||||||
for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) {
|
for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) {
|
||||||
if (E.value.order < 0) {
|
if (E.value.is_texture()) {
|
||||||
continue; // texture, does not go here
|
continue; // texture, does not go here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,7 @@ void MaterialStorage::get_shader_parameter_list(RID p_shader, List<PropertyInfo>
|
||||||
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (E.value.texture_order >= 0) {
|
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.prop_order));
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.texture_order + 100000));
|
|
||||||
} else {
|
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.order));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int uniform_count = filtered_uniforms.size();
|
int uniform_count = filtered_uniforms.size();
|
||||||
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
||||||
|
|
|
@ -580,11 +580,7 @@ void MaterialStorage::ShaderData::get_shader_uniform_list(List<PropertyInfo> *p_
|
||||||
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
if (E.value.scope != ShaderLanguage::ShaderNode::Uniform::SCOPE_LOCAL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (E.value.texture_order >= 0) {
|
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.prop_order));
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.texture_order + 100000));
|
|
||||||
} else {
|
|
||||||
filtered_uniforms.push_back(Pair<StringName, int>(E.key, E.value.order));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int uniform_count = filtered_uniforms.size();
|
int uniform_count = filtered_uniforms.size();
|
||||||
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
sorter.sort(filtered_uniforms.ptr(), uniform_count);
|
||||||
|
@ -634,7 +630,7 @@ bool MaterialStorage::ShaderData::is_parameter_texture(const StringName &p_param
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return uniforms[p_param].texture_order >= 0;
|
return uniforms[p_param].is_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -645,7 +641,7 @@ void MaterialStorage::MaterialData::update_uniform_buffer(const HashMap<StringNa
|
||||||
bool uses_global_buffer = false;
|
bool uses_global_buffer = false;
|
||||||
|
|
||||||
for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) {
|
for (const KeyValue<StringName, ShaderLanguage::ShaderNode::Uniform> &E : p_uniforms) {
|
||||||
if (E.value.order < 0) {
|
if (E.value.is_texture()) {
|
||||||
continue; // texture, does not go here
|
continue; // texture, does not go here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -922,7 +922,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
||||||
if (shader->uniforms.has(vnode->name)) {
|
if (shader->uniforms.has(vnode->name)) {
|
||||||
//its a uniform!
|
//its a uniform!
|
||||||
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[vnode->name];
|
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[vnode->name];
|
||||||
if (u.texture_order >= 0) {
|
if (u.is_texture()) {
|
||||||
StringName name;
|
StringName name;
|
||||||
if (u.hint == ShaderLanguage::ShaderNode::Uniform::HINT_SCREEN_TEXTURE) {
|
if (u.hint == ShaderLanguage::ShaderNode::Uniform::HINT_SCREEN_TEXTURE) {
|
||||||
name = "color_buffer";
|
name = "color_buffer";
|
||||||
|
@ -1039,7 +1039,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
||||||
if (shader->uniforms.has(anode->name)) {
|
if (shader->uniforms.has(anode->name)) {
|
||||||
//its a uniform!
|
//its a uniform!
|
||||||
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[anode->name];
|
const ShaderLanguage::ShaderNode::Uniform &u = shader->uniforms[anode->name];
|
||||||
if (u.texture_order >= 0) {
|
if (u.is_texture()) {
|
||||||
code = _mkid(anode->name); //texture, use as is
|
code = _mkid(anode->name); //texture, use as is
|
||||||
} else {
|
} else {
|
||||||
//a scalar or vector
|
//a scalar or vector
|
||||||
|
|
|
@ -8202,6 +8202,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
|
||||||
int texture_binding = 0;
|
int texture_binding = 0;
|
||||||
int uniforms = 0;
|
int uniforms = 0;
|
||||||
int instance_index = 0;
|
int instance_index = 0;
|
||||||
|
int prop_index = 0;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
uint64_t uniform_buffer_size = 0;
|
uint64_t uniform_buffer_size = 0;
|
||||||
uint64_t max_uniform_buffer_size = 0;
|
uint64_t max_uniform_buffer_size = 0;
|
||||||
|
@ -8756,6 +8757,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
|
||||||
++texture_binding;
|
++texture_binding;
|
||||||
}
|
}
|
||||||
uniform.order = -1;
|
uniform.order = -1;
|
||||||
|
uniform.prop_order = prop_index++;
|
||||||
} else {
|
} else {
|
||||||
if (uniform_scope == ShaderNode::Uniform::SCOPE_INSTANCE && (type == TYPE_MAT2 || type == TYPE_MAT3 || type == TYPE_MAT4)) {
|
if (uniform_scope == ShaderNode::Uniform::SCOPE_INSTANCE && (type == TYPE_MAT2 || type == TYPE_MAT3 || type == TYPE_MAT4)) {
|
||||||
_set_error(vformat(RTR("The '%s' qualifier is not supported for matrix types."), "SCOPE_INSTANCE"));
|
_set_error(vformat(RTR("The '%s' qualifier is not supported for matrix types."), "SCOPE_INSTANCE"));
|
||||||
|
@ -8764,6 +8766,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
|
||||||
uniform.texture_order = -1;
|
uniform.texture_order = -1;
|
||||||
if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) {
|
if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) {
|
||||||
uniform.order = uniforms++;
|
uniform.order = uniforms++;
|
||||||
|
uniform.prop_order = prop_index++;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (check_device_limit_warnings) {
|
if (check_device_limit_warnings) {
|
||||||
if (uniform.array_size > 0) {
|
if (uniform.array_size > 0) {
|
||||||
|
|
|
@ -648,6 +648,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int order = 0;
|
int order = 0;
|
||||||
|
int prop_order = 0;
|
||||||
int texture_order = 0;
|
int texture_order = 0;
|
||||||
int texture_binding = 0;
|
int texture_binding = 0;
|
||||||
DataType type = TYPE_VOID;
|
DataType type = TYPE_VOID;
|
||||||
|
@ -664,6 +665,11 @@ public:
|
||||||
String group;
|
String group;
|
||||||
String subgroup;
|
String subgroup;
|
||||||
|
|
||||||
|
_FORCE_INLINE_ bool is_texture() const {
|
||||||
|
// Order is assigned to -1 for texture uniforms.
|
||||||
|
return order < 0;
|
||||||
|
}
|
||||||
|
|
||||||
Uniform() {
|
Uniform() {
|
||||||
hint_range[0] = 0.0f;
|
hint_range[0] = 0.0f;
|
||||||
hint_range[1] = 1.0f;
|
hint_range[1] = 1.0f;
|
||||||
|
|
Loading…
Reference in New Issue