summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/video_core/shader/decode/image.cpp30
-rw-r--r--src/video_core/shader/shader_ir.h4
2 files changed, 15 insertions, 19 deletions
diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp
index 242cd6cc1..7ad908a0e 100644
--- a/src/video_core/shader/decode/image.cpp
+++ b/src/video_core/shader/decode/image.cpp
@@ -271,37 +271,36 @@ std::size_t GetImageTypeNumCoordinates(Tegra::Shader::ImageType image_type) {
}
} // Anonymous namespace
-Node ShaderIR::GetComponentValue(ComponentType component_type, u32 component_size,
- Node original_value, bool* is_signed) {
+std::pair<Node, bool> ShaderIR::GetComponentValue(ComponentType component_type, u32 component_size,
+ Node original_value) {
switch (component_type) {
case ComponentType::SNORM: {
- *is_signed = true;
// range [-1.0, 1.0]
auto cnv_value = Operation(OperationCode::FMul, original_value,
Immediate(static_cast<float>(1 << component_size) / 2.f - 1.f));
- cnv_value = SignedOperation(OperationCode::ICastFloat, is_signed, std::move(cnv_value));
- return BitfieldExtract(std::move(cnv_value), 0, component_size);
+ cnv_value = Operation(OperationCode::ICastFloat, std::move(cnv_value));
+ return {BitfieldExtract(std::move(cnv_value), 0, component_size), true};
}
case ComponentType::SINT:
case ComponentType::UNORM: {
- *is_signed = component_type == ComponentType::SINT;
+ bool is_signed = component_type == ComponentType::SINT;
// range [0.0, 1.0]
auto cnv_value = Operation(OperationCode::FMul, original_value,
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]
- *is_signed = false;
- return original_value;
+ return {original_value, false};
case ComponentType::FLOAT:
if (component_size == 16) {
- return Operation(OperationCode::HCastFloat, original_value);
+ return {Operation(OperationCode::HCastFloat, original_value), true};
} else {
- return original_value;
+ return {original_value, true};
}
default:
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_size = GetComponentSize(descriptor.format, element);
-
- bool is_signed = true;
MetaImage meta{image, {}, element};
- Node converted_value = GetComponentValue(
+ auto [converted_value, is_signed] = GetComponentValue(
component_type, component_size,
- Operation(OperationCode::ImageLoad, meta, GetCoordinates(type)),
- &is_signed);
+ Operation(OperationCode::ImageLoad, meta, GetCoordinates(type)));
// shift element to correct position
const auto shifted = shifted_counter;
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 408cce71e..ca6c976c9 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -313,8 +313,8 @@ private:
Node GetSaturatedHalfFloat(Node value, bool saturate = true);
/// Get image component value by type and size
- Node GetComponentValue(Tegra::Texture::ComponentType component_type, u32 component_size,
- const Node original_value, bool* is_signed);
+ std::pair<Node, bool> GetComponentValue(Tegra::Texture::ComponentType component_type,
+ u32 component_size, Node original_value);
/// Returns a predicate comparing two floats
Node GetPredicateComparisonFloat(Tegra::Shader::PredCondition condition, Node op_a, Node op_b);