Merge pull request #69005 from akien-mga/shaderlang-sampler-uniforms-array-type

Shader: Set proper resource type hints for sampler uniforms
This commit is contained in:
Rémi Verschelde 2022-11-23 08:33:05 +01:00
commit 714b978044
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -4110,43 +4110,41 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform
case ShaderLanguage::TYPE_USAMPLER2D: { case ShaderLanguage::TYPE_USAMPLER2D: {
if (p_uniform.array_size > 0) { if (p_uniform.array_size > 0) {
pi.type = Variant::ARRAY; pi.type = Variant::ARRAY;
pi.hint = PROPERTY_HINT_ARRAY_TYPE;
pi.hint_string = vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D");
} else { } else {
pi.type = Variant::OBJECT; pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture2D";
} }
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture2D";
} break; } break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY: case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY: case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
case ShaderLanguage::TYPE_USAMPLER2DARRAY: { case ShaderLanguage::TYPE_USAMPLER2DARRAY:
case ShaderLanguage::TYPE_SAMPLERCUBE:
case ShaderLanguage::TYPE_SAMPLERCUBEARRAY: {
if (p_uniform.array_size > 0) { if (p_uniform.array_size > 0) {
pi.type = Variant::ARRAY; pi.type = Variant::ARRAY;
pi.hint = PROPERTY_HINT_ARRAY_TYPE;
pi.hint_string = vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "TextureLayered");
} else { } else {
pi.type = Variant::OBJECT; pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureLayered";
} }
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureLayered";
} break; } break;
case ShaderLanguage::TYPE_SAMPLER3D: case ShaderLanguage::TYPE_SAMPLER3D:
case ShaderLanguage::TYPE_ISAMPLER3D: case ShaderLanguage::TYPE_ISAMPLER3D:
case ShaderLanguage::TYPE_USAMPLER3D: { case ShaderLanguage::TYPE_USAMPLER3D: {
if (p_uniform.array_size > 0) { if (p_uniform.array_size > 0) {
pi.type = Variant::ARRAY; pi.type = Variant::ARRAY;
pi.hint = PROPERTY_HINT_ARRAY_TYPE;
pi.hint_string = vformat("%s/%s:%s", Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Texture3D");
} else { } else {
pi.type = Variant::OBJECT; pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture3D";
} }
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture3D";
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE:
case ShaderLanguage::TYPE_SAMPLERCUBEARRAY: {
if (p_uniform.array_size > 0) {
pi.type = Variant::ARRAY;
} else {
pi.type = Variant::OBJECT;
}
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "TextureLayered";
} break; } break;
case ShaderLanguage::TYPE_STRUCT: { case ShaderLanguage::TYPE_STRUCT: {
// FIXME: Implement this. // FIXME: Implement this.