summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/decode
diff options
context:
space:
mode:
authornamkazy <nam.kazt.91@gmail.com>2020-04-06 08:46:55 +0200
committernamkazy <nam.kazt.91@gmail.com>2020-04-06 08:46:55 +0200
commit2c98e14d13c7611f488c351c5b42b1c58d4b33ea (patch)
tree6d68629b66cb3ff19efe5e9269611fccf35fe51a /src/video_core/shader/decode
parentshader_decode: SULD.D avoid duplicate code block. (diff)
downloadyuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar.gz
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar.bz2
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar.lz
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar.xz
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.tar.zst
yuzu-2c98e14d13c7611f488c351c5b42b1c58d4b33ea.zip
Diffstat (limited to 'src/video_core/shader/decode')
-rw-r--r--src/video_core/shader/decode/image.cpp30
1 files changed, 13 insertions, 17 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;