mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +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,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
|
||||
|
||||
Reference in New Issue
Block a user