shader_decode: SULD.D using std::pair instead of out parameter
This commit is contained in:
parent
9efa51311f
commit
2c98e14d13
@ -271,37 +271,36 @@ std::size_t GetImageTypeNumCoordinates(Tegra::Shader::ImageType image_type) {
|
|||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
Node ShaderIR::GetComponentValue(ComponentType component_type, u32 component_size,
|
std::pair<Node, bool> ShaderIR::GetComponentValue(ComponentType component_type, u32 component_size,
|
||||||
Node original_value, bool* is_signed) {
|
Node original_value) {
|
||||||
switch (component_type) {
|
switch (component_type) {
|
||||||
case ComponentType::SNORM: {
|
case ComponentType::SNORM: {
|
||||||
*is_signed = true;
|
|
||||||
// range [-1.0, 1.0]
|
// range [-1.0, 1.0]
|
||||||
auto cnv_value = Operation(OperationCode::FMul, original_value,
|
auto cnv_value = Operation(OperationCode::FMul, original_value,
|
||||||
Immediate(static_cast<float>(1 << component_size) / 2.f - 1.f));
|
Immediate(static_cast<float>(1 << component_size) / 2.f - 1.f));
|
||||||
cnv_value = SignedOperation(OperationCode::ICastFloat, is_signed, std::move(cnv_value));
|
cnv_value = Operation(OperationCode::ICastFloat, std::move(cnv_value));
|
||||||
return BitfieldExtract(std::move(cnv_value), 0, component_size);
|
return {BitfieldExtract(std::move(cnv_value), 0, component_size), true};
|
||||||
}
|
}
|
||||||
case ComponentType::SINT:
|
case ComponentType::SINT:
|
||||||
case ComponentType::UNORM: {
|
case ComponentType::UNORM: {
|
||||||
*is_signed = component_type == ComponentType::SINT;
|
bool is_signed = component_type == ComponentType::SINT;
|
||||||
// range [0.0, 1.0]
|
// range [0.0, 1.0]
|
||||||
auto cnv_value = Operation(OperationCode::FMul, original_value,
|
auto cnv_value = Operation(OperationCode::FMul, original_value,
|
||||||
Immediate(static_cast<float>(1 << component_size) - 1.f));
|
Immediate(static_cast<float>(1 << component_size) - 1.f));
|
||||||
return SignedOperation(OperationCode::ICastFloat, is_signed, std::move(cnv_value));
|
return {SignedOperation(OperationCode::ICastFloat, is_signed, std::move(cnv_value)),
|
||||||
|
is_signed};
|
||||||
}
|
}
|
||||||
case ComponentType::UINT: // range [0, (1 << component_size) - 1]
|
case ComponentType::UINT: // range [0, (1 << component_size) - 1]
|
||||||
*is_signed = false;
|
return {original_value, false};
|
||||||
return original_value;
|
|
||||||
case ComponentType::FLOAT:
|
case ComponentType::FLOAT:
|
||||||
if (component_size == 16) {
|
if (component_size == 16) {
|
||||||
return Operation(OperationCode::HCastFloat, original_value);
|
return {Operation(OperationCode::HCastFloat, original_value), true};
|
||||||
} else {
|
} else {
|
||||||
return original_value;
|
return {original_value, true};
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
UNIMPLEMENTED_MSG("Unimplement component type={}", component_type);
|
UNIMPLEMENTED_MSG("Unimplement component type={}", component_type);
|
||||||
return original_value;
|
return {original_value, true};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,14 +376,11 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
|||||||
}
|
}
|
||||||
const auto component_type = GetComponentType(descriptor, element);
|
const auto component_type = GetComponentType(descriptor, element);
|
||||||
const auto component_size = GetComponentSize(descriptor.format, element);
|
const auto component_size = GetComponentSize(descriptor.format, element);
|
||||||
|
|
||||||
bool is_signed = true;
|
|
||||||
MetaImage meta{image, {}, element};
|
MetaImage meta{image, {}, element};
|
||||||
|
|
||||||
Node converted_value = GetComponentValue(
|
auto [converted_value, is_signed] = GetComponentValue(
|
||||||
component_type, component_size,
|
component_type, component_size,
|
||||||
Operation(OperationCode::ImageLoad, meta, GetCoordinates(type)),
|
Operation(OperationCode::ImageLoad, meta, GetCoordinates(type)));
|
||||||
&is_signed);
|
|
||||||
|
|
||||||
// shift element to correct position
|
// shift element to correct position
|
||||||
const auto shifted = shifted_counter;
|
const auto shifted = shifted_counter;
|
||||||
|
@ -313,8 +313,8 @@ private:
|
|||||||
Node GetSaturatedHalfFloat(Node value, bool saturate = true);
|
Node GetSaturatedHalfFloat(Node value, bool saturate = true);
|
||||||
|
|
||||||
/// Get image component value by type and size
|
/// Get image component value by type and size
|
||||||
Node GetComponentValue(Tegra::Texture::ComponentType component_type, u32 component_size,
|
std::pair<Node, bool> GetComponentValue(Tegra::Texture::ComponentType component_type,
|
||||||
const Node original_value, bool* is_signed);
|
u32 component_size, Node original_value);
|
||||||
|
|
||||||
/// Returns a predicate comparing two floats
|
/// Returns a predicate comparing two floats
|
||||||
Node GetPredicateComparisonFloat(Tegra::Shader::PredCondition condition, Node op_a, Node op_b);
|
Node GetPredicateComparisonFloat(Tegra::Shader::PredCondition condition, Node op_a, Node op_b);
|
||||||
|
Loading…
Reference in New Issue
Block a user