Apply suggestions from code review

Co-Authored-By: Rodrigo Locatti <reinuseslisp@airmail.cc>
This commit is contained in:
Nguyen Dac Nam 2020-04-07 07:55:49 +07:00 committed by GitHub
parent 2c98e14d13
commit bf1174c114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,19 +141,19 @@ u32 GetComponentSize(TextureFormat format, std::size_t component) {
case TextureFormat::R16_G16_B16_A16: case TextureFormat::R16_G16_B16_A16:
return 16; return 16;
case TextureFormat::R32_G32_B32: case TextureFormat::R32_G32_B32:
return (component == 0 || component == 1 || component == 2) ? 32 : 0; return component <= 2 ? 32 : 0;
case TextureFormat::R32_G32: case TextureFormat::R32_G32:
return (component == 0 || component == 1) ? 32 : 0; return component <= 1 ? 32 : 0;
case TextureFormat::R16_G16: case TextureFormat::R16_G16:
return (component == 0 || component == 1) ? 16 : 0; return component <= 1 ? 16 : 0;
case TextureFormat::R32: case TextureFormat::R32:
return (component == 0) ? 32 : 0; return component == 0 ? 32 : 0;
case TextureFormat::R16: case TextureFormat::R16:
return (component == 0) ? 16 : 0; return component == 0 ? 16 : 0;
case TextureFormat::R8: case TextureFormat::R8:
return (component == 0) ? 8 : 0; return component == 0 ? 8 : 0;
case TextureFormat::R1: case TextureFormat::R1:
return (component == 0) ? 1 : 0; return component == 0 ? 1 : 0;
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
return 8; return 8;
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
@ -296,11 +296,11 @@ std::pair<Node, bool> ShaderIR::GetComponentValue(ComponentType component_type,
if (component_size == 16) { if (component_size == 16) {
return {Operation(OperationCode::HCastFloat, original_value), true}; return {Operation(OperationCode::HCastFloat, original_value), true};
} else { } else {
return {original_value, true}; return {std::move(original_value), true};
} }
default: default:
UNIMPLEMENTED_MSG("Unimplement component type={}", component_type); UNIMPLEMENTED_MSG("Unimplement component type={}", component_type);
return {original_value, true}; return {std::move(original_value), true};
} }
} }