tint: Fix MSL generation of '&' and '|' with booleans

The bitwise-and and bitwise-or binary operators on booleans result in an integer.
Explicitly cast this back to a boolean.

Fixed: tint:1540
Fixed: tint:1541
Change-Id: I395176f291e6080c88b8cff18e14ed6cd1234074
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90501
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2022-05-16 12:02:52 +00:00
committed by Dawn LUCI CQ
parent 35f0fcaac0
commit e6b6777c8e
26 changed files with 316 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
@stage(compute) @workgroup_size(1)
fn f() {
let a = vec3<bool>(true, true, false);
let b = vec3<bool>(true, false, true);
let r : vec3<bool> = a & b;
}

View File

@@ -0,0 +1,13 @@
#version 310 es
void f() {
bvec3 a = bvec3(true, true, false);
bvec3 b = bvec3(true, false, true);
bvec3 r = bvec3(uvec3(a) & uvec3(b));
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,7 @@
[numthreads(1, 1, 1)]
void f() {
const bool3 a = bool3(true, true, false);
const bool3 b = bool3(true, false, true);
const bool3 r = (a & b);
return;
}

View File

@@ -0,0 +1,10 @@
#include <metal_stdlib>
using namespace metal;
kernel void f() {
bool3 const a = bool3(true, true, false);
bool3 const b = bool3(true, false, true);
bool3 const r = (a & b);
return;
}

View File

@@ -0,0 +1,23 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 12
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %f "f"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%bool = OpTypeBool
%v3bool = OpTypeVector %bool 3
%true = OpConstantTrue %bool
%false = OpConstantFalse %bool
%9 = OpConstantComposite %v3bool %true %true %false
%10 = OpConstantComposite %v3bool %true %false %true
%f = OpFunction %void None %1
%4 = OpLabel
%11 = OpLogicalAnd %v3bool %9 %10
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
@stage(compute) @workgroup_size(1)
fn f() {
let a = vec3<bool>(true, true, false);
let b = vec3<bool>(true, false, true);
let r : vec3<bool> = (a & b);
}