├── __init__.py ├── third_party ├── __init__.py ├── bazel │ ├── __init__.py │ └── BUILD ├── dear_imgui │ ├── imconfig.cpp │ ├── LICENSE │ ├── imconfig.h │ └── BUILD ├── proggy_fonts │ ├── ProggyTiny.ttf │ ├── proggy_tiny.h │ ├── BUILD │ └── LICENSE ├── glad │ ├── LICENSE │ └── BUILD ├── GLES_khronos_headers │ ├── include │ │ ├── GLES │ │ │ └── glplatform.h │ │ ├── GLES2 │ │ │ └── gl2platform.h │ │ └── GLES3 │ │ │ └── gl3platform.h │ └── BUILD └── spirv_cross.BUILD ├── xrtl ├── testing │ ├── testdata │ │ ├── empty_file │ │ ├── text_file │ │ ├── image_file.png │ │ └── BUILD │ ├── empty_test.sh │ ├── diffing │ │ ├── testdata │ │ │ ├── text_file.txt │ │ │ ├── goldens │ │ │ │ ├── text_file.txt │ │ │ │ ├── data_file.bin │ │ │ │ ├── image_file.png │ │ │ │ └── BUILD │ │ │ ├── text_file_mismatch.txt │ │ │ ├── data_file.bin │ │ │ ├── image_file.png │ │ │ ├── data_file_mismatch.bin │ │ │ ├── image_file_mismatch.png │ │ │ └── BUILD │ │ ├── html_diff_provider_create.cc │ │ ├── data_differ_test.cc │ │ ├── data_differ.cc │ │ ├── text_differ.cc │ │ └── text_differ_test.cc │ ├── gtest.h │ ├── demo_main.cc │ └── demo_main.h ├── gfx │ ├── CPPLINT.cfg │ ├── testing │ │ ├── testdata │ │ │ └── goldens │ │ │ │ ├── compare_image.png │ │ │ │ ├── compare_framebuffer_0.png │ │ │ │ ├── compare_framebuffer_1.png │ │ │ │ ├── compare_buffer_golden_full.bin │ │ │ │ ├── compare_buffer_golden_partial.bin │ │ │ │ └── BUILD │ │ └── BUILD │ ├── es3 │ │ ├── es3_framebuffer.cc │ │ ├── es3_command_fence.h │ │ ├── es3_resource_set_layout.h │ │ ├── es3_image_view.h │ │ ├── es3_framebuffer.h │ │ ├── es3_device.h │ │ ├── es3_pipeline_layout.h │ │ ├── es3_resource_set.h │ │ ├── es3_render_pass.h │ │ ├── es3_sampler.h │ │ ├── es3_shader_module.cc │ │ ├── es3_device.cc │ │ ├── es3_pixel_format.h │ │ └── es3_shader_module.h │ ├── device.cc │ ├── context_factory_test.cc │ ├── spirv │ │ ├── shader_compiler_fuzzer.cc │ │ ├── spirv_optimizer_fuzzer.cc │ │ └── BUILD │ ├── shader_module.h │ ├── util │ │ └── memory_command_decoder.h │ ├── command_fence.h │ ├── memory_heap.cc │ ├── managed_object.h │ ├── context.cc │ ├── command_buffer.cc │ ├── vertex_format_test.cc │ └── framebuffer.h ├── port │ ├── android │ │ ├── testing │ │ │ ├── portable_testing_android.bzl │ │ │ └── BUILD │ │ ├── BUILD │ │ └── base │ │ │ └── BUILD │ ├── apple │ │ ├── testing │ │ │ ├── apple_test.plist │ │ │ └── BUILD │ │ ├── BUILD │ │ └── base │ │ │ ├── BUILD │ │ │ ├── threading │ │ │ └── BUILD │ │ │ └── darwin_debugging.cc │ ├── common │ │ ├── ui │ │ │ └── BUILD │ │ ├── BUILD │ │ ├── base │ │ │ ├── posix_cli_main.cc │ │ │ ├── gflags_flags.h │ │ │ ├── threading │ │ │ │ ├── pthreads_wait_handle.cc │ │ │ │ └── BUILD │ │ │ ├── posix_debugging.cc │ │ │ ├── posix_env.cc │ │ │ ├── protobuf.h │ │ │ └── posix_logging_sink.cc │ │ ├── testing │ │ │ ├── posix_demo_main.cc │ │ │ ├── posix_test_main.cc │ │ │ └── BUILD │ │ └── gfx │ │ │ └── es3 │ │ │ └── egl_strings.h │ ├── linux │ │ ├── BUILD │ │ └── ui │ │ │ ├── x11_system_theme.cc │ │ │ ├── x11_headers.h │ │ │ ├── x11_window.h │ │ │ └── x11_window.cc │ ├── emscripten │ │ ├── base │ │ │ └── BUILD │ │ └── BUILD │ ├── windows │ │ ├── BUILD │ │ ├── ui │ │ │ ├── win32_system_theme.cc │ │ │ ├── BUILD │ │ │ ├── win32_window.h │ │ │ └── win32_window.cc │ │ ├── testing │ │ │ └── BUILD │ │ ├── gfx │ │ │ └── es3 │ │ │ │ └── BUILD │ │ └── base │ │ │ ├── BUILD │ │ │ ├── threading │ │ │ ├── win32_semaphore.cc │ │ │ ├── win32_event.cc │ │ │ ├── win32_wait_handle.h │ │ │ └── BUILD │ │ │ └── windows.h │ ├── ios │ │ └── BUILD │ ├── macos │ │ ├── BUILD │ │ └── gfx │ │ │ └── es3 │ │ │ └── BUILD │ └── BUILD ├── base │ ├── testdata │ │ ├── BUILD │ │ └── proto_util_test.proto │ ├── proto_util.cc │ ├── proto_util.h │ ├── threading │ │ ├── timer_test.cc │ │ ├── wait_handle.h │ │ └── thread.cc │ ├── debugging_settings.h │ ├── protobuf.h │ ├── cli_main.cc │ ├── system_clock.cc │ ├── uri_fuzzer.cc │ ├── env.cc │ ├── proto_util_test.cc │ ├── cli_main.h │ ├── stopwatch.h │ ├── tracing.cc │ ├── debugging.cc │ ├── tracing.h │ ├── stopwatch_test.cc │ └── logging.cc ├── tools │ ├── target_platform │ │ ├── platforms.bzl │ │ ├── tests │ │ │ ├── platform_ios_test.cc │ │ │ ├── platform_linux_test.cc │ │ │ ├── platform_macos_test.cc │ │ │ ├── platform_android_test.cc │ │ │ ├── platform_windows_test.cc │ │ │ ├── platform_emscripten_test.cc │ │ │ └── BUILD │ │ ├── target_platform.cc │ │ └── conditions.bzl │ └── target_config │ │ ├── target_config.cc │ │ └── target_config.h ├── BUILD ├── ui │ ├── testing │ │ └── BUILD │ ├── system_theme_test.cc │ ├── shaders │ │ ├── imgui_overlay.frag │ │ ├── imgui_overlay.vert │ │ └── BUILD │ └── system_theme.h └── examples │ └── BUILD ├── WORKSPACE ├── .gitattributes ├── BUILD ├── tools ├── utils │ ├── BUILD │ ├── macos_test_runner.sh │ └── echo_vcvarsall.bat ├── ci │ ├── travis │ │ ├── lint.sh │ │ ├── analyze.sh │ │ ├── build.sh │ │ ├── test.sh │ │ └── .bazelrc │ └── appveyor │ │ ├── build.bat │ │ ├── test.bat │ │ └── .bazelrc ├── visual_studio │ ├── vcxproj.filters.template │ ├── vcxproj.user.template │ └── sln.template ├── xcode │ └── xrtl.tulsiproj │ │ ├── project.tulsiconf │ │ └── Configs │ │ ├── ios.tulsigen │ │ └── macos.tulsigen ├── crosstool │ └── msan │ │ └── BUILD └── actions │ ├── generate_link_target.py │ └── BUILD ├── .bazelproject ├── .clang-format ├── .gitignore ├── CONTRIBUTING.md ├── .gitmodules └── .appveyor.yml /__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/bazel/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /xrtl/testing/testdata/empty_file: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /xrtl/testing/empty_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | -------------------------------------------------------------------------------- /xrtl/testing/testdata/text_file: -------------------------------------------------------------------------------- 1 | hello world! -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/text_file.txt: -------------------------------------------------------------------------------- 1 | hello world! 2 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/goldens/text_file.txt: -------------------------------------------------------------------------------- 1 | hello world! 2 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/text_file_mismatch.txt: -------------------------------------------------------------------------------- 1 | goodnight moon! 2 | -------------------------------------------------------------------------------- /xrtl/gfx/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | exclude_files=pixel_format.h 2 | exclude_files=vertex_format.h 3 | -------------------------------------------------------------------------------- /xrtl/testing/testdata/image_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/testdata/image_file.png -------------------------------------------------------------------------------- /third_party/dear_imgui/imconfig.cpp: -------------------------------------------------------------------------------- 1 | #include "imgui.h" 2 | 3 | thread_local ImGuiContext* thread_imgui_context = nullptr; 4 | -------------------------------------------------------------------------------- /third_party/proggy_fonts/ProggyTiny.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/third_party/proggy_fonts/ProggyTiny.ttf -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "xrtl") 2 | 3 | load("//xrtl:workspace.bzl", "xrtl_workspace") 4 | xrtl_workspace(__workspace_dir__) 5 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/data_file.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/data_file.bin -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/image_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/image_file.png -------------------------------------------------------------------------------- /third_party/proggy_fonts/proggy_tiny.h: -------------------------------------------------------------------------------- 1 | // NUL-terminated base85 encoded font. 2 | extern const char proggy_tiny_compressed_data_base85[]; 3 | -------------------------------------------------------------------------------- /xrtl/port/android/testing/portable_testing_android.bzl: -------------------------------------------------------------------------------- 1 | """cc_test rules for Android.""" 2 | 3 | def android_cc_test(**kwargs): 4 | pass 5 | -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/compare_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/gfx/testing/testdata/goldens/compare_image.png -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/data_file_mismatch.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/data_file_mismatch.bin -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/goldens/data_file.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/goldens/data_file.bin -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/goldens/image_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/goldens/image_file.png -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/image_file_mismatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/testing/diffing/testdata/image_file_mismatch.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto whitespace=blank-at-eol,tab-in-indent,trailing-space,tabwidth=2 2 | 3 | *.bat text eol=crlf 4 | *.sh text eol=lf 5 | -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/compare_framebuffer_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/gfx/testing/testdata/goldens/compare_framebuffer_0.png -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/compare_framebuffer_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/gfx/testing/testdata/goldens/compare_framebuffer_1.png -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/compare_buffer_golden_full.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/gfx/testing/testdata/goldens/compare_buffer_golden_full.bin -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/compare_buffer_golden_partial.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/xrtl/HEAD/xrtl/gfx/testing/testdata/goldens/compare_buffer_golden_partial.bin -------------------------------------------------------------------------------- /xrtl/port/apple/testing/apple_test.plist: -------------------------------------------------------------------------------- 1 | { 2 | CFBundleIdentifier = "${PRODUCT_BUNDLE_IDENTIFIER}"; 3 | CFBundleName = "${PRODUCT_NAME}"; 4 | CFBundlePackageType = "APPL"; 5 | CFBundleSignature = "????"; 6 | } 7 | -------------------------------------------------------------------------------- /third_party/bazel/BUILD: -------------------------------------------------------------------------------- 1 | package(default_visibility = ["//visibility:public"]) 2 | 3 | licenses(["notice"]) # Apache 2.0 4 | 5 | py_library( 6 | name = "extra_actions_proto_py", 7 | srcs = ["extra_actions_base_pb2.py"], 8 | ) 9 | -------------------------------------------------------------------------------- /BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Cross-platform Real-time Rendering Library. 3 | # https://github.com/google/xrtl 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | licenses(["notice"]) # Apache 2.0 8 | 9 | exports_files(["LICENSE"]) 10 | -------------------------------------------------------------------------------- /tools/utils/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Utility scripts. 3 | 4 | package(default_visibility = ["//visibility:public"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | sh_binary( 9 | name = "macos_test_runner", 10 | srcs = ["macos_test_runner.sh"], 11 | ) 12 | -------------------------------------------------------------------------------- /tools/ci/travis/lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 5 | export CC=clang-5.0 6 | export CXX=clang++-5.0 7 | else 8 | export CC=clang 9 | export CXX=clang 10 | fi 11 | 12 | # Use CI-specific bazel configurations. 13 | cp tools/ci/travis/.bazelrc . 14 | 15 | ./xtool lint --origin 16 | -------------------------------------------------------------------------------- /tools/utils/macos_test_runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Required to workaround https://github.com/bazelbuild/bazel/issues/3921. 4 | # If that gets fixed this can be replaced with a --test_env=LD_LIBRARY_PATH 5 | # in bazel.rc. Or, we could fix the underlying reason swiftshader needs this. 6 | 7 | export LD_LIBRARY_PATH=$PWD/external/com_github_google_swiftshader/ 8 | $@ 9 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/goldens/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Diff test goldens. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | filegroup( 9 | name = "test_files", 10 | srcs = [ 11 | "data_file.bin", 12 | "image_file.png", 13 | "text_file.txt", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /tools/visual_studio/vcxproj.filters.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $FILTER_LINES 5 | 6 | 7 | $CL_COMPILE_LINES 8 | 9 | 10 | $CL_INCLUDE_LINES 11 | 12 | 13 | -------------------------------------------------------------------------------- /tools/ci/travis/analyze.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 5 | export CC=clang-5.0 6 | export CXX=clang++-5.0 7 | else 8 | export CC=clang 9 | export CXX=clang 10 | fi 11 | 12 | # Use CI-specific bazel configurations. 13 | cp tools/ci/travis/.bazelrc . 14 | 15 | ./xtool tidy \ 16 | --output_base=/tmp/.cache/bazel_root_analyze/ \ 17 | --origin 18 | -------------------------------------------------------------------------------- /xrtl/base/testdata/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Testdata for //xrtl/base. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | proto_library( 9 | name = "proto_util_test_proto", 10 | srcs = ["proto_util_test.proto"], 11 | ) 12 | 13 | cc_proto_library( 14 | name = "proto_util_test_cc_proto", 15 | deps = [":proto_util_test_proto"], 16 | ) 17 | -------------------------------------------------------------------------------- /xrtl/testing/testdata/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # gfx test data. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | filegroup( 9 | name = "image_buffer_data", 10 | srcs = [ 11 | "image_file.png", 12 | ], 13 | ) 14 | 15 | filegroup( 16 | name = "file_util_data", 17 | srcs = [ 18 | "empty_file", 19 | "text_file", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /xrtl/port/android/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Testing utilities. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:android"]) 11 | 12 | # 13 | 14 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 15 | 16 | portable_test_suite() 17 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/testdata/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Diff test data. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | filegroup( 9 | name = "test_files", 10 | srcs = [ 11 | "data_file.bin", 12 | "data_file_mismatch.bin", 13 | "image_file.png", 14 | "image_file_mismatch.png", 15 | "text_file.txt", 16 | "text_file_mismatch.txt", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/platforms.bzl: -------------------------------------------------------------------------------- 1 | """Platform constants.""" 2 | 3 | # Friendly platform names. 4 | PLATFORM_NAMES = [ 5 | "android", 6 | "emscripten", 7 | "ios", 8 | "linux", 9 | "macos", 10 | "windows", 11 | ] 12 | 13 | # Fully-qualified platform name. These can be used in select()s. 14 | # Example: //xrtl/tools/target_platform:ios 15 | PLATFORMS = ["//xrtl/tools/target_platform:%s" % (platform_name) for platform_name in PLATFORM_NAMES] 16 | -------------------------------------------------------------------------------- /tools/ci/travis/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 5 | export CC=clang-5.0 6 | export CXX=clang++-5.0 7 | else 8 | export CC=clang 9 | export CXX=clang 10 | fi 11 | 12 | # Use CI-specific bazel configurations. 13 | cp tools/ci/travis/.bazelrc . 14 | 15 | ./xtool build \ 16 | --output_base=/tmp/.cache/bazel_root_$CONFIG/ \ 17 | -c dbg \ 18 | --config=$CONFIG \ 19 | --define=XRTL_USE_SWIFTSHADER=1 \ 20 | --keep_going \ 21 | --all 22 | -------------------------------------------------------------------------------- /xrtl/gfx/testing/testdata/goldens/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Golden testdata for gfx testing utilities. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | filegroup( 9 | name = "graphics_test_data", 10 | srcs = [ 11 | "compare_buffer_golden_full.bin", 12 | "compare_buffer_golden_partial.bin", 13 | "compare_framebuffer_0.png", 14 | "compare_framebuffer_1.png", 15 | "compare_image.png", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /xrtl/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Cross-platform Real-time Rendering Library. 3 | # https://github.com/google/xrtl 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | licenses(["notice"]) # Apache 2.0 8 | 9 | # Restricts most packages to use by //xrtl/... only. 10 | # Selective rules we wish to support to external users are set to 11 | # //visibility:public. 12 | package_group( 13 | name = "internal", 14 | packages = [ 15 | "//third_party/...", 16 | "//xrtl/...", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /xrtl/port/apple/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Code common to Apple platforms (iOS, MacOS, etc). 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = [ 11 | "//xrtl/tools/target_platform:ios", 12 | "//xrtl/tools/target_platform:macos", 13 | ]) 14 | 15 | # 16 | 17 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 18 | 19 | portable_test_suite() 20 | -------------------------------------------------------------------------------- /xrtl/ui/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Testing utilities for UI code. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | cc_library( 9 | name = "mock_control_listener", 10 | testonly = 1, 11 | hdrs = ["mock_control_listener.h"], 12 | deps = [ 13 | "//xrtl/base/threading:event", 14 | "//xrtl/base/threading:semaphore", 15 | "//xrtl/base/threading:thread", 16 | "//xrtl/testing:gtest_main", 17 | "//xrtl/ui:control", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /tools/ci/travis/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 5 | export CC=clang-5.0 6 | export CXX=clang++-5.0 7 | else 8 | export CC=clang 9 | export CXX=clang 10 | fi 11 | 12 | # Use CI-specific bazel configurations. 13 | cp tools/ci/travis/.bazelrc . 14 | 15 | ./xtool test \ 16 | --output_base=/tmp/.cache/bazel_root_$CONFIG/ \ 17 | -c dbg \ 18 | --config=$CONFIG \ 19 | --define=XRTL_USE_SWIFTSHADER=1 \ 20 | --keep_going \ 21 | --all \ 22 | --test_tag_filters=-requires_gui,-requires_gpu 23 | -------------------------------------------------------------------------------- /xrtl/port/common/ui/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Common port variants of //xrtl/ui/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | cc_library( 9 | name = "timer_display_link", 10 | srcs = ["timer_display_link.cc"], 11 | hdrs = ["timer_display_link.h"], 12 | deps = [ 13 | "//xrtl/base:logging", 14 | "//xrtl/base:system_clock", 15 | "//xrtl/base/threading:message_loop", 16 | "//xrtl/base/threading:thread", 17 | "//xrtl/ui:display_link", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /tools/visual_studio/vcxproj.user.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --gunit_break_on_failure --undefok=gunit_break_on_failure -v=2 5 | WindowsLocalDebugger 6 | $ENV_VAR_LINES 7 | $$(LocalDebuggerEnvironment) 8 | 9 | 10 | -------------------------------------------------------------------------------- /xrtl/port/linux/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Linux port root. Packages under here match those in the root XRTL package. 3 | # May use some of the common port files under //xrtl/port/common/. 4 | # 5 | # Targets: 6 | # - Ubuntu 7 | 8 | package(default_visibility = ["//xrtl:internal"]) 9 | 10 | licenses(["notice"]) # Apache 2.0 11 | 12 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 13 | 14 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:linux"]) 15 | 16 | # 17 | 18 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 19 | 20 | portable_test_suite() 21 | -------------------------------------------------------------------------------- /xrtl/port/emscripten/base/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Emscripten port variants of //xrtl/base/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = [ 11 | "//xrtl/tools/target_platform:emscripten", 12 | ]) 13 | 14 | cc_library( 15 | name = "emscripten_logging_sink", 16 | srcs = ["emscripten_logging_sink.cc"], 17 | deps = [ 18 | "//xrtl/base:logging_hdrs", 19 | "//xrtl/port/common/base:logging_macros_hdrs", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /xrtl/port/windows/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Windows port root. Packages under here match those in the root XRTL package. 3 | # May use some of the common port files under //xrtl/port/common/. 4 | # 5 | # Targets: 6 | # - Visual C++: 2017 7 | # - Windows SDK: 10? 8 | 9 | package(default_visibility = ["//xrtl:internal"]) 10 | 11 | licenses(["notice"]) # Apache 2.0 12 | 13 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 14 | 15 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:windows"]) 16 | 17 | # 18 | 19 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 20 | 21 | portable_test_suite() 22 | -------------------------------------------------------------------------------- /xrtl/port/emscripten/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Emscripten port root. Packages under here match those in the root XRTL 3 | # package. May use some of the common port files under //xrtl/port/common/. 4 | # 5 | # Targets: 6 | # - Emscripten: 1.37.3 7 | 8 | package(default_visibility = ["//xrtl:internal"]) 9 | 10 | licenses(["notice"]) # Apache 2.0 11 | 12 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 13 | 14 | package_platforms(default_platforms = [ 15 | "//xrtl/tools/target_platform:emscripten", 16 | ]) 17 | 18 | # 19 | 20 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 21 | 22 | portable_test_suite() 23 | -------------------------------------------------------------------------------- /tools/visual_studio/sln.template: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 15 3 | VisualStudioVersion = 15.0.26228.9 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | $PROJECT_LINES 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | dbg|x64 = dbg|x64 10 | fastbuild|x64 = fastbuild|x64 11 | opt|x64 = opt|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | $PROJECT_CONFIG_LINES 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /xrtl/port/android/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Android port root. Packages under here match those in the root XRTL package. 3 | # May use some of the common port files under //xrtl/port/common/. 4 | # 5 | # Targets: 6 | # - Android API Level: 23 7 | # - NDK Version: 14b 8 | # - Compiler: clang 9 | 10 | package(default_visibility = ["//xrtl:internal"]) 11 | 12 | licenses(["notice"]) # Apache 2.0 13 | 14 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 15 | 16 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:android"]) 17 | 18 | # 19 | 20 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 21 | 22 | portable_test_suite() 23 | -------------------------------------------------------------------------------- /xrtl/port/ios/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # iOS port root. Packages under here match those in the root XRTL package. 3 | # May use some of the common port files under //xrtl/port/common/ and 4 | # //xrtl/port/apple/. 5 | # 6 | # Targets: 7 | # - Xcode Version: 8.2 8 | # - iOS SDK: 10? 9 | # - iOS Version: 10? 10 | 11 | package(default_visibility = ["//xrtl:internal"]) 12 | 13 | licenses(["notice"]) # Apache 2.0 14 | 15 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 16 | 17 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:ios"]) 18 | 19 | # 20 | 21 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 22 | 23 | portable_test_suite() 24 | -------------------------------------------------------------------------------- /xrtl/port/macos/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # MacOS port root. Packages under here match those in the root XRTL package. 3 | # May use some of the common port files under //xrtl/port/common/ and 4 | # //xrtl/port/apple/. 5 | # 6 | # Targets: 7 | # - Xcode Version: 8.2 8 | # - MacOS SDK: 10? 9 | # - MacOS Version: 10? 10 | 11 | package(default_visibility = ["//xrtl:internal"]) 12 | 13 | licenses(["notice"]) # Apache 2.0 14 | 15 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 16 | 17 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:macos"]) 18 | 19 | # 20 | 21 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 22 | 23 | portable_test_suite() 24 | -------------------------------------------------------------------------------- /xrtl/port/android/base/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Android port variants of //xrtl/base/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:android"]) 11 | 12 | cc_library( 13 | name = "android_logging_sink", 14 | srcs = ["android_logging_sink.cc"], 15 | deps = [ 16 | "//xrtl/base:logging_hdrs", 17 | "//xrtl/port/common/base:logging_macros_hdrs", 18 | ], 19 | ) 20 | 21 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 22 | 23 | portable_test_suite() 24 | -------------------------------------------------------------------------------- /.bazelproject: -------------------------------------------------------------------------------- 1 | # This is the default project view file for CLion. It describes which 2 | # directories and targets CLion should traverse when ingesting the Bazel build. 3 | # 4 | # Developers who only wish to work on a subset of XRTL may maintain custom 5 | # project views locally. The more narrowly scoped the project view, the faster 6 | # CLion indexing will be. Restricted project views of general interest may also 7 | # be committed to this directory, with file names of the form foo.bazelproject. 8 | # 9 | # Detailed documentation for the file format is available at 10 | # https://ij.bazel.build/docs/project-views.html 11 | 12 | directories: 13 | third_party/ 14 | xrtl/ 15 | 16 | targets: 17 | //xrtl/...:all 18 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # Clang format with similar settings to how clang-format internally works. 2 | 3 | BasedOnStyle: Google 4 | 5 | # Keep 80 so we have the same in all files (including .mm). 6 | ColumnLimit: 80 7 | 8 | # If false, a function call’s or function definition’s parameters will either 9 | # all be on the same line or will have one line each. 10 | BinPackParameters: true 11 | 12 | # Allow putting all parameters of a function declaration onto the next line even 13 | # if BinPackParameters is false. 14 | # For example this should be ok: 15 | # someFunction(foo, 16 | # bar, 17 | # baz); 18 | AllowAllParametersOfDeclarationOnNextLine: true 19 | 20 | DerivePointerAlignment: false 21 | PointerAlignment: Left 22 | SortIncludes: true 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS detritus 2 | .DS_Store 3 | ._* 4 | .Spotlight-V100 5 | .Trashes 6 | .com.apple.* 7 | Thumbs.db 8 | Desktop.ini 9 | .svn 10 | 11 | # Emacs 12 | *~ 13 | 14 | # Sublime Text 15 | *.sublime-project 16 | *.sublime-workspace 17 | 18 | # VIM 19 | .*.sw[a-z] 20 | *.un~ 21 | Session.vim 22 | 23 | # TextMate 24 | *.tmproj 25 | *.tmproject 26 | tmtags 27 | 28 | # Eclipse 29 | .project 30 | .metadata 31 | 32 | # WebStorm 33 | .idea 34 | 35 | # VS 36 | .vs 37 | *.user 38 | *.sdf 39 | *.opensdf 40 | bin/ 41 | obj/ 42 | 43 | # Compiler Outputs 44 | *.py[co] 45 | *.o 46 | .scratch/ 47 | 48 | # Bazel 49 | /bazel-bin 50 | /bazel-genfiles 51 | /bazel-out 52 | /bazel-testlogs 53 | /bazel-xrtl 54 | 55 | # Tulsi 56 | tulsi-workspace 57 | tulsigen-xrtl 58 | *.tulsiconf-user 59 | 60 | # Android 61 | tools/android-sdk/ 62 | -------------------------------------------------------------------------------- /xrtl/base/proto_util.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/proto_util.h" 16 | 17 | #include "xrtl/base/macros.h" 18 | 19 | namespace xrtl { 20 | 21 | XRTL_EMPTY_FILE() 22 | 23 | } // namespace xrtl 24 | -------------------------------------------------------------------------------- /tools/utils/echo_vcvarsall.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Copyright 2017 Google Inc. 3 | REM 4 | REM Licensed under the Apache License, Version 2.0 (the "License"); 5 | REM you may not use this file except in compliance with the License. 6 | REM You may obtain a copy of the License at 7 | REM 8 | REM http://www.apache.org/licenses/LICENSE-2.0 9 | REM 10 | REM Unless required by applicable law or agreed to in writing, software 11 | REM distributed under the License is distributed on an "AS IS" BASIS, 12 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | REM See the License for the specific language governing permissions and 14 | REM limitations under the License. 15 | 16 | IF EXIST "%VS140COMNTOOLS%..\..\vc\vcvarsall.bat" ( 17 | "%VS140COMNTOOLS%..\..\vc\vcvarsall.bat" && SET 18 | ) 19 | -------------------------------------------------------------------------------- /xrtl/port/common/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Common port root. Packages under here match those in the root XRTL package. 3 | # The code in these packages may be shared by one or more of the platform ports 4 | # either directly or as a base implementation. Not all code may be used by 5 | # all platforms. 6 | # 7 | # We keep this common code here instead of outside of port/ so that we can 8 | # ensure all non-port/ code is platform agnostic. Were we to put these files 9 | # directly under //xrtl/... it becomes very easy to inadvertently pull in 10 | # platform-family-specific code. By keeping the code separate we also allow 11 | # bazel recursive package actions to work without any particular --config 12 | # specified. 13 | 14 | package(default_visibility = ["//xrtl:internal"]) 15 | 16 | licenses(["notice"]) # Apache 2.0 17 | -------------------------------------------------------------------------------- /xrtl/base/testdata/proto_util_test.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package xrtl.testdata; 18 | 19 | message SimpleMessage { 20 | int32 int32_value = 1; 21 | string string_value = 2; 22 | } 23 | -------------------------------------------------------------------------------- /xrtl/testing/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_TESTING_GTEST_H_ 16 | #define XRTL_TESTING_GTEST_H_ 17 | 18 | #include "gmock/gmock.h" 19 | #include "gtest/gtest.h" 20 | 21 | #endif // XRTL_TESTING_GTEST_H_ 22 | -------------------------------------------------------------------------------- /tools/ci/travis/.bazelrc: -------------------------------------------------------------------------------- 1 | # Default bazel configuration when running under Travis. 2 | 3 | startup --host_jvm_args=-Xmx500m 4 | startup --host_jvm_args=-Xmx500m 5 | startup --batch 6 | 7 | build --define=XRTL_USE_SWIFTSHADER=1 8 | build --ignore_unsupported_sandboxing 9 | build --verbose_failures 10 | build --progress_report_interval=10 11 | build --spawn_strategy=standalone 12 | build --genrule_strategy=standalone 13 | build --keep_going 14 | 15 | test --define=XRTL_USE_SWIFTSHADER=1 16 | test --ignore_unsupported_sandboxing 17 | test --verbose_failures 18 | test --progress_report_interval=10 19 | test --spawn_strategy=standalone 20 | test --genrule_strategy=standalone 21 | test --test_output=errors 22 | test --test_strategy=standalone 23 | test --worker_verbose 24 | test --strategy=Javac=worker 25 | test --strategy=Closure=worker 26 | test --keep_going 27 | -------------------------------------------------------------------------------- /xrtl/port/common/base/posix_cli_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/cli_main.h" 16 | 17 | namespace xrtl { 18 | 19 | extern "C" int main(int argc, char** argv) { return CliMain(argc, argv); } 20 | 21 | } // namespace xrtl 22 | -------------------------------------------------------------------------------- /xrtl/port/common/base/gflags_flags.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_COMMON_BASE_GFLAGS_FLAGS_H_ 16 | #define XRTL_PORT_COMMON_BASE_GFLAGS_FLAGS_H_ 17 | 18 | #include 19 | 20 | #endif // XRTL_PORT_COMMON_BASE_GFLAGS_FLAGS_H_ 21 | -------------------------------------------------------------------------------- /tools/xcode/xrtl.tulsiproj/project.tulsiconf: -------------------------------------------------------------------------------- 1 | { 2 | "configDefaults" : { 3 | "optionSet" : { 4 | "CommandlineArguments" : { 5 | "p" : "--undefok=NSDocumentRevisionsDebugMode" 6 | }, 7 | "BazelBuildOptionsDebug" : { 8 | "p" : "--ios_signing_cert_name=-" 9 | }, 10 | "BazelBuildOptionsRelease" : { 11 | "p" : "--ios_signing_cert_name=-" 12 | } 13 | } 14 | }, 15 | "projectName" : "xrtl", 16 | "packages" : [ 17 | "xrtl", 18 | "xrtl\/base", 19 | "xrtl\/examples", 20 | "xrtl\/gfx", 21 | "xrtl\/gfx\/spirv", 22 | "xrtl\/gfx\/testing", 23 | "xrtl\/port\/apple", 24 | "xrtl\/port\/ios", 25 | "xrtl\/port\/macos", 26 | "xrtl\/port\/macos\/gfx\/es3", 27 | "xrtl\/testing", 28 | "xrtl\/testing\/diffing", 29 | "xrtl\/ui" 30 | ], 31 | "workspaceRoot" : "..\/..\/.." 32 | } 33 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_framebuffer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/es3/es3_framebuffer.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | namespace es3 { 20 | 21 | // 22 | 23 | } // namespace es3 24 | } // namespace gfx 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/ui/system_theme_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/ui/system_theme.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace ui { 21 | namespace { 22 | 23 | // 24 | 25 | } // namespace 26 | } // namespace ui 27 | } // namespace xrtl 28 | -------------------------------------------------------------------------------- /xrtl/base/proto_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_PROTO_UTIL_H_ 16 | #define XRTL_BASE_PROTO_UTIL_H_ 17 | 18 | namespace xrtl { 19 | 20 | // TODO(benvanik): utilities to serialize/compress/etc protos. 21 | 22 | } // namespace xrtl 23 | 24 | #endif // XRTL_BASE_PROTO_UTIL_H_ 25 | -------------------------------------------------------------------------------- /xrtl/port/apple/base/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Apple port variants of //xrtl/base/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = [ 11 | "//xrtl/tools/target_platform:ios", 12 | "//xrtl/tools/target_platform:macos", 13 | ]) 14 | 15 | cc_library( 16 | name = "darwin_debugging", 17 | srcs = ["darwin_debugging.cc"], 18 | deps = [ 19 | "//xrtl/base:debugging_hdrs", 20 | ], 21 | ) 22 | 23 | cc_library( 24 | name = "mach_system_clock", 25 | srcs = ["mach_system_clock.cc"], 26 | deps = [ 27 | "//xrtl/base:macros", 28 | "//xrtl/base:system_clock_hdrs", 29 | ], 30 | ) 31 | 32 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 33 | 34 | portable_test_suite() 35 | -------------------------------------------------------------------------------- /xrtl/port/common/testing/posix_demo_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/demo_main.h" 16 | 17 | namespace xrtl { 18 | namespace testing { 19 | 20 | extern "C" int main(int argc, char** argv) { return DemoMain(argc, argv); } 21 | 22 | } // namespace testing 23 | } // namespace xrtl 24 | -------------------------------------------------------------------------------- /xrtl/port/linux/ui/x11_system_theme.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/port/linux/ui/x11_headers.h" 16 | #include "xrtl/ui/system_theme.h" 17 | 18 | namespace xrtl { 19 | namespace ui { 20 | 21 | // TODO(benvanik): read X resource database. 22 | 23 | } // namespace ui 24 | } // namespace xrtl 25 | -------------------------------------------------------------------------------- /tools/crosstool/msan/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # cc_toolchain for --config=msan. 3 | # This is required for msan as we need to use our own locally-built libc++. 4 | # See //tools/ci/jenkins/linux/setup_node.sh for the libc++ setup instructions. 5 | 6 | package(default_visibility = ["//visibility:public"]) 7 | 8 | filegroup( 9 | name = "empty", 10 | srcs = [], 11 | ) 12 | 13 | cc_toolchain_suite( 14 | name = "msan", 15 | toolchains = { 16 | "k8|compiler": ":cc-compiler-k8-msan", 17 | }, 18 | ) 19 | 20 | cc_toolchain( 21 | name = "cc-compiler-k8-msan", 22 | all_files = ":empty", 23 | compiler_files = ":empty", 24 | cpu = "local", 25 | dwp_files = ":empty", 26 | dynamic_runtime_libs = [":empty"], 27 | linker_files = ":empty", 28 | objcopy_files = ":empty", 29 | static_runtime_libs = [":empty"], 30 | strip_files = ":empty", 31 | supports_param_files = 1, 32 | ) 33 | -------------------------------------------------------------------------------- /xrtl/gfx/device.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/device.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | 20 | bool Device::IsCompatible(const Features& requested_features) const { 21 | // TODO(benvanik): features. 22 | return true; 23 | } 24 | 25 | } // namespace gfx 26 | } // namespace xrtl 27 | -------------------------------------------------------------------------------- /xrtl/port/windows/ui/win32_system_theme.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/port/windows/base/windows.h" 16 | #include "xrtl/ui/system_theme.h" 17 | 18 | namespace xrtl { 19 | namespace ui { 20 | 21 | // TODO(benvanik): GetSysColors/GetSystemMetrics/etc. 22 | 23 | } // namespace ui 24 | } // namespace xrtl 25 | -------------------------------------------------------------------------------- /xrtl/gfx/context_factory_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/context_factory.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace gfx { 21 | namespace { 22 | 23 | TEST(ContextFactoryTest, Foo) { 24 | // 25 | } 26 | 27 | } // namespace 28 | } // namespace gfx 29 | } // namespace xrtl 30 | -------------------------------------------------------------------------------- /xrtl/port/windows/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Windows port variants of //xrtl/testing/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:windows"]) 11 | 12 | cc_library( 13 | name = "win32_demo_main", 14 | srcs = ["win32_demo_main.cc"], 15 | linkopts = [ 16 | "-SUBSYSTEM:WINDOWS", 17 | "-DEFAULTLIB:ole32.lib", 18 | "-DEFAULTLIB:shell32.lib", 19 | ], 20 | deps = [ 21 | "//xrtl/base:debugging", 22 | "//xrtl/base:flags", 23 | "//xrtl/base:logging", 24 | "//xrtl/port/windows/base:windows_headers", 25 | "//xrtl/testing:demo_main_hdrs", 26 | ], 27 | ) 28 | 29 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 30 | 31 | portable_test_suite() 32 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_ios_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformIosTest, True) { EXPECT_TRUE(XRTL_PLATFORM_IOS); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_linux_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformLinuxTest, True) { EXPECT_TRUE(XRTL_PLATFORM_LINUX); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_macos_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformMacOSTest, True) { EXPECT_TRUE(XRTL_PLATFORM_MACOS); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/port/apple/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Testing utilities for iOS and MacOS. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = [ 11 | "//xrtl/tools/target_platform:ios", 12 | "//xrtl/tools/target_platform:macos", 13 | ]) 14 | 15 | exports_files(["apple_test.plist"]) 16 | 17 | objc_library( 18 | name = "apple_test_main", 19 | testonly = 1, 20 | srcs = ["apple_test_main.mm"], 21 | sdk_frameworks = [ 22 | "XCTest", 23 | ], 24 | deps = [ 25 | "//xrtl/base:env", 26 | "//xrtl/base:flags", 27 | "//xrtl/testing:file_util", 28 | "//xrtl/testing:gtest", 29 | "//xrtl/tools/target_platform", 30 | ], 31 | ) 32 | 33 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 34 | 35 | portable_test_suite() 36 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_android_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformAndroidTest, True) { EXPECT_TRUE(XRTL_PLATFORM_ANDROID); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_windows_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformWindowsTest, True) { EXPECT_TRUE(XRTL_PLATFORM_WINDOWS); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/base/threading/timer_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/threading/timer.h" 16 | 17 | #include "xrtl/base/threading/thread.h" 18 | #include "xrtl/testing/gtest.h" 19 | 20 | namespace xrtl { 21 | namespace { 22 | 23 | TEST(TimerTest, Initialization) { 24 | // TODO(benvanik): timers. 25 | } 26 | 27 | } // namespace 28 | } // namespace xrtl 29 | -------------------------------------------------------------------------------- /xrtl/port/apple/base/threading/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # CFRunLoop and Mach port variants of //xrtl/base/threading/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = [ 11 | "//xrtl/tools/target_platform:ios", 12 | "//xrtl/tools/target_platform:macos", 13 | ]) 14 | 15 | objc_library( 16 | name = "cfrunloop_message_loop", 17 | srcs = ["cfrunloop_message_loop.mm"], 18 | copts = [ 19 | "-std=c++11", 20 | "-x objective-c++", 21 | ], 22 | sdk_frameworks = ["CoreFoundation"], 23 | deps = [ 24 | "//xrtl/base/threading:event", 25 | "//xrtl/base/threading:thread", 26 | "//xrtl/base/threading:threading_hdrs", 27 | ], 28 | ) 29 | 30 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 31 | 32 | portable_test_suite() 33 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/platform_emscripten_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | TEST(PlatformEmscriptenTest, True) { EXPECT_TRUE(XRTL_PLATFORM_EMSCRIPTEN); } 23 | 24 | } // namespace 25 | } // namespace xrtl 26 | -------------------------------------------------------------------------------- /xrtl/port/linux/ui/x11_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_LINUX_UI_X11_HEADERS_H_ 16 | #define XRTL_PORT_LINUX_UI_X11_HEADERS_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #undef Bool 26 | #undef None 27 | 28 | #endif // XRTL_PORT_LINUX_UI_X11_HEADERS_H_ 29 | -------------------------------------------------------------------------------- /xrtl/tools/target_config/target_config.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_config/target_config.h" 16 | 17 | // XRTL_EMPTY_FILE(), inlined because we can't depend on macros.h. 18 | #if defined(__clang__) || defined(__GNUC__) 19 | __attribute__((visibility("default"))) static int dummy 20 | __attribute__((unused, used)) = 0; 21 | #endif // GCC-ish 22 | -------------------------------------------------------------------------------- /xrtl/base/debugging_settings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_DEBUGGING_SETTINGS_H_ 16 | #define XRTL_BASE_DEBUGGING_SETTINGS_H_ 17 | 18 | namespace xrtl { 19 | namespace debugging { 20 | 21 | // TODO(benvanik): a way to get compile-time settings? 22 | 23 | } // namespace debugging 24 | } // namespace xrtl 25 | 26 | #endif // XRTL_BASE_DEBUGGING_SETTINGS_H_ 27 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/target_platform.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/tools/target_platform/target_platform.h" 16 | 17 | // XRTL_EMPTY_FILE(), inlined because we can't depend on macros.h. 18 | #if defined(__clang__) || defined(__GNUC__) 19 | __attribute__((visibility("default"))) static int dummy 20 | __attribute__((unused, used)) = 0; 21 | #endif // GCC-ish 22 | -------------------------------------------------------------------------------- /third_party/proggy_fonts/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Proggy fonts package. 3 | # http://upperbounds.net/index.php?menu=download 4 | # https://geoff.greer.fm/2013/12/24/programming-fonts/ 5 | 6 | package(default_visibility = ["//visibility:private"]) 7 | 8 | licenses(["notice"]) # MIT 9 | 10 | exports_files(["LICENSE"]) 11 | 12 | genrule( 13 | name = "proggy_tiny_cc", 14 | srcs = ["ProggyTiny.ttf"], 15 | outs = ["proggy_tiny.cc"], 16 | cmd = "\n".join([ 17 | "echo \"#include \\\"proggy_tiny.h\\\"\n\" > $@", 18 | "$(location @//third_party/dear_imgui:binary_to_compressed_c) -base85 $(location ProggyTiny.ttf) proggy_tiny >> $@", 19 | ]), 20 | tools = ["@//third_party/dear_imgui:binary_to_compressed_c"], 21 | ) 22 | 23 | cc_library( 24 | name = "proggy_tiny_embedded", 25 | srcs = [":proggy_tiny_cc"], 26 | hdrs = ["proggy_tiny.h"], 27 | copts = [ 28 | "-Ithird_party/proggy_fonts/", 29 | ], 30 | visibility = ["//visibility:public"], 31 | ) 32 | -------------------------------------------------------------------------------- /xrtl/port/windows/gfx/es3/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # OpenGL ES 3.X platform implementation based on WGL. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:windows"]) 11 | 12 | cc_library( 13 | name = "wgl_platform_context", 14 | srcs = ["wgl_platform_context.cc"], 15 | hdrs = ["wgl_platform_context.h"], 16 | linkopts = [ 17 | "-DEFAULTLIB:gdi32.lib", 18 | ], 19 | deps = [ 20 | "//third_party/glad:glad_wgl", 21 | "//xrtl/base:debugging", 22 | "//xrtl/base:flags", 23 | "//xrtl/base:macros", 24 | "//xrtl/base:tracing", 25 | "//xrtl/gfx/es3:es3_platform_context_hdrs", 26 | "@com_google_absl//absl/base", 27 | ], 28 | ) 29 | 30 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 31 | 32 | portable_test_suite() 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | -------------------------------------------------------------------------------- /xrtl/port/macos/gfx/es3/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # OpenGL ES 3.X platform implementation based on CGL. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:macos"]) 11 | 12 | objc_library( 13 | name = "cgl_platform_context", 14 | srcs = ["cgl_platform_context.cc"], 15 | hdrs = ["cgl_platform_context.h"], 16 | copts = [ 17 | "-std=c++11", 18 | "-x objective-c++", 19 | ], 20 | sdk_frameworks = [ 21 | "CoreFoundation", 22 | "OpenGL", 23 | ], 24 | deps = [ 25 | "//xrtl/base:debugging", 26 | "//xrtl/base:flags", 27 | "//xrtl/base:macros", 28 | "//xrtl/base:tracing", 29 | "//xrtl/gfx/es3:es3_platform_context_hdrs", 30 | "@com_google_absl//absl/base", 31 | ], 32 | ) 33 | 34 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 35 | 36 | portable_test_suite() 37 | -------------------------------------------------------------------------------- /tools/ci/appveyor/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Copyright 2017 Google Inc. 3 | REM 4 | REM Licensed under the Apache License, Version 2.0 (the "License"); 5 | REM you may not use this file except in compliance with the License. 6 | REM You may obtain a copy of the License at 7 | REM 8 | REM http://www.apache.org/licenses/LICENSE-2.0 9 | REM 10 | REM Unless required by applicable law or agreed to in writing, software 11 | REM distributed under the License is distributed on an "AS IS" BASIS, 12 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | REM See the License for the specific language governing permissions and 14 | REM limitations under the License. 15 | 16 | SET DIR=%~dp0 17 | 18 | CD %WORKSPACE% 19 | 20 | REM ============================================================================ 21 | REM Run Build 22 | REM ============================================================================ 23 | 24 | CMD /C xtool.bat build --tool_tag=vs --all -c dbg 25 | IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL% 26 | 27 | EXIT /b 0 28 | -------------------------------------------------------------------------------- /xrtl/base/protobuf.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_PROTOBUF_H_ 16 | #define XRTL_BASE_PROTOBUF_H_ 17 | 18 | #include "xrtl/base/macros.h" 19 | 20 | // Import the platform-specific protobuf implementation into the xrtl::protobuf 21 | // namespace. 22 | 23 | #ifdef XRTL_CONFIG_GOOGLE_INTERNAL 24 | #include "xrtl/port/google/base/protobuf.h" 25 | #else 26 | #include "xrtl/port/common/base/protobuf.h" 27 | #endif // XRTL_CONFIG_GOOGLE_INTERNAL 28 | 29 | #endif // XRTL_BASE_PROTOBUF_H_ 30 | -------------------------------------------------------------------------------- /tools/ci/appveyor/test.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Copyright 2017 Google Inc. 3 | REM 4 | REM Licensed under the Apache License, Version 2.0 (the "License"); 5 | REM you may not use this file except in compliance with the License. 6 | REM You may obtain a copy of the License at 7 | REM 8 | REM http://www.apache.org/licenses/LICENSE-2.0 9 | REM 10 | REM Unless required by applicable law or agreed to in writing, software 11 | REM distributed under the License is distributed on an "AS IS" BASIS, 12 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | REM See the License for the specific language governing permissions and 14 | REM limitations under the License. 15 | 16 | SET DIR=%~dp0 17 | 18 | CD %WORKSPACE% 19 | 20 | REM ============================================================================ 21 | REM Run Tests 22 | REM ============================================================================ 23 | 24 | CMD /C xtool.bat test --tool_tag=vs --all -c dbg --keep_going --test_tag_filters=-requires_gpu 25 | IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL% 26 | 27 | EXIT /b 0 28 | -------------------------------------------------------------------------------- /xrtl/ui/shaders/imgui_overlay.frag: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | precision highp float; 16 | 17 | layout(push_constant) uniform PushConstants { 18 | mat4 proj_matrix; 19 | } push_constants; 20 | 21 | layout(set = 0, binding = 0) uniform sampler2D image_sampler; 22 | 23 | layout(location = 0) in vec2 vtx_uv; 24 | layout(location = 1) in vec4 vtx_color; 25 | 26 | layout(location = 0) out vec4 out_color; 27 | 28 | void main() { 29 | vec4 tex_sample = texture(image_sampler, vtx_uv); 30 | out_color = vtx_color * tex_sample; 31 | } 32 | -------------------------------------------------------------------------------- /third_party/proggy_fonts/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004, 2005 Tristan Grimmer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /tools/ci/appveyor/.bazelrc: -------------------------------------------------------------------------------- 1 | # Default bazel configuration when running under Travis. 2 | 3 | startup --output_base="c:\\bazel_root\\" 4 | startup --host_jvm_args=-Xmx500m 5 | startup --host_jvm_args=-Xmx500m 6 | startup --batch 7 | 8 | build --define=XRTL_USE_SWIFTSHADER=1 9 | build --ignore_unsupported_sandboxing 10 | build --verbose_failures 11 | build --local_resources=400,2,1.0 12 | build --spawn_strategy=standalone 13 | build --genrule_strategy=standalone 14 | build --keep_going 15 | 16 | test --define=XRTL_USE_SWIFTSHADER=1 17 | test --ignore_unsupported_sandboxing 18 | test --verbose_failures 19 | test --local_resources=400,2,1.0 20 | test --spawn_strategy=standalone 21 | test --genrule_strategy=standalone 22 | test --test_output=errors 23 | test --test_strategy=standalone 24 | test --worker_verbose 25 | test --strategy=Javac=worker 26 | test --strategy=Closure=worker 27 | test --keep_going 28 | 29 | # TODO(benvanik): figure out why appveyor needs these for third_party includes. 30 | build --strategy=CppCompile=standalone 31 | build --strategy=CppLink=standalone 32 | test --strategy=CppCompile=standalone 33 | test --strategy=CppLink=standalone 34 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_command_fence.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_COMMAND_FENCE_H_ 16 | #define XRTL_GFX_ES3_ES3_COMMAND_FENCE_H_ 17 | 18 | #include "xrtl/gfx/command_fence.h" 19 | #include "xrtl/gfx/es3/es3_common.h" 20 | 21 | namespace xrtl { 22 | namespace gfx { 23 | namespace es3 { 24 | 25 | class ES3CommandFence : public CommandFence { 26 | public: 27 | ES3CommandFence() = default; 28 | }; 29 | 30 | } // namespace es3 31 | } // namespace gfx 32 | } // namespace xrtl 33 | 34 | #endif // XRTL_GFX_ES3_ES3_COMMAND_FENCE_H_ 35 | -------------------------------------------------------------------------------- /third_party/glad/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 David Herberth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /xrtl/ui/shaders/imgui_overlay.vert: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | precision highp float; 16 | 17 | layout(push_constant, std140) uniform PushConstants { 18 | mat4 proj_matrix; 19 | } push_constants; 20 | 21 | layout(location = 0) in vec2 in_pos; 22 | layout(location = 1) in vec2 in_uv; 23 | layout(location = 2) in vec4 in_color; 24 | 25 | layout(location = 0) out vec2 vtx_uv; 26 | layout(location = 1) out vec4 vtx_color; 27 | 28 | void main() { 29 | gl_Position = push_constants.proj_matrix * vec4(in_pos.xy, 0.0, 1.0); 30 | vtx_uv = in_uv; 31 | vtx_color = in_color; 32 | } 33 | -------------------------------------------------------------------------------- /third_party/dear_imgui/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Omar Cornut and ImGui contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /xrtl/base/cli_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/cli_main.h" 16 | 17 | #include 18 | 19 | #include "xrtl/base/flags.h" 20 | #include "xrtl/base/logging.h" 21 | 22 | namespace xrtl { 23 | 24 | int CliMain(int argc, char** argv) { 25 | // Setup flags. 26 | xrtl::flags::SetUsageMessage(std::string("\n$ ") + argv[0]); 27 | xrtl::flags::ParseCommandLineFlags(&argc, &argv, true); 28 | 29 | int exit_code = GetCliEntryPoint()(argc, argv); 30 | 31 | xrtl::flags::ShutDownCommandLineFlags(); 32 | 33 | return exit_code; 34 | } 35 | 36 | } // namespace xrtl 37 | -------------------------------------------------------------------------------- /xrtl/base/system_clock.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/system_clock.h" 16 | 17 | #include "xrtl/base/macros.h" 18 | 19 | namespace xrtl { 20 | 21 | SystemClock* SystemClock::default_clock_ = nullptr; 22 | 23 | SystemClock* SystemClock::default_clock() { 24 | return default_clock_ ? default_clock_ : logging_clock(); 25 | } 26 | 27 | void SystemClock::set_default_clock(SystemClock* clock) { 28 | default_clock_ = clock; 29 | } 30 | 31 | SystemClock* SystemClock::logging_clock() { 32 | static SystemClock* clock = Create().release(); 33 | return clock; 34 | } 35 | 36 | } // namespace xrtl 37 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/html_diff_provider_create.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/diffing/html_diff_provider.h" 16 | 17 | #include "xrtl/base/macros.h" 18 | 19 | namespace xrtl { 20 | namespace testing { 21 | namespace diffing { 22 | 23 | // Factory function to create the HtmlDiffProvider as the default provider. 24 | // Depend on //xrtl/testing/diffing:html_diff_provider_create to link this in. 25 | std::unique_ptr DiffProvider::Create() { 26 | return absl::make_unique(); 27 | } 28 | 29 | } // namespace diffing 30 | } // namespace testing 31 | } // namespace xrtl 32 | -------------------------------------------------------------------------------- /xrtl/port/common/base/threading/pthreads_wait_handle.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/port/common/base/threading/pthreads_wait_handle.h" 16 | 17 | namespace xrtl { 18 | 19 | namespace { 20 | 21 | pthread_mutex_t shared_multi_mutex_ = PTHREAD_MUTEX_INITIALIZER; 22 | pthread_cond_t shared_multi_cond_ = PTHREAD_COND_INITIALIZER; 23 | 24 | } // namespace 25 | 26 | pthread_mutex_t* PthreadsWaitHandleImpl::shared_multi_mutex() { 27 | return &shared_multi_mutex_; 28 | } 29 | 30 | pthread_cond_t* PthreadsWaitHandleImpl::shared_multi_cond() { 31 | return &shared_multi_cond_; 32 | } 33 | 34 | } // namespace xrtl 35 | -------------------------------------------------------------------------------- /third_party/dear_imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef IMCONFIG_H_ 2 | #define IMCONFIG_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "xrtl/base/logging.h" 8 | 9 | // Define assertion handler. 10 | #define IM_ASSERT(_EXPR) DCHECK(_EXPR) 11 | 12 | // Don't define obsolete functions names. 13 | #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 14 | 15 | // Define constructor and implicit cast operators to convert glm. 16 | #define IM_VEC2_CLASS_EXTRA \ 17 | ImVec2(const glm::vec2& f) { \ 18 | x = f.x; \ 19 | y = f.y; \ 20 | } \ 21 | operator glm::vec2() const { return glm::vec2(x, y); } 22 | #define IM_VEC4_CLASS_EXTRA \ 23 | ImVec4(const glm::vec4& f) { \ 24 | x = f.x; \ 25 | y = f.y; \ 26 | z = f.z; \ 27 | w = f.w; \ 28 | } \ 29 | operator glm::vec4() const { return glm::vec4(x, y, z, w); } 30 | 31 | struct ImGuiContext; 32 | extern thread_local ImGuiContext* thread_imgui_context; 33 | 34 | #define GImGui thread_imgui_context 35 | #define IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx) thread_imgui_context = ctx 36 | 37 | #endif // IMCONFIG_H_ 38 | -------------------------------------------------------------------------------- /xrtl/port/common/base/posix_debugging.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/debugging.h" 16 | 17 | namespace xrtl { 18 | namespace debugging { 19 | 20 | void EnableDebugHeap() { 21 | // TODO(benvanik): something with tcmalloc? 22 | } 23 | 24 | bool is_console_attached() { 25 | // TODO(benvanik): console detection. 26 | return true; 27 | } 28 | 29 | bool AttachConsole() { 30 | // TODO(benvanik): console detection. 31 | return true; 32 | } 33 | 34 | bool is_debugger_attached() { 35 | // TODO(benvanik): debugger detection. 36 | return false; 37 | } 38 | 39 | } // namespace debugging 40 | } // namespace xrtl 41 | -------------------------------------------------------------------------------- /xrtl/port/common/gfx/es3/egl_strings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_COMMON_GFX_ES3_EGL_STRINGS_H_ 16 | #define XRTL_PORT_COMMON_GFX_ES3_EGL_STRINGS_H_ 17 | 18 | namespace xrtl { 19 | namespace gfx { 20 | namespace es3 { 21 | 22 | // Returns a string representing the given EGL error enum value name. 23 | const char* GetEglErrorName(int error); 24 | 25 | // Returns a string representing the given EGL error enum value description. 26 | const char* GetEglErrorDescription(int error); 27 | 28 | } // namespace es3 29 | } // namespace gfx 30 | } // namespace xrtl 31 | 32 | #endif // XRTL_PORT_COMMON_GFX_ES3_EGL_STRINGS_H_ 33 | -------------------------------------------------------------------------------- /third_party/dear_imgui/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # imgui package. 3 | 4 | package(default_visibility = ["//visibility:private"]) 5 | 6 | licenses(["notice"]) # MIT 7 | 8 | cc_library( 9 | name = "dear_imgui", 10 | srcs = [ 11 | "imconfig.cpp", 12 | "imconfig.h", 13 | "imgui.cpp", 14 | "imgui_demo.cpp", 15 | "imgui_draw.cpp", 16 | "imgui_internal.h", 17 | ], 18 | hdrs = [ 19 | "imgui.h", 20 | ], 21 | copts = [ 22 | "-DIMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION", 23 | "-DIMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION", 24 | ], 25 | defines = [ 26 | "IMGUI_INCLUDE_IMCONFIG_H", 27 | ], 28 | visibility = ["//visibility:public"], 29 | deps = [ 30 | "@//xrtl/base:logging", 31 | "@com_github_gtruc_glm//:glm", 32 | 33 | # imgui requires an internal textedit implementation. 34 | "@com_github_nothings_stb//:stb_textedit_hdrs", 35 | "@com_github_nothings_stb//:stb_rect_pack", 36 | "@com_github_nothings_stb//:stb_truetype", 37 | ], 38 | ) 39 | 40 | cc_binary( 41 | name = "binary_to_compressed_c", 42 | srcs = ["extra_fonts/binary_to_compressed_c.cpp"], 43 | visibility = ["//visibility:public"], 44 | ) 45 | -------------------------------------------------------------------------------- /xrtl/port/common/testing/posix_test_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/flags.h" 16 | #include "xrtl/base/logging.h" 17 | #include "xrtl/testing/file_util.h" 18 | #include "xrtl/testing/gtest.h" 19 | 20 | extern "C" int main(int argc, char** argv) { 21 | xrtl::flags::SetUsageMessage(std::string("\n$ ") + argv[0]); 22 | xrtl::flags::ParseCommandLineFlags(&argc, &argv, true); 23 | 24 | ::testing::InitGoogleTest(&argc, argv); 25 | 26 | xrtl::testing::FileUtil::LoadFileManifest(std::string(argv[0])); 27 | 28 | int exit_code = RUN_ALL_TESTS(); 29 | 30 | xrtl::flags::ShutDownCommandLineFlags(); 31 | 32 | return exit_code; 33 | } 34 | -------------------------------------------------------------------------------- /xrtl/gfx/spirv/shader_compiler_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/spirv/shader_compiler.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | namespace spirv { 20 | 21 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 22 | ShaderCompiler shader_compiler(ShaderCompiler::SourceLanguage::kGlsl, 23 | ShaderCompiler::ShaderStage::kVertex); 24 | shader_compiler.AddSource(absl::string_view{data, size}); 25 | std::vector spirv_data; 26 | shader_compiler.Compile(&spirv_data); 27 | return 0; 28 | } 29 | 30 | } // namespace spirv 31 | } // namespace gfx 32 | } // namespace xrtl 33 | -------------------------------------------------------------------------------- /xrtl/base/uri_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/uri.h" 16 | 17 | namespace xrtl { 18 | namespace uri { 19 | 20 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 21 | absl::string_view input_uri(reinterpret_cast(data), size); 22 | IsSchemeless(input_uri); 23 | GetScheme(input_uri); 24 | GetHost(input_uri); 25 | GetOrigin(input_uri); 26 | GetPath(input_uri); 27 | IsPathAbsolute(input_uri); 28 | GetBasePath(input_uri); 29 | JoinParts(input_uri, "a"); 30 | JoinParts("a", input_uri); 31 | JoinParts(input_uri, input_uri); 32 | return 0; 33 | } 34 | 35 | } // namespace uri 36 | } // namespace xrtl 37 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_resource_set_layout.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_RESOURCE_SET_LAYOUT_H_ 16 | #define XRTL_GFX_ES3_ES3_RESOURCE_SET_LAYOUT_H_ 17 | 18 | #include "xrtl/gfx/es3/es3_common.h" 19 | #include "xrtl/gfx/resource_set_layout.h" 20 | 21 | namespace xrtl { 22 | namespace gfx { 23 | namespace es3 { 24 | 25 | class ES3ResourceSetLayout : public ResourceSetLayout { 26 | public: 27 | explicit ES3ResourceSetLayout(absl::Span binding_slots) 28 | : ResourceSetLayout(binding_slots) {} 29 | }; 30 | 31 | } // namespace es3 32 | } // namespace gfx 33 | } // namespace xrtl 34 | 35 | #endif // XRTL_GFX_ES3_ES3_RESOURCE_SET_LAYOUT_H_ 36 | -------------------------------------------------------------------------------- /xrtl/examples/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Examples exercising large pieces of functionality. 3 | # Demos that target individual features are available side-by-side with their 4 | # code (such as window_demo). 5 | 6 | package(default_visibility = ["//xrtl:internal"]) 7 | 8 | licenses(["notice"]) # Apache 2.0 9 | 10 | cc_binary( 11 | name = "triangle_example", 12 | srcs = ["triangle_example.cc"], 13 | deps = [ 14 | "//xrtl/base:logging", 15 | "//xrtl/base:system_clock", 16 | "//xrtl/base/threading:event", 17 | "//xrtl/base/threading:thread", 18 | "//xrtl/gfx:context", 19 | "//xrtl/gfx:context_factory", 20 | "//xrtl/gfx/spirv:shader_compiler", 21 | "//xrtl/testing:demo_main", 22 | "//xrtl/ui:window", 23 | ], 24 | ) 25 | 26 | cc_binary( 27 | name = "triangle_full_example", 28 | srcs = ["triangle_full_example.cc"], 29 | deps = [ 30 | "//xrtl/base:logging", 31 | "//xrtl/base:system_clock", 32 | "//xrtl/base/threading:event", 33 | "//xrtl/base/threading:thread", 34 | "//xrtl/gfx:context", 35 | "//xrtl/gfx:context_factory", 36 | "//xrtl/gfx/spirv:shader_compiler", 37 | "//xrtl/testing:demo_main", 38 | "//xrtl/ui:window", 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /xrtl/gfx/shader_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_SHADER_MODULE_H_ 16 | #define XRTL_GFX_SHADER_MODULE_H_ 17 | 18 | #include "xrtl/gfx/managed_object.h" 19 | 20 | namespace xrtl { 21 | namespace gfx { 22 | 23 | // A module of shader code. 24 | // Each module may contain multiple entry points that can be used by pipelines. 25 | class ShaderModule : public ManagedObject { 26 | public: 27 | // Describes the format of shader module data. 28 | enum class DataFormat { 29 | // Standard SPIR-V. 30 | kSpirV, 31 | }; 32 | 33 | protected: 34 | ShaderModule() = default; 35 | }; 36 | 37 | } // namespace gfx 38 | } // namespace xrtl 39 | 40 | #endif // XRTL_GFX_SHADER_MODULE_H_ 41 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/data_differ_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/diffing/data_differ.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace testing { 21 | namespace diffing { 22 | namespace { 23 | 24 | // Tests a variety of normal data types. 25 | TEST(DataDifferTest, SimpleComparisons) { 26 | EXPECT_TRUE(DataDiffer::CompareBuffers({}, {}, {})); 27 | EXPECT_TRUE(DataDiffer::CompareBuffers({1}, {1}, {})); 28 | EXPECT_FALSE(DataDiffer::CompareBuffers({1}, {}, {})); 29 | EXPECT_FALSE(DataDiffer::CompareBuffers({1}, {2}, {})); 30 | } 31 | 32 | } // namespace 33 | } // namespace diffing 34 | } // namespace testing 35 | } // namespace xrtl 36 | -------------------------------------------------------------------------------- /third_party/glad/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Generated OpenGL loader files from the GLAD web service. 3 | # https://github.com/Dav1dde/glad 4 | # http://glad.dav1d.de/ 5 | 6 | package(default_visibility = ["//visibility:public"]) 7 | 8 | licenses(["notice"]) # MIT 9 | 10 | exports_files(["LICENSE"]) 11 | 12 | COMMON_COPTS = select({ 13 | "@//xrtl/tools/target_platform:windows": [ 14 | "/TP", # Compile as C++. 15 | ], 16 | "//conditions:default": [ 17 | "-x", 18 | "c++", 19 | ], 20 | }) 21 | 22 | cc_library( 23 | name = "glad", 24 | srcs = ["src/glad.c"], 25 | hdrs = ["include/glad/glad.h"], 26 | copts = COMMON_COPTS, 27 | includes = ["include"], 28 | deps = [ 29 | "//third_party/GLES_khronos_headers:GLES3", 30 | ], 31 | ) 32 | 33 | cc_library( 34 | name = "glad_egl", 35 | srcs = ["src/glad_egl.c"], 36 | hdrs = ["include/glad/glad_egl.h"], 37 | copts = COMMON_COPTS, 38 | includes = ["include"], 39 | deps = [ 40 | ":glad", 41 | "//third_party/GLES_khronos_headers:EGL", 42 | ], 43 | ) 44 | 45 | cc_library( 46 | name = "glad_wgl", 47 | srcs = ["src/glad_wgl.c"], 48 | hdrs = ["include/glad/glad_wgl.h"], 49 | includes = ["include"], 50 | deps = [ 51 | ":glad", 52 | ], 53 | ) 54 | -------------------------------------------------------------------------------- /xrtl/base/env.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/env.h" 16 | 17 | namespace xrtl { 18 | 19 | std::string Env::temp_path_; 20 | 21 | std::string Env::GetValueOrDefault(absl::string_view key, 22 | absl::string_view default_value) { 23 | absl::optional value_opt = GetValue(key); 24 | return value_opt ? value_opt.value() : std::string(default_value); 25 | } 26 | 27 | std::string Env::temp_path() { 28 | if (temp_path_.empty()) { 29 | temp_path_ = Env::QueryTempPath(); 30 | } 31 | return temp_path_; 32 | } 33 | 34 | void Env::set_temp_path(std::string temp_path) { 35 | temp_path_ = std::move(temp_path); 36 | } 37 | 38 | } // namespace xrtl 39 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_image_view.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_IMAGE_VIEW_H_ 16 | #define XRTL_GFX_ES3_ES3_IMAGE_VIEW_H_ 17 | 18 | #include 19 | 20 | #include "xrtl/gfx/es3/es3_common.h" 21 | #include "xrtl/gfx/image_view.h" 22 | 23 | namespace xrtl { 24 | namespace gfx { 25 | namespace es3 { 26 | 27 | class ES3ImageView : public ImageView { 28 | public: 29 | ES3ImageView(ref_ptr image, Image::Type type, PixelFormat format, 30 | Image::LayerRange layer_range) 31 | : ImageView(std::move(image), type, format, layer_range) {} 32 | }; 33 | 34 | } // namespace es3 35 | } // namespace gfx 36 | } // namespace xrtl 37 | 38 | #endif // XRTL_GFX_ES3_ES3_IMAGE_VIEW_H_ 39 | -------------------------------------------------------------------------------- /xrtl/gfx/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Graphics testing utilties. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "portable_cc_test") 9 | 10 | cc_library( 11 | name = "graphics_test", 12 | testonly = 1, 13 | srcs = ["graphics_test.cc"], 14 | hdrs = ["graphics_test.h"], 15 | deps = [ 16 | "//xrtl/base:tracing", 17 | "//xrtl/gfx:context", 18 | "//xrtl/gfx:context_factory", 19 | "//xrtl/testing:gtest", 20 | "//xrtl/testing/diffing:diff_provider", 21 | "@com_google_absl//absl/strings", 22 | ], 23 | ) 24 | 25 | portable_cc_test( 26 | name = "graphics_test_test", 27 | size = "small", 28 | srcs = ["graphics_test_test.cc"], 29 | data = [ 30 | "//xrtl/gfx/testing/testdata/goldens:graphics_test_data", 31 | ], 32 | deps = [ 33 | ":graphics_test", 34 | "//xrtl/testing:gtest_main", 35 | ], 36 | ) 37 | 38 | cc_library( 39 | name = "partial_command_encoder", 40 | testonly = 1, 41 | hdrs = ["partial_command_encoder.h"], 42 | deps = [ 43 | "//xrtl/gfx:command_encoder", 44 | ], 45 | ) 46 | 47 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 48 | 49 | portable_test_suite() 50 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_framebuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_FRAMEBUFFER_H_ 16 | #define XRTL_GFX_ES3_ES3_FRAMEBUFFER_H_ 17 | 18 | #include 19 | 20 | #include "xrtl/gfx/es3/es3_common.h" 21 | #include "xrtl/gfx/framebuffer.h" 22 | 23 | namespace xrtl { 24 | namespace gfx { 25 | namespace es3 { 26 | 27 | class ES3Framebuffer : public Framebuffer { 28 | public: 29 | ES3Framebuffer(ref_ptr render_pass, Size3D size, 30 | absl::Span> attachments) 31 | : Framebuffer(std::move(render_pass), size, attachments) {} 32 | }; 33 | 34 | } // namespace es3 35 | } // namespace gfx 36 | } // namespace xrtl 37 | 38 | #endif // XRTL_GFX_ES3_ES3_FRAMEBUFFER_H_ 39 | -------------------------------------------------------------------------------- /third_party/GLES_khronos_headers/include/GLES/glplatform.h: -------------------------------------------------------------------------------- 1 | #ifndef __glplatform_h_ 2 | #define __glplatform_h_ 3 | 4 | /* 5 | ** Copyright (c) 2017 The Khronos Group Inc. 6 | ** 7 | ** Licensed under the Apache License, Version 2.0 (the "License"); 8 | ** you may not use this file except in compliance with the License. 9 | ** You may obtain a copy of the License at 10 | ** 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** 13 | ** Unless required by applicable law or agreed to in writing, software 14 | ** distributed under the License is distributed on an "AS IS" BASIS, 15 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | ** See the License for the specific language governing permissions and 17 | ** limitations under the License. 18 | */ 19 | 20 | /* Platform-specific types and definitions for OpenGL ES 1.X gl.h 21 | * 22 | * Adopters may modify khrplatform.h and this file to suit their platform. 23 | * Please contribute modifications back to Khronos as pull requests on the 24 | * public github repository: 25 | * https://github.com/KhronosGroup/OpenGL-Registry 26 | */ 27 | 28 | #include 29 | 30 | #ifndef GL_API 31 | #define GL_API KHRONOS_APICALL 32 | #endif 33 | 34 | #ifndef GL_APIENTRY 35 | #define GL_APIENTRY KHRONOS_APIENTRY 36 | #endif 37 | 38 | #endif /* __glplatform_h_ */ 39 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_device.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_DEVICE_H_ 16 | #define XRTL_GFX_ES3_ES3_DEVICE_H_ 17 | 18 | #include "xrtl/gfx/device.h" 19 | 20 | namespace xrtl { 21 | namespace gfx { 22 | namespace es3 { 23 | 24 | class ES3Device : public Device { 25 | public: 26 | ES3Device() = default; 27 | 28 | // Adopts the device parameters of the currently bound GL platform context. 29 | bool AdoptCurrentContext(); 30 | 31 | private: 32 | // Queries available pixel formats and populates the given struct. 33 | void QuerySupportedPixelFormats(Features::PixelFormats* pixel_formats); 34 | }; 35 | 36 | } // namespace es3 37 | } // namespace gfx 38 | } // namespace xrtl 39 | 40 | #endif // XRTL_GFX_ES3_ES3_DEVICE_H_ 41 | -------------------------------------------------------------------------------- /third_party/GLES_khronos_headers/include/GLES2/gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* 5 | ** Copyright (c) 2017 The Khronos Group Inc. 6 | ** 7 | ** Licensed under the Apache License, Version 2.0 (the "License"); 8 | ** you may not use this file except in compliance with the License. 9 | ** You may obtain a copy of the License at 10 | ** 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** 13 | ** Unless required by applicable law or agreed to in writing, software 14 | ** distributed under the License is distributed on an "AS IS" BASIS, 15 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | ** See the License for the specific language governing permissions and 17 | ** limitations under the License. 18 | */ 19 | 20 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 21 | * 22 | * Adopters may modify khrplatform.h and this file to suit their platform. 23 | * Please contribute modifications back to Khronos as pull requests on the 24 | * public github repository: 25 | * https://github.com/KhronosGroup/OpenGL-Registry 26 | */ 27 | 28 | #include 29 | 30 | #ifndef GL_APICALL 31 | #define GL_APICALL KHRONOS_APICALL 32 | #endif 33 | 34 | #ifndef GL_APIENTRY 35 | #define GL_APIENTRY KHRONOS_APIENTRY 36 | #endif 37 | 38 | #endif /* __gl2platform_h_ */ 39 | -------------------------------------------------------------------------------- /third_party/GLES_khronos_headers/include/GLES3/gl3platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl3platform_h_ 2 | #define __gl3platform_h_ 3 | 4 | /* 5 | ** Copyright (c) 2017 The Khronos Group Inc. 6 | ** 7 | ** Licensed under the Apache License, Version 2.0 (the "License"); 8 | ** you may not use this file except in compliance with the License. 9 | ** You may obtain a copy of the License at 10 | ** 11 | ** http://www.apache.org/licenses/LICENSE-2.0 12 | ** 13 | ** Unless required by applicable law or agreed to in writing, software 14 | ** distributed under the License is distributed on an "AS IS" BASIS, 15 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | ** See the License for the specific language governing permissions and 17 | ** limitations under the License. 18 | */ 19 | 20 | /* Platform-specific types and definitions for OpenGL ES 3.X gl3.h 21 | * 22 | * Adopters may modify khrplatform.h and this file to suit their platform. 23 | * Please contribute modifications back to Khronos as pull requests on the 24 | * public github repository: 25 | * https://github.com/KhronosGroup/OpenGL-Registry 26 | */ 27 | 28 | #include 29 | 30 | #ifndef GL_APICALL 31 | #define GL_APICALL KHRONOS_APICALL 32 | #endif 33 | 34 | #ifndef GL_APIENTRY 35 | #define GL_APIENTRY KHRONOS_APIENTRY 36 | #endif 37 | 38 | #endif /* __gl3platform_h_ */ 39 | -------------------------------------------------------------------------------- /xrtl/gfx/util/memory_command_decoder.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_UTIL_MEMORY_COMMAND_DECODER_H_ 16 | #define XRTL_GFX_UTIL_MEMORY_COMMAND_DECODER_H_ 17 | 18 | #include "xrtl/gfx/command_buffer.h" 19 | #include "xrtl/gfx/command_encoder.h" 20 | #include "xrtl/gfx/util/memory_command_buffer_reader.h" 21 | #include "xrtl/gfx/util/memory_commands.h" 22 | 23 | namespace xrtl { 24 | namespace gfx { 25 | namespace util { 26 | 27 | class MemoryCommandDecoder { 28 | public: 29 | static bool Decode(MemoryCommandBufferReader* reader, 30 | CommandBuffer* target_command_buffer); 31 | }; 32 | 33 | } // namespace util 34 | } // namespace gfx 35 | } // namespace xrtl 36 | 37 | #endif // XRTL_GFX_UTIL_MEMORY_COMMAND_DECODER_H_ 38 | -------------------------------------------------------------------------------- /xrtl/base/proto_util_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/proto_util.h" 16 | 17 | #include "xrtl/base/protobuf.h" 18 | #include "xrtl/base/testdata/proto_util_test.pb.h" 19 | #include "xrtl/testing/gtest.h" 20 | 21 | namespace xrtl { 22 | namespace { 23 | 24 | TEST(ProtoUtilTest, TextPb) { 25 | const char* kTextPb = "int32_value: 5\nstring_value: \"foo\"\n"; 26 | 27 | // Deserialize from string. 28 | xrtl::testdata::SimpleMessage message; 29 | EXPECT_TRUE(xrtl::protobuf::TextFormat::ParseFromString(kTextPb, &message)); 30 | EXPECT_EQ(5, message.int32_value()); 31 | EXPECT_EQ("foo", message.string_value()); 32 | 33 | // Serialize to string. 34 | EXPECT_EQ(kTextPb, message.DebugString()); 35 | } 36 | 37 | } // namespace 38 | } // namespace xrtl 39 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_pipeline_layout.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_PIPELINE_LAYOUT_H_ 16 | #define XRTL_GFX_ES3_ES3_PIPELINE_LAYOUT_H_ 17 | 18 | #include "xrtl/gfx/es3/es3_common.h" 19 | #include "xrtl/gfx/pipeline_layout.h" 20 | 21 | namespace xrtl { 22 | namespace gfx { 23 | namespace es3 { 24 | 25 | class ES3PipelineLayout : public PipelineLayout { 26 | public: 27 | ES3PipelineLayout( 28 | absl::Span> resource_set_layouts, 29 | absl::Span push_constant_ranges) 30 | : PipelineLayout(resource_set_layouts, push_constant_ranges) {} 31 | }; 32 | 33 | } // namespace es3 34 | } // namespace gfx 35 | } // namespace xrtl 36 | 37 | #endif // XRTL_GFX_ES3_ES3_PIPELINE_LAYOUT_H_ 38 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_resource_set.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_RESOURCE_SET_H_ 16 | #define XRTL_GFX_ES3_ES3_RESOURCE_SET_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "xrtl/gfx/es3/es3_common.h" 22 | #include "xrtl/gfx/resource_set.h" 23 | 24 | namespace xrtl { 25 | namespace gfx { 26 | namespace es3 { 27 | 28 | class ES3ResourceSet : public ResourceSet { 29 | public: 30 | explicit ES3ResourceSet(ref_ptr resource_set_layout, 31 | absl::Span binding_values) 32 | : ResourceSet(std::move(resource_set_layout), binding_values) {} 33 | }; 34 | 35 | } // namespace es3 36 | } // namespace gfx 37 | } // namespace xrtl 38 | 39 | #endif // XRTL_GFX_ES3_ES3_RESOURCE_SET_H_ 40 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_render_pass.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_RENDER_PASS_H_ 16 | #define XRTL_GFX_ES3_ES3_RENDER_PASS_H_ 17 | 18 | #include "xrtl/gfx/es3/es3_common.h" 19 | #include "xrtl/gfx/render_pass.h" 20 | 21 | namespace xrtl { 22 | namespace gfx { 23 | namespace es3 { 24 | 25 | class ES3RenderPass : public RenderPass { 26 | public: 27 | ES3RenderPass(absl::Span attachments, 28 | absl::Span subpasses, 29 | absl::Span subpass_dependencies) 30 | : RenderPass(attachments, subpasses, subpass_dependencies) {} 31 | }; 32 | 33 | } // namespace es3 34 | } // namespace gfx 35 | } // namespace xrtl 36 | 37 | #endif // XRTL_GFX_ES3_ES3_RENDER_PASS_H_ 38 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/gflags"] 2 | path = third_party/gflags 3 | url = https://github.com/gflags/gflags.git 4 | [submodule "third_party/gtest_xrtl/gtest"] 5 | path = third_party/gtest_xrtl/gtest 6 | url = https://github.com/google/googletest.git 7 | [submodule "third_party/google_styleguide"] 8 | path = third_party/google_styleguide 9 | url = https://github.com/google/styleguide.git 10 | [submodule "third_party/spirv_headers"] 11 | path = third_party/spirv_headers 12 | url = https://github.com/KhronosGroup/SPIRV-Headers.git 13 | [submodule "third_party/spirv_cross"] 14 | path = third_party/spirv_cross 15 | url = https://github.com/KhronosGroup/SPIRV-Cross.git 16 | [submodule "third_party/spirv_tools"] 17 | path = third_party/spirv_tools 18 | url = https://github.com/KhronosGroup/SPIRV-Tools.git 19 | [submodule "third_party/glslang"] 20 | path = third_party/glslang 21 | url = https://github.com/KhronosGroup/glslang.git 22 | [submodule "third_party/stblib"] 23 | path = third_party/stblib 24 | url = https://github.com/nothings/stb.git 25 | [submodule "third_party/swiftshader"] 26 | path = third_party/swiftshader 27 | url = https://github.com/google/swiftshader.git 28 | [submodule "third_party/glm"] 29 | path = third_party/glm 30 | url = https://github.com/g-truc/glm.git 31 | [submodule "third_party/abseil-cpp"] 32 | path = third_party/abseil-cpp 33 | url = https://github.com/abseil/abseil-cpp.git 34 | -------------------------------------------------------------------------------- /xrtl/port/common/testing/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Common port variants of //xrtl/testing/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | cc_library( 9 | name = "posix_demo_main", 10 | srcs = ["posix_demo_main.cc"], 11 | linkopts = select({ 12 | # TODO(benvanik): find a way to remove this requirement. 13 | "//xrtl/tools/target_platform:ios": [ 14 | "-framework CoreFoundation", 15 | ], 16 | "//xrtl/tools/target_platform:macos": [ 17 | "-framework CoreFoundation", 18 | ], 19 | "//conditions:default": [], 20 | }), 21 | deps = [ 22 | "//xrtl/testing:demo_main_hdrs", 23 | ], 24 | ) 25 | 26 | cc_library( 27 | name = "posix_test_main", 28 | testonly = 1, 29 | srcs = ["posix_test_main.cc"], 30 | linkopts = select({ 31 | # TODO(benvanik): find a way to remove this requirement. 32 | "//xrtl/tools/target_platform:ios": [ 33 | "-framework CoreFoundation", 34 | ], 35 | "//xrtl/tools/target_platform:macos": [ 36 | "-framework CoreFoundation", 37 | ], 38 | "//conditions:default": [], 39 | }), 40 | deps = [ 41 | "//xrtl/base:flags", 42 | "//xrtl/base:logging", 43 | "//xrtl/testing:file_util", 44 | "//xrtl/testing:gtest", 45 | ], 46 | ) 47 | -------------------------------------------------------------------------------- /xrtl/port/common/base/posix_env.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "xrtl/base/env.h" 18 | #include "xrtl/base/logging.h" 19 | 20 | namespace xrtl { 21 | 22 | absl::optional Env::GetValue(absl::string_view key) { 23 | char key_buffer[255 + 1] = {0}; 24 | if (key.size() >= ABSL_ARRAYSIZE(key_buffer)) { 25 | DCHECK(false) << "Attempting to access a really long env var: " << key; 26 | return absl::nullopt; 27 | } 28 | std::memcpy(key_buffer, key.data(), key.size()); 29 | key_buffer[key.size()] = 0; 30 | char* value = std::getenv(key_buffer); 31 | if (!value) { 32 | return absl::nullopt; 33 | } 34 | return std::string(value); 35 | } 36 | 37 | std::string Env::QueryTempPath() { 38 | return Env::GetValueOrDefault("TMPDIR", "/tmp"); 39 | } 40 | 41 | } // namespace xrtl 42 | -------------------------------------------------------------------------------- /xrtl/gfx/spirv/spirv_optimizer_fuzzer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/spirv/spirv_optimizer.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | namespace spirv { 20 | 21 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 22 | SpirVOptimizer::Options options; 23 | options.strip_debug_info = true; 24 | options.freeze_specialization_values = true; 25 | options.inline_functions = true; 26 | options.remap_ids = true; 27 | SpirVOptimizer spirv_optimizer(options); 28 | std::vector source_spirv; 29 | source_spirv.resize(size / 4); 30 | std::memcpy(source_spirv.data(), data, (size / 4) * 4); 31 | std::vector target_spirv; 32 | spirv_optimizer.Optimize(source_spirv, &target_spirv); 33 | return 0; 34 | } 35 | 36 | } // namespace spirv 37 | } // namespace gfx 38 | } // namespace xrtl 39 | -------------------------------------------------------------------------------- /third_party/GLES_khronos_headers/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Defines targets for the standard OpenGL ES and EGL headers published by The 3 | # Khronos Group Inc. 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | licenses(["permissive"]) # Custom "The Khronos Group Inc." License. 8 | 9 | exports_files(["LICENSE"]) 10 | 11 | cc_library( 12 | name = "GLES", 13 | hdrs = [ 14 | "include/GLES/gl.h", 15 | "include/GLES/glext.h", 16 | "include/GLES/glplatform.h", 17 | "include/KHR/khrplatform.h", 18 | ], 19 | includes = ["include"], 20 | ) 21 | 22 | cc_library( 23 | name = "GLES2", 24 | hdrs = [ 25 | "include/GLES2/gl2.h", 26 | "include/GLES2/gl2ext.h", 27 | "include/GLES2/gl2platform.h", 28 | "include/KHR/khrplatform.h", 29 | ], 30 | includes = ["include"], 31 | ) 32 | 33 | cc_library( 34 | name = "GLES3", 35 | hdrs = [ 36 | "include/GLES2/gl2ext.h", 37 | "include/GLES3/gl3.h", 38 | "include/GLES3/gl31.h", 39 | "include/GLES3/gl32.h", 40 | "include/GLES3/gl3platform.h", 41 | "include/KHR/khrplatform.h", 42 | ], 43 | includes = ["include"], 44 | ) 45 | 46 | cc_library( 47 | name = "EGL", 48 | hdrs = [ 49 | "include/EGL/egl.h", 50 | "include/EGL/eglext.h", 51 | "include/EGL/eglplatform.h", 52 | "include/KHR/khrplatform.h", 53 | ], 54 | includes = ["include"], 55 | ) 56 | -------------------------------------------------------------------------------- /xrtl/gfx/command_fence.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_COMMAND_FENCE_H_ 16 | #define XRTL_GFX_COMMAND_FENCE_H_ 17 | 18 | #include "xrtl/gfx/managed_object.h" 19 | 20 | namespace xrtl { 21 | namespace gfx { 22 | 23 | // A fence that orders commands within a command buffer. 24 | // These may be signaled once per object. Attempting to signal an already- 25 | // signaled fence may produce undefined results. 26 | // 27 | // These are device-side only and are only used to order the way commands 28 | // are processed within command buffers. They cannot be used for synchronization 29 | // with the CPU (use Context::WaitUntilQueuesIdle for that). 30 | class CommandFence : public ManagedObject { 31 | public: 32 | protected: 33 | CommandFence() = default; 34 | }; 35 | 36 | } // namespace gfx 37 | } // namespace xrtl 38 | 39 | #endif // XRTL_GFX_COMMAND_FENCE_H_ 40 | -------------------------------------------------------------------------------- /xrtl/testing/demo_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/demo_main.h" 16 | 17 | #include 18 | 19 | #include "xrtl/base/debugging.h" 20 | #include "xrtl/base/flags.h" 21 | #include "xrtl/base/logging.h" 22 | 23 | namespace xrtl { 24 | namespace testing { 25 | 26 | int DemoMain(int argc, char** argv) { 27 | // Attach a console so we can write output to stdout. If the user hasn't 28 | // redirected output themselves it'll pop up a window. 29 | xrtl::debugging::AttachConsole(); 30 | 31 | // Setup flags. 32 | xrtl::flags::SetUsageMessage(std::string("\n$ ") + argv[0]); 33 | xrtl::flags::ParseCommandLineFlags(&argc, &argv, true); 34 | 35 | int exit_code = GetEntryPoint()(argc, argv); 36 | 37 | xrtl::flags::ShutDownCommandLineFlags(); 38 | 39 | return exit_code; 40 | } 41 | 42 | } // namespace testing 43 | } // namespace xrtl 44 | -------------------------------------------------------------------------------- /xrtl/base/cli_main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_CLI_MAIN_H_ 16 | #define XRTL_BASE_CLI_MAIN_H_ 17 | 18 | namespace xrtl { 19 | 20 | using CliEntryPointFn = int (*)(int argc, char** argv); 21 | 22 | // Returns a function pointer to the entry point of the application. 23 | // CliMain will call this once the environment has been setup. 24 | // 25 | // Usage: 26 | // my_cli.cc: 27 | // int MyEntry(int argc, char** argv) { return 55; } 28 | // DECLARE_CLI_ENTRY_POINT(MyEntry); 29 | CliEntryPointFn GetCliEntryPoint(); 30 | 31 | #define DECLARE_CLI_ENTRY_POINT(fn) \ 32 | xrtl::CliEntryPointFn xrtl::GetCliEntryPoint() { return fn; } 33 | 34 | // Application entry point for CLI apps. 35 | // This follows the standard C main() function convention. 36 | int CliMain(int argc, char** argv); 37 | 38 | } // namespace xrtl 39 | 40 | #endif // XRTL_BASE_CLI_MAIN_H_ 41 | -------------------------------------------------------------------------------- /xrtl/port/common/base/protobuf.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_COMMON_BASE_PROTOBUF_H_ 16 | #define XRTL_PORT_COMMON_BASE_PROTOBUF_H_ 17 | 18 | #include "google/protobuf/arena.h" 19 | #include "google/protobuf/compiler/importer.h" 20 | #include "google/protobuf/descriptor.h" 21 | #include "google/protobuf/dynamic_message.h" 22 | #include "google/protobuf/io/coded_stream.h" 23 | #include "google/protobuf/io/zero_copy_stream.h" 24 | #include "google/protobuf/io/zero_copy_stream_impl_lite.h" 25 | #include "google/protobuf/map.h" 26 | #include "google/protobuf/repeated_field.h" 27 | #include "google/protobuf/text_format.h" 28 | #include "google/protobuf/util/json_util.h" 29 | #include "google/protobuf/util/type_resolver_util.h" 30 | 31 | namespace xrtl { 32 | namespace protobuf = ::google::protobuf; 33 | } // namespace xrtl 34 | 35 | #endif // XRTL_PORT_COMMON_BASE_PROTOBUF_H_ 36 | -------------------------------------------------------------------------------- /third_party/spirv_cross.BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Library for performing reflection on SPIR-V and disassembling SPIR-V 3 | # bytecode. 4 | 5 | package(default_visibility = ["//visibility:private"]) 6 | 7 | licenses(["notice"]) # Apache 2.0 8 | 9 | exports_files(["LICENSE"]) 10 | 11 | COMMON_COPTS = [ 12 | "-DDISABLE_GOOGLE_STRING", 13 | ] + select({ 14 | "@//xrtl/tools/target_platform:windows": [], 15 | "//conditions:default": [ 16 | "-fexceptions", 17 | ], 18 | }) 19 | 20 | cc_library( 21 | name = "spirv_cross_lib", 22 | srcs = [ 23 | "GLSL.std.450.h", 24 | "spirv_cfg.cpp", 25 | "spirv_cpp.cpp", 26 | "spirv_cross.cpp", 27 | "spirv_cross_util.cpp", 28 | "spirv_glsl.cpp", 29 | "spirv_hlsl.cpp", 30 | "spirv_msl.cpp", 31 | "spirv_reflect.cpp", 32 | ], 33 | hdrs = [ 34 | "spirv.hpp", 35 | "spirv_cfg.hpp", 36 | "spirv_common.hpp", 37 | "spirv_cpp.hpp", 38 | "spirv_cross.hpp", 39 | "spirv_cross_util.hpp", 40 | "spirv_glsl.hpp", 41 | "spirv_hlsl.hpp", 42 | "spirv_msl.hpp", 43 | "spirv_reflect.hpp", 44 | ], 45 | copts = COMMON_COPTS, 46 | includes = ["."], 47 | visibility = ["//visibility:public"], 48 | ) 49 | 50 | cc_binary( 51 | name = "spirv_cross", 52 | srcs = ["main.cpp"], 53 | copts = COMMON_COPTS, 54 | visibility = ["//visibility:public"], 55 | deps = [":spirv_cross_lib"], 56 | ) 57 | -------------------------------------------------------------------------------- /xrtl/port/windows/ui/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Win32 implementations of the UI types. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:windows"]) 11 | 12 | cc_library( 13 | name = "win32_control", 14 | srcs = ["win32_control.cc"], 15 | hdrs = ["win32_control.h"], 16 | linkopts = [ 17 | "-DEFAULTLIB:wtsapi32.lib", 18 | ], 19 | deps = [ 20 | "//xrtl/base:logging", 21 | "//xrtl/base/threading:event", 22 | "//xrtl/port/common/ui:timer_display_link", 23 | "//xrtl/port/windows/base:windows_headers", 24 | "//xrtl/ui:control_hdrs", 25 | "@com_google_absl//absl/base", 26 | ], 27 | ) 28 | 29 | cc_library( 30 | name = "win32_system_theme", 31 | srcs = ["win32_system_theme.cc"], 32 | deps = [ 33 | "//xrtl/port/windows/base:windows_headers", 34 | "//xrtl/ui:system_theme_hdrs", 35 | ], 36 | ) 37 | 38 | cc_library( 39 | name = "win32_window", 40 | srcs = ["win32_window.cc"], 41 | hdrs = ["win32_window.h"], 42 | deps = [ 43 | ":win32_control", 44 | "//xrtl/base:logging", 45 | "//xrtl/port/windows/base:windows_headers", 46 | "//xrtl/ui:window_hdrs", 47 | ], 48 | ) 49 | 50 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 51 | 52 | portable_test_suite() 53 | -------------------------------------------------------------------------------- /xrtl/base/threading/wait_handle.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_THREADING_WAIT_HANDLE_H_ 16 | #define XRTL_BASE_THREADING_WAIT_HANDLE_H_ 17 | 18 | #include "xrtl/base/ref_ptr.h" 19 | 20 | namespace xrtl { 21 | 22 | // Base type for waitable threading objects. 23 | // Waitable objects can be used with the various Thread::Wait routines to delay 24 | // execution until a condition is set. 25 | class WaitHandle : public RefObject { 26 | public: 27 | WaitHandle(const WaitHandle&) = delete; 28 | WaitHandle& operator=(WaitHandle const&) = delete; 29 | virtual ~WaitHandle() = default; 30 | 31 | // Returns the native platform handle of the wait object. 32 | // This value is platform specific. 33 | virtual uintptr_t native_handle() = 0; 34 | 35 | protected: 36 | WaitHandle() = default; 37 | }; 38 | 39 | } // namespace xrtl 40 | 41 | #endif // XRTL_BASE_THREADING_WAIT_HANDLE_H_ 42 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Windows port variants of //xrtl/base/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "package_platforms") 9 | 10 | package_platforms(default_platforms = ["//xrtl/tools/target_platform:windows"]) 11 | 12 | cc_library( 13 | name = "win32_debugging", 14 | srcs = ["win32_debugging.cc"], 15 | deps = [ 16 | ":windows_headers", 17 | "//xrtl/base:debugging_hdrs", 18 | "//xrtl/base:logging", 19 | ], 20 | ) 21 | 22 | cc_library( 23 | name = "win32_env", 24 | srcs = ["win32_env.cc"], 25 | deps = [ 26 | ":windows_headers", 27 | "//xrtl/base:env_hdrs", 28 | "//xrtl/base:logging", 29 | ], 30 | ) 31 | 32 | cc_library( 33 | name = "win32_system_clock", 34 | srcs = ["win32_system_clock.cc"], 35 | deps = [ 36 | ":windows_headers", 37 | "//xrtl/base:macros", 38 | "//xrtl/base:system_clock_hdrs", 39 | ], 40 | ) 41 | 42 | cc_library( 43 | name = "windows_headers", 44 | hdrs = ["windows.h"], 45 | copts = [ 46 | "/UNOGDI", 47 | "/wd9025", 48 | ], 49 | defines = [ 50 | "UNICODE=1", 51 | ], 52 | visibility = ["//xrtl/port:windows_only"], 53 | deps = [ 54 | "//xrtl/tools/target_platform", 55 | ], 56 | ) 57 | 58 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 59 | 60 | portable_test_suite() 61 | -------------------------------------------------------------------------------- /xrtl/port/apple/base/darwin_debugging.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include "xrtl/base/debugging.h" 19 | 20 | namespace xrtl { 21 | namespace debugging { 22 | 23 | bool is_console_attached() { 24 | // TODO(benvanik): console detection. 25 | return false; 26 | } 27 | 28 | bool AttachConsole() { 29 | // TODO(benvanik): console detection. 30 | return false; 31 | } 32 | 33 | bool is_debugger_attached() { 34 | // This works on both iOS and OSX. 35 | // https://developer.apple.com/library/mac/qa/qa1361/_index.html 36 | kinfo_proc info = {{{{0}}}}; 37 | info.kp_proc.p_flag = 0; 38 | int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; 39 | size_t size = sizeof(info); 40 | sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0); 41 | return (info.kp_proc.p_flag & P_TRACED) != 0; 42 | } 43 | 44 | } // namespace debugging 45 | } // namespace xrtl 46 | -------------------------------------------------------------------------------- /xrtl/testing/demo_main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_TESTING_DEMO_MAIN_H_ 16 | #define XRTL_TESTING_DEMO_MAIN_H_ 17 | 18 | namespace xrtl { 19 | namespace testing { 20 | 21 | using EntryPointFn = int (*)(int argc, char** argv); 22 | 23 | // Returns a function pointer to the entry point of the application. 24 | // DemoMain will call this once the environment has been setup. 25 | // 26 | // Usage: 27 | // my_demo.cc: 28 | // int MyEntry(int argc, char** argv) { return 55; } 29 | // DECLARE_ENTRY_POINT(MyEntry); 30 | EntryPointFn GetEntryPoint(); 31 | 32 | #define DECLARE_ENTRY_POINT(fn) \ 33 | xrtl::testing::EntryPointFn xrtl::testing::GetEntryPoint() { return fn; } 34 | 35 | // Application entry point for demos. 36 | // This follows the standard C main() function convention. 37 | int DemoMain(int argc, char** argv); 38 | 39 | } // namespace testing 40 | } // namespace xrtl 41 | 42 | #endif // XRTL_TESTING_DEMO_MAIN_H_ 43 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/tests/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Tests for our target_platform settings. 3 | # These can be used to test changes to the conditions backing the platform 4 | # selection rules. 5 | 6 | package(default_visibility = ["//visibility:public"]) 7 | 8 | licenses(["notice"]) # Apache 2.0 9 | 10 | load("//xrtl/testing:portable_testing.bzl", "portable_cc_test") 11 | 12 | portable_cc_test( 13 | name = "platform_test", 14 | size = "small", 15 | srcs = select( 16 | { 17 | "//xrtl/tools/target_platform:android": [ 18 | "platform_android_test.cc", 19 | ], 20 | "//xrtl/tools/target_platform:emscripten": [ 21 | "platform_emscripten_test.cc", 22 | ], 23 | "//xrtl/tools/target_platform:ios": [ 24 | "platform_ios_test.cc", 25 | ], 26 | "//xrtl/tools/target_platform:linux": [ 27 | "platform_linux_test.cc", 28 | ], 29 | "//xrtl/tools/target_platform:macos": [ 30 | "platform_macos_test.cc", 31 | ], 32 | "//xrtl/tools/target_platform:windows": [ 33 | "platform_windows_test.cc", 34 | ], 35 | }, 36 | no_match_error = "Unrecognized platform", 37 | ), 38 | deps = [ 39 | "//xrtl/testing:gtest_main", 40 | "//xrtl/tools/target_platform", 41 | ], 42 | ) 43 | 44 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 45 | 46 | portable_test_suite() 47 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_sampler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_SAMPLER_H_ 16 | #define XRTL_GFX_ES3_ES3_SAMPLER_H_ 17 | 18 | #include 19 | 20 | #include "xrtl/gfx/es3/es3_common.h" 21 | #include "xrtl/gfx/es3/es3_queue_object.h" 22 | #include "xrtl/gfx/sampler.h" 23 | 24 | namespace xrtl { 25 | namespace gfx { 26 | namespace es3 { 27 | 28 | class ES3Sampler : public Sampler, public ES3QueueObject { 29 | public: 30 | ES3Sampler(ES3ObjectLifetimeQueue* queue, Params params); 31 | ~ES3Sampler() override; 32 | 33 | void PrepareAllocation() override; 34 | 35 | GLuint sampler_id() const { return sampler_id_; } 36 | 37 | private: 38 | void Release() override; 39 | bool AllocateOnQueue() override; 40 | void DeallocateOnQueue() override; 41 | 42 | ES3ObjectLifetimeQueue* queue_; 43 | GLuint sampler_id_ = 0; 44 | }; 45 | 46 | } // namespace es3 47 | } // namespace gfx 48 | } // namespace xrtl 49 | 50 | #endif // XRTL_GFX_ES3_ES3_SAMPLER_H_ 51 | -------------------------------------------------------------------------------- /xrtl/gfx/memory_heap.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/memory_heap.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | 20 | std::ostream& operator<<(std::ostream& stream, 21 | const MemoryHeap::AllocationResult& value) { 22 | switch (value) { 23 | XRTL_UNREACHABLE_DEFAULT(); 24 | case MemoryHeap::AllocationResult::kSuccess: 25 | return stream << "AllocationResult::kSuccess"; 26 | case MemoryHeap::AllocationResult::kInvalidArguments: 27 | return stream << "AllocationResult::kInvalidArguments"; 28 | case MemoryHeap::AllocationResult::kUnsupported: 29 | return stream << "AllocationResult::kUnsupported"; 30 | case MemoryHeap::AllocationResult::kLimitsExceeded: 31 | return stream << "AllocationResult::kLimitsExceeded"; 32 | case MemoryHeap::AllocationResult::kOutOfMemory: 33 | return stream << "AllocationResult::kOutOfMemory"; 34 | } 35 | } 36 | 37 | } // namespace gfx 38 | } // namespace xrtl 39 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | clone_folder: c:\xrtl\ 4 | #cache: 5 | #- C:\bazel_root\execroot\xrtl\bazel-out\host -> .appveyor.yml 6 | #- C:\bazel_root\execroot\xrtl\bazel-out\msvc_x64-dbg\bin -> .appveyor.yml 7 | #- C:\bazel_root\execroot\xrtl\bazel-out\msvc_x64-dbg\genfiles -> .appveyor.yml 8 | #- C:\bazel_root\execroot\xrtl\bazel-out\stable-status.txt -> .appveyor.yml 9 | #- C:\bazel_root\execroot\xrtl\bazel-out\volatile-status.txt -> .appveyor.yml 10 | #- c:\install_cache\ -> .appveyor.yml 11 | 12 | skip_tags: true 13 | skip_branch_with_pr: true 14 | skip_commits: 15 | files: 16 | - docs/* 17 | - README.md 18 | 19 | environment: 20 | global: 21 | WORKSPACE: c:\xrtl\ 22 | BAZEL_ROOT: c:\bazel_root\ 23 | INSTALL_CACHE: c:\install_cache\ 24 | APPVEYOR_SAVE_CACHE_ON_ERROR: true 25 | matrix: 26 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 27 | 28 | install: 29 | - set PATH=%PATH%;%INSTALL_CACHE% 30 | - cmd: tools\ci\appveyor\install.bat 31 | 32 | build_script: 33 | - cmd: tools\ci\appveyor\build.bat 34 | 35 | test_script: 36 | - ps: Add-AppveyorTest "Unit Tests" -Outcome Running 37 | - cmd: tools\ci\appveyor\test.bat 38 | - ps: Update-AppveyorTest "Unit Tests" -Outcome Passed 39 | 40 | # Enable to debug issues: 41 | #on_finish: 42 | # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 43 | 44 | # TODO(benvanik): upload gtest logs, golden diffs, etc. 45 | #after_test: 46 | #- ps: Push-AppveyorArtifact some_artifact.txt 47 | 48 | deploy: off 49 | -------------------------------------------------------------------------------- /xrtl/gfx/managed_object.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_MANAGED_OBJECT_H_ 16 | #define XRTL_GFX_MANAGED_OBJECT_H_ 17 | 18 | #include "xrtl/base/ref_ptr.h" 19 | 20 | namespace xrtl { 21 | namespace gfx { 22 | 23 | // Base type for objects managed by the graphics system. 24 | // These objects may have differing lifetime rules based on the underlying 25 | // implementation. 26 | class ManagedObject : public RefObject { 27 | public: 28 | virtual ~ManagedObject() = default; 29 | 30 | // Deleter used by RefObject instead of normal C++ delete. 31 | static void Delete(ManagedObject* obj) { obj->Release(); } 32 | 33 | protected: 34 | ManagedObject() = default; 35 | 36 | // Implementation subclasses may override this to perform custom destruction 37 | // logic, such as returning to a pool or deferring deletion to another thread. 38 | virtual void Release() { delete this; } 39 | }; 40 | 41 | } // namespace gfx 42 | } // namespace xrtl 43 | 44 | #endif // XRTL_GFX_MANAGED_OBJECT_H_ 45 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/threading/win32_semaphore.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/threading/semaphore.h" 16 | #include "xrtl/port/windows/base/threading/win32_wait_handle.h" 17 | #include "xrtl/port/windows/base/windows.h" 18 | 19 | namespace xrtl { 20 | 21 | namespace { 22 | 23 | class Win32Semaphore : public Win32WaitHandle { 24 | public: 25 | Win32Semaphore(HANDLE handle, int maximum_count) 26 | : Win32WaitHandle(handle, maximum_count) {} 27 | 28 | bool Release(int release_count, int* out_previous_count) override { 29 | return ::ReleaseSemaphore(handle_, release_count, 30 | reinterpret_cast(out_previous_count)) != 31 | 0; 32 | } 33 | }; 34 | 35 | } // namespace 36 | 37 | ref_ptr Semaphore::Create(int initial_count, int maximum_count) { 38 | return make_ref( 39 | ::CreateSemaphore(nullptr, initial_count, maximum_count, nullptr), 40 | maximum_count); 41 | } 42 | 43 | } // namespace xrtl 44 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/threading/win32_event.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/threading/event.h" 16 | #include "xrtl/port/windows/base/threading/win32_wait_handle.h" 17 | #include "xrtl/port/windows/base/windows.h" 18 | 19 | namespace xrtl { 20 | 21 | namespace { 22 | 23 | class Win32Event : public Win32WaitHandle { 24 | public: 25 | explicit Win32Event(HANDLE handle) : Win32WaitHandle(handle) {} 26 | ~Win32Event() override = default; 27 | 28 | void Set() override { ::SetEvent(handle_); } 29 | void Reset() override { ::ResetEvent(handle_); } 30 | }; 31 | 32 | } // namespace 33 | 34 | ref_ptr Event::CreateManualResetEvent(bool initial_state) { 35 | return make_ref( 36 | ::CreateEvent(nullptr, TRUE, initial_state ? TRUE : FALSE, nullptr)); 37 | } 38 | 39 | ref_ptr Event::CreateAutoResetEvent(bool initial_state) { 40 | return make_ref( 41 | ::CreateEvent(nullptr, FALSE, initial_state ? TRUE : FALSE, nullptr)); 42 | } 43 | 44 | } // namespace xrtl 45 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_WINDOWS_BASE_WINDOWS_H_ 16 | #define XRTL_PORT_WINDOWS_BASE_WINDOWS_H_ 17 | 18 | // This file brings in the common Windows headers. 19 | // It should only be included by files under port/windows/. 20 | 21 | #include "xrtl/tools/target_platform/target_platform.h" 22 | 23 | #ifndef XRTL_PLATFORM_WINDOWS 24 | #error Attempting to use Windows headers on a non-Windows platform. 25 | #endif // !XRTL_PLATFORM_WINDOWS 26 | 27 | #ifndef WIN32_LEAN_AND_MEAN 28 | #define WIN32_LEAN_AND_MEAN 29 | #endif // WIN32_LEAN_AND_MEAN 30 | #ifndef NOMINMAX 31 | #define NOMINMAX 32 | #endif // NOMINMAX 33 | 34 | // Bazel's default CROSSTOOL defines NOGDI. Undo that nastiness. 35 | #undef NOGDI 36 | 37 | // Must be first. 38 | #include 39 | 40 | #include // winmm 41 | #include // ole32 42 | #include // shell32 43 | 44 | // Global namespace conflicts. 45 | #undef ERROR 46 | 47 | #endif // XRTL_PORT_WINDOWS_BASE_WINDOWS_H_ 48 | -------------------------------------------------------------------------------- /xrtl/base/stopwatch.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_STOPWATCH_H_ 16 | #define XRTL_BASE_STOPWATCH_H_ 17 | 18 | #include 19 | 20 | #include "xrtl/base/system_clock.h" 21 | 22 | namespace xrtl { 23 | 24 | // A simple stopwatch for timing operations. 25 | // 26 | // Usage: 27 | // Stopwatch stopwatch; 28 | // // ... do expensive things. 29 | // total_time = stopwatch.elapsed_micros(); 30 | class Stopwatch { 31 | public: 32 | Stopwatch() : clock_(SystemClock::default_clock()) { Reset(); } 33 | explicit Stopwatch(SystemClock* clock) : clock_(clock) { Reset(); } 34 | 35 | // Resets the elapsed time to 0. 36 | void Reset() { timebase_ = clock_->now_micros(); } 37 | 38 | // Total microseconds elapsed since the last Reset. 39 | std::chrono::microseconds elapsed_micros() { 40 | return clock_->now_micros() - timebase_; 41 | } 42 | 43 | private: 44 | SystemClock* clock_ = nullptr; 45 | std::chrono::microseconds timebase_; 46 | }; 47 | 48 | } // namespace xrtl 49 | 50 | #endif // XRTL_BASE_STOPWATCH_H_ 51 | -------------------------------------------------------------------------------- /xrtl/ui/shaders/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Shaders used by xrtl::ui. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | genrule( 9 | name = "imgui_overlay_frag_files", 10 | srcs = ["imgui_overlay.frag"], 11 | outs = [ 12 | "imgui_overlay_frag.cc", 13 | "imgui_overlay_frag.h", 14 | ], 15 | cmd = " ".join([ 16 | "$(location //xrtl/gfx/spirv:shader_tool)", 17 | "$(SRCS)", 18 | "--output_namespace=xrtl::ui::shaders", 19 | "--output_variable=kImGuiOverlayFragSpirV", 20 | "--output_spirv_h=$(location imgui_overlay_frag.h)", 21 | "--output_spirv_cc=$(location imgui_overlay_frag.cc)", 22 | ]), 23 | tools = ["//xrtl/gfx/spirv:shader_tool"], 24 | ) 25 | 26 | cc_library( 27 | name = "imgui_overlay_frag", 28 | srcs = [":imgui_overlay_frag.cc"], 29 | hdrs = [":imgui_overlay_frag.h"], 30 | ) 31 | 32 | genrule( 33 | name = "imgui_overlay_vert_files", 34 | srcs = ["imgui_overlay.vert"], 35 | outs = [ 36 | "imgui_overlay_vert.cc", 37 | "imgui_overlay_vert.h", 38 | ], 39 | cmd = " ".join([ 40 | "$(location //xrtl/gfx/spirv:shader_tool)", 41 | "$(SRCS)", 42 | "--output_namespace=xrtl::ui::shaders", 43 | "--output_variable=kImGuiOverlayVertSpirV", 44 | "--output_spirv_h=$(location imgui_overlay_vert.h)", 45 | "--output_spirv_cc=$(location imgui_overlay_vert.cc)", 46 | ]), 47 | tools = ["//xrtl/gfx/spirv:shader_tool"], 48 | ) 49 | 50 | cc_library( 51 | name = "imgui_overlay_vert", 52 | srcs = [":imgui_overlay_vert.cc"], 53 | hdrs = [":imgui_overlay_vert.h"], 54 | ) 55 | -------------------------------------------------------------------------------- /xrtl/gfx/context.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/context.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | 20 | std::ostream& operator<<(std::ostream& stream, 21 | const Context::SubmitResult& value) { 22 | switch (value) { 23 | XRTL_UNREACHABLE_DEFAULT(); 24 | case Context::SubmitResult::kSuccess: 25 | return stream << "SubmitResult::kSuccess"; 26 | case Context::SubmitResult::kCommandBufferReused: 27 | return stream << "SubmitResult::kCommandBufferReused"; 28 | case Context::SubmitResult::kDeviceLost: 29 | return stream << "SubmitResult::kDeviceLost"; 30 | } 31 | } 32 | 33 | std::ostream& operator<<(std::ostream& stream, 34 | const Context::WaitResult& value) { 35 | switch (value) { 36 | XRTL_UNREACHABLE_DEFAULT(); 37 | case Context::WaitResult::kSuccess: 38 | return stream << "SubmitResult::kSuccess"; 39 | case Context::WaitResult::kDeviceLost: 40 | return stream << "SubmitResult::kDeviceLost"; 41 | } 42 | } 43 | 44 | } // namespace gfx 45 | } // namespace xrtl 46 | -------------------------------------------------------------------------------- /xrtl/port/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Platform-specific implementations and features. 3 | # Anything that only compiles for a specific platform should be kept under the 4 | # appropriate directory here, with implementations shared amongst several 5 | # platforms under common/. 6 | 7 | package(default_visibility = ["//xrtl:internal"]) 8 | 9 | licenses(["notice"]) # Apache 2.0 10 | 11 | # The following package groups can be used to restrict code that cannot be 12 | # depended on outside of the respective ports path such as system headers 13 | # and libraries. 14 | 15 | package_group( 16 | name = "ports_only", 17 | packages = [ 18 | "//third_party/...", 19 | "//xrtl/port/...", 20 | ], 21 | ) 22 | 23 | package_group( 24 | name = "android_only", 25 | packages = [ 26 | "//third_party/...", 27 | "//xrtl/port/android/...", 28 | ], 29 | ) 30 | 31 | package_group( 32 | name = "emscripten_only", 33 | packages = [ 34 | "//third_party/...", 35 | "//xrtl/port/emscripten/...", 36 | ], 37 | ) 38 | 39 | package_group( 40 | name = "ios_only", 41 | packages = [ 42 | "//third_party/...", 43 | "//xrtl/port/ios/...", 44 | ], 45 | ) 46 | 47 | package_group( 48 | name = "linux_only", 49 | packages = [ 50 | "//third_party/...", 51 | "//xrtl/port/linux/...", 52 | ], 53 | ) 54 | 55 | package_group( 56 | name = "macos_only", 57 | packages = [ 58 | "//third_party/...", 59 | "//xrtl/port/macos/...", 60 | ], 61 | ) 62 | 63 | package_group( 64 | name = "windows_only", 65 | packages = [ 66 | "//third_party/...", 67 | "//xrtl/port/windows/...", 68 | ], 69 | ) 70 | -------------------------------------------------------------------------------- /xrtl/base/tracing.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/tracing.h" 16 | 17 | #include "xrtl/base/logging.h" 18 | #include "xrtl/base/macros.h" 19 | 20 | namespace xrtl { 21 | namespace tracing { 22 | 23 | #if WTF_ENABLE 24 | 25 | namespace { 26 | 27 | uint32_t current_frame_number_ = 0; 28 | 29 | } // namespace 30 | 31 | void EmitFrameStart() { 32 | wtf::StandardEvents::FrameStart(wtf::PlatformGetThreadLocalEventBuffer(), 33 | current_frame_number_); 34 | } 35 | 36 | void EmitFrameEnd() { 37 | wtf::StandardEvents::FrameEnd(wtf::PlatformGetThreadLocalEventBuffer(), 38 | current_frame_number_); 39 | ++current_frame_number_; 40 | } 41 | 42 | void SaveToFile(std::string file_path) { 43 | if (wtf::Runtime::GetInstance()->SaveToFile(file_path)) { 44 | LOG(INFO) << "Wrote trace to " << file_path; 45 | } else { 46 | LOG(ERROR) << "Unable to write trace file to " << file_path; 47 | } 48 | } 49 | 50 | #else 51 | 52 | XRTL_EMPTY_FILE(); 53 | 54 | #endif // WTF_ENABLE 55 | 56 | } // namespace tracing 57 | } // namespace xrtl 58 | -------------------------------------------------------------------------------- /xrtl/gfx/command_buffer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/command_buffer.h" 16 | 17 | namespace xrtl { 18 | namespace gfx { 19 | 20 | CommandBuffer::CommandBuffer() = default; 21 | 22 | CommandBuffer::~CommandBuffer() { ReleaseDependencies(); } 23 | 24 | void CommandBuffer::AttachDependency(void (*release_fn)(void* value_ptr), 25 | void* value_ptr) { 26 | dependencies_.push_back({release_fn, value_ptr}); 27 | } 28 | 29 | void CommandBuffer::AttachDependencies(void (*release_fn)(void* value_ptr), 30 | void* const* value_ptrs, 31 | size_t value_count) { 32 | dependencies_.reserve(dependencies_.size() + value_count); 33 | for (size_t i = 0; i < value_count; ++i) { 34 | dependencies_.push_back({release_fn, value_ptrs[i]}); 35 | } 36 | } 37 | 38 | void CommandBuffer::ReleaseDependencies() { 39 | for (auto& dependency : dependencies_) { 40 | dependency.release_fn(dependency.value_ptr); 41 | } 42 | dependencies_.resize(0); 43 | } 44 | 45 | } // namespace gfx 46 | } // namespace xrtl 47 | -------------------------------------------------------------------------------- /xrtl/tools/target_config/target_config.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_TOOLS_TARGET_CONFIG_TARGET_CONFIG_H_ 16 | #define XRTL_TOOLS_TARGET_CONFIG_TARGET_CONFIG_H_ 17 | 18 | // The bazel rule defines one of the following top-level configurations: 19 | // XRTL_CONFIG_DBG 20 | // XRTL_CONFIG_FASTBUILD 21 | // XRTL_CONFIG_OPT 22 | // 23 | // Additionally one or more of these may be defined: 24 | // XRTL_CONFIG_GOOGLE_INTERNAL 25 | // XRTL_CONFIG_LOGGING_VERBOSE 26 | // XRTL_CONFIG_SWIFTSHADER 27 | // 28 | // Depending on instrumentation mode, we set these dynamically: 29 | // XRTL_CONFIG_ASAN 30 | // XRTL_CONFIG_MSAN 31 | // XRTL_CONFIG_TSAN 32 | 33 | #if defined(__has_feature) 34 | #if __has_feature(address_sanitizer) 35 | #define XRTL_CONFIG_ASAN 1 36 | #endif // __has_feature(address_sanitizer) 37 | #if __has_feature(memory_sanitizer) 38 | #define XRTL_CONFIG_MSAN 1 39 | #endif // __has_feature(memory_sanitizer) 40 | #if __has_feature(thread_sanitizer) 41 | #define XRTL_CONFIG_TSAN 1 42 | #endif // __has_feature(thread_sanitizer) 43 | #endif // __has_feature 44 | 45 | #endif // XRTL_TOOLS_TARGET_CONFIG_TARGET_CONFIG_H_ 46 | -------------------------------------------------------------------------------- /xrtl/base/debugging.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/debugging.h" 16 | 17 | #include 18 | 19 | #if defined(XRTL_PLATFORM_APPLE) || defined(XRTL_PLATFORM_LINUX) 20 | #define HAS_BACKTRACE 21 | #include 22 | #include 23 | #endif // APPLE || LINUX 24 | 25 | namespace xrtl { 26 | namespace debugging { 27 | 28 | #if defined(HAS_BACKTRACE) 29 | std::string CaptureStackTraceString() { 30 | constexpr int kStackBufferSize = 64; 31 | void* stack_buffer[kStackBufferSize] = {0}; 32 | int stack_depth = backtrace(stack_buffer, kStackBufferSize); 33 | if (stack_depth <= 1) { 34 | return ""; 35 | } 36 | char** stack_strings = backtrace_symbols(stack_buffer, stack_depth); 37 | if (!stack_strings) { 38 | return ""; 39 | } 40 | std::ostringstream ss; 41 | ss << "Stack:\n"; 42 | for (int i = 1; i < stack_depth; ++i) { 43 | ss << stack_strings[i] << '\n'; 44 | } 45 | std::free(stack_strings); 46 | return ss.str(); 47 | } 48 | #else 49 | std::string CaptureStackTraceString() { return ""; } 50 | #endif // HAS_BACKTRACE 51 | 52 | } // namespace debugging 53 | } // namespace xrtl 54 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_shader_module.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/es3/es3_shader_module.h" 16 | 17 | #include 18 | 19 | namespace xrtl { 20 | namespace gfx { 21 | namespace es3 { 22 | 23 | ES3ShaderModule::ES3ShaderModule(ES3ObjectLifetimeQueue* queue) 24 | : queue_(queue) { 25 | } 26 | 27 | ES3ShaderModule::~ES3ShaderModule() = default; 28 | 29 | void ES3ShaderModule::PrepareAllocation() { 30 | queue_->EnqueueObjectAllocation(this); 31 | } 32 | 33 | void ES3ShaderModule::Release() { queue_->EnqueueObjectDeallocation(this); } 34 | 35 | bool ES3ShaderModule::AllocateOnQueue() { return true; } 36 | 37 | void ES3ShaderModule::DeallocateOnQueue() { shaders_.clear(); } 38 | 39 | void ES3ShaderModule::Register(ref_ptr shader) { 40 | shaders_.push_back(shader); 41 | } 42 | 43 | ref_ptr ES3ShaderModule::Lookup( 44 | absl::string_view entry_point) const { 45 | for (const auto& shader : shaders_) { 46 | if (entry_point == shader->entry_point()) { 47 | return shader; 48 | } 49 | } 50 | return nullptr; 51 | } 52 | 53 | } // namespace es3 54 | } // namespace gfx 55 | } // namespace xrtl 56 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/threading/win32_wait_handle.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_WINDOWS_BASE_THREADING_WIN32_WAIT_HANDLE_H_ 16 | #define XRTL_PORT_WINDOWS_BASE_THREADING_WIN32_WAIT_HANDLE_H_ 17 | 18 | #include 19 | 20 | #include "xrtl/base/threading/wait_handle.h" 21 | #include "xrtl/port/windows/base/windows.h" 22 | 23 | namespace xrtl { 24 | 25 | // CRTP WaitHandle shim. 26 | // This is used by the various waitable types on Windows to get safe HANDLE 27 | // storage. 28 | template 29 | class Win32WaitHandle : public T { 30 | public: 31 | template 32 | explicit Win32WaitHandle(HANDLE handle, Args&&... args) 33 | : T(std::forward(args)...), handle_(handle) {} 34 | 35 | ~Win32WaitHandle() override { 36 | if (handle_) { 37 | ::CloseHandle(handle_); 38 | handle_ = nullptr; 39 | } 40 | } 41 | 42 | uintptr_t native_handle() override { 43 | return reinterpret_cast(handle_); 44 | } 45 | 46 | protected: 47 | HANDLE handle_ = nullptr; 48 | }; 49 | 50 | } // namespace xrtl 51 | 52 | #endif // XRTL_PORT_WINDOWS_BASE_THREADING_WIN32_WAIT_HANDLE_H_ 53 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_device.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/es3/es3_device.h" 16 | 17 | #include "xrtl/gfx/es3/es3_common.h" 18 | 19 | namespace xrtl { 20 | namespace gfx { 21 | namespace es3 { 22 | 23 | bool ES3Device::AdoptCurrentContext() { 24 | // TODO(benvanik): pull renderer/etc. 25 | type_ = DeviceType::kGpu; 26 | 27 | // Query limits. 28 | // TODO(benvanik): query limits. 29 | 30 | // Query feature support flags. 31 | // TODO(benvanik): other features. 32 | QuerySupportedPixelFormats(&features_.pixel_formats); 33 | 34 | return true; 35 | } 36 | 37 | void ES3Device::QuerySupportedPixelFormats( 38 | Features::PixelFormats* pixel_formats) { 39 | pixel_formats->packed_depth_stencil = GLAD_GL_OES_packed_depth_stencil == 1; 40 | pixel_formats->bc1_2_3 = GLAD_GL_EXT_texture_compression_s3tc == 1; 41 | pixel_formats->bc4_5_6_7 = false; 42 | pixel_formats->etc2 = true; 43 | pixel_formats->eac = true; 44 | pixel_formats->astc = GLAD_GL_KHR_texture_compression_astc_hdr == 1; 45 | pixel_formats->pvrtc = GLAD_GL_IMG_texture_compression_pvrtc == 1; 46 | } 47 | 48 | } // namespace es3 49 | } // namespace gfx 50 | } // namespace xrtl 51 | -------------------------------------------------------------------------------- /xrtl/port/linux/ui/x11_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_LINUX_UI_X11_WINDOW_H_ 16 | #define XRTL_PORT_LINUX_UI_X11_WINDOW_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "xrtl/port/linux/ui/x11_control.h" 22 | #include "xrtl/port/linux/ui/x11_headers.h" 23 | #include "xrtl/ui/window.h" 24 | 25 | namespace xrtl { 26 | namespace ui { 27 | 28 | // X11 implementation of a window. 29 | class X11Window : public Window, private X11Control::ControlContainer { 30 | public: 31 | explicit X11Window(ref_ptr message_loop); 32 | ~X11Window() override; 33 | 34 | std::string title() override; 35 | void set_title(std::string title) override; 36 | 37 | ref_ptr root_control() override; 38 | 39 | ref_ptr Open() override; 40 | ref_ptr Close() override; 41 | 42 | protected: 43 | // From ControlContainer: 44 | void OnChildCreated(ref_ptr child_control) override; 45 | 46 | std::mutex mutex_; 47 | 48 | std::string title_; 49 | 50 | ref_ptr control_; 51 | }; 52 | 53 | } // namespace ui 54 | } // namespace xrtl 55 | 56 | #endif // XRTL_PORT_LINUX_UI_X11_WINDOW_H_ 57 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/data_differ.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/diffing/data_differ.h" 16 | 17 | #include "xrtl/base/logging.h" 18 | 19 | namespace xrtl { 20 | namespace testing { 21 | namespace diffing { 22 | 23 | DataDiffer::Result DataDiffer::DiffBuffers(const void* expected_value, 24 | size_t expected_value_length, 25 | const void* actual_value, 26 | size_t actual_value_length, 27 | Options options) { 28 | Result result; 29 | result.equivalent = true; 30 | if (expected_value_length != actual_value_length) { 31 | LOG(ERROR) << "Expected data length " << expected_value_length 32 | << " but got actual " << actual_value_length; 33 | result.equivalent = false; 34 | } else { 35 | if (std::memcmp(expected_value, actual_value, expected_value_length) != 0) { 36 | LOG(ERROR) << "One or more data bytes differ"; 37 | result.equivalent = false; 38 | } 39 | } 40 | return result; 41 | } 42 | 43 | } // namespace diffing 44 | } // namespace testing 45 | } // namespace xrtl 46 | -------------------------------------------------------------------------------- /xrtl/port/windows/ui/win32_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_PORT_WINDOWS_UI_WIN32_WINDOW_H_ 16 | #define XRTL_PORT_WINDOWS_UI_WIN32_WINDOW_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "xrtl/port/windows/base/windows.h" 22 | #include "xrtl/port/windows/ui/win32_control.h" 23 | #include "xrtl/ui/window.h" 24 | 25 | namespace xrtl { 26 | namespace ui { 27 | 28 | // Win32 implementation of a window. 29 | class Win32Window : public Window, private Win32Control::ControlContainer { 30 | public: 31 | explicit Win32Window(ref_ptr message_loop); 32 | ~Win32Window() override; 33 | 34 | std::string title() override; 35 | void set_title(std::string title) override; 36 | 37 | ref_ptr root_control() override; 38 | 39 | ref_ptr Open() override; 40 | ref_ptr Close() override; 41 | 42 | protected: 43 | // From ControlContainer: 44 | void OnChildCreated(ref_ptr child_control) override; 45 | 46 | std::mutex mutex_; 47 | 48 | std::string title_; 49 | 50 | ref_ptr control_; 51 | }; 52 | 53 | } // namespace ui 54 | } // namespace xrtl 55 | 56 | #endif // XRTL_PORT_WINDOWS_UI_WIN32_WINDOW_H_ 57 | -------------------------------------------------------------------------------- /xrtl/ui/system_theme.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_UI_SYSTEM_THEME_H_ 16 | #define XRTL_UI_SYSTEM_THEME_H_ 17 | 18 | #include "xrtl/base/macros.h" 19 | 20 | namespace xrtl { 21 | namespace ui { 22 | 23 | // Provides access to system metrics. 24 | // Note that the user may change the system metrics at any time. Listen for the 25 | // Window or Control OnSystemThemeChanged events and update cached values. 26 | // 27 | // Platform references: 28 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx 29 | // MacOS: 30 | // iOS: create a UIView, get default values 31 | // X11: TBD 32 | // Win32: GetSystemMetrics 33 | class SystemMetrics { 34 | public: 35 | }; 36 | 37 | // Provides access to system colors. 38 | // Note that the user may change the system colors at any time. Listen for the 39 | // Window or Control OnSystemThemeChanged events and update cached values. 40 | // 41 | // Platform references: 42 | // MacOS: GetThemeBrushAsColor 43 | // iOS: create a UIView, get default values 44 | // X11: TBD 45 | // Win32: GetSysColor 46 | class SystemColors { 47 | public: 48 | }; 49 | 50 | } // namespace ui 51 | } // namespace xrtl 52 | 53 | #endif // XRTL_UI_SYSTEM_THEME_H_ 54 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_pixel_format.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_PIXEL_FORMAT_H_ 16 | #define XRTL_GFX_ES3_ES3_PIXEL_FORMAT_H_ 17 | 18 | #include "xrtl/gfx/es3/es3_common.h" 19 | #include "xrtl/gfx/pixel_format.h" 20 | 21 | namespace xrtl { 22 | namespace gfx { 23 | namespace es3 { 24 | 25 | // Parameters for GL texture functions derived from our pixel formats. 26 | struct ES3TextureParams { 27 | // 'internalFormat' parameter. 28 | GLenum internal_format = GL_NONE; 29 | // 'format' parameter. 30 | GLenum format = GL_NONE; 31 | // 'type' parameter. 32 | GLenum type = GL_NONE; 33 | 34 | ES3TextureParams() = default; 35 | ES3TextureParams(GLenum internal_format, GLenum format, GLenum type) 36 | : internal_format(internal_format), format(format), type(type) {} 37 | }; 38 | 39 | // Converts a PixelFormat to a set of GL texture parameter info. 40 | // Returns false if the PixelFormat cannot be represented in GL. 41 | bool ConvertPixelFormatToTextureParams(PixelFormat pixel_format, 42 | ES3TextureParams* out_texture_params); 43 | 44 | } // namespace es3 45 | } // namespace gfx 46 | } // namespace xrtl 47 | 48 | #endif // XRTL_GFX_ES3_ES3_PIXEL_FORMAT_H_ 49 | -------------------------------------------------------------------------------- /tools/actions/generate_link_target.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright 2017 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | """A Bazel extra_action which genenerates link target files. 18 | The files written are consumed by the generate_link_targets_json.py script 19 | to collapse them into a single database. 20 | """ 21 | 22 | import sys 23 | 24 | import third_party.bazel.extra_actions_base_pb2 as extra_actions_base_pb2 25 | 26 | 27 | def main(argv): 28 | action = extra_actions_base_pb2.ExtraActionInfo() 29 | with open(argv[1], 'rb') as f: 30 | action.MergeFromString(f.read()) 31 | 32 | # From CppLink: 33 | cpp_link_info = action.Extensions[extra_actions_base_pb2.CppLinkInfo.cpp_link_info] 34 | if cpp_link_info.link_target_type != 'EXECUTABLE': 35 | # Skip all STATIC_LIBRARYs. 36 | with open(argv[2], 'w') as f: 37 | pass 38 | return 0 39 | 40 | # Write out required data for generate_link_targets_json.py. 41 | with open(argv[2], 'w') as f: 42 | # //some/path:rule 43 | f.write(action.owner) 44 | f.write('\0') 45 | # 1517a.... 46 | f.write(action.id) 47 | f.write('\0') 48 | # bazel-out/.../some.exe 49 | f.write(cpp_link_info.output_file) 50 | 51 | 52 | if __name__ == '__main__': 53 | sys.exit(main(sys.argv)) 54 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/text_differ.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/diffing/text_differ.h" 16 | 17 | #include "xrtl/base/logging.h" 18 | 19 | namespace xrtl { 20 | namespace testing { 21 | namespace diffing { 22 | 23 | TextDiffer::Result TextDiffer::DiffStrings(absl::string_view expected_value, 24 | absl::string_view actual_value, 25 | Options options) { 26 | Result result; 27 | result.equivalent = true; 28 | if (expected_value.size() != actual_value.size()) { 29 | LOG(ERROR) << "Expected string length " << expected_value.size() 30 | << " but got actual " << actual_value.size(); 31 | result.equivalent = false; 32 | } else { 33 | if (std::memcmp(expected_value.data(), actual_value.data(), 34 | expected_value.size()) != 0) { 35 | LOG(ERROR) << "One or more characters differ" << std::endl 36 | << "Expected: " << expected_value << std::endl 37 | << "Actual: " << actual_value; 38 | result.equivalent = false; 39 | } 40 | } 41 | return result; 42 | } 43 | 44 | } // namespace diffing 45 | } // namespace testing 46 | } // namespace xrtl 47 | -------------------------------------------------------------------------------- /xrtl/gfx/vertex_format_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/gfx/vertex_format.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace gfx { 21 | namespace { 22 | 23 | // Tests the comparison operations on vertex formats. 24 | TEST(VertexFormatTest, Comparisons) { 25 | EXPECT_FALSE(VertexFormats::kUndefined); 26 | EXPECT_TRUE(VertexFormats::kW2X10Y10Z10UNorm); 27 | EXPECT_EQ(VertexFormats::kUndefined, VertexFormats::kUndefined); 28 | EXPECT_NE(VertexFormats::kUndefined, VertexFormats::kW2X10Y10Z10UNorm); 29 | EXPECT_EQ(VertexFormats::kW2X10Y10Z10UNorm, VertexFormats::kW2X10Y10Z10UNorm); 30 | } 31 | 32 | // Tests some types and their math. 33 | TEST(VertexFormatTest, Types) { 34 | VertexFormat format = VertexFormats::kW2X10Y10Z10UNorm; 35 | EXPECT_EQ(17, format.unique_id()); 36 | EXPECT_EQ(ComponentFormat::kUNorm, format.component_format()); 37 | EXPECT_EQ(4, format.component_count()); 38 | EXPECT_EQ(10, format.component_bits_x()); 39 | EXPECT_EQ(10, format.component_bits_y()); 40 | EXPECT_EQ(10, format.component_bits_z()); 41 | EXPECT_EQ(2, format.component_bits_w()); 42 | EXPECT_EQ(4, format.data_size()); 43 | } 44 | 45 | } // namespace 46 | } // namespace gfx 47 | } // namespace xrtl 48 | -------------------------------------------------------------------------------- /xrtl/base/tracing.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_BASE_TRACING_H_ 16 | #define XRTL_BASE_TRACING_H_ 17 | 18 | #include 19 | 20 | #if !defined(WTF_ENABLE) 21 | #define WTF_ENABLE 0 22 | #endif // !WTF_ENABLE 23 | 24 | #if WTF_ENABLE 25 | #include 26 | #include 27 | #include 28 | #include 29 | #endif // WTF_ENABLE 30 | 31 | namespace xrtl { 32 | namespace tracing { 33 | 34 | #if WTF_ENABLE 35 | 36 | // Marks a frame start/end event with a monotonically increasing frame number. 37 | void EmitFrameStart(); 38 | void EmitFrameEnd(); 39 | 40 | // Saves the current trace buffer to the given file path, if enabled. 41 | void SaveToFile(std::string file_path); 42 | 43 | #else 44 | 45 | // Empty functions to prevent compilation errors. 46 | inline void EmitFrameStart() {} 47 | inline void EmitFrameEnd() {} 48 | inline void SaveToFile(std::string file_path) {} 49 | 50 | // No-op macros. 51 | #define __WTF_IGNORED(...) 52 | #define WTF_EVENT(...) __WTF_IGNORED 53 | #define WTF_EVENT0(...) 54 | #define WTF_SCOPE(...) __WTF_IGNORED 55 | #define WTF_SCOPE0(...) 56 | 57 | #endif // WTF_ENABLE 58 | 59 | } // namespace tracing 60 | } // namespace xrtl 61 | 62 | #endif // XRTL_BASE_TRACING_H_ 63 | -------------------------------------------------------------------------------- /xrtl/tools/target_platform/conditions.bzl: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Condition values for config_settings in target_platform. 3 | # These allow us to use a bit of skylark magic more easily 4 | # and swap out this file for other versions. 5 | 6 | CONDITION_ANDROID = { 7 | "crosstool_top": "TODO", 8 | } 9 | 10 | CONDITION_ANDROID_ARM_V7A = { 11 | "crosstool_top": "TODO", 12 | "cpu": "armeabi-v7a", 13 | } 14 | 15 | CONDITION_ANDROID_ARM_V8A = { 16 | "crosstool_top": "TODO", 17 | "cpu": "arm64-v8a", 18 | } 19 | 20 | CONDITION_ANDROID_X86_32 = { 21 | "crosstool_top": "TODO", 22 | "cpu": "x86", 23 | } 24 | 25 | CONDITION_ANDROID_X86_64 = { 26 | "crosstool_top": "TODO", 27 | "cpu": "x86_64", 28 | } 29 | 30 | CONDITION_EMSCRIPTEN = { 31 | "crosstool_top": "TODO", 32 | } 33 | 34 | CONDITION_EMSCRIPTEN_ASMJS = { 35 | "crosstool_top": "TODO", 36 | "cpu": "asmjs", 37 | } 38 | 39 | CONDITION_EMSCRIPTEN_WASM_32 = { 40 | "crosstool_top": "TODO", 41 | "cpu": "asmjs", 42 | } 43 | 44 | CONDITION_EMSCRIPTEN_WASM_64 = { 45 | "crosstool_top": "TODO", 46 | "cpu": "asmjs", 47 | } 48 | 49 | CONDITION_IOS = { 50 | "crosstool_top": "TODO", 51 | } 52 | 53 | CONDITION_IOS_ARM_V7A = { 54 | "cpu": "ios_armv7", 55 | } 56 | 57 | CONDITION_IOS_ARM_V8A = { 58 | "cpu": "ios_arm64", 59 | } 60 | 61 | CONDITION_IOS_X86_32 = { 62 | "cpu": "ios_i386", 63 | } 64 | 65 | CONDITION_IOS_X86_64 = { 66 | "cpu": "ios_x86_64", 67 | } 68 | 69 | CONDITION_LINUX = { 70 | "cpu": "k8", 71 | } 72 | 73 | CONDITION_LINUX_X86_64 = { 74 | "cpu": "k8", 75 | } 76 | 77 | CONDITION_MACOS = { 78 | "cpu": "darwin_x86_64", 79 | } 80 | 81 | CONDITION_MACOS_X86_64 = { 82 | "cpu": "darwin_x86_64", 83 | } 84 | 85 | CONDITION_WINDOWS = { 86 | "cpu": "x64_windows_msvc", 87 | } 88 | 89 | CONDITION_WINDOWS_X86_64 = { 90 | "cpu": "x64_windows_msvc", 91 | } 92 | -------------------------------------------------------------------------------- /xrtl/base/stopwatch_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/stopwatch.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace { 21 | 22 | class ManualClock : public SystemClock { 23 | public: 24 | std::chrono::microseconds now_utc_micros() override { 25 | return std::chrono::microseconds(0); 26 | } 27 | 28 | std::chrono::microseconds now_micros() override { 29 | return std::chrono::microseconds(now_micros_); 30 | } 31 | void set_now_micros(uint64_t now_micros) { now_micros_ = now_micros; } 32 | 33 | private: 34 | uint64_t now_micros_ = 0; 35 | }; 36 | 37 | TEST(StopwatchTest, Timing) { 38 | ManualClock clock; 39 | clock.set_now_micros(100); 40 | 41 | // Time a range. 42 | Stopwatch sw(&clock); 43 | EXPECT_EQ(0, sw.elapsed_micros().count()); 44 | clock.set_now_micros(200); 45 | EXPECT_EQ(100, sw.elapsed_micros().count()); 46 | 47 | // Reset the time. 48 | sw.Reset(); 49 | EXPECT_EQ(0, sw.elapsed_micros().count()); 50 | clock.set_now_micros(300); 51 | EXPECT_EQ(100, sw.elapsed_micros().count()); 52 | } 53 | 54 | TEST(StopwatchTest, SystemClock) { 55 | // Default ctor uses system clock. This is just here for coverage. 56 | Stopwatch sw; 57 | sw.Reset(); 58 | } 59 | 60 | } // namespace 61 | } // namespace xrtl 62 | -------------------------------------------------------------------------------- /xrtl/testing/diffing/text_differ_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/testing/diffing/text_differ.h" 16 | 17 | #include "xrtl/testing/gtest.h" 18 | 19 | namespace xrtl { 20 | namespace testing { 21 | namespace diffing { 22 | namespace { 23 | 24 | // Tests a variety of normal string types. 25 | TEST(TextDifferTest, SimpleComparisons) { 26 | EXPECT_TRUE(TextDiffer::CompareStrings(nullptr, nullptr, {})); 27 | EXPECT_FALSE(TextDiffer::CompareStrings("foo", nullptr, {})); 28 | EXPECT_TRUE(TextDiffer::CompareStrings("", "", {})); 29 | EXPECT_FALSE(TextDiffer::CompareStrings("foo", "", {})); 30 | EXPECT_TRUE(TextDiffer::CompareStrings("a", "a", {})); 31 | EXPECT_FALSE(TextDiffer::CompareStrings("a", "b", {})); 32 | EXPECT_FALSE(TextDiffer::CompareStrings("a", "aa", {})); 33 | } 34 | 35 | // Tests binary data (including NUL and such) types. 36 | TEST(TextDifferTest, BinaryComparisons) { 37 | EXPECT_TRUE(TextDiffer::CompareStrings(absl::string_view("a\0b", 3), 38 | absl::string_view("a\0b", 3), {})); 39 | EXPECT_FALSE(TextDiffer::CompareStrings(absl::string_view("a\0c", 3), 40 | absl::string_view("a\0b", 3), {})); 41 | } 42 | 43 | } // namespace 44 | } // namespace diffing 45 | } // namespace testing 46 | } // namespace xrtl 47 | -------------------------------------------------------------------------------- /xrtl/gfx/spirv/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # SPIR-V tools. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | load("//xrtl/testing:portable_testing.bzl", "portable_cc_test") 9 | 10 | cc_library( 11 | name = "shader_compiler", 12 | srcs = ["shader_compiler.cc"], 13 | hdrs = ["shader_compiler.h"], 14 | deps = [ 15 | "//xrtl/base:debugging", 16 | "//xrtl/base:logging", 17 | "//xrtl/base:tracing", 18 | "@com_github_khronosgroup_glslang//:SPIRV", 19 | "@com_github_khronosgroup_glslang//:glslang", 20 | "@com_google_absl//absl/base", 21 | "@com_google_absl//absl/strings", 22 | ], 23 | ) 24 | 25 | portable_cc_test( 26 | name = "shader_compiler_test", 27 | size = "small", 28 | srcs = ["shader_compiler_test.cc"], 29 | deps = [ 30 | ":shader_compiler", 31 | "//xrtl/testing:gtest_main", 32 | ], 33 | ) 34 | 35 | cc_binary( 36 | name = "shader_tool", 37 | srcs = ["shader_tool_cli.cc"], 38 | deps = [ 39 | ":shader_compiler", 40 | ":spirv_optimizer", 41 | "//xrtl/base:cli_main", 42 | "//xrtl/base:flags", 43 | "//xrtl/base:logging", 44 | "@spirv_tools//:spirv_tools", 45 | ], 46 | ) 47 | 48 | cc_library( 49 | name = "spirv_optimizer", 50 | srcs = ["spirv_optimizer.cc"], 51 | hdrs = ["spirv_optimizer.h"], 52 | deps = [ 53 | "//xrtl/base:logging", 54 | "//xrtl/base:tracing", 55 | "@spirv_tools//:spirv_tools_opt", 56 | ], 57 | ) 58 | 59 | portable_cc_test( 60 | name = "spirv_optimizer_test", 61 | size = "small", 62 | srcs = ["spirv_optimizer_test.cc"], 63 | deps = [ 64 | ":spirv_optimizer", 65 | "//xrtl/base:macros", 66 | "//xrtl/testing:gtest_main", 67 | ], 68 | ) 69 | 70 | load("//xrtl/testing:portable_testing.bzl", "portable_test_suite") 71 | 72 | portable_test_suite() 73 | -------------------------------------------------------------------------------- /tools/xcode/xrtl.tulsiproj/Configs/ios.tulsigen: -------------------------------------------------------------------------------- 1 | { 2 | "sourceFilters" : [ 3 | "@build_bazel_rules_apple\/...", 4 | "@com_google_absl\/...", 5 | "bazel-genfiles\/...", 6 | "external\/...", 7 | "third_party\/...", 8 | "xrtl\/..." 9 | ], 10 | "buildTargets" : [ 11 | "\/\/xrtl\/base:arena_test_ios", 12 | "\/\/xrtl\/testing:image_buffer_test_ios" 13 | ], 14 | "projectName" : "xrtl", 15 | "optionSet" : { 16 | "LaunchActionPostActionScript" : { 17 | "p" : "$(inherited)" 18 | }, 19 | "BazelBuildStartupOptionsRelease" : { 20 | "p" : "$(inherited)" 21 | }, 22 | "BazelBuildOptionsRelease" : { 23 | "p" : "$(inherited) --config=macos_x86_64" 24 | }, 25 | "BazelBuildOptionsDebug" : { 26 | "p" : "$(inherited) --config=macos_x86_64" 27 | }, 28 | "EnvironmentVariables" : { 29 | "p" : "$(inherited)" 30 | }, 31 | "BuildActionPreActionScript" : { 32 | "p" : "$(inherited)" 33 | }, 34 | "CommandlineArguments" : { 35 | "p" : "$(inherited)" 36 | }, 37 | "TestActionPreActionScript" : { 38 | "p" : "$(inherited)" 39 | }, 40 | "BazelBuildStartupOptionsDebug" : { 41 | "p" : "$(inherited)" 42 | }, 43 | "TestActionPostActionScript" : { 44 | "p" : "$(inherited)" 45 | }, 46 | "BuildActionPostActionScript" : { 47 | "p" : "$(inherited)" 48 | }, 49 | "LaunchActionPreActionScript" : { 50 | "p" : "$(inherited)" 51 | } 52 | }, 53 | "additionalFilePaths" : [ 54 | "xrtl\/BUILD", 55 | "xrtl\/base\/BUILD", 56 | "xrtl\/examples\/BUILD", 57 | "xrtl\/gfx\/BUILD", 58 | "xrtl\/gfx\/spirv\/BUILD", 59 | "xrtl\/gfx\/testing\/BUILD", 60 | "xrtl\/port\/apple\/BUILD", 61 | "xrtl\/port\/ios\/BUILD", 62 | "xrtl\/port\/macos\/BUILD", 63 | "xrtl\/port\/macos\/gfx\/es3\/BUILD", 64 | "xrtl\/testing\/BUILD", 65 | "xrtl\/testing\/diffing\/BUILD", 66 | "xrtl\/ui\/BUILD" 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /xrtl/port/windows/base/threading/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Windows port variants of //xrtl/base/threading/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | cc_library( 9 | name = "win32_event", 10 | srcs = ["win32_event.cc"], 11 | deps = [ 12 | ":win32_wait_handle", 13 | "//xrtl/base/threading:threading_hdrs", 14 | "//xrtl/port/windows/base:windows_headers", 15 | ], 16 | ) 17 | 18 | cc_library( 19 | name = "win32_message_loop", 20 | srcs = ["win32_message_loop.cc"], 21 | linkopts = [ 22 | "-DEFAULTLIB:user32.lib", 23 | ], 24 | deps = [ 25 | "//xrtl/base/threading:event", 26 | "//xrtl/base/threading:thread", 27 | "//xrtl/base/threading:threading_hdrs", 28 | "//xrtl/port/windows/base:windows_headers", 29 | "@com_google_absl//absl/base", 30 | ], 31 | ) 32 | 33 | cc_library( 34 | name = "win32_semaphore", 35 | srcs = ["win32_semaphore.cc"], 36 | deps = [ 37 | ":win32_wait_handle", 38 | "//xrtl/base/threading:threading_hdrs", 39 | "//xrtl/port/windows/base:windows_headers", 40 | ], 41 | ) 42 | 43 | cc_library( 44 | name = "win32_thread", 45 | srcs = ["win32_thread.cc"], 46 | linkopts = [ 47 | "-DEFAULTLIB:winmm.lib", 48 | ], 49 | deps = [ 50 | ":win32_wait_handle", 51 | "//xrtl/base:logging", 52 | "//xrtl/base:stopwatch", 53 | "//xrtl/base/threading:thread_base", 54 | "//xrtl/base/threading:threading_hdrs", 55 | "//xrtl/port/windows/base:windows_headers", 56 | "@com_google_absl//absl/base", 57 | "@com_google_absl//absl/container:fixed_array", 58 | ], 59 | ) 60 | 61 | cc_library( 62 | name = "win32_wait_handle", 63 | hdrs = ["win32_wait_handle.h"], 64 | deps = [ 65 | "//xrtl/base/threading:wait_handle", 66 | "//xrtl/port/windows/base:windows_headers", 67 | ], 68 | ) 69 | -------------------------------------------------------------------------------- /xrtl/port/common/base/threading/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Posix pthreads port variants of //xrtl/base/threading/ features. 3 | 4 | package(default_visibility = ["//xrtl:internal"]) 5 | 6 | licenses(["notice"]) # Apache 2.0 7 | 8 | cc_library( 9 | name = "epoll_message_loop", 10 | srcs = ["epoll_message_loop.cc"], 11 | hdrs = ["epoll_message_loop.h"], 12 | deps = [ 13 | "//xrtl/base:system_clock", 14 | "//xrtl/base/threading:event", 15 | "//xrtl/base/threading:thread", 16 | "//xrtl/base/threading:threading_hdrs", 17 | ], 18 | ) 19 | 20 | cc_library( 21 | name = "pthreads_event", 22 | srcs = ["pthreads_event.cc"], 23 | linkopts = [ 24 | "-lpthread", 25 | ], 26 | deps = [ 27 | ":pthreads_wait_handle", 28 | "//xrtl/base/threading:threading_hdrs", 29 | ], 30 | ) 31 | 32 | cc_library( 33 | name = "pthreads_semaphore", 34 | srcs = ["pthreads_semaphore.cc"], 35 | linkopts = [ 36 | "-lpthread", 37 | ], 38 | deps = [ 39 | ":pthreads_wait_handle", 40 | "//xrtl/base/threading:threading_hdrs", 41 | ], 42 | ) 43 | 44 | cc_library( 45 | name = "pthreads_thread", 46 | srcs = ["pthreads_thread.cc"], 47 | linkopts = [ 48 | "-lpthread", 49 | ], 50 | deps = [ 51 | ":pthreads_event", 52 | ":pthreads_wait_handle", 53 | "//xrtl/base:logging", 54 | "//xrtl/base:stopwatch", 55 | "//xrtl/base/threading:thread_base", 56 | "//xrtl/base/threading:threading_hdrs", 57 | "//xrtl/tools/target_platform", 58 | "@com_google_absl//absl/base", 59 | "@com_google_absl//absl/container:fixed_array", 60 | ], 61 | ) 62 | 63 | cc_library( 64 | name = "pthreads_wait_handle", 65 | srcs = ["pthreads_wait_handle.cc"], 66 | hdrs = ["pthreads_wait_handle.h"], 67 | linkopts = [ 68 | "-lpthread", 69 | ], 70 | deps = [ 71 | "//xrtl/base/threading:wait_handle", 72 | ], 73 | ) 74 | -------------------------------------------------------------------------------- /xrtl/base/threading/thread.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/threading/thread.h" 16 | 17 | namespace xrtl { 18 | 19 | Thread::Thread() = default; 20 | 21 | Thread::~Thread() = default; 22 | 23 | void Thread::RegisterExitCallback(std::function callback) { 24 | std::lock_guard lock(exit_mutex_); 25 | exit_callbacks_.push_back(std::move(callback)); 26 | } 27 | 28 | void Thread::OnEnter() { 29 | // TODO(benvanik): prepare WTF on this thread. 30 | } 31 | 32 | void Thread::OnExit() { 33 | // Call exit routines in reverse order of registration. 34 | // NOTE: this is not re-entrant! 35 | { 36 | std::lock_guard lock(exit_mutex_); 37 | for (auto it = exit_callbacks_.rbegin(); it != exit_callbacks_.rend(); 38 | ++it) { 39 | (*it)(); 40 | } 41 | exit_callbacks_.clear(); 42 | } 43 | 44 | // TODO(benvanik): shutdown WTF for this thread. 45 | } 46 | 47 | std::ostream& operator<<(std::ostream& stream, 48 | const Thread::WaitResult& value) { 49 | switch (value) { 50 | XRTL_UNREACHABLE_DEFAULT(); 51 | case Thread::WaitResult::kSuccess: 52 | return stream << "WaitResult::kSuccess"; 53 | case Thread::WaitResult::kTimeout: 54 | return stream << "WaitResult::kTimeout"; 55 | case Thread::WaitResult::kError: 56 | return stream << "WaitResult::kError"; 57 | } 58 | } 59 | 60 | } // namespace xrtl 61 | -------------------------------------------------------------------------------- /tools/xcode/xrtl.tulsiproj/Configs/macos.tulsigen: -------------------------------------------------------------------------------- 1 | { 2 | "sourceFilters" : [ 3 | "@build_bazel_rules_apple\/...", 4 | "@com_google_absl\/...", 5 | "bazel-genfiles\/...", 6 | "external\/...", 7 | "third_party\/...", 8 | "xrtl\/..." 9 | ], 10 | "buildTargets" : [ 11 | "\/\/xrtl\/base:arena_test_macos", 12 | "\/\/xrtl\/gfx\/testing:graphics_test_test_macos", 13 | "\/\/xrtl\/testing:image_buffer_test_macos" 14 | ], 15 | "projectName" : "xrtl", 16 | "optionSet" : { 17 | "LaunchActionPostActionScript" : { 18 | "p" : "$(inherited)" 19 | }, 20 | "BazelBuildStartupOptionsRelease" : { 21 | "p" : "$(inherited)" 22 | }, 23 | "BazelBuildOptionsRelease" : { 24 | "p" : "$(inherited) --config=macos_x86_64" 25 | }, 26 | "BazelBuildOptionsDebug" : { 27 | "p" : "$(inherited) --config=macos_x86_64" 28 | }, 29 | "EnvironmentVariables" : { 30 | "p" : "$(inherited)" 31 | }, 32 | "BuildActionPreActionScript" : { 33 | "p" : "$(inherited)" 34 | }, 35 | "CommandlineArguments" : { 36 | "p" : "$(inherited)" 37 | }, 38 | "TestActionPreActionScript" : { 39 | "p" : "$(inherited)" 40 | }, 41 | "BazelBuildStartupOptionsDebug" : { 42 | "p" : "$(inherited)" 43 | }, 44 | "TestActionPostActionScript" : { 45 | "p" : "$(inherited)" 46 | }, 47 | "BuildActionPostActionScript" : { 48 | "p" : "$(inherited)" 49 | }, 50 | "LaunchActionPreActionScript" : { 51 | "p" : "$(inherited)" 52 | } 53 | }, 54 | "additionalFilePaths" : [ 55 | "xrtl\/BUILD", 56 | "xrtl\/base\/BUILD", 57 | "xrtl\/examples\/BUILD", 58 | "xrtl\/gfx\/BUILD", 59 | "xrtl\/gfx\/spirv\/BUILD", 60 | "xrtl\/gfx\/testing\/BUILD", 61 | "xrtl\/port\/apple\/BUILD", 62 | "xrtl\/port\/ios\/BUILD", 63 | "xrtl\/port\/macos\/BUILD", 64 | "xrtl\/port\/macos\/gfx\/es3\/BUILD", 65 | "xrtl\/testing\/BUILD", 66 | "xrtl\/testing\/diffing\/BUILD", 67 | "xrtl\/ui\/BUILD" 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /xrtl/port/windows/ui/win32_window.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/port/windows/ui/win32_window.h" 16 | 17 | #include "xrtl/base/logging.h" 18 | 19 | namespace xrtl { 20 | namespace ui { 21 | 22 | ref_ptr Window::Create(ref_ptr message_loop) { 23 | return make_ref(message_loop); 24 | } 25 | 26 | Win32Window::Win32Window(ref_ptr message_loop) 27 | : Window(message_loop) { 28 | control_ = make_ref( 29 | message_loop, static_cast(this)); 30 | } 31 | 32 | Win32Window::~Win32Window() { control_.reset(); } 33 | 34 | std::string Win32Window::title() { 35 | std::lock_guard lock(mutex_); 36 | return title_; 37 | } 38 | 39 | void Win32Window::set_title(std::string title) { 40 | std::lock_guard lock(mutex_); 41 | title_ = title; 42 | if (control_ && control_->is_active()) { 43 | ::SetWindowTextA(control_->hwnd(), title_.c_str()); 44 | } 45 | } 46 | 47 | ref_ptr Win32Window::root_control() { return control_.As(); } 48 | 49 | ref_ptr Win32Window::Open() { return control_->Create(); } 50 | 51 | ref_ptr Win32Window::Close() { return control_->Destroy(); } 52 | 53 | void Win32Window::OnChildCreated(ref_ptr child_control) { 54 | // Set values now that we have a window. 55 | set_title(title()); 56 | } 57 | 58 | } // namespace ui 59 | } // namespace xrtl 60 | -------------------------------------------------------------------------------- /xrtl/base/logging.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/base/logging.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "absl/base/optimization.h" 22 | #include "xrtl/base/macros.h" 23 | 24 | namespace xrtl { 25 | 26 | void LogStringFormat(const char* file_name, int line, int severity, 27 | const char* fmt, ...) { 28 | // Format message into a stack buffer. If the message runs over the buffer we 29 | // will do a heap allocation. 30 | constexpr int kStackLogLength = 2048; 31 | char stack_buffer[kStackLogLength]; 32 | va_list args; 33 | va_start(args, fmt); 34 | int stack_buffer_length = 35 | std::vsnprintf(stack_buffer, sizeof(stack_buffer), fmt, args); 36 | va_end(args); 37 | if (ABSL_PREDICT_TRUE(stack_buffer_length < 0)) { 38 | // Error during formatting. 39 | return; 40 | } 41 | if (stack_buffer_length < kStackLogLength) { 42 | LogString(file_name, line, severity, stack_buffer, stack_buffer_length); 43 | } else { 44 | // Ran over stack buffer; heap allocate and try again. 45 | std::vector heap_buffer(stack_buffer_length + 1); 46 | va_start(args, fmt); 47 | int heap_buffer_length = 48 | std::vsnprintf(heap_buffer.data(), heap_buffer.size(), fmt, args); 49 | va_end(args); 50 | LogString(file_name, line, severity, heap_buffer.data(), 51 | heap_buffer_length); 52 | } 53 | } 54 | 55 | } // namespace xrtl 56 | -------------------------------------------------------------------------------- /xrtl/gfx/es3/es3_shader_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_ES3_ES3_SHADER_MODULE_H_ 16 | #define XRTL_GFX_ES3_ES3_SHADER_MODULE_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "absl/strings/string_view.h" 22 | #include "xrtl/gfx/es3/es3_common.h" 23 | #include "xrtl/gfx/es3/es3_queue_object.h" 24 | #include "xrtl/gfx/es3/es3_shader.h" 25 | #include "xrtl/gfx/shader_module.h" 26 | 27 | namespace xrtl { 28 | namespace gfx { 29 | namespace es3 { 30 | 31 | class ES3ShaderModule : public ShaderModule, public ES3QueueObject { 32 | public: 33 | explicit ES3ShaderModule(ES3ObjectLifetimeQueue* queue); 34 | ~ES3ShaderModule() override; 35 | 36 | void PrepareAllocation() override; 37 | 38 | // Registers a shader with the shader module. 39 | // The entry point of the shader must be unique within the module. 40 | // This is not thread safe and should only be used during initialization. 41 | void Register(ref_ptr shader); 42 | 43 | // Finds a shader by entry point name, if it exists. 44 | ref_ptr Lookup(absl::string_view entry_point) const; 45 | 46 | private: 47 | void Release() override; 48 | bool AllocateOnQueue() override; 49 | void DeallocateOnQueue() override; 50 | 51 | ES3ObjectLifetimeQueue* queue_; 52 | std::vector> shaders_; 53 | }; 54 | 55 | } // namespace es3 56 | } // namespace gfx 57 | } // namespace xrtl 58 | 59 | #endif // XRTL_GFX_ES3_ES3_SHADER_MODULE_H_ 60 | -------------------------------------------------------------------------------- /xrtl/port/common/base/posix_logging_sink.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "xrtl/base/flags.h" 20 | #include "xrtl/base/logging.h" 21 | #include "xrtl/base/system_clock.h" 22 | #include "xrtl/port/common/base/logging_macros.h" 23 | 24 | DEFINE_bool(logtostderr, false, "Logs to stderr instead of stdout"); 25 | 26 | namespace xrtl { 27 | 28 | void FlushLog() { std::fflush(FLAGS_logtostderr ? stderr : stdout); } 29 | 30 | namespace internal { 31 | 32 | void LogMessage::EmitLogMessage() { 33 | static SystemClock* clock = SystemClock::logging_clock(); 34 | uint64_t now_micros = clock->now_utc_micros().count(); 35 | time_t now_seconds = static_cast(now_micros / 1000000); 36 | int32_t micros_remainder = static_cast(now_micros % 1000000); 37 | constexpr size_t kTimeBufferSize = 30; 38 | char time_buffer[kTimeBufferSize]; 39 | tm now_local; 40 | 41 | #if defined(XRTL_PLATFORM_WINDOWS) 42 | localtime_s(&now_local, &now_seconds); 43 | #else 44 | localtime_r(&now_seconds, &now_local); 45 | #endif // XRTL_PLATFORM_WINDOWS 46 | 47 | strftime(time_buffer, kTimeBufferSize, "%Y-%m-%d %H:%M:%S", &now_local); 48 | 49 | std::fprintf(FLAGS_logtostderr ? stderr : stdout, "%s.%06d: %c %s:%d] %s\n", 50 | time_buffer, micros_remainder, "IWEF"[severity_], file_name_, 51 | line_, str().c_str()); 52 | } 53 | 54 | } // namespace internal 55 | } // namespace xrtl 56 | -------------------------------------------------------------------------------- /xrtl/gfx/framebuffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef XRTL_GFX_FRAMEBUFFER_H_ 16 | #define XRTL_GFX_FRAMEBUFFER_H_ 17 | 18 | #include 19 | 20 | #include "absl/container/inlined_vector.h" 21 | #include "absl/types/span.h" 22 | #include "xrtl/base/geometry.h" 23 | #include "xrtl/gfx/image_view.h" 24 | #include "xrtl/gfx/managed_object.h" 25 | #include "xrtl/gfx/render_pass.h" 26 | 27 | namespace xrtl { 28 | namespace gfx { 29 | 30 | // A render target framebuffer, composed of one or more attachments. 31 | class Framebuffer : public ManagedObject { 32 | public: 33 | // Render pass this framebuffer is used with. 34 | ref_ptr render_pass() const { return render_pass_; } 35 | // Dimensions of the framebuffer in pixels. 36 | Size3D size() const { return size_; } 37 | // Attachments for the framebuffer in the same order as specified in the 38 | // render pass. 39 | absl::Span> attachments() const { 40 | return attachments_; 41 | } 42 | 43 | protected: 44 | Framebuffer(ref_ptr render_pass, Size3D size, 45 | absl::Span> attachments) 46 | : render_pass_(std::move(render_pass)), 47 | size_(size), 48 | attachments_(attachments.begin(), attachments.end()) {} 49 | 50 | ref_ptr render_pass_; 51 | Size3D size_; 52 | absl::InlinedVector, 4> attachments_; 53 | }; 54 | 55 | } // namespace gfx 56 | } // namespace xrtl 57 | 58 | #endif // XRTL_GFX_FRAMEBUFFER_H_ 59 | -------------------------------------------------------------------------------- /tools/actions/BUILD: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Action listener that generates the LLVM compile command database. 3 | # http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html 4 | 5 | package(default_visibility = ["//visibility:public"]) 6 | 7 | licenses(["notice"]) # Apache 2.0 8 | 9 | py_binary( 10 | name = "generate_compile_command", 11 | srcs = ["generate_compile_command.py"], 12 | visibility = ["//visibility:private"], 13 | deps = ["//third_party/bazel:extra_actions_proto_py"], 14 | ) 15 | 16 | extra_action( 17 | name = "generate_compile_commands_action", 18 | cmd = " ".join([ 19 | "PYTHONPATH=$$PYTHONPATH:$$PWD", 20 | "$(location :generate_compile_command)", 21 | "$(EXTRA_ACTION_FILE)", 22 | "$(output $(ACTION_ID)_compile_command)", 23 | ]), 24 | out_templates = ["$(ACTION_ID)_compile_command"], 25 | tools = [":generate_compile_command"], 26 | visibility = ["//visibility:private"], 27 | ) 28 | 29 | action_listener( 30 | name = "generate_compile_commands_listener", 31 | extra_actions = [":generate_compile_commands_action"], 32 | mnemonics = [ 33 | # TODO(benvanik): objc? 34 | "CppCompile", 35 | ], 36 | visibility = ["//visibility:public"], 37 | ) 38 | 39 | py_binary( 40 | name = "generate_link_target", 41 | srcs = ["generate_link_target.py"], 42 | visibility = ["//visibility:private"], 43 | deps = ["//third_party/bazel:extra_actions_proto_py"], 44 | ) 45 | 46 | extra_action( 47 | name = "generate_link_targets_action", 48 | cmd = " ".join([ 49 | "PYTHONPATH=$$PYTHONPATH:$$PWD", 50 | "$(location :generate_link_target)", 51 | "$(EXTRA_ACTION_FILE)", 52 | "$(output $(ACTION_ID)_link_target)", 53 | ]), 54 | out_templates = ["$(ACTION_ID)_link_target"], 55 | tools = [":generate_link_target"], 56 | visibility = ["//visibility:private"], 57 | ) 58 | 59 | action_listener( 60 | name = "generate_link_targets_listener", 61 | extra_actions = [":generate_link_targets_action"], 62 | mnemonics = [ 63 | "CppLink", 64 | ], 65 | visibility = ["//visibility:public"], 66 | ) 67 | -------------------------------------------------------------------------------- /xrtl/port/linux/ui/x11_window.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "xrtl/port/linux/ui/x11_window.h" 16 | 17 | #include "xrtl/base/logging.h" 18 | 19 | namespace xrtl { 20 | namespace ui { 21 | 22 | ref_ptr Window::Create(ref_ptr message_loop) { 23 | return make_ref(message_loop); 24 | } 25 | 26 | X11Window::X11Window(ref_ptr message_loop) : Window(message_loop) { 27 | control_ = make_ref( 28 | message_loop, static_cast(this)); 29 | } 30 | 31 | X11Window::~X11Window() { control_.reset(); } 32 | 33 | std::string X11Window::title() { 34 | std::lock_guard lock(mutex_); 35 | return title_; 36 | } 37 | 38 | void X11Window::set_title(std::string title) { 39 | { 40 | std::lock_guard lock(mutex_); 41 | title_ = title; 42 | } 43 | if (control_ && control_->is_active()) { 44 | ::XStoreName(control_->display_handle(), control_->window_handle(), 45 | title.c_str()); 46 | ::XFlush(control_->display_handle()); 47 | } 48 | } 49 | 50 | ref_ptr X11Window::root_control() { 51 | return ref_ptr(control_.get()); 52 | } 53 | 54 | ref_ptr X11Window::Open() { return control_->Create(); } 55 | 56 | ref_ptr X11Window::Close() { return control_->Destroy(); } 57 | 58 | void X11Window::OnChildCreated(ref_ptr child_control) { 59 | // Set values now that we have a window. 60 | set_title(title()); 61 | } 62 | 63 | } // namespace ui 64 | } // namespace xrtl 65 | --------------------------------------------------------------------------------