mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
tint/transform: Implement div / mod polyfill
Prevents UB for divide-by-zero and integer overflow when dividing Fixed: tint:1349 Change-Id: Ieef66d27d7aec3011628ced076b2bccc7770a8af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108925 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
9418152d08
commit
46ee63933c
@@ -1,7 +1,11 @@
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 1;
|
||||
const int b = 2;
|
||||
const int r = (a / (b == 0 ? 1 : b));
|
||||
const int r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 1;
|
||||
const int b = 2;
|
||||
const int r = (a / (b == 0 ? 1 : b));
|
||||
const int r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
int r = (a / b);
|
||||
int r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int const a = 1;
|
||||
int const b = 2;
|
||||
int const r = (a / b);
|
||||
int const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,41 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 9
|
||||
; Bound: 25
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%1 = OpTypeFunction %int %int %int
|
||||
%8 = OpConstantNull %int
|
||||
%bool = OpTypeBool
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%int_1 = OpConstant %int 1
|
||||
%void = OpTypeVoid
|
||||
%19 = OpTypeFunction %void
|
||||
%int_2 = OpConstant %int 2
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%8 = OpSDiv %int %int_1 %int_2
|
||||
%tint_div = OpFunction %int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%12 = OpIEqual %bool %lhs %int_n2147483648
|
||||
%14 = OpIEqual %bool %rhs %int_n1
|
||||
%15 = OpLogicalAnd %bool %12 %14
|
||||
%16 = OpLogicalOr %bool %9 %15
|
||||
%7 = OpSelect %int %16 %int_1 %rhs
|
||||
%18 = OpSDiv %int %lhs %7
|
||||
OpReturnValue %18
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %19
|
||||
%22 = OpLabel
|
||||
%24 = OpFunctionCall %int %tint_div %int_1 %int_2
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 1u;
|
||||
const uint b = 2u;
|
||||
const uint r = (a / (b == 0u ? 1u : b));
|
||||
const uint r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 1u;
|
||||
const uint b = 2u;
|
||||
const uint r = (a / (b == 0u ? 1u : b));
|
||||
const uint r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 1u;
|
||||
uint b = 2u;
|
||||
uint r = (a / b);
|
||||
uint r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / select(rhs, 1u, (rhs == 0u)));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint const a = 1u;
|
||||
uint const b = 2u;
|
||||
uint const r = (a / b);
|
||||
uint const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 9
|
||||
; Bound: 19
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%1 = OpTypeFunction %uint %uint %uint
|
||||
%8 = OpConstantNull %uint
|
||||
%bool = OpTypeBool
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%13 = OpTypeFunction %void
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%8 = OpUDiv %uint %uint_1 %uint_2
|
||||
%tint_div = OpFunction %uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %uint
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%7 = OpSelect %uint %9 %uint_1 %rhs
|
||||
%12 = OpUDiv %uint %lhs %7
|
||||
OpReturnValue %12
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %13
|
||||
%16 = OpLabel
|
||||
%18 = OpFunctionCall %uint %tint_div %uint_1 %uint_2
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 4;
|
||||
const int3 b = int3(1, 2, 3);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 4;
|
||||
const int3 b = int3(1, 2, 3);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 4;
|
||||
ivec3 b = ivec3(1, 2, 3);
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
int3 const l = int3(lhs);
|
||||
return (l / select(rhs, int3(1), ((rhs == int3(0)) | ((l == int3((-2147483647 - 1))) & (rhs == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int const a = 4;
|
||||
int3 const b = int3(1, 2, 3);
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,50 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%int_4 = OpConstant %int 4
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %int %v3int
|
||||
%10 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%25 = OpTypeFunction %void
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%11 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%15 = OpConstantNull %v3int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3int Function %15
|
||||
%16 = OpCompositeConstruct %v3int %int_4 %int_4 %int_4
|
||||
%12 = OpSDiv %v3int %16 %11
|
||||
%32 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %v3int
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3int %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%16 = OpIEqual %v3bool %8 %15
|
||||
%19 = OpIEqual %v3bool %rhs %18
|
||||
%20 = OpLogicalAnd %v3bool %16 %19
|
||||
%21 = OpLogicalOr %v3bool %11 %20
|
||||
%9 = OpSelect %v3int %21 %23 %rhs
|
||||
%24 = OpSDiv %v3int %8 %9
|
||||
OpReturnValue %24
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %25
|
||||
%28 = OpLabel
|
||||
%33 = OpFunctionCall %v3int %tint_div %int_4 %32
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 4u;
|
||||
const uint3 b = uint3(1u, 2u, 3u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 4u;
|
||||
const uint3 b = uint3(1u, 2u, 3u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uint lhs, uvec3 rhs) {
|
||||
uvec3 l = uvec3(lhs);
|
||||
return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 4u;
|
||||
uvec3 b = uvec3(1u, 2u, 3u);
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
uint3 const l = uint3(lhs);
|
||||
return (l / select(rhs, uint3(1u), (rhs == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint const a = 4u;
|
||||
uint3 const b = uint3(1u, 2u, 3u);
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %uint %v3uint
|
||||
%10 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%15 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%17 = OpTypeFunction %void
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%11 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%15 = OpConstantNull %v3uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3uint Function %15
|
||||
%16 = OpCompositeConstruct %v3uint %uint_4 %uint_4 %uint_4
|
||||
%12 = OpUDiv %v3uint %16 %11
|
||||
%24 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %v3uint
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3uint %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%9 = OpSelect %v3uint %11 %15 %rhs
|
||||
%16 = OpUDiv %v3uint %8 %9
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %17
|
||||
%20 = OpLabel
|
||||
%25 = OpFunctionCall %v3uint %tint_div %uint_4 %24
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
const int3 r = int3((rhs).xxx);
|
||||
return (lhs / (((r == (0).xxx) | ((lhs == (-2147483648).xxx) & (r == (-1).xxx))) ? (1).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int b = 4;
|
||||
const int3 r = (a / (b == 0 ? 1 : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
const int3 r = int3((rhs).xxx);
|
||||
return (lhs / (((r == (0).xxx) | ((lhs == (-2147483648).xxx) & (r == (-1).xxx))) ? (1).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int b = 4;
|
||||
const int3 r = (a / (b == 0 ? 1 : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
ivec3 a = ivec3(1, 2, 3);
|
||||
int b = 4;
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
int3 const r = int3(rhs);
|
||||
return (lhs / select(r, int3(1), ((r == int3(0)) | ((lhs == int3((-2147483647 - 1))) & (r == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int3 const a = int3(1, 2, 3);
|
||||
int const b = 4;
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,50 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %v3int %int
|
||||
%10 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%25 = OpTypeFunction %void
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%10 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%31 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%int_4 = OpConstant %int 4
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%15 = OpConstantNull %v3int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3int Function %15
|
||||
%16 = OpCompositeConstruct %v3int %int_4 %int_4 %int_4
|
||||
%12 = OpSDiv %v3int %10 %16
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %v3int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3int %rhs %rhs %rhs
|
||||
%11 = OpIEqual %v3bool %8 %10
|
||||
%16 = OpIEqual %v3bool %lhs %15
|
||||
%19 = OpIEqual %v3bool %8 %18
|
||||
%20 = OpLogicalAnd %v3bool %16 %19
|
||||
%21 = OpLogicalOr %v3bool %11 %20
|
||||
%9 = OpSelect %v3int %21 %23 %8
|
||||
%24 = OpSDiv %v3int %lhs %9
|
||||
OpReturnValue %24
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %25
|
||||
%28 = OpLabel
|
||||
%33 = OpFunctionCall %v3int %tint_div %31 %int_4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
const uint3 r = uint3((rhs).xxx);
|
||||
return (lhs / ((r == (0u).xxx) ? (1u).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint b = 4u;
|
||||
const uint3 r = (a / (b == 0u ? 1u : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
const uint3 r = uint3((rhs).xxx);
|
||||
return (lhs / ((r == (0u).xxx) ? (1u).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint b = 4u;
|
||||
const uint3 r = (a / (b == 0u ? 1u : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uvec3 lhs, uint rhs) {
|
||||
uvec3 r = uvec3(rhs);
|
||||
return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uvec3 a = uvec3(1u, 2u, 3u);
|
||||
uint b = 4u;
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
uint3 const r = uint3(rhs);
|
||||
return (lhs / select(r, uint3(1u), (r == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint3 const a = uint3(1u, 2u, 3u);
|
||||
uint const b = 4u;
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %v3uint %uint
|
||||
%10 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%15 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%17 = OpTypeFunction %void
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%23 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%15 = OpConstantNull %v3uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3uint Function %15
|
||||
%16 = OpCompositeConstruct %v3uint %uint_4 %uint_4 %uint_4
|
||||
%12 = OpUDiv %v3uint %10 %16
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %v3uint
|
||||
%rhs = OpFunctionParameter %uint
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3uint %rhs %rhs %rhs
|
||||
%11 = OpIEqual %v3bool %8 %10
|
||||
%9 = OpSelect %v3uint %11 %15 %8
|
||||
%16 = OpUDiv %v3uint %lhs %9
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %17
|
||||
%20 = OpLabel
|
||||
%25 = OpFunctionCall %v3uint %tint_div %23 %uint_4
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / (((rhs == (0).xxx) | ((lhs == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int3 b = int3(4, 5, 6);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / (((rhs == (0).xxx) | ((lhs == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int3 b = int3(4, 5, 6);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
ivec3 a = ivec3(1, 2, 3);
|
||||
ivec3 b = ivec3(4, 5, 6);
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / select(rhs, int3(1), ((rhs == int3(0)) | ((lhs == int3((-2147483647 - 1))) & (rhs == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int3 const a = int3(1, 2, 3);
|
||||
int3 const b = int3(4, 5, 6);
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,52 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 36
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %v3int %v3int
|
||||
%9 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%14 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%17 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%22 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%24 = OpTypeFunction %void
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%10 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%30 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%14 = OpConstantComposite %v3int %int_4 %int_5 %int_6
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%15 = OpSDiv %v3int %10 %14
|
||||
%34 = OpConstantComposite %v3int %int_4 %int_5 %int_6
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %v3int
|
||||
%rhs = OpFunctionParameter %v3int
|
||||
%7 = OpLabel
|
||||
%10 = OpIEqual %v3bool %rhs %9
|
||||
%15 = OpIEqual %v3bool %lhs %14
|
||||
%18 = OpIEqual %v3bool %rhs %17
|
||||
%19 = OpLogicalAnd %v3bool %15 %18
|
||||
%20 = OpLogicalOr %v3bool %10 %19
|
||||
%8 = OpSelect %v3int %20 %22 %rhs
|
||||
%23 = OpSDiv %v3int %lhs %8
|
||||
OpReturnValue %23
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %24
|
||||
%27 = OpLabel
|
||||
%35 = OpFunctionCall %v3int %tint_div %30 %34
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint3 b = uint3(4u, 5u, 6u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint3 b = uint3(4u, 5u, 6u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uvec3 lhs, uvec3 rhs) {
|
||||
return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uvec3 a = uvec3(1u, 2u, 3u);
|
||||
uvec3 b = uvec3(4u, 5u, 6u);
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / select(rhs, uint3(1u), (rhs == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint3 const a = uint3(1u, 2u, 3u);
|
||||
uint3 const b = uint3(4u, 5u, 6u);
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 28
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %v3uint %v3uint
|
||||
%9 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%14 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%16 = OpTypeFunction %void
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%22 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%uint_5 = OpConstant %uint 5
|
||||
%uint_6 = OpConstant %uint 6
|
||||
%14 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%15 = OpUDiv %v3uint %10 %14
|
||||
%26 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %v3uint
|
||||
%rhs = OpFunctionParameter %v3uint
|
||||
%7 = OpLabel
|
||||
%10 = OpIEqual %v3bool %rhs %9
|
||||
%8 = OpSelect %v3uint %10 %14 %rhs
|
||||
%15 = OpUDiv %v3uint %lhs %8
|
||||
OpReturnValue %15
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %16
|
||||
%19 = OpLabel
|
||||
%27 = OpFunctionCall %v3uint %tint_div %22 %26
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 1;
|
||||
const int b = 0;
|
||||
const int r = (a / (b == 0 ? 1 : b));
|
||||
const int r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 1;
|
||||
const int b = 0;
|
||||
const int r = (a / (b == 0 ? 1 : b));
|
||||
const int r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
int r = (a / b);
|
||||
int r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int const a = 1;
|
||||
int const b = 0;
|
||||
int const r = (a / b);
|
||||
int const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 9
|
||||
; Bound: 24
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%1 = OpTypeFunction %int %int %int
|
||||
%8 = OpConstantNull %int
|
||||
%bool = OpTypeBool
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%int_1 = OpConstant %int 1
|
||||
%7 = OpConstantNull %int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%8 = OpSDiv %int %int_1 %7
|
||||
%void = OpTypeVoid
|
||||
%19 = OpTypeFunction %void
|
||||
%tint_div = OpFunction %int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%12 = OpIEqual %bool %lhs %int_n2147483648
|
||||
%14 = OpIEqual %bool %rhs %int_n1
|
||||
%15 = OpLogicalAnd %bool %12 %14
|
||||
%16 = OpLogicalOr %bool %9 %15
|
||||
%7 = OpSelect %int %16 %int_1 %rhs
|
||||
%18 = OpSDiv %int %lhs %7
|
||||
OpReturnValue %18
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %19
|
||||
%22 = OpLabel
|
||||
%23 = OpFunctionCall %int %tint_div %int_1 %8
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 1u;
|
||||
const uint b = 0u;
|
||||
const uint r = (a / (b == 0u ? 1u : b));
|
||||
const uint r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 1u;
|
||||
const uint b = 0u;
|
||||
const uint r = (a / (b == 0u ? 1u : b));
|
||||
const uint r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 1u;
|
||||
uint b = 0u;
|
||||
uint r = (a / b);
|
||||
uint r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / select(rhs, 1u, (rhs == 0u)));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint const a = 1u;
|
||||
uint const b = 0u;
|
||||
uint const r = (a / b);
|
||||
uint const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 9
|
||||
; Bound: 18
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%1 = OpTypeFunction %uint %uint %uint
|
||||
%8 = OpConstantNull %uint
|
||||
%bool = OpTypeBool
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%7 = OpConstantNull %uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%8 = OpUDiv %uint %uint_1 %7
|
||||
%void = OpTypeVoid
|
||||
%13 = OpTypeFunction %void
|
||||
%tint_div = OpFunction %uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %uint
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%7 = OpSelect %uint %9 %uint_1 %rhs
|
||||
%12 = OpUDiv %uint %lhs %7
|
||||
OpReturnValue %12
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %13
|
||||
%16 = OpLabel
|
||||
%17 = OpFunctionCall %uint %tint_div %uint_1 %8
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 4;
|
||||
const int3 b = int3(0, 2, 0);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int a = 4;
|
||||
const int3 b = int3(0, 2, 0);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 4;
|
||||
ivec3 b = ivec3(0, 2, 0);
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
int3 const l = int3(lhs);
|
||||
return (l / select(rhs, int3(1), ((rhs == int3(0)) | ((l == int3((-2147483647 - 1))) & (rhs == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int const a = 4;
|
||||
int3 const b = int3(0, 2, 0);
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,50 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%int_4 = OpConstant %int 4
|
||||
%v3int = OpTypeVector %int 3
|
||||
%8 = OpConstantNull %int
|
||||
%1 = OpTypeFunction %v3int %int %v3int
|
||||
%10 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%25 = OpTypeFunction %void
|
||||
%int_4 = OpConstant %int 4
|
||||
%30 = OpConstantNull %int
|
||||
%int_2 = OpConstant %int 2
|
||||
%10 = OpConstantComposite %v3int %8 %int_2 %8
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%14 = OpConstantNull %v3int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%12 = OpVariable %_ptr_Function_v3int Function %14
|
||||
%15 = OpCompositeConstruct %v3int %int_4 %int_4 %int_4
|
||||
%11 = OpSDiv %v3int %15 %10
|
||||
%32 = OpConstantComposite %v3int %30 %int_2 %30
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %v3int
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3int %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%16 = OpIEqual %v3bool %8 %15
|
||||
%19 = OpIEqual %v3bool %rhs %18
|
||||
%20 = OpLogicalAnd %v3bool %16 %19
|
||||
%21 = OpLogicalOr %v3bool %11 %20
|
||||
%9 = OpSelect %v3int %21 %23 %rhs
|
||||
%24 = OpSDiv %v3int %8 %9
|
||||
OpReturnValue %24
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %25
|
||||
%28 = OpLabel
|
||||
%33 = OpFunctionCall %v3int %tint_div %int_4 %32
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 4u;
|
||||
const uint3 b = uint3(0u, 2u, 0u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint a = 4u;
|
||||
const uint3 b = uint3(0u, 2u, 0u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uint lhs, uvec3 rhs) {
|
||||
uvec3 l = uvec3(lhs);
|
||||
return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 4u;
|
||||
uvec3 b = uvec3(0u, 2u, 0u);
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
uint3 const l = uint3(lhs);
|
||||
return (l / select(rhs, uint3(1u), (rhs == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint const a = 4u;
|
||||
uint3 const b = uint3(0u, 2u, 0u);
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%8 = OpConstantNull %uint
|
||||
%1 = OpTypeFunction %v3uint %uint %v3uint
|
||||
%10 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%15 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%17 = OpTypeFunction %void
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%22 = OpConstantNull %uint
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%10 = OpConstantComposite %v3uint %8 %uint_2 %8
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%14 = OpConstantNull %v3uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%12 = OpVariable %_ptr_Function_v3uint Function %14
|
||||
%15 = OpCompositeConstruct %v3uint %uint_4 %uint_4 %uint_4
|
||||
%11 = OpUDiv %v3uint %15 %10
|
||||
%24 = OpConstantComposite %v3uint %22 %uint_2 %22
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %v3uint
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3uint %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%9 = OpSelect %v3uint %11 %15 %rhs
|
||||
%16 = OpUDiv %v3uint %8 %9
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %17
|
||||
%20 = OpLabel
|
||||
%25 = OpFunctionCall %v3uint %tint_div %uint_4 %24
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
const int3 r = int3((rhs).xxx);
|
||||
return (lhs / (((r == (0).xxx) | ((lhs == (-2147483648).xxx) & (r == (-1).xxx))) ? (1).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int b = 0;
|
||||
const int3 r = (a / (b == 0 ? 1 : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
const int3 r = int3((rhs).xxx);
|
||||
return (lhs / (((r == (0).xxx) | ((lhs == (-2147483648).xxx) & (r == (-1).xxx))) ? (1).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int b = 0;
|
||||
const int3 r = (a / (b == 0 ? 1 : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, int rhs) {
|
||||
ivec3 r = ivec3(rhs);
|
||||
return (lhs / mix(r, ivec3(1), bvec3(uvec3(equal(r, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(r, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
ivec3 a = ivec3(1, 2, 3);
|
||||
int b = 0;
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int3 lhs, int rhs) {
|
||||
int3 const r = int3(rhs);
|
||||
return (lhs / select(r, int3(1), ((r == int3(0)) | ((lhs == int3((-2147483647 - 1))) & (r == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int3 const a = int3(1, 2, 3);
|
||||
int const b = 0;
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,50 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %v3int %int
|
||||
%10 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%25 = OpTypeFunction %void
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%10 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%11 = OpConstantNull %int
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%15 = OpConstantNull %v3int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3int Function %15
|
||||
%16 = OpCompositeConstruct %v3int %11 %11 %11
|
||||
%12 = OpSDiv %v3int %10 %16
|
||||
%31 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%32 = OpConstantNull %int
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %v3int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3int %rhs %rhs %rhs
|
||||
%11 = OpIEqual %v3bool %8 %10
|
||||
%16 = OpIEqual %v3bool %lhs %15
|
||||
%19 = OpIEqual %v3bool %8 %18
|
||||
%20 = OpLogicalAnd %v3bool %16 %19
|
||||
%21 = OpLogicalOr %v3bool %11 %20
|
||||
%9 = OpSelect %v3int %21 %23 %8
|
||||
%24 = OpSDiv %v3int %lhs %9
|
||||
OpReturnValue %24
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %25
|
||||
%28 = OpLabel
|
||||
%33 = OpFunctionCall %v3int %tint_div %31 %32
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
const uint3 r = uint3((rhs).xxx);
|
||||
return (lhs / ((r == (0u).xxx) ? (1u).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint b = 0u;
|
||||
const uint3 r = (a / (b == 0u ? 1u : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
const uint3 r = uint3((rhs).xxx);
|
||||
return (lhs / ((r == (0u).xxx) ? (1u).xxx : r));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint b = 0u;
|
||||
const uint3 r = (a / (b == 0u ? 1u : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uvec3 lhs, uint rhs) {
|
||||
uvec3 r = uvec3(rhs);
|
||||
return (lhs / mix(r, uvec3(1u), equal(r, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uvec3 a = uvec3(1u, 2u, 3u);
|
||||
uint b = 0u;
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint3 lhs, uint rhs) {
|
||||
uint3 const r = uint3(rhs);
|
||||
return (lhs / select(r, uint3(1u), (r == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint3 const a = uint3(1u, 2u, 3u);
|
||||
uint const b = 0u;
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 17
|
||||
; Bound: 26
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %v3uint %uint
|
||||
%10 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%15 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%17 = OpTypeFunction %void
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%11 = OpConstantNull %uint
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%15 = OpConstantNull %v3uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%13 = OpVariable %_ptr_Function_v3uint Function %15
|
||||
%16 = OpCompositeConstruct %v3uint %11 %11 %11
|
||||
%12 = OpUDiv %v3uint %10 %16
|
||||
%23 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%24 = OpConstantNull %uint
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %v3uint
|
||||
%rhs = OpFunctionParameter %uint
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3uint %rhs %rhs %rhs
|
||||
%11 = OpIEqual %v3bool %8 %10
|
||||
%9 = OpSelect %v3uint %11 %15 %8
|
||||
%16 = OpUDiv %v3uint %lhs %9
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %17
|
||||
%20 = OpLabel
|
||||
%25 = OpFunctionCall %v3uint %tint_div %23 %24
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / (((rhs == (0).xxx) | ((lhs == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int3 b = int3(0, 5, 0);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / (((rhs == (0).xxx) | ((lhs == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const int3 a = int3(1, 2, 3);
|
||||
const int3 b = int3(0, 5, 0);
|
||||
const int3 r = (a / (b == int3(0, 0, 0) ? int3(1, 1, 1) : b));
|
||||
const int3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(ivec3 lhs, ivec3 rhs) {
|
||||
return (lhs / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(lhs, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
ivec3 a = ivec3(1, 2, 3);
|
||||
ivec3 b = ivec3(0, 5, 0);
|
||||
ivec3 r = (a / b);
|
||||
ivec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int3 lhs, int3 rhs) {
|
||||
return (lhs / select(rhs, int3(1), ((rhs == int3(0)) | ((lhs == int3((-2147483647 - 1))) & (rhs == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int3 const a = int3(1, 2, 3);
|
||||
int3 const b = int3(0, 5, 0);
|
||||
int3 const r = (a / b);
|
||||
int3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,51 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 15
|
||||
; Bound: 35
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %v3int %v3int
|
||||
%9 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%14 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%17 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%22 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%24 = OpTypeFunction %void
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%10 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%11 = OpConstantNull %int
|
||||
%30 = OpConstantComposite %v3int %int_1 %int_2 %int_3
|
||||
%31 = OpConstantNull %int
|
||||
%int_5 = OpConstant %int 5
|
||||
%13 = OpConstantComposite %v3int %11 %int_5 %11
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%14 = OpSDiv %v3int %10 %13
|
||||
%33 = OpConstantComposite %v3int %31 %int_5 %31
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %v3int
|
||||
%rhs = OpFunctionParameter %v3int
|
||||
%7 = OpLabel
|
||||
%10 = OpIEqual %v3bool %rhs %9
|
||||
%15 = OpIEqual %v3bool %lhs %14
|
||||
%18 = OpIEqual %v3bool %rhs %17
|
||||
%19 = OpLogicalAnd %v3bool %15 %18
|
||||
%20 = OpLogicalOr %v3bool %10 %19
|
||||
%8 = OpSelect %v3int %20 %22 %rhs
|
||||
%23 = OpSDiv %v3int %lhs %8
|
||||
OpReturnValue %23
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %24
|
||||
%27 = OpLabel
|
||||
%34 = OpFunctionCall %v3int %tint_div %30 %33
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint3 b = uint3(0u, 5u, 0u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint3 a = uint3(1u, 2u, 3u);
|
||||
const uint3 b = uint3(0u, 5u, 0u);
|
||||
const uint3 r = (a / (b == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : b));
|
||||
const uint3 r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uvec3 lhs, uvec3 rhs) {
|
||||
return (lhs / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uvec3 a = uvec3(1u, 2u, 3u);
|
||||
uvec3 b = uvec3(0u, 5u, 0u);
|
||||
uvec3 r = (a / b);
|
||||
uvec3 r = tint_div(a, b);
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint3 lhs, uint3 rhs) {
|
||||
return (lhs / select(rhs, uint3(1u), (rhs == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint3 const a = uint3(1u, 2u, 3u);
|
||||
uint3 const b = uint3(0u, 5u, 0u);
|
||||
uint3 const r = (a / b);
|
||||
uint3 const r = tint_div(a, b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,43 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 15
|
||||
; Bound: 27
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %v3uint %v3uint
|
||||
%9 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%14 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%16 = OpTypeFunction %void
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%10 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%11 = OpConstantNull %uint
|
||||
%22 = OpConstantComposite %v3uint %uint_1 %uint_2 %uint_3
|
||||
%23 = OpConstantNull %uint
|
||||
%uint_5 = OpConstant %uint 5
|
||||
%13 = OpConstantComposite %v3uint %11 %uint_5 %11
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%14 = OpUDiv %v3uint %10 %13
|
||||
%25 = OpConstantComposite %v3uint %23 %uint_5 %23
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %v3uint
|
||||
%rhs = OpFunctionParameter %v3uint
|
||||
%7 = OpLabel
|
||||
%10 = OpIEqual %v3bool %rhs %9
|
||||
%8 = OpSelect %v3uint %10 %14 %rhs
|
||||
%15 = OpUDiv %v3uint %lhs %8
|
||||
OpReturnValue %15
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %16
|
||||
%19 = OpLabel
|
||||
%26 = OpFunctionCall %v3uint %tint_div %22 %25
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
int value_or_one_if_zero_int(int value) {
|
||||
return value == 0 ? 1 : value;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
const int r = (a / value_or_one_if_zero_int((b + b)));
|
||||
const int r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
int value_or_one_if_zero_int(int value) {
|
||||
return value == 0 ? 1 : value;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (((rhs == 0) | ((lhs == -2147483648) & (rhs == -1))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
const int r = (a / value_or_one_if_zero_int((b + b)));
|
||||
const int r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / (bool(uint((rhs == 0)) | uint(bool(uint((lhs == -2147483648)) & uint((rhs == -1))))) ? 1 : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
int r = (a / (b + b));
|
||||
int r = tint_div(a, (b + b));
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int tint_div(int lhs, int rhs) {
|
||||
return (lhs / select(rhs, 1, bool((rhs == 0) | bool((lhs == (-2147483647 - 1)) & (rhs == -1)))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
int const r = (a / as_type<int>((as_type<uint>(b) + as_type<uint>(b))));
|
||||
int const r = tint_div(a, as_type<int>((as_type<uint>(b) + as_type<uint>(b))));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,51 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 31
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%1 = OpTypeFunction %int %int %int
|
||||
%8 = OpConstantNull %int
|
||||
%bool = OpTypeBool
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%int_1 = OpConstant %int 1
|
||||
%void = OpTypeVoid
|
||||
%19 = OpTypeFunction %void
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%9 = OpConstantNull %int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function %9
|
||||
%b = OpVariable %_ptr_Function_int Function %9
|
||||
%tint_div = OpFunction %int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %int
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%12 = OpIEqual %bool %lhs %int_n2147483648
|
||||
%14 = OpIEqual %bool %rhs %int_n1
|
||||
%15 = OpLogicalAnd %bool %12 %14
|
||||
%16 = OpLogicalOr %bool %9 %15
|
||||
%7 = OpSelect %int %16 %int_1 %rhs
|
||||
%18 = OpSDiv %int %lhs %7
|
||||
OpReturnValue %18
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %19
|
||||
%22 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function %8
|
||||
%b = OpVariable %_ptr_Function_int Function %8
|
||||
OpStore %a %int_1
|
||||
OpStore %b %9
|
||||
%11 = OpLoad %int %a
|
||||
%12 = OpLoad %int %b
|
||||
%13 = OpLoad %int %b
|
||||
%14 = OpIAdd %int %12 %13
|
||||
%15 = OpSDiv %int %11 %14
|
||||
OpStore %b %8
|
||||
%27 = OpLoad %int %a
|
||||
%28 = OpLoad %int %b
|
||||
%29 = OpLoad %int %b
|
||||
%30 = OpIAdd %int %28 %29
|
||||
%26 = OpFunctionCall %int %tint_div %27 %30
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
uint value_or_one_if_zero_uint(uint value) {
|
||||
return value == 0u ? 1u : value;
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
uint a = 1u;
|
||||
uint b = 0u;
|
||||
const uint r = (a / value_or_one_if_zero_uint((b + b)));
|
||||
const uint r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
uint value_or_one_if_zero_uint(uint value) {
|
||||
return value == 0u ? 1u : value;
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
uint a = 1u;
|
||||
uint b = 0u;
|
||||
const uint r = (a / value_or_one_if_zero_uint((b + b)));
|
||||
const uint r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#version 310 es
|
||||
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 1u;
|
||||
uint b = 0u;
|
||||
uint r = (a / (b + b));
|
||||
uint r = tint_div(a, (b + b));
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint tint_div(uint lhs, uint rhs) {
|
||||
return (lhs / select(rhs, 1u, (rhs == 0u)));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint a = 1u;
|
||||
uint b = 0u;
|
||||
uint const r = (a / (b + b));
|
||||
uint const r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +1,45 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 16
|
||||
; Bound: 25
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%1 = OpTypeFunction %uint %uint %uint
|
||||
%8 = OpConstantNull %uint
|
||||
%bool = OpTypeBool
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%void = OpTypeVoid
|
||||
%13 = OpTypeFunction %void
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%9 = OpConstantNull %uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_uint Function %9
|
||||
%b = OpVariable %_ptr_Function_uint Function %9
|
||||
%tint_div = OpFunction %uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %uint
|
||||
%6 = OpLabel
|
||||
%9 = OpIEqual %bool %rhs %8
|
||||
%7 = OpSelect %uint %9 %uint_1 %rhs
|
||||
%12 = OpUDiv %uint %lhs %7
|
||||
OpReturnValue %12
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %13
|
||||
%16 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_uint Function %8
|
||||
%b = OpVariable %_ptr_Function_uint Function %8
|
||||
OpStore %a %uint_1
|
||||
OpStore %b %9
|
||||
%11 = OpLoad %uint %a
|
||||
%12 = OpLoad %uint %b
|
||||
%13 = OpLoad %uint %b
|
||||
%14 = OpIAdd %uint %12 %13
|
||||
%15 = OpUDiv %uint %11 %14
|
||||
OpStore %b %8
|
||||
%21 = OpLoad %uint %a
|
||||
%22 = OpLoad %uint %b
|
||||
%23 = OpLoad %uint %b
|
||||
%24 = OpIAdd %uint %22 %23
|
||||
%20 = OpFunctionCall %uint %tint_div %21 %24
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
int3 value_or_one_if_zero_int3(int3 value) {
|
||||
return value == int3(0, 0, 0) ? int3(1, 1, 1) : value;
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
int a = 4;
|
||||
int3 b = int3(0, 2, 0);
|
||||
const int3 r = (a / value_or_one_if_zero_int3((b + b)));
|
||||
const int3 r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
int3 value_or_one_if_zero_int3(int3 value) {
|
||||
return value == int3(0, 0, 0) ? int3(1, 1, 1) : value;
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
const int3 l = int3((lhs).xxx);
|
||||
return (l / (((rhs == (0).xxx) | ((l == (-2147483648).xxx) & (rhs == (-1).xxx))) ? (1).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
int a = 4;
|
||||
int3 b = int3(0, 2, 0);
|
||||
const int3 r = (a / value_or_one_if_zero_int3((b + b)));
|
||||
const int3 r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
ivec3 tint_div(int lhs, ivec3 rhs) {
|
||||
ivec3 l = ivec3(lhs);
|
||||
return (l / mix(rhs, ivec3(1), bvec3(uvec3(equal(rhs, ivec3(0))) | uvec3(bvec3(uvec3(equal(l, ivec3(-2147483648))) & uvec3(equal(rhs, ivec3(-1))))))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
int a = 4;
|
||||
ivec3 b = ivec3(0, 2, 0);
|
||||
ivec3 r = (a / (b + b));
|
||||
ivec3 r = tint_div(a, (b + b));
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
int3 tint_div(int lhs, int3 rhs) {
|
||||
int3 const l = int3(lhs);
|
||||
return (l / select(rhs, int3(1), ((rhs == int3(0)) | ((l == int3((-2147483647 - 1))) & (rhs == int3(-1))))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
int a = 4;
|
||||
int3 b = int3(0, 2, 0);
|
||||
int3 const r = (a / as_type<int3>((as_type<uint3>(b) + as_type<uint3>(b))));
|
||||
int3 const r = tint_div(a, as_type<int3>((as_type<uint3>(b) + as_type<uint3>(b))));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,62 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 23
|
||||
; Bound: 42
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%v3int = OpTypeVector %int 3
|
||||
%1 = OpTypeFunction %v3int %int %v3int
|
||||
%10 = OpConstantNull %v3int
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
|
||||
%int_n1 = OpConstant %int -1
|
||||
%18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
|
||||
%int_1 = OpConstant %int 1
|
||||
%23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
|
||||
%void = OpTypeVoid
|
||||
%25 = OpTypeFunction %void
|
||||
%int_4 = OpConstant %int 4
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%9 = OpConstantNull %int
|
||||
%v3int = OpTypeVector %int 3
|
||||
%32 = OpConstantNull %int
|
||||
%int_2 = OpConstant %int 2
|
||||
%12 = OpConstantComposite %v3int %9 %int_2 %9
|
||||
%34 = OpConstantComposite %v3int %32 %int_2 %32
|
||||
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||
%15 = OpConstantNull %v3int
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function %9
|
||||
%b = OpVariable %_ptr_Function_v3int Function %15
|
||||
%21 = OpVariable %_ptr_Function_v3int Function %15
|
||||
%tint_div = OpFunction %v3int None %1
|
||||
%lhs = OpFunctionParameter %int
|
||||
%rhs = OpFunctionParameter %v3int
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3int %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%16 = OpIEqual %v3bool %8 %15
|
||||
%19 = OpIEqual %v3bool %rhs %18
|
||||
%20 = OpLogicalAnd %v3bool %16 %19
|
||||
%21 = OpLogicalOr %v3bool %11 %20
|
||||
%9 = OpSelect %v3int %21 %23 %rhs
|
||||
%24 = OpSDiv %v3int %8 %9
|
||||
OpReturnValue %24
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %25
|
||||
%28 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function %32
|
||||
%b = OpVariable %_ptr_Function_v3int Function %10
|
||||
OpStore %a %int_4
|
||||
OpStore %b %12
|
||||
%16 = OpLoad %int %a
|
||||
%17 = OpLoad %v3int %b
|
||||
%18 = OpLoad %v3int %b
|
||||
%19 = OpIAdd %v3int %17 %18
|
||||
%22 = OpCompositeConstruct %v3int %16 %16 %16
|
||||
%20 = OpSDiv %v3int %22 %19
|
||||
OpStore %b %34
|
||||
%38 = OpLoad %int %a
|
||||
%39 = OpLoad %v3int %b
|
||||
%40 = OpLoad %v3int %b
|
||||
%41 = OpIAdd %v3int %39 %40
|
||||
%37 = OpFunctionCall %v3int %tint_div %38 %41
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
uint3 value_or_one_if_zero_uint3(uint3 value) {
|
||||
return value == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : value;
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
uint a = 4u;
|
||||
uint3 b = uint3(0u, 2u, 0u);
|
||||
const uint3 r = (a / value_or_one_if_zero_uint3((b + b)));
|
||||
const uint3 r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
uint3 value_or_one_if_zero_uint3(uint3 value) {
|
||||
return value == uint3(0u, 0u, 0u) ? uint3(1u, 1u, 1u) : value;
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
const uint3 l = uint3((lhs).xxx);
|
||||
return (l / ((rhs == (0u).xxx) ? (1u).xxx : rhs));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
uint a = 4u;
|
||||
uint3 b = uint3(0u, 2u, 0u);
|
||||
const uint3 r = (a / value_or_one_if_zero_uint3((b + b)));
|
||||
const uint3 r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 310 es
|
||||
|
||||
uvec3 tint_div(uint lhs, uvec3 rhs) {
|
||||
uvec3 l = uvec3(lhs);
|
||||
return (l / mix(rhs, uvec3(1u), equal(rhs, uvec3(0u))));
|
||||
}
|
||||
|
||||
void f() {
|
||||
uint a = 4u;
|
||||
uvec3 b = uvec3(0u, 2u, 0u);
|
||||
uvec3 r = (a / (b + b));
|
||||
uvec3 r = tint_div(a, (b + b));
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
uint3 tint_div(uint lhs, uint3 rhs) {
|
||||
uint3 const l = uint3(lhs);
|
||||
return (l / select(rhs, uint3(1u), (rhs == uint3(0u))));
|
||||
}
|
||||
|
||||
kernel void f() {
|
||||
uint a = 4u;
|
||||
uint3 b = uint3(0u, 2u, 0u);
|
||||
uint3 const r = (a / (b + b));
|
||||
uint3 const r = tint_div(a, (b + b));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,54 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 23
|
||||
; Bound: 34
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %f "f"
|
||||
OpExecutionMode %f LocalSize 1 1 1
|
||||
OpName %tint_div "tint_div"
|
||||
OpName %lhs "lhs"
|
||||
OpName %rhs "rhs"
|
||||
OpName %f "f"
|
||||
OpName %a "a"
|
||||
OpName %b "b"
|
||||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%1 = OpTypeFunction %v3uint %uint %v3uint
|
||||
%10 = OpConstantNull %v3uint
|
||||
%bool = OpTypeBool
|
||||
%v3bool = OpTypeVector %bool 3
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%15 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||
%void = OpTypeVoid
|
||||
%17 = OpTypeFunction %void
|
||||
%uint_4 = OpConstant %uint 4
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%9 = OpConstantNull %uint
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%24 = OpConstantNull %uint
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%12 = OpConstantComposite %v3uint %9 %uint_2 %9
|
||||
%26 = OpConstantComposite %v3uint %24 %uint_2 %24
|
||||
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||
%15 = OpConstantNull %v3uint
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_uint Function %9
|
||||
%b = OpVariable %_ptr_Function_v3uint Function %15
|
||||
%21 = OpVariable %_ptr_Function_v3uint Function %15
|
||||
%tint_div = OpFunction %v3uint None %1
|
||||
%lhs = OpFunctionParameter %uint
|
||||
%rhs = OpFunctionParameter %v3uint
|
||||
%7 = OpLabel
|
||||
%8 = OpCompositeConstruct %v3uint %lhs %lhs %lhs
|
||||
%11 = OpIEqual %v3bool %rhs %10
|
||||
%9 = OpSelect %v3uint %11 %15 %rhs
|
||||
%16 = OpUDiv %v3uint %8 %9
|
||||
OpReturnValue %16
|
||||
OpFunctionEnd
|
||||
%f = OpFunction %void None %17
|
||||
%20 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_uint Function %24
|
||||
%b = OpVariable %_ptr_Function_v3uint Function %10
|
||||
OpStore %a %uint_4
|
||||
OpStore %b %12
|
||||
%16 = OpLoad %uint %a
|
||||
%17 = OpLoad %v3uint %b
|
||||
%18 = OpLoad %v3uint %b
|
||||
%19 = OpIAdd %v3uint %17 %18
|
||||
%22 = OpCompositeConstruct %v3uint %16 %16 %16
|
||||
%20 = OpUDiv %v3uint %22 %19
|
||||
OpStore %b %26
|
||||
%30 = OpLoad %uint %a
|
||||
%31 = OpLoad %v3uint %b
|
||||
%32 = OpLoad %v3uint %b
|
||||
%33 = OpIAdd %v3uint %31 %32
|
||||
%29 = OpFunctionCall %v3uint %tint_div %30 %33
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user