├── 3rdparty ├── volk │ └── VERSION ├── gtest │ ├── VERSION │ ├── googletest │ │ ├── cmake │ │ │ ├── Config.cmake.in │ │ │ ├── gtest.pc.in │ │ │ ├── gtest_main.pc.in │ │ │ └── libgtest.la.in │ │ ├── include │ │ │ └── gtest │ │ │ │ ├── internal │ │ │ │ └── custom │ │ │ │ │ ├── README.md │ │ │ │ │ ├── gtest.h │ │ │ │ │ ├── gtest-port.h │ │ │ │ │ └── gtest-printers.h │ │ │ │ └── gtest_prod.h │ │ └── src │ │ │ ├── gtest-all.cc │ │ │ ├── gtest_main.cc │ │ │ └── gtest-assertion-result.cc │ └── CMakeLists.txt ├── vulkan │ ├── VERSION │ └── include │ │ ├── vk_video │ │ ├── vulkan_video_codecs_common.h │ │ ├── vulkan_video_codec_h265std_decode.h │ │ └── vulkan_video_codec_h264std_decode.h │ │ └── vulkan │ │ ├── vulkan_vi.h │ │ ├── vulkan_ios.h │ │ ├── vulkan_macos.h │ │ ├── vulkan_xlib_xrandr.h │ │ ├── vulkan_xlib.h │ │ ├── vulkan.h │ │ ├── vulkan_directfb.h │ │ ├── vulkan_wayland.h │ │ ├── vulkan_xcb.h │ │ ├── vulkan_ggp.h │ │ └── vk_platform.h ├── vma │ └── include │ │ └── vk_mem_alloc.cpp └── gbench │ ├── cmake │ ├── split_list.cmake │ ├── thread_safety_attributes.cpp │ ├── steady_clock.cpp │ ├── Config.cmake.in │ ├── benchmark_main.pc.in │ ├── std_regex.cpp │ ├── llvm-toolchain.cmake │ ├── gnu_posix_regex.cpp │ ├── benchmark.pc.in │ ├── posix_regex.cpp │ ├── Modules │ │ ├── FindLLVMRanLib.cmake │ │ ├── FindLLVMAr.cmake │ │ ├── FindLLVMNm.cmake │ │ └── FindPFM.cmake │ ├── pthread_affinity.cpp │ ├── GetGitVersion.cmake │ ├── GoogleTest.cmake │ ├── GoogleTest.cmake.in │ ├── CXXFeatureCheck.cmake │ └── AddCXXCompilerFlag.cmake │ ├── src │ ├── check.cc │ ├── benchmark_main.cc │ ├── colorprint.h │ ├── arraysize.h │ ├── counter.h │ ├── timers.h │ ├── statistics.h │ ├── thread_manager.h │ ├── benchmark_name.cc │ ├── complexity.h │ ├── string_util.h │ ├── counter.cc │ ├── log.h │ ├── thread_timer.h │ ├── benchmark_api_internal.h │ ├── internal_macros.h │ ├── benchmark_register.h │ └── check.h │ └── include │ └── benchmark │ └── export.h ├── src ├── directx12 │ └── directx12_guids.c ├── common │ ├── bump.h │ ├── ring.h │ ├── bump.c │ ├── pool.h │ ├── ring.c │ ├── heap.h │ └── intrinsics.h ├── null │ ├── null_internal.h │ └── null_instance.c ├── opal_internal.h ├── vulkan │ └── vulkan_platform_win32.c └── opal_internal.c ├── README.md ├── .gitignore ├── samples ├── 04_triangle │ ├── shaders │ │ ├── vulkan │ │ │ ├── main.frag.spv │ │ │ ├── main.vert.spv │ │ │ ├── main.frag.glsl │ │ │ └── main.vert.glsl │ │ ├── directx12 │ │ │ ├── main.frag.cso │ │ │ ├── main.vert.cso │ │ │ ├── main.frag.hlsl │ │ │ └── main.vert.hlsl │ │ ├── metal │ │ │ ├── main.frag.metallib │ │ │ ├── main.vert.metallib │ │ │ ├── main.vert.metal │ │ │ └── main.frag.metal │ │ └── webgpu │ │ │ ├── main.frag.wgsl │ │ │ └── main.vert.wgsl │ ├── main.wasm.html │ ├── app.h │ ├── main.wasm.cpp │ ├── main.osx.mm │ └── main.win.cpp ├── 05_rt_triangle │ ├── shaders │ │ ├── vulkan │ │ │ ├── main.rchit.spv │ │ │ ├── main.rgen.spv │ │ │ ├── main.rmiss.spv │ │ │ ├── main.rmiss.glsl │ │ │ ├── main.rchit.glsl │ │ │ └── main.rgen.glsl │ │ ├── directx12 │ │ │ ├── main.rgen.cso │ │ │ ├── main.rchit.cso │ │ │ ├── main.rmiss.cso │ │ │ ├── main.rmiss.hlsl │ │ │ ├── main.rchit.hlsl │ │ │ └── main.rgen.hlsl │ │ └── metal │ │ │ ├── main.comp.metallib │ │ │ └── main.comp.metal │ ├── main.wasm.html │ ├── main.wasm.cpp │ ├── app.h │ ├── main.osx.mm │ └── main.win.cpp ├── 06_gpu_particles │ ├── shaders │ │ ├── vulkan │ │ │ ├── emit.comp.spv │ │ │ ├── render.frag.spv │ │ │ ├── render.vert.spv │ │ │ ├── simulate.comp.spv │ │ │ ├── render.frag.glsl │ │ │ ├── render.vert.glsl │ │ │ └── emit.comp.glsl │ │ ├── directx12 │ │ │ ├── emit.comp.cso │ │ │ ├── render.frag.cso │ │ │ ├── render.vert.cso │ │ │ ├── simulate.comp.cso │ │ │ ├── render.frag.hlsl │ │ │ ├── render.vert.hlsl │ │ │ └── emit.comp.hlsl │ │ └── webgpu │ │ │ ├── render.frag.wgsl │ │ │ ├── render.vert.wgsl │ │ │ └── emit.comp.wgsl │ ├── main.wasm.html │ ├── main.wasm.cpp │ ├── main.osx.mm │ └── main.win.cpp ├── 03_textures │ ├── main.cpp │ └── CMakeLists.txt ├── 02_buffers │ ├── main.cpp │ └── CMakeLists.txt └── 01_enumerate_devices │ └── CMakeLists.txt ├── docs └── minspec.md ├── LICENSE ├── tests ├── heap │ └── CMakeLists.txt └── pool │ └── CMakeLists.txt └── benchmarks └── allocator └── CMakeLists.txt /3rdparty/volk/VERSION: -------------------------------------------------------------------------------- 1 | https://github.com/zeux/volk/tree/1.3.270 -------------------------------------------------------------------------------- /3rdparty/gtest/VERSION: -------------------------------------------------------------------------------- 1 | https://github.com/google/googletest/tree/v1.14.0 -------------------------------------------------------------------------------- /3rdparty/vulkan/VERSION: -------------------------------------------------------------------------------- 1 | https://github.com/KhronosGroup/Vulkan-Headers/tree/v1.3.270 -------------------------------------------------------------------------------- /src/directx12/directx12_guids.c: -------------------------------------------------------------------------------- 1 | #define INITGUID 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # opal 2 | Opal is a low level rendering framework that supports Vulkan / DirectX 12 / Metal / WebGPU 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # CMake specific 2 | [Bb]uild/ 3 | 4 | # VS Code specific 5 | .vscode 6 | 7 | # Mac OS specific 8 | .DS_Store -------------------------------------------------------------------------------- /3rdparty/vma/include/vk_mem_alloc.cpp: -------------------------------------------------------------------------------- 1 | #include "volk.h" 2 | 3 | #define VMA_IMPLEMENTATION 4 | #include "vk_mem_alloc.h" 5 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/split_list.cmake: -------------------------------------------------------------------------------- 1 | macro(split_list listname) 2 | string(REPLACE ";" " " ${listname} "${${listname}}") 3 | endmacro() 4 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/thread_safety_attributes.cpp: -------------------------------------------------------------------------------- 1 | #define HAVE_THREAD_SAFETY_ATTRIBUTES 2 | #include "../src/mutex.h" 3 | 4 | int main() {} 5 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/vulkan/main.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/vulkan/main.frag.spv -------------------------------------------------------------------------------- /samples/04_triangle/shaders/vulkan/main.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/vulkan/main.vert.spv -------------------------------------------------------------------------------- /samples/04_triangle/shaders/directx12/main.frag.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/directx12/main.frag.cso -------------------------------------------------------------------------------- /samples/04_triangle/shaders/directx12/main.vert.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/directx12/main.vert.cso -------------------------------------------------------------------------------- /samples/04_triangle/shaders/metal/main.frag.metallib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/metal/main.frag.metallib -------------------------------------------------------------------------------- /samples/04_triangle/shaders/metal/main.vert.metallib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/04_triangle/shaders/metal/main.vert.metallib -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rchit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/vulkan/main.rchit.spv -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rgen.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/vulkan/main.rgen.spv -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rmiss.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/vulkan/main.rmiss.spv -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rgen.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/directx12/main.rgen.cso -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/emit.comp.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/vulkan/emit.comp.spv -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rchit.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/directx12/main.rchit.cso -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rmiss.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/directx12/main.rmiss.cso -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/metal/main.comp.metallib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/05_rt_triangle/shaders/metal/main.comp.metallib -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/emit.comp.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/directx12/emit.comp.cso -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/render.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/vulkan/render.frag.spv -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/render.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/vulkan/render.vert.spv -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/simulate.comp.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/vulkan/simulate.comp.spv -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/render.frag.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/directx12/render.frag.cso -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/render.vert.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/directx12/render.vert.cso -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/simulate.comp.cso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seednull/opal/HEAD/samples/06_gpu_particles/shaders/directx12/simulate.comp.cso -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/steady_clock.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | typedef std::chrono::steady_clock Clock; 5 | Clock::time_point tp = Clock::now(); 6 | ((void)tp); 7 | } 8 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include (CMakeFindDependencyMacro) 4 | 5 | find_dependency (Threads) 6 | 7 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 8 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/benchmark_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | 3 | Name: @PROJECT_NAME@ 4 | Description: Google microbenchmark framework (with main() function) 5 | Version: @VERSION@ 6 | Requires: benchmark 7 | Libs: -L${libdir} -lbenchmark_main 8 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/vulkan/main.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec4 in_color; 4 | layout(location = 0) out vec4 out_color; 5 | 6 | void fragmentMain() 7 | { 8 | out_color.rgb = pow(in_color.rgb, vec3(1.0f / 2.2f)); 9 | out_color.a = in_color.a; 10 | } 11 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/directx12/main.frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexOutput 2 | { 3 | float4 position: SV_Position; 4 | float4 color: COLOR0; 5 | }; 6 | 7 | float4 fragmentMain(VertexOutput input): SV_Target 8 | { 9 | return float4(pow(input.color.rgb, 1.0f / 2.2f), input.color.a); 10 | } 11 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rmiss.hlsl: -------------------------------------------------------------------------------- 1 | // bindings 2 | 3 | // ray payload 4 | struct RayPayload 5 | { 6 | float3 color; 7 | }; 8 | 9 | [shader("miss")] 10 | void rayMissMain(inout RayPayload payload : SV_RayPayload) 11 | { 12 | payload.color = float3(0.4f, 0.4f, 0.4f); 13 | } 14 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/check.cc: -------------------------------------------------------------------------------- 1 | #include "check.h" 2 | 3 | namespace benchmark { 4 | namespace internal { 5 | 6 | static AbortHandlerT* handler = &std::abort; 7 | 8 | BENCHMARK_EXPORT AbortHandlerT*& GetAbortHandler() { return handler; } 9 | 10 | } // namespace internal 11 | } // namespace benchmark 12 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rmiss.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_ray_tracing : enable 3 | 4 | // bindings 5 | 6 | // ray payload 7 | layout(location = 0) rayPayloadInEXT vec3 payload_color; 8 | 9 | void rayMissMain() 10 | { 11 | payload_color = vec3(0.4f, 0.4f, 0.4f); 12 | } 13 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/vulkan/main.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec4 in_position; 4 | layout(location = 1) in vec4 in_color; 5 | 6 | layout(location = 0) out vec4 out_color; 7 | 8 | void vertexMain() 9 | { 10 | gl_Position = vec4(in_position.xyz, 1.0); 11 | out_color = in_color; 12 | } 13 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/webgpu/main.frag.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexOutput 2 | { 3 | @builtin(position) position: vec4f, 4 | @location(0) color: vec4f 5 | }; 6 | 7 | @fragment 8 | fn fragmentMain(input: VertexOutput) -> @location(0) vec4f 9 | { 10 | return vec4f(pow(input.color.rgb, vec3f(1.0 / 2.2)), input.color.a); 11 | } 12 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/std_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | const std::string str = "test0159"; 5 | std::regex re; 6 | re = std::regex("^[a-z]+[0-9]+$", 7 | std::regex_constants::extended | std::regex_constants::nosubs); 8 | return std::regex_search(str, re) ? 0 : -1; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/llvm-toolchain.cmake: -------------------------------------------------------------------------------- 1 | find_package(LLVMAr REQUIRED) 2 | set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) 3 | 4 | find_package(LLVMNm REQUIRED) 5 | set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) 6 | 7 | find_package(LLVMRanLib REQUIRED) 8 | set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) 9 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/gnu_posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/benchmark.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: Google microbenchmark framework 8 | Version: @VERSION@ 9 | 10 | Libs: -L${libdir} -lbenchmark 11 | Libs.private: -lpthread 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | regfree(&re); 12 | return ret; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/common/bump.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct Opal_Bump_t 6 | { 7 | uint8_t *data; 8 | uint32_t size; 9 | uint32_t capacity; 10 | } Opal_Bump; 11 | 12 | Opal_Result opal_bumpInitialize(Opal_Bump *bump, uint32_t capacity); 13 | Opal_Result opal_bumpShutdown(Opal_Bump *bump); 14 | 15 | uint32_t opal_bumpAlloc(Opal_Bump *bump, uint32_t size); 16 | Opal_Result opal_bumpReset(Opal_Bump *bump); 17 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/Modules/FindLLVMRanLib.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMRANLIB_EXECUTABLE 4 | NAMES llvm-ranlib 5 | DOC "The llvm-ranlib executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMRanLib 10 | DEFAULT_MSG 11 | LLVMRANLIB_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMRanLib PROPERTIES 14 | DESCRIPTION "generate index for LLVM archive" 15 | ) 16 | -------------------------------------------------------------------------------- /docs/minspec.md: -------------------------------------------------------------------------------- 1 | # Minimum Requirements 2 | 3 | ## Directx 12 4 | 5 | At least Windows 10 is required. 6 | At least D3D_FEATURE_LEVEL_11_0 is required. 7 | 8 | ## Vulkan 9 | 10 | At least Vulkan 1.1 is required. 11 | 12 | ## Metal 13 | 14 | At least iOS 18.0 is required. 15 | At least iPadOS 18.0 is required. 16 | At least Mac Catalyst 18.0 is required. 17 | At least macOS 15.0 is required. 18 | At least tvOS 18.0 is required. 19 | At least visionOS 2.0 is required. -------------------------------------------------------------------------------- /samples/04_triangle/shaders/directx12/main.vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexInput 2 | { 3 | float4 position: LOCATION0; 4 | float4 color: LOCATION1; 5 | }; 6 | 7 | struct VertexOutput 8 | { 9 | float4 position: SV_Position; 10 | float4 color: COLOR0; 11 | }; 12 | 13 | VertexOutput vertexMain(VertexInput input) 14 | { 15 | VertexOutput result; 16 | 17 | result.position = float4(input.position.xyz, 1.0f); 18 | result.color = input.color; 19 | 20 | return result; 21 | } 22 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/metal/main.vert.metal: -------------------------------------------------------------------------------- 1 | struct VertexInput 2 | { 3 | float4 position [[attribute(0)]]; 4 | float4 color [[attribute(1)]]; 5 | }; 6 | 7 | struct VertexToFragment 8 | { 9 | float4 position [[position]]; 10 | float4 color; 11 | }; 12 | 13 | [[vertex]] VertexToFragment vertexMain(VertexInput in [[stage_in]]) 14 | { 15 | VertexToFragment out; 16 | 17 | out.position = float4(in.position.xyz, 1.0f); 18 | out.color = in.color; 19 | 20 | return out; 21 | } 22 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/Modules/FindLLVMAr.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMAR_EXECUTABLE 4 | NAMES llvm-ar 5 | DOC "The llvm-ar executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMAr 10 | DEFAULT_MSG 11 | LLVMAR_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMAr PROPERTIES 14 | URL https://llvm.org/docs/CommandGuide/llvm-ar.html 15 | DESCRIPTION "create, modify, and extract from archives" 16 | ) 17 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/Modules/FindLLVMNm.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMNM_EXECUTABLE 4 | NAMES llvm-nm 5 | DOC "The llvm-nm executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMNm 10 | DEFAULT_MSG 11 | LLVMNM_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMNm PROPERTIES 14 | URL https://llvm.org/docs/CommandGuide/llvm-nm.html 15 | DESCRIPTION "list LLVM bitcode and object file’s symbol table" 16 | ) 17 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/pthread_affinity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | cpu_set_t set; 4 | CPU_ZERO(&set); 5 | for (int i = 0; i < CPU_SETSIZE; ++i) { 6 | CPU_SET(i, &set); 7 | CPU_CLR(i, &set); 8 | } 9 | pthread_t self = pthread_self(); 10 | int ret; 11 | ret = pthread_getaffinity_np(self, sizeof(set), &set); 12 | if (ret != 0) return ret; 13 | ret = pthread_setaffinity_np(self, sizeof(set), &set); 14 | if (ret != 0) return ret; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/metal/main.frag.metal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct VertexToFragment 4 | { 5 | float4 position [[position]]; 6 | float4 color; 7 | }; 8 | 9 | struct FragmentOutput 10 | { 11 | float4 color [[color(0)]]; 12 | }; 13 | 14 | [[fragment]] FragmentOutput fragmentMain(VertexToFragment in [[stage_in]]) 15 | { 16 | FragmentOutput out; 17 | 18 | out.color.rgb = metal::pow(in.color.rgb, float3(1.0f / 2.2f)); 19 | out.color.a = in.color.a; 20 | 21 | return out; 22 | } 23 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rchit.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_ray_tracing : enable 3 | 4 | // bindings 5 | 6 | // ray payload 7 | layout(location = 0) rayPayloadInEXT vec3 payload_color; 8 | 9 | // hit attributes 10 | hitAttributeEXT vec2 attribs; 11 | 12 | // entry 13 | void rayClosestHitMain() 14 | { 15 | const vec3 barycentric_coords = vec3(1.0f - attribs.x - attribs.y, attribs.x, attribs.y); 16 | 17 | payload_color = pow(barycentric_coords, vec3(1.0f / 2.2f)); 18 | } 19 | -------------------------------------------------------------------------------- /samples/04_triangle/shaders/webgpu/main.vert.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexInput 2 | { 3 | @builtin(vertex_index) index: u32, 4 | @location(0) position: vec4f, 5 | @location(1) color: vec4f 6 | }; 7 | 8 | struct VertexOutput 9 | { 10 | @builtin(position) position: vec4f, 11 | @location(0) color: vec4f 12 | }; 13 | 14 | @vertex 15 | fn vertexMain(input: VertexInput) -> VertexOutput 16 | { 17 | var out: VertexOutput; 18 | 19 | out.position = vec4(input.position.xyz, 1.0); 20 | out.color = input.color; 21 | 22 | return out; 23 | } 24 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rchit.hlsl: -------------------------------------------------------------------------------- 1 | // bindings 2 | 3 | // ray payload 4 | struct RayPayload 5 | { 6 | float3 color; 7 | }; 8 | 9 | [shader("closesthit")] 10 | void rayClosestHitMain(inout RayPayload payload : SV_RayPayload, in BuiltInTriangleIntersectionAttributes attribs : SV_IntersectionAttributes) 11 | { 12 | float2 bary = attribs.barycentrics; 13 | 14 | float3 barycentric_coords = float3(1.0f - bary.x - bary.y, bary.x, bary.y); 15 | payload.color = pow(barycentric_coords, 1.0f / 2.2f); 16 | } 17 | -------------------------------------------------------------------------------- /src/common/ring.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct Opal_Ring_t 6 | { 7 | uint8_t *data; 8 | uint32_t capacity; 9 | uint32_t size; 10 | uint32_t read; 11 | uint32_t write; 12 | } Opal_Ring; 13 | 14 | Opal_Result opal_ringInitialize(Opal_Ring *ring, uint32_t size); 15 | Opal_Result opal_ringShutdown(Opal_Ring *ring); 16 | 17 | uint32_t opal_ringGetSize(const Opal_Ring *ring); 18 | 19 | void opal_ringRead(Opal_Ring *ring, void *data, uint32_t size); 20 | void opal_ringWrite(Opal_Ring *ring, const void *data, uint32_t size); 21 | -------------------------------------------------------------------------------- /src/null/null_internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "opal_internal.h" 4 | 5 | typedef struct Null_Instance_t 6 | { 7 | Opal_InstanceTable *vtbl; 8 | char *application_name; 9 | uint32_t application_version; 10 | char *engine_name; 11 | uint32_t engine_version; 12 | } Null_Instance; 13 | 14 | typedef struct Null_Device_t 15 | { 16 | Opal_DeviceTable *vtbl; 17 | Opal_DeviceInfo info; 18 | Opal_DeviceLimits limits; 19 | } Null_Device; 20 | 21 | Opal_Result null_fillDeviceInfo(Opal_DeviceInfo *info); 22 | Opal_Result null_deviceInitialize(Null_Device *device_ptr, Null_Instance *instance_ptr); 23 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /src/opal_internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define OPAL_UNUSED(x) do { (void)(x); } while(0) 6 | 7 | Opal_Result vulkan_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance); 8 | Opal_Result directx12_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance); 9 | Opal_Result metal_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance); 10 | Opal_Result webgpu_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance); 11 | Opal_Result null_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance); 12 | 13 | uint32_t opal_evaluateDevice(const Opal_DeviceInfo *info, Opal_DeviceHint hint); -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/render.frag.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec4 in_data; 4 | layout(location = 0) out vec4 out_color; 5 | 6 | const vec3 START_COLOR = vec3(60.0f / 255.0f, 106.0f / 255.0f, 155.0f / 255.0f); 7 | const vec3 END_COLOR = vec3(57.0f / 255.0f, 218.0f / 255.0f, 155.0f / 255.0f); 8 | const float ATTENUATION_POWER = 0.01f; 9 | 10 | void fragmentMain() 11 | { 12 | vec2 uv = in_data.xy * 0.5f + vec2(0.5f); 13 | float lifetime = pow(in_data.z, 0.5f); 14 | 15 | vec3 color = mix(END_COLOR, START_COLOR, lifetime) * 0.02f; 16 | float attenuation = pow(clamp(1.0f - dot(in_data.xy, in_data.xy), 0.0f, 1.0f), ATTENUATION_POWER); 17 | 18 | out_color = vec4(color * attenuation, 1.0f); 19 | } 20 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/render.frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexToFragment 2 | { 3 | float4 data: TEXCOORD0; 4 | }; 5 | 6 | static const float3 START_COLOR = float3(60.0f / 255.0f, 106.0f / 255.0f, 155.0f / 255.0f); 7 | static const float3 END_COLOR = float3(57.0f / 255.0f, 218.0f / 255.0f, 155.0f / 255.0f); 8 | static const float ATTENUATION_POWER = 0.01f; 9 | 10 | float4 fragmentMain(VertexToFragment input): SV_Target 11 | { 12 | float2 uv = input.data.xy * 0.5f + float2(0.5f, 0.5f); 13 | float lifetime = pow(saturate(input.data.z), 0.5f); 14 | 15 | float3 color = lerp(END_COLOR, START_COLOR, lifetime) * 0.02f; 16 | float attenuation = pow(saturate(1.0f - dot(input.data.xy, input.data.xy)), ATTENUATION_POWER); 17 | 18 | return float4(color * attenuation, 1.0f); 19 | } 20 | -------------------------------------------------------------------------------- /src/vulkan/vulkan_platform_win32.c: -------------------------------------------------------------------------------- 1 | #include "vulkan_internal.h" 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | 6 | /* 7 | */ 8 | const char *vulkan_platformGetSurfaceExtension() 9 | { 10 | return VK_KHR_WIN32_SURFACE_EXTENSION_NAME; 11 | } 12 | 13 | Opal_Result vulkan_platformCreateSurface(VkInstance instance, void *handle, VkSurfaceKHR *surface) 14 | { 15 | VkWin32SurfaceCreateInfoKHR surface_info = {0}; 16 | surface_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; 17 | surface_info.hinstance = GetModuleHandle(NULL); 18 | surface_info.hwnd = (HWND)handle; 19 | 20 | VkResult result = vkCreateWin32SurfaceKHR(instance, &surface_info, NULL, surface); 21 | if (result != VK_SUCCESS) 22 | return OPAL_VULKAN_ERROR; 23 | 24 | return OPAL_SUCCESS; 25 | } 26 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/benchmark_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 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 "benchmark/benchmark.h" 16 | 17 | BENCHMARK_EXPORT int main(int, char**); 18 | BENCHMARK_MAIN(); 19 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/webgpu/render.frag.wgsl: -------------------------------------------------------------------------------- 1 | struct FragmentInput 2 | { 3 | @builtin(position) position: vec4f, 4 | @location(0) data: vec4f 5 | }; 6 | 7 | const START_COLOR: vec3f = vec3f(60.0 / 255.0, 106.0 / 255.0, 155.0 / 255.0); 8 | const END_COLOR: vec3f = vec3f(57.0 / 255.0, 218.0 / 255.0, 155.0 / 255.0); 9 | const ATTENUATION_POWER: f32 = 0.01; 10 | 11 | @fragment 12 | fn fragmentMain(input: FragmentInput) -> @location(0) vec4f 13 | { 14 | var uv: vec2f = input.data.xy * 0.5 + vec2f(0.5); 15 | var lifetime: f32 = pow(input.data.z, 0.5); 16 | 17 | var color: vec3f = mix(END_COLOR, START_COLOR, lifetime) * 0.02; 18 | var attenuation: f32 = pow(clamp(1.0 - dot(input.data.xy, input.data.xy), 0.0, 1.0), ATTENUATION_POWER); 19 | 20 | return vec4f(color * attenuation, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vk_video/vulkan_video_codecs_common.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_VIDEO_CODECS_COMMON_H_ 2 | #define VULKAN_VIDEO_CODECS_COMMON_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // vulkan_video_codecs_common is a preprocessor guard. Do not pass it to API calls. 23 | #define vulkan_video_codecs_common 1 24 | #if !defined(VK_NO_STDINT_H) 25 | #include 26 | #endif 27 | 28 | #define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ 29 | ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/colorprint.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_COLORPRINT_H_ 2 | #define BENCHMARK_COLORPRINT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace benchmark { 9 | enum LogColor { 10 | COLOR_DEFAULT, 11 | COLOR_RED, 12 | COLOR_GREEN, 13 | COLOR_YELLOW, 14 | COLOR_BLUE, 15 | COLOR_MAGENTA, 16 | COLOR_CYAN, 17 | COLOR_WHITE 18 | }; 19 | 20 | std::string FormatString(const char* msg, va_list args); 21 | std::string FormatString(const char* msg, ...); 22 | 23 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, 24 | va_list args); 25 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...); 26 | 27 | // Returns true if stdout appears to be a terminal that supports colored 28 | // output, false otherwise. 29 | bool IsColorTerminal(); 30 | 31 | } // end namespace benchmark 32 | 33 | #endif // BENCHMARK_COLORPRINT_H_ 34 | -------------------------------------------------------------------------------- /3rdparty/gtest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Note: CMake support is community-based. The maintainers do not use CMake 2 | # internally. 3 | 4 | cmake_minimum_required(VERSION 3.13) 5 | 6 | project(googletest-distribution) 7 | set(GOOGLETEST_VERSION 1.14.0) 8 | 9 | if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) 10 | set(CMAKE_CXX_EXTENSIONS OFF) 11 | endif() 12 | 13 | enable_testing() 14 | 15 | include(CMakeDependentOption) 16 | include(GNUInstallDirs) 17 | 18 | #Note that googlemock target already builds googletest 19 | option(BUILD_GMOCK "Builds the googlemock subproject" OFF) 20 | option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" OFF) 21 | option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) 22 | 23 | if(BUILD_GMOCK) 24 | add_subdirectory( googlemock ) 25 | else() 26 | add_subdirectory( googletest ) 27 | endif() 28 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/render.vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec4 in_position; 4 | 5 | layout(set = 0, binding = 1) uniform Camera 6 | { 7 | mat4 view; 8 | mat4 projection; 9 | } camera; 10 | 11 | layout(location = 0) out vec4 out_data; 12 | 13 | const float PARTICLE_SIZE = 0.005f; 14 | 15 | const vec2 VERTICES[4] = 16 | { 17 | vec2(-1.0f, -1.0f), 18 | vec2(-1.0f, 1.0f), 19 | vec2( 1.0f, -1.0f), 20 | vec2( 1.0f, 1.0f), 21 | }; 22 | 23 | void vertexMain() 24 | { 25 | float lifetime = pow(clamp(in_position.w, 0.0f, 1.0f), 0.1f); 26 | float size = PARTICLE_SIZE * lifetime; 27 | 28 | vec2 offset = VERTICES[gl_VertexIndex]; 29 | 30 | vec4 view_position = camera.view * vec4(in_position.xyz, 1.0); 31 | view_position.x += offset.x * size; 32 | view_position.y += offset.y * size; 33 | 34 | gl_Position = camera.projection * view_position; 35 | 36 | out_data = vec4(offset.x, offset.y, in_position.w, 0.0f); 37 | } 38 | -------------------------------------------------------------------------------- /samples/04_triangle/main.wasm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Opal Sample (04_triangle) 7 | 16 | 17 | 18 | 19 | 20 | 32 | {{{ SCRIPT }}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/main.wasm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Opal Sample (05_rt_triangle) 7 | 16 | 17 | 18 | 19 | 20 | 32 | {{{ SCRIPT }}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/main.wasm.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Opal Sample (06_gpu_particles) 7 | 16 | 17 | 18 | 19 | 20 | 32 | {{{ SCRIPT }}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/GetGitVersion.cmake: -------------------------------------------------------------------------------- 1 | # - Returns a version string from Git tags 2 | # 3 | # This function inspects the annotated git tags for the project and returns a string 4 | # into a CMake variable 5 | # 6 | # get_git_version() 7 | # 8 | # - Example 9 | # 10 | # include(GetGitVersion) 11 | # get_git_version(GIT_VERSION) 12 | # 13 | # Requires CMake 2.8.11+ 14 | find_package(Git) 15 | 16 | if(__get_git_version) 17 | return() 18 | endif() 19 | set(__get_git_version INCLUDED) 20 | 21 | function(get_git_version var) 22 | if(GIT_EXECUTABLE) 23 | execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 --dirty 24 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 25 | RESULT_VARIABLE status 26 | OUTPUT_VARIABLE GIT_VERSION 27 | ERROR_QUIET) 28 | if(status) 29 | set(GIT_VERSION "v0.0.0") 30 | endif() 31 | else() 32 | set(GIT_VERSION "v0.0.0") 33 | endif() 34 | 35 | set(${var} ${GIT_VERSION} PARENT_SCOPE) 36 | endfunction() 37 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/Modules/FindPFM.cmake: -------------------------------------------------------------------------------- 1 | # If successful, the following variables will be defined: 2 | # PFM_FOUND. 3 | # PFM_LIBRARIES 4 | # PFM_INCLUDE_DIRS 5 | # the following target will be defined: 6 | # PFM::libpfm 7 | 8 | include(FeatureSummary) 9 | include(FindPackageHandleStandardArgs) 10 | 11 | set_package_properties(PFM PROPERTIES 12 | URL http://perfmon2.sourceforge.net/ 13 | DESCRIPTION "A helper library to develop monitoring tools" 14 | PURPOSE "Used to program specific performance monitoring events") 15 | 16 | find_library(PFM_LIBRARY NAMES pfm) 17 | find_path(PFM_INCLUDE_DIR NAMES perfmon/pfmlib.h) 18 | 19 | find_package_handle_standard_args(PFM REQUIRED_VARS PFM_LIBRARY PFM_INCLUDE_DIR) 20 | 21 | if (PFM_FOUND AND NOT TARGET PFM::libpfm) 22 | add_library(PFM::libpfm UNKNOWN IMPORTED) 23 | set_target_properties(PFM::libpfm PROPERTIES 24 | IMPORTED_LOCATION "${PFM_LIBRARY}" 25 | INTERFACE_INCLUDE_DIRECTORIES "${PFM_INCLUDE_DIR}") 26 | endif() 27 | 28 | mark_as_advanced(PFM_LIBRARY PFM_INCLUDE_DIR) 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 SEEDØ 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 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/render.vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexInput 2 | { 3 | float4 position: LOCATION0; 4 | uint vertex_id: SV_VertexID; 5 | }; 6 | 7 | struct VertexToFragment 8 | { 9 | float4 data: TEXCOORD0; 10 | float4 position: SV_Position; 11 | }; 12 | 13 | cbuffer Camera: register(b1, space0) 14 | { 15 | float4x4 view; 16 | float4x4 projection; 17 | }; 18 | 19 | static const float PARTICLE_SIZE = 0.005f; 20 | 21 | static const float2 VERTICES[4] = 22 | { 23 | float2(-1.0f, -1.0f), 24 | float2(-1.0f, 1.0f), 25 | float2( 1.0f, -1.0f), 26 | float2( 1.0f, 1.0f) 27 | }; 28 | 29 | VertexToFragment vertexMain(VertexInput input) 30 | { 31 | float lifetime = pow(saturate(input.position.w), 0.1f); 32 | float size = PARTICLE_SIZE * lifetime; 33 | 34 | float2 offset = VERTICES[input.vertex_id]; 35 | 36 | float4 view_position = mul(view, float4(input.position.xyz, 1.0f)); 37 | view_position.x += offset.x * size; 38 | view_position.y += offset.y * size; 39 | 40 | VertexToFragment output; 41 | output.position = mul(projection, view_position); 42 | output.data = float4(offset.x, offset.y, input.position.w, 0.0f); 43 | 44 | return output; 45 | } 46 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/webgpu/render.vert.wgsl: -------------------------------------------------------------------------------- 1 | struct VertexInput 2 | { 3 | @builtin(vertex_index) index: u32, 4 | @location(0) position: vec4f 5 | }; 6 | 7 | struct VertexOutput 8 | { 9 | @builtin(position) position: vec4f, 10 | @location(0) data: vec4f 11 | }; 12 | 13 | struct Camera 14 | { 15 | view: mat4x4f, 16 | projection: mat4x4f 17 | }; 18 | 19 | const PARTICLE_SIZE: f32 = 0.005; 20 | 21 | const VERTICES = array( 22 | vec2f(-1.0f, -1.0f), 23 | vec2f(-1.0f, 1.0f), 24 | vec2f( 1.0f, -1.0f), 25 | vec2f( 1.0f, 1.0f), 26 | ); 27 | 28 | @group(0) @binding(1) var camera: Camera; 29 | 30 | @vertex 31 | fn vertexMain(input: VertexInput) -> VertexOutput 32 | { 33 | var lifetime: f32 = pow(clamp(input.position.w, 0.0, 1.0), 0.1); 34 | var size: f32 = PARTICLE_SIZE * lifetime; 35 | 36 | var offset: vec2f = VERTICES[input.index]; 37 | 38 | var view_position: vec4f = camera.view * vec4f(input.position.xyz, 1.0); 39 | view_position.x += offset.x * size; 40 | view_position.y += offset.y * size; 41 | 42 | var out: VertexOutput; 43 | out.position = camera.projection * view_position; 44 | out.data = vec4f(offset.x, offset.y, input.position.w, 0.0); 45 | 46 | return out; 47 | } 48 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/arraysize.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_ARRAYSIZE_H_ 2 | #define BENCHMARK_ARRAYSIZE_H_ 3 | 4 | #include "internal_macros.h" 5 | 6 | namespace benchmark { 7 | namespace internal { 8 | // The arraysize(arr) macro returns the # of elements in an array arr. 9 | // The expression is a compile-time constant, and therefore can be 10 | // used in defining new arrays, for example. If you use arraysize on 11 | // a pointer by mistake, you will get a compile-time error. 12 | // 13 | 14 | // This template function declaration is used in defining arraysize. 15 | // Note that the function doesn't need an implementation, as we only 16 | // use its type. 17 | template 18 | char (&ArraySizeHelper(T (&array)[N]))[N]; 19 | 20 | // That gcc wants both of these prototypes seems mysterious. VC, for 21 | // its part, can't decide which to use (another mystery). Matching of 22 | // template overloads: the final frontier. 23 | #ifndef COMPILER_MSVC 24 | template 25 | char (&ArraySizeHelper(const T (&array)[N]))[N]; 26 | #endif 27 | 28 | #define arraysize(array) (sizeof(::benchmark::internal::ArraySizeHelper(array))) 29 | 30 | } // end namespace internal 31 | } // end namespace benchmark 32 | 33 | #endif // BENCHMARK_ARRAYSIZE_H_ 34 | -------------------------------------------------------------------------------- /src/common/bump.c: -------------------------------------------------------------------------------- 1 | #include "bump.h" 2 | #include "intrinsics.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | */ 10 | Opal_Result opal_bumpInitialize(Opal_Bump *bump, uint32_t capacity) 11 | { 12 | assert(bump); 13 | assert(capacity > 0); 14 | 15 | memset(bump, 0, sizeof(Opal_Bump)); 16 | 17 | bump->capacity = capacity; 18 | bump->data = (uint8_t *)malloc(capacity); 19 | 20 | return OPAL_SUCCESS; 21 | } 22 | 23 | Opal_Result opal_bumpShutdown(Opal_Bump *bump) 24 | { 25 | assert(bump); 26 | 27 | free(bump->data); 28 | 29 | memset(bump, 0, sizeof(Opal_Bump)); 30 | 31 | return OPAL_SUCCESS; 32 | } 33 | 34 | /* 35 | */ 36 | uint32_t opal_bumpAlloc(Opal_Bump *bump, uint32_t size) 37 | { 38 | assert(bump); 39 | assert(bump->data); 40 | 41 | uint32_t new_capacity = bump->size + size; 42 | 43 | if (bump->capacity < new_capacity) 44 | { 45 | bump->data = (uint8_t *)realloc(bump->data, new_capacity); 46 | bump->capacity = new_capacity; 47 | } 48 | 49 | uint32_t offset = bump->size; 50 | bump->size += size; 51 | 52 | return offset; 53 | } 54 | 55 | Opal_Result opal_bumpReset(Opal_Bump *bump) 56 | { 57 | assert(bump); 58 | assert(bump->data); 59 | 60 | bump->size = 0; 61 | 62 | return OPAL_SUCCESS; 63 | } 64 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/counter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 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 BENCHMARK_COUNTER_H_ 16 | #define BENCHMARK_COUNTER_H_ 17 | 18 | #include "benchmark/benchmark.h" 19 | 20 | namespace benchmark { 21 | 22 | // these counter-related functions are hidden to reduce API surface. 23 | namespace internal { 24 | void Finish(UserCounters* l, IterationCount iterations, double time, 25 | double num_threads); 26 | void Increment(UserCounters* l, UserCounters const& r); 27 | bool SameNames(UserCounters const& l, UserCounters const& r); 28 | } // end namespace internal 29 | 30 | } // end namespace benchmark 31 | 32 | #endif // BENCHMARK_COUNTER_H_ 33 | -------------------------------------------------------------------------------- /samples/04_triangle/app.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | */ 7 | class Application 8 | { 9 | public: 10 | void init(void *handle, uint32_t width, uint32_t height); 11 | void shutdown(); 12 | void update(float dt); 13 | void resize(uint32_t width, uint32_t height); 14 | void render(); 15 | void present(); 16 | 17 | private: 18 | enum 19 | { 20 | IN_FLIGHT_FRAMES = 2, 21 | WAIT_TIMEOUT_MS = 1000, 22 | }; 23 | 24 | private: 25 | Opal_Instance instance {OPAL_NULL_HANDLE}; 26 | Opal_Device device {OPAL_NULL_HANDLE}; 27 | Opal_Queue queue {OPAL_NULL_HANDLE}; 28 | 29 | Opal_Buffer triangle_buffer {OPAL_NULL_HANDLE}; 30 | 31 | Opal_Shader vertex_shader {OPAL_NULL_HANDLE}; 32 | Opal_Shader fragment_shader {OPAL_NULL_HANDLE}; 33 | Opal_PipelineLayout pipeline_layout {OPAL_NULL_HANDLE}; 34 | Opal_GraphicsPipeline pipeline {OPAL_NULL_HANDLE}; 35 | 36 | Opal_Surface surface {OPAL_NULL_HANDLE}; 37 | Opal_Swapchain swapchain {OPAL_NULL_HANDLE}; 38 | Opal_Semaphore semaphore {OPAL_NULL_HANDLE}; 39 | Opal_CommandAllocator command_allocators[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE}; 40 | Opal_CommandBuffer command_buffers[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 41 | 42 | uint64_t current_frame {0}; 43 | uint64_t wait_frame {0}; 44 | 45 | uint32_t width {0}; 46 | uint32_t height {0}; 47 | }; 48 | -------------------------------------------------------------------------------- /src/common/pool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define OPAL_POOL_MAX_ELEMENTS 0x00FFFFFF 6 | #define OPAL_POOL_MAX_GENERATIONS 0xFF 7 | #define OPAL_POOL_HANDLE_NULL 0xFFFFFFFF 8 | 9 | typedef uint32_t Opal_PoolHandle; 10 | 11 | typedef struct Opal_Pool_t 12 | { 13 | uint8_t *data; 14 | uint8_t *generations; 15 | uint32_t *nexts; 16 | uint32_t *prevs; 17 | uint32_t head; 18 | uint32_t tail; 19 | 20 | uint32_t element_size; 21 | uint32_t size; 22 | uint32_t capacity; 23 | 24 | uint32_t *masks; 25 | uint32_t *indices; 26 | uint32_t num_free_indices; 27 | } Opal_Pool; 28 | 29 | Opal_Result opal_poolInitialize(Opal_Pool *pool, uint32_t element_size, uint32_t capacity); 30 | Opal_Result opal_poolShutdown(Opal_Pool *pool); 31 | 32 | Opal_PoolHandle opal_poolAddElement(Opal_Pool *pool, const void *data); 33 | Opal_Result opal_poolRemoveElement(Opal_Pool *pool, Opal_PoolHandle handle); 34 | void *opal_poolGetElement(const Opal_Pool *pool, Opal_PoolHandle handle); 35 | 36 | void *opal_poolGetElementByIndex(const Opal_Pool *pool, uint32_t index); 37 | uint32_t opal_poolGetHeadIndex(const Opal_Pool *pool); 38 | uint32_t opal_poolGetTailIndex(const Opal_Pool *pool); 39 | uint32_t opal_poolGetNextIndex(const Opal_Pool *pool, uint32_t index); 40 | uint32_t opal_poolGetPrevIndex(const Opal_Pool *pool, uint32_t index); 41 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_TIMERS_H 2 | #define BENCHMARK_TIMERS_H 3 | 4 | #include 5 | #include 6 | 7 | namespace benchmark { 8 | 9 | // Return the CPU usage of the current process 10 | double ProcessCPUUsage(); 11 | 12 | // Return the CPU usage of the children of the current process 13 | double ChildrenCPUUsage(); 14 | 15 | // Return the CPU usage of the current thread 16 | double ThreadCPUUsage(); 17 | 18 | #if defined(HAVE_STEADY_CLOCK) 19 | template 20 | struct ChooseSteadyClock { 21 | typedef std::chrono::high_resolution_clock type; 22 | }; 23 | 24 | template <> 25 | struct ChooseSteadyClock { 26 | typedef std::chrono::steady_clock type; 27 | }; 28 | #endif 29 | 30 | struct ChooseClockType { 31 | #if defined(HAVE_STEADY_CLOCK) 32 | typedef ChooseSteadyClock<>::type type; 33 | #else 34 | typedef std::chrono::high_resolution_clock type; 35 | #endif 36 | }; 37 | 38 | inline double ChronoClockNow() { 39 | typedef ChooseClockType::type ClockType; 40 | using FpSeconds = std::chrono::duration; 41 | return FpSeconds(ClockType::now().time_since_epoch()).count(); 42 | } 43 | 44 | std::string LocalDateTimeString(); 45 | 46 | } // end namespace benchmark 47 | 48 | #endif // BENCHMARK_TIMERS_H 49 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Logging: 19 | 20 | * `GTEST_LOG_(severity)` 21 | * `GTEST_CHECK_(condition)` 22 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 23 | 24 | ### Threading: 25 | 26 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 27 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 28 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 29 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 30 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 31 | * `GTEST_LOCK_EXCLUDED_(locks)` 32 | 33 | ### Underlying library support features 34 | 35 | * `GTEST_HAS_CXXABI_H_` 36 | 37 | ### Exporting API symbols: 38 | 39 | * `GTEST_API_` - Specifier for exported symbols. 40 | 41 | ## Header `gtest-printers.h` 42 | 43 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 44 | custom printer. 45 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_vi.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_VI_H_ 2 | #define VULKAN_VI_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_NN_vi_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_NN_vi_surface 1 24 | #define VK_NN_VI_SURFACE_SPEC_VERSION 1 25 | #define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" 26 | typedef VkFlags VkViSurfaceCreateFlagsNN; 27 | typedef struct VkViSurfaceCreateInfoNN { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkViSurfaceCreateFlagsNN flags; 31 | void* window; 32 | } VkViSurfaceCreateInfoNN; 33 | 34 | typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 35 | 36 | #ifndef VK_NO_PROTOTYPES 37 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN( 38 | VkInstance instance, 39 | const VkViSurfaceCreateInfoNN* pCreateInfo, 40 | const VkAllocationCallbacks* pAllocator, 41 | VkSurfaceKHR* pSurface); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_ios.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_IOS_H_ 2 | #define VULKAN_IOS_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_MVK_ios_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_MVK_ios_surface 1 24 | #define VK_MVK_IOS_SURFACE_SPEC_VERSION 3 25 | #define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" 26 | typedef VkFlags VkIOSSurfaceCreateFlagsMVK; 27 | typedef struct VkIOSSurfaceCreateInfoMVK { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkIOSSurfaceCreateFlagsMVK flags; 31 | const void* pView; 32 | } VkIOSSurfaceCreateInfoMVK; 33 | 34 | typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 35 | 36 | #ifndef VK_NO_PROTOTYPES 37 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK( 38 | VkInstance instance, 39 | const VkIOSSurfaceCreateInfoMVK* pCreateInfo, 40 | const VkAllocationCallbacks* pAllocator, 41 | VkSurfaceKHR* pSurface); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_macos.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_MACOS_H_ 2 | #define VULKAN_MACOS_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_MVK_macos_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_MVK_macos_surface 1 24 | #define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3 25 | #define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" 26 | typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; 27 | typedef struct VkMacOSSurfaceCreateInfoMVK { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkMacOSSurfaceCreateFlagsMVK flags; 31 | const void* pView; 32 | } VkMacOSSurfaceCreateInfoMVK; 33 | 34 | typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 35 | 36 | #ifndef VK_NO_PROTOTYPES 37 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK( 38 | VkInstance instance, 39 | const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, 40 | const VkAllocationCallbacks* pAllocator, 41 | VkSurfaceKHR* pSurface); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_xlib_xrandr.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_XLIB_XRANDR_H_ 2 | #define VULKAN_XLIB_XRANDR_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_EXT_acquire_xlib_display is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_EXT_acquire_xlib_display 1 24 | #define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 25 | #define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" 26 | typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); 27 | typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay); 28 | 29 | #ifndef VK_NO_PROTOTYPES 30 | VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT( 31 | VkPhysicalDevice physicalDevice, 32 | Display* dpy, 33 | VkDisplayKHR display); 34 | 35 | VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT( 36 | VkPhysicalDevice physicalDevice, 37 | Display* dpy, 38 | RROutput rrOutput, 39 | VkDisplayKHR* pDisplay); 40 | #endif 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/statistics.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Ismael Jimenez Martinez. All rights reserved. 2 | // Copyright 2017 Roman Lebedev. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #ifndef STATISTICS_H_ 17 | #define STATISTICS_H_ 18 | 19 | #include 20 | 21 | #include "benchmark/benchmark.h" 22 | 23 | namespace benchmark { 24 | 25 | // Return a vector containing the mean, median and standard deviation 26 | // information (and any user-specified info) for the specified list of reports. 27 | // If 'reports' contains less than two non-errored runs an empty vector is 28 | // returned 29 | BENCHMARK_EXPORT 30 | std::vector ComputeStats( 31 | const std::vector& reports); 32 | 33 | BENCHMARK_EXPORT 34 | double StatisticsMean(const std::vector& v); 35 | BENCHMARK_EXPORT 36 | double StatisticsMedian(const std::vector& v); 37 | BENCHMARK_EXPORT 38 | double StatisticsStdDev(const std::vector& v); 39 | BENCHMARK_EXPORT 40 | double StatisticsCV(const std::vector& v); 41 | 42 | } // end namespace benchmark 43 | 44 | #endif // STATISTICS_H_ 45 | -------------------------------------------------------------------------------- /3rdparty/gbench/include/benchmark/export.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_EXPORT_H 2 | #define BENCHMARK_EXPORT_H 3 | 4 | #if defined(_WIN32) 5 | #define EXPORT_ATTR __declspec(dllexport) 6 | #define IMPORT_ATTR __declspec(dllimport) 7 | #define NO_EXPORT_ATTR 8 | #define DEPRECATED_ATTR __declspec(deprecated) 9 | #else // _WIN32 10 | #define EXPORT_ATTR __attribute__((visibility("default"))) 11 | #define IMPORT_ATTR __attribute__((visibility("default"))) 12 | #define NO_EXPORT_ATTR __attribute__((visibility("hidden"))) 13 | #define DEPRECATE_ATTR __attribute__((__deprecated__)) 14 | #endif // _WIN32 15 | 16 | #ifdef BENCHMARK_STATIC_DEFINE 17 | #define BENCHMARK_EXPORT 18 | #define BENCHMARK_NO_EXPORT 19 | #else // BENCHMARK_STATIC_DEFINE 20 | #ifndef BENCHMARK_EXPORT 21 | #ifdef benchmark_EXPORTS 22 | /* We are building this library */ 23 | #define BENCHMARK_EXPORT EXPORT_ATTR 24 | #else // benchmark_EXPORTS 25 | /* We are using this library */ 26 | #define BENCHMARK_EXPORT IMPORT_ATTR 27 | #endif // benchmark_EXPORTS 28 | #endif // !BENCHMARK_EXPORT 29 | 30 | #ifndef BENCHMARK_NO_EXPORT 31 | #define BENCHMARK_NO_EXPORT NO_EXPORT_ATTR 32 | #endif // !BENCHMARK_NO_EXPORT 33 | #endif // BENCHMARK_STATIC_DEFINE 34 | 35 | #ifndef BENCHMARK_DEPRECATED 36 | #define BENCHMARK_DEPRECATED DEPRECATE_ATTR 37 | #endif // BENCHMARK_DEPRECATED 38 | 39 | #ifndef BENCHMARK_DEPRECATED_EXPORT 40 | #define BENCHMARK_DEPRECATED_EXPORT BENCHMARK_EXPORT BENCHMARK_DEPRECATED 41 | #endif // BENCHMARK_DEPRECATED_EXPORT 42 | 43 | #ifndef BENCHMARK_DEPRECATED_NO_EXPORT 44 | #define BENCHMARK_DEPRECATED_NO_EXPORT BENCHMARK_NO_EXPORT BENCHMARK_DEPRECATED 45 | #endif // BENCHMARK_DEPRECATED_EXPORT 46 | 47 | #endif /* BENCHMARK_EXPORT_H */ 48 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/vulkan/main.rgen.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_ray_tracing : enable 3 | 4 | #define DEG2RAD 0.0174532925f 5 | 6 | // bindings 7 | layout(set = 0, binding = 0) uniform Camera 8 | { 9 | vec4 position; 10 | vec4 direction; 11 | } camera; 12 | 13 | layout(set = 0, binding = 1) uniform accelerationStructureEXT tlas; 14 | layout(set = 0, binding = 2, rgba8) uniform image2D image; 15 | 16 | // ray payload 17 | layout(location = 0) rayPayloadEXT vec3 payload_color; 18 | 19 | // entry 20 | void rayGenerationMain() 21 | { 22 | // uv 23 | const vec2 center = vec2(gl_LaunchIDEXT.xy) + vec2(0.5f); 24 | const float aspect = float(gl_LaunchSizeEXT.x) / gl_LaunchSizeEXT.y; 25 | const float fov = 60.0f; 26 | const float focal_length = 1 / (2.0f * tan(fov * DEG2RAD * 0.5f)); 27 | 28 | vec2 ndc = center / vec2(gl_LaunchSizeEXT.xy) * 2.0f - vec2(1.0f); 29 | ndc.x *= aspect; 30 | 31 | 32 | // gen 33 | vec3 origin_ws = camera.position.xyz; 34 | 35 | vec3 forward = camera.direction.xyz; 36 | vec3 up = vec3(0.0f, 0.0f, 1.0f); 37 | vec3 right = normalize(cross(forward, up)); 38 | up = normalize(cross(right, forward)); 39 | 40 | vec3 direction_ws = normalize(forward * focal_length + up * ndc.y + right * ndc.x); 41 | 42 | // trace 43 | payload_color = vec3(0.0f); 44 | 45 | const float tmin = 0.001f; 46 | const float tmax = 10000.0f; 47 | 48 | const uint ray_type = 0; 49 | const uint num_ray_types = 0; 50 | const uint miss_index = 0; 51 | 52 | traceRayEXT(tlas, gl_RayFlagsOpaqueEXT, 0xff, ray_type, num_ray_types, miss_index, origin_ws, tmin, direction_ws, tmax, 0); 53 | 54 | // store 55 | imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(payload_color, 1.0)); 56 | } 57 | -------------------------------------------------------------------------------- /samples/03_textures/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void testTextures(Opal_Device device) 6 | { 7 | Opal_Texture textures[2] = {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 8 | 9 | Opal_TextureDesc desc = 10 | { 11 | OPAL_TEXTURE_TYPE_2D, 12 | OPAL_TEXTURE_FORMAT_RGBA8_UNORM, 13 | 128, 14 | 128, 15 | 1, 16 | 1, 17 | 1, 18 | OPAL_SAMPLES_1, 19 | OPAL_ALLOCATION_HINT_AUTO, 20 | (Opal_TextureUsageFlags)(OPAL_TEXTURE_USAGE_FRAGMENT_SHADER_SAMPLED | OPAL_TEXTURE_USAGE_FRAMEBUFFER_ATTACHMENT), 21 | }; 22 | 23 | Opal_Result result = opalCreateTexture(device, &desc, &textures[0]); 24 | assert(result == OPAL_SUCCESS); 25 | 26 | result = opalCreateTexture(device, &desc, &textures[1]); 27 | assert(result == OPAL_SUCCESS); 28 | 29 | result = opalDestroyTexture(device, textures[0]); 30 | assert(result == OPAL_SUCCESS); 31 | 32 | result = opalDestroyTexture(device, textures[1]); 33 | assert(result == OPAL_SUCCESS); 34 | } 35 | 36 | int main() 37 | { 38 | Opal_Instance instance = OPAL_NULL_HANDLE; 39 | 40 | Opal_InstanceDesc instance_desc = 41 | { 42 | "03_textures", 43 | "Opal", 44 | 0, 45 | 0, 46 | OPAL_DEFAULT_HEAP_SIZE, 47 | OPAL_DEFAULT_HEAP_ALLOCATIONS, 48 | OPAL_DEFAULT_HEAPS, 49 | }; 50 | 51 | Opal_Result result = opalCreateInstance(OPAL_API_AUTO, &instance_desc, &instance); 52 | assert(result == OPAL_SUCCESS); 53 | 54 | Opal_Device device = OPAL_NULL_HANDLE; 55 | result = opalCreateDefaultDevice(instance, OPAL_DEVICE_HINT_DEFAULT, &device); 56 | assert(result == OPAL_SUCCESS); 57 | 58 | testTextures(device); 59 | 60 | result = opalDestroyDevice(device); 61 | assert(result == OPAL_SUCCESS); 62 | 63 | result = opalDestroyInstance(instance); 64 | assert(result == OPAL_SUCCESS); 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/thread_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_THREAD_MANAGER_H 2 | #define BENCHMARK_THREAD_MANAGER_H 3 | 4 | #include 5 | 6 | #include "benchmark/benchmark.h" 7 | #include "mutex.h" 8 | 9 | namespace benchmark { 10 | namespace internal { 11 | 12 | class ThreadManager { 13 | public: 14 | explicit ThreadManager(int num_threads) 15 | : alive_threads_(num_threads), start_stop_barrier_(num_threads) {} 16 | 17 | Mutex& GetBenchmarkMutex() const RETURN_CAPABILITY(benchmark_mutex_) { 18 | return benchmark_mutex_; 19 | } 20 | 21 | bool StartStopBarrier() EXCLUDES(end_cond_mutex_) { 22 | return start_stop_barrier_.wait(); 23 | } 24 | 25 | void NotifyThreadComplete() EXCLUDES(end_cond_mutex_) { 26 | start_stop_barrier_.removeThread(); 27 | if (--alive_threads_ == 0) { 28 | MutexLock lock(end_cond_mutex_); 29 | end_condition_.notify_all(); 30 | } 31 | } 32 | 33 | void WaitForAllThreads() EXCLUDES(end_cond_mutex_) { 34 | MutexLock lock(end_cond_mutex_); 35 | end_condition_.wait(lock.native_handle(), 36 | [this]() { return alive_threads_ == 0; }); 37 | } 38 | 39 | struct Result { 40 | IterationCount iterations = 0; 41 | double real_time_used = 0; 42 | double cpu_time_used = 0; 43 | double manual_time_used = 0; 44 | int64_t complexity_n = 0; 45 | std::string report_label_; 46 | std::string skip_message_; 47 | internal::Skipped skipped_ = internal::NotSkipped; 48 | UserCounters counters; 49 | }; 50 | GUARDED_BY(GetBenchmarkMutex()) Result results; 51 | 52 | private: 53 | mutable Mutex benchmark_mutex_; 54 | std::atomic alive_threads_; 55 | Barrier start_stop_barrier_; 56 | Mutex end_cond_mutex_; 57 | Condition end_condition_; 58 | }; 59 | 60 | } // namespace internal 61 | } // namespace benchmark 62 | 63 | #endif // BENCHMARK_THREAD_MANAGER_H 64 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/directx12/main.rgen.hlsl: -------------------------------------------------------------------------------- 1 | #define DEG2RAD 0.0174532925f 2 | 3 | // bindings 4 | struct Camera 5 | { 6 | float4 position; 7 | float4 direction; 8 | }; 9 | 10 | cbuffer CameraBuffer : register(b0, space0) 11 | { 12 | Camera camera; 13 | }; 14 | 15 | RaytracingAccelerationStructure tlas : register(t1, space0); 16 | RWTexture2D image : register(u2, space0); 17 | 18 | // Ray payload 19 | struct RayPayload 20 | { 21 | float3 color; 22 | }; 23 | 24 | [shader("raygeneration")] 25 | void rayGenerationMain() 26 | { 27 | // uv 28 | const uint2 launch_id = DispatchRaysIndex().xy; 29 | const uint2 launch_size = DispatchRaysDimensions().xy; 30 | const float aspect = float(launch_size.x) / launch_size.y; 31 | const float fov = 60.0f; 32 | const float focal_length = 1 / (2.0f * tan(fov * DEG2RAD * 0.5f)); 33 | 34 | const float2 center = launch_id + 0.5f; 35 | float2 ndc = (center / launch_size) * 2.0f - 1.0f; 36 | ndc.x *= aspect; 37 | 38 | // gen 39 | float3 origin_ws = camera.position.xyz; 40 | 41 | float3 forward = camera.direction.xyz; 42 | float3 up = float3(0.0f, 0.0f, 1.0f); 43 | float3 right = normalize(cross(forward, up)); 44 | up = normalize(cross(right, forward)); 45 | 46 | float3 direction_ws = normalize(forward * focal_length + up * ndc.y + right * ndc.x); 47 | 48 | // trace 49 | RayPayload payload; 50 | payload.color = float3(0.0f, 0.0f, 0.0f); 51 | 52 | const float tmin = 0.001f; 53 | const float tmax = 10000.0f; 54 | 55 | const uint ray_type = 0; 56 | const uint num_ray_types = 0; 57 | const uint miss_index = 0; 58 | 59 | RayDesc desc; 60 | desc.Origin = origin_ws; 61 | desc.TMin = tmin; 62 | desc.Direction = direction_ws; 63 | desc.TMax = tmax; 64 | 65 | TraceRay(tlas, RAY_FLAG_FORCE_OPAQUE, 0xFF, ray_type, num_ray_types, miss_index, desc, payload); 66 | 67 | // store 68 | image[launch_id] = float4(payload.color, 1.0f); 69 | } 70 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/benchmark_name.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 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 | namespace benchmark { 18 | 19 | namespace { 20 | 21 | // Compute the total size of a pack of std::strings 22 | size_t size_impl() { return 0; } 23 | 24 | template 25 | size_t size_impl(const Head& head, const Tail&... tail) { 26 | return head.size() + size_impl(tail...); 27 | } 28 | 29 | // Join a pack of std::strings using a delimiter 30 | // TODO: use absl::StrJoin 31 | void join_impl(std::string&, char) {} 32 | 33 | template 34 | void join_impl(std::string& s, const char delimiter, const Head& head, 35 | const Tail&... tail) { 36 | if (!s.empty() && !head.empty()) { 37 | s += delimiter; 38 | } 39 | 40 | s += head; 41 | 42 | join_impl(s, delimiter, tail...); 43 | } 44 | 45 | template 46 | std::string join(char delimiter, const Ts&... ts) { 47 | std::string s; 48 | s.reserve(sizeof...(Ts) + size_impl(ts...)); 49 | join_impl(s, delimiter, ts...); 50 | return s; 51 | } 52 | } // namespace 53 | 54 | BENCHMARK_EXPORT 55 | std::string BenchmarkName::str() const { 56 | return join('/', function_name, args, min_time, min_warmup_time, iterations, 57 | repetitions, time_type, threads); 58 | } 59 | } // namespace benchmark 60 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /samples/02_buffers/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void testBuffers(Opal_Device device) 6 | { 7 | Opal_Buffer buffers[2] = {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 8 | void *ptrs[2] = {nullptr, nullptr}; 9 | 10 | Opal_BufferDesc desc = 11 | { 12 | 16, 13 | OPAL_ALLOCATION_MEMORY_TYPE_UPLOAD, 14 | OPAL_ALLOCATION_HINT_AUTO, 15 | OPAL_BUFFER_USAGE_COPY_SRC, 16 | OPAL_BUFFER_STATE_GENERIC_READ, 17 | }; 18 | 19 | Opal_Result result = opalCreateBuffer(device, &desc, &buffers[0]); 20 | assert(result == OPAL_SUCCESS); 21 | 22 | result = opalCreateBuffer(device, &desc, &buffers[1]); 23 | assert(result == OPAL_SUCCESS); 24 | 25 | result = opalMapBuffer(device, buffers[0], &ptrs[0]); 26 | assert(result == OPAL_SUCCESS); 27 | 28 | result = opalMapBuffer(device, buffers[1], &ptrs[1]); 29 | assert(result == OPAL_SUCCESS); 30 | 31 | uint32_t data_0 = 42; 32 | uint32_t data_1 = 0xDEADBEEF; 33 | memcpy(ptrs[0], &data_0, sizeof(uint32_t)); 34 | memcpy(ptrs[1], &data_1, sizeof(uint32_t)); 35 | 36 | result = opalDestroyBuffer(device, buffers[0]); 37 | assert(result == OPAL_SUCCESS); 38 | 39 | result = opalDestroyBuffer(device, buffers[1]); 40 | assert(result == OPAL_SUCCESS); 41 | } 42 | 43 | int main() 44 | { 45 | Opal_Instance instance = OPAL_NULL_HANDLE; 46 | 47 | Opal_InstanceDesc instance_desc = 48 | { 49 | "02_buffers", 50 | "Opal", 51 | 0, 52 | 0, 53 | OPAL_DEFAULT_HEAP_SIZE, 54 | OPAL_DEFAULT_HEAP_ALLOCATIONS, 55 | OPAL_DEFAULT_HEAPS, 56 | }; 57 | 58 | Opal_Result result = opalCreateInstance(OPAL_API_AUTO, &instance_desc, &instance); 59 | assert(result == OPAL_SUCCESS); 60 | 61 | Opal_Device device = OPAL_NULL_HANDLE; 62 | result = opalCreateDefaultDevice(instance, OPAL_DEVICE_HINT_DEFAULT, &device); 63 | assert(result == OPAL_SUCCESS); 64 | 65 | testBuffers(device); 66 | 67 | result = opalDestroyDevice(device); 68 | assert(result == OPAL_SUCCESS); 69 | 70 | result = opalDestroyInstance(instance); 71 | assert(result == OPAL_SUCCESS); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /src/common/ring.c: -------------------------------------------------------------------------------- 1 | #include "ring.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | Opal_Result opal_ringInitialize(Opal_Ring *ring, uint32_t size) 8 | { 9 | assert(ring); 10 | assert(size > 0); 11 | 12 | ring->data = (uint8_t *)malloc(size); 13 | ring->capacity = size; 14 | ring->size = 0; 15 | ring->read = 0; 16 | ring->write = 0; 17 | 18 | return OPAL_SUCCESS; 19 | } 20 | 21 | Opal_Result opal_ringShutdown(Opal_Ring *ring) 22 | { 23 | assert(ring); 24 | free(ring->data); 25 | 26 | return OPAL_SUCCESS; 27 | } 28 | 29 | uint32_t opal_ringGetSize(const Opal_Ring *ring) 30 | { 31 | assert(ring); 32 | return ring->size; 33 | } 34 | 35 | void opal_ringRead(Opal_Ring *ring, void *data, uint32_t size) 36 | { 37 | assert(ring); 38 | assert(ring->size >= size); 39 | assert(data); 40 | 41 | if (size == 0) 42 | return; 43 | 44 | uint8_t *begin_ptr = ring->data + ring->read; 45 | 46 | ring->read += size; 47 | ring->read %= ring->capacity; 48 | ring->size -= size; 49 | 50 | uint8_t *end_ptr = ring->data + ring->read; 51 | 52 | if (begin_ptr < end_ptr) 53 | memcpy(data, begin_ptr, size); 54 | else 55 | { 56 | uint32_t remainder = size - ring->read; 57 | memcpy(data, begin_ptr, remainder); 58 | 59 | if (ring->read > 0) 60 | memcpy((uint8_t *)data + remainder, ring->data, ring->read); 61 | } 62 | } 63 | 64 | void opal_ringWrite(Opal_Ring *ring, const void *data, uint32_t size) 65 | { 66 | if (size == 0) 67 | return; 68 | 69 | assert(ring); 70 | assert(ring->size + size <= ring->capacity); 71 | assert(data); 72 | 73 | uint8_t *begin_ptr = ring->data + ring->write; 74 | 75 | ring->write += size; 76 | ring->write %= ring->capacity; 77 | ring->size += size; 78 | 79 | uint8_t *end_ptr = ring->data + ring->write; 80 | 81 | if (begin_ptr < end_ptr) 82 | memcpy(begin_ptr, data, size); 83 | else 84 | { 85 | uint32_t remainder = size - ring->write; 86 | memcpy(begin_ptr, data, remainder); 87 | 88 | if (ring->write > 0) 89 | memcpy(ring->data, (uint8_t *)data + remainder, ring->write); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_xlib.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_XLIB_H_ 2 | #define VULKAN_XLIB_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_KHR_xlib_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_KHR_xlib_surface 1 24 | #define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 25 | #define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" 26 | typedef VkFlags VkXlibSurfaceCreateFlagsKHR; 27 | typedef struct VkXlibSurfaceCreateInfoKHR { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkXlibSurfaceCreateFlagsKHR flags; 31 | Display* dpy; 32 | Window window; 33 | } VkXlibSurfaceCreateInfoKHR; 34 | 35 | typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 36 | typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); 37 | 38 | #ifndef VK_NO_PROTOTYPES 39 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( 40 | VkInstance instance, 41 | const VkXlibSurfaceCreateInfoKHR* pCreateInfo, 42 | const VkAllocationCallbacks* pAllocator, 43 | VkSurfaceKHR* pSurface); 44 | 45 | VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( 46 | VkPhysicalDevice physicalDevice, 47 | uint32_t queueFamilyIndex, 48 | Display* dpy, 49 | VisualID visualID); 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_H_ 2 | #define VULKAN_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | #include "vk_platform.h" 11 | #include "vulkan_core.h" 12 | 13 | #ifdef VK_USE_PLATFORM_ANDROID_KHR 14 | #include "vulkan_android.h" 15 | #endif 16 | 17 | #ifdef VK_USE_PLATFORM_FUCHSIA 18 | #include 19 | #include "vulkan_fuchsia.h" 20 | #endif 21 | 22 | #ifdef VK_USE_PLATFORM_IOS_MVK 23 | #include "vulkan_ios.h" 24 | #endif 25 | 26 | 27 | #ifdef VK_USE_PLATFORM_MACOS_MVK 28 | #include "vulkan_macos.h" 29 | #endif 30 | 31 | #ifdef VK_USE_PLATFORM_METAL_EXT 32 | #include "vulkan_metal.h" 33 | #endif 34 | 35 | #ifdef VK_USE_PLATFORM_VI_NN 36 | #include "vulkan_vi.h" 37 | #endif 38 | 39 | 40 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR 41 | #include "vulkan_wayland.h" 42 | #endif 43 | 44 | 45 | #ifdef VK_USE_PLATFORM_WIN32_KHR 46 | #include 47 | #include "vulkan_win32.h" 48 | #endif 49 | 50 | 51 | #ifdef VK_USE_PLATFORM_XCB_KHR 52 | #include 53 | #include "vulkan_xcb.h" 54 | #endif 55 | 56 | 57 | #ifdef VK_USE_PLATFORM_XLIB_KHR 58 | #include 59 | #include "vulkan_xlib.h" 60 | #endif 61 | 62 | 63 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT 64 | #include 65 | #include "vulkan_directfb.h" 66 | #endif 67 | 68 | 69 | #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT 70 | #include 71 | #include 72 | #include "vulkan_xlib_xrandr.h" 73 | #endif 74 | 75 | 76 | #ifdef VK_USE_PLATFORM_GGP 77 | #include 78 | #include "vulkan_ggp.h" 79 | #endif 80 | 81 | 82 | #ifdef VK_USE_PLATFORM_SCREEN_QNX 83 | #include 84 | #include "vulkan_screen.h" 85 | #endif 86 | 87 | 88 | #ifdef VK_USE_PLATFORM_SCI 89 | #include 90 | #include 91 | #include "vulkan_sci.h" 92 | #endif 93 | 94 | 95 | #ifdef VK_ENABLE_BETA_EXTENSIONS 96 | #include "vulkan_beta.h" 97 | #endif 98 | 99 | #endif // VULKAN_H_ 100 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_directfb.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_DIRECTFB_H_ 2 | #define VULKAN_DIRECTFB_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_EXT_directfb_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_EXT_directfb_surface 1 24 | #define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1 25 | #define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface" 26 | typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT; 27 | typedef struct VkDirectFBSurfaceCreateInfoEXT { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkDirectFBSurfaceCreateFlagsEXT flags; 31 | IDirectFB* dfb; 32 | IDirectFBSurface* surface; 33 | } VkDirectFBSurfaceCreateInfoEXT; 34 | 35 | typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 36 | typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb); 37 | 38 | #ifndef VK_NO_PROTOTYPES 39 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT( 40 | VkInstance instance, 41 | const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, 42 | const VkAllocationCallbacks* pAllocator, 43 | VkSurfaceKHR* pSurface); 44 | 45 | VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT( 46 | VkPhysicalDevice physicalDevice, 47 | uint32_t queueFamilyIndex, 48 | IDirectFB* dfb); 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_wayland.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_WAYLAND_H_ 2 | #define VULKAN_WAYLAND_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_KHR_wayland_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_KHR_wayland_surface 1 24 | #define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 25 | #define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" 26 | typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; 27 | typedef struct VkWaylandSurfaceCreateInfoKHR { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkWaylandSurfaceCreateFlagsKHR flags; 31 | struct wl_display* display; 32 | struct wl_surface* surface; 33 | } VkWaylandSurfaceCreateInfoKHR; 34 | 35 | typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 36 | typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); 37 | 38 | #ifndef VK_NO_PROTOTYPES 39 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( 40 | VkInstance instance, 41 | const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, 42 | const VkAllocationCallbacks* pAllocator, 43 | VkSurfaceKHR* pSurface); 44 | 45 | VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( 46 | VkPhysicalDevice physicalDevice, 47 | uint32_t queueFamilyIndex, 48 | struct wl_display* display); 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_xcb.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_XCB_H_ 2 | #define VULKAN_XCB_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_KHR_xcb_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_KHR_xcb_surface 1 24 | #define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 25 | #define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" 26 | typedef VkFlags VkXcbSurfaceCreateFlagsKHR; 27 | typedef struct VkXcbSurfaceCreateInfoKHR { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkXcbSurfaceCreateFlagsKHR flags; 31 | xcb_connection_t* connection; 32 | xcb_window_t window; 33 | } VkXcbSurfaceCreateInfoKHR; 34 | 35 | typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 36 | typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); 37 | 38 | #ifndef VK_NO_PROTOTYPES 39 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( 40 | VkInstance instance, 41 | const VkXcbSurfaceCreateInfoKHR* pCreateInfo, 42 | const VkAllocationCallbacks* pAllocator, 43 | VkSurfaceKHR* pSurface); 44 | 45 | VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( 46 | VkPhysicalDevice physicalDevice, 47 | uint32_t queueFamilyIndex, 48 | xcb_connection_t* connection, 49 | xcb_visualid_t visual_id); 50 | #endif 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vulkan_ggp.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_GGP_H_ 2 | #define VULKAN_GGP_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // VK_GGP_stream_descriptor_surface is a preprocessor guard. Do not pass it to API calls. 23 | #define VK_GGP_stream_descriptor_surface 1 24 | #define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1 25 | #define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface" 26 | typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP; 27 | typedef struct VkStreamDescriptorSurfaceCreateInfoGGP { 28 | VkStructureType sType; 29 | const void* pNext; 30 | VkStreamDescriptorSurfaceCreateFlagsGGP flags; 31 | GgpStreamDescriptor streamDescriptor; 32 | } VkStreamDescriptorSurfaceCreateInfoGGP; 33 | 34 | typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 35 | 36 | #ifndef VK_NO_PROTOTYPES 37 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP( 38 | VkInstance instance, 39 | const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, 40 | const VkAllocationCallbacks* pAllocator, 41 | VkSurfaceKHR* pSurface); 42 | #endif 43 | 44 | 45 | // VK_GGP_frame_token is a preprocessor guard. Do not pass it to API calls. 46 | #define VK_GGP_frame_token 1 47 | #define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1 48 | #define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token" 49 | typedef struct VkPresentFrameTokenGGP { 50 | VkStructureType sType; 51 | const void* pNext; 52 | GgpFrameToken frameToken; 53 | } VkPresentFrameTokenGGP; 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/common/heap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define OPAL_MANTISSA_BITS 3 6 | #define OPAL_MANTISSA_MAX 0x00000008 7 | #define OPAL_MANTISSA_MASK 0x00000007 8 | 9 | #define OPAL_EXPONENT_BITS 5 10 | #define OPAL_EXPONENT_MAX 0x00000020 11 | 12 | #define OPAL_NUM_SPARSE_BINS OPAL_EXPONENT_MAX 13 | #define OPAL_NUM_LINEAR_BINS OPAL_MANTISSA_MAX 14 | #define OPAL_NUM_BINS OPAL_NUM_SPARSE_BINS * OPAL_NUM_LINEAR_BINS 15 | 16 | #define OPAL_NODE_INDEX_NULL 0xFFFFFFFF 17 | #define OPAL_LINEAR_BIN_INDEX_NULL 0xFF 18 | 19 | typedef uint8_t Opal_BinIndex; 20 | typedef uint32_t Opal_NodeIndex; 21 | 22 | typedef struct Opal_HeapAllocation_t 23 | { 24 | uint32_t offset; 25 | Opal_NodeIndex metadata; 26 | } Opal_HeapAllocation; 27 | 28 | typedef struct Opal_HeapNode_t 29 | { 30 | uint32_t offset; 31 | uint32_t size; 32 | Opal_NodeIndex next_bin; 33 | Opal_NodeIndex prev_bin; 34 | Opal_NodeIndex next_neighbour; 35 | Opal_NodeIndex prev_neighbour; 36 | uint8_t used; 37 | } Opal_HeapNode; 38 | 39 | typedef struct Opal_Heap_t 40 | { 41 | uint32_t used_sparse_bins; 42 | uint8_t used_linear_bins[OPAL_NUM_SPARSE_BINS]; 43 | Opal_NodeIndex bins[OPAL_NUM_BINS]; 44 | Opal_HeapNode *nodes; 45 | Opal_NodeIndex *free_indices; 46 | uint32_t num_nodes; 47 | uint32_t num_free_nodes; 48 | uint32_t size; 49 | } Opal_Heap; 50 | 51 | Opal_Result opal_heapInitialize(Opal_Heap *heap, uint32_t size, uint32_t max_allocations); 52 | Opal_Result opal_heapShutdown(Opal_Heap *heap); 53 | 54 | Opal_Result opal_heapAlloc(Opal_Heap *heap, uint32_t size, Opal_HeapAllocation *allocation); 55 | Opal_Result opal_heapAllocAligned(Opal_Heap *heap, uint32_t size, uint32_t alignment, Opal_HeapAllocation *allocation); 56 | 57 | Opal_Result opal_heapStageAlloc(const Opal_Heap *heap, uint32_t size, Opal_NodeIndex *node_index, uint32_t *offset); 58 | Opal_Result opal_heapStageAllocAligned(const Opal_Heap *heap, uint32_t size, uint32_t alignment, Opal_NodeIndex *node_index, uint32_t *offset); 59 | Opal_Result opal_heapCommitAlloc(Opal_Heap *heap, Opal_NodeIndex node_index, uint32_t offset, uint32_t size); 60 | 61 | Opal_Result opal_heapFree(Opal_Heap *heap, Opal_HeapAllocation allocation); 62 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/complexity.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Ismael Jimenez Martinez. All rights reserved. 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 | // Source project : https://github.com/ismaelJimenez/cpp.leastsq 16 | // Adapted to be used with google benchmark 17 | 18 | #ifndef COMPLEXITY_H_ 19 | #define COMPLEXITY_H_ 20 | 21 | #include 22 | #include 23 | 24 | #include "benchmark/benchmark.h" 25 | 26 | namespace benchmark { 27 | 28 | // Return a vector containing the bigO and RMS information for the specified 29 | // list of reports. If 'reports.size() < 2' an empty vector is returned. 30 | std::vector ComputeBigO( 31 | const std::vector& reports); 32 | 33 | // This data structure will contain the result returned by MinimalLeastSq 34 | // - coef : Estimated coefficient for the high-order term as 35 | // interpolated from data. 36 | // - rms : Normalized Root Mean Squared Error. 37 | // - complexity : Scalability form (e.g. oN, oNLogN). In case a scalability 38 | // form has been provided to MinimalLeastSq this will return 39 | // the same value. In case BigO::oAuto has been selected, this 40 | // parameter will return the best fitting curve detected. 41 | 42 | struct LeastSq { 43 | LeastSq() : coef(0.0), rms(0.0), complexity(oNone) {} 44 | 45 | double coef; 46 | double rms; 47 | BigO complexity; 48 | }; 49 | 50 | // Function to return an string for the calculated complexity 51 | std::string GetBigOString(BigO complexity); 52 | 53 | } // end namespace benchmark 54 | 55 | #endif // COMPLEXITY_H_ 56 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/shaders/metal/main.comp.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | using namespace raytracing; 6 | 7 | constant float DEG2RAD = 0.0174532925f; 8 | 9 | struct Camera 10 | { 11 | float4 position; 12 | float4 direction; 13 | }; 14 | 15 | struct RaytraceBindings 16 | { 17 | constant Camera& camera [[id(0)]]; 18 | instance_acceleration_structure tlas [[id(1)]]; 19 | texture2d image [[id(2)]]; 20 | }; 21 | 22 | kernel void computeMain( 23 | constant RaytraceBindings &bindings [[buffer(0)]], 24 | uint2 thread_position_in_grid [[thread_position_in_grid]], 25 | uint2 grid_size [[threads_per_grid]] 26 | ) 27 | { 28 | // uv 29 | float2 center = float2(thread_position_in_grid) + float2(0.5f); 30 | float aspect = float(grid_size.x) / float(grid_size.y); 31 | float fov = 60.0f; 32 | float focal_length = 1.0f / (2.0f * tan(fov * DEG2RAD * 0.5f)); 33 | 34 | float2 ndc = center / float2(grid_size) * 2.0f - float2(1.0f); 35 | ndc.x *= aspect; 36 | 37 | // gen 38 | float3 origin_ws = bindings.camera.position.xyz; 39 | 40 | float3 forward = normalize(bindings.camera.direction.xyz); 41 | float3 up = float3(0.0f, 0.0f, 1.0f); 42 | float3 right = normalize(cross(forward, up)); 43 | up = normalize(cross(right, forward)); 44 | 45 | float3 direction_ws = normalize(forward * focal_length + up * ndc.y + right * ndc.x); 46 | 47 | // trace 48 | ray ray; 49 | ray.origin = origin_ws; 50 | ray.direction = direction_ws; 51 | ray.min_distance = 0.001f; 52 | ray.max_distance = 10000.0f; 53 | 54 | intersector intersector; 55 | intersection_result intersection; 56 | 57 | intersector.accept_any_intersection(false); 58 | intersection = intersector.intersect(ray, bindings.tlas); 59 | 60 | float3 color = float3(0.0f); 61 | 62 | if (intersection.type != intersection_type::none) 63 | { 64 | float2 attribs = intersection.triangle_barycentric_coord; 65 | float3 barycentric_coords = float3(1.0f - attribs.x - attribs.y, attribs.x, attribs.y); 66 | color = pow(barycentric_coords, float3(1.0f / 2.2f)); 67 | } else 68 | { 69 | color = float3(0.4f, 0.4f, 0.4f); 70 | } 71 | 72 | // store 73 | bindings.image.write(float4(color, 1.0f), thread_position_in_grid); 74 | } -------------------------------------------------------------------------------- /3rdparty/gbench/src/string_util.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_STRING_UTIL_H_ 2 | #define BENCHMARK_STRING_UTIL_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "benchmark/benchmark.h" 10 | #include "benchmark/export.h" 11 | #include "check.h" 12 | #include "internal_macros.h" 13 | 14 | namespace benchmark { 15 | 16 | BENCHMARK_EXPORT 17 | std::string HumanReadableNumber(double n, Counter::OneK one_k); 18 | 19 | BENCHMARK_EXPORT 20 | #if defined(__MINGW32__) 21 | __attribute__((format(__MINGW_PRINTF_FORMAT, 1, 2))) 22 | #elif defined(__GNUC__) 23 | __attribute__((format(printf, 1, 2))) 24 | #endif 25 | std::string 26 | StrFormat(const char* format, ...); 27 | 28 | inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT { 29 | return out; 30 | } 31 | 32 | template 33 | inline std::ostream& StrCatImp(std::ostream& out, First&& f, Rest&&... rest) { 34 | out << std::forward(f); 35 | return StrCatImp(out, std::forward(rest)...); 36 | } 37 | 38 | template 39 | inline std::string StrCat(Args&&... args) { 40 | std::ostringstream ss; 41 | StrCatImp(ss, std::forward(args)...); 42 | return ss.str(); 43 | } 44 | 45 | BENCHMARK_EXPORT 46 | std::vector StrSplit(const std::string& str, char delim); 47 | 48 | // Disable lint checking for this block since it re-implements C functions. 49 | // NOLINTBEGIN 50 | #ifdef BENCHMARK_STL_ANDROID_GNUSTL 51 | /* 52 | * GNU STL in Android NDK lacks support for some C++11 functions, including 53 | * stoul, stoi, stod. We reimplement them here using C functions strtoul, 54 | * strtol, strtod. Note that reimplemented functions are in benchmark:: 55 | * namespace, not std:: namespace. 56 | */ 57 | unsigned long stoul(const std::string& str, size_t* pos = nullptr, 58 | int base = 10); 59 | int stoi(const std::string& str, size_t* pos = nullptr, int base = 10); 60 | double stod(const std::string& str, size_t* pos = nullptr); 61 | #else 62 | using std::stod; // NOLINT(misc-unused-using-decls) 63 | using std::stoi; // NOLINT(misc-unused-using-decls) 64 | using std::stoul; // NOLINT(misc-unused-using-decls) 65 | #endif 66 | // NOLINTEND 67 | 68 | } // end namespace benchmark 69 | 70 | #endif // BENCHMARK_STRING_UTIL_H_ 71 | -------------------------------------------------------------------------------- /samples/04_triangle/main.wasm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | static int current_width = 800; 8 | static int current_height = 600; 9 | static bool need_resize = false; 10 | static char canvas_handle[] = "#canvas"; 11 | 12 | static EM_BOOL onCanvasResize(int event_type, const EmscriptenUiEvent *event, void *user_data) 13 | { 14 | if (event_type != EMSCRIPTEN_EVENT_RESIZE) 15 | return EM_FALSE; 16 | 17 | current_width = static_cast(event->windowInnerWidth); 18 | current_height = static_cast(event->windowInnerHeight); 19 | 20 | need_resize = true; 21 | return EM_FALSE; 22 | } 23 | 24 | static EM_BOOL onFullscreenChange(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) 25 | { 26 | if (event->isFullscreen) 27 | { 28 | current_width = event->screenWidth; 29 | current_height = event->screenHeight; 30 | } 31 | 32 | need_resize = true; 33 | return EM_FALSE; 34 | } 35 | 36 | void frame(void *user_data) 37 | { 38 | Application *app = reinterpret_cast(user_data); 39 | assert(app); 40 | 41 | if (need_resize) 42 | { 43 | assert(current_width > 0 && current_height > 0); 44 | emscripten_set_canvas_element_size(canvas_handle, current_width, current_height); 45 | 46 | app->resize(static_cast(current_width), static_cast(current_height)); 47 | need_resize = false; 48 | } 49 | 50 | static float dt = 0.0f; 51 | const float denominator = 1.0f / 1000.0f; 52 | 53 | double start_time = emscripten_performance_now(); 54 | 55 | app->update(dt); 56 | app->render(); 57 | app->present(); 58 | 59 | dt = static_cast((emscripten_performance_now() - start_time) * denominator); 60 | } 61 | 62 | int main() 63 | { 64 | emscripten_get_canvas_element_size(canvas_handle, ¤t_width, ¤t_height); 65 | 66 | Application app; 67 | app.init(canvas_handle, static_cast(current_width), static_cast(current_height)); 68 | 69 | emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onFullscreenChange); 70 | emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onCanvasResize); 71 | emscripten_set_main_loop_arg(frame, &app, 0, 1); 72 | 73 | app.shutdown(); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/main.wasm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | static int current_width = 800; 8 | static int current_height = 600; 9 | static bool need_resize = false; 10 | static char canvas_handle[] = "#canvas"; 11 | 12 | static EM_BOOL onCanvasResize(int event_type, const EmscriptenUiEvent *event, void *user_data) 13 | { 14 | if (event_type != EMSCRIPTEN_EVENT_RESIZE) 15 | return EM_FALSE; 16 | 17 | current_width = static_cast(event->windowInnerWidth); 18 | current_height = static_cast(event->windowInnerHeight); 19 | 20 | need_resize = true; 21 | return EM_FALSE; 22 | } 23 | 24 | static EM_BOOL onFullscreenChange(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) 25 | { 26 | if (event->isFullscreen) 27 | { 28 | current_width = event->screenWidth; 29 | current_height = event->screenHeight; 30 | } 31 | 32 | need_resize = true; 33 | return EM_FALSE; 34 | } 35 | 36 | void frame(void *user_data) 37 | { 38 | Application *app = reinterpret_cast(user_data); 39 | assert(app); 40 | 41 | if (need_resize) 42 | { 43 | assert(current_width > 0 && current_height > 0); 44 | emscripten_set_canvas_element_size(canvas_handle, current_width, current_height); 45 | 46 | app->resize(static_cast(current_width), static_cast(current_height)); 47 | need_resize = false; 48 | } 49 | 50 | static float dt = 0.0f; 51 | const float denominator = 1.0f / 1000.0f; 52 | 53 | double start_time = emscripten_performance_now(); 54 | 55 | app->update(dt); 56 | app->render(); 57 | app->present(); 58 | 59 | dt = static_cast((emscripten_performance_now() - start_time) * denominator); 60 | } 61 | 62 | int main() 63 | { 64 | emscripten_get_canvas_element_size(canvas_handle, ¤t_width, ¤t_height); 65 | 66 | Application app; 67 | app.init(canvas_handle, static_cast(current_width), static_cast(current_height)); 68 | 69 | emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onFullscreenChange); 70 | emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onCanvasResize); 71 | emscripten_set_main_loop_arg(frame, &app, 0, 1); 72 | 73 | app.shutdown(); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/main.wasm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | static int current_width = 800; 8 | static int current_height = 600; 9 | static bool need_resize = false; 10 | static char canvas_handle[] = "#canvas"; 11 | 12 | static EM_BOOL onCanvasResize(int event_type, const EmscriptenUiEvent *event, void *user_data) 13 | { 14 | if (event_type != EMSCRIPTEN_EVENT_RESIZE) 15 | return EM_FALSE; 16 | 17 | current_width = static_cast(event->windowInnerWidth); 18 | current_height = static_cast(event->windowInnerHeight); 19 | 20 | need_resize = true; 21 | return EM_FALSE; 22 | } 23 | 24 | static EM_BOOL onFullscreenChange(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) 25 | { 26 | if (event->isFullscreen) 27 | { 28 | current_width = event->screenWidth; 29 | current_height = event->screenHeight; 30 | } 31 | 32 | need_resize = true; 33 | return EM_FALSE; 34 | } 35 | 36 | void frame(void *user_data) 37 | { 38 | Application *app = reinterpret_cast(user_data); 39 | assert(app); 40 | 41 | if (need_resize) 42 | { 43 | assert(current_width > 0 && current_height > 0); 44 | emscripten_set_canvas_element_size(canvas_handle, current_width, current_height); 45 | 46 | app->resize(static_cast(current_width), static_cast(current_height)); 47 | need_resize = false; 48 | } 49 | 50 | static float dt = 0.0f; 51 | const float denominator = 1.0f / 1000.0f; 52 | 53 | double start_time = emscripten_performance_now(); 54 | 55 | app->update(dt); 56 | app->render(); 57 | app->present(); 58 | 59 | dt = static_cast((emscripten_performance_now() - start_time) * denominator); 60 | } 61 | 62 | int main() 63 | { 64 | emscripten_get_canvas_element_size(canvas_handle, ¤t_width, ¤t_height); 65 | 66 | Application app; 67 | app.init(canvas_handle, static_cast(current_width), static_cast(current_height)); 68 | 69 | emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onFullscreenChange); 70 | emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, onCanvasResize); 71 | emscripten_set_main_loop_arg(frame, &app, 0, 1); 72 | 73 | app.shutdown(); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/app.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | /* 6 | */ 7 | class Application 8 | { 9 | public: 10 | void init(void *handle, uint32_t width, uint32_t height); 11 | void shutdown(); 12 | void update(float dt); 13 | void resize(uint32_t width, uint32_t height); 14 | void render(); 15 | void present(); 16 | 17 | private: 18 | void buildPipelineLayout(); 19 | void buildPipeline(); 20 | void buildSBT(); 21 | void buildBLAS(); 22 | void buildTLAS(); 23 | 24 | private: 25 | struct Camera 26 | { 27 | float pos[4]; 28 | float dir[4]; 29 | }; 30 | 31 | private: 32 | enum 33 | { 34 | IN_FLIGHT_FRAMES = 2, 35 | WAIT_TIMEOUT_MS = 1000, 36 | }; 37 | 38 | private: 39 | Opal_Instance instance {OPAL_NULL_HANDLE}; 40 | Opal_Device device {OPAL_NULL_HANDLE}; 41 | Opal_Queue queue {OPAL_NULL_HANDLE}; 42 | 43 | Opal_DeviceInfo device_info {}; 44 | 45 | Opal_AccelerationStructure blas {OPAL_NULL_HANDLE}; 46 | Opal_AccelerationStructure tlas {OPAL_NULL_HANDLE}; 47 | 48 | Opal_ShaderBindingTable sbt {OPAL_NULL_HANDLE}; 49 | 50 | Opal_Buffer camera_buffer {OPAL_NULL_HANDLE}; 51 | Camera *camera_ptr {nullptr}; 52 | 53 | Opal_PipelineLayout pipeline_layout {OPAL_NULL_HANDLE}; 54 | #ifndef OPAL_PLATFORM_MACOS 55 | Opal_RaytracePipeline raytrace_pipeline {OPAL_NULL_HANDLE}; 56 | #else 57 | Opal_ComputePipeline compute_pipeline {OPAL_NULL_HANDLE}; 58 | #endif 59 | 60 | Opal_DescriptorHeap descriptor_heap {OPAL_NULL_HANDLE}; 61 | Opal_DescriptorSetLayout descriptor_set_layout {OPAL_NULL_HANDLE}; 62 | 63 | Opal_Surface surface {OPAL_NULL_HANDLE}; 64 | Opal_Swapchain swapchain {OPAL_NULL_HANDLE}; 65 | Opal_Semaphore semaphore {OPAL_NULL_HANDLE}; 66 | Opal_Fence fence {OPAL_NULL_HANDLE}; 67 | 68 | Opal_DescriptorSet descriptor_sets[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 69 | Opal_CommandAllocator command_allocators[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE}; 70 | Opal_CommandBuffer command_buffers[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 71 | Opal_Texture frame_textures[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 72 | Opal_TextureView frame_texture_views[IN_FLIGHT_FRAMES] {OPAL_NULL_HANDLE, OPAL_NULL_HANDLE}; 73 | bool frame_initialized[IN_FLIGHT_FRAMES] {false, false}; 74 | 75 | uint64_t current_frame {0}; 76 | uint64_t wait_frame {0}; 77 | 78 | uint32_t width {0}; 79 | uint32_t height {0}; 80 | }; 81 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build Google Test by compiling a single file. 34 | // This file serves this purpose. 35 | 36 | // This line ensures that gtest.h can be compiled on its own, even 37 | // when it's fused. 38 | #include "gtest/gtest.h" 39 | 40 | // The following lines pull in the real gtest *.cc files. 41 | #include "src/gtest-assertion-result.cc" 42 | #include "src/gtest-death-test.cc" 43 | #include "src/gtest-filepath.cc" 44 | #include "src/gtest-matchers.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | #include "src/gtest.cc" 50 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/counter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 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 "counter.h" 16 | 17 | namespace benchmark { 18 | namespace internal { 19 | 20 | double Finish(Counter const& c, IterationCount iterations, double cpu_time, 21 | double num_threads) { 22 | double v = c.value; 23 | if (c.flags & Counter::kIsRate) { 24 | v /= cpu_time; 25 | } 26 | if (c.flags & Counter::kAvgThreads) { 27 | v /= num_threads; 28 | } 29 | if (c.flags & Counter::kIsIterationInvariant) { 30 | v *= static_cast(iterations); 31 | } 32 | if (c.flags & Counter::kAvgIterations) { 33 | v /= static_cast(iterations); 34 | } 35 | 36 | if (c.flags & Counter::kInvert) { // Invert is *always* last. 37 | v = 1.0 / v; 38 | } 39 | return v; 40 | } 41 | 42 | void Finish(UserCounters* l, IterationCount iterations, double cpu_time, 43 | double num_threads) { 44 | for (auto& c : *l) { 45 | c.second.value = Finish(c.second, iterations, cpu_time, num_threads); 46 | } 47 | } 48 | 49 | void Increment(UserCounters* l, UserCounters const& r) { 50 | // add counters present in both or just in *l 51 | for (auto& c : *l) { 52 | auto it = r.find(c.first); 53 | if (it != r.end()) { 54 | c.second.value = c.second + it->second; 55 | } 56 | } 57 | // add counters present in r, but not in *l 58 | for (auto const& tc : r) { 59 | auto it = l->find(tc.first); 60 | if (it == l->end()) { 61 | (*l)[tc.first] = tc.second; 62 | } 63 | } 64 | } 65 | 66 | bool SameNames(UserCounters const& l, UserCounters const& r) { 67 | if (&l == &r) return true; 68 | if (l.size() != r.size()) { 69 | return false; 70 | } 71 | for (auto const& c : l) { 72 | if (r.find(c.first) == r.end()) { 73 | return false; 74 | } 75 | } 76 | return true; 77 | } 78 | 79 | } // end namespace internal 80 | } // end namespace benchmark 81 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/log.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_LOG_H_ 2 | #define BENCHMARK_LOG_H_ 3 | 4 | #include 5 | #include 6 | 7 | // NOTE: this is also defined in benchmark.h but we're trying to avoid a 8 | // dependency. 9 | // The _MSVC_LANG check should detect Visual Studio 2015 Update 3 and newer. 10 | #if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) 11 | #define BENCHMARK_HAS_CXX11 12 | #endif 13 | 14 | namespace benchmark { 15 | namespace internal { 16 | 17 | typedef std::basic_ostream&(EndLType)(std::basic_ostream&); 18 | 19 | class LogType { 20 | friend LogType& GetNullLogInstance(); 21 | friend LogType& GetErrorLogInstance(); 22 | 23 | // FIXME: Add locking to output. 24 | template 25 | friend LogType& operator<<(LogType&, Tp const&); 26 | friend LogType& operator<<(LogType&, EndLType*); 27 | 28 | private: 29 | LogType(std::ostream* out) : out_(out) {} 30 | std::ostream* out_; 31 | 32 | // NOTE: we could use BENCHMARK_DISALLOW_COPY_AND_ASSIGN but we shouldn't have 33 | // a dependency on benchmark.h from here. 34 | #ifndef BENCHMARK_HAS_CXX11 35 | LogType(const LogType&); 36 | LogType& operator=(const LogType&); 37 | #else 38 | LogType(const LogType&) = delete; 39 | LogType& operator=(const LogType&) = delete; 40 | #endif 41 | }; 42 | 43 | template 44 | LogType& operator<<(LogType& log, Tp const& value) { 45 | if (log.out_) { 46 | *log.out_ << value; 47 | } 48 | return log; 49 | } 50 | 51 | inline LogType& operator<<(LogType& log, EndLType* m) { 52 | if (log.out_) { 53 | *log.out_ << m; 54 | } 55 | return log; 56 | } 57 | 58 | inline int& LogLevel() { 59 | static int log_level = 0; 60 | return log_level; 61 | } 62 | 63 | inline LogType& GetNullLogInstance() { 64 | static LogType null_log(static_cast(nullptr)); 65 | return null_log; 66 | } 67 | 68 | inline LogType& GetErrorLogInstance() { 69 | static LogType error_log(&std::clog); 70 | return error_log; 71 | } 72 | 73 | inline LogType& GetLogInstanceForLevel(int level) { 74 | if (level <= LogLevel()) { 75 | return GetErrorLogInstance(); 76 | } 77 | return GetNullLogInstance(); 78 | } 79 | 80 | } // end namespace internal 81 | } // end namespace benchmark 82 | 83 | // clang-format off 84 | #define BM_VLOG(x) \ 85 | (::benchmark::internal::GetLogInstanceForLevel(x) << "-- LOG(" << x << "):" \ 86 | " ") 87 | // clang-format on 88 | #endif 89 | -------------------------------------------------------------------------------- /src/opal_internal.c: -------------------------------------------------------------------------------- 1 | #include "opal_internal.h" 2 | 3 | #include 4 | 5 | static uint32_t device_type_default_scores[] = 6 | { 7 | 1000, 8 | 100, 9 | 0, 10 | 0, 11 | 0, 12 | }; 13 | 14 | static uint32_t device_type_high_performance_scores[] = 15 | { 16 | 1000, 17 | 100, 18 | 0, 19 | 0, 20 | 0, 21 | }; 22 | 23 | static uint32_t device_type_low_power_scores[] = 24 | { 25 | 100, 26 | 1000, 27 | 0, 28 | 0, 29 | 0, 30 | }; 31 | 32 | /* 33 | */ 34 | uint32_t opal_evaluateDevice(const Opal_DeviceInfo *info, Opal_DeviceHint hint) 35 | { 36 | assert(info); 37 | 38 | uint32_t score = 0; 39 | 40 | switch (hint) 41 | { 42 | case OPAL_DEVICE_HINT_PREFER_HIGH_PERFORMANCE: score += device_type_high_performance_scores[info->device_type]; break; 43 | case OPAL_DEVICE_HINT_PREFER_LOW_POWER: score += device_type_low_power_scores[info->device_type]; break; 44 | default: score += device_type_default_scores[info->device_type]; break; 45 | } 46 | 47 | score += info->features.tessellation_shader; 48 | score += info->features.geometry_shader; 49 | score += info->features.compute_pipeline * 10; 50 | score += info->features.meshlet_pipeline * 10; 51 | score += info->features.raytrace_pipeline * 10; 52 | 53 | return score; 54 | } 55 | 56 | #if !defined(OPAL_BACKEND_DIRECTX12) 57 | 58 | Opal_Result directx12_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance) 59 | { 60 | assert(desc); 61 | assert(instance); 62 | 63 | OPAL_UNUSED(desc); 64 | OPAL_UNUSED(instance); 65 | 66 | return OPAL_NOT_SUPPORTED; 67 | } 68 | 69 | #endif 70 | 71 | #if !defined(OPAL_BACKEND_WEBGPU) 72 | 73 | Opal_Result webgpu_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance) 74 | { 75 | assert(desc); 76 | assert(instance); 77 | 78 | OPAL_UNUSED(desc); 79 | OPAL_UNUSED(instance); 80 | 81 | return OPAL_NOT_SUPPORTED; 82 | } 83 | 84 | #endif 85 | 86 | #if !defined(OPAL_BACKEND_VULKAN) 87 | 88 | Opal_Result vulkan_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance) 89 | { 90 | assert(desc); 91 | assert(instance); 92 | 93 | OPAL_UNUSED(desc); 94 | OPAL_UNUSED(instance); 95 | 96 | return OPAL_NOT_SUPPORTED; 97 | } 98 | 99 | #endif 100 | 101 | #if !defined(OPAL_BACKEND_METAL) 102 | 103 | Opal_Result metal_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance) 104 | { 105 | assert(desc); 106 | assert(instance); 107 | 108 | OPAL_UNUSED(desc); 109 | OPAL_UNUSED(instance); 110 | 111 | return OPAL_NOT_SUPPORTED; 112 | } 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/thread_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_THREAD_TIMER_H 2 | #define BENCHMARK_THREAD_TIMER_H 3 | 4 | #include "check.h" 5 | #include "timers.h" 6 | 7 | namespace benchmark { 8 | namespace internal { 9 | 10 | class ThreadTimer { 11 | explicit ThreadTimer(bool measure_process_cpu_time_) 12 | : measure_process_cpu_time(measure_process_cpu_time_) {} 13 | 14 | public: 15 | static ThreadTimer Create() { 16 | return ThreadTimer(/*measure_process_cpu_time_=*/false); 17 | } 18 | static ThreadTimer CreateProcessCpuTime() { 19 | return ThreadTimer(/*measure_process_cpu_time_=*/true); 20 | } 21 | 22 | // Called by each thread 23 | void StartTimer() { 24 | running_ = true; 25 | start_real_time_ = ChronoClockNow(); 26 | start_cpu_time_ = ReadCpuTimerOfChoice(); 27 | } 28 | 29 | // Called by each thread 30 | void StopTimer() { 31 | BM_CHECK(running_); 32 | running_ = false; 33 | real_time_used_ += ChronoClockNow() - start_real_time_; 34 | // Floating point error can result in the subtraction producing a negative 35 | // time. Guard against that. 36 | cpu_time_used_ += 37 | std::max(ReadCpuTimerOfChoice() - start_cpu_time_, 0); 38 | } 39 | 40 | // Called by each thread 41 | void SetIterationTime(double seconds) { manual_time_used_ += seconds; } 42 | 43 | bool running() const { return running_; } 44 | 45 | // REQUIRES: timer is not running 46 | double real_time_used() const { 47 | BM_CHECK(!running_); 48 | return real_time_used_; 49 | } 50 | 51 | // REQUIRES: timer is not running 52 | double cpu_time_used() const { 53 | BM_CHECK(!running_); 54 | return cpu_time_used_; 55 | } 56 | 57 | // REQUIRES: timer is not running 58 | double manual_time_used() const { 59 | BM_CHECK(!running_); 60 | return manual_time_used_; 61 | } 62 | 63 | private: 64 | double ReadCpuTimerOfChoice() const { 65 | if (measure_process_cpu_time) return ProcessCPUUsage(); 66 | return ThreadCPUUsage(); 67 | } 68 | 69 | // should the thread, or the process, time be measured? 70 | const bool measure_process_cpu_time; 71 | 72 | bool running_ = false; // Is the timer running 73 | double start_real_time_ = 0; // If running_ 74 | double start_cpu_time_ = 0; // If running_ 75 | 76 | // Accumulated time so far (does not contain current slice if running_) 77 | double real_time_used_ = 0; 78 | double cpu_time_used_ = 0; 79 | // Manually set iteration time. User sets this with SetIterationTime(seconds). 80 | double manual_time_used_ = 0; 81 | }; 82 | 83 | } // namespace internal 84 | } // namespace benchmark 85 | 86 | #endif // BENCHMARK_THREAD_TIMER_H 87 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/directx12/emit.comp.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer Application: register(b0, space0) 2 | { 3 | float4 viewport; 4 | float time; 5 | float dt; 6 | }; 7 | 8 | struct EmitterData 9 | { 10 | int num_free; 11 | uint num_partices; 12 | uint num_triangles; 13 | uint padding; 14 | float min_lifetime; 15 | float max_lifetime; 16 | float min_imass; 17 | float max_imass; 18 | }; 19 | 20 | RWStructuredBuffer positions: register(u0, space1); 21 | RWStructuredBuffer velocities: register(u1, space1); 22 | RWStructuredBuffer parameters: register(u2, space1); 23 | RWStructuredBuffer free_indices: register(u3, space1); 24 | RWStructuredBuffer emitter: register(u4, space1); 25 | RWStructuredBuffer mesh_vertices: register(u5, space1); 26 | RWStructuredBuffer mesh_indices: register(u6, space1); 27 | 28 | static const float4 RANDOM_SCALE = float4(443.897f, 441.423f, 0.0973f, 0.1099f); 29 | 30 | float3 random3(float3 p) 31 | { 32 | p = frac(p * RANDOM_SCALE.xyz); 33 | p += dot(p, p.yxz + 19.19f); 34 | return frac((p.xxy + p.yzz) * p.zyx); 35 | } 36 | 37 | float4 randomPointOnTriangle(float2 barycentric, float4 v0, float4 v1, float4 v2) 38 | { 39 | float b1 = 1.0f - sqrt(barycentric.x); 40 | float b2 = (1.0f - b1) * barycentric.y; 41 | 42 | float4 e1 = v1 - v0; 43 | float4 e2 = v2 - v0; 44 | 45 | return v0 + e1 * b1 + e2 * b2; 46 | } 47 | 48 | uint popFreeParticleIndex() 49 | { 50 | int index; 51 | InterlockedAdd(emitter[0].num_free, -1, index); 52 | 53 | return free_indices[index]; 54 | } 55 | 56 | [numthreads(256, 1, 1)] 57 | void computeMain(uint3 global_invocation_id : SV_DispatchThreadID) 58 | { 59 | uint free_index = global_invocation_id.x; 60 | if (free_index >= uint(emitter[0].num_free)) 61 | return; 62 | 63 | uint triangle_index = free_index % emitter[0].num_triangles; 64 | uint i0 = mesh_indices[triangle_index * 3u + 0u]; 65 | uint i1 = mesh_indices[triangle_index * 3u + 1u]; 66 | uint i2 = mesh_indices[triangle_index * 3u + 2u]; 67 | 68 | float4 v0 = mesh_vertices[i0]; 69 | float4 v1 = mesh_vertices[i1]; 70 | float4 v2 = mesh_vertices[i2]; 71 | 72 | float3 uv = float3(float(triangle_index), time, float(free_index)); 73 | float3 value = random3(uv); 74 | 75 | float lifetime = lerp(emitter[0].min_lifetime, emitter[0].max_lifetime, value.x); 76 | float imass = lerp(emitter[0].min_imass, emitter[0].max_imass, value.x); 77 | 78 | uint particle_index = popFreeParticleIndex(); 79 | positions[particle_index] = randomPointOnTriangle(value.yz, v0, v1, v2); 80 | velocities[particle_index] = float4(0.0f, 0.0f, 0.0f, 0.0f); 81 | parameters[particle_index] = float4(lifetime, lifetime, imass, 0.0f); 82 | } 83 | -------------------------------------------------------------------------------- /tests/heap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET test_heap) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | # ================================================================================================== 9 | # Sources 10 | # ================================================================================================== 11 | file(GLOB SOURCES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 13 | ${OPAL_DIR_SRC}/common/heap.c 14 | ) 15 | 16 | file(GLOB HEADERS 17 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 18 | ${OPAL_DIR_SRC}/common/*.h 19 | ) 20 | 21 | # ================================================================================================== 22 | # Target 23 | # ================================================================================================== 24 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 25 | 26 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 27 | 28 | # ================================================================================================== 29 | # Includes 30 | # ================================================================================================== 31 | target_include_directories(${TARGET} PUBLIC ${OPAL_DIR_API}) 32 | target_include_directories(${TARGET} PUBLIC ${OPAL_DIR_SRC}/common) 33 | 34 | # ================================================================================================== 35 | # Preprocessor 36 | # ================================================================================================== 37 | 38 | # ================================================================================================== 39 | # Libraries 40 | # ================================================================================================== 41 | target_link_libraries(${TARGET} PUBLIC gtest) 42 | 43 | # ================================================================================================== 44 | # Custom commands 45 | # ================================================================================================== 46 | 47 | # ================================================================================================== 48 | # Installation 49 | # ================================================================================================== 50 | if (NOT EMSCRIPTEN) 51 | install( 52 | TARGETS ${TARGET} 53 | EXPORT ${TARGET} 54 | RUNTIME DESTINATION bin 55 | LIBRARY DESTINATION lib 56 | ARCHIVE DESTINATION lib 57 | INCLUDES DESTINATION include 58 | PUBLIC_HEADER DESTINATION include 59 | ) 60 | endif() 61 | -------------------------------------------------------------------------------- /tests/pool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET test_pool) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | # ================================================================================================== 9 | # Sources 10 | # ================================================================================================== 11 | file(GLOB SOURCES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 13 | ${OPAL_DIR_SRC}/common/pool.c 14 | ) 15 | 16 | file(GLOB HEADERS 17 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 18 | ${OPAL_DIR_SRC}/common/*.h 19 | ) 20 | 21 | # ================================================================================================== 22 | # Target 23 | # ================================================================================================== 24 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 25 | 26 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 27 | 28 | # ================================================================================================== 29 | # Includes 30 | # ================================================================================================== 31 | target_include_directories(${TARGET} PUBLIC ${OPAL_DIR_API}) 32 | target_include_directories(${TARGET} PUBLIC ${OPAL_DIR_SRC}/common) 33 | 34 | # ================================================================================================== 35 | # Preprocessor 36 | # ================================================================================================== 37 | 38 | # ================================================================================================== 39 | # Libraries 40 | # ================================================================================================== 41 | target_link_libraries(${TARGET} PUBLIC gtest) 42 | 43 | # ================================================================================================== 44 | # Custom commands 45 | # ================================================================================================== 46 | 47 | # ================================================================================================== 48 | # Installation 49 | # ================================================================================================== 50 | if (NOT EMSCRIPTEN) 51 | install( 52 | TARGETS ${TARGET} 53 | EXPORT ${TARGET} 54 | RUNTIME DESTINATION bin 55 | LIBRARY DESTINATION lib 56 | ARCHIVE DESTINATION lib 57 | INCLUDES DESTINATION include 58 | PUBLIC_HEADER DESTINATION include 59 | ) 60 | endif() 61 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | #if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || \ 35 | (defined(GTEST_OS_NRF52) && defined(ARDUINO)) 36 | // Arduino-like platforms: program entry points are setup/loop instead of main. 37 | 38 | #ifdef GTEST_OS_ESP8266 39 | extern "C" { 40 | #endif 41 | 42 | void setup() { testing::InitGoogleTest(); } 43 | 44 | void loop() { RUN_ALL_TESTS(); } 45 | 46 | #ifdef GTEST_OS_ESP8266 47 | } 48 | #endif 49 | 50 | #elif defined(GTEST_OS_QURT) 51 | // QuRT: program entry point is main, but argc/argv are unusable. 52 | 53 | GTEST_API_ int main() { 54 | printf("Running main() from %s\n", __FILE__); 55 | testing::InitGoogleTest(); 56 | return RUN_ALL_TESTS(); 57 | } 58 | #else 59 | // Normal platforms: program entry point is main, argc/argv are initialized. 60 | 61 | GTEST_API_ int main(int argc, char **argv) { 62 | printf("Running main() from %s\n", __FILE__); 63 | testing::InitGoogleTest(&argc, argv); 64 | return RUN_ALL_TESTS(); 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vk_video/vulkan_video_codec_h265std_decode.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 2 | #define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // vulkan_video_codec_h265std_decode is a preprocessor guard. Do not pass it to API calls. 23 | #define vulkan_video_codec_h265std_decode 1 24 | #include "vulkan_video_codec_h265std.h" 25 | 26 | #define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) 27 | 28 | #define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 29 | #define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_decode" 30 | #define STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE 8 31 | typedef struct StdVideoDecodeH265PictureInfoFlags { 32 | uint32_t IrapPicFlag : 1; 33 | uint32_t IdrPicFlag : 1; 34 | uint32_t IsReference : 1; 35 | uint32_t short_term_ref_pic_set_sps_flag : 1; 36 | } StdVideoDecodeH265PictureInfoFlags; 37 | 38 | typedef struct StdVideoDecodeH265PictureInfo { 39 | StdVideoDecodeH265PictureInfoFlags flags; 40 | uint8_t sps_video_parameter_set_id; 41 | uint8_t pps_seq_parameter_set_id; 42 | uint8_t pps_pic_parameter_set_id; 43 | uint8_t NumDeltaPocsOfRefRpsIdx; 44 | int32_t PicOrderCntVal; 45 | uint16_t NumBitsForSTRefPicSetInSlice; 46 | uint16_t reserved; 47 | uint8_t RefPicSetStCurrBefore[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; 48 | uint8_t RefPicSetStCurrAfter[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; 49 | uint8_t RefPicSetLtCurr[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; 50 | } StdVideoDecodeH265PictureInfo; 51 | 52 | typedef struct StdVideoDecodeH265ReferenceInfoFlags { 53 | uint32_t used_for_long_term_reference : 1; 54 | uint32_t unused_for_reference : 1; 55 | } StdVideoDecodeH265ReferenceInfoFlags; 56 | 57 | typedef struct StdVideoDecodeH265ReferenceInfo { 58 | StdVideoDecodeH265ReferenceInfoFlags flags; 59 | int32_t PicOrderCntVal; 60 | } StdVideoDecodeH265ReferenceInfo; 61 | 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google C++ Testing and Mocking Framework definitions useful in production 31 | // code. 32 | 33 | #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 34 | #define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | 36 | // When you need to test the private or protected members of a class, 37 | // use the FRIEND_TEST macro to declare your tests as friends of the 38 | // class. For example: 39 | // 40 | // class MyClass { 41 | // private: 42 | // void PrivateMethod(); 43 | // FRIEND_TEST(MyClassTest, PrivateMethodWorks); 44 | // }; 45 | // 46 | // class MyClassTest : public testing::Test { 47 | // // ... 48 | // }; 49 | // 50 | // TEST_F(MyClassTest, PrivateMethodWorks) { 51 | // // Can call MyClass::PrivateMethod() here. 52 | // } 53 | // 54 | // Note: The test class must be in the same namespace as the class being tested. 55 | // For example, putting MyClassTest in an anonymous namespace will not work. 56 | 57 | #define FRIEND_TEST(test_case_name, test_name) \ 58 | friend class test_case_name##_##test_name##_Test 59 | 60 | #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 61 | -------------------------------------------------------------------------------- /samples/02_buffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET 02_buffers) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | # ================================================================================================== 9 | # Sources 10 | # ================================================================================================== 11 | file(GLOB SOURCES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 13 | ) 14 | 15 | file(GLOB HEADERS 16 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 17 | ) 18 | 19 | # ================================================================================================== 20 | # Target 21 | # ================================================================================================== 22 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 23 | 24 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 25 | 26 | # ================================================================================================== 27 | # Includes 28 | # ================================================================================================== 29 | target_include_directories(${TARGET} PUBLIC ${OPAL_API_DIR}) 30 | 31 | # ================================================================================================== 32 | # Preprocessor 33 | # ================================================================================================== 34 | 35 | # ================================================================================================== 36 | # Libraries 37 | # ================================================================================================== 38 | target_link_libraries(${TARGET} PUBLIC opal) 39 | 40 | # ================================================================================================== 41 | # Custom commands 42 | # ================================================================================================== 43 | 44 | # ================================================================================================== 45 | # Installation 46 | # ================================================================================================== 47 | if (EMSCRIPTEN) 48 | install( 49 | FILES 50 | "$/$.js" 51 | "$/$.wasm" 52 | "$/$.html" 53 | DESTINATION bin 54 | ) 55 | else() 56 | install( 57 | TARGETS ${TARGET} 58 | EXPORT ${TARGET} 59 | RUNTIME DESTINATION bin 60 | LIBRARY DESTINATION lib 61 | ARCHIVE DESTINATION lib 62 | INCLUDES DESTINATION include 63 | PUBLIC_HEADER DESTINATION include 64 | ) 65 | endif() 66 | -------------------------------------------------------------------------------- /samples/03_textures/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET 03_textures) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | # ================================================================================================== 9 | # Sources 10 | # ================================================================================================== 11 | file(GLOB SOURCES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 13 | ) 14 | 15 | file(GLOB HEADERS 16 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 17 | ) 18 | 19 | # ================================================================================================== 20 | # Target 21 | # ================================================================================================== 22 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 23 | 24 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 25 | 26 | # ================================================================================================== 27 | # Includes 28 | # ================================================================================================== 29 | target_include_directories(${TARGET} PUBLIC ${OPAL_API_DIR}) 30 | 31 | # ================================================================================================== 32 | # Preprocessor 33 | # ================================================================================================== 34 | 35 | # ================================================================================================== 36 | # Libraries 37 | # ================================================================================================== 38 | target_link_libraries(${TARGET} PUBLIC opal) 39 | 40 | # ================================================================================================== 41 | # Custom commands 42 | # ================================================================================================== 43 | 44 | # ================================================================================================== 45 | # Installation 46 | # ================================================================================================== 47 | if (EMSCRIPTEN) 48 | install( 49 | FILES 50 | "$/$.js" 51 | "$/$.wasm" 52 | "$/$.html" 53 | DESTINATION bin 54 | ) 55 | else() 56 | install( 57 | TARGETS ${TARGET} 58 | EXPORT ${TARGET} 59 | RUNTIME DESTINATION bin 60 | LIBRARY DESTINATION lib 61 | ARCHIVE DESTINATION lib 62 | INCLUDES DESTINATION include 63 | PUBLIC_HEADER DESTINATION include 64 | ) 65 | endif() 66 | -------------------------------------------------------------------------------- /benchmarks/allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET bench_allocator) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | # ================================================================================================== 9 | # Sources 10 | # ================================================================================================== 11 | file(GLOB SOURCES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 13 | ) 14 | 15 | file(GLOB HEADERS 16 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 17 | ) 18 | 19 | # ================================================================================================== 20 | # Target 21 | # ================================================================================================== 22 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 23 | 24 | set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OPAL_DIR_EXPORT}/${OPAL_PLATFORM}/${OPAL_ABI}) 25 | set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${OPAL_DIR_EXPORT}/${OPAL_PLATFORM}/${OPAL_ABI}) 26 | set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${OPAL_DIR_EXPORT}/${OPAL_PLATFORM}/${OPAL_ABI}) 27 | set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OPAL_DIR_EXPORT}/${OPAL_PLATFORM}/${OPAL_ABI}) 28 | 29 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 30 | 31 | # ================================================================================================== 32 | # Includes 33 | # ================================================================================================== 34 | target_include_directories(${TARGET} PUBLIC ${OPAL_API_DIR}) 35 | 36 | # ================================================================================================== 37 | # Preprocessor 38 | # ================================================================================================== 39 | 40 | # ================================================================================================== 41 | # Libraries 42 | # ================================================================================================== 43 | target_link_libraries(${TARGET} PUBLIC opal benchmark::benchmark) 44 | 45 | # ================================================================================================== 46 | # Custom commands 47 | # ================================================================================================== 48 | if (NOT EMSCRIPTEN) 49 | install( 50 | TARGETS ${TARGET} 51 | EXPORT ${TARGET} 52 | RUNTIME DESTINATION bin 53 | LIBRARY DESTINATION lib 54 | ARCHIVE DESTINATION lib 55 | INCLUDES DESTINATION include 56 | PUBLIC_HEADER DESTINATION include 57 | ) 58 | endif() 59 | -------------------------------------------------------------------------------- /samples/01_enumerate_devices/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(TARGET 01_enumerate_devices) 3 | 4 | # ================================================================================================== 5 | # Variables 6 | # ================================================================================================== 7 | 8 | 9 | # ================================================================================================== 10 | # Sources 11 | # ================================================================================================== 12 | file(GLOB SOURCES 13 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp 14 | ) 15 | 16 | file(GLOB HEADERS 17 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h 18 | ) 19 | 20 | # ================================================================================================== 21 | # Target 22 | # ================================================================================================== 23 | add_executable(${TARGET} ${SOURCES} ${HEADERS}) 24 | 25 | set_target_properties(${TARGET} PROPERTIES DEBUG_POSTFIX d) 26 | 27 | # ================================================================================================== 28 | # Includes 29 | # ================================================================================================== 30 | target_include_directories(${TARGET} PUBLIC ${OPAL_API_DIR}) 31 | 32 | # ================================================================================================== 33 | # Preprocessor 34 | # ================================================================================================== 35 | 36 | # ================================================================================================== 37 | # Libraries 38 | # ================================================================================================== 39 | target_link_libraries(${TARGET} PUBLIC opal) 40 | 41 | # ================================================================================================== 42 | # Custom commands 43 | # ================================================================================================== 44 | 45 | # ================================================================================================== 46 | # Installation 47 | # ================================================================================================== 48 | if (EMSCRIPTEN) 49 | install( 50 | FILES 51 | "$/$.js" 52 | "$/$.wasm" 53 | "$/$.html" 54 | DESTINATION bin 55 | ) 56 | else() 57 | install( 58 | TARGETS ${TARGET} 59 | EXPORT ${TARGET} 60 | RUNTIME DESTINATION bin 61 | LIBRARY DESTINATION lib 62 | ARCHIVE DESTINATION lib 63 | INCLUDES DESTINATION include 64 | PUBLIC_HEADER DESTINATION include 65 | ) 66 | endif() 67 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/GoogleTest.cmake: -------------------------------------------------------------------------------- 1 | # Download and unpack googletest at configure time 2 | set(GOOGLETEST_PREFIX "${benchmark_BINARY_DIR}/third_party/googletest") 3 | configure_file(${benchmark_SOURCE_DIR}/cmake/GoogleTest.cmake.in ${GOOGLETEST_PREFIX}/CMakeLists.txt @ONLY) 4 | 5 | set(GOOGLETEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/googletest" CACHE PATH "") # Mind the quotes 6 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" 7 | -DALLOW_DOWNLOADING_GOOGLETEST=${BENCHMARK_DOWNLOAD_DEPENDENCIES} -DGOOGLETEST_PATH:PATH=${GOOGLETEST_PATH} . 8 | RESULT_VARIABLE result 9 | WORKING_DIRECTORY ${GOOGLETEST_PREFIX} 10 | ) 11 | 12 | if(result) 13 | message(FATAL_ERROR "CMake step for googletest failed: ${result}") 14 | endif() 15 | 16 | execute_process( 17 | COMMAND ${CMAKE_COMMAND} --build . 18 | RESULT_VARIABLE result 19 | WORKING_DIRECTORY ${GOOGLETEST_PREFIX} 20 | ) 21 | 22 | if(result) 23 | message(FATAL_ERROR "Build step for googletest failed: ${result}") 24 | endif() 25 | 26 | # Prevent overriding the parent project's compiler/linker 27 | # settings on Windows 28 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 29 | 30 | include(${GOOGLETEST_PREFIX}/googletest-paths.cmake) 31 | 32 | # Add googletest directly to our build. This defines 33 | # the gtest and gtest_main targets. 34 | add_subdirectory(${GOOGLETEST_SOURCE_DIR} 35 | ${GOOGLETEST_BINARY_DIR} 36 | EXCLUDE_FROM_ALL) 37 | 38 | # googletest doesn't seem to want to stay build warning clean so let's not hurt ourselves. 39 | if (MSVC) 40 | target_compile_options(gtest PRIVATE "/wd4244" "/wd4722") 41 | target_compile_options(gtest_main PRIVATE "/wd4244" "/wd4722") 42 | target_compile_options(gmock PRIVATE "/wd4244" "/wd4722") 43 | target_compile_options(gmock_main PRIVATE "/wd4244" "/wd4722") 44 | else() 45 | target_compile_options(gtest PRIVATE "-w") 46 | target_compile_options(gtest_main PRIVATE "-w") 47 | target_compile_options(gmock PRIVATE "-w") 48 | target_compile_options(gmock_main PRIVATE "-w") 49 | endif() 50 | 51 | if(NOT DEFINED GTEST_COMPILE_COMMANDS) 52 | set(GTEST_COMPILE_COMMANDS ON) 53 | endif() 54 | 55 | set_target_properties(gtest PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $ EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS}) 56 | set_target_properties(gtest_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $ EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS}) 57 | set_target_properties(gmock PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $ EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS}) 58 | set_target_properties(gmock_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $ EXPORT_COMPILE_COMMANDS ${GTEST_COMPILE_COMMANDS}) 59 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/GoogleTest.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | 3 | project(googletest-download NONE) 4 | 5 | # Enable ExternalProject CMake module 6 | include(ExternalProject) 7 | 8 | option(ALLOW_DOWNLOADING_GOOGLETEST "If googletest src tree is not found in location specified by GOOGLETEST_PATH, do fetch the archive from internet" OFF) 9 | set(GOOGLETEST_PATH "/usr/src/googletest" CACHE PATH 10 | "Path to the googletest root tree. Should contain googletest and googlemock subdirs. And CMakeLists.txt in root, and in both of these subdirs") 11 | 12 | # Download and install GoogleTest 13 | 14 | message(STATUS "Looking for Google Test sources") 15 | message(STATUS "Looking for Google Test sources in ${GOOGLETEST_PATH}") 16 | if(EXISTS "${GOOGLETEST_PATH}" AND IS_DIRECTORY "${GOOGLETEST_PATH}" AND EXISTS "${GOOGLETEST_PATH}/CMakeLists.txt" AND 17 | EXISTS "${GOOGLETEST_PATH}/googletest" AND IS_DIRECTORY "${GOOGLETEST_PATH}/googletest" AND EXISTS "${GOOGLETEST_PATH}/googletest/CMakeLists.txt" AND 18 | EXISTS "${GOOGLETEST_PATH}/googlemock" AND IS_DIRECTORY "${GOOGLETEST_PATH}/googlemock" AND EXISTS "${GOOGLETEST_PATH}/googlemock/CMakeLists.txt") 19 | message(STATUS "Found Google Test in ${GOOGLETEST_PATH}") 20 | 21 | ExternalProject_Add( 22 | googletest 23 | PREFIX "${CMAKE_BINARY_DIR}" 24 | DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/download" 25 | SOURCE_DIR "${GOOGLETEST_PATH}" # use existing src dir. 26 | BINARY_DIR "${CMAKE_BINARY_DIR}/build" 27 | CONFIGURE_COMMAND "" 28 | BUILD_COMMAND "" 29 | INSTALL_COMMAND "" 30 | TEST_COMMAND "" 31 | ) 32 | else() 33 | if(NOT ALLOW_DOWNLOADING_GOOGLETEST) 34 | message(SEND_ERROR "Did not find Google Test sources! Either pass correct path in GOOGLETEST_PATH, or enable BENCHMARK_DOWNLOAD_DEPENDENCIES, or disable BENCHMARK_USE_BUNDLED_GTEST, or disable BENCHMARK_ENABLE_GTEST_TESTS / BENCHMARK_ENABLE_TESTING.") 35 | return() 36 | else() 37 | message(WARNING "Did not find Google Test sources! Fetching from web...") 38 | ExternalProject_Add( 39 | googletest 40 | GIT_REPOSITORY https://github.com/google/googletest.git 41 | GIT_TAG "release-1.11.0" 42 | PREFIX "${CMAKE_BINARY_DIR}" 43 | STAMP_DIR "${CMAKE_BINARY_DIR}/stamp" 44 | DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/download" 45 | SOURCE_DIR "${CMAKE_BINARY_DIR}/src" 46 | BINARY_DIR "${CMAKE_BINARY_DIR}/build" 47 | CONFIGURE_COMMAND "" 48 | BUILD_COMMAND "" 49 | INSTALL_COMMAND "" 50 | TEST_COMMAND "" 51 | ) 52 | endif() 53 | endif() 54 | 55 | ExternalProject_Get_Property(googletest SOURCE_DIR BINARY_DIR) 56 | file(WRITE googletest-paths.cmake 57 | "set(GOOGLETEST_SOURCE_DIR \"${SOURCE_DIR}\") 58 | set(GOOGLETEST_BINARY_DIR \"${BINARY_DIR}\") 59 | ") 60 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/CXXFeatureCheck.cmake: -------------------------------------------------------------------------------- 1 | # - Compile and run code to check for C++ features 2 | # 3 | # This functions compiles a source file under the `cmake` folder 4 | # and adds the corresponding `HAVE_[FILENAME]` flag to the CMake 5 | # environment 6 | # 7 | # cxx_feature_check( []) 8 | # 9 | # - Example 10 | # 11 | # include(CXXFeatureCheck) 12 | # cxx_feature_check(STD_REGEX) 13 | # Requires CMake 2.8.12+ 14 | 15 | if(__cxx_feature_check) 16 | return() 17 | endif() 18 | set(__cxx_feature_check INCLUDED) 19 | 20 | option(CXXFEATURECHECK_DEBUG OFF) 21 | 22 | function(cxx_feature_check FILE) 23 | string(TOLOWER ${FILE} FILE) 24 | string(TOUPPER ${FILE} VAR) 25 | string(TOUPPER "HAVE_${VAR}" FEATURE) 26 | if (DEFINED HAVE_${VAR}) 27 | set(HAVE_${VAR} 1 PARENT_SCOPE) 28 | add_definitions(-DHAVE_${VAR}) 29 | return() 30 | endif() 31 | 32 | set(FEATURE_CHECK_CMAKE_FLAGS ${BENCHMARK_CXX_LINKER_FLAGS}) 33 | if (ARGC GREATER 1) 34 | message(STATUS "Enabling additional flags: ${ARGV1}") 35 | list(APPEND FEATURE_CHECK_CMAKE_FLAGS ${ARGV1}) 36 | endif() 37 | 38 | if (NOT DEFINED COMPILE_${FEATURE}) 39 | if(CMAKE_CROSSCOMPILING) 40 | message(STATUS "Cross-compiling to test ${FEATURE}") 41 | try_compile(COMPILE_${FEATURE} 42 | ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp 43 | CXX_STANDARD 11 44 | CXX_STANDARD_REQUIRED ON 45 | CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} 46 | LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} 47 | OUTPUT_VARIABLE COMPILE_OUTPUT_VAR) 48 | if(COMPILE_${FEATURE}) 49 | message(WARNING 50 | "If you see build failures due to cross compilation, try setting HAVE_${VAR} to 0") 51 | set(RUN_${FEATURE} 0 CACHE INTERNAL "") 52 | else() 53 | set(RUN_${FEATURE} 1 CACHE INTERNAL "") 54 | endif() 55 | else() 56 | message(STATUS "Compiling and running to test ${FEATURE}") 57 | try_run(RUN_${FEATURE} COMPILE_${FEATURE} 58 | ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp 59 | CXX_STANDARD 11 60 | CXX_STANDARD_REQUIRED ON 61 | CMAKE_FLAGS ${FEATURE_CHECK_CMAKE_FLAGS} 62 | LINK_LIBRARIES ${BENCHMARK_CXX_LIBRARIES} 63 | COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR) 64 | endif() 65 | endif() 66 | 67 | if(RUN_${FEATURE} EQUAL 0) 68 | message(STATUS "Performing Test ${FEATURE} -- success") 69 | set(HAVE_${VAR} 1 PARENT_SCOPE) 70 | add_definitions(-DHAVE_${VAR}) 71 | else() 72 | if(NOT COMPILE_${FEATURE}) 73 | if(CXXFEATURECHECK_DEBUG) 74 | message(STATUS "Performing Test ${FEATURE} -- failed to compile: ${COMPILE_OUTPUT_VAR}") 75 | else() 76 | message(STATUS "Performing Test ${FEATURE} -- failed to compile") 77 | endif() 78 | else() 79 | message(STATUS "Performing Test ${FEATURE} -- compiled but failed to run") 80 | endif() 81 | endif() 82 | endfunction() 83 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/webgpu/emit.comp.wgsl: -------------------------------------------------------------------------------- 1 | struct Application 2 | { 3 | viewport: vec4f, 4 | time: f32, 5 | dt: f32 6 | }; 7 | 8 | struct EmitterData 9 | { 10 | num_free: atomic, 11 | num_particles: u32, 12 | num_triangles: u32, 13 | padding: u32, 14 | min_lifetime: f32, 15 | max_lifetime: f32, 16 | min_imass: f32, 17 | max_imass: f32 18 | }; 19 | 20 | @group(0) @binding(0) var application: Application; 21 | 22 | @group(1) @binding(0) var positions: array; 23 | @group(1) @binding(1) var velocities: array; 24 | @group(1) @binding(2) var parameters: array; 25 | @group(1) @binding(3) var free_indices: array; 26 | @group(1) @binding(4) var emitter: EmitterData; 27 | @group(1) @binding(5) var mesh_vertices: array; 28 | @group(1) @binding(6) var mesh_indices: array; 29 | 30 | const RANDOM_SCALE: vec4f = vec4f(443.897, 441.423, 0.0973, 0.1099); 31 | 32 | @must_use 33 | fn random3(p: vec3f) -> vec3f 34 | { 35 | var v: vec3f = fract(p * RANDOM_SCALE.xyz); 36 | v += dot(v, v.yxz + vec3f(19.19)); 37 | return fract((v.xxy + v.yzz) * v.zyx); 38 | } 39 | 40 | @must_use 41 | fn randomPointOnTriangle(barycentric: vec2f, v0: vec4f, v1: vec4f, v2: vec4f) -> vec4f 42 | { 43 | var b1: f32 = 1.0 - sqrt(barycentric.x); 44 | var b2: f32 = (1.0 - b1) * barycentric.y; 45 | 46 | var e1: vec4f = v1 - v0; 47 | var e2: vec4f = v2 - v0; 48 | 49 | return v0 + e1 * b1 + e2 * b2; 50 | } 51 | 52 | @must_use 53 | fn popFreeParticleIndex() -> u32 54 | { 55 | let index: i32 = atomicAdd(&emitter.num_free, -1); 56 | return free_indices[index]; 57 | } 58 | 59 | struct ComputeInput 60 | { 61 | @builtin(global_invocation_id) global_invocation_id: vec3u, 62 | }; 63 | 64 | @compute @workgroup_size(256, 1, 1) 65 | fn computeMain(input: ComputeInput) 66 | { 67 | var free_index: u32 = input.global_invocation_id.x; 68 | var num_free: u32 = u32(atomicLoad(&emitter.num_free)); 69 | if (free_index >= num_free) 70 | { 71 | return; 72 | } 73 | 74 | var triangle_index: u32 = free_index % emitter.num_triangles; 75 | var i0: u32 = mesh_indices[triangle_index * 3 + 0]; 76 | var i1: u32 = mesh_indices[triangle_index * 3 + 1]; 77 | var i2: u32 = mesh_indices[triangle_index * 3 + 2]; 78 | 79 | var v0: vec4f = mesh_vertices[i0]; 80 | var v1: vec4f = mesh_vertices[i1]; 81 | var v2: vec4f = mesh_vertices[i2]; 82 | 83 | var uv: vec3f = vec3f(f32(triangle_index), application.time, f32(free_index)); 84 | var value: vec3f = random3(uv); 85 | 86 | var lifetime: f32 = mix(emitter.min_lifetime, emitter.max_lifetime, value.x); 87 | var imass: f32 = mix(emitter.min_imass, emitter.max_imass, value.x); 88 | 89 | var particle_index: u32 = popFreeParticleIndex(); 90 | positions[particle_index] = randomPointOnTriangle(value.yz, v0, v1, v2); 91 | velocities[particle_index] = vec4f(0.0, 0.0, 0.0, 0.0); 92 | parameters[particle_index] = vec4f(lifetime, lifetime, imass, 0.0); 93 | } 94 | -------------------------------------------------------------------------------- /src/common/intrinsics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // Note: 'static' keyword is intentionally put here to avoid linker errors on emscripten. 7 | // If compiled only with OPAL_INLINE, it searches for symbols and fails to link. 8 | // 9 | // On a side, it's ok to keep these intrinsics statis and have multiple copies in 10 | // translation units. We hope the compiler will inline them anyways. 11 | 12 | /* 13 | */ 14 | static OPAL_INLINE uint32_t lzcnt(uint32_t value) 15 | { 16 | assert(value != 0); 17 | 18 | #ifdef _MSC_VER 19 | unsigned long result = 0; 20 | _BitScanReverse(&result, value); 21 | return 31 - result; 22 | #else 23 | return __builtin_clz(value); 24 | #endif 25 | } 26 | 27 | static OPAL_INLINE uint32_t tzcnt(uint32_t value) 28 | { 29 | assert(value != 0); 30 | 31 | #ifdef _MSC_VER 32 | unsigned long result = 0; 33 | _BitScanForward(&result, value); 34 | return result; 35 | #else 36 | return __builtin_ctz(value); 37 | #endif 38 | } 39 | 40 | static OPAL_INLINE uint32_t popcnt(uint32_t value) 41 | { 42 | #ifdef _MSC_VER 43 | return __popcnt(value); 44 | #else 45 | return __builtin_popcount(value); 46 | #endif 47 | } 48 | 49 | static OPAL_INLINE uint32_t isPow2u(uint32_t value) 50 | { 51 | return (value & (value - 1)) == 0; 52 | } 53 | 54 | static OPAL_INLINE uint64_t isPow2ul(uint64_t value) 55 | { 56 | return (value & (value - 1)) == 0; 57 | } 58 | 59 | static OPAL_INLINE uint32_t isAlignedu(uint32_t value, uint32_t alignment) 60 | { 61 | assert(isPow2u(alignment)); 62 | 63 | uint32_t mask = alignment - 1; 64 | return (value & mask) == 0; 65 | } 66 | 67 | static OPAL_INLINE uint64_t isAlignedul(uint64_t value, uint64_t alignment) 68 | { 69 | assert(isPow2ul(alignment)); 70 | 71 | uint64_t mask = alignment - 1; 72 | return (value & mask) == 0; 73 | } 74 | 75 | static OPAL_INLINE uint32_t alignDown(uint32_t value, uint32_t alignment) 76 | { 77 | assert(isPow2u(alignment)); 78 | 79 | uint32_t mask = alignment - 1; 80 | return value & ~mask; 81 | } 82 | 83 | static OPAL_INLINE uint64_t alignDownul(uint64_t value, uint64_t alignment) 84 | { 85 | assert(isPow2ul(alignment)); 86 | 87 | uint64_t mask = alignment - 1; 88 | return value & ~mask; 89 | } 90 | 91 | static OPAL_INLINE uint32_t alignUp(uint32_t value, uint32_t alignment) 92 | { 93 | assert(isPow2u(alignment)); 94 | 95 | uint32_t mask = alignment - 1; 96 | return (value + mask) & ~mask; 97 | } 98 | 99 | static OPAL_INLINE uint64_t alignUpul(uint64_t value, uint64_t alignment) 100 | { 101 | assert(isPow2ul(alignment)); 102 | 103 | uint64_t mask = alignment - 1; 104 | return (value + mask) & ~mask; 105 | } 106 | 107 | // NOTE: hello, microsoft ucrt 108 | #undef min 109 | #undef max 110 | 111 | static OPAL_INLINE uint32_t min(uint32_t a, uint32_t b) 112 | { 113 | return (a < b) ? a : b; 114 | } 115 | 116 | static OPAL_INLINE uint32_t max(uint32_t a, uint32_t b) 117 | { 118 | return (a < b) ? b : a; 119 | } 120 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/shaders/vulkan/emit.comp.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(set = 0, binding = 0) uniform Application 4 | { 5 | vec4 viewport; 6 | float time; 7 | float dt; 8 | } application; 9 | 10 | layout(std430, set = 1, binding = 0) buffer ParticlePositions 11 | { 12 | vec4 data[]; 13 | } positions; 14 | 15 | layout(std430, set = 1, binding = 1) buffer ParticleVelocities 16 | { 17 | vec4 data[]; 18 | } velocities; 19 | 20 | layout(std430, set = 1, binding = 2) buffer ParticleParameters 21 | { 22 | vec4 data[]; 23 | } parameters; 24 | 25 | layout(std430, set = 1, binding = 3) buffer FreeIndices 26 | { 27 | uint data[]; 28 | } free_indices; 29 | 30 | layout(std430, set = 1, binding = 4) buffer EmitterData 31 | { 32 | int num_free; 33 | uint num_particles; 34 | uint num_triangles; 35 | uint padding; 36 | float min_lifetime; 37 | float max_lifetime; 38 | float min_imass; 39 | float max_imass; 40 | } emitter; 41 | 42 | layout(std430, set = 1, binding = 5) buffer MeshVertices 43 | { 44 | vec4 data[]; 45 | } mesh_vertices; 46 | 47 | layout(std430, set = 1, binding = 6) buffer MeshIndices 48 | { 49 | uint data[]; 50 | } mesh_indices; 51 | 52 | const vec4 RANDOM_SCALE = vec4(443.897f, 441.423f, 0.0973f, 0.1099f); 53 | 54 | vec3 random3(vec3 p) 55 | { 56 | p = fract(p * RANDOM_SCALE.xyz); 57 | p += dot(p, p.yxz + 19.19f); 58 | return fract((p.xxy + p.yzz) * p.zyx); 59 | } 60 | 61 | vec4 randomPointOnTriangle(vec2 barycentric, vec4 v0, vec4 v1, vec4 v2) 62 | { 63 | float b1 = 1.0f - sqrt(barycentric.x); 64 | float b2 = (1.0f - b1) * barycentric.y; 65 | 66 | vec4 e1 = v1 - v0; 67 | vec4 e2 = v2 - v0; 68 | 69 | return v0 + e1 * b1 + e2 * b2; 70 | } 71 | 72 | uint popFreeParticleIndex() 73 | { 74 | uint index = atomicAdd(emitter.num_free, -1); 75 | return free_indices.data[index]; 76 | } 77 | 78 | layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 79 | 80 | void computeMain() 81 | { 82 | uint free_index = gl_GlobalInvocationID.x; 83 | if (free_index >= uint(emitter.num_free)) 84 | return; 85 | 86 | uint triangle_index = free_index % emitter.num_triangles; 87 | uint i0 = mesh_indices.data[triangle_index * 3 + 0]; 88 | uint i1 = mesh_indices.data[triangle_index * 3 + 1]; 89 | uint i2 = mesh_indices.data[triangle_index * 3 + 2]; 90 | 91 | vec4 v0 = mesh_vertices.data[i0]; 92 | vec4 v1 = mesh_vertices.data[i1]; 93 | vec4 v2 = mesh_vertices.data[i2]; 94 | 95 | vec3 uv = vec3(float(triangle_index), application.time, float(free_index)); 96 | vec3 value = random3(uv); 97 | 98 | float lifetime = mix(emitter.min_lifetime, emitter.max_lifetime, value.x); 99 | float imass = mix(emitter.min_imass, emitter.max_imass, value.x); 100 | 101 | uint particle_index = popFreeParticleIndex(); 102 | positions.data[particle_index] = randomPointOnTriangle(value.yz, v0, v1, v2); 103 | velocities.data[particle_index] = vec4(0.0f, 0.0f, 0.0f, 0.0f); 104 | parameters.data[particle_index] = vec4(lifetime, lifetime, imass, 0.0f); 105 | } 106 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vk_video/vulkan_video_codec_h264std_decode.h: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 2 | #define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 3 | 4 | /* 5 | ** Copyright 2015-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | /* 11 | ** This header is generated from the Khronos Vulkan XML API Registry. 12 | ** 13 | */ 14 | 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | 21 | 22 | // vulkan_video_codec_h264std_decode is a preprocessor guard. Do not pass it to API calls. 23 | #define vulkan_video_codec_h264std_decode 1 24 | #include "vulkan_video_codec_h264std.h" 25 | 26 | #define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) 27 | 28 | #define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 29 | #define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_decode" 30 | #define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2 31 | 32 | typedef enum StdVideoDecodeH264FieldOrderCount { 33 | STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0, 34 | STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1, 35 | STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF, 36 | STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF 37 | } StdVideoDecodeH264FieldOrderCount; 38 | typedef struct StdVideoDecodeH264PictureInfoFlags { 39 | uint32_t field_pic_flag : 1; 40 | uint32_t is_intra : 1; 41 | uint32_t IdrPicFlag : 1; 42 | uint32_t bottom_field_flag : 1; 43 | uint32_t is_reference : 1; 44 | uint32_t complementary_field_pair : 1; 45 | } StdVideoDecodeH264PictureInfoFlags; 46 | 47 | typedef struct StdVideoDecodeH264PictureInfo { 48 | StdVideoDecodeH264PictureInfoFlags flags; 49 | uint8_t seq_parameter_set_id; 50 | uint8_t pic_parameter_set_id; 51 | uint8_t reserved1; 52 | uint8_t reserved2; 53 | uint16_t frame_num; 54 | uint16_t idr_pic_id; 55 | int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; 56 | } StdVideoDecodeH264PictureInfo; 57 | 58 | typedef struct StdVideoDecodeH264ReferenceInfoFlags { 59 | uint32_t top_field_flag : 1; 60 | uint32_t bottom_field_flag : 1; 61 | uint32_t used_for_long_term_reference : 1; 62 | uint32_t is_non_existing : 1; 63 | } StdVideoDecodeH264ReferenceInfoFlags; 64 | 65 | typedef struct StdVideoDecodeH264ReferenceInfo { 66 | StdVideoDecodeH264ReferenceInfoFlags flags; 67 | uint16_t FrameNum; 68 | uint16_t reserved; 69 | int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; 70 | } StdVideoDecodeH264ReferenceInfo; 71 | 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /3rdparty/vulkan/include/vulkan/vk_platform.h: -------------------------------------------------------------------------------- 1 | // 2 | // File: vk_platform.h 3 | // 4 | /* 5 | ** Copyright 2014-2023 The Khronos Group Inc. 6 | ** 7 | ** SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | 11 | #ifndef VK_PLATFORM_H_ 12 | #define VK_PLATFORM_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif // __cplusplus 18 | 19 | /* 20 | *************************************************************************************************** 21 | * Platform-specific directives and type declarations 22 | *************************************************************************************************** 23 | */ 24 | 25 | /* Platform-specific calling convention macros. 26 | * 27 | * Platforms should define these so that Vulkan clients call Vulkan commands 28 | * with the same calling conventions that the Vulkan implementation expects. 29 | * 30 | * VKAPI_ATTR - Placed before the return type in function declarations. 31 | * Useful for C++11 and GCC/Clang-style function attribute syntax. 32 | * VKAPI_CALL - Placed after the return type in function declarations. 33 | * Useful for MSVC-style calling convention syntax. 34 | * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. 35 | * 36 | * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); 37 | * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); 38 | */ 39 | #if defined(_WIN32) 40 | // On Windows, Vulkan commands use the stdcall convention 41 | #define VKAPI_ATTR 42 | #define VKAPI_CALL __stdcall 43 | #define VKAPI_PTR VKAPI_CALL 44 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 45 | #error "Vulkan is not supported for the 'armeabi' NDK ABI" 46 | #elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) 47 | // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" 48 | // calling convention, i.e. float parameters are passed in registers. This 49 | // is true even if the rest of the application passes floats on the stack, 50 | // as it does by default when compiling for the armeabi-v7a NDK ABI. 51 | #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) 52 | #define VKAPI_CALL 53 | #define VKAPI_PTR VKAPI_ATTR 54 | #else 55 | // On other platforms, use the default calling convention 56 | #define VKAPI_ATTR 57 | #define VKAPI_CALL 58 | #define VKAPI_PTR 59 | #endif 60 | 61 | #if !defined(VK_NO_STDDEF_H) 62 | #include 63 | #endif // !defined(VK_NO_STDDEF_H) 64 | 65 | #if !defined(VK_NO_STDINT_H) 66 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 67 | typedef signed __int8 int8_t; 68 | typedef unsigned __int8 uint8_t; 69 | typedef signed __int16 int16_t; 70 | typedef unsigned __int16 uint16_t; 71 | typedef signed __int32 int32_t; 72 | typedef unsigned __int32 uint32_t; 73 | typedef signed __int64 int64_t; 74 | typedef unsigned __int64 uint64_t; 75 | #else 76 | #include 77 | #endif 78 | #endif // !defined(VK_NO_STDINT_H) 79 | 80 | #ifdef __cplusplus 81 | } // extern "C" 82 | #endif // __cplusplus 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/benchmark_api_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_API_INTERNAL_H 2 | #define BENCHMARK_API_INTERNAL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "benchmark/benchmark.h" 12 | #include "commandlineflags.h" 13 | 14 | namespace benchmark { 15 | namespace internal { 16 | 17 | // Information kept per benchmark we may want to run 18 | class BenchmarkInstance { 19 | public: 20 | BenchmarkInstance(Benchmark* benchmark, int family_index, 21 | int per_family_instance_index, 22 | const std::vector& args, int threads); 23 | 24 | const BenchmarkName& name() const { return name_; } 25 | int family_index() const { return family_index_; } 26 | int per_family_instance_index() const { return per_family_instance_index_; } 27 | AggregationReportMode aggregation_report_mode() const { 28 | return aggregation_report_mode_; 29 | } 30 | TimeUnit time_unit() const { return time_unit_; } 31 | bool measure_process_cpu_time() const { return measure_process_cpu_time_; } 32 | bool use_real_time() const { return use_real_time_; } 33 | bool use_manual_time() const { return use_manual_time_; } 34 | BigO complexity() const { return complexity_; } 35 | BigOFunc* complexity_lambda() const { return complexity_lambda_; } 36 | const std::vector& statistics() const { return statistics_; } 37 | int repetitions() const { return repetitions_; } 38 | double min_time() const { return min_time_; } 39 | double min_warmup_time() const { return min_warmup_time_; } 40 | IterationCount iterations() const { return iterations_; } 41 | int threads() const { return threads_; } 42 | void Setup() const; 43 | void Teardown() const; 44 | 45 | State Run(IterationCount iters, int thread_id, internal::ThreadTimer* timer, 46 | internal::ThreadManager* manager, 47 | internal::PerfCountersMeasurement* perf_counters_measurement) const; 48 | 49 | private: 50 | BenchmarkName name_; 51 | Benchmark& benchmark_; 52 | const int family_index_; 53 | const int per_family_instance_index_; 54 | AggregationReportMode aggregation_report_mode_; 55 | const std::vector& args_; 56 | TimeUnit time_unit_; 57 | bool measure_process_cpu_time_; 58 | bool use_real_time_; 59 | bool use_manual_time_; 60 | BigO complexity_; 61 | BigOFunc* complexity_lambda_; 62 | UserCounters counters_; 63 | const std::vector& statistics_; 64 | int repetitions_; 65 | double min_time_; 66 | double min_warmup_time_; 67 | IterationCount iterations_; 68 | int threads_; // Number of concurrent threads to us 69 | 70 | typedef void (*callback_function)(const benchmark::State&); 71 | callback_function setup_ = nullptr; 72 | callback_function teardown_ = nullptr; 73 | }; 74 | 75 | bool FindBenchmarksInternal(const std::string& re, 76 | std::vector* benchmarks, 77 | std::ostream* Err); 78 | 79 | bool IsZero(double n); 80 | 81 | BENCHMARK_EXPORT 82 | ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false); 83 | 84 | } // end namespace internal 85 | } // end namespace benchmark 86 | 87 | #endif // BENCHMARK_API_INTERNAL_H 88 | -------------------------------------------------------------------------------- /3rdparty/gbench/cmake/AddCXXCompilerFlag.cmake: -------------------------------------------------------------------------------- 1 | # - Adds a compiler flag if it is supported by the compiler 2 | # 3 | # This function checks that the supplied compiler flag is supported and then 4 | # adds it to the corresponding compiler flags 5 | # 6 | # add_cxx_compiler_flag( []) 7 | # 8 | # - Example 9 | # 10 | # include(AddCXXCompilerFlag) 11 | # add_cxx_compiler_flag(-Wall) 12 | # add_cxx_compiler_flag(-no-strict-aliasing RELEASE) 13 | # Requires CMake 2.6+ 14 | 15 | if(__add_cxx_compiler_flag) 16 | return() 17 | endif() 18 | set(__add_cxx_compiler_flag INCLUDED) 19 | 20 | include(CheckCXXCompilerFlag) 21 | 22 | function(mangle_compiler_flag FLAG OUTPUT) 23 | string(TOUPPER "HAVE_CXX_FLAG_${FLAG}" SANITIZED_FLAG) 24 | string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG}) 25 | string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) 26 | string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG}) 27 | set(${OUTPUT} "${SANITIZED_FLAG}" PARENT_SCOPE) 28 | endfunction(mangle_compiler_flag) 29 | 30 | function(add_cxx_compiler_flag FLAG) 31 | mangle_compiler_flag("${FLAG}" MANGLED_FLAG) 32 | set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 33 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") 34 | check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) 35 | set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") 36 | if(${MANGLED_FLAG}) 37 | if(ARGC GREATER 1) 38 | set(VARIANT ${ARGV1}) 39 | string(TOUPPER "_${VARIANT}" VARIANT) 40 | else() 41 | set(VARIANT "") 42 | endif() 43 | set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${BENCHMARK_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) 44 | endif() 45 | endfunction() 46 | 47 | function(add_required_cxx_compiler_flag FLAG) 48 | mangle_compiler_flag("${FLAG}" MANGLED_FLAG) 49 | set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 50 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}") 51 | check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) 52 | set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") 53 | if(${MANGLED_FLAG}) 54 | if(ARGC GREATER 1) 55 | set(VARIANT ${ARGV1}) 56 | string(TOUPPER "_${VARIANT}" VARIANT) 57 | else() 58 | set(VARIANT "") 59 | endif() 60 | set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE) 61 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) 62 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) 63 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLAG}" PARENT_SCOPE) 64 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}" PARENT_SCOPE) 65 | else() 66 | message(FATAL_ERROR "Required flag '${FLAG}' is not supported by the compiler") 67 | endif() 68 | endfunction() 69 | 70 | function(check_cxx_warning_flag FLAG) 71 | mangle_compiler_flag("${FLAG}" MANGLED_FLAG) 72 | set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 73 | # Add -Werror to ensure the compiler generates an error if the warning flag 74 | # doesn't exist. 75 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror ${FLAG}") 76 | check_cxx_compiler_flag("${FLAG}" ${MANGLED_FLAG}) 77 | set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") 78 | endfunction() 79 | -------------------------------------------------------------------------------- /samples/04_triangle/main.osx.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "app.h" 7 | 8 | @interface AppDelegate : NSObject 9 | @end 10 | 11 | @implementation AppDelegate 12 | - (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender 13 | { 14 | return YES; 15 | } 16 | @end 17 | 18 | @interface WindowDelegate : NSObject 19 | @property Application *app; 20 | @property NSSize size; 21 | @end 22 | 23 | @implementation WindowDelegate 24 | - (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) size 25 | { 26 | NSRect frame = sender.frame; 27 | frame.size = size; 28 | 29 | NSRect content = [sender contentRectForFrameRect: frame]; 30 | self.size = content.size; 31 | 32 | return size; 33 | } 34 | 35 | - (void) windowDidResize:(NSNotification *) notification 36 | { 37 | assert(self.app); 38 | self.app->resize(self.size.width, self.size.height); 39 | } 40 | 41 | - (void) windowWillClose:(NSWindow *) sender 42 | { 43 | assert(self.app); 44 | self.app->shutdown(); 45 | } 46 | @end 47 | 48 | @interface WindowView : NSView 49 | @property Application *app; 50 | @end 51 | 52 | @implementation WindowView 53 | - (instancetype)initWithFrame:(NSRect) rect 54 | { 55 | self = [super initWithFrame: rect]; 56 | 57 | self.wantsLayer = YES; 58 | self.layer = [CAMetalLayer layer]; 59 | 60 | CADisplayLink *link = [self displayLinkWithTarget:self selector:@selector(update:)]; 61 | [link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 62 | 63 | return self; 64 | } 65 | 66 | - (void) update:(CADisplayLink *) sender 67 | { 68 | assert(self.app); 69 | 70 | float dt = static_cast(sender.targetTimestamp - sender.timestamp); 71 | 72 | self.app->update(dt); 73 | self.app->render(); 74 | self.app->present(); 75 | } 76 | @end 77 | 78 | int main(int argc, const char *argv[]) 79 | { 80 | NSRect screen = [[NSScreen mainScreen] frame]; 81 | 82 | int w = 800; 83 | int h = 600; 84 | int x = screen.size.width / 2 - w / 2; 85 | int y = screen.size.height / 2 - h / 2; 86 | 87 | NSRect view = NSMakeRect(x, y, w, h); 88 | 89 | Application app; 90 | 91 | [NSApplication sharedApplication]; 92 | NSApp.delegate = [[AppDelegate alloc] init]; 93 | NSApp.activationPolicy = NSApplicationActivationPolicyRegular; 94 | 95 | [NSApp finishLaunching]; 96 | 97 | NSWindow *window = [ 98 | [NSWindow alloc] 99 | initWithContentRect: view 100 | styleMask: (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable) 101 | backing: NSBackingStoreBuffered 102 | defer: NO 103 | ]; 104 | 105 | WindowDelegate *window_delegate = [[WindowDelegate alloc] init]; 106 | window_delegate.app = &app; 107 | 108 | WindowView *window_view = [[WindowView alloc] initWithFrame: view]; 109 | window_view.app = &app; 110 | 111 | window.delegate = window_delegate; 112 | window.contentView = window_view; 113 | window.acceptsMouseMovedEvents = YES; 114 | window.title = @"Opal Sample (04_triangle)"; 115 | 116 | [window makeKeyAndOrderFront:nil]; 117 | 118 | app.init(window_view.layer, w, h); 119 | [NSApp run]; 120 | 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/main.osx.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "app.h" 7 | 8 | @interface AppDelegate : NSObject 9 | @end 10 | 11 | @implementation AppDelegate 12 | - (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender 13 | { 14 | return YES; 15 | } 16 | @end 17 | 18 | @interface WindowDelegate : NSObject 19 | @property Application *app; 20 | @property NSSize size; 21 | @end 22 | 23 | @implementation WindowDelegate 24 | - (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) size 25 | { 26 | NSRect frame = sender.frame; 27 | frame.size = size; 28 | 29 | NSRect content = [sender contentRectForFrameRect: frame]; 30 | self.size = content.size; 31 | 32 | return size; 33 | } 34 | 35 | - (void) windowDidResize:(NSNotification *) notification 36 | { 37 | assert(self.app); 38 | self.app->resize(self.size.width, self.size.height); 39 | } 40 | 41 | - (void) windowWillClose:(NSWindow *) sender 42 | { 43 | assert(self.app); 44 | self.app->shutdown(); 45 | } 46 | @end 47 | 48 | @interface WindowView : NSView 49 | @property Application *app; 50 | @end 51 | 52 | @implementation WindowView 53 | - (instancetype)initWithFrame:(NSRect) rect 54 | { 55 | self = [super initWithFrame: rect]; 56 | 57 | self.wantsLayer = YES; 58 | self.layer = [CAMetalLayer layer]; 59 | 60 | CADisplayLink *link = [self displayLinkWithTarget:self selector:@selector(update:)]; 61 | [link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 62 | 63 | return self; 64 | } 65 | 66 | - (void) update:(CADisplayLink *) sender 67 | { 68 | assert(self.app); 69 | 70 | float dt = static_cast(sender.targetTimestamp - sender.timestamp); 71 | 72 | self.app->update(dt); 73 | self.app->render(); 74 | self.app->present(); 75 | } 76 | @end 77 | 78 | int main(int argc, const char *argv[]) 79 | { 80 | NSRect screen = [[NSScreen mainScreen] frame]; 81 | 82 | int w = 800; 83 | int h = 600; 84 | int x = screen.size.width / 2 - w / 2; 85 | int y = screen.size.height / 2 - h / 2; 86 | 87 | NSRect view = NSMakeRect(x, y, w, h); 88 | 89 | Application app; 90 | 91 | [NSApplication sharedApplication]; 92 | NSApp.delegate = [[AppDelegate alloc] init]; 93 | NSApp.activationPolicy = NSApplicationActivationPolicyRegular; 94 | 95 | [NSApp finishLaunching]; 96 | 97 | NSWindow *window = [ 98 | [NSWindow alloc] 99 | initWithContentRect: view 100 | styleMask: (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable) 101 | backing: NSBackingStoreBuffered 102 | defer: NO 103 | ]; 104 | 105 | WindowDelegate *window_delegate = [[WindowDelegate alloc] init]; 106 | window_delegate.app = &app; 107 | 108 | WindowView *window_view = [[WindowView alloc] initWithFrame: view]; 109 | window_view.app = &app; 110 | 111 | window.delegate = window_delegate; 112 | window.contentView = window_view; 113 | window.acceptsMouseMovedEvents = YES; 114 | window.title = @"Opal Sample (05_rt_triangle)"; 115 | 116 | [window makeKeyAndOrderFront:nil]; 117 | 118 | app.init(window_view.layer, w, h); 119 | [NSApp run]; 120 | 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/main.osx.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "app.h" 7 | 8 | @interface AppDelegate : NSObject 9 | @end 10 | 11 | @implementation AppDelegate 12 | - (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) sender 13 | { 14 | return YES; 15 | } 16 | @end 17 | 18 | @interface WindowDelegate : NSObject 19 | @property Application *app; 20 | @property NSSize size; 21 | @end 22 | 23 | @implementation WindowDelegate 24 | - (NSSize) windowWillResize:(NSWindow *) sender toSize:(NSSize) size 25 | { 26 | NSRect frame = sender.frame; 27 | frame.size = size; 28 | 29 | NSRect content = [sender contentRectForFrameRect: frame]; 30 | self.size = content.size; 31 | 32 | return size; 33 | } 34 | 35 | - (void) windowDidResize:(NSNotification *) notification 36 | { 37 | assert(self.app); 38 | self.app->resize(self.size.width, self.size.height); 39 | } 40 | 41 | - (void) windowWillClose:(NSWindow *) sender 42 | { 43 | assert(self.app); 44 | self.app->shutdown(); 45 | } 46 | @end 47 | 48 | @interface WindowView : NSView 49 | @property Application *app; 50 | @end 51 | 52 | @implementation WindowView 53 | - (instancetype)initWithFrame:(NSRect) rect 54 | { 55 | self = [super initWithFrame: rect]; 56 | 57 | self.wantsLayer = YES; 58 | self.layer = [CAMetalLayer layer]; 59 | 60 | CADisplayLink *link = [self displayLinkWithTarget:self selector:@selector(update:)]; 61 | [link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; 62 | 63 | return self; 64 | } 65 | 66 | - (void) update:(CADisplayLink *) sender 67 | { 68 | assert(self.app); 69 | 70 | float dt = static_cast(sender.targetTimestamp - sender.timestamp); 71 | 72 | self.app->update(dt); 73 | self.app->render(); 74 | self.app->present(); 75 | } 76 | @end 77 | 78 | int main(int argc, const char *argv[]) 79 | { 80 | NSRect screen = [[NSScreen mainScreen] frame]; 81 | 82 | int w = 800; 83 | int h = 600; 84 | int x = screen.size.width / 2 - w / 2; 85 | int y = screen.size.height / 2 - h / 2; 86 | 87 | NSRect view = NSMakeRect(x, y, w, h); 88 | 89 | Application app; 90 | 91 | [NSApplication sharedApplication]; 92 | NSApp.delegate = [[AppDelegate alloc] init]; 93 | NSApp.activationPolicy = NSApplicationActivationPolicyRegular; 94 | 95 | [NSApp finishLaunching]; 96 | 97 | NSWindow *window = [ 98 | [NSWindow alloc] 99 | initWithContentRect: view 100 | styleMask: (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable) 101 | backing: NSBackingStoreBuffered 102 | defer: NO 103 | ]; 104 | 105 | WindowDelegate *window_delegate = [[WindowDelegate alloc] init]; 106 | window_delegate.app = &app; 107 | 108 | WindowView *window_view = [[WindowView alloc] initWithFrame: view]; 109 | window_view.app = &app; 110 | 111 | window.delegate = window_delegate; 112 | window.contentView = window_view; 113 | window.acceptsMouseMovedEvents = YES; 114 | window.title = @"Opal Sample (06_gpu_particles)"; 115 | 116 | [window makeKeyAndOrderFront:nil]; 117 | 118 | app.init(window_view.layer, w, h); 119 | [NSApp run]; 120 | 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /3rdparty/gtest/googletest/src/gtest-assertion-result.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // The Google C++ Testing and Mocking Framework (Google Test) 31 | // 32 | // This file defines the AssertionResult type. 33 | 34 | #include "gtest/gtest-assertion-result.h" 35 | 36 | #include 37 | #include 38 | 39 | #include "gtest/gtest-message.h" 40 | 41 | namespace testing { 42 | 43 | // AssertionResult constructors. 44 | // Used in EXPECT_TRUE/FALSE(assertion_result). 45 | AssertionResult::AssertionResult(const AssertionResult& other) 46 | : success_(other.success_), 47 | message_(other.message_ != nullptr 48 | ? new ::std::string(*other.message_) 49 | : static_cast< ::std::string*>(nullptr)) {} 50 | 51 | // Swaps two AssertionResults. 52 | void AssertionResult::swap(AssertionResult& other) { 53 | using std::swap; 54 | swap(success_, other.success_); 55 | swap(message_, other.message_); 56 | } 57 | 58 | // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. 59 | AssertionResult AssertionResult::operator!() const { 60 | AssertionResult negation(!success_); 61 | if (message_ != nullptr) negation << *message_; 62 | return negation; 63 | } 64 | 65 | // Makes a successful assertion result. 66 | AssertionResult AssertionSuccess() { return AssertionResult(true); } 67 | 68 | // Makes a failed assertion result. 69 | AssertionResult AssertionFailure() { return AssertionResult(false); } 70 | 71 | // Makes a failed assertion result with the given failure message. 72 | // Deprecated; use AssertionFailure() << message. 73 | AssertionResult AssertionFailure(const Message& message) { 74 | return AssertionFailure() << message; 75 | } 76 | 77 | } // namespace testing 78 | -------------------------------------------------------------------------------- /samples/04_triangle/main.win.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | /* 8 | */ 9 | LRESULT CALLBACK windowProc(HWND handle, UINT message, WPARAM w_param, LPARAM l_param) 10 | { 11 | Application *app = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_USERDATA)); 12 | 13 | switch (message) 14 | { 15 | case WM_SIZE: 16 | { 17 | uint32_t width = static_cast(LOWORD(l_param)); 18 | uint32_t height = static_cast(HIWORD(l_param)); 19 | 20 | if (app) 21 | app->resize(width, height); 22 | } 23 | break; 24 | 25 | case WM_CLOSE: 26 | { 27 | PostQuitMessage(0); 28 | } 29 | break; 30 | 31 | default: 32 | return DefWindowProcW(handle, message, w_param, l_param); 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | HWND createWindow(const char *title, uint32_t width, uint32_t height) 39 | { 40 | HINSTANCE instance = GetModuleHandle(nullptr); 41 | WNDCLASSEXW wc = {}; 42 | 43 | wc.cbSize = sizeof(WNDCLASSEXW); 44 | wc.style = CS_HREDRAW | CS_VREDRAW; 45 | wc.lpfnWndProc = windowProc; 46 | wc.hInstance = instance; 47 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 48 | wc.lpszClassName = L"Opal Window"; 49 | 50 | RegisterClassExW(&wc); 51 | 52 | assert(title); 53 | int size = static_cast(strlen(title)); 54 | 55 | wchar_t titlew[4096] = {}; 56 | MultiByteToWideChar(CP_UTF8, 0, title, size, titlew, 4096); 57 | 58 | RECT rect = {0, 0, static_cast(width), static_cast(height)}; 59 | AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); 60 | 61 | HWND handle = CreateWindowExW( 62 | 0, 63 | wc.lpszClassName, 64 | titlew, 65 | WS_OVERLAPPEDWINDOW, 66 | CW_USEDEFAULT, CW_USEDEFAULT, 67 | rect.right - rect.left, 68 | rect.bottom - rect.top, 69 | NULL, 70 | NULL, 71 | instance, 72 | NULL 73 | ); 74 | 75 | assert(handle != NULL); 76 | return handle; 77 | } 78 | 79 | void destroyWindow(HWND handle) 80 | { 81 | DestroyWindow(handle); 82 | } 83 | 84 | int main() 85 | { 86 | const char *title = "Opal Sample (04_triangle)"; 87 | const uint32_t width = 800; 88 | const uint32_t height = 600; 89 | 90 | Application app; 91 | 92 | HWND handle = createWindow(title, width, height); 93 | 94 | SetWindowLongPtrW(handle, GWLP_USERDATA, reinterpret_cast(&app)); 95 | ShowWindow(handle, SW_SHOW); 96 | UpdateWindow(handle); 97 | 98 | app.init(handle, width, height); 99 | 100 | MSG msg = {}; 101 | LARGE_INTEGER begin_time = {}; 102 | LARGE_INTEGER end_time = {}; 103 | LARGE_INTEGER frequency = {}; 104 | float dt = 0.0f; 105 | 106 | QueryPerformanceFrequency(&frequency); 107 | double denominator = 1.0 / frequency.QuadPart; 108 | 109 | while (true) 110 | { 111 | QueryPerformanceCounter(&begin_time); 112 | if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE) > 0) 113 | { 114 | if (msg.message == WM_QUIT) 115 | break; 116 | 117 | TranslateMessage(&msg); 118 | DispatchMessageW(&msg); 119 | } 120 | 121 | app.update(dt); 122 | app.render(); 123 | app.present(); 124 | 125 | QueryPerformanceCounter(&end_time); 126 | dt = static_cast((end_time.QuadPart - begin_time.QuadPart) * denominator); 127 | } 128 | 129 | app.shutdown(); 130 | 131 | destroyWindow(handle); 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /samples/05_rt_triangle/main.win.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | /* 8 | */ 9 | LRESULT CALLBACK windowProc(HWND handle, UINT message, WPARAM w_param, LPARAM l_param) 10 | { 11 | Application *app = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_USERDATA)); 12 | 13 | switch (message) 14 | { 15 | case WM_SIZE: 16 | { 17 | uint32_t width = static_cast(LOWORD(l_param)); 18 | uint32_t height = static_cast(HIWORD(l_param)); 19 | 20 | if (app) 21 | app->resize(width, height); 22 | } 23 | break; 24 | 25 | case WM_CLOSE: 26 | { 27 | PostQuitMessage(0); 28 | } 29 | break; 30 | 31 | default: 32 | return DefWindowProcW(handle, message, w_param, l_param); 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | HWND createWindow(const char *title, uint32_t width, uint32_t height) 39 | { 40 | HINSTANCE instance = GetModuleHandle(nullptr); 41 | WNDCLASSEXW wc = {}; 42 | 43 | wc.cbSize = sizeof(WNDCLASSEXW); 44 | wc.style = CS_HREDRAW | CS_VREDRAW; 45 | wc.lpfnWndProc = windowProc; 46 | wc.hInstance = instance; 47 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 48 | wc.lpszClassName = L"Opal Window"; 49 | 50 | RegisterClassExW(&wc); 51 | 52 | assert(title); 53 | int size = static_cast(strlen(title)); 54 | 55 | wchar_t titlew[4096] = {}; 56 | MultiByteToWideChar(CP_UTF8, 0, title, size, titlew, 4096); 57 | 58 | RECT rect = {0, 0, static_cast(width), static_cast(height)}; 59 | AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); 60 | 61 | HWND handle = CreateWindowExW( 62 | 0, 63 | wc.lpszClassName, 64 | titlew, 65 | WS_OVERLAPPEDWINDOW, 66 | CW_USEDEFAULT, CW_USEDEFAULT, 67 | rect.right - rect.left, 68 | rect.bottom - rect.top, 69 | NULL, 70 | NULL, 71 | instance, 72 | NULL 73 | ); 74 | 75 | assert(handle != NULL); 76 | return handle; 77 | } 78 | 79 | void destroyWindow(HWND handle) 80 | { 81 | DestroyWindow(handle); 82 | } 83 | 84 | int main() 85 | { 86 | const char *title = "Opal Sample (05_rt_triangle)"; 87 | const uint32_t width = 800; 88 | const uint32_t height = 600; 89 | 90 | Application app; 91 | 92 | HWND handle = createWindow(title, width, height); 93 | 94 | SetWindowLongPtrW(handle, GWLP_USERDATA, reinterpret_cast(&app)); 95 | ShowWindow(handle, SW_SHOW); 96 | UpdateWindow(handle); 97 | 98 | app.init(handle, width, height); 99 | 100 | MSG msg = {}; 101 | LARGE_INTEGER begin_time = {}; 102 | LARGE_INTEGER end_time = {}; 103 | LARGE_INTEGER frequency = {}; 104 | float dt = 0.0f; 105 | 106 | QueryPerformanceFrequency(&frequency); 107 | double denominator = 1.0 / frequency.QuadPart; 108 | 109 | while (true) 110 | { 111 | QueryPerformanceCounter(&begin_time); 112 | if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE) > 0) 113 | { 114 | if (msg.message == WM_QUIT) 115 | break; 116 | 117 | TranslateMessage(&msg); 118 | DispatchMessageW(&msg); 119 | } 120 | 121 | app.update(dt); 122 | app.render(); 123 | app.present(); 124 | 125 | QueryPerformanceCounter(&end_time); 126 | dt = static_cast((end_time.QuadPart - begin_time.QuadPart) * denominator); 127 | } 128 | 129 | app.shutdown(); 130 | 131 | destroyWindow(handle); 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /samples/06_gpu_particles/main.win.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | #include 4 | 5 | #include "app.h" 6 | 7 | /* 8 | */ 9 | LRESULT CALLBACK windowProc(HWND handle, UINT message, WPARAM w_param, LPARAM l_param) 10 | { 11 | Application *app = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_USERDATA)); 12 | 13 | switch (message) 14 | { 15 | case WM_SIZE: 16 | { 17 | uint32_t width = static_cast(LOWORD(l_param)); 18 | uint32_t height = static_cast(HIWORD(l_param)); 19 | 20 | if (app) 21 | app->resize(width, height); 22 | } 23 | break; 24 | 25 | case WM_CLOSE: 26 | { 27 | PostQuitMessage(0); 28 | } 29 | break; 30 | 31 | default: 32 | return DefWindowProcW(handle, message, w_param, l_param); 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | HWND createWindow(const char *title, uint32_t width, uint32_t height) 39 | { 40 | HINSTANCE instance = GetModuleHandle(nullptr); 41 | WNDCLASSEXW wc = {}; 42 | 43 | wc.cbSize = sizeof(WNDCLASSEXW); 44 | wc.style = CS_HREDRAW | CS_VREDRAW; 45 | wc.lpfnWndProc = windowProc; 46 | wc.hInstance = instance; 47 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 48 | wc.lpszClassName = L"Opal Window"; 49 | 50 | RegisterClassExW(&wc); 51 | 52 | assert(title); 53 | int size = static_cast(strlen(title)); 54 | 55 | wchar_t titlew[4096] = {}; 56 | MultiByteToWideChar(CP_UTF8, 0, title, size, titlew, 4096); 57 | 58 | RECT rect = {0, 0, static_cast(width), static_cast(height)}; 59 | AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); 60 | 61 | HWND handle = CreateWindowExW( 62 | 0, 63 | wc.lpszClassName, 64 | titlew, 65 | WS_OVERLAPPEDWINDOW, 66 | CW_USEDEFAULT, CW_USEDEFAULT, 67 | rect.right - rect.left, 68 | rect.bottom - rect.top, 69 | NULL, 70 | NULL, 71 | instance, 72 | NULL 73 | ); 74 | 75 | assert(handle != NULL); 76 | return handle; 77 | } 78 | 79 | void destroyWindow(HWND handle) 80 | { 81 | DestroyWindow(handle); 82 | } 83 | 84 | int main() 85 | { 86 | const char *title = "Opal Sample (06_gpu_particles)"; 87 | const uint32_t width = 800; 88 | const uint32_t height = 600; 89 | 90 | Application app; 91 | 92 | HWND handle = createWindow(title, width, height); 93 | 94 | SetWindowLongPtrW(handle, GWLP_USERDATA, reinterpret_cast(&app)); 95 | ShowWindow(handle, SW_SHOW); 96 | UpdateWindow(handle); 97 | 98 | app.init(handle, width, height); 99 | 100 | MSG msg = {}; 101 | LARGE_INTEGER begin_time = {}; 102 | LARGE_INTEGER end_time = {}; 103 | LARGE_INTEGER frequency = {}; 104 | float dt = 0.0f; 105 | 106 | QueryPerformanceFrequency(&frequency); 107 | double denominator = 1.0 / frequency.QuadPart; 108 | 109 | while (true) 110 | { 111 | QueryPerformanceCounter(&begin_time); 112 | if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE) > 0) 113 | { 114 | if (msg.message == WM_QUIT) 115 | break; 116 | 117 | TranslateMessage(&msg); 118 | DispatchMessageW(&msg); 119 | } 120 | 121 | app.update(dt); 122 | app.render(); 123 | app.present(); 124 | 125 | QueryPerformanceCounter(&end_time); 126 | dt = static_cast((end_time.QuadPart - begin_time.QuadPart) * denominator); 127 | } 128 | 129 | app.shutdown(); 130 | 131 | destroyWindow(handle); 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/internal_macros.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_INTERNAL_MACROS_H_ 2 | #define BENCHMARK_INTERNAL_MACROS_H_ 3 | 4 | /* Needed to detect STL */ 5 | #include 6 | 7 | // clang-format off 8 | 9 | #ifndef __has_feature 10 | #define __has_feature(x) 0 11 | #endif 12 | 13 | #if defined(__clang__) 14 | #if !defined(COMPILER_CLANG) 15 | #define COMPILER_CLANG 16 | #endif 17 | #elif defined(_MSC_VER) 18 | #if !defined(COMPILER_MSVC) 19 | #define COMPILER_MSVC 20 | #endif 21 | #elif defined(__GNUC__) 22 | #if !defined(COMPILER_GCC) 23 | #define COMPILER_GCC 24 | #endif 25 | #endif 26 | 27 | #if __has_feature(cxx_attributes) 28 | #define BENCHMARK_NORETURN [[noreturn]] 29 | #elif defined(__GNUC__) 30 | #define BENCHMARK_NORETURN __attribute__((noreturn)) 31 | #elif defined(COMPILER_MSVC) 32 | #define BENCHMARK_NORETURN __declspec(noreturn) 33 | #else 34 | #define BENCHMARK_NORETURN 35 | #endif 36 | 37 | #if defined(__CYGWIN__) 38 | #define BENCHMARK_OS_CYGWIN 1 39 | #elif defined(_WIN32) 40 | #define BENCHMARK_OS_WINDOWS 1 41 | // WINAPI_FAMILY_PARTITION is defined in winapifamily.h. 42 | // We include windows.h which implicitly includes winapifamily.h for compatibility. 43 | #ifndef NOMINMAX 44 | #define NOMINMAX 45 | #endif 46 | #include 47 | #if defined(WINAPI_FAMILY_PARTITION) 48 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 49 | #define BENCHMARK_OS_WINDOWS_WIN32 1 50 | #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 51 | #define BENCHMARK_OS_WINDOWS_RT 1 52 | #endif 53 | #endif 54 | #if defined(__MINGW32__) 55 | #define BENCHMARK_OS_MINGW 1 56 | #endif 57 | #elif defined(__APPLE__) 58 | #define BENCHMARK_OS_APPLE 1 59 | #include "TargetConditionals.h" 60 | #if defined(TARGET_OS_MAC) 61 | #define BENCHMARK_OS_MACOSX 1 62 | #if defined(TARGET_OS_IPHONE) 63 | #define BENCHMARK_OS_IOS 1 64 | #endif 65 | #endif 66 | #elif defined(__FreeBSD__) 67 | #define BENCHMARK_OS_FREEBSD 1 68 | #elif defined(__NetBSD__) 69 | #define BENCHMARK_OS_NETBSD 1 70 | #elif defined(__OpenBSD__) 71 | #define BENCHMARK_OS_OPENBSD 1 72 | #elif defined(__DragonFly__) 73 | #define BENCHMARK_OS_DRAGONFLY 1 74 | #elif defined(__linux__) 75 | #define BENCHMARK_OS_LINUX 1 76 | #elif defined(__native_client__) 77 | #define BENCHMARK_OS_NACL 1 78 | #elif defined(__EMSCRIPTEN__) 79 | #define BENCHMARK_OS_EMSCRIPTEN 1 80 | #elif defined(__rtems__) 81 | #define BENCHMARK_OS_RTEMS 1 82 | #elif defined(__Fuchsia__) 83 | #define BENCHMARK_OS_FUCHSIA 1 84 | #elif defined (__SVR4) && defined (__sun) 85 | #define BENCHMARK_OS_SOLARIS 1 86 | #elif defined(__QNX__) 87 | #define BENCHMARK_OS_QNX 1 88 | #elif defined(__MVS__) 89 | #define BENCHMARK_OS_ZOS 1 90 | #elif defined(__hexagon__) 91 | #define BENCHMARK_OS_QURT 1 92 | #endif 93 | 94 | #if defined(__ANDROID__) && defined(__GLIBCXX__) 95 | #define BENCHMARK_STL_ANDROID_GNUSTL 1 96 | #endif 97 | 98 | #if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \ 99 | && !defined(__EXCEPTIONS) 100 | #define BENCHMARK_HAS_NO_EXCEPTIONS 101 | #endif 102 | 103 | #if defined(COMPILER_CLANG) || defined(COMPILER_GCC) 104 | #define BENCHMARK_MAYBE_UNUSED __attribute__((unused)) 105 | #else 106 | #define BENCHMARK_MAYBE_UNUSED 107 | #endif 108 | 109 | // clang-format on 110 | 111 | #endif // BENCHMARK_INTERNAL_MACROS_H_ 112 | -------------------------------------------------------------------------------- /src/null/null_instance.c: -------------------------------------------------------------------------------- 1 | #include "null_internal.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | /* 8 | */ 9 | static Opal_Result null_instanceEnumerateDevices(Opal_Instance this, uint32_t *device_count, Opal_DeviceInfo *infos) 10 | { 11 | assert(this); 12 | assert(device_count); 13 | 14 | OPAL_UNUSED(this); 15 | 16 | *device_count = 1; 17 | 18 | if (infos) 19 | null_fillDeviceInfo(&infos[0]); 20 | 21 | return OPAL_SUCCESS; 22 | } 23 | 24 | static Opal_Result null_instanceCreateSurface(Opal_Instance this, void *handle, Opal_Surface *surface) 25 | { 26 | OPAL_UNUSED(this); 27 | OPAL_UNUSED(handle); 28 | OPAL_UNUSED(surface); 29 | 30 | return OPAL_NOT_SUPPORTED; 31 | } 32 | 33 | static Opal_Result null_instanceCreateDefaultDevice(Opal_Instance this, Opal_DeviceHint hint, Opal_Device *device) 34 | { 35 | assert(this); 36 | assert(device); 37 | 38 | OPAL_UNUSED(hint); 39 | 40 | Null_Instance *instance_ptr = (Null_Instance *)this; 41 | Null_Device *device_ptr = (Null_Device *)malloc(sizeof(Null_Device)); 42 | assert(device_ptr); 43 | 44 | Opal_Result result = null_deviceInitialize(device_ptr, instance_ptr); 45 | if (result != OPAL_SUCCESS) 46 | { 47 | device_ptr->vtbl->destroyDevice((Opal_Device)device_ptr); 48 | return result; 49 | } 50 | 51 | *device = (Opal_Device)device_ptr; 52 | return OPAL_SUCCESS; 53 | } 54 | 55 | static Opal_Result null_instanceCreateDevice(Opal_Instance this, uint32_t index, Opal_Device *device) 56 | { 57 | assert(this); 58 | assert(device); 59 | 60 | if (index != 0) 61 | return OPAL_INVALID_DEVICE_INDEX; 62 | 63 | Null_Instance *instance_ptr = (Null_Instance *)this; 64 | Null_Device *device_ptr = (Null_Device *)malloc(sizeof(Null_Device)); 65 | assert(device_ptr); 66 | 67 | Opal_Result result = null_deviceInitialize(device_ptr, instance_ptr); 68 | if (result != OPAL_SUCCESS) 69 | { 70 | device_ptr->vtbl->destroyDevice((Opal_Device)device_ptr); 71 | return result; 72 | } 73 | 74 | *device = (Opal_Device)device_ptr; 75 | return OPAL_SUCCESS; 76 | } 77 | 78 | static Opal_Result null_instanceDestroySurface(Opal_Instance this, Opal_Surface surface) 79 | { 80 | OPAL_UNUSED(this); 81 | OPAL_UNUSED(surface); 82 | 83 | return OPAL_NOT_SUPPORTED; 84 | } 85 | 86 | static Opal_Result null_instanceDestroy(Opal_Instance this) 87 | { 88 | assert(this); 89 | 90 | Null_Instance *ptr = (Null_Instance *)this; 91 | 92 | free(ptr->application_name); 93 | free(ptr->engine_name); 94 | 95 | free(ptr); 96 | return OPAL_SUCCESS; 97 | } 98 | 99 | /* 100 | */ 101 | static Opal_InstanceTable instance_vtbl = 102 | { 103 | null_instanceEnumerateDevices, 104 | 105 | null_instanceCreateSurface, 106 | null_instanceCreateDevice, 107 | null_instanceCreateDefaultDevice, 108 | 109 | null_instanceDestroySurface, 110 | null_instanceDestroy, 111 | }; 112 | 113 | /* 114 | */ 115 | Opal_Result null_createInstance(const Opal_InstanceDesc *desc, Opal_Instance *instance) 116 | { 117 | assert(desc); 118 | assert(instance); 119 | 120 | Null_Instance *ptr = (Null_Instance *)malloc(sizeof(Null_Instance)); 121 | assert(ptr); 122 | 123 | // vtable 124 | ptr->vtbl = &instance_vtbl; 125 | 126 | // info 127 | ptr->application_name = strdup(desc->application_name); 128 | ptr->application_version = desc->application_version; 129 | ptr->engine_name = strdup(desc->engine_name); 130 | ptr->engine_version = desc->engine_version; 131 | 132 | *instance = (Opal_Instance)ptr; 133 | return OPAL_SUCCESS; 134 | } 135 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/benchmark_register.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_REGISTER_H 2 | #define BENCHMARK_REGISTER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "check.h" 9 | 10 | namespace benchmark { 11 | namespace internal { 12 | 13 | // Append the powers of 'mult' in the closed interval [lo, hi]. 14 | // Returns iterator to the start of the inserted range. 15 | template 16 | typename std::vector::iterator AddPowers(std::vector* dst, T lo, T hi, 17 | int mult) { 18 | BM_CHECK_GE(lo, 0); 19 | BM_CHECK_GE(hi, lo); 20 | BM_CHECK_GE(mult, 2); 21 | 22 | const size_t start_offset = dst->size(); 23 | 24 | static const T kmax = std::numeric_limits::max(); 25 | 26 | // Space out the values in multiples of "mult" 27 | for (T i = static_cast(1); i <= hi; i = static_cast(i * mult)) { 28 | if (i >= lo) { 29 | dst->push_back(i); 30 | } 31 | // Break the loop here since multiplying by 32 | // 'mult' would move outside of the range of T 33 | if (i > kmax / mult) break; 34 | } 35 | 36 | return dst->begin() + static_cast(start_offset); 37 | } 38 | 39 | template 40 | void AddNegatedPowers(std::vector* dst, T lo, T hi, int mult) { 41 | // We negate lo and hi so we require that they cannot be equal to 'min'. 42 | BM_CHECK_GT(lo, std::numeric_limits::min()); 43 | BM_CHECK_GT(hi, std::numeric_limits::min()); 44 | BM_CHECK_GE(hi, lo); 45 | BM_CHECK_LE(hi, 0); 46 | 47 | // Add positive powers, then negate and reverse. 48 | // Casts necessary since small integers get promoted 49 | // to 'int' when negating. 50 | const auto lo_complement = static_cast(-lo); 51 | const auto hi_complement = static_cast(-hi); 52 | 53 | const auto it = AddPowers(dst, hi_complement, lo_complement, mult); 54 | 55 | std::for_each(it, dst->end(), [](T& t) { t = static_cast(t * -1); }); 56 | std::reverse(it, dst->end()); 57 | } 58 | 59 | template 60 | void AddRange(std::vector* dst, T lo, T hi, int mult) { 61 | static_assert(std::is_integral::value && std::is_signed::value, 62 | "Args type must be a signed integer"); 63 | 64 | BM_CHECK_GE(hi, lo); 65 | BM_CHECK_GE(mult, 2); 66 | 67 | // Add "lo" 68 | dst->push_back(lo); 69 | 70 | // Handle lo == hi as a special case, so we then know 71 | // lo < hi and so it is safe to add 1 to lo and subtract 1 72 | // from hi without falling outside of the range of T. 73 | if (lo == hi) return; 74 | 75 | // Ensure that lo_inner <= hi_inner below. 76 | if (lo + 1 == hi) { 77 | dst->push_back(hi); 78 | return; 79 | } 80 | 81 | // Add all powers of 'mult' in the range [lo+1, hi-1] (inclusive). 82 | const auto lo_inner = static_cast(lo + 1); 83 | const auto hi_inner = static_cast(hi - 1); 84 | 85 | // Insert negative values 86 | if (lo_inner < 0) { 87 | AddNegatedPowers(dst, lo_inner, std::min(hi_inner, T{-1}), mult); 88 | } 89 | 90 | // Treat 0 as a special case (see discussion on #762). 91 | if (lo < 0 && hi >= 0) { 92 | dst->push_back(0); 93 | } 94 | 95 | // Insert positive values 96 | if (hi_inner > 0) { 97 | AddPowers(dst, std::max(lo_inner, T{1}), hi_inner, mult); 98 | } 99 | 100 | // Add "hi" (if different from last value). 101 | if (hi != dst->back()) { 102 | dst->push_back(hi); 103 | } 104 | } 105 | 106 | } // namespace internal 107 | } // namespace benchmark 108 | 109 | #endif // BENCHMARK_REGISTER_H 110 | -------------------------------------------------------------------------------- /3rdparty/gbench/src/check.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECK_H_ 2 | #define CHECK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "benchmark/export.h" 9 | #include "internal_macros.h" 10 | #include "log.h" 11 | 12 | #if defined(__GNUC__) || defined(__clang__) 13 | #define BENCHMARK_NOEXCEPT noexcept 14 | #define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) 15 | #elif defined(_MSC_VER) && !defined(__clang__) 16 | #if _MSC_VER >= 1900 17 | #define BENCHMARK_NOEXCEPT noexcept 18 | #define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) 19 | #else 20 | #define BENCHMARK_NOEXCEPT 21 | #define BENCHMARK_NOEXCEPT_OP(x) 22 | #endif 23 | #define __func__ __FUNCTION__ 24 | #else 25 | #define BENCHMARK_NOEXCEPT 26 | #define BENCHMARK_NOEXCEPT_OP(x) 27 | #endif 28 | 29 | namespace benchmark { 30 | namespace internal { 31 | 32 | typedef void(AbortHandlerT)(); 33 | 34 | BENCHMARK_EXPORT 35 | AbortHandlerT*& GetAbortHandler(); 36 | 37 | BENCHMARK_NORETURN inline void CallAbortHandler() { 38 | GetAbortHandler()(); 39 | std::abort(); // fallback to enforce noreturn 40 | } 41 | 42 | // CheckHandler is the class constructed by failing BM_CHECK macros. 43 | // CheckHandler will log information about the failures and abort when it is 44 | // destructed. 45 | class CheckHandler { 46 | public: 47 | CheckHandler(const char* check, const char* file, const char* func, int line) 48 | : log_(GetErrorLogInstance()) { 49 | log_ << file << ":" << line << ": " << func << ": Check `" << check 50 | << "' failed. "; 51 | } 52 | 53 | LogType& GetLog() { return log_; } 54 | 55 | #if defined(COMPILER_MSVC) 56 | #pragma warning(push) 57 | #pragma warning(disable : 4722) 58 | #endif 59 | BENCHMARK_NORETURN ~CheckHandler() BENCHMARK_NOEXCEPT_OP(false) { 60 | log_ << std::endl; 61 | CallAbortHandler(); 62 | } 63 | #if defined(COMPILER_MSVC) 64 | #pragma warning(pop) 65 | #endif 66 | 67 | CheckHandler& operator=(const CheckHandler&) = delete; 68 | CheckHandler(const CheckHandler&) = delete; 69 | CheckHandler() = delete; 70 | 71 | private: 72 | LogType& log_; 73 | }; 74 | 75 | } // end namespace internal 76 | } // end namespace benchmark 77 | 78 | // The BM_CHECK macro returns a std::ostream object that can have extra 79 | // information written to it. 80 | #ifndef NDEBUG 81 | #define BM_CHECK(b) \ 82 | (b ? ::benchmark::internal::GetNullLogInstance() \ 83 | : ::benchmark::internal::CheckHandler(#b, __FILE__, __func__, __LINE__) \ 84 | .GetLog()) 85 | #else 86 | #define BM_CHECK(b) ::benchmark::internal::GetNullLogInstance() 87 | #endif 88 | 89 | // clang-format off 90 | // preserve whitespacing between operators for alignment 91 | #define BM_CHECK_EQ(a, b) BM_CHECK((a) == (b)) 92 | #define BM_CHECK_NE(a, b) BM_CHECK((a) != (b)) 93 | #define BM_CHECK_GE(a, b) BM_CHECK((a) >= (b)) 94 | #define BM_CHECK_LE(a, b) BM_CHECK((a) <= (b)) 95 | #define BM_CHECK_GT(a, b) BM_CHECK((a) > (b)) 96 | #define BM_CHECK_LT(a, b) BM_CHECK((a) < (b)) 97 | 98 | #define BM_CHECK_FLOAT_EQ(a, b, eps) BM_CHECK(std::fabs((a) - (b)) < (eps)) 99 | #define BM_CHECK_FLOAT_NE(a, b, eps) BM_CHECK(std::fabs((a) - (b)) >= (eps)) 100 | #define BM_CHECK_FLOAT_GE(a, b, eps) BM_CHECK((a) - (b) > -(eps)) 101 | #define BM_CHECK_FLOAT_LE(a, b, eps) BM_CHECK((b) - (a) > -(eps)) 102 | #define BM_CHECK_FLOAT_GT(a, b, eps) BM_CHECK((a) - (b) > (eps)) 103 | #define BM_CHECK_FLOAT_LT(a, b, eps) BM_CHECK((b) - (a) > (eps)) 104 | //clang-format on 105 | 106 | #endif // CHECK_H_ 107 | --------------------------------------------------------------------------------