tint/writer: Replace use of strings for cache keys

Concatenating strings to use for cache keys is horribly inefficent and very error prone.

Add a UnorderedKeyWrapper helper to allow types to be used as a unordered_map and unordered_set key. Use this for the type_constructor_to_id_ map.

Produces SPIR-V with some duplicate SPIR-V instructions for constructors removed.

Change-Id: Ib072d485ca28bb07f03e979c133cdce1f69ee482
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88300
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-04-28 13:08:22 +00:00
committed by Dawn LUCI CQ
parent 89fe801dff
commit 046abc08e8
8 changed files with 189 additions and 84 deletions

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 73
; Bound: 72
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -69,12 +69,11 @@
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
%61 = OpConstantNull %v3uint
%63 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
%65 = OpConstantComposite %v3bool %true %true %true
%v4bool = OpTypeVector %bool 4
%false = OpConstantFalse %bool
%69 = OpConstantComposite %v4bool %true %false %true %false
%68 = OpConstantComposite %v4bool %true %false %true %false
%_ptr_Function_v4bool = OpTypePointer Function %v4bool
%72 = OpConstantNull %v4bool
%71 = OpConstantNull %v4bool
%constant_with_non_constant = OpFunction %void None %1
%4 = OpLabel
%a = OpVariable %_ptr_Function_float Function %6
@@ -107,7 +106,7 @@
%v3u32_var2 = OpVariable %_ptr_Function_v3uint Function %61
%v3u32_var3 = OpVariable %_ptr_Function_v3uint Function %61
%v3bool_var4 = OpVariable %_ptr_Function_v3bool Function %45
%v4bool_var5 = OpVariable %_ptr_Function_v4bool Function %72
%v4bool_var5 = OpVariable %_ptr_Function_v4bool Function %71
OpStore %bool_var1 %true
OpStore %bool_var2 %true
OpStore %bool_var3 %true
@@ -127,7 +126,7 @@
OpStore %v3u32_var1 %58
OpStore %v3u32_var2 %58
OpStore %v3u32_var3 %63
OpStore %v3bool_var4 %65
OpStore %v4bool_var5 %69
OpStore %v3bool_var4 %42
OpStore %v4bool_var5 %68
OpReturn
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 55
; Bound: 54
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -64,43 +64,42 @@
%v3u32_var1 = OpVariable %_ptr_Private_v3uint Private %32
%v3u32_var2 = OpVariable %_ptr_Private_v3uint Private %32
%v3u32_var3 = OpVariable %_ptr_Private_v3uint Private %32
%37 = OpConstantComposite %v3bool %true %true %true
%v3bool_var4 = OpVariable %_ptr_Private_v3bool Private %37
%v3bool_var4 = OpVariable %_ptr_Private_v3bool Private %20
%v4bool = OpTypeVector %bool 4
%false = OpConstantFalse %bool
%41 = OpConstantComposite %v4bool %true %false %true %false
%40 = OpConstantComposite %v4bool %true %false %true %false
%_ptr_Private_v4bool = OpTypePointer Private %v4bool
%v4bool_var5 = OpVariable %_ptr_Private_v4bool Private %41
%v4bool_var5 = OpVariable %_ptr_Private_v4bool Private %40
%void = OpTypeVoid
%44 = OpTypeFunction %void
%48 = OpConstantNull %bool
%49 = OpConstantNull %int
%50 = OpConstantNull %uint
%51 = OpConstantNull %v3bool
%52 = OpConstantNull %v4bool
%53 = OpConstantNull %v3int
%54 = OpConstantNull %v3uint
%main = OpFunction %void None %44
%47 = OpLabel
OpStore %bool_var1 %48
OpStore %bool_var2 %48
OpStore %bool_var3 %48
OpStore %i32_var1 %49
OpStore %i32_var2 %49
OpStore %i32_var3 %49
OpStore %u32_var1 %50
OpStore %u32_var2 %50
OpStore %u32_var3 %50
OpStore %v3bool_var1 %51
OpStore %v3bool_var2 %51
OpStore %v3bool_var3 %51
OpStore %v3bool_var4 %51
OpStore %v4bool_var5 %52
OpStore %v3i32_var1 %53
OpStore %v3i32_var2 %53
OpStore %v3i32_var3 %53
OpStore %v3u32_var1 %54
OpStore %v3u32_var2 %54
OpStore %v3u32_var3 %54
%43 = OpTypeFunction %void
%47 = OpConstantNull %bool
%48 = OpConstantNull %int
%49 = OpConstantNull %uint
%50 = OpConstantNull %v3bool
%51 = OpConstantNull %v4bool
%52 = OpConstantNull %v3int
%53 = OpConstantNull %v3uint
%main = OpFunction %void None %43
%46 = OpLabel
OpStore %bool_var1 %47
OpStore %bool_var2 %47
OpStore %bool_var3 %47
OpStore %i32_var1 %48
OpStore %i32_var2 %48
OpStore %i32_var3 %48
OpStore %u32_var1 %49
OpStore %u32_var2 %49
OpStore %u32_var3 %49
OpStore %v3bool_var1 %50
OpStore %v3bool_var2 %50
OpStore %v3bool_var3 %50
OpStore %v3bool_var4 %50
OpStore %v4bool_var5 %51
OpStore %v3i32_var1 %52
OpStore %v3i32_var2 %52
OpStore %v3i32_var3 %52
OpStore %v3u32_var1 %53
OpStore %v3u32_var2 %53
OpStore %v3u32_var3 %53
OpReturn
OpFunctionEnd