mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
tint: fix builtin calls and binary ops with abstract args of different type
If a call to atan2 with args of type AFloat and AInt is made, Resolver would correctly select the atan2(AFloat, AFloat) overload, but if the input args were of type (AFloat, AInt), it would attempt to constant evaluate without first converting the AInt arg to AFloat. The same would occur for a binary operation, say AFloat + AInt. Before constant evaluating, the Resolver now converts AInt to AFloat if necessary. Bug: chromium:1350147 Change-Id: I85390c5d7af7e706115278ece34b2b18b8574f9f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98543 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
90d5eb6128
commit
a58d8c9fac
25
test/tint/bug/chromium/1350147.wgsl
Normal file
25
test/tint/bug/chromium/1350147.wgsl
Normal file
@@ -0,0 +1,25 @@
|
||||
fn original_clusterfuzz_code() {
|
||||
atan2(1,.1);
|
||||
}
|
||||
|
||||
fn more_tests_that_would_fail() {
|
||||
// Builtin calls with mixed abstract args would fail because AInt would not materialize to AFloat.
|
||||
{
|
||||
let a = atan2(1, 0.1);
|
||||
let b = atan2(0.1, 1);
|
||||
}
|
||||
|
||||
// Same for binary operators
|
||||
{
|
||||
let a = 1 + 1.5;
|
||||
let b = 1.5 + 1;
|
||||
}
|
||||
|
||||
// Once above was fixed, builtin calls without assignment would also fail in backends because
|
||||
// abstract constant value is not handled by backends. These should be removed by RemovePhonies
|
||||
// transform.
|
||||
{
|
||||
atan2(1, 0.1);
|
||||
atan2(0.1, 1);
|
||||
}
|
||||
}
|
||||
20
test/tint/bug/chromium/1350147.wgsl.expected.dxc.hlsl
Normal file
20
test/tint/bug/chromium/1350147.wgsl.expected.dxc.hlsl
Normal file
@@ -0,0 +1,20 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void original_clusterfuzz_code() {
|
||||
}
|
||||
|
||||
void more_tests_that_would_fail() {
|
||||
{
|
||||
const float a = 1.471127629f;
|
||||
const float b = 0.099668652f;
|
||||
}
|
||||
{
|
||||
const float a = 2.5f;
|
||||
const float b = 2.5f;
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
20
test/tint/bug/chromium/1350147.wgsl.expected.fxc.hlsl
Normal file
20
test/tint/bug/chromium/1350147.wgsl.expected.fxc.hlsl
Normal file
@@ -0,0 +1,20 @@
|
||||
[numthreads(1, 1, 1)]
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
|
||||
void original_clusterfuzz_code() {
|
||||
}
|
||||
|
||||
void more_tests_that_would_fail() {
|
||||
{
|
||||
const float a = 1.471127629f;
|
||||
const float b = 0.099668652f;
|
||||
}
|
||||
{
|
||||
const float a = 2.5f;
|
||||
const float b = 2.5f;
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
22
test/tint/bug/chromium/1350147.wgsl.expected.glsl
Normal file
22
test/tint/bug/chromium/1350147.wgsl.expected.glsl
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
void unused_entry_point() {
|
||||
return;
|
||||
}
|
||||
void original_clusterfuzz_code() {
|
||||
}
|
||||
|
||||
void more_tests_that_would_fail() {
|
||||
{
|
||||
float a = 1.471127629f;
|
||||
float b = 0.099668652f;
|
||||
}
|
||||
{
|
||||
float a = 2.5f;
|
||||
float b = 2.5f;
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
19
test/tint/bug/chromium/1350147.wgsl.expected.msl
Normal file
19
test/tint/bug/chromium/1350147.wgsl.expected.msl
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
void original_clusterfuzz_code() {
|
||||
}
|
||||
|
||||
void more_tests_that_would_fail() {
|
||||
{
|
||||
float const a = 1.471127629f;
|
||||
float const b = 0.099668652f;
|
||||
}
|
||||
{
|
||||
float const a = 2.5f;
|
||||
float const b = 2.5f;
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
30
test/tint/bug/chromium/1350147.wgsl.expected.spvasm
Normal file
30
test/tint/bug/chromium/1350147.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,30 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 13
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
|
||||
OpExecutionMode %unused_entry_point LocalSize 1 1 1
|
||||
OpName %unused_entry_point "unused_entry_point"
|
||||
OpName %original_clusterfuzz_code "original_clusterfuzz_code"
|
||||
OpName %more_tests_that_would_fail "more_tests_that_would_fail"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%float_1_47112763 = OpConstant %float 1.47112763
|
||||
%float_0_0996686518 = OpConstant %float 0.0996686518
|
||||
%float_2_5 = OpConstant %float 2.5
|
||||
%unused_entry_point = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%original_clusterfuzz_code = OpFunction %void None %1
|
||||
%6 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%more_tests_that_would_fail = OpFunction %void None %1
|
||||
%8 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
18
test/tint/bug/chromium/1350147.wgsl.expected.wgsl
Normal file
18
test/tint/bug/chromium/1350147.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,18 @@
|
||||
fn original_clusterfuzz_code() {
|
||||
atan2(1, 0.100000001);
|
||||
}
|
||||
|
||||
fn more_tests_that_would_fail() {
|
||||
{
|
||||
let a = atan2(1, 0.100000001);
|
||||
let b = atan2(0.100000001, 1);
|
||||
}
|
||||
{
|
||||
let a = (1 + 1.5);
|
||||
let b = (1.5 + 1);
|
||||
}
|
||||
{
|
||||
atan2(1, 0.100000001);
|
||||
atan2(0.100000001, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user