mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-24 10:23:01 -06:00
shader_decode: SULD.D fix decode SNORM component
This commit is contained in:
parent
69657ff19c
commit
6f2b7087c2
1 changed files with 9 additions and 10 deletions
|
@ -350,25 +350,24 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||||
Node converted_value = [&] {
|
Node converted_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 =
|
auto cnv_value = Operation(OperationCode::FMul, original_value, Immediate(127.f));
|
||||||
Operation(OperationCode::FAdd, original_value, Immediate(1.f));
|
cnv_value = SignedOperation(OperationCode::ICastFloat, is_signed,
|
||||||
cnv_value = Operation(OperationCode::FMul, std::move(cnv_value),
|
std::move(cnv_value));
|
||||||
Immediate(127.f));
|
return BitfieldExtract(std::move(cnv_value), 0, 8);
|
||||||
is_signed = false;
|
|
||||||
return SignedOperation(OperationCode::ICastFloat, is_signed,
|
|
||||||
std::move(cnv_value));
|
|
||||||
}
|
}
|
||||||
case ComponentType::UNORM: {
|
case ComponentType::UNORM: {
|
||||||
|
is_signed = false;
|
||||||
// range [0.0, 1.0]
|
// range [0.0, 1.0]
|
||||||
auto cnv_value =
|
auto cnv_value =
|
||||||
Operation(OperationCode::FMul, original_value, Immediate(255.f));
|
Operation(OperationCode::FMul, original_value, Immediate(255.f));
|
||||||
is_signed = false;
|
|
||||||
return SignedOperation(OperationCode::ICastFloat, is_signed,
|
return SignedOperation(OperationCode::ICastFloat, is_signed,
|
||||||
std::move(cnv_value));
|
std::move(cnv_value));
|
||||||
}
|
}
|
||||||
case ComponentType::SINT: // range [-128,128]
|
case ComponentType::SINT: // range [-128,127]
|
||||||
return Operation(OperationCode::IAdd, original_value, Immediate(128));
|
is_signed = true;
|
||||||
|
return original_value;
|
||||||
case ComponentType::UINT: // range [0, 255]
|
case ComponentType::UINT: // range [0, 255]
|
||||||
is_signed = false;
|
is_signed = false;
|
||||||
return original_value;
|
return original_value;
|
||||||
|
|
Loading…
Reference in a new issue