Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GVR support #982

Merged
merged 8 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeProto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protoc_go("github.com/google/gapid/gapis/api/gles" "gapis/api/gles" "resolvables

protoc_go("github.com/google/gapid/gapis/api/gvr/gvr_pb" "gapis/api/gvr/gvr_pb" "api.proto")
protoc_cc("gapis/api/gvr/gvr_pb" "gapis/api/gvr/gvr_pb" "api.proto")
protoc_go("github.com/google/gapid/gapis/api/gvr" "gapis/api/gvr" "resolvables.proto")

protoc_go("github.com/google/gapid/gapis/api/vulkan/vulkan_pb" "gapis/api/vulkan/vulkan_pb" "api.proto")
protoc_cc("gapis/api/vulkan/vulkan_pb" "gapis/api/vulkan/vulkan_pb" "api.proto")
Expand Down
7 changes: 4 additions & 3 deletions cmd/gapit/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func init() {

// These are hard-coded and need to be kept in sync with the api_index
// in the *.api files.
const coreAPI = uint32(1 << 0)
const glesAPI = uint32(1 << 1)
const vulkanAPI = uint32(1 << 2)
const gvrAPI = uint32(1 << 3)

func (verb *traceVerb) Run(ctx context.Context, flags flag.FlagSet) error {
options := client.Options{
Expand Down Expand Up @@ -84,9 +84,10 @@ func (verb *traceVerb) Run(ctx context.Context, flags flag.FlagSet) error {

switch verb.API {
case "vulkan":
options.APIs = coreAPI | vulkanAPI
options.APIs = vulkanAPI
case "gles":
options.APIs = coreAPI | glesAPI
// TODO: Separate these two out once we can trace Vulkan with OpenGL ES.
options.APIs = glesAPI | gvrAPI
case "":
options.APIs = uint32(0xFFFFFFFF)
default:
Expand Down
26 changes: 26 additions & 0 deletions core/cc/gvr_ptr_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2017 Google Inc.
*
* 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.
*/

#ifndef CORE_GVR_PTR_TYPES_H_
#define CORE_GVR_PTR_TYPES_H_

#include "core/cc/target.h" // STDCALL

#define GVR_API_ATTR
#define GVR_API_CALL
#define GVR_API_PTR STDCALL

#endif // CORE_GVR_PTR_TYPES_H_
35 changes: 20 additions & 15 deletions core/cc/static_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,58 +21,63 @@

namespace core {

template <typename T, int N>
struct CStaticArray {
T mData[N];
};

// StaticArray represents a fixed size array with implicit conversions to and
// from T[N].
template <typename T, int N>
class StaticArray {
typedef T ARRAY_TY[N];
class StaticArray : protected CStaticArray<T, N> {
public:

inline StaticArray();
inline StaticArray(const StaticArray<T, N>& other);
inline StaticArray(const CStaticArray<T, N>& other);
inline StaticArray(T arr[N]);
inline StaticArray(std::initializer_list<T> l);

inline operator T*();
inline operator const T*() const;

private:
T mData[N];
};

template <typename T, int N>
inline StaticArray<T, N>::StaticArray() : mData{} {}
inline StaticArray<T, N>::StaticArray() {
for (int i = 0; i < N; i++) {
this->mData[i] = T();
}
}

template <typename T, int N>
inline StaticArray<T, N>::StaticArray(const StaticArray<T, N>& other) {
inline StaticArray<T, N>::StaticArray(const CStaticArray<T, N>& other) {
for (int i = 0; i < N; i++) {
mData[i] = other[i];
this->mData[i] = other.mData[i];
}
}

template <typename T, int N>
inline StaticArray<T, N>::StaticArray(T arr[N]) : mData{} {
inline StaticArray<T, N>::StaticArray(T arr[N]) {
for (int i = 0; i < N; i++) {
mData[i] = arr[i];
this->mData[i] = arr[i];
}
}

template <typename T, int N>
inline StaticArray<T, N>::StaticArray(std::initializer_list<T> l) : mData{} {
inline StaticArray<T, N>::StaticArray(std::initializer_list<T> l) {
GAPID_ASSERT(l.size() == N);
for (int i = 0; i < N; i++) {
mData[i] = l.begin()[i];
this->mData[i] = l.begin()[i];
}
}

template <typename T, int N>
inline StaticArray<T, N>::operator T*() {
return &mData[0];
return &this->mData[0];
}

template <typename T, int N>
inline StaticArray<T, N>::operator const T*() const {
return &mData[0];
return &this->mData[0];
}

} // namespace core
Expand Down
1 change: 1 addition & 0 deletions gapii/cc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/gles_types.h

/gvr_exports.cpp
/gvr_exports.h
/gvr_imports.cpp
/gvr_imports.h
/gvr_types.cpp
Expand Down
16 changes: 11 additions & 5 deletions gapii/cc/CMakeBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

build_subdirectory(android)

set(api gles/gles.api)

apic(${api} TEMPLATE ${APIC_API_PATH}/gles/templates/api_exports.cpp.tmpl)
Expand Down Expand Up @@ -42,8 +44,9 @@ apic(${api} TEMPLATE api_types.h.tmpl)

set(api gvr/gvr.api)

# apic(${api} TEMPLATE ${APIC_API_PATH}/gles/templates/api_exports.cpp.tmpl)
# apic(${api} TEMPLATE ${APIC_API_PATH}/gles/templates/api_imports.cpp.tmpl)
apic(${api} TEMPLATE ${APIC_API_PATH}/gvr/templates/api_exports.cpp.tmpl)
apic(${api} TEMPLATE ${APIC_API_PATH}/gvr/templates/api_exports.h.tmpl)
apic(${api} TEMPLATE ${APIC_API_PATH}/gvr/templates/api_imports.cpp.tmpl)
apic(${api} TEMPLATE api_imports.h.tmpl)
apic(${api} TEMPLATE api_spy.cpp.tmpl)
apic(${api} TEMPLATE api_spy.h.tmpl)
Expand Down Expand Up @@ -71,6 +74,7 @@ list(APPEND sources
"${PROTO_CC_OUT}/gapis/api/vulkan/vulkan_pb/api.pb.cc"
"${PROTO_CC_OUT}/gapis/api/gles/gles_pb/api.pb.cc"
"${PROTO_CC_OUT}/gapis/api/gles/gles_pb/extras.pb.cc"
"${PROTO_CC_OUT}/gapis/api/gvr/gvr_pb/api.pb.cc"
)

foreach(abi ${ANDROID_ACTIVE_ABI_LIST})
Expand All @@ -96,6 +100,10 @@ if(NOT DISABLED_CXX)
target_include_directories(gapii PUBLIC "${PROTO_CC_OUT}")
target_include_directories(gapii PUBLIC "${CMAKE_SOURCE_DIR}/external/protobuf/src")

# disable warning: 'foo' has C-linkage specified, but returns user-defined
# type 'bar' which is incompatible with C
target_compile_options(gapii PRIVATE "-Wno-return-type-c-linkage")

if(APPLE)
find_package(Cocoa REQUIRED)
target_link_libraries(gapii Cocoa::Lib)
Expand All @@ -107,9 +115,7 @@ if(NOT DISABLED_CXX)

set_target_properties(gapii PROPERTIES
LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/gapii.exports")
elseif(GAPII_TARGET)

else()
elseif(NOT GAPII_TARGET)
find_package(GL REQUIRED)
target_link_libraries(gapii GL::Lib)

Expand Down
15 changes: 15 additions & 0 deletions gapii/cc/CMakeFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ set(files
gles_spy_subroutines_1.cpp
gles_types.cpp
gles_types.h
gvr_abi_types.h
gvr_exports.cpp
gvr_extras.inl
gvr_imports.cpp
gvr_imports.h
gvr_inlines.inl
gvr_spy.h
gvr_spy_0.cpp
gvr_spy_1.cpp
gvr_spy_2.cpp
gvr_spy_3.cpp
gvr_spy_subroutines_0.cpp
gvr_spy_subroutines_1.cpp
gvr_types.cpp
gvr_types.h
pack_encoder.h
pack_encoder.cpp
pool.cpp
Expand Down
1 change: 1 addition & 0 deletions gapii/cc/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gvr_install.cpp
17 changes: 17 additions & 0 deletions gapii/cc/android/CMakeBuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2017 Google Inc.
#
# 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.

set(api gvr/gvr.api)

apic(${api} TEMPLATE ${APIC_API_PATH}/gvr/templates/api_install.cpp.tmpl)
2 changes: 2 additions & 0 deletions gapii/cc/android/CMakeFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# build and the file will be recreated, check in the new version.

set(files
gvr_install.cpp
gvr_install.h
installer.cpp
installer.h
)
Expand Down
30 changes: 30 additions & 0 deletions gapii/cc/android/gvr_install.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2015 Google Inc.
*
* 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.
*
*/

#ifndef GAPII_ANDROID_GVR_INSTALL_H
#define GAPII_ANDROID_GVR_INSTALL_H

namespace gapii {

class GvrImports;

// install_gvr installs interceptor hooks into all the GVR functions.
bool install_gvr(void* gvr_lib, GvrImports* imports);

} // namespace gapii

#endif // GAPII_ANDROID_GVR_INSTALL_H
6 changes: 4 additions & 2 deletions gapii/cc/connection_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ ConnectionHeader::ConnectionHeader()
, mStartFrame(0)
, mNumFrames(0)
, mAPIs(0xFFFFFFFF)
, mFlags(0) {}
, mFlags(0)
, mGvrHandle(0) {}

bool ConnectionHeader::read(core::StreamReader* reader) {
if (!reader->read(mMagic)) {
Expand Down Expand Up @@ -62,7 +63,8 @@ bool ConnectionHeader::read(core::StreamReader* reader) {
!reader->read(mStartFrame) ||
!reader->read(mNumFrames) ||
!reader->read(mAPIs) ||
!reader->read(mFlags)) {
!reader->read(mFlags) ||
!reader->read(mGvrHandle)) {
return false;
}

Expand Down
17 changes: 9 additions & 8 deletions gapii/cc/connection_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ class ConnectionHeader {
// on success or false on error.
bool read(core::StreamReader* reader);

uint8_t mMagic[4]; // 's', 'p', 'y', '0'
uint32_t mVersion; // 1
uint32_t mObserveFrameFrequency; // non-zero == enabled.
uint32_t mObserveDrawFrequency; // non-zero == enabled.
uint32_t mStartFrame; // non-zero == Frame to start at.
uint32_t mNumFrames; // non-zero == Number of frames to capture.
uint32_t mAPIs; // Bitset of APIS to enable.
uint32_t mFlags; // Combination of FLAG_XX bits.
uint8_t mMagic[4]; // 's', 'p', 'y', '0'
uint32_t mVersion; // 1
uint32_t mObserveFrameFrequency; // non-zero == enabled.
uint32_t mObserveDrawFrequency; // non-zero == enabled.
uint32_t mStartFrame; // non-zero == Frame to start at.
uint32_t mNumFrames; // non-zero == Number of frames to capture.
uint32_t mAPIs; // Bitset of APIS to enable.
uint32_t mFlags; // Combination of FLAG_XX bits.
uint64_t mGvrHandle; // Handle of GVR library.
};

} // namespace gapii
Expand Down
34 changes: 34 additions & 0 deletions gapii/cc/gvr_abi_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2017 Google Inc.
*
* 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.
*/


#ifndef GAPII_GVR_ABI_TYPES_H
#define GAPII_GVR_ABI_TYPES_H

namespace gapii {

struct gvr_mat4_abi : core::CStaticArray<float, 16> {};

gvr_mat4f::gvr_mat4f(gvr_mat4_abi const& abi) : mm(abi) {}
gvr_mat4f::operator gvr_mat4_abi() const {
gvr_mat4_abi out;
memcpy(&out, this, sizeof(out));
return out;
}

} // namespace gapii

#endif // GAPII_GVR_ABI_TYPES_H
22 changes: 22 additions & 0 deletions gapii/cc/gvr_extras.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2017 Google Inc.
*
* 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.
*/

// Note this file is included in context in gvr_spy.h:
//
// namespace gapii {
//
// class GvrSpy {
// protected:
Loading