blob: ef5f25869724bda19557a5c2d608e50874e8b45f [file] [log] [blame]
// 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 gapii
import (
"io"
"android.googlesource.com/platform/tools/gpu/framework/binary/endian"
"android.googlesource.com/platform/tools/gpu/framework/device"
)
var magic = [4]byte{'s', 'p', 'y', '0'}
const version = 3
// The GAPII header is defined as:
//
// struct ConnectionHeader {
// uint8_t mMagic[4]; // 's', 'p', 'y', '0'
// uint32_t mVersion; // 2 or 3
// uint32_t mObserveFrameFrequency; // non-zero == enabled. Version: 2+
// uint32_t mObserveDrawFrequency; // non-zero == enabled. Version: 2+
// uint32_t mFlags; // Combination of FLAG_XX bits. Version: 3+
// };
//
// All fields are encoded little-endian with no compression, regardless of
// architecture. All changes must be kept in sync with:
// platform/tools/gpu/cc/gapii/connection_header.h
func sendHeader(out io.Writer, options Options) error {
w := endian.Writer(out, device.LittleEndian)
for _, m := range magic {
w.Uint8(m)
}
w.Uint32(version)
w.Uint32(options.ObserveFrameFrequency)
w.Uint32(options.ObserveDrawFrequency)
w.Uint32(uint32(options.Flags))
return w.Error()
}