Update to server to handle Vulkan

Change-Id: I3a0a86d757aadeb4c602c68b340e132df220fc68
diff --git a/cc/gapii/vulkan_spy_4.cpp b/cc/gapii/vulkan_spy_4.cpp
index f65a842..0f00c82 100644
--- a/cc/gapii/vulkan_spy_4.cpp
+++ b/cc/gapii/vulkan_spy_4.cpp
@@ -912,9 +912,6 @@
 
     try {
         do {
-            VkCommandBuffer l_GetCommandBuffer_0_commandBuffer = commandBuffer;
-            std::shared_ptr<CommandBufferObject> l_GetCommandBuffer_0_result = findOrZero(this->State.mCommandBuffers, l_GetCommandBuffer_0_commandBuffer);
-            std::shared_ptr<CommandBufferObject> l_commandBufferObject = l_GetCommandBuffer_0_result;
             call();
             break;
         } while(false);
diff --git a/gapid/gfxapi/all/all.go b/gapid/gfxapi/all/all.go
index 76f87bc..e227b3e 100644
--- a/gapid/gfxapi/all/all.go
+++ b/gapid/gfxapi/all/all.go
@@ -20,6 +20,7 @@
 	"android.googlesource.com/platform/tools/gpu/framework/binary/schema"
 	"android.googlesource.com/platform/tools/gpu/gapid/atom"
 	"android.googlesource.com/platform/tools/gpu/gapid/gfxapi/gles"
+	"android.googlesource.com/platform/tools/gpu/gapid/gfxapi/vulkan"
 )
 
 var GraphicsNamespace = registry.NewNamespace()
@@ -27,6 +28,7 @@
 func init() {
 	GraphicsNamespace.Add((*atom.FramebufferObservation)(nil).Class())
 	GraphicsNamespace.AddFallbacks(gles.Namespace)
+	GraphicsNamespace.AddFallbacks(vulkan.Namespace)
 }
 
 func VisitConstantSets(visitor func(schema.ConstantSet)) {
diff --git a/gapid/gfxapi/templates/api.go.tmpl b/gapid/gfxapi/templates/api.go.tmpl
index 399a5ce..72fe926 100644
--- a/gapid/gfxapi/templates/api.go.tmpl
+++ b/gapid/gfxapi/templates/api.go.tmpl
@@ -145,10 +145,19 @@
 {{define "Array"}}
   {{AssertType $ "StaticArray"}}
 
-  type {{Template "Go.Type" $}} struct {
+  {{$ty := Macro "Go.Type" $}}
+  type {{$ty}} struct {
     binary.Generate
     Elements [{{$.Size}}]{{Template "Go.Type" $.ValueType}}
   }
+  {{if IsNumericType $.ValueType}}
+  func (a {{$ty}}) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+    for _, v := range a.Elements {
+      ϟb.Push({{Template "Go.Replay.Value" "Type" $.ValueType "Name" "v"}})
+    }
+    return ϟb.Buffer({{$.Size}})
+  }
+  {{end}}
 {{end}}
 
 
diff --git a/gapid/gfxapi/templates/go_common.tmpl b/gapid/gfxapi/templates/go_common.tmpl
index 7bd8ffe..cad4bb1 100644
--- a/gapid/gfxapi/templates/go_common.tmpl
+++ b/gapid/gfxapi/templates/go_common.tmpl
@@ -331,6 +331,7 @@
   {{else if IsBool        $.Type}}value.Bool({{$.Name}})
   {{else if IsS8          $.Type}}value.S8({{$.Name}})
   {{else if IsU8          $.Type}}value.U8({{$.Name}})
+  {{else if IsChar        $.Type}}value.U8(uint8({{$.Name}}))
   {{else if IsS16         $.Type}}value.S16({{$.Name}})
   {{else if IsU16         $.Type}}value.U16({{$.Name}})
   {{else if IsF32         $.Type}}value.F32({{$.Name}})
diff --git a/gapid/gfxapi/vulkan/api.go b/gapid/gfxapi/vulkan/api.go
index 450f4cb..833c1f4 100644
--- a/gapid/gfxapi/vulkan/api.go
+++ b/gapid/gfxapi/vulkan/api.go
@@ -13919,14 +13919,38 @@
 	binary.Generate
 	Elements [3]uint32
 }
+
+func (a U32ː3ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.U32(v))
+	}
+	return ϟb.Buffer(3)
+}
+
 type U32ː2ᵃ struct {
 	binary.Generate
 	Elements [2]uint32
 }
+
+func (a U32ː2ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.U32(v))
+	}
+	return ϟb.Buffer(2)
+}
+
 type F32ː2ᵃ struct {
 	binary.Generate
 	Elements [2]float32
 }
+
+func (a F32ː2ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.F32(v))
+	}
+	return ϟb.Buffer(2)
+}
+
 type Charː256ᵃ struct {
 	binary.Generate
 	Elements [256]gfxapi.Char
@@ -13935,6 +13959,14 @@
 	binary.Generate
 	Elements [16]uint8
 }
+
+func (a U8ː16ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.U8(v))
+	}
+	return ϟb.Buffer(16)
+}
+
 type VkMemoryTypeː32ᵃ struct {
 	binary.Generate
 	Elements [32]VkMemoryType
@@ -13947,6 +13979,14 @@
 	binary.Generate
 	Elements [4]float32
 }
+
+func (a F32ː4ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.F32(v))
+	}
+	return ϟb.Buffer(4)
+}
+
 type VkOffset3Dː2ᵃ struct {
 	binary.Generate
 	Elements [2]VkOffset3D
@@ -13955,11 +13995,26 @@
 	binary.Generate
 	Elements [4]int32
 }
+
+func (a S32ː4ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.S32(v))
+	}
+	return ϟb.Buffer(4)
+}
+
 type U32ː4ᵃ struct {
 	binary.Generate
 	Elements [4]uint32
 }
 
+func (a U32ː4ᵃ) value(ϟb *builder.Builder, ϟa atom.Atom, ϟs *gfxapi.State) value.Pointer {
+	for _, v := range a.Elements {
+		ϟb.Push(value.U32(v))
+	}
+	return ϟb.Buffer(4)
+}
+
 // ANativeWindowˢ is a slice of ANativeWindow.
 type ANativeWindowˢ struct {
 	binary.Generate
diff --git a/gapid/gfxapi/vulkan/mutate.go b/gapid/gfxapi/vulkan/mutate.go
index 6ac5d12..3d0af7e 100644
--- a/gapid/gfxapi/vulkan/mutate.go
+++ b/gapid/gfxapi/vulkan/mutate.go
@@ -3010,9 +3010,6 @@
 	ϟo := ϟa.Extras().Observations()
 	_ = ϟc
 	ϟo.ApplyReads(ϟs.Memory[memory.ApplicationPool])
-	GetCommandBuffer_0_commandBuffer := ϟa.CommandBuffer
-	GetCommandBuffer_0_result := ϟc.State.CommandBuffers.Get(GetCommandBuffer_0_commandBuffer)
-	commandBufferObject := GetCommandBuffer_0_result
 	if ϟb != nil {
 		ϟa.Call(ϟctx, ϟs, ϟd, ϟb)
 	}
diff --git a/gapid/gfxapi/vulkan/vulkan.api b/gapid/gfxapi/vulkan/vulkan.api
index bc5c508..423fbe9 100644
--- a/gapid/gfxapi/vulkan/vulkan.api
+++ b/gapid/gfxapi/vulkan/vulkan.api
@@ -3126,8 +3126,6 @@
 @command_buffer
 cmd VkResult vkEndCommandBuffer(
         VkCommandBuffer                             commandBuffer) {
-    commandBufferObject := GetCommandBuffer(commandBuffer)
-
     return ?
 }
 
diff --git a/gapid/gfxapi/vulkan/vulkan.go b/gapid/gfxapi/vulkan/vulkan.go
index 011a215..0a87bcf 100644
--- a/gapid/gfxapi/vulkan/vulkan.go
+++ b/gapid/gfxapi/vulkan/vulkan.go
@@ -31,4 +31,26 @@
 // Package vulkan implementes the API interface for the Vulkan graphics library.
 package vulkan
 
+import (
+	"android.googlesource.com/platform/tools/gpu/gapid/gfxapi"
+)
+
 // binary: cpp = vulkan
+type VulkanContext struct{}
+
+func (VulkanContext) Name() string {
+	return "Vulkan Context"
+}
+
+func (VulkanContext) ID() gfxapi.ContextID {
+	// ID returns the context's unique identifier
+	return gfxapi.ContextID{}
+}
+
+func (api) Context(s *gfxapi.State) gfxapi.Context {
+	return VulkanContext{}
+}
+
+func (api) GetFramebufferAttachmentSize(state *gfxapi.State, attachment gfxapi.FramebufferAttachment) (width uint32, height uint32, err error) {
+	return 0, 0, nil
+}
diff --git a/gapid/gfxapi/vulkan/vulkan_binary_metatadata.go b/gapid/gfxapi/vulkan/vulkan_binary_metatadata.go
new file mode 100644
index 0000000..3aa07cc
--- /dev/null
+++ b/gapid/gfxapi/vulkan/vulkan_binary_metatadata.go
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package vulkan
+
+import (
+	"fmt"
+	"reflect"
+
+	"android.googlesource.com/platform/tools/gpu/framework/binary"
+	"android.googlesource.com/platform/tools/gpu/framework/binary/registry"
+	"android.googlesource.com/platform/tools/gpu/gapid/atom"
+	"android.googlesource.com/platform/tools/gpu/gapid/gfxapi"
+)
+
+// AddMetadata annotates all atoms in the namespace
+func AddMetadata(n *registry.Namespace) {
+	n.Visit(func(c binary.Class) {
+		ent := c.Schema()
+		if ent == nil {
+			return
+		}
+		if atom.FindMetadata(ent) != nil {
+			// Don't add metadata, if there is already metadata. Duplicates
+			// can happen because it is not easy to distinguish Frozen from
+			// Generated.
+			return
+		}
+		u := n.LookupUpgrader(ent.Signature())
+		if u == nil {
+			return
+		}
+		obj := u.New()
+		if a, ok := obj.(atom.Atom); ok {
+			atom.AddMetadata(a, ent)
+		}
+	})
+}
+
+// Note vulkan_binary.go must initialize first. We really on the Go's
+// lexigraphical provision; that is "metadata.go" > "vulkan_binary.go"
+// for correct order of initialization.
+func init() {
+	AddMetadata(Namespace)
+	if err := atom.AddSnippetsFromBase64String(
+		Namespace, embedded[snippets_base64_file]); err != nil {
+		panic(fmt.Errorf("Error decoding atom snippets: %v", err))
+	}
+	var state *State
+	entity := state.Class().Schema()
+	if err := gfxapi.AddStateSnippetsFromBase64String(
+		entity,
+		embedded[globals_snippets_base64_file]); err != nil {
+		panic(fmt.Errorf("Error decoding global state snippets: %v", err))
+	}
+	gfxapi.AddCanFollowState(reflect.TypeOf(state).Elem(), &entity.Metadata)
+}