Revert "writer/hlsl: Special case negative zero"

This reverts commit 26b6edc545.

Reason for revert: Seems to be breaking Dawn's tests. Investigation required.

Original change's description:
> writer/hlsl: Special case negative zero
>
> Fixed: tint:960
> Change-Id: I060bc6b7a9ad4d21dd5cadb4b68998c7e54ebaed
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57142
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ben Clayton <bclayton@google.com>
> Auto-Submit: Ben Clayton <bclayton@google.com>
> Reviewed-by: James Price <jrprice@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ia0b0ec996f2ed6b1599a344c970f155c12314ea9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57460
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton 2021-07-08 16:49:33 +00:00 committed by Tint LUCI CQ
parent af89c729ed
commit 5d922d02fc
11 changed files with 7 additions and 147 deletions

View File

@ -2475,20 +2475,13 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, ast::Literal* lit) {
if (auto* l = lit->As<ast::BoolLiteral>()) {
out << (l->IsTrue() ? "true" : "false");
} else if (auto* fl = lit->As<ast::FloatLiteral>()) {
bool positive = std::signbit(fl->value()) == 0;
switch (std::fpclassify(fl->value())) {
case FP_INFINITE:
out << (positive ? "asfloat(0x7f800000u)" : "asfloat(0xff800000u)");
break;
case FP_NAN:
out << "asfloat(0x7fc00000u)";
break;
case FP_ZERO:
out << (positive ? "0.0f" : "asfloat(0xff800000u)");
break;
default:
out << FloatToString(fl->value()) << "f";
break;
if (std::isinf(fl->value())) {
out << (fl->value() >= 0 ? "asfloat(0x7f800000u)"
: "asfloat(0xff800000u)");
} else if (std::isnan(fl->value())) {
out << "asfloat(0x7fc00000u)";
} else {
out << FloatToString(fl->value()) << "f";
}
} else if (auto* sl = lit->As<ast::SintLiteral>()) {
out << sl->value();

View File

@ -1,21 +0,0 @@
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %out_var_SV_TARGET
OpExecutionMode %main OriginUpperLeft
OpSource HLSL 600
OpName %out_var_SV_TARGET "out.var.SV_TARGET"
OpName %main "main"
OpDecorate %out_var_SV_TARGET Location 0
%float = OpTypeFloat 32
%float_0x1p_128 = OpConstant %float -0
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%void = OpTypeVoid
%9 = OpTypeFunction %void
%out_var_SV_TARGET = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %9
%10 = OpLabel
%12 = OpCompositeConstruct %v4float %float_0x1p_128 %float_0x1p_128 %float_0x1p_128 %float_0x1p_128
OpStore %out_var_SV_TARGET %12
OpReturn
OpFunctionEnd

View File

@ -1,20 +0,0 @@
static float4 out_var_SV_TARGET = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
out_var_SV_TARGET = float4(asfloat(0xff800000u), asfloat(0xff800000u), asfloat(0xff800000u), asfloat(0xff800000u));
return;
}
struct main_out {
float4 out_var_SV_TARGET_1;
};
struct tint_symbol {
float4 out_var_SV_TARGET_1 : SV_Target0;
};
tint_symbol main() {
main_1();
const main_out tint_symbol_1 = {out_var_SV_TARGET};
const tint_symbol tint_symbol_2 = {tint_symbol_1.out_var_SV_TARGET_1};
return tint_symbol_2;
}

View File

@ -1,23 +0,0 @@
#include <metal_stdlib>
using namespace metal;
struct main_out {
float4 out_var_SV_TARGET_1;
};
struct tint_symbol_1 {
float4 out_var_SV_TARGET_1 [[color(0)]];
};
void main_1(thread float4* const tint_symbol_4) {
*(tint_symbol_4) = float4(-0.0f, -0.0f, -0.0f, -0.0f);
return;
}
fragment tint_symbol_1 tint_symbol() {
thread float4 tint_symbol_5 = 0.0f;
main_1(&(tint_symbol_5));
main_out const tint_symbol_2 = {.out_var_SV_TARGET_1=tint_symbol_5};
tint_symbol_1 const tint_symbol_3 = {.out_var_SV_TARGET_1=tint_symbol_2.out_var_SV_TARGET_1};
return tint_symbol_3;
}

View File

@ -1,52 +0,0 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 26
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %out_var_SV_TARGET "out_var_SV_TARGET"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %main_1 "main_1"
OpName %main_out "main_out"
OpMemberName %main_out 0 "out_var_SV_TARGET_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpDecorate %tint_symbol_1 Location 0
OpMemberDecorate %main_out 0 Offset 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%5 = OpConstantNull %v4float
%out_var_SV_TARGET = OpVariable %_ptr_Private_v4float Private %5
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %5
%void = OpTypeVoid
%8 = OpTypeFunction %void
%float_n0 = OpConstant %float -0
%13 = OpConstantComposite %v4float %float_n0 %float_n0 %float_n0 %float_n0
%main_out = OpTypeStruct %v4float
%14 = OpTypeFunction %void %main_out
%main_1 = OpFunction %void None %8
%11 = OpLabel
OpStore %out_var_SV_TARGET %13
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %14
%tint_symbol = OpFunctionParameter %main_out
%18 = OpLabel
%19 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %19
OpReturn
OpFunctionEnd
%main = OpFunction %void None %8
%21 = OpLabel
%22 = OpFunctionCall %void %main_1
%24 = OpLoad %v4float %out_var_SV_TARGET
%25 = OpCompositeConstruct %main_out %24
%23 = OpFunctionCall %void %tint_symbol_2 %25
OpReturn
OpFunctionEnd

View File

@ -1,17 +0,0 @@
var<private> out_var_SV_TARGET : vec4<f32>;
fn main_1() {
out_var_SV_TARGET = vec4<f32>(-0.0, -0.0, -0.0, -0.0);
return;
}
struct main_out {
[[location(0)]]
out_var_SV_TARGET_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(out_var_SV_TARGET);
}