mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-01-31 01:15:24 +01:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d63733830f | ||
|
|
3ebd496c37 | ||
|
|
f0f2b013fc | ||
|
|
9a75509614 | ||
|
|
c513a29bcf | ||
|
|
5d39c884b5 | ||
|
|
6a0f811812 | ||
|
|
f509fb6950 | ||
|
|
33a475a456 | ||
|
|
d2fb90a700 | ||
|
|
a34467dccd | ||
|
|
c6d0f5e3cd | ||
|
|
34c9590cf1 | ||
|
|
a2c7542e48 | ||
|
|
72a9f18456 | ||
|
|
7f59757eea | ||
|
|
3b89020082 | ||
|
|
a7b07eb53f | ||
|
|
58d13dac34 | ||
|
|
5a8921dd22 | ||
|
|
f964dfaa5e | ||
|
|
17274eb397 | ||
|
|
2f0b00a7a1 | ||
|
|
260380abec | ||
|
|
57fc87061d | ||
|
|
cc9f7e723a | ||
|
|
6a41e05694 | ||
|
|
c8e1dc5328 | ||
|
|
c2ee5a0234 | ||
|
|
3cafd2dc69 | ||
|
|
4b8890c438 | ||
|
|
19882dc160 | ||
|
|
0c21023bb2 | ||
|
|
68e6ede47e | ||
|
|
1ed3001358 | ||
|
|
b8ff171127 | ||
|
|
7d16a915ed | ||
|
|
ecc24ce2e9 | ||
|
|
65748351c7 | ||
|
|
a60489b6fd | ||
|
|
e8dbcc31aa | ||
|
|
5dbaf194c5 | ||
|
|
affdb78a65 | ||
|
|
313ddb7879 | ||
|
|
046b416f61 | ||
|
|
2cb311dd24 | ||
|
|
ba36d4b0c8 | ||
|
|
5de1c60d50 | ||
|
|
a8a170ebe6 | ||
|
|
d7937943b0 |
@@ -22,7 +22,7 @@ jobs:
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
title: "PAD: Update to latest controller database"
|
||||
commit-message: "PAD: Update to latest controller database."
|
||||
commit-message: "[ci skip] PAD: Update to latest controller database."
|
||||
committer: "PCSX2 Bot <PCSX2Bot@users.noreply.github.com>"
|
||||
author: "PCSX2 Bot <PCSX2Bot@users.noreply.github.com>"
|
||||
body: "Weekly automatic update of SDL Controller DB."
|
||||
|
||||
@@ -206,7 +206,7 @@ GIT_VERSION=$(git tag --points-at HEAD)
|
||||
|
||||
if [[ "${GIT_VERSION}" == "" ]]; then
|
||||
# In the odd event that we run this script before the release gets tagged.
|
||||
GIT_VERSION=$(git describe --tags)
|
||||
GIT_VERSION=$(git describe --tags || true)
|
||||
if [[ "${GIT_VERSION}" == "" ]]; then
|
||||
GIT_VERSION=$(git rev-parse HEAD)
|
||||
fi
|
||||
|
||||
@@ -19,7 +19,7 @@ LIBJPEG=9f
|
||||
LIBPNG=1.6.44
|
||||
LIBWEBP=1.4.0
|
||||
LZ4=b8fd2d15309dd4e605070bd4486e26b6ef814e29
|
||||
SDL=SDL2-2.30.9
|
||||
SDL=SDL2-2.30.10
|
||||
QT=6.8.1
|
||||
ZSTD=1.5.6
|
||||
|
||||
@@ -37,7 +37,7 @@ fd6f417fe9e3a071cf1424a5152d926a34c4a3c5070745470be6cf12a404ed79 $LIBBACKTRACE.
|
||||
60c4da1d5b7f0aa8d158da48e8f8afa9773c1c8baa5d21974df61f1886b8ce8e libpng-$LIBPNG.tar.xz
|
||||
61f873ec69e3be1b99535634340d5bde750b2e4447caa1db9f61be3fd49ab1e5 libwebp-$LIBWEBP.tar.gz
|
||||
0728800155f3ed0a0c87e03addbd30ecbe374f7b080678bbca1506051d50dec3 $LZ4.tar.gz
|
||||
24b574f71c87a763f50704bbb630cbe38298d544a1f890f099a4696b1d6beba4 $SDL.tar.gz
|
||||
f59adf36a0fcf4c94198e7d3d776c1b3824211ab7aeebeb31fe19836661196aa $SDL.tar.gz
|
||||
8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1 zstd-$ZSTD.tar.gz
|
||||
40b14562ef3bd779bc0e0418ea2ae08fa28235f8ea6e8c0cb3bce1d6ad58dcaf qtbase-everywhere-src-$QT.tar.xz
|
||||
138cc2909aa98f5ff7283e36eb3936eb5e625d3ca3b4febae2ca21d8903dd237 qtimageformats-everywhere-src-$QT.tar.xz
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://libsdl.org/release/SDL2-2.30.9.tar.gz",
|
||||
"sha256": "24b574f71c87a763f50704bbb630cbe38298d544a1f890f099a4696b1d6beba4"
|
||||
"url": "https://libsdl.org/release/SDL2-2.30.10.tar.gz",
|
||||
"sha256": "f59adf36a0fcf4c94198e7d3d776c1b3824211ab7aeebeb31fe19836661196aa"
|
||||
}
|
||||
],
|
||||
"cleanup": [
|
||||
|
||||
@@ -40,7 +40,7 @@ fi
|
||||
|
||||
FREETYPE=2.13.3
|
||||
HARFBUZZ=10.0.1
|
||||
SDL=SDL2-2.30.9
|
||||
SDL=SDL2-2.30.10
|
||||
ZSTD=1.5.6
|
||||
LZ4=b8fd2d15309dd4e605070bd4486e26b6ef814e29
|
||||
LIBPNG=1.6.44
|
||||
@@ -76,7 +76,7 @@ CMAKE_ARCH_UNIVERSAL=-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
|
||||
cat > SHASUMS <<EOF
|
||||
0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289 freetype-$FREETYPE.tar.xz
|
||||
e7358ea86fe10fb9261931af6f010d4358dac64f7074420ca9bc94aae2bdd542 harfbuzz-$HARFBUZZ.tar.gz
|
||||
24b574f71c87a763f50704bbb630cbe38298d544a1f890f099a4696b1d6beba4 $SDL.tar.gz
|
||||
f59adf36a0fcf4c94198e7d3d776c1b3824211ab7aeebeb31fe19836661196aa $SDL.tar.gz
|
||||
8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1 zstd-$ZSTD.tar.gz
|
||||
0728800155f3ed0a0c87e03addbd30ecbe374f7b080678bbca1506051d50dec3 $LZ4.tar.gz
|
||||
60c4da1d5b7f0aa8d158da48e8f8afa9773c1c8baa5d21974df61f1886b8ce8e libpng-$LIBPNG.tar.xz
|
||||
|
||||
@@ -22,7 +22,7 @@ fi
|
||||
|
||||
FREETYPE=2.13.3
|
||||
HARFBUZZ=10.0.1
|
||||
SDL=SDL2-2.30.9
|
||||
SDL=SDL2-2.30.10
|
||||
ZSTD=1.5.6
|
||||
LZ4=b8fd2d15309dd4e605070bd4486e26b6ef814e29
|
||||
LIBPNG=1.6.44
|
||||
@@ -56,7 +56,7 @@ CMAKE_COMMON=(
|
||||
cat > SHASUMS <<EOF
|
||||
0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289 freetype-$FREETYPE.tar.xz
|
||||
e7358ea86fe10fb9261931af6f010d4358dac64f7074420ca9bc94aae2bdd542 harfbuzz-$HARFBUZZ.tar.gz
|
||||
24b574f71c87a763f50704bbb630cbe38298d544a1f890f099a4696b1d6beba4 $SDL.tar.gz
|
||||
f59adf36a0fcf4c94198e7d3d776c1b3824211ab7aeebeb31fe19836661196aa $SDL.tar.gz
|
||||
8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1 zstd-$ZSTD.tar.gz
|
||||
0728800155f3ed0a0c87e03addbd30ecbe374f7b080678bbca1506051d50dec3 $LZ4.tar.gz
|
||||
60c4da1d5b7f0aa8d158da48e8f8afa9773c1c8baa5d21974df61f1886b8ce8e libpng-$LIBPNG.tar.xz
|
||||
|
||||
@@ -49,7 +49,7 @@ set LIBPNG=1643
|
||||
set LZ4=b8fd2d15309dd4e605070bd4486e26b6ef814e29
|
||||
set QT=6.8.1
|
||||
set QTMINOR=6.8
|
||||
set SDL=SDL2-2.30.9
|
||||
set SDL=SDL2-2.30.10
|
||||
set WEBP=1.4.0
|
||||
set ZLIB=1.3.1
|
||||
set ZLIBSHORT=131
|
||||
@@ -66,7 +66,7 @@ call :downloadfile "lpng%LIBPNG%.zip" https://download.sourceforge.net/libpng/lp
|
||||
call :downloadfile "jpegsr%LIBJPEG%.zip" https://ijg.org/files/jpegsr%LIBJPEG%.zip 6255da8c89e09d694e6800688c76145eb6870a76ac0d36c74fccd61b3940aafa || goto error
|
||||
call :downloadfile "libwebp-%WEBP%.tar.gz" "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-%WEBP%.tar.gz" 61f873ec69e3be1b99535634340d5bde750b2e4447caa1db9f61be3fd49ab1e5 || goto error
|
||||
call :downloadfile "lz4-%LZ4%.zip" "https://github.com/lz4/lz4/archive/%LZ4%.zip" 0c33119688d6b180c7e760b0acd70059222389cfd581632623784bee27e51a31 || goto error
|
||||
call :downloadfile "%SDL%.zip" "https://libsdl.org/release/%SDL%.zip" ec855bcd815b4b63d0c958c42c2923311c656227d6e0c1ae1e721406d346444b || goto error
|
||||
call :downloadfile "%SDL%.zip" "https://libsdl.org/release/%SDL%.zip" 14b06b30d3400953875e73b0c4771cad1483488a1ef816803610f22b32300ce8 || goto error
|
||||
call :downloadfile "qtbase-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtbase-everywhere-src-%QT%.zip" e22d997bd15b795a176c8da62c8c1da0a674eb534e02f7c01ca507bf11bce0c3 || goto error
|
||||
call :downloadfile "qtimageformats-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtimageformats-everywhere-src-%QT%.zip" 247a0a58039275a5a4fb499a600a90f66dc6e00321bb6f86a9b8d8020344d853 || goto error
|
||||
call :downloadfile "qtsvg-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtsvg-everywhere-src-%QT%.zip" 57bd332e5550ff70a852560c591b786b6ba587c5e41cb5ef91038d82db137ab9 || goto error
|
||||
|
||||
@@ -47,7 +47,7 @@ set LIBPNG=1643
|
||||
set LZ4=b8fd2d15309dd4e605070bd4486e26b6ef814e29
|
||||
set QT=6.8.1
|
||||
set QTMINOR=6.8
|
||||
set SDL=SDL2-2.30.9
|
||||
set SDL=SDL2-2.30.10
|
||||
set WEBP=1.4.0
|
||||
set ZLIB=1.3.1
|
||||
set ZLIBSHORT=131
|
||||
@@ -64,7 +64,7 @@ call :downloadfile "lpng%LIBPNG%.zip" https://download.sourceforge.net/libpng/lp
|
||||
call :downloadfile "jpegsr%LIBJPEG%.zip" https://ijg.org/files/jpegsr%LIBJPEG%.zip 6255da8c89e09d694e6800688c76145eb6870a76ac0d36c74fccd61b3940aafa || goto error
|
||||
call :downloadfile "libwebp-%WEBP%.tar.gz" "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-%WEBP%.tar.gz" 61f873ec69e3be1b99535634340d5bde750b2e4447caa1db9f61be3fd49ab1e5 || goto error
|
||||
call :downloadfile "lz4-%LZ4%.zip" "https://github.com/lz4/lz4/archive/%LZ4%.zip" 0c33119688d6b180c7e760b0acd70059222389cfd581632623784bee27e51a31 || goto error
|
||||
call :downloadfile "%SDL%.zip" "https://libsdl.org/release/%SDL%.zip" ec855bcd815b4b63d0c958c42c2923311c656227d6e0c1ae1e721406d346444b || goto error
|
||||
call :downloadfile "%SDL%.zip" "https://libsdl.org/release/%SDL%.zip" 14b06b30d3400953875e73b0c4771cad1483488a1ef816803610f22b32300ce8 || goto error
|
||||
call :downloadfile "qtbase-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtbase-everywhere-src-%QT%.zip" e22d997bd15b795a176c8da62c8c1da0a674eb534e02f7c01ca507bf11bce0c3 || goto error
|
||||
call :downloadfile "qtimageformats-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtimageformats-everywhere-src-%QT%.zip" 247a0a58039275a5a4fb499a600a90f66dc6e00321bb6f86a9b8d8020344d853 || goto error
|
||||
call :downloadfile "qtsvg-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtsvg-everywhere-src-%QT%.zip" 57bd332e5550ff70a852560c591b786b6ba587c5e41cb5ef91038d82db137ab9 || goto error
|
||||
|
||||
2
3rdparty/d3d12memalloc/LICENSE.txt
vendored
2
3rdparty/d3d12memalloc/LICENSE.txt
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Copyright (c) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
22
3rdparty/d3d12memalloc/README.md
vendored
22
3rdparty/d3d12memalloc/README.md
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
Easy to integrate memory allocation library for Direct3D 12.
|
||||
|
||||
**Documentation:** Browse online: [D3D12 Memory Allocator](https://gpuopen-librariesandsdks.github.io/D3D12MemoryAllocator/html/) (generated from Doxygen-style comments in [src/D3D12MemAlloc.h](src/D3D12MemAlloc.h))
|
||||
**Documentation:** Browse online: [D3D12 Memory Allocator](https://gpuopen-librariesandsdks.github.io/D3D12MemoryAllocator/html/) (generated from Doxygen-style comments in [include/D3D12MemAlloc.h](include/D3D12MemAlloc.h))
|
||||
|
||||
**License:** MIT. See [LICENSE.txt](LICENSE.txt)
|
||||
|
||||
@@ -36,6 +36,7 @@ Additional features:
|
||||
- Customization and integration with custom engines: Predefine appropriate macros to provide your own implementation of external facilities used by the library, like assert, mutex, and atomic.
|
||||
- Support for resource aliasing (overlap).
|
||||
- Custom memory pools: Create a pool with desired parameters (e.g. fixed or limited maximum size, custom `D3D12_HEAP_PROPERTIES` and `D3D12_HEAP_FLAGS`) and allocate memory out of it.
|
||||
- Support for GPU Upload Heaps from preview Agility SDK (needs compilation with `D3D12MA_OPTIONS16_SUPPORTED` macro).
|
||||
- Linear allocator: Create a pool with linear algorithm and use it for much faster allocations and deallocations in free-at-once, stack, double stack, or ring buffer fashion.
|
||||
- Defragmentation: Let the library move data around to free some memory blocks and make your allocations better compacted.
|
||||
- Statistics: Obtain brief or detailed statistics about the amount of memory used, unused, number of allocated heaps, number of allocations etc. - globally and per memory heap type. Current memory usage and budget as reported by the system can also be queried.
|
||||
@@ -101,15 +102,18 @@ This software package uses third party software:
|
||||
|
||||
For more information see [NOTICES.txt](NOTICES.txt).
|
||||
|
||||
# Software using this library
|
||||
|
||||
- **[The Forge](https://github.com/ConfettiFX/The-Forge)** - cross-platform rendering framework. Apache License 2.0.
|
||||
- **[Wicked Engine<img src="https://github.com/turanszkij/WickedEngine/blob/master/Content/logo_small.png" width="28px" align="center"/>](https://github.com/turanszkij/WickedEngine)** - 3D engine with modern graphics
|
||||
|
||||
[Some other projects on GitHub](https://github.com/search?q=D3D12MemAlloc.h&type=Code) and some game development studios that use DX12 in their games.
|
||||
|
||||
# See also
|
||||
|
||||
- **[Vcpkg](https://github.com/Microsoft/vcpkg)** dependency manager from Microsoft offers a port of this library that is easy to install.
|
||||
- **[Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/)** - equivalent library for Vulkan. License: MIT.
|
||||
- **[d3d12ma.c](https://github.com/milliewalky/d3d12ma.c)** - C bindings for this library. Author: Mateusz Maciejewski (Matt Walky). License: MIT.
|
||||
- **[TerraFX.Interop.D3D12MemoryAllocator](https://github.com/terrafx/terrafx.interop.d3d12memoryallocator)** - interop bindings for this library for C#, as used by [TerraFX](https://github.com/terrafx/terrafx). License: MIT.
|
||||
- **[Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/)** - equivalent library for Vulkan. License: MIT.
|
||||
|
||||
# Software using this library
|
||||
|
||||
- **[Qt Project](https://github.com/qt)**
|
||||
- **[Ghost of Tsushima: Director's Cut PC](https://www.youtube.com/watch?v=cPKBDbCYctc&t=698s)** - Information avaliable in 11:38 of credits
|
||||
- **[The Forge](https://github.com/ConfettiFX/The-Forge)** - cross-platform rendering framework. Apache License 2.0.
|
||||
- **[Wicked Engine<img src="https://github.com/turanszkij/WickedEngine/blob/master/Content/logo_small.png" width="28px" align="center"/>](https://github.com/turanszkij/WickedEngine)** - 3D engine with modern graphics
|
||||
|
||||
[Some other projects on GitHub](https://github.com/search?q=D3D12MemAlloc.h&type=Code) and some game development studios that use DX12 in their games.
|
||||
|
||||
81
3rdparty/d3d12memalloc/include/D3D12MemAlloc.h
vendored
81
3rdparty/d3d12memalloc/include/D3D12MemAlloc.h
vendored
@@ -24,9 +24,9 @@
|
||||
|
||||
/** \mainpage D3D12 Memory Allocator
|
||||
|
||||
<b>Version 2.1.0-development</b> (2023-07-05)
|
||||
<b>Version 2.1.0-development</b> (2024-07-05)
|
||||
|
||||
Copyright (c) 2019-2023 Advanced Micro Devices, Inc. All rights reserved. \n
|
||||
Copyright (c) 2019-2024 Advanced Micro Devices, Inc. All rights reserved. \n
|
||||
License: MIT
|
||||
|
||||
Documentation of all members: D3D12MemAlloc.h
|
||||
@@ -160,9 +160,9 @@ class D3D12MA_API IUnknownImpl : public IUnknown
|
||||
{
|
||||
public:
|
||||
virtual ~IUnknownImpl() = default;
|
||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef();
|
||||
virtual ULONG STDMETHODCALLTYPE Release();
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override;
|
||||
ULONG STDMETHODCALLTYPE AddRef() override;
|
||||
ULONG STDMETHODCALLTYPE Release() override;
|
||||
protected:
|
||||
virtual void ReleaseThis() { delete this; }
|
||||
private:
|
||||
@@ -265,18 +265,18 @@ enum ALLOCATION_FLAGS
|
||||
*/
|
||||
ALLOCATION_FLAG_CAN_ALIAS = 0x10,
|
||||
|
||||
/** Allocation strategy that chooses smallest possible free range for the allocation
|
||||
/** %Allocation strategy that chooses smallest possible free range for the allocation
|
||||
to minimize memory usage and fragmentation, possibly at the expense of allocation time.
|
||||
*/
|
||||
ALLOCATION_FLAG_STRATEGY_MIN_MEMORY = 0x00010000,
|
||||
|
||||
/** Allocation strategy that chooses first suitable free range for the allocation -
|
||||
/** %Allocation strategy that chooses first suitable free range for the allocation -
|
||||
not necessarily in terms of the smallest offset but the one that is easiest and fastest to find
|
||||
to minimize allocation time, possibly at the expense of allocation quality.
|
||||
*/
|
||||
ALLOCATION_FLAG_STRATEGY_MIN_TIME = 0x00020000,
|
||||
|
||||
/** Allocation strategy that chooses always the lowest offset in available space.
|
||||
/** %Allocation strategy that chooses always the lowest offset in available space.
|
||||
This is not the most efficient strategy but achieves highly packed data.
|
||||
Used internally by defragmentation, not recomended in typical usage.
|
||||
*/
|
||||
@@ -402,8 +402,9 @@ struct TotalStatistics
|
||||
- 1 = `D3D12_HEAP_TYPE_UPLOAD`
|
||||
- 2 = `D3D12_HEAP_TYPE_READBACK`
|
||||
- 3 = `D3D12_HEAP_TYPE_CUSTOM`
|
||||
- 4 = `D3D12_HEAP_TYPE_GPU_UPLOAD`
|
||||
*/
|
||||
DetailedStatistics HeapType[4];
|
||||
DetailedStatistics HeapType[5];
|
||||
/** \brief One element for each memory segment group located at the following indices:
|
||||
|
||||
- 0 = `DXGI_MEMORY_SEGMENT_GROUP_LOCAL`
|
||||
@@ -413,9 +414,9 @@ struct TotalStatistics
|
||||
|
||||
- When `IsUMA() == FALSE` (discrete graphics card):
|
||||
- `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` (index 0) represents GPU memory
|
||||
(resources allocated in `D3D12_HEAP_TYPE_DEFAULT` or `D3D12_MEMORY_POOL_L1`).
|
||||
(resources allocated in `D3D12_HEAP_TYPE_DEFAULT`, `D3D12_HEAP_TYPE_GPU_UPLOAD` or `D3D12_MEMORY_POOL_L1`).
|
||||
- `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL` (index 1) represents system memory
|
||||
(resources allocated in `D3D12_HEAP_TYPE_UPLOAD`, `D3D12_HEAP_TYPE_READBACK`, or `D3D12_MEMORY_POOL_L0`).
|
||||
(resources allocated in `D3D12_HEAP_TYPE_UPLOAD`, `D3D12_HEAP_TYPE_READBACK`, or `D3D12_MEMORY_POOL_L0`).
|
||||
- When `IsUMA() == TRUE` (integrated graphics chip):
|
||||
- `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` = (index 0) represents memory shared for all the resources.
|
||||
- `DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL` = (index 1) is unused and always 0.
|
||||
@@ -542,26 +543,6 @@ public:
|
||||
*/
|
||||
LPCWSTR GetName() const { return m_Name; }
|
||||
|
||||
/** \brief Returns `TRUE` if the memory of the allocation was filled with zeros when the allocation was created.
|
||||
|
||||
Returns `TRUE` only if the allocator is sure that the entire memory where the
|
||||
allocation was created was filled with zeros at the moment the allocation was made.
|
||||
|
||||
Returns `FALSE` if the memory could potentially contain garbage data.
|
||||
If it's a render-target or depth-stencil texture, it then needs proper
|
||||
initialization with `ClearRenderTargetView`, `ClearDepthStencilView`, `DiscardResource`,
|
||||
or a copy operation, as described on page
|
||||
"ID3D12Device::CreatePlacedResource method - Notes on the required resource initialization" in Microsoft documentation.
|
||||
Please note that rendering a fullscreen triangle or quad to the texture as
|
||||
a render target is not a proper way of initialization!
|
||||
|
||||
See also articles:
|
||||
|
||||
- "Coming to DirectX 12: More control over memory allocation" on DirectX Developer Blog
|
||||
- ["Initializing DX12 Textures After Allocation and Aliasing"](https://asawicki.info/news_1724_initializing_dx12_textures_after_allocation_and_aliasing).
|
||||
*/
|
||||
BOOL WasZeroInitialized() const { return m_PackedData.WasZeroInitialized(); }
|
||||
|
||||
protected:
|
||||
void ReleaseThis() override;
|
||||
|
||||
@@ -620,29 +601,26 @@ private:
|
||||
{
|
||||
public:
|
||||
PackedData() :
|
||||
m_Type(0), m_ResourceDimension(0), m_ResourceFlags(0), m_TextureLayout(0), m_WasZeroInitialized(0) { }
|
||||
m_Type(0), m_ResourceDimension(0), m_ResourceFlags(0), m_TextureLayout(0) { }
|
||||
|
||||
Type GetType() const { return (Type)m_Type; }
|
||||
D3D12_RESOURCE_DIMENSION GetResourceDimension() const { return (D3D12_RESOURCE_DIMENSION)m_ResourceDimension; }
|
||||
D3D12_RESOURCE_FLAGS GetResourceFlags() const { return (D3D12_RESOURCE_FLAGS)m_ResourceFlags; }
|
||||
D3D12_TEXTURE_LAYOUT GetTextureLayout() const { return (D3D12_TEXTURE_LAYOUT)m_TextureLayout; }
|
||||
BOOL WasZeroInitialized() const { return (BOOL)m_WasZeroInitialized; }
|
||||
|
||||
void SetType(Type type);
|
||||
void SetResourceDimension(D3D12_RESOURCE_DIMENSION resourceDimension);
|
||||
void SetResourceFlags(D3D12_RESOURCE_FLAGS resourceFlags);
|
||||
void SetTextureLayout(D3D12_TEXTURE_LAYOUT textureLayout);
|
||||
void SetWasZeroInitialized(BOOL wasZeroInitialized) { m_WasZeroInitialized = wasZeroInitialized ? 1 : 0; }
|
||||
|
||||
private:
|
||||
UINT m_Type : 2; // enum Type
|
||||
UINT m_ResourceDimension : 3; // enum D3D12_RESOURCE_DIMENSION
|
||||
UINT m_ResourceFlags : 24; // flags D3D12_RESOURCE_FLAGS
|
||||
UINT m_TextureLayout : 9; // enum D3D12_TEXTURE_LAYOUT
|
||||
UINT m_WasZeroInitialized : 1; // BOOL
|
||||
} m_PackedData;
|
||||
|
||||
Allocation(AllocatorPimpl* allocator, UINT64 size, UINT64 alignment, BOOL wasZeroInitialized);
|
||||
Allocation(AllocatorPimpl* allocator, UINT64 size, UINT64 alignment);
|
||||
// Nothing here, everything already done in Release.
|
||||
virtual ~Allocation() = default;
|
||||
|
||||
@@ -1065,6 +1043,16 @@ enum ALLOCATOR_FLAGS
|
||||
to create its heaps on smaller alignment not suitable for MSAA textures.
|
||||
*/
|
||||
ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED = 0x8,
|
||||
/** \brief Disable optimization that prefers creating small buffers as committed to avoid 64 KB alignment.
|
||||
|
||||
By default, the library prefers creating small buffers <= 32 KB as committed,
|
||||
because drivers tend to pack them better, while placed buffers require 64 KB alignment.
|
||||
This, however, may decrease performance, as creating committed resources involves allocation of implicit heaps,
|
||||
which may take longer than creating placed resources in existing heaps.
|
||||
Passing this flag will disable this committed preference globally for the allocator.
|
||||
It can also be disabled for a single allocation by using #ALLOCATION_FLAG_STRATEGY_MIN_TIME.
|
||||
*/
|
||||
ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED = 0x10,
|
||||
};
|
||||
|
||||
/// \brief Parameters of created Allocator object. To be used with CreateAllocator().
|
||||
@@ -1130,6 +1118,15 @@ public:
|
||||
- "ID3D12Device::GetCustomHeapProperties method (d3d12.h)"
|
||||
*/
|
||||
BOOL IsCacheCoherentUMA() const;
|
||||
/** \brief Returns true if GPU Upload Heaps are supported on the current system.
|
||||
|
||||
When true, you can use `D3D12_HEAP_TYPE_GPU_UPLOAD`.
|
||||
|
||||
This flag is fetched from `D3D12_FEATURE_D3D12_OPTIONS16::GPUUploadHeapSupported`.
|
||||
|
||||
`#define D3D12MA_OPTIONS16_SUPPORTED 1` is needed for the compilation of this library. Otherwise the flag is always false.
|
||||
*/
|
||||
BOOL IsGPUUploadHeapSupported() const;
|
||||
/** \brief Returns total amount of memory of specific segment group, in bytes.
|
||||
|
||||
\param memorySegmentGroup use `DXGI_MEMORY_SEGMENT_GROUP_LOCAL` or DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL`.
|
||||
@@ -1447,11 +1444,11 @@ enum VIRTUAL_ALLOCATION_FLAGS
|
||||
*/
|
||||
VIRTUAL_ALLOCATION_FLAG_UPPER_ADDRESS = ALLOCATION_FLAG_UPPER_ADDRESS,
|
||||
|
||||
/// Allocation strategy that tries to minimize memory usage.
|
||||
/// %Allocation strategy that tries to minimize memory usage.
|
||||
VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_MEMORY = ALLOCATION_FLAG_STRATEGY_MIN_MEMORY,
|
||||
/// Allocation strategy that tries to minimize allocation time.
|
||||
/// %Allocation strategy that tries to minimize allocation time.
|
||||
VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_TIME = ALLOCATION_FLAG_STRATEGY_MIN_TIME,
|
||||
/** \brief Allocation strategy that chooses always the lowest offset in available space.
|
||||
/** %Allocation strategy that chooses always the lowest offset in available space.
|
||||
This is not the most efficient strategy but achieves highly packed data.
|
||||
*/
|
||||
VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_OFFSET = ALLOCATION_FLAG_STRATEGY_MIN_OFFSET,
|
||||
@@ -1640,6 +1637,9 @@ ID3D12Device* device = (...)
|
||||
D3D12MA::ALLOCATOR_DESC allocatorDesc = {};
|
||||
allocatorDesc.pDevice = device;
|
||||
allocatorDesc.pAdapter = adapter;
|
||||
// These flags are optional but recommended.
|
||||
allocatorDesc.Flags = D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED |
|
||||
D3D12MA::ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED;
|
||||
|
||||
D3D12MA::Allocator* allocator;
|
||||
HRESULT hr = D3D12MA::CreateAllocator(&allocatorDesc, &allocator);
|
||||
@@ -1864,6 +1864,9 @@ to obtain object D3D12MA::Pool. Example:
|
||||
\code
|
||||
POOL_DESC poolDesc = {};
|
||||
poolDesc.HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
// These flags are optional but recommended.
|
||||
poolDesc.Flags = D3D12MA::POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED;
|
||||
poolDesc.HeapFlags = D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
|
||||
|
||||
Pool* pool;
|
||||
HRESULT hr = allocator->CreatePool(&poolDesc, &pool);
|
||||
|
||||
863
3rdparty/d3d12memalloc/src/D3D12MemAlloc.cpp
vendored
863
3rdparty/d3d12memalloc/src/D3D12MemAlloc.cpp
vendored
File diff suppressed because it is too large
Load Diff
22
3rdparty/googletest/README.md
vendored
22
3rdparty/googletest/README.md
vendored
@@ -9,7 +9,7 @@ GoogleTest now follows the
|
||||
We recommend
|
||||
[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it).
|
||||
We do publish occasional semantic versions, tagged with
|
||||
`v${major}.${minor}.${patch}` (e.g. `v1.13.0`).
|
||||
`v${major}.${minor}.${patch}` (e.g. `v1.15.0`).
|
||||
|
||||
#### Documentation Updates
|
||||
|
||||
@@ -17,25 +17,21 @@ Our documentation is now live on GitHub Pages at
|
||||
https://google.github.io/googletest/. We recommend browsing the documentation on
|
||||
GitHub Pages rather than directly in the repository.
|
||||
|
||||
#### Release 1.13.0
|
||||
#### Release 1.15.0
|
||||
|
||||
[Release 1.13.0](https://github.com/google/googletest/releases/tag/v1.13.0) is
|
||||
[Release 1.15.0](https://github.com/google/googletest/releases/tag/v1.15.0) is
|
||||
now available.
|
||||
|
||||
The 1.13.x branch requires at least C++14.
|
||||
The 1.15.x branch requires at least C++14.
|
||||
|
||||
#### Continuous Integration
|
||||
|
||||
We use Google's internal systems for continuous integration. \
|
||||
GitHub Actions were added for the convenience of open-source contributors. They
|
||||
are exclusively maintained by the open-source community and not used by the
|
||||
GoogleTest team.
|
||||
We use Google's internal systems for continuous integration.
|
||||
|
||||
#### Coming Soon
|
||||
|
||||
* We are planning to take a dependency on
|
||||
[Abseil](https://github.com/abseil/abseil-cpp).
|
||||
* More documentation improvements are planned.
|
||||
|
||||
## Welcome to **GoogleTest**, Google's C++ test framework!
|
||||
|
||||
@@ -100,12 +96,12 @@ tools.
|
||||
In addition to many internal projects at Google, GoogleTest is also used by the
|
||||
following notable projects:
|
||||
|
||||
* The [Chromium projects](http://www.chromium.org/) (behind the Chrome browser
|
||||
and Chrome OS).
|
||||
* The [LLVM](http://llvm.org/) compiler.
|
||||
* The [Chromium projects](https://www.chromium.org/) (behind the Chrome
|
||||
browser and Chrome OS).
|
||||
* The [LLVM](https://llvm.org/) compiler.
|
||||
* [Protocol Buffers](https://github.com/google/protobuf), Google's data
|
||||
interchange format.
|
||||
* The [OpenCV](http://opencv.org/) computer vision library.
|
||||
* The [OpenCV](https://opencv.org/) computer vision library.
|
||||
|
||||
## Related Open Source Projects
|
||||
|
||||
|
||||
6
3rdparty/googletest/googlemock/README.md
vendored
6
3rdparty/googletest/googlemock/README.md
vendored
@@ -8,8 +8,8 @@ derive better designs of your system and write better tests.
|
||||
It is inspired by:
|
||||
|
||||
* [jMock](http://www.jmock.org/)
|
||||
* [EasyMock](http://www.easymock.org/)
|
||||
* [Hamcrest](http://code.google.com/p/hamcrest/)
|
||||
* [EasyMock](https://easymock.org/)
|
||||
* [Hamcrest](https://code.google.com/p/hamcrest/)
|
||||
|
||||
It is designed with C++'s specifics in mind.
|
||||
|
||||
@@ -36,5 +36,5 @@ Details and examples can be found here:
|
||||
* [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html)
|
||||
|
||||
GoogleMock is a part of
|
||||
[GoogleTest C++ testing framework](http://github.com/google/googletest/) and a
|
||||
[GoogleTest C++ testing framework](https://github.com/google/googletest/) and a
|
||||
subject to the same requirements.
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -175,9 +176,15 @@ struct BuiltInDefaultValueGetter<T, false> {
|
||||
static T Get() {
|
||||
Assert(false, __FILE__, __LINE__,
|
||||
"Default action undefined for the function return type.");
|
||||
return internal::Invalid<T>();
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
__builtin_unreachable();
|
||||
#elif defined(_MSC_VER)
|
||||
__assume(0);
|
||||
#else
|
||||
return Invalid<T>();
|
||||
// The above statement will never be reached, but is required in
|
||||
// order for this function to compile.
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1740,6 +1747,13 @@ struct ThrowAction {
|
||||
return [copy](Args...) -> R { throw copy; };
|
||||
}
|
||||
};
|
||||
struct RethrowAction {
|
||||
std::exception_ptr exception;
|
||||
template <typename R, typename... Args>
|
||||
operator Action<R(Args...)>() const { // NOLINT
|
||||
return [ex = exception](Args...) -> R { std::rethrow_exception(ex); };
|
||||
}
|
||||
};
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
} // namespace internal
|
||||
@@ -2056,13 +2070,23 @@ internal::ReturnPointeeAction<Ptr> ReturnPointee(Ptr pointer) {
|
||||
return {pointer};
|
||||
}
|
||||
|
||||
// Action Throw(exception) can be used in a mock function of any type
|
||||
// to throw the given exception. Any copyable value can be thrown.
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
// Action Throw(exception) can be used in a mock function of any type
|
||||
// to throw the given exception. Any copyable value can be thrown,
|
||||
// except for std::exception_ptr, which is likely a mistake if
|
||||
// thrown directly.
|
||||
template <typename T>
|
||||
internal::ThrowAction<typename std::decay<T>::type> Throw(T&& exception) {
|
||||
typename std::enable_if<
|
||||
!std::is_base_of<std::exception_ptr, typename std::decay<T>::type>::value,
|
||||
internal::ThrowAction<typename std::decay<T>::type>>::type
|
||||
Throw(T&& exception) {
|
||||
return {std::forward<T>(exception)};
|
||||
}
|
||||
// Action Rethrow(exception_ptr) can be used in a mock function of any type
|
||||
// to rethrow any exception_ptr. Note that the same object is thrown each time.
|
||||
inline internal::RethrowAction Rethrow(std::exception_ptr exception) {
|
||||
return {std::move(exception)};
|
||||
}
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
namespace internal {
|
||||
@@ -2111,13 +2135,13 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
|
||||
R operator()(Args&&... arg) const {
|
||||
static constexpr size_t kMaxArgs =
|
||||
sizeof...(Args) <= 10 ? sizeof...(Args) : 10;
|
||||
return Apply(MakeIndexSequence<kMaxArgs>{},
|
||||
MakeIndexSequence<10 - kMaxArgs>{},
|
||||
return Apply(std::make_index_sequence<kMaxArgs>{},
|
||||
std::make_index_sequence<10 - kMaxArgs>{},
|
||||
args_type{std::forward<Args>(arg)...});
|
||||
}
|
||||
|
||||
template <std::size_t... arg_id, std::size_t... excess_id>
|
||||
R Apply(IndexSequence<arg_id...>, IndexSequence<excess_id...>,
|
||||
R Apply(std::index_sequence<arg_id...>, std::index_sequence<excess_id...>,
|
||||
const args_type& args) const {
|
||||
// Impl need not be specific to the signature of action being implemented;
|
||||
// only the implementing function body needs to have all of the specific
|
||||
@@ -2150,9 +2174,9 @@ template <typename F, typename Impl>
|
||||
}
|
||||
|
||||
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
|
||||
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
|
||||
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
|
||||
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
|
||||
, GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const arg##i##_type& arg##i
|
||||
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const args_type& args GMOCK_PP_REPEAT( \
|
||||
GMOCK_INTERNAL_ARG_UNUSED, , 10)
|
||||
|
||||
#define GMOCK_INTERNAL_ARG(i, data, el) , const arg##i##_type& arg##i
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_
|
||||
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits> // IWYU pragma: keep
|
||||
#include <utility> // IWYU pragma: keep
|
||||
|
||||
@@ -69,22 +70,22 @@ constexpr bool PrefixOf(const char* a, const char* b) {
|
||||
return *a == 0 || (*a == *b && internal::PrefixOf(a + 1, b + 1));
|
||||
}
|
||||
|
||||
template <int N, int M>
|
||||
template <size_t N, size_t M>
|
||||
constexpr bool StartsWith(const char (&prefix)[N], const char (&str)[M]) {
|
||||
return N <= M && internal::PrefixOf(prefix, str);
|
||||
}
|
||||
|
||||
template <int N, int M>
|
||||
template <size_t N, size_t M>
|
||||
constexpr bool EndsWith(const char (&suffix)[N], const char (&str)[M]) {
|
||||
return N <= M && internal::PrefixOf(suffix, str + M - N);
|
||||
}
|
||||
|
||||
template <int N, int M>
|
||||
template <size_t N, size_t M>
|
||||
constexpr bool Equals(const char (&a)[N], const char (&b)[M]) {
|
||||
return N == M && internal::PrefixOf(a, b);
|
||||
}
|
||||
|
||||
template <int N>
|
||||
template <size_t N>
|
||||
constexpr bool ValidateSpec(const char (&spec)[N]) {
|
||||
return internal::Equals("const", spec) ||
|
||||
internal::Equals("override", spec) ||
|
||||
|
||||
@@ -490,12 +490,12 @@ class MatcherBaseImpl<Derived<Ts...>> {
|
||||
|
||||
template <typename F>
|
||||
operator ::testing::Matcher<F>() const { // NOLINT(runtime/explicit)
|
||||
return Apply<F>(MakeIndexSequence<sizeof...(Ts)>{});
|
||||
return Apply<F>(std::make_index_sequence<sizeof...(Ts)>{});
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename F, std::size_t... tuple_ids>
|
||||
::testing::Matcher<F> Apply(IndexSequence<tuple_ids...>) const {
|
||||
::testing::Matcher<F> Apply(std::index_sequence<tuple_ids...>) const {
|
||||
return ::testing::Matcher<F>(
|
||||
new typename Derived<Ts...>::template gmock_Impl<F>(
|
||||
std::get<tuple_ids>(params_)...));
|
||||
@@ -1048,7 +1048,7 @@ class StartsWithMatcher {
|
||||
template <typename MatcheeStringType>
|
||||
bool MatchAndExplain(const MatcheeStringType& s,
|
||||
MatchResultListener* /* listener */) const {
|
||||
const StringType& s2(s);
|
||||
const StringType s2(s);
|
||||
return s2.length() >= prefix_.length() &&
|
||||
s2.substr(0, prefix_.length()) == prefix_;
|
||||
}
|
||||
@@ -1102,7 +1102,7 @@ class EndsWithMatcher {
|
||||
template <typename MatcheeStringType>
|
||||
bool MatchAndExplain(const MatcheeStringType& s,
|
||||
MatchResultListener* /* listener */) const {
|
||||
const StringType& s2(s);
|
||||
const StringType s2(s);
|
||||
return s2.length() >= suffix_.length() &&
|
||||
s2.substr(s2.length() - suffix_.length()) == suffix_;
|
||||
}
|
||||
@@ -2920,26 +2920,27 @@ class EachMatcher {
|
||||
const M inner_matcher_;
|
||||
};
|
||||
|
||||
struct Rank1 {};
|
||||
struct Rank0 : Rank1 {};
|
||||
// Use go/ranked-overloads for dispatching.
|
||||
struct Rank0 {};
|
||||
struct Rank1 : Rank0 {};
|
||||
|
||||
namespace pair_getters {
|
||||
using std::get;
|
||||
template <typename T>
|
||||
auto First(T& x, Rank1) -> decltype(get<0>(x)) { // NOLINT
|
||||
auto First(T& x, Rank0) -> decltype(get<0>(x)) { // NOLINT
|
||||
return get<0>(x);
|
||||
}
|
||||
template <typename T>
|
||||
auto First(T& x, Rank0) -> decltype((x.first)) { // NOLINT
|
||||
auto First(T& x, Rank1) -> decltype((x.first)) { // NOLINT
|
||||
return x.first;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto Second(T& x, Rank1) -> decltype(get<1>(x)) { // NOLINT
|
||||
auto Second(T& x, Rank0) -> decltype(get<1>(x)) { // NOLINT
|
||||
return get<1>(x);
|
||||
}
|
||||
template <typename T>
|
||||
auto Second(T& x, Rank0) -> decltype((x.second)) { // NOLINT
|
||||
auto Second(T& x, Rank1) -> decltype((x.second)) { // NOLINT
|
||||
return x.second;
|
||||
}
|
||||
} // namespace pair_getters
|
||||
@@ -2965,7 +2966,7 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
|
||||
MatchResultListener* listener) const override {
|
||||
StringMatchResultListener inner_listener;
|
||||
const bool match = inner_matcher_.MatchAndExplain(
|
||||
pair_getters::First(key_value, Rank0()), &inner_listener);
|
||||
pair_getters::First(key_value, Rank1()), &inner_listener);
|
||||
const std::string explanation = inner_listener.str();
|
||||
if (!explanation.empty()) {
|
||||
*listener << "whose first field is a value " << explanation;
|
||||
@@ -3087,18 +3088,18 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
|
||||
if (!listener->IsInterested()) {
|
||||
// If the listener is not interested, we don't need to construct the
|
||||
// explanation.
|
||||
return first_matcher_.Matches(pair_getters::First(a_pair, Rank0())) &&
|
||||
second_matcher_.Matches(pair_getters::Second(a_pair, Rank0()));
|
||||
return first_matcher_.Matches(pair_getters::First(a_pair, Rank1())) &&
|
||||
second_matcher_.Matches(pair_getters::Second(a_pair, Rank1()));
|
||||
}
|
||||
StringMatchResultListener first_inner_listener;
|
||||
if (!first_matcher_.MatchAndExplain(pair_getters::First(a_pair, Rank0()),
|
||||
if (!first_matcher_.MatchAndExplain(pair_getters::First(a_pair, Rank1()),
|
||||
&first_inner_listener)) {
|
||||
*listener << "whose first field does not match";
|
||||
PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
|
||||
return false;
|
||||
}
|
||||
StringMatchResultListener second_inner_listener;
|
||||
if (!second_matcher_.MatchAndExplain(pair_getters::Second(a_pair, Rank0()),
|
||||
if (!second_matcher_.MatchAndExplain(pair_getters::Second(a_pair, Rank1()),
|
||||
&second_inner_listener)) {
|
||||
*listener << "whose second field does not match";
|
||||
PrintIfNotEmpty(second_inner_listener.str(), listener->stream());
|
||||
@@ -3151,8 +3152,8 @@ class PairMatcher {
|
||||
};
|
||||
|
||||
template <typename T, size_t... I>
|
||||
auto UnpackStructImpl(const T& t, IndexSequence<I...>, int)
|
||||
-> decltype(std::tie(get<I>(t)...)) {
|
||||
auto UnpackStructImpl(const T& t, std::index_sequence<I...>,
|
||||
int) -> decltype(std::tie(get<I>(t)...)) {
|
||||
static_assert(std::tuple_size<T>::value == sizeof...(I),
|
||||
"Number of arguments doesn't match the number of fields.");
|
||||
return std::tie(get<I>(t)...);
|
||||
@@ -3160,97 +3161,97 @@ auto UnpackStructImpl(const T& t, IndexSequence<I...>, int)
|
||||
|
||||
#if defined(__cpp_structured_bindings) && __cpp_structured_bindings >= 201606
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<1>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<1>, char) {
|
||||
const auto& [a] = t;
|
||||
return std::tie(a);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<2>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<2>, char) {
|
||||
const auto& [a, b] = t;
|
||||
return std::tie(a, b);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<3>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<3>, char) {
|
||||
const auto& [a, b, c] = t;
|
||||
return std::tie(a, b, c);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<4>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<4>, char) {
|
||||
const auto& [a, b, c, d] = t;
|
||||
return std::tie(a, b, c, d);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<5>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<5>, char) {
|
||||
const auto& [a, b, c, d, e] = t;
|
||||
return std::tie(a, b, c, d, e);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<6>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<6>, char) {
|
||||
const auto& [a, b, c, d, e, f] = t;
|
||||
return std::tie(a, b, c, d, e, f);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<7>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<7>, char) {
|
||||
const auto& [a, b, c, d, e, f, g] = t;
|
||||
return std::tie(a, b, c, d, e, f, g);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<8>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<8>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<9>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<9>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<10>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<10>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<11>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<11>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<12>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<12>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<13>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<13>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<14>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<14>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<15>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<15>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<16>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<16>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<17>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<17>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<18>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<18>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
|
||||
}
|
||||
template <typename T>
|
||||
auto UnpackStructImpl(const T& t, MakeIndexSequence<19>, char) {
|
||||
auto UnpackStructImpl(const T& t, std::make_index_sequence<19>, char) {
|
||||
const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = t;
|
||||
return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s);
|
||||
}
|
||||
@@ -3258,8 +3259,8 @@ auto UnpackStructImpl(const T& t, MakeIndexSequence<19>, char) {
|
||||
|
||||
template <size_t I, typename T>
|
||||
auto UnpackStruct(const T& t)
|
||||
-> decltype((UnpackStructImpl)(t, MakeIndexSequence<I>{}, 0)) {
|
||||
return (UnpackStructImpl)(t, MakeIndexSequence<I>{}, 0);
|
||||
-> decltype((UnpackStructImpl)(t, std::make_index_sequence<I>{}, 0)) {
|
||||
return (UnpackStructImpl)(t, std::make_index_sequence<I>{}, 0);
|
||||
}
|
||||
|
||||
// Helper function to do comma folding in C++11.
|
||||
@@ -3272,7 +3273,7 @@ template <typename Struct, typename StructSize>
|
||||
class FieldsAreMatcherImpl;
|
||||
|
||||
template <typename Struct, size_t... I>
|
||||
class FieldsAreMatcherImpl<Struct, IndexSequence<I...>>
|
||||
class FieldsAreMatcherImpl<Struct, std::index_sequence<I...>>
|
||||
: public MatcherInterface<Struct> {
|
||||
using UnpackedType =
|
||||
decltype(UnpackStruct<sizeof...(I)>(std::declval<const Struct&>()));
|
||||
@@ -3354,8 +3355,8 @@ class FieldsAreMatcher {
|
||||
template <typename Struct>
|
||||
operator Matcher<Struct>() const { // NOLINT
|
||||
return Matcher<Struct>(
|
||||
new FieldsAreMatcherImpl<const Struct&, IndexSequenceFor<Inner...>>(
|
||||
matchers_));
|
||||
new FieldsAreMatcherImpl<const Struct&,
|
||||
std::index_sequence_for<Inner...>>(matchers_));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -5444,47 +5445,47 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
||||
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
|
||||
|
||||
// MATCHER* macros itself are listed below.
|
||||
#define MATCHER(name, description) \
|
||||
class name##Matcher \
|
||||
: public ::testing::internal::MatcherBaseImpl<name##Matcher> { \
|
||||
public: \
|
||||
template <typename arg_type> \
|
||||
class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
|
||||
public: \
|
||||
gmock_Impl() {} \
|
||||
bool MatchAndExplain( \
|
||||
const arg_type& arg, \
|
||||
::testing::MatchResultListener* result_listener) const override; \
|
||||
void DescribeTo(::std::ostream* gmock_os) const override { \
|
||||
*gmock_os << FormatDescription(false); \
|
||||
} \
|
||||
void DescribeNegationTo(::std::ostream* gmock_os) const override { \
|
||||
*gmock_os << FormatDescription(true); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
::std::string FormatDescription(bool negation) const { \
|
||||
/* NOLINTNEXTLINE readability-redundant-string-init */ \
|
||||
::std::string gmock_description = (description); \
|
||||
if (!gmock_description.empty()) { \
|
||||
return gmock_description; \
|
||||
} \
|
||||
return ::testing::internal::FormatMatcherDescription(negation, #name, \
|
||||
{}, {}); \
|
||||
} \
|
||||
}; \
|
||||
}; \
|
||||
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
|
||||
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
|
||||
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
|
||||
name GMOCK_INTERNAL_WARNING_POP()() { \
|
||||
return {}; \
|
||||
} \
|
||||
template <typename arg_type> \
|
||||
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain( \
|
||||
const arg_type& arg, \
|
||||
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) \
|
||||
const
|
||||
#define MATCHER(name, description) \
|
||||
class name##Matcher \
|
||||
: public ::testing::internal::MatcherBaseImpl<name##Matcher> { \
|
||||
public: \
|
||||
template <typename arg_type> \
|
||||
class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> { \
|
||||
public: \
|
||||
gmock_Impl() {} \
|
||||
bool MatchAndExplain( \
|
||||
const arg_type& arg, \
|
||||
::testing::MatchResultListener* result_listener) const override; \
|
||||
void DescribeTo(::std::ostream* gmock_os) const override { \
|
||||
*gmock_os << FormatDescription(false); \
|
||||
} \
|
||||
void DescribeNegationTo(::std::ostream* gmock_os) const override { \
|
||||
*gmock_os << FormatDescription(true); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
::std::string FormatDescription(bool negation) const { \
|
||||
/* NOLINTNEXTLINE readability-redundant-string-init */ \
|
||||
::std::string gmock_description = (description); \
|
||||
if (!gmock_description.empty()) { \
|
||||
return gmock_description; \
|
||||
} \
|
||||
return ::testing::internal::FormatMatcherDescription(negation, #name, \
|
||||
{}, {}); \
|
||||
} \
|
||||
}; \
|
||||
}; \
|
||||
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
|
||||
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
|
||||
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
|
||||
name GMOCK_INTERNAL_WARNING_POP()() { \
|
||||
return {}; \
|
||||
} \
|
||||
template <typename arg_type> \
|
||||
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain( \
|
||||
const arg_type& arg, \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing::MatchResultListener* \
|
||||
result_listener) const
|
||||
|
||||
#define MATCHER_P(name, p0, description) \
|
||||
GMOCK_INTERNAL_MATCHER(name, name##MatcherP, description, (#p0), (p0))
|
||||
@@ -5566,11 +5567,11 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
||||
} \
|
||||
template <GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args)> \
|
||||
template <typename arg_type> \
|
||||
bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>::gmock_Impl< \
|
||||
arg_type>::MatchAndExplain(const arg_type& arg, \
|
||||
::testing::MatchResultListener* \
|
||||
result_listener GTEST_ATTRIBUTE_UNUSED_) \
|
||||
const
|
||||
bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>:: \
|
||||
gmock_Impl<arg_type>::MatchAndExplain( \
|
||||
const arg_type& arg, \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing:: \
|
||||
MatchResultListener* result_listener) const
|
||||
|
||||
#define GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args) \
|
||||
GMOCK_PP_TAIL( \
|
||||
@@ -5605,8 +5606,8 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
||||
|
||||
#define GMOCK_INTERNAL_MATCHER_ARGS_USAGE(args) \
|
||||
GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_ARG_USAGE, , args))
|
||||
#define GMOCK_INTERNAL_MATCHER_ARG_USAGE(i, data_unused, arg_unused) \
|
||||
, gmock_p##i
|
||||
#define GMOCK_INTERNAL_MATCHER_ARG_USAGE(i, data_unused, arg) \
|
||||
, ::std::forward<arg##_type>(gmock_p##i)
|
||||
|
||||
// To prevent ADL on certain functions we put them on a separate namespace.
|
||||
using namespace no_adl; // NOLINT
|
||||
|
||||
@@ -592,8 +592,9 @@ namespace internal {
|
||||
// Overloads for other custom-callables are provided in the
|
||||
// internal/custom/gmock-generated-actions.h header.
|
||||
template <typename F, typename... Args>
|
||||
auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {
|
||||
return f(args...);
|
||||
auto InvokeArgument(F &&f,
|
||||
Args... args) -> decltype(std::forward<F>(f)(args...)) {
|
||||
return std::forward<F>(f)(args...);
|
||||
}
|
||||
|
||||
template <std::size_t index, typename... Params>
|
||||
@@ -606,7 +607,7 @@ struct InvokeArgumentAction {
|
||||
internal::FlatTuple<Args &&...> args_tuple(FlatTupleConstructTag{},
|
||||
std::forward<Args>(args)...);
|
||||
return params.Apply([&](const Params &...unpacked_params) {
|
||||
auto &&callable = args_tuple.template Get<index>();
|
||||
auto &&callable = std::move(args_tuple.template Get<index>());
|
||||
return internal::InvokeArgument(
|
||||
std::forward<decltype(callable)>(callable), unpacked_params...);
|
||||
});
|
||||
|
||||
@@ -53,13 +53,14 @@
|
||||
//
|
||||
// where all clauses are optional and WillOnce() can be repeated.
|
||||
|
||||
#include "gmock/gmock-actions.h"
|
||||
#include "gmock/gmock-cardinalities.h"
|
||||
#include "gmock/gmock-function-mocker.h"
|
||||
#include "gmock/gmock-matchers.h"
|
||||
#include "gmock/gmock-more-actions.h"
|
||||
#include "gmock/gmock-more-matchers.h"
|
||||
#include "gmock/gmock-nice-strict.h"
|
||||
#include "gmock/gmock-actions.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-cardinalities.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-function-mocker.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-matchers.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-more-actions.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-more-matchers.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-nice-strict.h" // IWYU pragma: export
|
||||
#include "gmock/gmock-spec-builders.h" // IWYU pragma: export
|
||||
#include "gmock/internal/gmock-internal-utils.h"
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <ostream> // NOLINT
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
@@ -420,7 +421,7 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
|
||||
GTEST_API_ void IllegalDoDefault(const char* file, int line);
|
||||
|
||||
template <typename F, typename Tuple, size_t... Idx>
|
||||
auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>)
|
||||
auto ApplyImpl(F&& f, Tuple&& args, std::index_sequence<Idx...>)
|
||||
-> decltype(std::forward<F>(f)(
|
||||
std::get<Idx>(std::forward<Tuple>(args))...)) {
|
||||
return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
|
||||
@@ -428,12 +429,13 @@ auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>)
|
||||
|
||||
// Apply the function to a tuple of arguments.
|
||||
template <typename F, typename Tuple>
|
||||
auto Apply(F&& f, Tuple&& args) -> decltype(ApplyImpl(
|
||||
std::forward<F>(f), std::forward<Tuple>(args),
|
||||
MakeIndexSequence<std::tuple_size<
|
||||
typename std::remove_reference<Tuple>::type>::value>())) {
|
||||
auto Apply(F&& f, Tuple&& args)
|
||||
-> decltype(ApplyImpl(
|
||||
std::forward<F>(f), std::forward<Tuple>(args),
|
||||
std::make_index_sequence<std::tuple_size<
|
||||
typename std::remove_reference<Tuple>::type>::value>())) {
|
||||
return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
|
||||
MakeIndexSequence<std::tuple_size<
|
||||
std::make_index_sequence<std::tuple_size<
|
||||
typename std::remove_reference<Tuple>::type>::value>());
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "gmock/internal/custom/gmock-port.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
#include "absl/flags/declare.h"
|
||||
#include "absl/flags/flag.h"
|
||||
#endif
|
||||
@@ -73,7 +73,7 @@
|
||||
#define GMOCK_FLAG(name) FLAGS_gmock_##name
|
||||
|
||||
// Pick a command line flags implementation.
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
|
||||
@@ -95,7 +95,7 @@
|
||||
#define GMOCK_FLAG_SET(name, value) \
|
||||
(void)(::absl::SetFlag(&GMOCK_FLAG(name), value))
|
||||
|
||||
#else // GTEST_HAS_ABSL
|
||||
#else // defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
|
||||
@@ -134,6 +134,6 @@
|
||||
#define GMOCK_FLAG_GET(name) ::testing::GMOCK_FLAG(name)
|
||||
#define GMOCK_FLAG_SET(name, value) (void)(::testing::GMOCK_FLAG(name) = value)
|
||||
|
||||
#endif // GTEST_HAS_ABSL
|
||||
#endif // defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
|
||||
#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <iostream>
|
||||
#include <ostream> // NOLINT
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@@ -211,14 +212,14 @@ constexpr char UnBase64Impl(char c, const char* const base64, char carry) {
|
||||
}
|
||||
|
||||
template <size_t... I>
|
||||
constexpr std::array<char, 256> UnBase64Impl(IndexSequence<I...>,
|
||||
constexpr std::array<char, 256> UnBase64Impl(std::index_sequence<I...>,
|
||||
const char* const base64) {
|
||||
return {
|
||||
{UnBase64Impl(UndoWebSafeEncoding(static_cast<char>(I)), base64, 0)...}};
|
||||
}
|
||||
|
||||
constexpr std::array<char, 256> UnBase64(const char* const base64) {
|
||||
return UnBase64Impl(MakeIndexSequence<256>{}, base64);
|
||||
return UnBase64Impl(std::make_index_sequence<256>{}, base64);
|
||||
}
|
||||
|
||||
static constexpr char kBase64[] =
|
||||
|
||||
@@ -120,7 +120,7 @@ GTEST_API_ std::string FormatMatcherDescription(
|
||||
// [1] Cormen, et al (2001). "Section 26.2: The Ford-Fulkerson method".
|
||||
// "Introduction to Algorithms (Second ed.)", pp. 651-664.
|
||||
// [2] "Ford-Fulkerson algorithm", Wikipedia,
|
||||
// 'http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'
|
||||
// 'https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'
|
||||
class MaxBipartiteMatchState {
|
||||
public:
|
||||
explicit MaxBipartiteMatchState(const MatchMatrix& graph)
|
||||
@@ -236,9 +236,8 @@ static void LogElementMatcherPairVec(const ElementMatcherPairs& pairs,
|
||||
os << "{";
|
||||
const char* sep = "";
|
||||
for (Iter it = pairs.begin(); it != pairs.end(); ++it) {
|
||||
os << sep << "\n ("
|
||||
<< "element #" << it->first << ", "
|
||||
<< "matcher #" << it->second << ")";
|
||||
os << sep << "\n (" << "element #" << it->first << ", " << "matcher #"
|
||||
<< it->second << ")";
|
||||
sep = ",";
|
||||
}
|
||||
os << "\n}";
|
||||
@@ -374,20 +373,20 @@ bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (match_flags() == UnorderedMatcherRequire::ExactMatch) {
|
||||
if (matrix.LhsSize() != matrix.RhsSize()) {
|
||||
// The element count doesn't match. If the container is empty,
|
||||
// there's no need to explain anything as Google Mock already
|
||||
// prints the empty container. Otherwise we just need to show
|
||||
// how many elements there actually are.
|
||||
if (matrix.LhsSize() != 0 && listener->IsInterested()) {
|
||||
*listener << "which has " << Elements(matrix.LhsSize());
|
||||
}
|
||||
return false;
|
||||
const bool is_exact_match_with_size_discrepency =
|
||||
match_flags() == UnorderedMatcherRequire::ExactMatch &&
|
||||
matrix.LhsSize() != matrix.RhsSize();
|
||||
if (is_exact_match_with_size_discrepency) {
|
||||
// The element count doesn't match. If the container is empty,
|
||||
// there's no need to explain anything as Google Mock already
|
||||
// prints the empty container. Otherwise we just need to show
|
||||
// how many elements there actually are.
|
||||
if (matrix.LhsSize() != 0 && listener->IsInterested()) {
|
||||
*listener << "which has " << Elements(matrix.LhsSize()) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
bool result = !is_exact_match_with_size_discrepency;
|
||||
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
||||
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
||||
|
||||
|
||||
@@ -490,6 +490,7 @@ class MockObjectRegistry {
|
||||
// failure, unless the user explicitly asked us to ignore it.
|
||||
~MockObjectRegistry() {
|
||||
if (!GMOCK_FLAG_GET(catch_leaked_mocks)) return;
|
||||
internal::MutexLock l(&internal::g_gmock_mutex);
|
||||
|
||||
int leaked_count = 0;
|
||||
for (StateMap::const_iterator it = states_.begin(); it != states_.end();
|
||||
@@ -530,7 +531,7 @@ class MockObjectRegistry {
|
||||
#ifdef GTEST_OS_QURT
|
||||
qurt_exception_raise_fatal();
|
||||
#else
|
||||
_exit(1); // We cannot call exit() as it is not reentrant and
|
||||
_Exit(1); // We cannot call exit() as it is not reentrant and
|
||||
// may already have been called.
|
||||
#endif
|
||||
}
|
||||
|
||||
4
3rdparty/googletest/googletest/README.md
vendored
4
3rdparty/googletest/googletest/README.md
vendored
@@ -12,7 +12,7 @@ GoogleTest comes with a CMake build script
|
||||
([CMakeLists.txt](https://github.com/google/googletest/blob/main/CMakeLists.txt))
|
||||
that can be used on a wide range of platforms ("C" stands for cross-platform.).
|
||||
If you don't have CMake installed already, you can download it for free from
|
||||
<http://www.cmake.org/>.
|
||||
<https://cmake.org/>.
|
||||
|
||||
CMake works by generating native makefiles or build projects that can be used in
|
||||
the compiler environment of your choice. You can either build GoogleTest as a
|
||||
@@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
|
||||
with
|
||||
|
||||
```
|
||||
git clone https://github.com/google/googletest.git -b v1.13.0
|
||||
git clone https://github.com/google/googletest.git -b v1.15.0
|
||||
cd googletest # Main directory of the cloned repository.
|
||||
mkdir build # Create a directory to hold the build output.
|
||||
cd build
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace testing {
|
||||
//
|
||||
// Expected: Foo() is even
|
||||
// Actual: it's 5
|
||||
//
|
||||
|
||||
class GTEST_API_ AssertionResult {
|
||||
public:
|
||||
// Copy constructor.
|
||||
|
||||
@@ -293,8 +293,8 @@ class GTEST_API_ KilledBySignal {
|
||||
// statement is compiled but not executed, to ensure that
|
||||
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
|
||||
// parameter if and only if EXPECT_DEATH compiles with it.
|
||||
// regex - A regex that a macro such as EXPECT_DEATH would use to test
|
||||
// the output of statement. This parameter has to be
|
||||
// regex_or_matcher - A regex that a macro such as EXPECT_DEATH would use
|
||||
// to test the output of statement. This parameter has to be
|
||||
// compiled but not evaluated by this macro, to ensure that
|
||||
// this macro only accepts expressions that a macro such as
|
||||
// EXPECT_DEATH would accept.
|
||||
@@ -311,13 +311,13 @@ class GTEST_API_ KilledBySignal {
|
||||
// statement unconditionally returns or throws. The Message constructor at
|
||||
// the end allows the syntax of streaming additional messages into the
|
||||
// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
|
||||
#define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \
|
||||
#define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex_or_matcher, terminator) \
|
||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||
if (::testing::internal::AlwaysTrue()) { \
|
||||
GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \
|
||||
<< "Statement '" #statement "' cannot be verified."; \
|
||||
} else if (::testing::internal::AlwaysFalse()) { \
|
||||
::testing::internal::RE::PartialMatch(".*", (regex)); \
|
||||
::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
|
||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
|
||||
terminator; \
|
||||
} else \
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/strings/internal/has_absl_stringify.h"
|
||||
#include "absl/strings/has_absl_stringify.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
@@ -121,14 +121,14 @@ class GTEST_API_ Message {
|
||||
// Streams a non-pointer value to this object. If building a version of
|
||||
// GoogleTest with ABSL, this overload is only enabled if the value does not
|
||||
// have an AbslStringify definition.
|
||||
template <typename T
|
||||
template <
|
||||
typename T
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
,
|
||||
typename std::enable_if<
|
||||
!absl::strings_internal::HasAbslStringify<T>::value, // NOLINT
|
||||
int>::type = 0
|
||||
,
|
||||
typename std::enable_if<!absl::HasAbslStringify<T>::value, // NOLINT
|
||||
int>::type = 0
|
||||
#endif // GTEST_HAS_ABSL
|
||||
>
|
||||
>
|
||||
inline Message& operator<<(const T& val) {
|
||||
// Some libraries overload << for STL containers. These
|
||||
// overloads are defined in the global namespace instead of ::std.
|
||||
@@ -153,9 +153,8 @@ class GTEST_API_ Message {
|
||||
// Streams a non-pointer value with an AbslStringify definition to this
|
||||
// object.
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
absl::strings_internal::HasAbslStringify<T>::value, // NOLINT
|
||||
int>::type = 0>
|
||||
typename std::enable_if<absl::HasAbslStringify<T>::value, // NOLINT
|
||||
int>::type = 0>
|
||||
inline Message& operator<<(const T& val) {
|
||||
// ::operator<< is needed here for a similar reason as with the non-Abseil
|
||||
// version above
|
||||
|
||||
@@ -178,7 +178,7 @@ TEST_P(DerivedTest, DoesBlah) {
|
||||
#include <utility>
|
||||
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-param-util.h"
|
||||
#include "gtest/internal/gtest-param-util.h" // IWYU pragma: export
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
namespace testing {
|
||||
@@ -469,7 +469,7 @@ internal::ParamConverterGenerator<T> ConvertGenerator(
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__)); \
|
||||
return 0; \
|
||||
} \
|
||||
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int gtest_registering_dummy_; \
|
||||
}; \
|
||||
int GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
test_name)::gtest_registering_dummy_ = \
|
||||
@@ -514,8 +514,8 @@ internal::ParamConverterGenerator<T> ConvertGenerator(
|
||||
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
|
||||
DUMMY_PARAM_))))(info); \
|
||||
} \
|
||||
static int gtest_##prefix##test_suite_name##_dummy_ \
|
||||
GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int \
|
||||
gtest_##prefix##test_suite_name##_dummy_ = \
|
||||
::testing::UnitTest::GetInstance() \
|
||||
->parameterized_test_registry() \
|
||||
.GetTestSuitePatternHolder<test_suite_name>( \
|
||||
|
||||
@@ -116,12 +116,16 @@
|
||||
#include <vector>
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#include "absl/strings/internal/has_absl_stringify.h"
|
||||
#include "absl/strings/has_absl_stringify.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#endif // GTEST_HAS_ABSL
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STD_SPAN
|
||||
#include <span> // NOLINT
|
||||
#endif // GTEST_INTERNAL_HAS_STD_SPAN
|
||||
|
||||
namespace testing {
|
||||
|
||||
// Definitions in the internal* namespaces are subject to change without notice.
|
||||
@@ -131,13 +135,32 @@ namespace internal {
|
||||
template <typename T>
|
||||
void UniversalPrint(const T& value, ::std::ostream* os);
|
||||
|
||||
template <typename T>
|
||||
struct IsStdSpan {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
#if GTEST_INTERNAL_HAS_STD_SPAN
|
||||
template <typename E>
|
||||
struct IsStdSpan<std::span<E>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
#endif // GTEST_INTERNAL_HAS_STD_SPAN
|
||||
|
||||
// Used to print an STL-style container when the user doesn't define
|
||||
// a PrintTo() for it.
|
||||
//
|
||||
// NOTE: Since std::span does not have const_iterator until C++23, it would
|
||||
// fail IsContainerTest before C++23. However, IsContainerTest only uses
|
||||
// the presence of const_iterator to avoid treating iterators as containers
|
||||
// because of iterator::iterator. Which means std::span satisfies the *intended*
|
||||
// condition of IsContainerTest.
|
||||
struct ContainerPrinter {
|
||||
template <typename T,
|
||||
typename = typename std::enable_if<
|
||||
(sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
|
||||
!IsRecursiveContainer<T>::value>::type>
|
||||
((sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&
|
||||
!IsRecursiveContainer<T>::value) ||
|
||||
IsStdSpan<T>::value>::type>
|
||||
static void PrintValue(const T& container, std::ostream* os) {
|
||||
const size_t kMaxCount = 32; // The maximum number of elements to print.
|
||||
*os << '{';
|
||||
@@ -218,8 +241,8 @@ struct StreamPrinter {
|
||||
// ADL (possibly involving implicit conversions).
|
||||
// (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
|
||||
// lookup properly when we do it in the template parameter list.)
|
||||
static auto PrintValue(const T& value, ::std::ostream* os)
|
||||
-> decltype((void)(*os << value)) {
|
||||
static auto PrintValue(const T& value,
|
||||
::std::ostream* os) -> decltype((void)(*os << value)) {
|
||||
// Call streaming operator found by ADL, possibly with implicit conversions
|
||||
// of the arguments.
|
||||
*os << value;
|
||||
@@ -269,10 +292,9 @@ struct ConvertibleToStringViewPrinter {
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
struct ConvertibleToAbslStringifyPrinter {
|
||||
template <
|
||||
typename T,
|
||||
typename = typename std::enable_if<
|
||||
absl::strings_internal::HasAbslStringify<T>::value>::type> // NOLINT
|
||||
template <typename T,
|
||||
typename = typename std::enable_if<
|
||||
absl::HasAbslStringify<T>::value>::type> // NOLINT
|
||||
static void PrintValue(const T& value, ::std::ostream* os) {
|
||||
*os << absl::StrCat(value);
|
||||
}
|
||||
@@ -530,49 +552,63 @@ int AppropriateResolution(FloatType val) {
|
||||
int full = std::numeric_limits<FloatType>::max_digits10;
|
||||
if (val < 0) val = -val;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#endif
|
||||
if (val < 1000000) {
|
||||
FloatType mulfor6 = 1e10;
|
||||
if (val >= 100000.0) { // 100,000 to 999,999
|
||||
// Without these static casts, the template instantiation for float would
|
||||
// fail to compile when -Wdouble-promotion is enabled, as the arithmetic and
|
||||
// comparison logic would promote floats to doubles.
|
||||
if (val >= static_cast<FloatType>(100000.0)) { // 100,000 to 999,999
|
||||
mulfor6 = 1.0;
|
||||
} else if (val >= 10000.0) {
|
||||
} else if (val >= static_cast<FloatType>(10000.0)) {
|
||||
mulfor6 = 1e1;
|
||||
} else if (val >= 1000.0) {
|
||||
} else if (val >= static_cast<FloatType>(1000.0)) {
|
||||
mulfor6 = 1e2;
|
||||
} else if (val >= 100.0) {
|
||||
} else if (val >= static_cast<FloatType>(100.0)) {
|
||||
mulfor6 = 1e3;
|
||||
} else if (val >= 10.0) {
|
||||
} else if (val >= static_cast<FloatType>(10.0)) {
|
||||
mulfor6 = 1e4;
|
||||
} else if (val >= 1.0) {
|
||||
} else if (val >= static_cast<FloatType>(1.0)) {
|
||||
mulfor6 = 1e5;
|
||||
} else if (val >= 0.1) {
|
||||
} else if (val >= static_cast<FloatType>(0.1)) {
|
||||
mulfor6 = 1e6;
|
||||
} else if (val >= 0.01) {
|
||||
} else if (val >= static_cast<FloatType>(0.01)) {
|
||||
mulfor6 = 1e7;
|
||||
} else if (val >= 0.001) {
|
||||
} else if (val >= static_cast<FloatType>(0.001)) {
|
||||
mulfor6 = 1e8;
|
||||
} else if (val >= 0.0001) {
|
||||
} else if (val >= static_cast<FloatType>(0.0001)) {
|
||||
mulfor6 = 1e9;
|
||||
}
|
||||
if (static_cast<FloatType>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
|
||||
if (static_cast<FloatType>(static_cast<int32_t>(
|
||||
val * mulfor6 + (static_cast<FloatType>(0.5)))) /
|
||||
mulfor6 ==
|
||||
val)
|
||||
return 6;
|
||||
} else if (val < 1e10) {
|
||||
FloatType divfor6 = 1.0;
|
||||
if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999
|
||||
} else if (val < static_cast<FloatType>(1e10)) {
|
||||
FloatType divfor6 = static_cast<FloatType>(1.0);
|
||||
if (val >= static_cast<FloatType>(1e9)) { // 1,000,000,000 to 9,999,999,999
|
||||
divfor6 = 10000;
|
||||
} else if (val >= 1e8) { // 100,000,000 to 999,999,999
|
||||
} else if (val >=
|
||||
static_cast<FloatType>(1e8)) { // 100,000,000 to 999,999,999
|
||||
divfor6 = 1000;
|
||||
} else if (val >= 1e7) { // 10,000,000 to 99,999,999
|
||||
} else if (val >=
|
||||
static_cast<FloatType>(1e7)) { // 10,000,000 to 99,999,999
|
||||
divfor6 = 100;
|
||||
} else if (val >= 1e6) { // 1,000,000 to 9,999,999
|
||||
} else if (val >= static_cast<FloatType>(1e6)) { // 1,000,000 to 9,999,999
|
||||
divfor6 = 10;
|
||||
}
|
||||
if (static_cast<FloatType>(static_cast<int32_t>(val / divfor6 + 0.5)) *
|
||||
if (static_cast<FloatType>(static_cast<int32_t>(
|
||||
val / divfor6 + (static_cast<FloatType>(0.5)))) *
|
||||
divfor6 ==
|
||||
val)
|
||||
return 6;
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
return full;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,33 +194,34 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
||||
typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
|
||||
GTEST_NAME_GENERATOR_(CaseName)
|
||||
|
||||
#define TYPED_TEST(CaseName, TestName) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
|
||||
"test-name must not be empty"); \
|
||||
template <typename gtest_TypeParam_> \
|
||||
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
|
||||
: public CaseName<gtest_TypeParam_> { \
|
||||
private: \
|
||||
typedef CaseName<gtest_TypeParam_> TestFixture; \
|
||||
typedef gtest_TypeParam_ TypeParam; \
|
||||
void TestBody() override; \
|
||||
}; \
|
||||
static bool gtest_##CaseName##_##TestName##_registered_ \
|
||||
GTEST_ATTRIBUTE_UNUSED_ = ::testing::internal::TypeParameterizedTest< \
|
||||
CaseName, \
|
||||
::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
|
||||
TestName)>, \
|
||||
GTEST_TYPE_PARAMS_( \
|
||||
CaseName)>::Register("", \
|
||||
::testing::internal::CodeLocation( \
|
||||
__FILE__, __LINE__), \
|
||||
GTEST_STRINGIFY_(CaseName), \
|
||||
GTEST_STRINGIFY_(TestName), 0, \
|
||||
::testing::internal::GenerateNames< \
|
||||
GTEST_NAME_GENERATOR_(CaseName), \
|
||||
GTEST_TYPE_PARAMS_(CaseName)>()); \
|
||||
template <typename gtest_TypeParam_> \
|
||||
void GTEST_TEST_CLASS_NAME_(CaseName, \
|
||||
#define TYPED_TEST(CaseName, TestName) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \
|
||||
"test-name must not be empty"); \
|
||||
template <typename gtest_TypeParam_> \
|
||||
class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
|
||||
: public CaseName<gtest_TypeParam_> { \
|
||||
private: \
|
||||
typedef CaseName<gtest_TypeParam_> TestFixture; \
|
||||
typedef gtest_TypeParam_ TypeParam; \
|
||||
void TestBody() override; \
|
||||
}; \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \
|
||||
gtest_##CaseName##_##TestName##_registered_ = \
|
||||
::testing::internal::TypeParameterizedTest< \
|
||||
CaseName, \
|
||||
::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_( \
|
||||
CaseName, TestName)>, \
|
||||
GTEST_TYPE_PARAMS_( \
|
||||
CaseName)>::Register("", \
|
||||
::testing::internal::CodeLocation( \
|
||||
__FILE__, __LINE__), \
|
||||
GTEST_STRINGIFY_(CaseName), \
|
||||
GTEST_STRINGIFY_(TestName), 0, \
|
||||
::testing::internal::GenerateNames< \
|
||||
GTEST_NAME_GENERATOR_(CaseName), \
|
||||
GTEST_TYPE_PARAMS_(CaseName)>()); \
|
||||
template <typename gtest_TypeParam_> \
|
||||
void GTEST_TEST_CLASS_NAME_(CaseName, \
|
||||
TestName)<gtest_TypeParam_>::TestBody()
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
@@ -267,22 +268,23 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
||||
TYPED_TEST_SUITE_P
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
#define TYPED_TEST_P(SuiteName, TestName) \
|
||||
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
|
||||
template <typename gtest_TypeParam_> \
|
||||
class TestName : public SuiteName<gtest_TypeParam_> { \
|
||||
private: \
|
||||
typedef SuiteName<gtest_TypeParam_> TestFixture; \
|
||||
typedef gtest_TypeParam_ TypeParam; \
|
||||
void TestBody() override; \
|
||||
}; \
|
||||
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
|
||||
__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_STRINGIFY_(TestName)); \
|
||||
} \
|
||||
template <typename gtest_TypeParam_> \
|
||||
void GTEST_SUITE_NAMESPACE_( \
|
||||
#define TYPED_TEST_P(SuiteName, TestName) \
|
||||
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
|
||||
template <typename gtest_TypeParam_> \
|
||||
class TestName : public SuiteName<gtest_TypeParam_> { \
|
||||
private: \
|
||||
typedef SuiteName<gtest_TypeParam_> TestFixture; \
|
||||
typedef gtest_TypeParam_ TypeParam; \
|
||||
void TestBody() override; \
|
||||
}; \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \
|
||||
gtest_##TestName##_defined_ = \
|
||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
|
||||
__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_STRINGIFY_(TestName)); \
|
||||
} \
|
||||
template <typename gtest_TypeParam_> \
|
||||
void GTEST_SUITE_NAMESPACE_( \
|
||||
SuiteName)::TestName<gtest_TypeParam_>::TestBody()
|
||||
|
||||
// Note: this won't work correctly if the trailing arguments are macros.
|
||||
@@ -290,8 +292,8 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
||||
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
|
||||
typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
|
||||
} \
|
||||
static const char* const GTEST_REGISTERED_TEST_NAMES_( \
|
||||
SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static const char* const \
|
||||
GTEST_REGISTERED_TEST_NAMES_(SuiteName) = \
|
||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
|
||||
GTEST_STRINGIFY_(SuiteName), __FILE__, __LINE__, #__VA_ARGS__)
|
||||
|
||||
@@ -303,22 +305,24 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
||||
REGISTER_TYPED_TEST_SUITE_P
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
|
||||
"test-suit-prefix must not be empty"); \
|
||||
static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
|
||||
::testing::internal::TypeParameterizedTestSuite< \
|
||||
SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>:: \
|
||||
Register(GTEST_STRINGIFY_(Prefix), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), \
|
||||
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
|
||||
GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
|
||||
::testing::internal::GenerateNames< \
|
||||
::testing::internal::NameGeneratorSelector< \
|
||||
__VA_ARGS__>::type, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>())
|
||||
#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
|
||||
static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \
|
||||
"test-suit-prefix must not be empty"); \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool \
|
||||
gtest_##Prefix##_##SuiteName = \
|
||||
::testing::internal::TypeParameterizedTestSuite< \
|
||||
SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>:: \
|
||||
Register( \
|
||||
GTEST_STRINGIFY_(Prefix), \
|
||||
::testing::internal::CodeLocation(__FILE__, __LINE__), \
|
||||
>EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \
|
||||
GTEST_STRINGIFY_(SuiteName), \
|
||||
GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
|
||||
::testing::internal::GenerateNames< \
|
||||
::testing::internal::NameGeneratorSelector< \
|
||||
__VA_ARGS__>::type, \
|
||||
::testing::internal::GenerateTypeList<Types>::type>())
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
@@ -61,16 +60,16 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest-assertion-result.h"
|
||||
#include "gtest/gtest-death-test.h"
|
||||
#include "gtest/gtest-matchers.h"
|
||||
#include "gtest/gtest-message.h"
|
||||
#include "gtest/gtest-param-test.h"
|
||||
#include "gtest/gtest-printers.h"
|
||||
#include "gtest/gtest-test-part.h"
|
||||
#include "gtest/gtest-typed-test.h"
|
||||
#include "gtest/gtest_pred_impl.h"
|
||||
#include "gtest/gtest_prod.h"
|
||||
#include "gtest/gtest-assertion-result.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-death-test.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-matchers.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-message.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-param-test.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-printers.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-test-part.h" // IWYU pragma: export
|
||||
#include "gtest/gtest-typed-test.h" // IWYU pragma: export
|
||||
#include "gtest/gtest_pred_impl.h" // IWYU pragma: export
|
||||
#include "gtest/gtest_prod.h" // IWYU pragma: export
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
|
||||
@@ -608,7 +607,7 @@ class GTEST_API_ TestInfo {
|
||||
friend class internal::UnitTestImpl;
|
||||
friend class internal::StreamingListenerTest;
|
||||
friend TestInfo* internal::MakeAndRegisterTestInfo(
|
||||
const char* test_suite_name, const char* name, const char* type_param,
|
||||
std::string test_suite_name, const char* name, const char* type_param,
|
||||
const char* value_param, internal::CodeLocation code_location,
|
||||
internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc,
|
||||
@@ -616,7 +615,7 @@ class GTEST_API_ TestInfo {
|
||||
|
||||
// Constructs a TestInfo object. The newly constructed instance assumes
|
||||
// ownership of the factory object.
|
||||
TestInfo(const std::string& test_suite_name, const std::string& name,
|
||||
TestInfo(std::string test_suite_name, std::string name,
|
||||
const char* a_type_param, // NULL if not a type-parameterized test
|
||||
const char* a_value_param, // NULL if not a value-parameterized test
|
||||
internal::CodeLocation a_code_location,
|
||||
@@ -684,7 +683,7 @@ class GTEST_API_ TestSuite {
|
||||
// this is not a type-parameterized test.
|
||||
// set_up_tc: pointer to the function that sets up the test suite
|
||||
// tear_down_tc: pointer to the function that tears down the test suite
|
||||
TestSuite(const char* name, const char* a_type_param,
|
||||
TestSuite(const std::string& name, const char* a_type_param,
|
||||
internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc);
|
||||
|
||||
@@ -1263,6 +1262,20 @@ class GTEST_API_ UnitTest {
|
||||
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
|
||||
TestSuite* GetMutableTestSuite(int i);
|
||||
|
||||
// Invokes OsStackTrackGetterInterface::UponLeavingGTest. UponLeavingGTest()
|
||||
// should be called immediately before Google Test calls user code. It saves
|
||||
// some information about the current stack that CurrentStackTrace() will use
|
||||
// to find and hide Google Test stack frames.
|
||||
void UponLeavingGTest();
|
||||
|
||||
// Sets the TestSuite object for the test that's currently running.
|
||||
void set_current_test_suite(TestSuite* a_current_test_suite)
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
// Sets the TestInfo object for the test that's currently running.
|
||||
void set_current_test_info(TestInfo* a_current_test_info)
|
||||
GTEST_LOCK_EXCLUDED_(mutex_);
|
||||
|
||||
// Accessors for the implementation object.
|
||||
internal::UnitTestImpl* impl() { return impl_; }
|
||||
const internal::UnitTestImpl* impl() const { return impl_; }
|
||||
@@ -1271,6 +1284,8 @@ class GTEST_API_ UnitTest {
|
||||
// members of UnitTest.
|
||||
friend class ScopedTrace;
|
||||
friend class Test;
|
||||
friend class TestInfo;
|
||||
friend class TestSuite;
|
||||
friend class internal::AssertHelper;
|
||||
friend class internal::StreamingListenerTest;
|
||||
friend class internal::UnitTestRecordPropertyTestHelper;
|
||||
@@ -1574,12 +1589,12 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
}
|
||||
|
||||
::std::stringstream lhs_ss;
|
||||
lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< lhs_value;
|
||||
lhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2);
|
||||
lhs_ss << lhs_value;
|
||||
|
||||
::std::stringstream rhs_ss;
|
||||
rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< rhs_value;
|
||||
rhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2);
|
||||
rhs_ss << rhs_value;
|
||||
|
||||
return EqFailure(lhs_expression, rhs_expression,
|
||||
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
|
||||
@@ -1752,6 +1767,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
|
||||
// generic name and clashes with some other libraries.
|
||||
#if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL)
|
||||
#define FAIL() GTEST_FAIL()
|
||||
#define FAIL_AT(file, line) GTEST_FAIL_AT(file, line)
|
||||
#endif
|
||||
|
||||
// Generates a success with a generic message.
|
||||
@@ -2308,7 +2324,8 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
|
||||
// tests are successful, or 1 otherwise.
|
||||
//
|
||||
// RUN_ALL_TESTS() should be invoked after the command line has been
|
||||
// parsed by InitGoogleTest().
|
||||
// parsed by InitGoogleTest(). RUN_ALL_TESTS will tear down and delete any
|
||||
// installed environments and should only be called once per binary.
|
||||
//
|
||||
// This function was formerly a macro; thus, it is in the global
|
||||
// namespace and has an all-caps name.
|
||||
|
||||
@@ -46,17 +46,38 @@
|
||||
|
||||
#include "gtest/gtest-matchers.h"
|
||||
#include "gtest/internal/gtest-internal.h"
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
GTEST_DECLARE_string_(internal_run_death_test);
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
|
||||
// Names of the flags (needed for parsing Google Test flags).
|
||||
const char kDeathTestStyleFlag[] = "death_test_style";
|
||||
const char kDeathTestUseFork[] = "death_test_use_fork";
|
||||
// Name of the flag (needed for parsing Google Test flag).
|
||||
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
|
||||
|
||||
// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
|
||||
// and interpreted as a regex (rather than an Eq matcher) for legacy
|
||||
// compatibility.
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
::testing::internal::RE regex) {
|
||||
return ContainsRegex(regex.pattern());
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
const ::std::string& regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
|
||||
// If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
|
||||
// used directly.
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
Matcher<const ::std::string&> matcher) {
|
||||
return matcher;
|
||||
}
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||
@@ -73,7 +94,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
|
||||
//
|
||||
// exit status: The integer exit information in the format specified
|
||||
// by wait(2)
|
||||
// exit code: The integer code passed to exit(3), _exit(2), or
|
||||
// exit code: The integer code passed to exit(3), _Exit(2), or
|
||||
// returned from main()
|
||||
class GTEST_API_ DeathTest {
|
||||
public:
|
||||
@@ -170,28 +191,6 @@ class DefaultDeathTestFactory : public DeathTestFactory {
|
||||
// by a signal, or exited normally with a nonzero exit code.
|
||||
GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
||||
|
||||
// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
|
||||
// and interpreted as a regex (rather than an Eq matcher) for legacy
|
||||
// compatibility.
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
::testing::internal::RE regex) {
|
||||
return ContainsRegex(regex.pattern());
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
const ::std::string& regex) {
|
||||
return ContainsRegex(regex);
|
||||
}
|
||||
|
||||
// If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
|
||||
// used directly.
|
||||
inline Matcher<const ::std::string&> MakeDeathTestMatcher(
|
||||
Matcher<const ::std::string&> matcher) {
|
||||
return matcher;
|
||||
}
|
||||
|
||||
// Traps C++ exceptions escaping statement and reports them as test
|
||||
// failures. Note that trapping SEH exceptions is not implemented here.
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
#include "gtest/internal/gtest-string.h"
|
||||
@@ -70,8 +71,9 @@ class GTEST_API_ FilePath {
|
||||
public:
|
||||
FilePath() : pathname_("") {}
|
||||
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
|
||||
FilePath(FilePath&& rhs) noexcept : pathname_(std::move(rhs.pathname_)) {}
|
||||
|
||||
explicit FilePath(const std::string& pathname) : pathname_(pathname) {
|
||||
explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
|
||||
Normalize();
|
||||
}
|
||||
|
||||
@@ -79,6 +81,10 @@ class GTEST_API_ FilePath {
|
||||
Set(rhs);
|
||||
return *this;
|
||||
}
|
||||
FilePath& operator=(FilePath&& rhs) noexcept {
|
||||
pathname_ = std::move(rhs.pathname_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -79,7 +78,7 @@
|
||||
//
|
||||
// will result in the token foo__LINE__, instead of foo followed by
|
||||
// the current line number. For more details, see
|
||||
// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
|
||||
// https://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
|
||||
#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
|
||||
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo##bar
|
||||
|
||||
@@ -170,7 +169,7 @@ namespace edit_distance {
|
||||
// All edits cost the same, with replace having lower priority than
|
||||
// add/remove.
|
||||
// Simple implementation of the Wagner-Fischer algorithm.
|
||||
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
|
||||
// See https://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
|
||||
enum EditType { kMatch, kAdd, kRemove, kReplace };
|
||||
GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
|
||||
const std::vector<size_t>& left, const std::vector<size_t>& right);
|
||||
@@ -237,7 +236,7 @@ GTEST_API_ std::string GetBoolAssertionFailureMessage(
|
||||
// For double, there are 11 exponent bits and 52 fraction bits.
|
||||
//
|
||||
// More details can be found at
|
||||
// http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
|
||||
// https://en.wikipedia.org/wiki/IEEE_floating-point_standard.
|
||||
//
|
||||
// Template parameter:
|
||||
//
|
||||
@@ -282,7 +281,7 @@ class FloatingPoint {
|
||||
// bits. Therefore, 4 should be enough for ordinary use.
|
||||
//
|
||||
// See the following article for more details on ULP:
|
||||
// http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
static const uint32_t kMaxUlps = 4;
|
||||
|
||||
// Constructs a FloatingPoint from a raw floating-point number.
|
||||
@@ -363,7 +362,7 @@ class FloatingPoint {
|
||||
// N - 1 (the biggest number representable using
|
||||
// sign-and-magnitude) is represented by 2N - 1.
|
||||
//
|
||||
// Read http://en.wikipedia.org/wiki/Signed_number_representations
|
||||
// Read https://en.wikipedia.org/wiki/Signed_number_representations
|
||||
// for more details on signed number representations.
|
||||
static Bits SignAndMagnitudeToBiased(const Bits& sam) {
|
||||
if (kSignBitMask & sam) {
|
||||
@@ -475,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)();
|
||||
using TearDownTestSuiteFunc = void (*)();
|
||||
|
||||
struct CodeLocation {
|
||||
CodeLocation(const std::string& a_file, int a_line)
|
||||
: file(a_file), line(a_line) {}
|
||||
CodeLocation(std::string a_file, int a_line)
|
||||
: file(std::move(a_file)), line(a_line) {}
|
||||
|
||||
std::string file;
|
||||
int line;
|
||||
@@ -556,7 +555,7 @@ struct SuiteApiResolver : T {
|
||||
// type_param: the name of the test's type parameter, or NULL if
|
||||
// this is not a typed or a type-parameterized test.
|
||||
// value_param: text representation of the test's value parameter,
|
||||
// or NULL if this is not a type-parameterized test.
|
||||
// or NULL if this is not a value-parameterized test.
|
||||
// code_location: code location where the test is defined
|
||||
// fixture_class_id: ID of the test fixture class
|
||||
// set_up_tc: pointer to the function that sets up the test suite
|
||||
@@ -565,7 +564,7 @@ struct SuiteApiResolver : T {
|
||||
// The newly created TestInfo instance will assume
|
||||
// ownership of the factory object.
|
||||
GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
|
||||
const char* test_suite_name, const char* name, const char* type_param,
|
||||
std::string test_suite_name, const char* name, const char* type_param,
|
||||
const char* value_param, CodeLocation code_location,
|
||||
TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
|
||||
TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
|
||||
@@ -596,8 +595,7 @@ class GTEST_API_ TypedTestSuitePState {
|
||||
fflush(stderr);
|
||||
posix::Abort();
|
||||
}
|
||||
registered_tests_.insert(
|
||||
::std::make_pair(test_name, CodeLocation(file, line)));
|
||||
registered_tests_.emplace(test_name, CodeLocation(file, line));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -701,7 +699,7 @@ class TypeParameterizedTest {
|
||||
// specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
|
||||
// Types). Valid values for 'index' are [0, N - 1] where N is the
|
||||
// length of Types.
|
||||
static bool Register(const char* prefix, const CodeLocation& code_location,
|
||||
static bool Register(const char* prefix, CodeLocation code_location,
|
||||
const char* case_name, const char* test_names, int index,
|
||||
const std::vector<std::string>& type_names =
|
||||
GenerateNames<DefaultNameGenerator, Types>()) {
|
||||
@@ -713,8 +711,7 @@ class TypeParameterizedTest {
|
||||
// list.
|
||||
MakeAndRegisterTestInfo(
|
||||
(std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
|
||||
"/" + type_names[static_cast<size_t>(index)])
|
||||
.c_str(),
|
||||
"/" + type_names[static_cast<size_t>(index)]),
|
||||
StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
|
||||
GetTypeName<Type>().c_str(),
|
||||
nullptr, // No value parameter.
|
||||
@@ -726,13 +723,9 @@ class TypeParameterizedTest {
|
||||
new TestFactoryImpl<TestClass>);
|
||||
|
||||
// Next, recurses (at compile time) with the tail of the type list.
|
||||
return TypeParameterizedTest<Fixture, TestSel,
|
||||
typename Types::Tail>::Register(prefix,
|
||||
code_location,
|
||||
case_name,
|
||||
test_names,
|
||||
index + 1,
|
||||
type_names);
|
||||
return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>::
|
||||
Register(prefix, std::move(code_location), case_name, test_names,
|
||||
index + 1, type_names);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -740,7 +733,7 @@ class TypeParameterizedTest {
|
||||
template <GTEST_TEMPLATE_ Fixture, class TestSel>
|
||||
class TypeParameterizedTest<Fixture, TestSel, internal::None> {
|
||||
public:
|
||||
static bool Register(const char* /*prefix*/, const CodeLocation&,
|
||||
static bool Register(const char* /*prefix*/, CodeLocation,
|
||||
const char* /*case_name*/, const char* /*test_names*/,
|
||||
int /*index*/,
|
||||
const std::vector<std::string>& =
|
||||
@@ -787,7 +780,8 @@ class TypeParameterizedTestSuite {
|
||||
|
||||
// Next, recurses (at compile time) with the tail of the test list.
|
||||
return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,
|
||||
Types>::Register(prefix, code_location,
|
||||
Types>::Register(prefix,
|
||||
std::move(code_location),
|
||||
state, case_name,
|
||||
SkipComma(test_names),
|
||||
type_names);
|
||||
@@ -1143,40 +1137,6 @@ class NativeArray {
|
||||
void (NativeArray::*clone_)(const Element*, size_t);
|
||||
};
|
||||
|
||||
// Backport of std::index_sequence.
|
||||
template <size_t... Is>
|
||||
struct IndexSequence {
|
||||
using type = IndexSequence;
|
||||
};
|
||||
|
||||
// Double the IndexSequence, and one if plus_one is true.
|
||||
template <bool plus_one, typename T, size_t sizeofT>
|
||||
struct DoubleSequence;
|
||||
template <size_t... I, size_t sizeofT>
|
||||
struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
|
||||
using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
|
||||
};
|
||||
template <size_t... I, size_t sizeofT>
|
||||
struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
|
||||
using type = IndexSequence<I..., (sizeofT + I)...>;
|
||||
};
|
||||
|
||||
// Backport of std::make_index_sequence.
|
||||
// It uses O(ln(N)) instantiation depth.
|
||||
template <size_t N>
|
||||
struct MakeIndexSequenceImpl
|
||||
: DoubleSequence<N % 2 == 1, typename MakeIndexSequenceImpl<N / 2>::type,
|
||||
N / 2>::type {};
|
||||
|
||||
template <>
|
||||
struct MakeIndexSequenceImpl<0> : IndexSequence<> {};
|
||||
|
||||
template <size_t N>
|
||||
using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::type;
|
||||
|
||||
template <typename... T>
|
||||
using IndexSequenceFor = typename MakeIndexSequence<sizeof...(T)>::type;
|
||||
|
||||
template <size_t>
|
||||
struct Ignore {
|
||||
Ignore(...); // NOLINT
|
||||
@@ -1185,7 +1145,7 @@ struct Ignore {
|
||||
template <typename>
|
||||
struct ElemFromListImpl;
|
||||
template <size_t... I>
|
||||
struct ElemFromListImpl<IndexSequence<I...>> {
|
||||
struct ElemFromListImpl<std::index_sequence<I...>> {
|
||||
// We make Ignore a template to solve a problem with MSVC.
|
||||
// A non-template Ignore would work fine with `decltype(Ignore(I))...`, but
|
||||
// MSVC doesn't understand how to deal with that pack expansion.
|
||||
@@ -1196,9 +1156,8 @@ struct ElemFromListImpl<IndexSequence<I...>> {
|
||||
|
||||
template <size_t N, typename... T>
|
||||
struct ElemFromList {
|
||||
using type =
|
||||
decltype(ElemFromListImpl<typename MakeIndexSequence<N>::type>::Apply(
|
||||
static_cast<T (*)()>(nullptr)...));
|
||||
using type = decltype(ElemFromListImpl<std::make_index_sequence<N>>::Apply(
|
||||
static_cast<T (*)()>(nullptr)...));
|
||||
};
|
||||
|
||||
struct FlatTupleConstructTag {};
|
||||
@@ -1223,9 +1182,9 @@ template <typename Derived, typename Idx>
|
||||
struct FlatTupleBase;
|
||||
|
||||
template <size_t... Idx, typename... T>
|
||||
struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
|
||||
struct FlatTupleBase<FlatTuple<T...>, std::index_sequence<Idx...>>
|
||||
: FlatTupleElemBase<FlatTuple<T...>, Idx>... {
|
||||
using Indices = IndexSequence<Idx...>;
|
||||
using Indices = std::index_sequence<Idx...>;
|
||||
FlatTupleBase() = default;
|
||||
template <typename... Args>
|
||||
explicit FlatTupleBase(FlatTupleConstructTag, Args&&... args)
|
||||
@@ -1260,14 +1219,15 @@ struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
|
||||
// implementations.
|
||||
// FlatTuple and ElemFromList are not recursive and have a fixed depth
|
||||
// regardless of T...
|
||||
// MakeIndexSequence, on the other hand, it is recursive but with an
|
||||
// std::make_index_sequence, on the other hand, it is recursive but with an
|
||||
// instantiation depth of O(ln(N)).
|
||||
template <typename... T>
|
||||
class FlatTuple
|
||||
: private FlatTupleBase<FlatTuple<T...>,
|
||||
typename MakeIndexSequence<sizeof...(T)>::type> {
|
||||
using Indices = typename FlatTupleBase<
|
||||
FlatTuple<T...>, typename MakeIndexSequence<sizeof...(T)>::type>::Indices;
|
||||
std::make_index_sequence<sizeof...(T)>> {
|
||||
using Indices =
|
||||
typename FlatTupleBase<FlatTuple<T...>,
|
||||
std::make_index_sequence<sizeof...(T)>>::Indices;
|
||||
|
||||
public:
|
||||
FlatTuple() = default;
|
||||
@@ -1541,7 +1501,8 @@ class NeverThrown {
|
||||
\
|
||||
private: \
|
||||
void TestBody() override; \
|
||||
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_; \
|
||||
GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static ::testing::TestInfo* const \
|
||||
test_info_; \
|
||||
}; \
|
||||
\
|
||||
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name, \
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -85,7 +86,7 @@ namespace internal {
|
||||
// TEST_P macro is used to define two tests with the same name
|
||||
// but in different namespaces.
|
||||
GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
|
||||
CodeLocation code_location);
|
||||
const CodeLocation& code_location);
|
||||
|
||||
template <typename>
|
||||
class ParamGeneratorInterface;
|
||||
@@ -379,9 +380,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
|
||||
// integer test parameter index.
|
||||
template <class ParamType>
|
||||
std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
|
||||
Message name_stream;
|
||||
name_stream << info.index;
|
||||
return name_stream.GetString();
|
||||
return std::to_string(info.index);
|
||||
}
|
||||
|
||||
template <typename T = int>
|
||||
@@ -513,9 +512,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
||||
typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
|
||||
using ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&);
|
||||
|
||||
explicit ParameterizedTestSuiteInfo(const char* name,
|
||||
explicit ParameterizedTestSuiteInfo(std::string name,
|
||||
CodeLocation code_location)
|
||||
: test_suite_name_(name), code_location_(code_location) {}
|
||||
: test_suite_name_(std::move(name)),
|
||||
code_location_(std::move(code_location)) {}
|
||||
|
||||
// Test suite base name for display purposes.
|
||||
const std::string& GetTestSuiteName() const override {
|
||||
@@ -529,20 +529,21 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
||||
// prefix). test_base_name is the name of an individual test without
|
||||
// parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
|
||||
// test suite base name and DoBar is test base name.
|
||||
void AddTestPattern(const char* test_suite_name, const char* test_base_name,
|
||||
void AddTestPattern(const char*,
|
||||
const char* test_base_name,
|
||||
TestMetaFactoryBase<ParamType>* meta_factory,
|
||||
CodeLocation code_location) {
|
||||
tests_.push_back(std::shared_ptr<TestInfo>(new TestInfo(
|
||||
test_suite_name, test_base_name, meta_factory, code_location)));
|
||||
tests_.emplace_back(
|
||||
new TestInfo(test_base_name, meta_factory, std::move(code_location)));
|
||||
}
|
||||
// INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
|
||||
// about a generator.
|
||||
int AddTestSuiteInstantiation(const std::string& instantiation_name,
|
||||
int AddTestSuiteInstantiation(std::string instantiation_name,
|
||||
GeneratorCreationFunc* func,
|
||||
ParamNameGeneratorFunc* name_func,
|
||||
const char* file, int line) {
|
||||
instantiations_.push_back(
|
||||
InstantiationInfo(instantiation_name, func, name_func, file, line));
|
||||
instantiations_.emplace_back(std::move(instantiation_name), func, name_func,
|
||||
file, line);
|
||||
return 0; // Return value used only to run this method in namespace scope.
|
||||
}
|
||||
// UnitTest class invokes this method to register tests in this test suite
|
||||
@@ -553,60 +554,61 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
||||
void RegisterTests() override {
|
||||
bool generated_instantiations = false;
|
||||
|
||||
for (typename TestInfoContainer::iterator test_it = tests_.begin();
|
||||
test_it != tests_.end(); ++test_it) {
|
||||
std::shared_ptr<TestInfo> test_info = *test_it;
|
||||
for (typename InstantiationContainer::iterator gen_it =
|
||||
instantiations_.begin();
|
||||
gen_it != instantiations_.end(); ++gen_it) {
|
||||
const std::string& instantiation_name = gen_it->name;
|
||||
ParamGenerator<ParamType> generator((*gen_it->generator)());
|
||||
ParamNameGeneratorFunc* name_func = gen_it->name_func;
|
||||
const char* file = gen_it->file;
|
||||
int line = gen_it->line;
|
||||
std::string test_suite_name;
|
||||
std::string test_name;
|
||||
for (const std::shared_ptr<TestInfo>& test_info : tests_) {
|
||||
for (const InstantiationInfo& instantiation : instantiations_) {
|
||||
const std::string& instantiation_name = instantiation.name;
|
||||
ParamGenerator<ParamType> generator((*instantiation.generator)());
|
||||
ParamNameGeneratorFunc* name_func = instantiation.name_func;
|
||||
const char* file = instantiation.file;
|
||||
int line = instantiation.line;
|
||||
|
||||
std::string test_suite_name;
|
||||
if (!instantiation_name.empty())
|
||||
test_suite_name = instantiation_name + "/";
|
||||
test_suite_name += test_info->test_suite_base_name;
|
||||
else
|
||||
test_suite_name.clear();
|
||||
test_suite_name += test_suite_name_;
|
||||
|
||||
size_t i = 0;
|
||||
std::set<std::string> test_param_names;
|
||||
for (typename ParamGenerator<ParamType>::iterator param_it =
|
||||
generator.begin();
|
||||
param_it != generator.end(); ++param_it, ++i) {
|
||||
for (const auto& param : generator) {
|
||||
generated_instantiations = true;
|
||||
|
||||
Message test_name_stream;
|
||||
test_name.clear();
|
||||
|
||||
std::string param_name =
|
||||
name_func(TestParamInfo<ParamType>(*param_it, i));
|
||||
name_func(TestParamInfo<ParamType>(param, i));
|
||||
|
||||
GTEST_CHECK_(IsValidParamName(param_name))
|
||||
<< "Parameterized test name '" << param_name
|
||||
<< "' is invalid, in " << file << " line " << line << std::endl;
|
||||
<< "' is invalid (contains spaces, dashes, or any "
|
||||
"non-alphanumeric characters other than underscores), in "
|
||||
<< file << " line " << line << "" << std::endl;
|
||||
|
||||
GTEST_CHECK_(test_param_names.count(param_name) == 0)
|
||||
<< "Duplicate parameterized test name '" << param_name << "', in "
|
||||
<< file << " line " << line << std::endl;
|
||||
|
||||
test_param_names.insert(param_name);
|
||||
|
||||
if (!test_info->test_base_name.empty()) {
|
||||
test_name_stream << test_info->test_base_name << "/";
|
||||
test_name.append(test_info->test_base_name).append("/");
|
||||
}
|
||||
test_name_stream << param_name;
|
||||
test_name += param_name;
|
||||
|
||||
test_param_names.insert(std::move(param_name));
|
||||
|
||||
MakeAndRegisterTestInfo(
|
||||
test_suite_name.c_str(), test_name_stream.GetString().c_str(),
|
||||
test_suite_name, test_name.c_str(),
|
||||
nullptr, // No type parameter.
|
||||
PrintToString(*param_it).c_str(), test_info->code_location,
|
||||
PrintToString(param).c_str(), test_info->code_location,
|
||||
GetTestSuiteTypeId(),
|
||||
SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(file, line),
|
||||
SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(file, line),
|
||||
test_info->test_meta_factory->CreateTestFactory(*param_it));
|
||||
} // for param_it
|
||||
} // for gen_it
|
||||
} // for test_it
|
||||
test_info->test_meta_factory->CreateTestFactory(param));
|
||||
++i;
|
||||
} // for param
|
||||
} // for instantiation
|
||||
} // for test_info
|
||||
|
||||
if (!generated_instantiations) {
|
||||
// There are no generaotrs, or they all generate nothing ...
|
||||
@@ -619,15 +621,13 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
||||
// LocalTestInfo structure keeps information about a single test registered
|
||||
// with TEST_P macro.
|
||||
struct TestInfo {
|
||||
TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
|
||||
TestInfo(const char* a_test_base_name,
|
||||
TestMetaFactoryBase<ParamType>* a_test_meta_factory,
|
||||
CodeLocation a_code_location)
|
||||
: test_suite_base_name(a_test_suite_base_name),
|
||||
test_base_name(a_test_base_name),
|
||||
: test_base_name(a_test_base_name),
|
||||
test_meta_factory(a_test_meta_factory),
|
||||
code_location(a_code_location) {}
|
||||
code_location(std::move(a_code_location)) {}
|
||||
|
||||
const std::string test_suite_base_name;
|
||||
const std::string test_base_name;
|
||||
const std::unique_ptr<TestMetaFactoryBase<ParamType>> test_meta_factory;
|
||||
const CodeLocation code_location;
|
||||
@@ -637,11 +637,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
|
||||
// <Instantiation name, Sequence generator creation function,
|
||||
// Name generator function, Source file, Source line>
|
||||
struct InstantiationInfo {
|
||||
InstantiationInfo(const std::string& name_in,
|
||||
GeneratorCreationFunc* generator_in,
|
||||
InstantiationInfo(std::string name_in, GeneratorCreationFunc* generator_in,
|
||||
ParamNameGeneratorFunc* name_func_in, const char* file_in,
|
||||
int line_in)
|
||||
: name(name_in),
|
||||
: name(std::move(name_in)),
|
||||
generator(generator_in),
|
||||
name_func(name_func_in),
|
||||
file(file_in),
|
||||
@@ -702,29 +701,32 @@ class ParameterizedTestSuiteRegistry {
|
||||
// tests and instantiations of a particular test suite.
|
||||
template <class TestSuite>
|
||||
ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(
|
||||
const char* test_suite_name, CodeLocation code_location) {
|
||||
std::string test_suite_name, CodeLocation code_location) {
|
||||
ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;
|
||||
for (auto& test_suite_info : test_suite_infos_) {
|
||||
if (test_suite_info->GetTestSuiteName() == test_suite_name) {
|
||||
if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
|
||||
// Complain about incorrect usage of Google Test facilities
|
||||
// and terminate the program since we cannot guaranty correct
|
||||
// test suite setup and tear-down in this case.
|
||||
ReportInvalidTestSuiteType(test_suite_name, code_location);
|
||||
posix::Abort();
|
||||
} else {
|
||||
// At this point we are sure that the object we found is of the same
|
||||
// type we are looking for, so we downcast it to that type
|
||||
// without further checks.
|
||||
typed_test_info = CheckedDowncastToActualType<
|
||||
ParameterizedTestSuiteInfo<TestSuite>>(test_suite_info);
|
||||
}
|
||||
break;
|
||||
|
||||
auto item_it = suite_name_to_info_index_.find(test_suite_name);
|
||||
if (item_it != suite_name_to_info_index_.end()) {
|
||||
auto* test_suite_info = test_suite_infos_[item_it->second];
|
||||
if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {
|
||||
// Complain about incorrect usage of Google Test facilities
|
||||
// and terminate the program since we cannot guaranty correct
|
||||
// test suite setup and tear-down in this case.
|
||||
ReportInvalidTestSuiteType(test_suite_name.c_str(), code_location);
|
||||
posix::Abort();
|
||||
} else {
|
||||
// At this point we are sure that the object we found is of the same
|
||||
// type we are looking for, so we downcast it to that type
|
||||
// without further checks.
|
||||
typed_test_info =
|
||||
CheckedDowncastToActualType<ParameterizedTestSuiteInfo<TestSuite>>(
|
||||
test_suite_info);
|
||||
}
|
||||
}
|
||||
if (typed_test_info == nullptr) {
|
||||
typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(
|
||||
test_suite_name, code_location);
|
||||
test_suite_name, std::move(code_location));
|
||||
suite_name_to_info_index_.emplace(std::move(test_suite_name),
|
||||
test_suite_infos_.size());
|
||||
test_suite_infos_.push_back(typed_test_info);
|
||||
}
|
||||
return typed_test_info;
|
||||
@@ -738,8 +740,9 @@ class ParameterizedTestSuiteRegistry {
|
||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
template <class TestCase>
|
||||
ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(
|
||||
const char* test_case_name, CodeLocation code_location) {
|
||||
return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);
|
||||
std::string test_case_name, CodeLocation code_location) {
|
||||
return GetTestSuitePatternHolder<TestCase>(std::move(test_case_name),
|
||||
std::move(code_location));
|
||||
}
|
||||
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
@@ -748,6 +751,7 @@ class ParameterizedTestSuiteRegistry {
|
||||
using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;
|
||||
|
||||
TestSuiteInfoContainer test_suite_infos_;
|
||||
::std::unordered_map<std::string, size_t> suite_name_to_info_index_;
|
||||
|
||||
ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
|
||||
delete;
|
||||
@@ -774,7 +778,7 @@ class TypeParameterizedTestSuiteRegistry {
|
||||
private:
|
||||
struct TypeParameterizedTestSuiteInfo {
|
||||
explicit TypeParameterizedTestSuiteInfo(CodeLocation c)
|
||||
: code_location(c), instantiated(false) {}
|
||||
: code_location(std::move(c)), instantiated(false) {}
|
||||
|
||||
CodeLocation code_location;
|
||||
bool instantiated;
|
||||
@@ -803,12 +807,12 @@ class ValueArray {
|
||||
|
||||
template <typename T>
|
||||
operator ParamGenerator<T>() const { // NOLINT
|
||||
return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
|
||||
return ValuesIn(MakeVector<T>(std::make_index_sequence<sizeof...(Ts)>()));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T, size_t... I>
|
||||
std::vector<T> MakeVector(IndexSequence<I...>) const {
|
||||
std::vector<T> MakeVector(std::index_sequence<I...>) const {
|
||||
return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
|
||||
}
|
||||
|
||||
@@ -838,7 +842,7 @@ class CartesianProductGenerator
|
||||
template <class I>
|
||||
class IteratorImpl;
|
||||
template <size_t... I>
|
||||
class IteratorImpl<IndexSequence<I...>>
|
||||
class IteratorImpl<std::index_sequence<I...>>
|
||||
: public ParamIteratorInterface<ParamType> {
|
||||
public:
|
||||
IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
|
||||
@@ -929,7 +933,7 @@ class CartesianProductGenerator
|
||||
std::shared_ptr<ParamType> current_value_;
|
||||
};
|
||||
|
||||
using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;
|
||||
using Iterator = IteratorImpl<std::make_index_sequence<sizeof...(T)>>;
|
||||
|
||||
std::tuple<ParamGenerator<T>...> generators_;
|
||||
};
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
|
||||
#define GTEST_OS_WINDOWS_PHONE 1
|
||||
#define GTEST_OS_WINDOWS_TV_TITLE 1
|
||||
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
|
||||
#define GTEST_OS_WINDOWS_GAMES 1
|
||||
#else
|
||||
// WINAPI_FAMILY defined but no known partition matched.
|
||||
// Default to desktop.
|
||||
|
||||
@@ -194,8 +194,6 @@
|
||||
//
|
||||
// Macros for basic C++ coding:
|
||||
// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
|
||||
// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a
|
||||
// variable don't have to be used.
|
||||
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
|
||||
// GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
|
||||
// suppressed (constant conditional).
|
||||
@@ -208,6 +206,8 @@
|
||||
// or
|
||||
// UniversalPrinter<absl::optional>
|
||||
// specializations. Always defined to 0 or 1.
|
||||
// GTEST_INTERNAL_HAS_STD_SPAN - for enabling UniversalPrinter<std::span>
|
||||
// specializations. Always defined to 0 or 1
|
||||
// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or
|
||||
// Matcher<absl::string_view>
|
||||
// specializations. Always defined to 0 or 1.
|
||||
@@ -279,6 +279,22 @@
|
||||
#error C++ versions less than C++14 are not supported.
|
||||
#endif
|
||||
|
||||
// MSVC >= 19.11 (VS 2017 Update 3) supports __has_include.
|
||||
#ifdef __has_include
|
||||
#define GTEST_INTERNAL_HAS_INCLUDE __has_include
|
||||
#else
|
||||
#define GTEST_INTERNAL_HAS_INCLUDE(...) 0
|
||||
#endif
|
||||
|
||||
// Detect C++ feature test macros as gracefully as possible.
|
||||
// MSVC >= 19.15, Clang >= 3.4.1, and GCC >= 4.1.2 support feature test macros.
|
||||
#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L && \
|
||||
(!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<version>))
|
||||
#include <version> // C++20 and later
|
||||
#elif (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<ciso646>))
|
||||
#include <ciso646> // Pre-C++20
|
||||
#endif
|
||||
|
||||
#include <ctype.h> // for isspace, etc
|
||||
#include <stddef.h> // for ptrdiff_t
|
||||
#include <stdio.h>
|
||||
@@ -320,7 +336,8 @@
|
||||
#define GTEST_HAS_NOTIFICATION_ 0
|
||||
#endif
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
#define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
|
||||
#include "absl/flags/declare.h"
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/reflection.h"
|
||||
@@ -590,7 +607,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \
|
||||
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \
|
||||
defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_HAIKU) || \
|
||||
defined(GTEST_OS_GNU_HURD))
|
||||
defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_SOLARIS) || \
|
||||
defined(GTEST_OS_AIX) || defined(GTEST_OS_ZOS))
|
||||
#define GTEST_HAS_PTHREAD 1
|
||||
#else
|
||||
#define GTEST_HAS_PTHREAD 0
|
||||
@@ -609,7 +627,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// Determines whether clone(2) is supported.
|
||||
// Usually it will only be available on Linux, excluding
|
||||
// Linux on the Itanium architecture.
|
||||
// Also see http://linux.die.net/man/2/clone.
|
||||
// Also see https://linux.die.net/man/2/clone.
|
||||
#ifndef GTEST_HAS_CLONE
|
||||
// The user didn't tell us, so we need to figure it out.
|
||||
|
||||
@@ -640,9 +658,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// platforms except known mobile / embedded ones. Also, if the port doesn't have
|
||||
// a file system, stream redirection is not supported.
|
||||
#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
|
||||
defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \
|
||||
defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) || \
|
||||
!GTEST_HAS_FILE_SYSTEM
|
||||
defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_WINDOWS_GAMES) || \
|
||||
defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
|
||||
defined(GTEST_OS_QURT) || !GTEST_HAS_FILE_SYSTEM
|
||||
#define GTEST_HAS_STREAM_REDIRECTION 0
|
||||
#else
|
||||
#define GTEST_HAS_STREAM_REDIRECTION 1
|
||||
@@ -652,7 +670,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// Determines whether to support death tests.
|
||||
// pops up a dialog window that cannot be suppressed programmatically.
|
||||
#if (defined(GTEST_OS_LINUX) || defined(GTEST_OS_CYGWIN) || \
|
||||
defined(GTEST_OS_SOLARIS) || \
|
||||
defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_ZOS) || \
|
||||
(defined(GTEST_OS_MAC) && !defined(GTEST_OS_IOS)) || \
|
||||
(defined(GTEST_OS_WINDOWS_DESKTOP) && _MSC_VER) || \
|
||||
defined(GTEST_OS_WINDOWS_MINGW) || defined(GTEST_OS_AIX) || \
|
||||
@@ -730,6 +748,20 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#define GTEST_HAVE_ATTRIBUTE_(x) 0
|
||||
#endif
|
||||
|
||||
// GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE
|
||||
//
|
||||
// A function-like feature checking macro that accepts C++11 style attributes.
|
||||
// It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6
|
||||
// (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't
|
||||
// find `__has_cpp_attribute`, will evaluate to 0.
|
||||
#if defined(__has_cpp_attribute)
|
||||
// NOTE: requiring __cplusplus above should not be necessary, but
|
||||
// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
|
||||
#define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||
#else
|
||||
#define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
// GTEST_HAVE_FEATURE_
|
||||
//
|
||||
// A function-like feature checking macro that is a wrapper around
|
||||
@@ -741,14 +773,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#endif
|
||||
|
||||
// Use this annotation after a variable or parameter declaration to tell the
|
||||
// compiler the variable/parameter does not have to be used.
|
||||
// compiler the variable/parameter may be used.
|
||||
// Example:
|
||||
//
|
||||
// GTEST_ATTRIBUTE_UNUSED_ int foo = bar();
|
||||
#if GTEST_HAVE_ATTRIBUTE_(unused)
|
||||
#define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused))
|
||||
// GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED int foo = bar();
|
||||
//
|
||||
// This can be removed once we only support only C++17 or newer and
|
||||
// [[maybe_unused]] is available on all supported platforms.
|
||||
#if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(maybe_unused)
|
||||
#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
|
||||
#elif GTEST_HAVE_ATTRIBUTE_(unused)
|
||||
// This is inferior to [[maybe_unused]] as it can produce a
|
||||
// -Wused-but-marked-unused warning on optionally used symbols, but it is all we
|
||||
// have.
|
||||
#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define GTEST_ATTRIBUTE_UNUSED_
|
||||
#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED
|
||||
#endif
|
||||
|
||||
// Use this annotation before a function that takes a printf format string.
|
||||
@@ -827,9 +867,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#ifndef GTEST_API_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
#if defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY
|
||||
#define GTEST_API_ __declspec(dllimport)
|
||||
#elif GTEST_CREATE_SHARED_LIBRARY
|
||||
#elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY
|
||||
#define GTEST_API_ __declspec(dllexport)
|
||||
#endif
|
||||
#elif GTEST_HAVE_ATTRIBUTE_(visibility)
|
||||
@@ -1987,7 +2027,9 @@ inline std::string StripTrailingSpaces(std::string str) {
|
||||
namespace posix {
|
||||
|
||||
// File system porting.
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
// Note: Not every I/O-related function is related to file systems, so don't
|
||||
// just disable all of them here. For example, fileno() and isatty(), etc. must
|
||||
// always be available in order to detect if a pipe points to a terminal.
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
typedef struct _stat StatStruct;
|
||||
@@ -1998,27 +2040,32 @@ inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
|
||||
// time and thus not defined there.
|
||||
#else
|
||||
inline int FileNo(FILE* file) { return _fileno(file); }
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
|
||||
inline int RmDir(const char* dir) { return _rmdir(dir); }
|
||||
inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; }
|
||||
#endif
|
||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
#elif defined(GTEST_OS_ESP8266)
|
||||
typedef struct stat StatStruct;
|
||||
|
||||
inline int FileNo(FILE* file) { return fileno(file); }
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
inline int Stat(const char* path, StatStruct* buf) {
|
||||
// stat function not implemented on ESP8266
|
||||
return 0;
|
||||
}
|
||||
inline int RmDir(const char* dir) { return rmdir(dir); }
|
||||
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
typedef struct stat StatStruct;
|
||||
|
||||
inline int FileNo(FILE* file) { return fileno(file); }
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
|
||||
#ifdef GTEST_OS_QURT
|
||||
// QuRT doesn't support any directory functions, including rmdir
|
||||
@@ -2027,9 +2074,9 @@ inline int RmDir(const char*) { return 0; }
|
||||
inline int RmDir(const char* dir) { return rmdir(dir); }
|
||||
#endif
|
||||
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
||||
#endif
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
|
||||
// Other functions with a different name on Windows.
|
||||
|
||||
@@ -2082,8 +2129,9 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
// defined there.
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_ESP8266) && \
|
||||
!defined(GTEST_OS_XTENSA) && !defined(GTEST_OS_QURT)
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \
|
||||
!defined(GTEST_OS_ESP8266) && !defined(GTEST_OS_XTENSA) && \
|
||||
!defined(GTEST_OS_QURT)
|
||||
inline int ChDir(const char* dir) { return chdir(dir); }
|
||||
#endif
|
||||
inline FILE* FOpen(const char* path, const char* mode) {
|
||||
@@ -2227,7 +2275,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
#endif // !defined(GTEST_FLAG)
|
||||
|
||||
// Pick a command line flags implementation.
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
@@ -2252,7 +2300,8 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
(void)(::absl::SetFlag(>EST_FLAG(name), value))
|
||||
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
|
||||
|
||||
#else // GTEST_HAS_ABSL
|
||||
#undef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
#else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
@@ -2294,7 +2343,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
|
||||
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
|
||||
|
||||
#endif // GTEST_HAS_ABSL
|
||||
#endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Thread annotations
|
||||
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
|
||||
@@ -2349,9 +2398,9 @@ using Any = ::absl::any;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
|
||||
(!defined(_MSC_VER) || GTEST_HAS_RTTI)
|
||||
#if defined(__cpp_lib_any) || (GTEST_INTERNAL_HAS_INCLUDE(<any>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
|
||||
(!defined(_MSC_VER) || GTEST_HAS_RTTI))
|
||||
// Otherwise for C++17 and higher use std::any for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_ANY 1
|
||||
@@ -2363,8 +2412,7 @@ using Any = ::std::any;
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::any is not
|
||||
// supported.
|
||||
#endif // __has_include(<any>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // __cpp_lib_any
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_ANY
|
||||
@@ -2384,8 +2432,8 @@ inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#if defined(__cpp_lib_optional) || (GTEST_INTERNAL_HAS_INCLUDE(<optional>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
|
||||
// Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_OPTIONAL 1
|
||||
@@ -2399,14 +2447,22 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::optional is not
|
||||
// supported.
|
||||
#endif // __has_include(<optional>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // __cpp_lib_optional
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_OPTIONAL
|
||||
#define GTEST_INTERNAL_HAS_OPTIONAL 0
|
||||
#endif
|
||||
|
||||
#if defined(__cpp_lib_span) || (GTEST_INTERNAL_HAS_INCLUDE(<span>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L)
|
||||
#define GTEST_INTERNAL_HAS_STD_SPAN 1
|
||||
#endif // __cpp_lib_span
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_STD_SPAN
|
||||
#define GTEST_INTERNAL_HAS_STD_SPAN 0
|
||||
#endif
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
// Always use absl::string_view for Matcher<> specializations if googletest
|
||||
// is built with absl support.
|
||||
@@ -2418,8 +2474,9 @@ using StringView = ::absl::string_view;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#if defined(__cpp_lib_string_view) || \
|
||||
(GTEST_INTERNAL_HAS_INCLUDE(<string_view>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
|
||||
// Otherwise for C++17 and higher use std::string_view for Matcher<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_STRING_VIEW 1
|
||||
@@ -2431,9 +2488,7 @@ using StringView = ::std::string_view;
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::string_view is not
|
||||
// supported.
|
||||
#endif // __has_include(<string_view>) && GTEST_INTERNAL_CPLUSPLUS_LANG >=
|
||||
// 201703L
|
||||
#endif // __has_include
|
||||
#endif // __cpp_lib_string_view
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_STRING_VIEW
|
||||
@@ -2452,8 +2507,8 @@ using Variant = ::absl::variant<T...>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
#else
|
||||
#ifdef __has_include
|
||||
#if __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#if defined(__cpp_lib_variant) || (GTEST_INTERNAL_HAS_INCLUDE(<variant>) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
|
||||
// Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
|
||||
// specializations.
|
||||
#define GTEST_INTERNAL_HAS_VARIANT 1
|
||||
@@ -2465,16 +2520,16 @@ using Variant = ::std::variant<T...>;
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
// The case where absl is configured NOT to alias std::variant is not supported.
|
||||
#endif // __has_include(<variant>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
||||
#endif // __has_include
|
||||
#endif // __cpp_lib_variant
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
#ifndef GTEST_INTERNAL_HAS_VARIANT
|
||||
#define GTEST_INTERNAL_HAS_VARIANT 0
|
||||
#endif
|
||||
|
||||
#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
|
||||
#if (defined(__cpp_constexpr) && !defined(__cpp_inline_variables)) || \
|
||||
(defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
|
||||
GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L)
|
||||
#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
|
||||
// Strip redundant spaces in typename to match MSVC
|
||||
// For example, std::pair<int, bool> -> std::pair<int,bool>
|
||||
static const char to_search[] = ", ";
|
||||
static const char replace_str[] = ",";
|
||||
const char replace_char = ',';
|
||||
size_t pos = 0;
|
||||
while (true) {
|
||||
// Get the next occurrence from the current position
|
||||
@@ -80,8 +80,8 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
|
||||
break;
|
||||
}
|
||||
// Replace this occurrence of substring
|
||||
s.replace(pos, strlen(to_search), replace_str);
|
||||
pos += strlen(replace_str);
|
||||
s.replace(pos, strlen(to_search), 1, replace_char);
|
||||
++pos;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "gtest/gtest-death-test.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@@ -115,7 +117,7 @@ GTEST_DEFINE_string_(
|
||||
GTEST_DEFINE_bool_(
|
||||
death_test_use_fork,
|
||||
testing::internal::BoolFromGTestEnv("death_test_use_fork", false),
|
||||
"Instructs to use fork()/_exit() instead of clone() in death tests. "
|
||||
"Instructs to use fork()/_Exit() instead of clone() in death tests. "
|
||||
"Ignored and always uses fork() on POSIX systems where clone() is not "
|
||||
"implemented. Useful when running under valgrind or similar tools if "
|
||||
"those do not support clone(). Valgrind 3.3.1 will just fail if "
|
||||
@@ -299,7 +301,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
|
||||
fputc(kDeathTestInternalError, parent);
|
||||
fprintf(parent, "%s", message.c_str());
|
||||
fflush(parent);
|
||||
_exit(1);
|
||||
_Exit(1);
|
||||
} else {
|
||||
fprintf(stderr, "%s", message.c_str());
|
||||
fflush(stderr);
|
||||
@@ -511,7 +513,7 @@ std::string DeathTestImpl::GetErrorLogs() { return GetCapturedStderr(); }
|
||||
// Signals that the death test code which should have exited, didn't.
|
||||
// Should be called only in a death test child process.
|
||||
// Writes a status byte to the child's status file descriptor, then
|
||||
// calls _exit(1).
|
||||
// calls _Exit(1).
|
||||
void DeathTestImpl::Abort(AbortReason reason) {
|
||||
// The parent process considers the death test to be a failure if
|
||||
// it finds any data in our pipe. So, here we write a single flag byte
|
||||
@@ -523,13 +525,13 @@ void DeathTestImpl::Abort(AbortReason reason) {
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
|
||||
// We are leaking the descriptor here because on some platforms (i.e.,
|
||||
// when built as Windows DLL), destructors of global objects will still
|
||||
// run after calling _exit(). On such systems, write_fd_ will be
|
||||
// run after calling _Exit(). On such systems, write_fd_ will be
|
||||
// indirectly closed from the destructor of UnitTestImpl, causing double
|
||||
// close if it is also closed here. On debug configurations, double close
|
||||
// may assert. As there are no in-process buffers to flush here, we are
|
||||
// relying on the OS to close the descriptor after the process terminates
|
||||
// when the destructors are not run.
|
||||
_exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
|
||||
_Exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
|
||||
}
|
||||
|
||||
// Returns an indented copy of stderr output for a death test.
|
||||
@@ -628,13 +630,13 @@ bool DeathTestImpl::Passed(bool status_ok) {
|
||||
#ifndef GTEST_OS_WINDOWS
|
||||
// Note: The return value points into args, so the return value's lifetime is
|
||||
// bound to that of args.
|
||||
static std::unique_ptr<char*[]> CreateArgvFromArgs(
|
||||
std::vector<std::string>& args) {
|
||||
auto result = std::make_unique<char*[]>(args.size() + 1);
|
||||
for (size_t i = 0; i < args.size(); ++i) {
|
||||
result[i] = &args[i][0];
|
||||
static std::vector<char*> CreateArgvFromArgs(std::vector<std::string>& args) {
|
||||
std::vector<char*> result;
|
||||
result.reserve(args.size() + 1);
|
||||
for (auto& arg : args) {
|
||||
result.push_back(&arg[0]);
|
||||
}
|
||||
result[args.size()] = nullptr; // extra null terminator
|
||||
result.push_back(nullptr); // Extra null terminator.
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
@@ -783,7 +785,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
|
||||
StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +
|
||||
// size_t has the same width as pointers on both 32-bit and 64-bit
|
||||
// Windows platforms.
|
||||
// See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
|
||||
// See https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
|
||||
"|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) + "|" +
|
||||
StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));
|
||||
|
||||
@@ -1034,8 +1036,8 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
|
||||
// "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
|
||||
// Launching processes is a privileged operation in Fuchsia, and the
|
||||
// declaration indicates that the ability is required for the component.
|
||||
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args);
|
||||
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(),
|
||||
std::vector<char*> argv = CreateArgvFromArgs(args);
|
||||
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.data(),
|
||||
nullptr, 2, spawn_actions,
|
||||
child_process_.reset_and_get_address(), nullptr);
|
||||
GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
|
||||
@@ -1333,7 +1335,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
|
||||
#endif // GTEST_HAS_CLONE
|
||||
|
||||
if (use_fork && (child_pid = fork()) == 0) {
|
||||
_exit(ExecDeathTestChildMain(&args));
|
||||
_Exit(ExecDeathTestChildMain(&args));
|
||||
}
|
||||
#endif // GTEST_OS_QNX
|
||||
#ifdef GTEST_OS_LINUX
|
||||
@@ -1386,8 +1388,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
|
||||
// is necessary.
|
||||
FlushInfoLog();
|
||||
|
||||
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args);
|
||||
const pid_t child_pid = ExecDeathTestSpawnChild(argv.get(), pipe_fd[0]);
|
||||
std::vector<char*> argv = CreateArgvFromArgs(args);
|
||||
const pid_t child_pid = ExecDeathTestSpawnChild(argv.data(), pipe_fd[0]);
|
||||
GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
|
||||
set_child_pid(child_pid);
|
||||
set_read_fd(pipe_fd[0]);
|
||||
|
||||
@@ -336,7 +336,7 @@ bool FilePath::CreateDirectoriesRecursively() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pathname_.length() == 0 || this->DirectoryExists()) {
|
||||
if (pathname_.empty() || this->DirectoryExists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
@@ -312,7 +313,7 @@ void ShuffleRange(internal::Random* random, int begin, int end,
|
||||
<< begin << ", " << size << "].";
|
||||
|
||||
// Fisher-Yates shuffle, from
|
||||
// http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
|
||||
// https://en.wikipedia.org/wiki/Fisher-Yates_shuffle
|
||||
for (int range_width = end - begin; range_width >= 2; range_width--) {
|
||||
const int last_in_range = begin + range_width - 1;
|
||||
const int selected =
|
||||
@@ -649,13 +650,15 @@ class GTEST_API_ UnitTestImpl {
|
||||
// this is not a typed or a type-parameterized test.
|
||||
// set_up_tc: pointer to the function that sets up the test suite
|
||||
// tear_down_tc: pointer to the function that tears down the test suite
|
||||
TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
|
||||
TestSuite* GetTestSuite(const std::string& test_suite_name,
|
||||
const char* type_param,
|
||||
internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc);
|
||||
|
||||
// Legacy API is deprecated but still available
|
||||
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
TestCase* GetTestCase(const char* test_case_name, const char* type_param,
|
||||
TestCase* GetTestCase(const std::string& test_case_name,
|
||||
const char* type_param,
|
||||
internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc) {
|
||||
return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);
|
||||
@@ -681,13 +684,13 @@ class GTEST_API_ UnitTestImpl {
|
||||
// AddTestInfo(), which is called to register a TEST or TEST_F
|
||||
// before main() is reached.
|
||||
if (original_working_dir_.IsEmpty()) {
|
||||
original_working_dir_.Set(FilePath::GetCurrentDir());
|
||||
original_working_dir_ = FilePath::GetCurrentDir();
|
||||
GTEST_CHECK_(!original_working_dir_.IsEmpty())
|
||||
<< "Failed to get the current working directory.";
|
||||
}
|
||||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
|
||||
GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
|
||||
GetTestSuite(test_info->test_suite_name_, test_info->type_param(),
|
||||
set_up_tc, tear_down_tc)
|
||||
->AddTestInfo(test_info);
|
||||
}
|
||||
@@ -709,18 +712,6 @@ class GTEST_API_ UnitTestImpl {
|
||||
return type_parameterized_test_registry_;
|
||||
}
|
||||
|
||||
// Sets the TestSuite object for the test that's currently running.
|
||||
void set_current_test_suite(TestSuite* a_current_test_suite) {
|
||||
current_test_suite_ = a_current_test_suite;
|
||||
}
|
||||
|
||||
// Sets the TestInfo object for the test that's currently running. If
|
||||
// current_test_info is NULL, the assertion results will be stored in
|
||||
// ad_hoc_test_result_.
|
||||
void set_current_test_info(TestInfo* a_current_test_info) {
|
||||
current_test_info_ = a_current_test_info;
|
||||
}
|
||||
|
||||
// Registers all parameterized tests defined using TEST_P and
|
||||
// INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter
|
||||
// combination. This method can be called more then once; it has guards
|
||||
@@ -835,12 +826,30 @@ class GTEST_API_ UnitTestImpl {
|
||||
bool catch_exceptions() const { return catch_exceptions_; }
|
||||
|
||||
private:
|
||||
struct CompareTestSuitesByPointer {
|
||||
bool operator()(const TestSuite* lhs, const TestSuite* rhs) const {
|
||||
return lhs->name_ < rhs->name_;
|
||||
}
|
||||
};
|
||||
|
||||
friend class ::testing::UnitTest;
|
||||
|
||||
// Used by UnitTest::Run() to capture the state of
|
||||
// GTEST_FLAG(catch_exceptions) at the moment it starts.
|
||||
void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
|
||||
|
||||
// Sets the TestSuite object for the test that's currently running.
|
||||
void set_current_test_suite(TestSuite* a_current_test_suite) {
|
||||
current_test_suite_ = a_current_test_suite;
|
||||
}
|
||||
|
||||
// Sets the TestInfo object for the test that's currently running. If
|
||||
// current_test_info is NULL, the assertion results will be stored in
|
||||
// ad_hoc_test_result_.
|
||||
void set_current_test_info(TestInfo* a_current_test_info) {
|
||||
current_test_info_ = a_current_test_info;
|
||||
}
|
||||
|
||||
// The UnitTest object that owns this implementation object.
|
||||
UnitTest* const parent_;
|
||||
|
||||
@@ -873,6 +882,9 @@ class GTEST_API_ UnitTestImpl {
|
||||
// elements in the vector.
|
||||
std::vector<TestSuite*> test_suites_;
|
||||
|
||||
// The set of TestSuites by name.
|
||||
std::unordered_map<std::string, TestSuite*> test_suites_by_name_;
|
||||
|
||||
// Provides a level of indirection for the test suite list to allow
|
||||
// easy shuffling and restoring the test suite order. The i-th
|
||||
// element of this vector is the index of the i-th test suite in the
|
||||
|
||||
98
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
98
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
@@ -158,13 +158,13 @@ size_t GetThreadCount() {
|
||||
// we cannot detect it.
|
||||
size_t GetThreadCount() {
|
||||
int mib[] = {
|
||||
CTL_KERN,
|
||||
KERN_PROC,
|
||||
KERN_PROC_PID,
|
||||
getpid(),
|
||||
CTL_KERN,
|
||||
KERN_PROC,
|
||||
KERN_PROC_PID,
|
||||
getpid(),
|
||||
#ifdef GTEST_OS_NETBSD
|
||||
sizeof(struct kinfo_proc),
|
||||
1,
|
||||
sizeof(struct kinfo_proc),
|
||||
1,
|
||||
#endif
|
||||
};
|
||||
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||
@@ -587,9 +587,11 @@ class ThreadLocalRegistryImpl {
|
||||
// thread's ID.
|
||||
typedef std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals;
|
||||
|
||||
// Holds the thread id and thread handle that we pass from
|
||||
// StartWatcherThreadFor to WatcherThreadFunc.
|
||||
typedef std::pair<DWORD, HANDLE> ThreadIdAndHandle;
|
||||
struct WatcherThreadParams {
|
||||
DWORD thread_id;
|
||||
HANDLE handle;
|
||||
Notification has_initialized;
|
||||
};
|
||||
|
||||
static void StartWatcherThreadFor(DWORD thread_id) {
|
||||
// The returned handle will be kept in thread_map and closed by
|
||||
@@ -597,15 +599,20 @@ class ThreadLocalRegistryImpl {
|
||||
HANDLE thread =
|
||||
::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, FALSE, thread_id);
|
||||
GTEST_CHECK_(thread != nullptr);
|
||||
|
||||
WatcherThreadParams* watcher_thread_params = new WatcherThreadParams;
|
||||
watcher_thread_params->thread_id = thread_id;
|
||||
watcher_thread_params->handle = thread;
|
||||
|
||||
// We need to pass a valid thread ID pointer into CreateThread for it
|
||||
// to work correctly under Win98.
|
||||
DWORD watcher_thread_id;
|
||||
HANDLE watcher_thread = ::CreateThread(
|
||||
nullptr, // Default security.
|
||||
0, // Default stack size
|
||||
&ThreadLocalRegistryImpl::WatcherThreadFunc,
|
||||
reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),
|
||||
CREATE_SUSPENDED, &watcher_thread_id);
|
||||
HANDLE watcher_thread =
|
||||
::CreateThread(nullptr, // Default security.
|
||||
0, // Default stack size
|
||||
&ThreadLocalRegistryImpl::WatcherThreadFunc,
|
||||
reinterpret_cast<LPVOID>(watcher_thread_params),
|
||||
CREATE_SUSPENDED, &watcher_thread_id);
|
||||
GTEST_CHECK_(watcher_thread != nullptr)
|
||||
<< "CreateThread failed with error " << ::GetLastError() << ".";
|
||||
// Give the watcher thread the same priority as ours to avoid being
|
||||
@@ -614,17 +621,25 @@ class ThreadLocalRegistryImpl {
|
||||
::GetThreadPriority(::GetCurrentThread()));
|
||||
::ResumeThread(watcher_thread);
|
||||
::CloseHandle(watcher_thread);
|
||||
|
||||
// Wait for the watcher thread to start to avoid race conditions.
|
||||
// One specific race condition that can happen is that we have returned
|
||||
// from main and have started to tear down, the newly spawned watcher
|
||||
// thread may access already-freed variables, like global shared_ptrs.
|
||||
watcher_thread_params->has_initialized.WaitForNotification();
|
||||
}
|
||||
|
||||
// Monitors exit from a given thread and notifies those
|
||||
// ThreadIdToThreadLocals about thread termination.
|
||||
static DWORD WINAPI WatcherThreadFunc(LPVOID param) {
|
||||
const ThreadIdAndHandle* tah =
|
||||
reinterpret_cast<const ThreadIdAndHandle*>(param);
|
||||
GTEST_CHECK_(::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);
|
||||
OnThreadExit(tah->first);
|
||||
::CloseHandle(tah->second);
|
||||
delete tah;
|
||||
WatcherThreadParams* watcher_thread_params =
|
||||
reinterpret_cast<WatcherThreadParams*>(param);
|
||||
watcher_thread_params->has_initialized.Notify();
|
||||
GTEST_CHECK_(::WaitForSingleObject(watcher_thread_params->handle,
|
||||
INFINITE) == WAIT_OBJECT_0);
|
||||
OnThreadExit(watcher_thread_params->thread_id);
|
||||
::CloseHandle(watcher_thread_params->handle);
|
||||
delete watcher_thread_params;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -697,13 +712,24 @@ bool RE::PartialMatch(const char* str, const RE& re) {
|
||||
void RE::Init(const char* regex) {
|
||||
pattern_ = regex;
|
||||
|
||||
// NetBSD (and Android, which takes its regex implemntation from NetBSD) does
|
||||
// not include the GNU regex extensions (such as Perl style character classes
|
||||
// like \w) in REG_EXTENDED. REG_EXTENDED is only specified to include the
|
||||
// [[:alpha:]] style character classes. Enable REG_GNU wherever it is defined
|
||||
// so users can use those extensions.
|
||||
#if defined(REG_GNU)
|
||||
constexpr int reg_flags = REG_EXTENDED | REG_GNU;
|
||||
#else
|
||||
constexpr int reg_flags = REG_EXTENDED;
|
||||
#endif
|
||||
|
||||
// Reserves enough bytes to hold the regular expression used for a
|
||||
// full match.
|
||||
const size_t full_regex_len = strlen(regex) + 10;
|
||||
char* const full_pattern = new char[full_regex_len];
|
||||
|
||||
snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
|
||||
is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
|
||||
is_valid_ = regcomp(&full_regex_, full_pattern, reg_flags) == 0;
|
||||
// We want to call regcomp(&partial_regex_, ...) even if the
|
||||
// previous expression returns false. Otherwise partial_regex_ may
|
||||
// not be properly initialized can may cause trouble when it's
|
||||
@@ -714,7 +740,7 @@ void RE::Init(const char* regex) {
|
||||
// regex. We change it to an equivalent form "()" to be safe.
|
||||
if (is_valid_) {
|
||||
const char* const partial_regex = (*regex == '\0') ? "()" : regex;
|
||||
is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
|
||||
is_valid_ = regcomp(&partial_regex_, partial_regex, reg_flags) == 0;
|
||||
}
|
||||
EXPECT_TRUE(is_valid_)
|
||||
<< "Regular expression \"" << regex
|
||||
@@ -1022,11 +1048,21 @@ GTestLog::~GTestLog() {
|
||||
}
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STREAM_REDIRECTION
|
||||
|
||||
// Disable Microsoft deprecation warnings for POSIX functions called from
|
||||
// this class (creat, dup, dup2, and close)
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
|
||||
#if GTEST_HAS_STREAM_REDIRECTION
|
||||
namespace {
|
||||
|
||||
#if defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_IOS)
|
||||
bool EndsWithPathSeparator(const std::string& path) {
|
||||
return !path.empty() && path.back() == GTEST_PATH_SEP_[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
// Object that captures an output stream (stdout/stderr).
|
||||
class CapturedStream {
|
||||
@@ -1064,7 +1100,13 @@ class CapturedStream {
|
||||
// The location /data/local/tmp is directly accessible from native code.
|
||||
// '/sdcard' and other variants cannot be relied on, as they are not
|
||||
// guaranteed to be mounted, or may have a delay in mounting.
|
||||
name_template = "/data/local/tmp/";
|
||||
//
|
||||
// However, prefer using the TMPDIR environment variable if set, as newer
|
||||
// devices may have /data/local/tmp read-only.
|
||||
name_template = TempDir();
|
||||
if (!EndsWithPathSeparator(name_template))
|
||||
name_template.push_back(GTEST_PATH_SEP_[0]);
|
||||
|
||||
#elif defined(GTEST_OS_IOS)
|
||||
char user_temp_dir[PATH_MAX + 1];
|
||||
|
||||
@@ -1084,7 +1126,7 @@ class CapturedStream {
|
||||
::confstr(_CS_DARWIN_USER_TEMP_DIR, user_temp_dir, sizeof(user_temp_dir));
|
||||
|
||||
name_template = user_temp_dir;
|
||||
if (name_template.back() != GTEST_PATH_SEP_[0])
|
||||
if (!EndsWithPathSeparator(name_template))
|
||||
name_template.push_back(GTEST_PATH_SEP_[0]);
|
||||
#else
|
||||
name_template = "/tmp/";
|
||||
@@ -1306,8 +1348,8 @@ bool ParseInt32(const Message& src_text, const char* str, int32_t* value) {
|
||||
) {
|
||||
Message msg;
|
||||
msg << "WARNING: " << src_text
|
||||
<< " is expected to be a 32-bit integer, but actually"
|
||||
<< " has value " << str << ", which overflows.\n";
|
||||
<< " is expected to be a 32-bit integer, but actually" << " has value "
|
||||
<< str << ", which overflows.\n";
|
||||
printf("%s", msg.GetString().c_str());
|
||||
fflush(stdout);
|
||||
return false;
|
||||
|
||||
294
3rdparty/googletest/googletest/src/gtest.cc
vendored
294
3rdparty/googletest/googletest/src/gtest.cc
vendored
@@ -43,6 +43,7 @@
|
||||
#include <algorithm>
|
||||
#include <chrono> // NOLINT
|
||||
#include <cmath>
|
||||
#include <csignal> // NOLINT: raise(3) is used on some platforms
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -161,6 +162,10 @@
|
||||
#define GTEST_HAS_BUILTIN(x) 0
|
||||
#endif // defined(__has_builtin)
|
||||
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
#define GTEST_HAS_ABSL_FLAGS
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
|
||||
using internal::CountIf;
|
||||
@@ -374,7 +379,7 @@ GTEST_DEFINE_string_(
|
||||
testing::internal::StringFromGTestEnv("stream_result_to", ""),
|
||||
"This flag specifies the host name and the port number on which to stream "
|
||||
"test results. Example: \"localhost:555\". The flag is effective only on "
|
||||
"Linux.");
|
||||
"Linux and macOS.");
|
||||
|
||||
GTEST_DEFINE_bool_(
|
||||
throw_on_failure,
|
||||
@@ -446,6 +451,19 @@ static bool ShouldRunTestSuite(const TestSuite* test_suite) {
|
||||
return test_suite->should_run();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns true if test part results of type `type` should include a stack
|
||||
// trace.
|
||||
bool ShouldEmitStackTraceForResultType(TestPartResult::Type type) {
|
||||
// Suppress emission of the stack trace for SUCCEED() since it likely never
|
||||
// requires investigation, and GTEST_SKIP() since skipping is an intentional
|
||||
// act by the developer rather than a failure requiring investigation.
|
||||
return type != TestPartResult::kSuccess && type != TestPartResult::kSkip;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// AssertHelper constructor.
|
||||
AssertHelper::AssertHelper(TestPartResult::Type type, const char* file,
|
||||
int line, const char* message)
|
||||
@@ -458,7 +476,9 @@ void AssertHelper::operator=(const Message& message) const {
|
||||
UnitTest::GetInstance()->AddTestPartResult(
|
||||
data_->type, data_->file, data_->line,
|
||||
AppendUserMessage(data_->message, message),
|
||||
UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
|
||||
ShouldEmitStackTraceForResultType(data_->type)
|
||||
? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
|
||||
: ""
|
||||
// Skips the stack frame for this function itself.
|
||||
); // NOLINT
|
||||
}
|
||||
@@ -516,7 +536,8 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
|
||||
if (ignored.find(name) != ignored.end()) return;
|
||||
|
||||
const char kMissingInstantiation[] = //
|
||||
" is defined via TEST_P, but never instantiated. None of the test cases "
|
||||
" is defined via TEST_P, but never instantiated. None of the test "
|
||||
"cases "
|
||||
"will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only "
|
||||
"ones provided expand to nothing."
|
||||
"\n\n"
|
||||
@@ -557,7 +578,7 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
|
||||
void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
|
||||
CodeLocation code_location) {
|
||||
GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(
|
||||
test_suite_name, code_location);
|
||||
test_suite_name, std::move(code_location));
|
||||
}
|
||||
|
||||
void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
|
||||
@@ -568,7 +589,7 @@ void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
|
||||
void TypeParameterizedTestSuiteRegistry::RegisterTestSuite(
|
||||
const char* test_suite_name, CodeLocation code_location) {
|
||||
suites_.emplace(std::string(test_suite_name),
|
||||
TypeParameterizedTestSuiteInfo(code_location));
|
||||
TypeParameterizedTestSuiteInfo(std::move(code_location)));
|
||||
}
|
||||
|
||||
void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
|
||||
@@ -595,10 +616,12 @@ void TypeParameterizedTestSuiteRegistry::CheckForInstantiations() {
|
||||
"\n\n"
|
||||
"Ideally, TYPED_TEST_P definitions should only ever be included as "
|
||||
"part of binaries that intend to use them. (As opposed to, for "
|
||||
"example, being placed in a library that may be linked in to get other "
|
||||
"example, being placed in a library that may be linked in to get "
|
||||
"other "
|
||||
"utilities.)"
|
||||
"\n\n"
|
||||
"To suppress this error for this test suite, insert the following line "
|
||||
"To suppress this error for this test suite, insert the following "
|
||||
"line "
|
||||
"(in a non-header) in the namespace it is defined in:"
|
||||
"\n\n"
|
||||
"GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" +
|
||||
@@ -638,11 +661,14 @@ static ::std::vector<std::string> g_argvs;
|
||||
FilePath GetCurrentExecutableName() {
|
||||
FilePath result;
|
||||
|
||||
auto args = GetArgvs();
|
||||
if (!args.empty()) {
|
||||
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_OS2)
|
||||
result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe"));
|
||||
result.Set(FilePath(args[0]).RemoveExtension("exe"));
|
||||
#else
|
||||
result.Set(FilePath(GetArgvs()[0]));
|
||||
result.Set(FilePath(args[0]));
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
}
|
||||
|
||||
return result.RemoveDirectoryName();
|
||||
}
|
||||
@@ -778,7 +804,7 @@ class UnitTestFilter {
|
||||
// Returns true if and only if name matches at least one of the patterns in
|
||||
// the filter.
|
||||
bool MatchesName(const std::string& name) const {
|
||||
return exact_match_patterns_.count(name) > 0 ||
|
||||
return exact_match_patterns_.find(name) != exact_match_patterns_.end() ||
|
||||
std::any_of(glob_patterns_.begin(), glob_patterns_.end(),
|
||||
[&name](const std::string& pattern) {
|
||||
return PatternMatchesString(
|
||||
@@ -879,7 +905,7 @@ int UnitTestOptions::GTestProcessSEH(DWORD seh_code, const char* location) {
|
||||
// apparently).
|
||||
//
|
||||
// SEH exception code for C++ exceptions.
|
||||
// (see http://support.microsoft.com/kb/185294 for more information).
|
||||
// (see https://support.microsoft.com/kb/185294 for more information).
|
||||
const DWORD kCxxExceptionCode = 0xe06d7363;
|
||||
|
||||
if (!GTEST_FLAG_GET(catch_exceptions) || seh_code == kCxxExceptionCode ||
|
||||
@@ -2317,7 +2343,7 @@ static const char* const kReservedTestCaseAttributes[] = {
|
||||
"type_param", "value_param", "file", "line"};
|
||||
|
||||
// Use a slightly different set for allowed output to ensure existing tests can
|
||||
// still RecordProperty("result") or "RecordProperty(timestamp")
|
||||
// still RecordProperty("result") or RecordProperty("timestamp")
|
||||
static const char* const kReservedOutputTestCaseAttributes[] = {
|
||||
"classname", "name", "status", "time", "type_param",
|
||||
"value_param", "file", "line", "result", "timestamp"};
|
||||
@@ -2717,18 +2743,16 @@ bool Test::IsSkipped() {
|
||||
|
||||
// Constructs a TestInfo object. It assumes ownership of the test factory
|
||||
// object.
|
||||
TestInfo::TestInfo(const std::string& a_test_suite_name,
|
||||
const std::string& a_name, const char* a_type_param,
|
||||
const char* a_value_param,
|
||||
TestInfo::TestInfo(std::string a_test_suite_name, std::string a_name,
|
||||
const char* a_type_param, const char* a_value_param,
|
||||
internal::CodeLocation a_code_location,
|
||||
internal::TypeId fixture_class_id,
|
||||
internal::TestFactoryBase* factory)
|
||||
: test_suite_name_(a_test_suite_name),
|
||||
// begin()/end() is MSVC 17.3.3 ASAN crash workaround (GitHub issue #3997)
|
||||
name_(a_name.begin(), a_name.end()),
|
||||
: test_suite_name_(std::move(a_test_suite_name)),
|
||||
name_(std::move(a_name)),
|
||||
type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
|
||||
value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
|
||||
location_(a_code_location),
|
||||
location_(std::move(a_code_location)),
|
||||
fixture_class_id_(fixture_class_id),
|
||||
should_run_(false),
|
||||
is_disabled_(false),
|
||||
@@ -2761,19 +2785,19 @@ namespace internal {
|
||||
// The newly created TestInfo instance will assume
|
||||
// ownership of the factory object.
|
||||
TestInfo* MakeAndRegisterTestInfo(
|
||||
const char* test_suite_name, const char* name, const char* type_param,
|
||||
std::string test_suite_name, const char* name, const char* type_param,
|
||||
const char* value_param, CodeLocation code_location,
|
||||
TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
|
||||
TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {
|
||||
TestInfo* const test_info =
|
||||
new TestInfo(test_suite_name, name, type_param, value_param,
|
||||
code_location, fixture_class_id, factory);
|
||||
new TestInfo(std::move(test_suite_name), name, type_param, value_param,
|
||||
std::move(code_location), fixture_class_id, factory);
|
||||
GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
|
||||
return test_info;
|
||||
}
|
||||
|
||||
void ReportInvalidTestSuiteType(const char* test_suite_name,
|
||||
CodeLocation code_location) {
|
||||
const CodeLocation& code_location) {
|
||||
Message errors;
|
||||
errors
|
||||
<< "Attempted redefinition of test suite " << test_suite_name << ".\n"
|
||||
@@ -2813,14 +2837,13 @@ void TestInfo::Run() {
|
||||
}
|
||||
|
||||
// Tells UnitTest where to store test result.
|
||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||
impl->set_current_test_info(this);
|
||||
UnitTest::GetInstance()->set_current_test_info(this);
|
||||
|
||||
// Notifies the unit test event listeners that a test is about to start.
|
||||
repeater->OnTestStart(*this);
|
||||
result_.set_start_timestamp(internal::GetTimeInMillis());
|
||||
internal::Timer timer;
|
||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
UnitTest::GetInstance()->UponLeavingGTest();
|
||||
|
||||
// Creates the test object.
|
||||
Test* const test = internal::HandleExceptionsInMethodIfSupported(
|
||||
@@ -2838,7 +2861,7 @@ void TestInfo::Run() {
|
||||
|
||||
if (test != nullptr) {
|
||||
// Deletes the test object.
|
||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
UnitTest::GetInstance()->UponLeavingGTest();
|
||||
internal::HandleExceptionsInMethodIfSupported(
|
||||
test, &Test::DeleteSelf_, "the test fixture's destructor");
|
||||
}
|
||||
@@ -2850,15 +2873,14 @@ void TestInfo::Run() {
|
||||
|
||||
// Tells UnitTest to stop associating assertion results to this
|
||||
// test.
|
||||
impl->set_current_test_info(nullptr);
|
||||
UnitTest::GetInstance()->set_current_test_info(nullptr);
|
||||
}
|
||||
|
||||
// Skip and records a skipped test result for this object.
|
||||
void TestInfo::Skip() {
|
||||
if (!should_run_) return;
|
||||
|
||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||
impl->set_current_test_info(this);
|
||||
UnitTest::GetInstance()->set_current_test_info(this);
|
||||
|
||||
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
|
||||
|
||||
@@ -2867,12 +2889,13 @@ void TestInfo::Skip() {
|
||||
|
||||
const TestPartResult test_part_result =
|
||||
TestPartResult(TestPartResult::kSkip, this->file(), this->line(), "");
|
||||
impl->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(
|
||||
test_part_result);
|
||||
internal::GetUnitTestImpl()
|
||||
->GetTestPartResultReporterForCurrentThread()
|
||||
->ReportTestPartResult(test_part_result);
|
||||
|
||||
// Notifies the unit test event listener that a test has just finished.
|
||||
repeater->OnTestEnd(*this);
|
||||
impl->set_current_test_info(nullptr);
|
||||
UnitTest::GetInstance()->set_current_test_info(nullptr);
|
||||
}
|
||||
|
||||
// class TestSuite
|
||||
@@ -2926,7 +2949,7 @@ int TestSuite::total_test_count() const {
|
||||
// this is not a typed or a type-parameterized test suite.
|
||||
// set_up_tc: pointer to the function that sets up the test suite
|
||||
// tear_down_tc: pointer to the function that tears down the test suite
|
||||
TestSuite::TestSuite(const char* a_name, const char* a_type_param,
|
||||
TestSuite::TestSuite(const std::string& a_name, const char* a_type_param,
|
||||
internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc)
|
||||
: name_(a_name),
|
||||
@@ -2968,8 +2991,7 @@ void TestSuite::AddTestInfo(TestInfo* test_info) {
|
||||
void TestSuite::Run() {
|
||||
if (!should_run_) return;
|
||||
|
||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||
impl->set_current_test_suite(this);
|
||||
UnitTest::GetInstance()->set_current_test_suite(this);
|
||||
|
||||
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
|
||||
|
||||
@@ -2999,7 +3021,7 @@ void TestSuite::Run() {
|
||||
repeater->OnTestCaseStart(*this);
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
UnitTest::GetInstance()->UponLeavingGTest();
|
||||
internal::HandleExceptionsInMethodIfSupported(
|
||||
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
|
||||
|
||||
@@ -3024,7 +3046,7 @@ void TestSuite::Run() {
|
||||
}
|
||||
elapsed_time_ = timer.Elapsed();
|
||||
|
||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||
UnitTest::GetInstance()->UponLeavingGTest();
|
||||
internal::HandleExceptionsInMethodIfSupported(
|
||||
this, &TestSuite::RunTearDownTestSuite, "TearDownTestSuite()");
|
||||
|
||||
@@ -3035,15 +3057,14 @@ void TestSuite::Run() {
|
||||
repeater->OnTestCaseEnd(*this);
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
impl->set_current_test_suite(nullptr);
|
||||
UnitTest::GetInstance()->set_current_test_suite(nullptr);
|
||||
}
|
||||
|
||||
// Skips all tests under this TestSuite.
|
||||
void TestSuite::Skip() {
|
||||
if (!should_run_) return;
|
||||
|
||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||
impl->set_current_test_suite(this);
|
||||
UnitTest::GetInstance()->set_current_test_suite(this);
|
||||
|
||||
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
|
||||
|
||||
@@ -3065,7 +3086,7 @@ void TestSuite::Skip() {
|
||||
repeater->OnTestCaseEnd(*this);
|
||||
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
|
||||
impl->set_current_test_suite(nullptr);
|
||||
UnitTest::GetInstance()->set_current_test_suite(nullptr);
|
||||
}
|
||||
|
||||
// Clears the results of all tests in this test suite.
|
||||
@@ -3166,9 +3187,9 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
|
||||
}
|
||||
|
||||
// class PrettyUnitTestResultPrinter
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
|
||||
!defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
|
||||
!defined(GTEST_OS_WINDOWS_MINGW)
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
|
||||
!defined(GTEST_OS_WINDOWS_GAMES) && !defined(GTEST_OS_WINDOWS_PHONE) && \
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_MINGW)
|
||||
|
||||
// Returns the character attribute for the given color.
|
||||
static WORD GetColorAttribute(GTestColor color) {
|
||||
@@ -3228,7 +3249,8 @@ static const char* GetAnsiColorCode(GTestColor color) {
|
||||
case GTestColor::kYellow:
|
||||
return "3";
|
||||
default:
|
||||
return nullptr;
|
||||
assert(false);
|
||||
return "9";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3251,6 +3273,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
||||
term != nullptr && (String::CStringEquals(term, "xterm") ||
|
||||
String::CStringEquals(term, "xterm-color") ||
|
||||
String::CStringEquals(term, "xterm-kitty") ||
|
||||
String::CStringEquals(term, "alacritty") ||
|
||||
String::CStringEquals(term, "screen") ||
|
||||
String::CStringEquals(term, "tmux") ||
|
||||
String::CStringEquals(term, "rxvt-unicode") ||
|
||||
@@ -3281,11 +3304,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
va_start(args, fmt);
|
||||
|
||||
static const bool in_color_mode =
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
// We don't condition this on GTEST_HAS_FILE_SYSTEM because we still need
|
||||
// to be able to detect terminal I/O regardless.
|
||||
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
|
||||
#else
|
||||
false;
|
||||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
|
||||
const bool use_color = in_color_mode && (color != GTestColor::kDefault);
|
||||
|
||||
@@ -3295,9 +3316,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
|
||||
!defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
|
||||
!defined(GTEST_OS_WINDOWS_MINGW)
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
|
||||
!defined(GTEST_OS_WINDOWS_GAMES) && !defined(GTEST_OS_WINDOWS_PHONE) && \
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_MINGW)
|
||||
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
// Gets the current text color.
|
||||
@@ -4420,8 +4441,8 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
|
||||
Message attributes;
|
||||
for (int i = 0; i < result.test_property_count(); ++i) {
|
||||
const TestProperty& property = result.GetTestProperty(i);
|
||||
attributes << " " << property.key() << "="
|
||||
<< "\"" << EscapeXmlAttribute(property.value()) << "\"";
|
||||
attributes << " " << property.key() << "=" << "\""
|
||||
<< EscapeXmlAttribute(property.value()) << "\"";
|
||||
}
|
||||
return attributes.GetString();
|
||||
}
|
||||
@@ -4725,28 +4746,53 @@ void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
|
||||
const TestResult& result) {
|
||||
const std::string kIndent = Indent(10);
|
||||
|
||||
int failures = 0;
|
||||
for (int i = 0; i < result.total_part_count(); ++i) {
|
||||
const TestPartResult& part = result.GetTestPartResult(i);
|
||||
if (part.failed()) {
|
||||
*stream << ",\n";
|
||||
if (++failures == 1) {
|
||||
*stream << kIndent << "\""
|
||||
<< "failures"
|
||||
<< "\": [\n";
|
||||
{
|
||||
int failures = 0;
|
||||
for (int i = 0; i < result.total_part_count(); ++i) {
|
||||
const TestPartResult& part = result.GetTestPartResult(i);
|
||||
if (part.failed()) {
|
||||
*stream << ",\n";
|
||||
if (++failures == 1) {
|
||||
*stream << kIndent << "\"" << "failures" << "\": [\n";
|
||||
}
|
||||
const std::string location =
|
||||
internal::FormatCompilerIndependentFileLocation(part.file_name(),
|
||||
part.line_number());
|
||||
const std::string message =
|
||||
EscapeJson(location + "\n" + part.message());
|
||||
*stream << kIndent << " {\n"
|
||||
<< kIndent << " \"failure\": \"" << message << "\",\n"
|
||||
<< kIndent << " \"type\": \"\"\n"
|
||||
<< kIndent << " }";
|
||||
}
|
||||
const std::string location =
|
||||
internal::FormatCompilerIndependentFileLocation(part.file_name(),
|
||||
part.line_number());
|
||||
const std::string message = EscapeJson(location + "\n" + part.message());
|
||||
*stream << kIndent << " {\n"
|
||||
<< kIndent << " \"failure\": \"" << message << "\",\n"
|
||||
<< kIndent << " \"type\": \"\"\n"
|
||||
<< kIndent << " }";
|
||||
}
|
||||
|
||||
if (failures > 0) *stream << "\n" << kIndent << "]";
|
||||
}
|
||||
|
||||
{
|
||||
int skipped = 0;
|
||||
for (int i = 0; i < result.total_part_count(); ++i) {
|
||||
const TestPartResult& part = result.GetTestPartResult(i);
|
||||
if (part.skipped()) {
|
||||
*stream << ",\n";
|
||||
if (++skipped == 1) {
|
||||
*stream << kIndent << "\"" << "skipped" << "\": [\n";
|
||||
}
|
||||
const std::string location =
|
||||
internal::FormatCompilerIndependentFileLocation(part.file_name(),
|
||||
part.line_number());
|
||||
const std::string message =
|
||||
EscapeJson(location + "\n" + part.message());
|
||||
*stream << kIndent << " {\n"
|
||||
<< kIndent << " \"message\": \"" << message << "\"\n"
|
||||
<< kIndent << " }";
|
||||
}
|
||||
}
|
||||
|
||||
if (skipped > 0) *stream << "\n" << kIndent << "]";
|
||||
}
|
||||
|
||||
if (failures > 0) *stream << "\n" << kIndent << "]";
|
||||
*stream << "\n" << Indent(8) << "}";
|
||||
}
|
||||
|
||||
@@ -4883,8 +4929,8 @@ std::string JsonUnitTestResultPrinter::TestPropertiesAsJson(
|
||||
for (int i = 0; i < result.test_property_count(); ++i) {
|
||||
const TestProperty& property = result.GetTestProperty(i);
|
||||
attributes << ",\n"
|
||||
<< indent << "\"" << property.key() << "\": "
|
||||
<< "\"" << EscapeJson(property.value()) << "\"";
|
||||
<< indent << "\"" << property.key() << "\": " << "\""
|
||||
<< EscapeJson(property.value()) << "\"";
|
||||
}
|
||||
return attributes.GetString();
|
||||
}
|
||||
@@ -5282,6 +5328,22 @@ TestSuite* UnitTest::GetMutableTestSuite(int i) {
|
||||
return impl()->GetMutableSuiteCase(i);
|
||||
}
|
||||
|
||||
void UnitTest::UponLeavingGTest() {
|
||||
impl()->os_stack_trace_getter()->UponLeavingGTest();
|
||||
}
|
||||
|
||||
// Sets the TestSuite object for the test that's currently running.
|
||||
void UnitTest::set_current_test_suite(TestSuite* a_current_test_suite) {
|
||||
internal::MutexLock lock(&mutex_);
|
||||
impl_->set_current_test_suite(a_current_test_suite);
|
||||
}
|
||||
|
||||
// Sets the TestInfo object for the test that's currently running.
|
||||
void UnitTest::set_current_test_info(TestInfo* a_current_test_info) {
|
||||
internal::MutexLock lock(&mutex_);
|
||||
impl_->set_current_test_info(a_current_test_info);
|
||||
}
|
||||
|
||||
// Returns the list of event listeners that can be used to track events
|
||||
// inside Google Test.
|
||||
TestEventListeners& UnitTest::listeners() { return *impl()->listeners(); }
|
||||
@@ -5399,7 +5461,7 @@ void UnitTest::RecordProperty(const std::string& key,
|
||||
int UnitTest::Run() {
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
const bool in_death_test_child_process =
|
||||
GTEST_FLAG_GET(internal_run_death_test).length() > 0;
|
||||
!GTEST_FLAG_GET(internal_run_death_test).empty();
|
||||
|
||||
// Google Test implements this protocol for catching that a test
|
||||
// program exits before returning control to Google Test:
|
||||
@@ -5441,7 +5503,7 @@ int UnitTest::Run() {
|
||||
// about crashes - they are expected.
|
||||
if (impl()->catch_exceptions() || in_death_test_child_process) {
|
||||
#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
|
||||
!defined(GTEST_OS_WINDOWS_RT)
|
||||
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES)
|
||||
// SetErrorMode doesn't exist on CE.
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
|
||||
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
@@ -5711,29 +5773,6 @@ void UnitTestImpl::PostFlagParsingInit() {
|
||||
}
|
||||
}
|
||||
|
||||
// A predicate that checks the name of a TestSuite against a known
|
||||
// value.
|
||||
//
|
||||
// This is used for implementation of the UnitTest class only. We put
|
||||
// it in the anonymous namespace to prevent polluting the outer
|
||||
// namespace.
|
||||
//
|
||||
// TestSuiteNameIs is copyable.
|
||||
class TestSuiteNameIs {
|
||||
public:
|
||||
// Constructor.
|
||||
explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
|
||||
|
||||
// Returns true if and only if the name of test_suite matches name_.
|
||||
bool operator()(const TestSuite* test_suite) const {
|
||||
return test_suite != nullptr &&
|
||||
strcmp(test_suite->name(), name_.c_str()) == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
// Finds and returns a TestSuite with the given name. If one doesn't
|
||||
// exist, creates one and returns it. It's the CALLER'S
|
||||
// RESPONSIBILITY to ensure that this function is only called WHEN THE
|
||||
@@ -5747,19 +5786,27 @@ class TestSuiteNameIs {
|
||||
// set_up_tc: pointer to the function that sets up the test suite
|
||||
// tear_down_tc: pointer to the function that tears down the test suite
|
||||
TestSuite* UnitTestImpl::GetTestSuite(
|
||||
const char* test_suite_name, const char* type_param,
|
||||
const std::string& test_suite_name, const char* type_param,
|
||||
internal::SetUpTestSuiteFunc set_up_tc,
|
||||
internal::TearDownTestSuiteFunc tear_down_tc) {
|
||||
// Can we find a TestSuite with the given name?
|
||||
const auto test_suite =
|
||||
std::find_if(test_suites_.rbegin(), test_suites_.rend(),
|
||||
TestSuiteNameIs(test_suite_name));
|
||||
// During initialization, all TestInfos for a given suite are added in
|
||||
// sequence. To optimize this case, see if the most recently added suite is
|
||||
// the one being requested now.
|
||||
if (!test_suites_.empty() &&
|
||||
(*test_suites_.rbegin())->name_ == test_suite_name) {
|
||||
return *test_suites_.rbegin();
|
||||
}
|
||||
|
||||
if (test_suite != test_suites_.rend()) return *test_suite;
|
||||
// Fall back to searching the collection.
|
||||
auto item_it = test_suites_by_name_.find(test_suite_name);
|
||||
if (item_it != test_suites_by_name_.end()) {
|
||||
return item_it->second;
|
||||
}
|
||||
|
||||
// No. Let's create one.
|
||||
// Not found. Create a new instance.
|
||||
auto* const new_test_suite =
|
||||
new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);
|
||||
test_suites_by_name_.emplace(test_suite_name, new_test_suite);
|
||||
|
||||
const UnitTestFilter death_test_suite_filter(kDeathTestSuiteFilter);
|
||||
// Is this a death test suite?
|
||||
@@ -5972,6 +6019,12 @@ bool UnitTestImpl::RunAllTests() {
|
||||
}
|
||||
|
||||
repeater->OnTestProgramEnd(*parent_);
|
||||
// Destroy environments in normal code, not in static teardown.
|
||||
bool delete_environment_on_teardown = true;
|
||||
if (delete_environment_on_teardown) {
|
||||
ForEach(environments_, internal::Delete<Environment>);
|
||||
environments_.clear();
|
||||
}
|
||||
|
||||
if (!gtest_is_initialized_before_run_all_tests) {
|
||||
ColoredPrintf(
|
||||
@@ -6105,12 +6158,11 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
|
||||
int num_runnable_tests = 0;
|
||||
int num_selected_tests = 0;
|
||||
for (auto* test_suite : test_suites_) {
|
||||
const std::string& test_suite_name = test_suite->name();
|
||||
const std::string& test_suite_name = test_suite->name_;
|
||||
test_suite->set_should_run(false);
|
||||
|
||||
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
|
||||
TestInfo* const test_info = test_suite->test_info_list()[j];
|
||||
const std::string test_name(test_info->name());
|
||||
for (TestInfo* test_info : test_suite->test_info_list()) {
|
||||
const std::string& test_name = test_info->name_;
|
||||
// A test is disabled if test suite name or test name matches
|
||||
// kDisableTestFilter.
|
||||
const bool is_disabled =
|
||||
@@ -6201,8 +6253,8 @@ void UnitTestImpl::ListTestsMatchingFilter() {
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
const std::string& output_format = UnitTestOptions::GetOutputFormat();
|
||||
if (output_format == "xml" || output_format == "json") {
|
||||
FILE* fileout = OpenFileForWriting(
|
||||
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
|
||||
FILE* fileout =
|
||||
OpenFileForWriting(UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||
std::stringstream stream;
|
||||
if (output_format == "xml") {
|
||||
XmlUnitTestResultPrinter(
|
||||
@@ -6651,17 +6703,17 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
|
||||
}
|
||||
|
||||
if (remove_flag) {
|
||||
// Shift the remainder of the argv list left by one. Note
|
||||
// that argv has (*argc + 1) elements, the last one always being
|
||||
// NULL. The following loop moves the trailing NULL element as
|
||||
// well.
|
||||
for (int j = i; j != *argc; j++) {
|
||||
argv[j] = argv[j + 1];
|
||||
// Shift the remainder of the argv list left by one.
|
||||
for (int j = i + 1; j < *argc; ++j) {
|
||||
argv[j - 1] = argv[j];
|
||||
}
|
||||
|
||||
// Decrements the argument count.
|
||||
(*argc)--;
|
||||
|
||||
// Terminate the array with nullptr.
|
||||
argv[*argc] = nullptr;
|
||||
|
||||
// We also need to decrement the iterator as we just removed
|
||||
// an element.
|
||||
i--;
|
||||
@@ -6683,7 +6735,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
|
||||
// remain in place. Unrecognized flags are not reported and do not cause the
|
||||
// program to exit.
|
||||
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#ifdef GTEST_HAS_ABSL_FLAGS
|
||||
if (*argc <= 0) return;
|
||||
|
||||
std::vector<char*> positional_args;
|
||||
@@ -6769,11 +6821,13 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
absl::InitializeSymbolizer(g_argvs[0].c_str());
|
||||
|
||||
#ifdef GTEST_HAS_ABSL_FLAGS
|
||||
// When using the Abseil Flags library, set the program usage message to the
|
||||
// help message, but remove the color-encoding from the message first.
|
||||
absl::SetProgramUsageMessage(absl::StrReplaceAll(
|
||||
kColorEncodedHelpMessage,
|
||||
{{"@D", ""}, {"@R", ""}, {"@G", ""}, {"@Y", ""}, {"@@", "@"}}));
|
||||
#endif // GTEST_HAS_ABSL_FLAGS
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
ParseGoogleTestFlagsOnly(argc, argv);
|
||||
|
||||
26
3rdparty/libchdr/include/libchdr/cdrom.h
vendored
26
3rdparty/libchdr/include/libchdr/cdrom.h
vendored
@@ -10,12 +10,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef __CDROM_H__
|
||||
#define __CDROM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <libchdr/chdconfig.h>
|
||||
|
||||
/***************************************************************************
|
||||
@@ -49,15 +47,11 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
CD_SUB_NONE = 0, /* no subcode data stored */
|
||||
CD_SUB_RAW_INTERLEAVED, /* raw interleaved 96 bytes per sector */
|
||||
CD_SUB_RAW, /* raw non-interleaved 96 bytes per sector */
|
||||
CD_SUB_NORMAL = 0, /* "cooked" 96 bytes per sector */
|
||||
CD_SUB_RAW, /* raw uninterleaved 96 bytes per sector */
|
||||
CD_SUB_NONE /* no subcode data stored */
|
||||
};
|
||||
|
||||
const char* cdrom_get_subtype_string(uint32_t subtype);
|
||||
bool cdrom_parse_subtype_string(const char* typestring, uint32_t* subtype, uint32_t* subsize);
|
||||
|
||||
|
||||
#define CD_FLAG_GDROM 0x00000001 /* disc is a GD-ROM, all tracks should be stored with GD-ROM metadata */
|
||||
#define CD_FLAG_GDROMLE 0x00000002 /* legacy GD-ROM, with little-endian CDDA data */
|
||||
|
||||
@@ -87,10 +81,10 @@ static inline uint32_t lba_to_msf(uint32_t lba)
|
||||
{
|
||||
uint8_t m, s, f;
|
||||
|
||||
m = (uint8_t)(lba / (60 * 75));
|
||||
m = lba / (60 * 75);
|
||||
lba -= m * (60 * 75);
|
||||
s = (uint8_t)(lba / 75);
|
||||
f = (uint8_t)(lba % 75);
|
||||
s = lba / 75;
|
||||
f = lba % 75;
|
||||
|
||||
return ((m / 10) << 20) | ((m % 10) << 16) |
|
||||
((s / 10) << 12) | ((s % 10) << 8) |
|
||||
@@ -113,6 +107,4 @@ static inline uint32_t lba_to_msf_alt(int lba)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif /* __CDROM_H__ */
|
||||
|
||||
205
3rdparty/libchdr/include/libchdr/chd.h
vendored
205
3rdparty/libchdr/include/libchdr/chd.h
vendored
@@ -48,7 +48,6 @@ extern "C" {
|
||||
|
||||
#include <libchdr/coretypes.h>
|
||||
#include <libchdr/chdconfig.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
@@ -59,67 +58,67 @@ extern "C" {
|
||||
V1 header:
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] UINT32 length; // length of header (including tag and length fields)
|
||||
[ 12] UINT32 version; // drive format version
|
||||
[ 16] UINT32 flags; // flags (see below)
|
||||
[ 20] UINT32 compression; // compression type
|
||||
[ 24] UINT32 hunksize; // 512-byte sectors per hunk
|
||||
[ 28] UINT32 totalhunks; // total # of hunks represented
|
||||
[ 32] UINT32 cylinders; // number of cylinders on hard disk
|
||||
[ 36] UINT32 heads; // number of heads on hard disk
|
||||
[ 40] UINT32 sectors; // number of sectors on hard disk
|
||||
[ 44] UINT8 md5[16]; // MD5 checksum of raw data
|
||||
[ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 8] uint32_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t version; // drive format version
|
||||
[ 16] uint32_t flags; // flags (see below)
|
||||
[ 20] uint32_t compression; // compression type
|
||||
[ 24] uint32_t hunksize; // 512-byte sectors per hunk
|
||||
[ 28] uint32_t totalhunks; // total # of hunks represented
|
||||
[ 32] uint32_t cylinders; // number of cylinders on hard disk
|
||||
[ 36] uint32_t heads; // number of heads on hard disk
|
||||
[ 40] uint32_t sectors; // number of sectors on hard disk
|
||||
[ 44] uint8_t md5[16]; // MD5 checksum of raw data
|
||||
[ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] (V1 header length)
|
||||
|
||||
V2 header:
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] UINT32 length; // length of header (including tag and length fields)
|
||||
[ 12] UINT32 version; // drive format version
|
||||
[ 16] UINT32 flags; // flags (see below)
|
||||
[ 20] UINT32 compression; // compression type
|
||||
[ 24] UINT32 hunksize; // seclen-byte sectors per hunk
|
||||
[ 28] UINT32 totalhunks; // total # of hunks represented
|
||||
[ 32] UINT32 cylinders; // number of cylinders on hard disk
|
||||
[ 36] UINT32 heads; // number of heads on hard disk
|
||||
[ 40] UINT32 sectors; // number of sectors on hard disk
|
||||
[ 44] UINT8 md5[16]; // MD5 checksum of raw data
|
||||
[ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] UINT32 seclen; // number of bytes per sector
|
||||
[ 8] uint32_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t version; // drive format version
|
||||
[ 16] uint32_t flags; // flags (see below)
|
||||
[ 20] uint32_t compression; // compression type
|
||||
[ 24] uint32_t hunksize; // seclen-byte sectors per hunk
|
||||
[ 28] uint32_t totalhunks; // total # of hunks represented
|
||||
[ 32] uint32_t cylinders; // number of cylinders on hard disk
|
||||
[ 36] uint32_t heads; // number of heads on hard disk
|
||||
[ 40] uint32_t sectors; // number of sectors on hard disk
|
||||
[ 44] uint8_t md5[16]; // MD5 checksum of raw data
|
||||
[ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] uint32_t seclen; // number of bytes per sector
|
||||
[ 80] (V2 header length)
|
||||
|
||||
V3 header:
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] UINT32 length; // length of header (including tag and length fields)
|
||||
[ 12] UINT32 version; // drive format version
|
||||
[ 16] UINT32 flags; // flags (see below)
|
||||
[ 20] UINT32 compression; // compression type
|
||||
[ 24] UINT32 totalhunks; // total # of hunks represented
|
||||
[ 28] UINT64 logicalbytes; // logical size of the data (in bytes)
|
||||
[ 36] UINT64 metaoffset; // offset to the first blob of metadata
|
||||
[ 44] UINT8 md5[16]; // MD5 checksum of raw data
|
||||
[ 60] UINT8 parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] UINT32 hunkbytes; // number of bytes per hunk
|
||||
[ 80] UINT8 sha1[20]; // SHA1 checksum of raw data
|
||||
[100] UINT8 parentsha1[20];// SHA1 checksum of parent file
|
||||
[ 8] uint32_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t version; // drive format version
|
||||
[ 16] uint32_t flags; // flags (see below)
|
||||
[ 20] uint32_t compression; // compression type
|
||||
[ 24] uint32_t totalhunks; // total # of hunks represented
|
||||
[ 28] uint64_t logicalbytes; // logical size of the data (in bytes)
|
||||
[ 36] uint64_t metaoffset; // offset to the first blob of metadata
|
||||
[ 44] uint8_t md5[16]; // MD5 checksum of raw data
|
||||
[ 60] uint8_t parentmd5[16]; // MD5 checksum of parent file
|
||||
[ 76] uint32_t hunkbytes; // number of bytes per hunk
|
||||
[ 80] uint8_t sha1[20]; // SHA1 checksum of raw data
|
||||
[100] uint8_t parentsha1[20];// SHA1 checksum of parent file
|
||||
[120] (V3 header length)
|
||||
|
||||
V4 header:
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] UINT32 length; // length of header (including tag and length fields)
|
||||
[ 12] UINT32 version; // drive format version
|
||||
[ 16] UINT32 flags; // flags (see below)
|
||||
[ 20] UINT32 compression; // compression type
|
||||
[ 24] UINT32 totalhunks; // total # of hunks represented
|
||||
[ 28] UINT64 logicalbytes; // logical size of the data (in bytes)
|
||||
[ 36] UINT64 metaoffset; // offset to the first blob of metadata
|
||||
[ 44] UINT32 hunkbytes; // number of bytes per hunk
|
||||
[ 48] UINT8 sha1[20]; // combined raw+meta SHA1
|
||||
[ 68] UINT8 parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[ 88] UINT8 rawsha1[20]; // raw data SHA1
|
||||
[ 8] uint32_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t version; // drive format version
|
||||
[ 16] uint32_t flags; // flags (see below)
|
||||
[ 20] uint32_t compression; // compression type
|
||||
[ 24] uint32_t totalhunks; // total # of hunks represented
|
||||
[ 28] uint64_t logicalbytes; // logical size of the data (in bytes)
|
||||
[ 36] uint64_t metaoffset; // offset to the first blob of metadata
|
||||
[ 44] uint32_t hunkbytes; // number of bytes per hunk
|
||||
[ 48] uint8_t sha1[20]; // combined raw+meta SHA1
|
||||
[ 68] uint8_t parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[ 88] uint8_t rawsha1[20]; // raw data SHA1
|
||||
[108] (V4 header length)
|
||||
|
||||
Flags:
|
||||
@@ -131,17 +130,17 @@ extern "C" {
|
||||
V5 header:
|
||||
|
||||
[ 0] char tag[8]; // 'MComprHD'
|
||||
[ 8] uint32_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t version; // drive format version
|
||||
[ 16] uint32_t compressors[4];// which custom compressors are used?
|
||||
[ 32] uint64_t logicalbytes; // logical size of the data (in bytes)
|
||||
[ 40] uint64_t mapoffset; // offset to the map
|
||||
[ 48] uint64_t metaoffset; // offset to the first blob of metadata
|
||||
[ 56] uint32_t hunkbytes; // number of bytes per hunk (512k maximum)
|
||||
[ 60] uint32_t unitbytes; // number of bytes per unit within each hunk
|
||||
[ 64] uint8_t rawsha1[20]; // raw data SHA1
|
||||
[ 84] uint8_t sha1[20]; // combined raw+meta SHA1
|
||||
[104] uint8_t parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[ 8] uint32_t_t length; // length of header (including tag and length fields)
|
||||
[ 12] uint32_t_t version; // drive format version
|
||||
[ 16] uint32_t_t compressors[4];// which custom compressors are used?
|
||||
[ 32] uint64_t_t logicalbytes; // logical size of the data (in bytes)
|
||||
[ 40] uint64_t_t mapoffset; // offset to the map
|
||||
[ 48] uint64_t_t metaoffset; // offset to the first blob of metadata
|
||||
[ 56] uint32_t_t hunkbytes; // number of bytes per hunk (512k maximum)
|
||||
[ 60] uint32_t_t unitbytes; // number of bytes per unit within each hunk
|
||||
[ 64] uint8_t_t rawsha1[20]; // raw data SHA1
|
||||
[ 84] uint8_t_t sha1[20]; // combined raw+meta SHA1
|
||||
[104] uint8_t_t parentsha1[20];// combined raw+meta SHA1 of parent
|
||||
[124] (V5 header length)
|
||||
|
||||
If parentsha1 != 0, we have a parent (no need for flags)
|
||||
@@ -149,22 +148,22 @@ extern "C" {
|
||||
|
||||
V5 uncompressed map format:
|
||||
|
||||
[ 0] uint32_t offset; // starting offset / hunk size
|
||||
[ 0] uint32_t_t offset; // starting offset / hunk size
|
||||
|
||||
V5 compressed map format header:
|
||||
|
||||
[ 0] uint32_t length; // length of compressed map
|
||||
[ 0] uint32_t_t length; // length of compressed map
|
||||
[ 4] UINT48 datastart; // offset of first block
|
||||
[ 10] uint16_t crc; // crc-16 of the map
|
||||
[ 12] uint8_t lengthbits; // bits used to encode complength
|
||||
[ 13] uint8_t hunkbits; // bits used to encode self-refs
|
||||
[ 14] uint8_t parentunitbits; // bits used to encode parent unit refs
|
||||
[ 15] uint8_t reserved; // future use
|
||||
[ 12] uint8_t_t lengthbits; // bits used to encode complength
|
||||
[ 13] uint8_t_t hunkbits; // bits used to encode self-refs
|
||||
[ 14] uint8_t_t parentunitbits; // bits used to encode parent unit refs
|
||||
[ 15] uint8_t_t reserved; // future use
|
||||
[ 16] (compressed header length)
|
||||
|
||||
Each compressed map entry, once expanded, looks like:
|
||||
|
||||
[ 0] uint8_t compression; // compression type
|
||||
[ 0] uint8_t_t compression; // compression type
|
||||
[ 1] UINT24 complength; // compressed length
|
||||
[ 4] UINT48 offset; // offset
|
||||
[ 10] uint16_t crc; // crc-16 of the data
|
||||
@@ -221,7 +220,7 @@ extern "C" {
|
||||
|
||||
/* metadata parameters */
|
||||
#define CHDMETATAG_WILDCARD 0
|
||||
#define CHD_METAINDEX_APPEND ((UINT32)-1)
|
||||
#define CHD_METAINDEX_APPEND ((uint32_t)-1)
|
||||
|
||||
/* metadata flags */
|
||||
#define CHD_MDFLAGS_CHECKSUM 0x01 /* indicates data is checksummed */
|
||||
@@ -259,7 +258,6 @@ extern "C" {
|
||||
/* CHD open values */
|
||||
#define CHD_OPEN_READ 1
|
||||
#define CHD_OPEN_READWRITE 2
|
||||
#define CHD_OPEN_TRANSFER_FILE 4 /* Freeing of the FILE* is now libchdr's responsibility if open was successful */
|
||||
|
||||
/* error types */
|
||||
enum _chd_error
|
||||
@@ -291,8 +289,7 @@ enum _chd_error
|
||||
CHDERR_INVALID_STATE,
|
||||
CHDERR_OPERATION_PENDING,
|
||||
CHDERR_NO_ASYNC_OPERATION,
|
||||
CHDERR_UNSUPPORTED_FORMAT,
|
||||
CHDERR_CANCELLED,
|
||||
CHDERR_UNSUPPORTED_FORMAT
|
||||
};
|
||||
typedef enum _chd_error chd_error;
|
||||
|
||||
@@ -310,32 +307,32 @@ typedef struct _chd_file chd_file;
|
||||
typedef struct _chd_header chd_header;
|
||||
struct _chd_header
|
||||
{
|
||||
UINT32 length; /* length of header data */
|
||||
UINT32 version; /* drive format version */
|
||||
UINT32 flags; /* flags field */
|
||||
UINT32 compression[4]; /* compression type */
|
||||
UINT32 hunkbytes; /* number of bytes per hunk */
|
||||
UINT32 totalhunks; /* total # of hunks represented */
|
||||
UINT64 logicalbytes; /* logical size of the data */
|
||||
UINT64 metaoffset; /* offset in file of first metadata */
|
||||
UINT64 mapoffset; /* TOOD V5 */
|
||||
UINT8 md5[CHD_MD5_BYTES]; /* overall MD5 checksum */
|
||||
UINT8 parentmd5[CHD_MD5_BYTES]; /* overall MD5 checksum of parent */
|
||||
UINT8 sha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum */
|
||||
UINT8 rawsha1[CHD_SHA1_BYTES]; /* SHA1 checksum of raw data */
|
||||
UINT8 parentsha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum of parent */
|
||||
UINT32 unitbytes; /* TODO V5 */
|
||||
UINT64 unitcount; /* TODO V5 */
|
||||
UINT32 hunkcount; /* TODO V5 */
|
||||
uint32_t length; /* length of header data */
|
||||
uint32_t version; /* drive format version */
|
||||
uint32_t flags; /* flags field */
|
||||
uint32_t compression[4]; /* compression type */
|
||||
uint32_t hunkbytes; /* number of bytes per hunk */
|
||||
uint32_t totalhunks; /* total # of hunks represented */
|
||||
uint64_t logicalbytes; /* logical size of the data */
|
||||
uint64_t metaoffset; /* offset in file of first metadata */
|
||||
uint64_t mapoffset; /* TOOD V5 */
|
||||
uint8_t md5[CHD_MD5_BYTES]; /* overall MD5 checksum */
|
||||
uint8_t parentmd5[CHD_MD5_BYTES]; /* overall MD5 checksum of parent */
|
||||
uint8_t sha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum */
|
||||
uint8_t rawsha1[CHD_SHA1_BYTES]; /* SHA1 checksum of raw data */
|
||||
uint8_t parentsha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum of parent */
|
||||
uint32_t unitbytes; /* TODO V5 */
|
||||
uint64_t unitcount; /* TODO V5 */
|
||||
uint32_t hunkcount; /* TODO V5 */
|
||||
|
||||
/* map information */
|
||||
UINT32 mapentrybytes; /* length of each entry in a map (V5) */
|
||||
UINT8* rawmap; /* raw map data */
|
||||
uint32_t mapentrybytes; /* length of each entry in a map (V5) */
|
||||
uint8_t* rawmap; /* raw map data */
|
||||
|
||||
UINT32 obsolete_cylinders; /* obsolete field -- do not use! */
|
||||
UINT32 obsolete_sectors; /* obsolete field -- do not use! */
|
||||
UINT32 obsolete_heads; /* obsolete field -- do not use! */
|
||||
UINT32 obsolete_hunksize; /* obsolete field -- do not use! */
|
||||
uint32_t obsolete_cylinders; /* obsolete field -- do not use! */
|
||||
uint32_t obsolete_sectors; /* obsolete field -- do not use! */
|
||||
uint32_t obsolete_heads; /* obsolete field -- do not use! */
|
||||
uint32_t obsolete_hunksize; /* obsolete field -- do not use! */
|
||||
};
|
||||
|
||||
|
||||
@@ -343,10 +340,10 @@ struct _chd_header
|
||||
typedef struct _chd_verify_result chd_verify_result;
|
||||
struct _chd_verify_result
|
||||
{
|
||||
UINT8 md5[CHD_MD5_BYTES]; /* overall MD5 checksum */
|
||||
UINT8 sha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum */
|
||||
UINT8 rawsha1[CHD_SHA1_BYTES]; /* SHA1 checksum of raw data */
|
||||
UINT8 metasha1[CHD_SHA1_BYTES]; /* SHA1 checksum of metadata */
|
||||
uint8_t md5[CHD_MD5_BYTES]; /* overall MD5 checksum */
|
||||
uint8_t sha1[CHD_SHA1_BYTES]; /* overall SHA1 checksum */
|
||||
uint8_t rawsha1[CHD_SHA1_BYTES]; /* SHA1 checksum of raw data */
|
||||
uint8_t metasha1[CHD_SHA1_BYTES]; /* SHA1 checksum of metadata */
|
||||
};
|
||||
|
||||
|
||||
@@ -372,10 +369,10 @@ struct _chd_verify_result
|
||||
/* ----- CHD file management ----- */
|
||||
|
||||
/* create a new CHD file fitting the given description */
|
||||
/* chd_error chd_create(const char *filename, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); */
|
||||
/* chd_error chd_create(const char *filename, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t compression, chd_file *parent); */
|
||||
|
||||
/* same as chd_create(), but accepts an already-opened core_file object */
|
||||
/* chd_error chd_create_file(core_file *file, UINT64 logicalbytes, UINT32 hunkbytes, UINT32 compression, chd_file *parent); */
|
||||
/* chd_error chd_create_file(core_file *file, uint64_t logicalbytes, uint32_t hunkbytes, uint32_t compression, chd_file *parent); */
|
||||
|
||||
/* open an existing CHD file */
|
||||
CHD_EXPORT chd_error chd_open_core_file(core_file *file, int mode, chd_file *parent, chd_file **chd);
|
||||
@@ -384,7 +381,6 @@ CHD_EXPORT chd_error chd_open(const char *filename, int mode, chd_file *parent,
|
||||
|
||||
/* precache underlying file */
|
||||
CHD_EXPORT chd_error chd_precache(chd_file *chd);
|
||||
CHD_EXPORT chd_error chd_precache_progress(chd_file* chd, bool(*progress)(size_t pos, size_t total, void* param), void* param);
|
||||
|
||||
/* close a CHD file */
|
||||
CHD_EXPORT void chd_close(chd_file *chd);
|
||||
@@ -392,13 +388,11 @@ CHD_EXPORT void chd_close(chd_file *chd);
|
||||
/* return the associated core_file */
|
||||
CHD_EXPORT core_file *chd_core_file(chd_file *chd);
|
||||
|
||||
/* return the overall size of a CHD, and any of its parents */
|
||||
CHD_EXPORT UINT64 chd_get_compressed_size(chd_file* chd);
|
||||
|
||||
/* return an error string for the given CHD error */
|
||||
CHD_EXPORT const char *chd_error_string(chd_error err);
|
||||
|
||||
|
||||
|
||||
/* ----- CHD header management ----- */
|
||||
|
||||
/* return a pointer to the extracted CHD header data */
|
||||
@@ -408,21 +402,20 @@ CHD_EXPORT const chd_header *chd_get_header(chd_file *chd);
|
||||
CHD_EXPORT chd_error chd_read_header_core_file(core_file *file, chd_header *header);
|
||||
CHD_EXPORT chd_error chd_read_header_file(FILE *file, chd_header *header);
|
||||
CHD_EXPORT chd_error chd_read_header(const char *filename, chd_header *header);
|
||||
CHD_EXPORT bool chd_is_matching_parent(const chd_header* header, const chd_header* parent_header);
|
||||
|
||||
|
||||
|
||||
/* ----- core data read/write ----- */
|
||||
|
||||
/* read one hunk from the CHD file */
|
||||
CHD_EXPORT chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer);
|
||||
CHD_EXPORT chd_error chd_read(chd_file *chd, uint32_t hunknum, void *buffer);
|
||||
|
||||
|
||||
|
||||
/* ----- metadata management ----- */
|
||||
|
||||
/* get indexed metadata of a particular sort */
|
||||
CHD_EXPORT chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex, void *output, UINT32 outputlen, UINT32 *resultlen, UINT32 *resulttag, UINT8 *resultflags);
|
||||
CHD_EXPORT chd_error chd_get_metadata(chd_file *chd, uint32_t searchtag, uint32_t searchindex, void *output, uint32_t outputlen, uint32_t *resultlen, uint32_t *resulttag, uint8_t *resultflags);
|
||||
|
||||
|
||||
|
||||
@@ -433,7 +426,7 @@ CHD_EXPORT chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 se
|
||||
CHD_EXPORT chd_error chd_codec_config(chd_file *chd, int param, void *config);
|
||||
|
||||
/* return a string description of a codec */
|
||||
CHD_EXPORT const char *chd_get_codec_name(UINT32 codec);
|
||||
CHD_EXPORT const char *chd_get_codec_name(uint32_t codec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
31
3rdparty/libchdr/include/libchdr/coretypes.h
vendored
31
3rdparty/libchdr/include/libchdr/coretypes.h
vendored
@@ -8,26 +8,13 @@
|
||||
#include <streams/file_stream_transforms.h>
|
||||
#endif
|
||||
|
||||
#ifndef ARRAY_LENGTH
|
||||
#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
#if defined(__PS3__) || defined(__PSL1GHT__)
|
||||
#undef UINT32
|
||||
#undef UINT16
|
||||
#undef UINT8
|
||||
#undef INT32
|
||||
#undef INT16
|
||||
#undef INT8
|
||||
#endif
|
||||
|
||||
typedef uint64_t UINT64;
|
||||
typedef uint32_t UINT32;
|
||||
typedef uint16_t UINT16;
|
||||
typedef uint8_t UINT8;
|
||||
|
||||
typedef int64_t INT64;
|
||||
typedef int32_t INT32;
|
||||
typedef int16_t INT16;
|
||||
typedef int8_t INT8;
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
#endif
|
||||
|
||||
typedef struct chd_core_file {
|
||||
/*
|
||||
@@ -41,9 +28,9 @@ typedef struct chd_core_file {
|
||||
* undefined because many implementations will seek to the end of the
|
||||
* file and call ftell.
|
||||
*
|
||||
* on error, (UINT64)-1 is returned.
|
||||
* on error, (uint64_t)-1 is returned.
|
||||
*/
|
||||
UINT64(*fsize)(struct chd_core_file*);
|
||||
uint64_t(*fsize)(struct chd_core_file*);
|
||||
|
||||
/*
|
||||
* should match the behavior of fread, except the FILE* argument at the end
|
||||
@@ -55,7 +42,7 @@ typedef struct chd_core_file {
|
||||
int (*fclose)(struct chd_core_file*);
|
||||
|
||||
// fseek clone
|
||||
int (*fseek)(struct chd_core_file*, INT64, int);
|
||||
int (*fseek)(struct chd_core_file*, int64_t, int);
|
||||
} core_file;
|
||||
|
||||
static inline int core_fclose(core_file *fp) {
|
||||
@@ -66,11 +53,11 @@ static inline size_t core_fread(core_file *fp, void *ptr, size_t len) {
|
||||
return fp->fread(ptr, 1, len, fp);
|
||||
}
|
||||
|
||||
static inline int core_fseek(core_file* fp, INT64 offset, int whence) {
|
||||
static inline int core_fseek(core_file* fp, int64_t offset, int whence) {
|
||||
return fp->fseek(fp, offset, whence);
|
||||
}
|
||||
|
||||
static inline UINT64 core_fsize(core_file *fp)
|
||||
static inline uint64_t core_fsize(core_file *fp)
|
||||
{
|
||||
return fp->fsize(fp);
|
||||
}
|
||||
|
||||
2
3rdparty/libchdr/include/libchdr/huffman.h
vendored
2
3rdparty/libchdr/include/libchdr/huffman.h
vendored
@@ -85,6 +85,6 @@ int huffman_build_tree(struct huffman_decoder* decoder, uint32_t totaldata, uint
|
||||
enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decoder);
|
||||
enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decoder);
|
||||
|
||||
void huffman_build_lookup_table(struct huffman_decoder* decoder);
|
||||
enum huffman_error huffman_build_lookup_table(struct huffman_decoder* decoder);
|
||||
|
||||
#endif
|
||||
|
||||
29
3rdparty/libchdr/src/libchdr_cdrom.c
vendored
29
3rdparty/libchdr/src/libchdr_cdrom.c
vendored
@@ -20,35 +20,6 @@
|
||||
|
||||
#include <libchdr/cdrom.h>
|
||||
|
||||
const char* cdrom_get_subtype_string(uint32_t subtype)
|
||||
{
|
||||
switch (subtype)
|
||||
{
|
||||
case CD_SUB_RAW: return "RW";
|
||||
case CD_SUB_RAW_INTERLEAVED: return "RW_RAW";
|
||||
default: return "NONE";
|
||||
}
|
||||
}
|
||||
|
||||
bool cdrom_parse_subtype_string(const char* typestring, uint32_t* subtype, uint32_t* subsize)
|
||||
{
|
||||
// https://github.com/mamedev/mame/blob/d2d54fb8ed53a2e86d308067da8414f85b5929b0/src/lib/util/cdrom.cpp#L767
|
||||
if (!strcmp(typestring, "RW"))
|
||||
{
|
||||
*subtype = CD_SUB_RAW;
|
||||
*subsize = 96;
|
||||
return true;
|
||||
}
|
||||
else if (!strcmp(typestring, "RW_RAW"))
|
||||
{
|
||||
*subtype = CD_SUB_RAW_INTERLEAVED;
|
||||
*subsize = 96;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef WANT_RAW_DATA_SECTOR
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
630
3rdparty/libchdr/src/libchdr_chd.c
vendored
630
3rdparty/libchdr/src/libchdr_chd.c
vendored
File diff suppressed because it is too large
Load Diff
32
3rdparty/libchdr/src/libchdr_huffman.c
vendored
32
3rdparty/libchdr/src/libchdr_huffman.c
vendored
@@ -230,7 +230,9 @@ enum huffman_error huffman_import_tree_rle(struct huffman_decoder* decoder, stru
|
||||
return error;
|
||||
|
||||
/* build the lookup table */
|
||||
huffman_build_lookup_table(decoder);
|
||||
error = huffman_build_lookup_table(decoder);
|
||||
if (error != HUFFERR_NONE)
|
||||
return error;
|
||||
|
||||
/* determine final input length and report errors */
|
||||
return bitstream_overflow(bitbuf) ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
|
||||
@@ -271,8 +273,16 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
|
||||
/* then regenerate the tree */
|
||||
error = huffman_assign_canonical_codes(smallhuff);
|
||||
if (error != HUFFERR_NONE)
|
||||
{
|
||||
delete_huffman_decoder(smallhuff);
|
||||
return error;
|
||||
huffman_build_lookup_table(smallhuff);
|
||||
}
|
||||
error = huffman_build_lookup_table(smallhuff);
|
||||
if (error != HUFFERR_NONE)
|
||||
{
|
||||
delete_huffman_decoder(smallhuff);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* determine the maximum length of an RLE count */
|
||||
temp = decoder->numcodes - 9;
|
||||
@@ -308,7 +318,9 @@ enum huffman_error huffman_import_tree_huffman(struct huffman_decoder* decoder,
|
||||
return error;
|
||||
|
||||
/* build the lookup table */
|
||||
huffman_build_lookup_table(decoder);
|
||||
error = huffman_build_lookup_table(decoder);
|
||||
if (error != HUFFERR_NONE)
|
||||
return error;
|
||||
|
||||
/* determine final input length and report errors */
|
||||
return bitstream_overflow(bitbuf) ? HUFFERR_INPUT_BUFFER_TOO_SMALL : HUFFERR_NONE;
|
||||
@@ -523,8 +535,9 @@ enum huffman_error huffman_assign_canonical_codes(struct huffman_decoder* decode
|
||||
*-------------------------------------------------
|
||||
*/
|
||||
|
||||
void huffman_build_lookup_table(struct huffman_decoder* decoder)
|
||||
enum huffman_error huffman_build_lookup_table(struct huffman_decoder* decoder)
|
||||
{
|
||||
const lookup_value* lookupend = &decoder->lookup[(1u << decoder->maxbits)];
|
||||
uint32_t curcode;
|
||||
/* iterate over all codes */
|
||||
for (curcode = 0; curcode < decoder->numcodes; curcode++)
|
||||
@@ -533,9 +546,10 @@ void huffman_build_lookup_table(struct huffman_decoder* decoder)
|
||||
struct node_t* node = &decoder->huffnode[curcode];
|
||||
if (node->numbits > 0)
|
||||
{
|
||||
int shift;
|
||||
lookup_value *dest;
|
||||
lookup_value *destend;
|
||||
int shift;
|
||||
lookup_value *dest;
|
||||
lookup_value *destend;
|
||||
|
||||
/* set up the entry */
|
||||
lookup_value value = MAKE_LOOKUP(curcode, node->numbits);
|
||||
|
||||
@@ -543,8 +557,12 @@ void huffman_build_lookup_table(struct huffman_decoder* decoder)
|
||||
shift = decoder->maxbits - node->numbits;
|
||||
dest = &decoder->lookup[node->bits << shift];
|
||||
destend = &decoder->lookup[((node->bits + 1) << shift) - 1];
|
||||
if (dest >= lookupend || destend >= lookupend || destend < dest)
|
||||
return HUFFERR_INTERNAL_INCONSISTENCY;
|
||||
while (dest <= destend)
|
||||
*dest++ = value;
|
||||
}
|
||||
}
|
||||
|
||||
return HUFFERR_NONE;
|
||||
}
|
||||
|
||||
523
3rdparty/vulkan/include/vk_mem_alloc.h
vendored
523
3rdparty/vulkan/include/vk_mem_alloc.h
vendored
@@ -95,6 +95,7 @@ See also: [product page on GPUOpen](https://gpuopen.com/gaming-product/vulkan-me
|
||||
- \subpage enabling_buffer_device_address
|
||||
- \subpage vk_ext_memory_priority
|
||||
- \subpage vk_amd_device_coherent_memory
|
||||
- \subpage vk_khr_external_memory_win32
|
||||
- \subpage general_considerations
|
||||
- [Thread safety](@ref general_considerations_thread_safety)
|
||||
- [Versioning and compatibility](@ref general_considerations_versioning_and_compatibility)
|
||||
@@ -127,7 +128,9 @@ See documentation chapter: \ref statistics.
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(VULKAN_H_)
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
||||
#if !defined(VMA_VULKAN_VERSION)
|
||||
#if defined(VK_VERSION_1_3)
|
||||
@@ -240,6 +243,15 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Defined to 1 when VK_KHR_external_memory_win32 device extension is defined in Vulkan headers.
|
||||
#if !defined(VMA_EXTERNAL_MEMORY_WIN32)
|
||||
#if VK_KHR_external_memory_win32
|
||||
#define VMA_EXTERNAL_MEMORY_WIN32 1
|
||||
#else
|
||||
#define VMA_EXTERNAL_MEMORY_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define these macros to decorate all public functions with additional code,
|
||||
// before and after returned type, appropriately. This may be useful for
|
||||
// exporting the functions when compiling VMA as a separate library. Example:
|
||||
@@ -459,6 +471,15 @@ typedef enum VmaAllocatorCreateFlagBits
|
||||
*/
|
||||
VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT = 0x00000100,
|
||||
|
||||
/**
|
||||
Enables usage of VK_KHR_external_memory_win32 extension in the library.
|
||||
|
||||
You should set this flag if you found available and enabled this device extension,
|
||||
while creating Vulkan device passed as VmaAllocatorCreateInfo::device.
|
||||
For more information, see \ref vk_khr_external_memory_win32.
|
||||
*/
|
||||
VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT = 0x00000200,
|
||||
|
||||
VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} VmaAllocatorCreateFlagBits;
|
||||
/// See #VmaAllocatorCreateFlagBits.
|
||||
@@ -1033,6 +1054,11 @@ typedef struct VmaVulkanFunctions
|
||||
/// Fetch from "vkGetDeviceImageMemoryRequirements" on Vulkan >= 1.3, but you can also fetch it from "vkGetDeviceImageMemoryRequirementsKHR" if you enabled extension VK_KHR_maintenance4.
|
||||
PFN_vkGetDeviceImageMemoryRequirementsKHR VMA_NULLABLE vkGetDeviceImageMemoryRequirements;
|
||||
#endif
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
PFN_vkGetMemoryWin32HandleKHR VMA_NULLABLE vkGetMemoryWin32HandleKHR;
|
||||
#else
|
||||
void* VMA_NULLABLE vkGetMemoryWin32HandleKHR;
|
||||
#endif
|
||||
} VmaVulkanFunctions;
|
||||
|
||||
/// Description of a Allocator to be created.
|
||||
@@ -1810,6 +1836,9 @@ VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool(
|
||||
\param allocator Allocator object.
|
||||
\param pool Pool object.
|
||||
\param[out] pPoolStats Statistics of specified pool.
|
||||
|
||||
Note that when using the pool from multiple threads, returned information may immediately
|
||||
become outdated.
|
||||
*/
|
||||
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStatistics(
|
||||
VmaAllocator VMA_NOT_NULL allocator,
|
||||
@@ -2050,6 +2079,40 @@ VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationMemoryProperties(
|
||||
VmaAllocation VMA_NOT_NULL allocation,
|
||||
VkMemoryPropertyFlags* VMA_NOT_NULL pFlags);
|
||||
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
/**
|
||||
\brief Given an allocation, returns Win32 handle that may be imported by other processes or APIs.
|
||||
|
||||
\param hTargetProcess Must be a valid handle to target process or null. If it's null, the function returns
|
||||
handle for the current process.
|
||||
\param[out] pHandle Output parameter that returns the handle.
|
||||
|
||||
The function fills `pHandle` with handle that can be used in target process.
|
||||
The handle is fetched using function `vkGetMemoryWin32HandleKHR`.
|
||||
When no longer needed, you must close it using:
|
||||
|
||||
\code
|
||||
CloseHandle(handle);
|
||||
\endcode
|
||||
|
||||
You can close it any time, before or after destroying the allocation object.
|
||||
It is reference-counted internally by Windows.
|
||||
|
||||
Note the handle is returned for the entire `VkDeviceMemory` block that the allocation belongs to.
|
||||
If the allocation is sub-allocated from a larger block, you may need to consider the offset of the allocation
|
||||
(VmaAllocationInfo::offset).
|
||||
|
||||
If the function fails with `VK_ERROR_FEATURE_NOT_PRESENT` error code, please double-check
|
||||
that VmaVulkanFunctions::vkGetMemoryWin32HandleKHR function pointer is set, e.g. either by using `VMA_DYNAMIC_VULKAN_FUNCTIONS`
|
||||
or by manually passing it through VmaAllocatorCreateInfo::pVulkanFunctions.
|
||||
|
||||
For more information, see chapter \ref vk_khr_external_memory_win32.
|
||||
*/
|
||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32Handle(VmaAllocator VMA_NOT_NULL allocator,
|
||||
VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle);
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
/** \brief Maps memory represented by given allocation and returns pointer to it.
|
||||
|
||||
Maps memory represented by given allocation to make it accessible to CPU code.
|
||||
@@ -3097,7 +3160,7 @@ static void vma_aligned_free(void* VMA_NULLABLE ptr)
|
||||
std::shared_mutex m_Mutex;
|
||||
};
|
||||
#define VMA_RW_MUTEX VmaRWMutex
|
||||
#elif defined(_WIN32) && defined(WINVER) && WINVER >= 0x0600
|
||||
#elif defined(_WIN32) && defined(WINVER) && defined(SRWLOCK_INIT) && WINVER >= 0x0600
|
||||
// Use SRWLOCK from WinAPI.
|
||||
// Minimum supported client = Windows Vista, server = Windows Server 2008.
|
||||
class VmaRWMutex
|
||||
@@ -3838,12 +3901,6 @@ struct VmaBufferImageUsage
|
||||
|
||||
const VmaBufferImageUsage VmaBufferImageUsage::UNKNOWN = VmaBufferImageUsage(0);
|
||||
|
||||
static void swap(VmaBufferImageUsage& lhs, VmaBufferImageUsage& rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs.Value, rhs.Value);
|
||||
}
|
||||
|
||||
VmaBufferImageUsage::VmaBufferImageUsage(const VkBufferCreateInfo &createInfo,
|
||||
bool useKhrMaintenance5)
|
||||
{
|
||||
@@ -6073,6 +6130,84 @@ private:
|
||||
|
||||
#endif // _VMA_MAPPING_HYSTERESIS
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
class VmaWin32Handle
|
||||
{
|
||||
public:
|
||||
VmaWin32Handle() noexcept : m_hHandle(VMA_NULL) { }
|
||||
explicit VmaWin32Handle(HANDLE hHandle) noexcept : m_hHandle(hHandle) { }
|
||||
~VmaWin32Handle() noexcept { if (m_hHandle != VMA_NULL) { ::CloseHandle(m_hHandle); } }
|
||||
VMA_CLASS_NO_COPY_NO_MOVE(VmaWin32Handle)
|
||||
|
||||
public:
|
||||
// Strengthened
|
||||
VkResult GetHandle(VkDevice device, VkDeviceMemory memory, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE hTargetProcess, bool useMutex, HANDLE* pHandle) noexcept
|
||||
{
|
||||
*pHandle = VMA_NULL;
|
||||
// Try to get handle first.
|
||||
if (m_hHandle != VMA_NULL)
|
||||
{
|
||||
*pHandle = Duplicate(hTargetProcess);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult res = VK_SUCCESS;
|
||||
// If failed, try to create it.
|
||||
{
|
||||
VmaMutexLockWrite lock(m_Mutex, useMutex);
|
||||
if (m_hHandle == VMA_NULL)
|
||||
{
|
||||
res = Create(device, memory, pvkGetMemoryWin32HandleKHR, &m_hHandle);
|
||||
}
|
||||
}
|
||||
|
||||
*pHandle = Duplicate(hTargetProcess);
|
||||
return res;
|
||||
}
|
||||
|
||||
operator bool() const noexcept { return m_hHandle != VMA_NULL; }
|
||||
private:
|
||||
// Not atomic
|
||||
static VkResult Create(VkDevice device, VkDeviceMemory memory, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE* pHandle) noexcept
|
||||
{
|
||||
VkResult res = VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
if (pvkGetMemoryWin32HandleKHR != VMA_NULL)
|
||||
{
|
||||
VkMemoryGetWin32HandleInfoKHR handleInfo{ };
|
||||
handleInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR;
|
||||
handleInfo.memory = memory;
|
||||
handleInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR;
|
||||
res = pvkGetMemoryWin32HandleKHR(device, &handleInfo, pHandle);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
HANDLE Duplicate(HANDLE hTargetProcess = VMA_NULL) const noexcept
|
||||
{
|
||||
if (!m_hHandle)
|
||||
return m_hHandle;
|
||||
|
||||
HANDLE hCurrentProcess = ::GetCurrentProcess();
|
||||
HANDLE hDupHandle = VMA_NULL;
|
||||
if (!::DuplicateHandle(hCurrentProcess, m_hHandle, hTargetProcess ? hTargetProcess : hCurrentProcess, &hDupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
VMA_ASSERT(0 && "Failed to duplicate handle.");
|
||||
}
|
||||
return hDupHandle;
|
||||
}
|
||||
private:
|
||||
HANDLE m_hHandle;
|
||||
VMA_RW_MUTEX m_Mutex; // Protects access m_Handle
|
||||
};
|
||||
#else
|
||||
class VmaWin32Handle
|
||||
{
|
||||
// ABI compatibility
|
||||
void* placeholder = VMA_NULL;
|
||||
VMA_RW_MUTEX placeholder2;
|
||||
};
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
|
||||
#ifndef _VMA_DEVICE_MEMORY_BLOCK
|
||||
/*
|
||||
Represents a single block of device memory (`VkDeviceMemory`) with all the
|
||||
@@ -6139,7 +6274,13 @@ public:
|
||||
VkDeviceSize allocationLocalOffset,
|
||||
VkImage hImage,
|
||||
const void* pNext);
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult CreateWin32Handle(
|
||||
const VmaAllocator hAllocator,
|
||||
PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR,
|
||||
HANDLE hTargetProcess,
|
||||
HANDLE* pHandle)noexcept;
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
private:
|
||||
VmaPool m_hParentPool; // VK_NULL_HANDLE if not belongs to custom pool.
|
||||
uint32_t m_MemoryTypeIndex;
|
||||
@@ -6155,10 +6296,18 @@ private:
|
||||
VmaMappingHysteresis m_MappingHysteresis;
|
||||
uint32_t m_MapCount;
|
||||
void* m_pMappedData;
|
||||
|
||||
VmaWin32Handle m_Handle;
|
||||
};
|
||||
#endif // _VMA_DEVICE_MEMORY_BLOCK
|
||||
|
||||
#ifndef _VMA_ALLOCATION_T
|
||||
struct VmaAllocationExtraData
|
||||
{
|
||||
void* m_pMappedData = VMA_NULL; // Not null means memory is mapped.
|
||||
VmaWin32Handle m_Handle;
|
||||
};
|
||||
|
||||
struct VmaAllocation_T
|
||||
{
|
||||
friend struct VmaDedicatedAllocationListItemTraits;
|
||||
@@ -6191,12 +6340,14 @@ public:
|
||||
bool mapped);
|
||||
// pMappedData not null means allocation is created with MAPPED flag.
|
||||
void InitDedicatedAllocation(
|
||||
VmaAllocator allocator,
|
||||
VmaPool hParentPool,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkDeviceMemory hMemory,
|
||||
VmaSuballocationType suballocationType,
|
||||
void* pMappedData,
|
||||
VkDeviceSize size);
|
||||
void Destroy(VmaAllocator allocator);
|
||||
|
||||
ALLOCATION_TYPE GetType() const { return (ALLOCATION_TYPE)m_Type; }
|
||||
VkDeviceSize GetAlignment() const { return m_Alignment; }
|
||||
@@ -6240,6 +6391,10 @@ public:
|
||||
void PrintParameters(class VmaJsonWriter& json) const;
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* hHandle) noexcept;
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
private:
|
||||
// Allocation out of VmaDeviceMemoryBlock.
|
||||
struct BlockAllocation
|
||||
@@ -6252,7 +6407,7 @@ private:
|
||||
{
|
||||
VmaPool m_hParentPool; // VK_NULL_HANDLE if not belongs to custom pool.
|
||||
VkDeviceMemory m_hMemory;
|
||||
void* m_pMappedData; // Not null means memory is mapped.
|
||||
VmaAllocationExtraData* m_ExtraData;
|
||||
VmaAllocation_T* m_Prev;
|
||||
VmaAllocation_T* m_Next;
|
||||
};
|
||||
@@ -6277,6 +6432,8 @@ private:
|
||||
#if VMA_STATS_STRING_ENABLED
|
||||
VmaBufferImageUsage m_BufferImageUsage; // 0 if unknown.
|
||||
#endif
|
||||
|
||||
void EnsureExtraData(VmaAllocator hAllocator);
|
||||
};
|
||||
#endif // _VMA_ALLOCATION_T
|
||||
|
||||
@@ -10075,6 +10232,7 @@ public:
|
||||
bool m_UseExtMemoryPriority;
|
||||
bool m_UseKhrMaintenance4;
|
||||
bool m_UseKhrMaintenance5;
|
||||
bool m_UseKhrExternalMemoryWin32;
|
||||
const VkDevice m_hDevice;
|
||||
const VkInstance m_hInstance;
|
||||
const bool m_AllocationCallbacksSpecified;
|
||||
@@ -10438,7 +10596,7 @@ VmaDeviceMemoryBlock::VmaDeviceMemoryBlock(VmaAllocator hAllocator)
|
||||
m_Id(0),
|
||||
m_hMemory(VK_NULL_HANDLE),
|
||||
m_MapCount(0),
|
||||
m_pMappedData(VMA_NULL) {}
|
||||
m_pMappedData(VMA_NULL){}
|
||||
|
||||
VmaDeviceMemoryBlock::~VmaDeviceMemoryBlock()
|
||||
{
|
||||
@@ -10681,6 +10839,14 @@ VkResult VmaDeviceMemoryBlock::BindImageMemory(
|
||||
VmaMutexLock lock(m_MapAndBindMutex, hAllocator->m_UseMutex);
|
||||
return hAllocator->BindVulkanImage(m_hMemory, memoryOffset, hImage, pNext);
|
||||
}
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult VmaDeviceMemoryBlock::CreateWin32Handle(const VmaAllocator hAllocator, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE hTargetProcess, HANDLE* pHandle) noexcept
|
||||
{
|
||||
VMA_ASSERT(pHandle);
|
||||
return m_Handle.GetHandle(hAllocator->m_hDevice, m_hMemory, pvkGetMemoryWin32HandleKHR, hTargetProcess, hAllocator->m_UseMutex, pHandle);
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // _VMA_DEVICE_MEMORY_BLOCK_FUNCTIONS
|
||||
|
||||
#ifndef _VMA_ALLOCATION_T_FUNCTIONS
|
||||
@@ -10733,6 +10899,7 @@ void VmaAllocation_T::InitBlockAllocation(
|
||||
}
|
||||
|
||||
void VmaAllocation_T::InitDedicatedAllocation(
|
||||
VmaAllocator allocator,
|
||||
VmaPool hParentPool,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkDeviceMemory hMemory,
|
||||
@@ -10747,16 +10914,29 @@ void VmaAllocation_T::InitDedicatedAllocation(
|
||||
m_Size = size;
|
||||
m_MemoryTypeIndex = memoryTypeIndex;
|
||||
m_SuballocationType = (uint8_t)suballocationType;
|
||||
if(pMappedData != VMA_NULL)
|
||||
m_DedicatedAllocation.m_ExtraData = VMA_NULL;
|
||||
m_DedicatedAllocation.m_hParentPool = hParentPool;
|
||||
m_DedicatedAllocation.m_hMemory = hMemory;
|
||||
m_DedicatedAllocation.m_Prev = VMA_NULL;
|
||||
m_DedicatedAllocation.m_Next = VMA_NULL;
|
||||
|
||||
if (pMappedData != VMA_NULL)
|
||||
{
|
||||
VMA_ASSERT(IsMappingAllowed() && "Mapping is not allowed on this allocation! Please use one of the new VMA_ALLOCATION_CREATE_HOST_ACCESS_* flags when creating it.");
|
||||
m_Flags |= (uint8_t)FLAG_PERSISTENT_MAP;
|
||||
EnsureExtraData(allocator);
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = pMappedData;
|
||||
}
|
||||
}
|
||||
|
||||
void VmaAllocation_T::Destroy(VmaAllocator allocator)
|
||||
{
|
||||
FreeName(allocator);
|
||||
|
||||
if (GetType() == ALLOCATION_TYPE_DEDICATED)
|
||||
{
|
||||
vma_delete(allocator, m_DedicatedAllocation.m_ExtraData);
|
||||
}
|
||||
m_DedicatedAllocation.m_hParentPool = hParentPool;
|
||||
m_DedicatedAllocation.m_hMemory = hMemory;
|
||||
m_DedicatedAllocation.m_pMappedData = pMappedData;
|
||||
m_DedicatedAllocation.m_Prev = VMA_NULL;
|
||||
m_DedicatedAllocation.m_Next = VMA_NULL;
|
||||
}
|
||||
|
||||
void VmaAllocation_T::SetName(VmaAllocator hAllocator, const char* pName)
|
||||
@@ -10861,8 +11041,9 @@ void* VmaAllocation_T::GetMappedData() const
|
||||
}
|
||||
break;
|
||||
case ALLOCATION_TYPE_DEDICATED:
|
||||
VMA_ASSERT((m_DedicatedAllocation.m_pMappedData != VMA_NULL) == (m_MapCount != 0 || IsPersistentMap()));
|
||||
return m_DedicatedAllocation.m_pMappedData;
|
||||
VMA_ASSERT((m_DedicatedAllocation.m_ExtraData != VMA_NULL && m_DedicatedAllocation.m_ExtraData->m_pMappedData != VMA_NULL) ==
|
||||
(m_MapCount != 0 || IsPersistentMap()));
|
||||
return m_DedicatedAllocation.m_ExtraData != VMA_NULL ? m_DedicatedAllocation.m_ExtraData->m_pMappedData : VMA_NULL;
|
||||
default:
|
||||
VMA_ASSERT(0);
|
||||
return VMA_NULL;
|
||||
@@ -10903,12 +11084,14 @@ VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppDa
|
||||
VMA_ASSERT(GetType() == ALLOCATION_TYPE_DEDICATED);
|
||||
VMA_ASSERT(IsMappingAllowed() && "Mapping is not allowed on this allocation! Please use one of the new VMA_ALLOCATION_CREATE_HOST_ACCESS_* flags when creating it.");
|
||||
|
||||
EnsureExtraData(hAllocator);
|
||||
|
||||
if (m_MapCount != 0 || IsPersistentMap())
|
||||
{
|
||||
if (m_MapCount < 0xFF)
|
||||
{
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_pMappedData != VMA_NULL);
|
||||
*ppData = m_DedicatedAllocation.m_pMappedData;
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_ExtraData->m_pMappedData != VMA_NULL);
|
||||
*ppData = m_DedicatedAllocation.m_ExtraData->m_pMappedData;
|
||||
++m_MapCount;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@@ -10929,7 +11112,7 @@ VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppDa
|
||||
ppData);
|
||||
if (result == VK_SUCCESS)
|
||||
{
|
||||
m_DedicatedAllocation.m_pMappedData = *ppData;
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = *ppData;
|
||||
m_MapCount = 1;
|
||||
}
|
||||
return result;
|
||||
@@ -10945,7 +11128,8 @@ void VmaAllocation_T::DedicatedAllocUnmap(VmaAllocator hAllocator)
|
||||
--m_MapCount;
|
||||
if (m_MapCount == 0 && !IsPersistentMap())
|
||||
{
|
||||
m_DedicatedAllocation.m_pMappedData = VMA_NULL;
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_ExtraData != VMA_NULL);
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = VMA_NULL;
|
||||
(*hAllocator->GetVulkanFunctions().vkUnmapMemory)(
|
||||
hAllocator->m_hDevice,
|
||||
m_DedicatedAllocation.m_hMemory);
|
||||
@@ -10981,8 +11165,33 @@ void VmaAllocation_T::PrintParameters(class VmaJsonWriter& json) const
|
||||
json.WriteString(m_pName);
|
||||
}
|
||||
}
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult VmaAllocation_T::GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* pHandle) noexcept
|
||||
{
|
||||
auto pvkGetMemoryWin32HandleKHR = hAllocator->GetVulkanFunctions().vkGetMemoryWin32HandleKHR;
|
||||
switch (m_Type)
|
||||
{
|
||||
case ALLOCATION_TYPE_BLOCK:
|
||||
return m_BlockAllocation.m_Block->CreateWin32Handle(hAllocator, pvkGetMemoryWin32HandleKHR, hTargetProcess, pHandle);
|
||||
case ALLOCATION_TYPE_DEDICATED:
|
||||
EnsureExtraData(hAllocator);
|
||||
return m_DedicatedAllocation.m_ExtraData->m_Handle.GetHandle(hAllocator->m_hDevice, m_DedicatedAllocation.m_hMemory, pvkGetMemoryWin32HandleKHR, hTargetProcess, hAllocator->m_UseMutex, pHandle);
|
||||
default:
|
||||
VMA_ASSERT(0);
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
}
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // VMA_STATS_STRING_ENABLED
|
||||
|
||||
void VmaAllocation_T::EnsureExtraData(VmaAllocator hAllocator)
|
||||
{
|
||||
if (m_DedicatedAllocation.m_ExtraData == VMA_NULL)
|
||||
{
|
||||
m_DedicatedAllocation.m_ExtraData = vma_new(hAllocator, VmaAllocationExtraData)();
|
||||
}
|
||||
}
|
||||
|
||||
void VmaAllocation_T::FreeName(VmaAllocator hAllocator)
|
||||
{
|
||||
if(m_pName)
|
||||
@@ -11399,6 +11608,10 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
|
||||
}
|
||||
|
||||
IncrementallySortBlocks();
|
||||
|
||||
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
|
||||
hAllocation->Destroy(m_hAllocator);
|
||||
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
|
||||
}
|
||||
|
||||
// Destruction of a free block. Deferred until this point, outside of mutex
|
||||
@@ -11409,9 +11622,6 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
|
||||
pBlockToDelete->Destroy(m_hAllocator);
|
||||
vma_delete(m_hAllocator, pBlockToDelete);
|
||||
}
|
||||
|
||||
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
|
||||
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
|
||||
}
|
||||
|
||||
VkDeviceSize VmaBlockVector::CalcMaxBlockSize() const
|
||||
@@ -12711,6 +12921,7 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
||||
m_UseExtMemoryPriority((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT) != 0),
|
||||
m_UseKhrMaintenance4((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT) != 0),
|
||||
m_UseKhrMaintenance5((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT) != 0),
|
||||
m_UseKhrExternalMemoryWin32((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT) != 0),
|
||||
m_hDevice(pCreateInfo->device),
|
||||
m_hInstance(pCreateInfo->instance),
|
||||
m_AllocationCallbacksSpecified(pCreateInfo->pAllocationCallbacks != VMA_NULL),
|
||||
@@ -12802,6 +13013,19 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
#if !(VMA_KHR_MAINTENANCE5)
|
||||
if(m_UseKhrMaintenance5)
|
||||
{
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(VMA_EXTERNAL_MEMORY_WIN32)
|
||||
if(m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(&m_DeviceMemoryCallbacks, 0 ,sizeof(m_DeviceMemoryCallbacks));
|
||||
memset(&m_PhysicalDeviceProperties, 0, sizeof(m_PhysicalDeviceProperties));
|
||||
@@ -13026,7 +13250,9 @@ void VmaAllocator_T::ImportVulkanFunctions_Custom(const VmaVulkanFunctions* pVul
|
||||
VMA_COPY_IF_NOT_NULL(vkGetDeviceBufferMemoryRequirements);
|
||||
VMA_COPY_IF_NOT_NULL(vkGetDeviceImageMemoryRequirements);
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VMA_COPY_IF_NOT_NULL(vkGetMemoryWin32HandleKHR);
|
||||
#endif
|
||||
#undef VMA_COPY_IF_NOT_NULL
|
||||
}
|
||||
|
||||
@@ -13128,7 +13354,12 @@ void VmaAllocator_T::ImportVulkanFunctions_Dynamic()
|
||||
VMA_FETCH_DEVICE_FUNC(vkGetDeviceImageMemoryRequirements, PFN_vkGetDeviceImageMemoryRequirementsKHR, "vkGetDeviceImageMemoryRequirementsKHR");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
if (m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_FETCH_DEVICE_FUNC(vkGetMemoryWin32HandleKHR, PFN_vkGetMemoryWin32HandleKHR, "vkGetMemoryWin32HandleKHR");
|
||||
}
|
||||
#endif
|
||||
#undef VMA_FETCH_DEVICE_FUNC
|
||||
#undef VMA_FETCH_INSTANCE_FUNC
|
||||
}
|
||||
@@ -13177,6 +13408,12 @@ void VmaAllocator_T::ValidateVulkanFunctions()
|
||||
VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR != VMA_NULL);
|
||||
}
|
||||
#endif
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
if (m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_ASSERT(m_VulkanFunctions.vkGetMemoryWin32HandleKHR != VMA_NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Not validating these due to suspected driver bugs with these function
|
||||
// pointers being null despite correct extension or Vulkan version is enabled.
|
||||
@@ -13527,7 +13764,7 @@ VkResult VmaAllocator_T::AllocateDedicatedMemoryPage(
|
||||
}
|
||||
|
||||
*pAllocation = m_AllocationObjectAllocator.Allocate(isMappingAllowed);
|
||||
(*pAllocation)->InitDedicatedAllocation(pool, memTypeIndex, hMemory, suballocType, pMappedData, size);
|
||||
(*pAllocation)->InitDedicatedAllocation(this, pool, memTypeIndex, hMemory, suballocType, pMappedData, size);
|
||||
if (isUserDataString)
|
||||
(*pAllocation)->SetName(this, (const char*)pUserData);
|
||||
else
|
||||
@@ -13863,8 +14100,6 @@ void VmaAllocator_T::FreeMemory(
|
||||
FillAllocation(allocation, VMA_ALLOCATION_FILL_PATTERN_DESTROYED);
|
||||
}
|
||||
|
||||
allocation->FreeName(this);
|
||||
|
||||
switch(allocation->GetType())
|
||||
{
|
||||
case VmaAllocation_T::ALLOCATION_TYPE_BLOCK:
|
||||
@@ -14335,7 +14570,6 @@ VkResult VmaAllocator_T::Map(VmaAllocation hAllocation, void** ppData)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
VMA_FALLTHROUGH; // Fallthrough
|
||||
case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED:
|
||||
return hAllocation->DedicatedAllocMap(this, ppData);
|
||||
default:
|
||||
@@ -14549,6 +14783,7 @@ void VmaAllocator_T::FreeDedicatedMemory(const VmaAllocation allocation)
|
||||
FreeVulkanMemory(memTypeIndex, allocation->GetSize(), hMemory);
|
||||
|
||||
m_Budget.RemoveAllocation(MemoryTypeIndexToHeapIndex(allocation->GetMemoryTypeIndex()), allocation->GetSize());
|
||||
allocation->Destroy(this);
|
||||
m_AllocationObjectAllocator.Free(allocation);
|
||||
|
||||
VMA_DEBUG_LOG_FORMAT(" Freed DedicatedMemory MemoryTypeIndex=%" PRIu32, memTypeIndex);
|
||||
@@ -16169,7 +16404,7 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage(
|
||||
pImageCreateInfo,
|
||||
allocator->GetAllocationCallbacks(),
|
||||
pImage);
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
VmaSuballocationType suballocType = pImageCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL ?
|
||||
VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL :
|
||||
@@ -16194,14 +16429,14 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage(
|
||||
1, // allocationCount
|
||||
pAllocation);
|
||||
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
// 3. Bind image with memory.
|
||||
if((pAllocationCreateInfo->flags & VMA_ALLOCATION_CREATE_DONT_BIND_BIT) == 0)
|
||||
{
|
||||
res = allocator->BindImageMemory(*pAllocation, 0, *pImage, VMA_NULL);
|
||||
}
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
// All steps succeeded.
|
||||
#if VMA_STATS_STRING_ENABLED
|
||||
@@ -16434,6 +16669,15 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeVirtualBlockStatsString(VmaVirtualBlock V
|
||||
VmaFreeString(virtualBlock->GetAllocationCallbacks(), pStatsString);
|
||||
}
|
||||
}
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32Handle(VmaAllocator VMA_NOT_NULL allocator,
|
||||
VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle)
|
||||
{
|
||||
VMA_ASSERT(allocator && allocation && pHandle);
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK;
|
||||
return allocation->GetWin32Handle(allocator, hTargetProcess, pHandle);
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // VMA_STATS_STRING_ENABLED
|
||||
#endif // _VMA_PUBLIC_INTERFACE
|
||||
#endif // VMA_IMPLEMENTATION
|
||||
@@ -16567,6 +16811,7 @@ VK_EXT_memory_budget | #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT
|
||||
VK_KHR_buffer_device_address | #VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT
|
||||
VK_EXT_memory_priority | #VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT
|
||||
VK_AMD_device_coherent_memory | #VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT
|
||||
VK_KHR_external_memory_win32 | #VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT
|
||||
|
||||
Example with fetching pointers to Vulkan functions dynamically:
|
||||
|
||||
@@ -17053,7 +17298,7 @@ implementation whether the allocation succeeds or fails. You can change this beh
|
||||
by using #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag. With it, the allocation is
|
||||
not made if it would exceed the budget or if the budget is already exceeded.
|
||||
VMA then tries to make the allocation from the next eligible Vulkan memory type.
|
||||
The all of them fail, the call then fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
|
||||
If all of them fail, the call then fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
|
||||
Example usage pattern may be to pass the #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag
|
||||
when creating resources that are not essential for the application (e.g. the texture
|
||||
of a specific object) and not to pass it when creating critically important resources
|
||||
@@ -18193,7 +18438,8 @@ allocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT |
|
||||
VkBuffer buf;
|
||||
VmaAllocation alloc;
|
||||
VmaAllocationInfo allocInfo;
|
||||
vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);
|
||||
VkResult result = vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);
|
||||
// Check result...
|
||||
|
||||
VkMemoryPropertyFlags memPropFlags;
|
||||
vmaGetAllocationMemoryProperties(allocator, alloc, &memPropFlags);
|
||||
@@ -18204,10 +18450,24 @@ if(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
|
||||
// [Executed in runtime]:
|
||||
memcpy(allocInfo.pMappedData, myData, myDataSize);
|
||||
result = vmaFlushAllocation(allocator, alloc, 0, VK_WHOLE_SIZE);
|
||||
// Check result...
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
bufMemBarrier.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT;
|
||||
bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.buffer = buf;
|
||||
bufMemBarrier.offset = 0;
|
||||
bufMemBarrier.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allocation ended up in a non-mappable memory - need to transfer.
|
||||
// Allocation ended up in a non-mappable memory - a transfer using a staging buffer is required.
|
||||
VkBufferCreateInfo stagingBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
stagingBufCreateInfo.size = 65536;
|
||||
stagingBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
@@ -18220,18 +18480,46 @@ else
|
||||
VkBuffer stagingBuf;
|
||||
VmaAllocation stagingAlloc;
|
||||
VmaAllocationInfo stagingAllocInfo;
|
||||
vmaCreateBuffer(allocator, &stagingBufCreateInfo, &stagingAllocCreateInfo,
|
||||
&stagingBuf, &stagingAlloc, stagingAllocInfo);
|
||||
result = vmaCreateBuffer(allocator, &stagingBufCreateInfo, &stagingAllocCreateInfo,
|
||||
&stagingBuf, &stagingAlloc, &stagingAllocInfo);
|
||||
// Check result...
|
||||
|
||||
// [Executed in runtime]:
|
||||
memcpy(stagingAllocInfo.pMappedData, myData, myDataSize);
|
||||
vmaFlushAllocation(allocator, stagingAlloc, 0, VK_WHOLE_SIZE);
|
||||
//vkCmdPipelineBarrier: VK_ACCESS_HOST_WRITE_BIT --> VK_ACCESS_TRANSFER_READ_BIT
|
||||
result = vmaFlushAllocation(allocator, stagingAlloc, 0, VK_WHOLE_SIZE);
|
||||
// Check result...
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
bufMemBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.buffer = stagingBuf;
|
||||
bufMemBarrier.offset = 0;
|
||||
bufMemBarrier.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr);
|
||||
|
||||
VkBufferCopy bufCopy = {
|
||||
0, // srcOffset
|
||||
0, // dstOffset,
|
||||
myDataSize); // size
|
||||
myDataSize, // size
|
||||
};
|
||||
|
||||
vkCmdCopyBuffer(cmdBuf, stagingBuf, buf, 1, &bufCopy);
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier2 = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier2.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
bufMemBarrier2.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT; // We created a uniform buffer
|
||||
bufMemBarrier2.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier2.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier2.buffer = buf;
|
||||
bufMemBarrier2.offset = 0;
|
||||
bufMemBarrier2.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier2, 0, nullptr);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@@ -18264,14 +18552,22 @@ Please check "CONFIGURATION SECTION" in the code to find macros that you can def
|
||||
before each include of this file or change directly in this file to provide
|
||||
your own implementation of basic facilities like assert, `min()` and `max()` functions,
|
||||
mutex, atomic etc.
|
||||
The library uses its own implementation of containers by default, but you can switch to using
|
||||
STL containers instead.
|
||||
|
||||
For example, define `VMA_ASSERT(expr)` before including the library to provide
|
||||
custom implementation of the assertion, compatible with your project.
|
||||
By default it is defined to standard C `assert(expr)` in `_DEBUG` configuration
|
||||
and empty otherwise.
|
||||
|
||||
Similarly, you can define `VMA_LEAK_LOG_FORMAT` macro to enable printing of leaked (unfreed) allocations,
|
||||
including their names and other parameters. Example:
|
||||
|
||||
\code
|
||||
#define VMA_LEAK_LOG_FORMAT(format, ...) do { \
|
||||
printf((format), __VA_ARGS__); \
|
||||
printf("\n"); \
|
||||
} while(false)
|
||||
\endcode
|
||||
|
||||
\section config_Vulkan_functions Pointers to Vulkan functions
|
||||
|
||||
There are multiple ways to import pointers to Vulkan functions in the library.
|
||||
@@ -18526,6 +18822,145 @@ Example use of this extension can be found in the code of the sample and test su
|
||||
accompanying this library.
|
||||
|
||||
|
||||
\page vk_khr_external_memory_win32 VK_KHR_external_memory_win32
|
||||
|
||||
On Windows, the VK_KHR_external_memory_win32 device extension allows exporting a Win32 `HANDLE`
|
||||
of a `VkDeviceMemory` block, to be able to reference the memory on other Vulkan logical devices or instances,
|
||||
in multiple processes, and/or in multiple APIs.
|
||||
VMA offers support for it.
|
||||
|
||||
\section vk_khr_external_memory_win32_initialization Initialization
|
||||
|
||||
1) Make sure the extension is defined in the code by including following header before including VMA:
|
||||
|
||||
\code
|
||||
#include <vulkan/vulkan_win32.h>
|
||||
\endcode
|
||||
|
||||
2) Check if "VK_KHR_external_memory_win32" is available among device extensions.
|
||||
Enable it when creating the `VkDevice` object.
|
||||
|
||||
3) Enable the usage of this extension in VMA by setting flag #VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT
|
||||
when calling vmaCreateAllocator().
|
||||
|
||||
4) Make sure that VMA has access to the `vkGetMemoryWin32HandleKHR` function by either enabling `VMA_DYNAMIC_VULKAN_FUNCTIONS` macro
|
||||
or setting VmaVulkanFunctions::vkGetMemoryWin32HandleKHR explicitly.
|
||||
For more information, see \ref quick_start_initialization_importing_vulkan_functions.
|
||||
|
||||
\section vk_khr_external_memory_win32_preparations Preparations
|
||||
|
||||
You can find example usage among tests, in file "Tests.cpp", function `TestWin32Handles()`.
|
||||
|
||||
To use the extenion, buffers need to be created with `VkExternalMemoryBufferCreateInfoKHR` attached to their `pNext` chain,
|
||||
and memory allocations need to be made with `VkExportMemoryAllocateInfoKHR` attached to their `pNext` chain.
|
||||
To make use of them, you need to use \ref custom_memory_pools. Example:
|
||||
|
||||
\code
|
||||
// Define an example buffer and allocation parameters.
|
||||
VkExternalMemoryBufferCreateInfoKHR externalMemBufCreateInfo = {
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VkBufferCreateInfo exampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
exampleBufCreateInfo.size = 0x10000; // Doesn't matter here.
|
||||
exampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
exampleBufCreateInfo.pNext = &externalMemBufCreateInfo;
|
||||
|
||||
VmaAllocationCreateInfo exampleAllocCreateInfo = {};
|
||||
exampleAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
|
||||
|
||||
// Find memory type index to use for the custom pool.
|
||||
uint32_t memTypeIndex;
|
||||
VkResult res = vmaFindMemoryTypeIndexForBufferInfo(g_Allocator,
|
||||
&exampleBufCreateInfo, &exampleAllocCreateInfo, &memTypeIndex);
|
||||
// Check res...
|
||||
|
||||
// Create a custom pool.
|
||||
constexpr static VkExportMemoryAllocateInfoKHR exportMemAllocInfo = {
|
||||
VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VmaPoolCreateInfo poolCreateInfo = {};
|
||||
poolCreateInfo.memoryTypeIndex = memTypeIndex;
|
||||
poolCreateInfo.pMemoryAllocateNext = (void*)&exportMemAllocInfo;
|
||||
|
||||
VmaPool pool;
|
||||
res = vmaCreatePool(g_Allocator, &poolCreateInfo, &pool);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, don't forget to destroy it!
|
||||
vmaDestroyPool(g_Allocator, pool);
|
||||
\endcode
|
||||
|
||||
Note that the structure passed as VmaPoolCreateInfo::pMemoryAllocateNext must remain alive and unchanged
|
||||
for the whole lifetime of the custom pool, because it will be used when the pool allocates a new device memory block.
|
||||
No copy is made internally. This is why variable `exportMemAllocInfo` is defined as `static`.
|
||||
|
||||
\section vk_khr_external_memory_win32_memory_allocation Memory allocation
|
||||
|
||||
Finally, you can create a buffer with an allocation out of the custom pool.
|
||||
The buffer should use same flags as the sample buffer used to find the memory type.
|
||||
It should also specify `VkExternalMemoryBufferCreateInfoKHR` in its `pNext` chain.
|
||||
|
||||
\code
|
||||
VkExternalMemoryBufferCreateInfoKHR externalMemBufCreateInfo = {
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
bufCreateInfo.size = // Your desired buffer size.
|
||||
bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
bufCreateInfo.pNext = &externalMemBufCreateInfo;
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.pool = pool; // It is enough to set this one member.
|
||||
|
||||
VkBuffer buf;
|
||||
VmaAllocation alloc;
|
||||
res = vmaCreateBuffer(g_Allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, nullptr);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, don't forget to destroy it!
|
||||
vmaDestroyBuffer(g_Allocator, buf, alloc);
|
||||
\endcode
|
||||
|
||||
If you need each allocation to have its own device memory block and start at offset 0, you can still do
|
||||
by using #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT flag. It works also with custom pools.
|
||||
|
||||
\section vk_khr_external_memory_win32_exporting_win32_handle Exporting Win32 handle
|
||||
|
||||
After the allocation is created, you can acquire a Win32 `HANDLE` to the `VkDeviceMemory` block it belongs to.
|
||||
VMA function vmaGetMemoryWin32Handle() is a replacement of the Vulkan function `vkGetMemoryWin32HandleKHR`.
|
||||
|
||||
\code
|
||||
HANDLE handle;
|
||||
res = vmaGetMemoryWin32Handle(g_Allocator, alloc, nullptr, &handle);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, you must close the handle.
|
||||
CloseHandle(handle);
|
||||
\endcode
|
||||
|
||||
Documentation of the VK_KHR_external_memory_win32 extension states that:
|
||||
|
||||
> If handleType is defined as an NT handle, vkGetMemoryWin32HandleKHR must be called no more than once for each valid unique combination of memory and handleType.
|
||||
|
||||
This is ensured automatically inside VMA.
|
||||
The library fetches the handle on first use, remembers it internally, and closes it when the memory block or dedicated allocation is destroyed.
|
||||
Every time you call vmaGetMemoryWin32Handle(), VMA calls `DuplicateHandle` and returns a new handle that you need to close.
|
||||
|
||||
For further information, please check documentation of the vmaGetMemoryWin32Handle() function.
|
||||
|
||||
|
||||
\page enabling_buffer_device_address Enabling buffer device address
|
||||
|
||||
Device extension VK_KHR_buffer_device_address
|
||||
|
||||
523
3rdparty/vulkan/include/vulkan/vk_mem_alloc.h
vendored
523
3rdparty/vulkan/include/vulkan/vk_mem_alloc.h
vendored
@@ -95,6 +95,7 @@ See also: [product page on GPUOpen](https://gpuopen.com/gaming-product/vulkan-me
|
||||
- \subpage enabling_buffer_device_address
|
||||
- \subpage vk_ext_memory_priority
|
||||
- \subpage vk_amd_device_coherent_memory
|
||||
- \subpage vk_khr_external_memory_win32
|
||||
- \subpage general_considerations
|
||||
- [Thread safety](@ref general_considerations_thread_safety)
|
||||
- [Versioning and compatibility](@ref general_considerations_versioning_and_compatibility)
|
||||
@@ -127,7 +128,9 @@ See documentation chapter: \ref statistics.
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(VULKAN_H_)
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
||||
#if !defined(VMA_VULKAN_VERSION)
|
||||
#if defined(VK_VERSION_1_3)
|
||||
@@ -240,6 +243,15 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Defined to 1 when VK_KHR_external_memory_win32 device extension is defined in Vulkan headers.
|
||||
#if !defined(VMA_EXTERNAL_MEMORY_WIN32)
|
||||
#if VK_KHR_external_memory_win32
|
||||
#define VMA_EXTERNAL_MEMORY_WIN32 1
|
||||
#else
|
||||
#define VMA_EXTERNAL_MEMORY_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define these macros to decorate all public functions with additional code,
|
||||
// before and after returned type, appropriately. This may be useful for
|
||||
// exporting the functions when compiling VMA as a separate library. Example:
|
||||
@@ -459,6 +471,15 @@ typedef enum VmaAllocatorCreateFlagBits
|
||||
*/
|
||||
VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT = 0x00000100,
|
||||
|
||||
/**
|
||||
Enables usage of VK_KHR_external_memory_win32 extension in the library.
|
||||
|
||||
You should set this flag if you found available and enabled this device extension,
|
||||
while creating Vulkan device passed as VmaAllocatorCreateInfo::device.
|
||||
For more information, see \ref vk_khr_external_memory_win32.
|
||||
*/
|
||||
VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT = 0x00000200,
|
||||
|
||||
VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
|
||||
} VmaAllocatorCreateFlagBits;
|
||||
/// See #VmaAllocatorCreateFlagBits.
|
||||
@@ -1033,6 +1054,11 @@ typedef struct VmaVulkanFunctions
|
||||
/// Fetch from "vkGetDeviceImageMemoryRequirements" on Vulkan >= 1.3, but you can also fetch it from "vkGetDeviceImageMemoryRequirementsKHR" if you enabled extension VK_KHR_maintenance4.
|
||||
PFN_vkGetDeviceImageMemoryRequirementsKHR VMA_NULLABLE vkGetDeviceImageMemoryRequirements;
|
||||
#endif
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
PFN_vkGetMemoryWin32HandleKHR VMA_NULLABLE vkGetMemoryWin32HandleKHR;
|
||||
#else
|
||||
void* VMA_NULLABLE vkGetMemoryWin32HandleKHR;
|
||||
#endif
|
||||
} VmaVulkanFunctions;
|
||||
|
||||
/// Description of a Allocator to be created.
|
||||
@@ -1810,6 +1836,9 @@ VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool(
|
||||
\param allocator Allocator object.
|
||||
\param pool Pool object.
|
||||
\param[out] pPoolStats Statistics of specified pool.
|
||||
|
||||
Note that when using the pool from multiple threads, returned information may immediately
|
||||
become outdated.
|
||||
*/
|
||||
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStatistics(
|
||||
VmaAllocator VMA_NOT_NULL allocator,
|
||||
@@ -2050,6 +2079,40 @@ VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationMemoryProperties(
|
||||
VmaAllocation VMA_NOT_NULL allocation,
|
||||
VkMemoryPropertyFlags* VMA_NOT_NULL pFlags);
|
||||
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
/**
|
||||
\brief Given an allocation, returns Win32 handle that may be imported by other processes or APIs.
|
||||
|
||||
\param hTargetProcess Must be a valid handle to target process or null. If it's null, the function returns
|
||||
handle for the current process.
|
||||
\param[out] pHandle Output parameter that returns the handle.
|
||||
|
||||
The function fills `pHandle` with handle that can be used in target process.
|
||||
The handle is fetched using function `vkGetMemoryWin32HandleKHR`.
|
||||
When no longer needed, you must close it using:
|
||||
|
||||
\code
|
||||
CloseHandle(handle);
|
||||
\endcode
|
||||
|
||||
You can close it any time, before or after destroying the allocation object.
|
||||
It is reference-counted internally by Windows.
|
||||
|
||||
Note the handle is returned for the entire `VkDeviceMemory` block that the allocation belongs to.
|
||||
If the allocation is sub-allocated from a larger block, you may need to consider the offset of the allocation
|
||||
(VmaAllocationInfo::offset).
|
||||
|
||||
If the function fails with `VK_ERROR_FEATURE_NOT_PRESENT` error code, please double-check
|
||||
that VmaVulkanFunctions::vkGetMemoryWin32HandleKHR function pointer is set, e.g. either by using `VMA_DYNAMIC_VULKAN_FUNCTIONS`
|
||||
or by manually passing it through VmaAllocatorCreateInfo::pVulkanFunctions.
|
||||
|
||||
For more information, see chapter \ref vk_khr_external_memory_win32.
|
||||
*/
|
||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32Handle(VmaAllocator VMA_NOT_NULL allocator,
|
||||
VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle);
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
/** \brief Maps memory represented by given allocation and returns pointer to it.
|
||||
|
||||
Maps memory represented by given allocation to make it accessible to CPU code.
|
||||
@@ -3097,7 +3160,7 @@ static void vma_aligned_free(void* VMA_NULLABLE ptr)
|
||||
std::shared_mutex m_Mutex;
|
||||
};
|
||||
#define VMA_RW_MUTEX VmaRWMutex
|
||||
#elif defined(_WIN32) && defined(WINVER) && WINVER >= 0x0600
|
||||
#elif defined(_WIN32) && defined(WINVER) && defined(SRWLOCK_INIT) && WINVER >= 0x0600
|
||||
// Use SRWLOCK from WinAPI.
|
||||
// Minimum supported client = Windows Vista, server = Windows Server 2008.
|
||||
class VmaRWMutex
|
||||
@@ -3838,12 +3901,6 @@ struct VmaBufferImageUsage
|
||||
|
||||
const VmaBufferImageUsage VmaBufferImageUsage::UNKNOWN = VmaBufferImageUsage(0);
|
||||
|
||||
static void swap(VmaBufferImageUsage& lhs, VmaBufferImageUsage& rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs.Value, rhs.Value);
|
||||
}
|
||||
|
||||
VmaBufferImageUsage::VmaBufferImageUsage(const VkBufferCreateInfo &createInfo,
|
||||
bool useKhrMaintenance5)
|
||||
{
|
||||
@@ -6073,6 +6130,84 @@ private:
|
||||
|
||||
#endif // _VMA_MAPPING_HYSTERESIS
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
class VmaWin32Handle
|
||||
{
|
||||
public:
|
||||
VmaWin32Handle() noexcept : m_hHandle(VMA_NULL) { }
|
||||
explicit VmaWin32Handle(HANDLE hHandle) noexcept : m_hHandle(hHandle) { }
|
||||
~VmaWin32Handle() noexcept { if (m_hHandle != VMA_NULL) { ::CloseHandle(m_hHandle); } }
|
||||
VMA_CLASS_NO_COPY_NO_MOVE(VmaWin32Handle)
|
||||
|
||||
public:
|
||||
// Strengthened
|
||||
VkResult GetHandle(VkDevice device, VkDeviceMemory memory, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE hTargetProcess, bool useMutex, HANDLE* pHandle) noexcept
|
||||
{
|
||||
*pHandle = VMA_NULL;
|
||||
// Try to get handle first.
|
||||
if (m_hHandle != VMA_NULL)
|
||||
{
|
||||
*pHandle = Duplicate(hTargetProcess);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult res = VK_SUCCESS;
|
||||
// If failed, try to create it.
|
||||
{
|
||||
VmaMutexLockWrite lock(m_Mutex, useMutex);
|
||||
if (m_hHandle == VMA_NULL)
|
||||
{
|
||||
res = Create(device, memory, pvkGetMemoryWin32HandleKHR, &m_hHandle);
|
||||
}
|
||||
}
|
||||
|
||||
*pHandle = Duplicate(hTargetProcess);
|
||||
return res;
|
||||
}
|
||||
|
||||
operator bool() const noexcept { return m_hHandle != VMA_NULL; }
|
||||
private:
|
||||
// Not atomic
|
||||
static VkResult Create(VkDevice device, VkDeviceMemory memory, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE* pHandle) noexcept
|
||||
{
|
||||
VkResult res = VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
if (pvkGetMemoryWin32HandleKHR != VMA_NULL)
|
||||
{
|
||||
VkMemoryGetWin32HandleInfoKHR handleInfo{ };
|
||||
handleInfo.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR;
|
||||
handleInfo.memory = memory;
|
||||
handleInfo.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR;
|
||||
res = pvkGetMemoryWin32HandleKHR(device, &handleInfo, pHandle);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
HANDLE Duplicate(HANDLE hTargetProcess = VMA_NULL) const noexcept
|
||||
{
|
||||
if (!m_hHandle)
|
||||
return m_hHandle;
|
||||
|
||||
HANDLE hCurrentProcess = ::GetCurrentProcess();
|
||||
HANDLE hDupHandle = VMA_NULL;
|
||||
if (!::DuplicateHandle(hCurrentProcess, m_hHandle, hTargetProcess ? hTargetProcess : hCurrentProcess, &hDupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
VMA_ASSERT(0 && "Failed to duplicate handle.");
|
||||
}
|
||||
return hDupHandle;
|
||||
}
|
||||
private:
|
||||
HANDLE m_hHandle;
|
||||
VMA_RW_MUTEX m_Mutex; // Protects access m_Handle
|
||||
};
|
||||
#else
|
||||
class VmaWin32Handle
|
||||
{
|
||||
// ABI compatibility
|
||||
void* placeholder = VMA_NULL;
|
||||
VMA_RW_MUTEX placeholder2;
|
||||
};
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
|
||||
#ifndef _VMA_DEVICE_MEMORY_BLOCK
|
||||
/*
|
||||
Represents a single block of device memory (`VkDeviceMemory`) with all the
|
||||
@@ -6139,7 +6274,13 @@ public:
|
||||
VkDeviceSize allocationLocalOffset,
|
||||
VkImage hImage,
|
||||
const void* pNext);
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult CreateWin32Handle(
|
||||
const VmaAllocator hAllocator,
|
||||
PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR,
|
||||
HANDLE hTargetProcess,
|
||||
HANDLE* pHandle)noexcept;
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
private:
|
||||
VmaPool m_hParentPool; // VK_NULL_HANDLE if not belongs to custom pool.
|
||||
uint32_t m_MemoryTypeIndex;
|
||||
@@ -6155,10 +6296,18 @@ private:
|
||||
VmaMappingHysteresis m_MappingHysteresis;
|
||||
uint32_t m_MapCount;
|
||||
void* m_pMappedData;
|
||||
|
||||
VmaWin32Handle m_Handle;
|
||||
};
|
||||
#endif // _VMA_DEVICE_MEMORY_BLOCK
|
||||
|
||||
#ifndef _VMA_ALLOCATION_T
|
||||
struct VmaAllocationExtraData
|
||||
{
|
||||
void* m_pMappedData = VMA_NULL; // Not null means memory is mapped.
|
||||
VmaWin32Handle m_Handle;
|
||||
};
|
||||
|
||||
struct VmaAllocation_T
|
||||
{
|
||||
friend struct VmaDedicatedAllocationListItemTraits;
|
||||
@@ -6191,12 +6340,14 @@ public:
|
||||
bool mapped);
|
||||
// pMappedData not null means allocation is created with MAPPED flag.
|
||||
void InitDedicatedAllocation(
|
||||
VmaAllocator allocator,
|
||||
VmaPool hParentPool,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkDeviceMemory hMemory,
|
||||
VmaSuballocationType suballocationType,
|
||||
void* pMappedData,
|
||||
VkDeviceSize size);
|
||||
void Destroy(VmaAllocator allocator);
|
||||
|
||||
ALLOCATION_TYPE GetType() const { return (ALLOCATION_TYPE)m_Type; }
|
||||
VkDeviceSize GetAlignment() const { return m_Alignment; }
|
||||
@@ -6240,6 +6391,10 @@ public:
|
||||
void PrintParameters(class VmaJsonWriter& json) const;
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* hHandle) noexcept;
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
|
||||
private:
|
||||
// Allocation out of VmaDeviceMemoryBlock.
|
||||
struct BlockAllocation
|
||||
@@ -6252,7 +6407,7 @@ private:
|
||||
{
|
||||
VmaPool m_hParentPool; // VK_NULL_HANDLE if not belongs to custom pool.
|
||||
VkDeviceMemory m_hMemory;
|
||||
void* m_pMappedData; // Not null means memory is mapped.
|
||||
VmaAllocationExtraData* m_ExtraData;
|
||||
VmaAllocation_T* m_Prev;
|
||||
VmaAllocation_T* m_Next;
|
||||
};
|
||||
@@ -6277,6 +6432,8 @@ private:
|
||||
#if VMA_STATS_STRING_ENABLED
|
||||
VmaBufferImageUsage m_BufferImageUsage; // 0 if unknown.
|
||||
#endif
|
||||
|
||||
void EnsureExtraData(VmaAllocator hAllocator);
|
||||
};
|
||||
#endif // _VMA_ALLOCATION_T
|
||||
|
||||
@@ -10075,6 +10232,7 @@ public:
|
||||
bool m_UseExtMemoryPriority;
|
||||
bool m_UseKhrMaintenance4;
|
||||
bool m_UseKhrMaintenance5;
|
||||
bool m_UseKhrExternalMemoryWin32;
|
||||
const VkDevice m_hDevice;
|
||||
const VkInstance m_hInstance;
|
||||
const bool m_AllocationCallbacksSpecified;
|
||||
@@ -10438,7 +10596,7 @@ VmaDeviceMemoryBlock::VmaDeviceMemoryBlock(VmaAllocator hAllocator)
|
||||
m_Id(0),
|
||||
m_hMemory(VK_NULL_HANDLE),
|
||||
m_MapCount(0),
|
||||
m_pMappedData(VMA_NULL) {}
|
||||
m_pMappedData(VMA_NULL){}
|
||||
|
||||
VmaDeviceMemoryBlock::~VmaDeviceMemoryBlock()
|
||||
{
|
||||
@@ -10681,6 +10839,14 @@ VkResult VmaDeviceMemoryBlock::BindImageMemory(
|
||||
VmaMutexLock lock(m_MapAndBindMutex, hAllocator->m_UseMutex);
|
||||
return hAllocator->BindVulkanImage(m_hMemory, memoryOffset, hImage, pNext);
|
||||
}
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult VmaDeviceMemoryBlock::CreateWin32Handle(const VmaAllocator hAllocator, PFN_vkGetMemoryWin32HandleKHR pvkGetMemoryWin32HandleKHR, HANDLE hTargetProcess, HANDLE* pHandle) noexcept
|
||||
{
|
||||
VMA_ASSERT(pHandle);
|
||||
return m_Handle.GetHandle(hAllocator->m_hDevice, m_hMemory, pvkGetMemoryWin32HandleKHR, hTargetProcess, hAllocator->m_UseMutex, pHandle);
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // _VMA_DEVICE_MEMORY_BLOCK_FUNCTIONS
|
||||
|
||||
#ifndef _VMA_ALLOCATION_T_FUNCTIONS
|
||||
@@ -10733,6 +10899,7 @@ void VmaAllocation_T::InitBlockAllocation(
|
||||
}
|
||||
|
||||
void VmaAllocation_T::InitDedicatedAllocation(
|
||||
VmaAllocator allocator,
|
||||
VmaPool hParentPool,
|
||||
uint32_t memoryTypeIndex,
|
||||
VkDeviceMemory hMemory,
|
||||
@@ -10747,16 +10914,29 @@ void VmaAllocation_T::InitDedicatedAllocation(
|
||||
m_Size = size;
|
||||
m_MemoryTypeIndex = memoryTypeIndex;
|
||||
m_SuballocationType = (uint8_t)suballocationType;
|
||||
if(pMappedData != VMA_NULL)
|
||||
m_DedicatedAllocation.m_ExtraData = VMA_NULL;
|
||||
m_DedicatedAllocation.m_hParentPool = hParentPool;
|
||||
m_DedicatedAllocation.m_hMemory = hMemory;
|
||||
m_DedicatedAllocation.m_Prev = VMA_NULL;
|
||||
m_DedicatedAllocation.m_Next = VMA_NULL;
|
||||
|
||||
if (pMappedData != VMA_NULL)
|
||||
{
|
||||
VMA_ASSERT(IsMappingAllowed() && "Mapping is not allowed on this allocation! Please use one of the new VMA_ALLOCATION_CREATE_HOST_ACCESS_* flags when creating it.");
|
||||
m_Flags |= (uint8_t)FLAG_PERSISTENT_MAP;
|
||||
EnsureExtraData(allocator);
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = pMappedData;
|
||||
}
|
||||
}
|
||||
|
||||
void VmaAllocation_T::Destroy(VmaAllocator allocator)
|
||||
{
|
||||
FreeName(allocator);
|
||||
|
||||
if (GetType() == ALLOCATION_TYPE_DEDICATED)
|
||||
{
|
||||
vma_delete(allocator, m_DedicatedAllocation.m_ExtraData);
|
||||
}
|
||||
m_DedicatedAllocation.m_hParentPool = hParentPool;
|
||||
m_DedicatedAllocation.m_hMemory = hMemory;
|
||||
m_DedicatedAllocation.m_pMappedData = pMappedData;
|
||||
m_DedicatedAllocation.m_Prev = VMA_NULL;
|
||||
m_DedicatedAllocation.m_Next = VMA_NULL;
|
||||
}
|
||||
|
||||
void VmaAllocation_T::SetName(VmaAllocator hAllocator, const char* pName)
|
||||
@@ -10861,8 +11041,9 @@ void* VmaAllocation_T::GetMappedData() const
|
||||
}
|
||||
break;
|
||||
case ALLOCATION_TYPE_DEDICATED:
|
||||
VMA_ASSERT((m_DedicatedAllocation.m_pMappedData != VMA_NULL) == (m_MapCount != 0 || IsPersistentMap()));
|
||||
return m_DedicatedAllocation.m_pMappedData;
|
||||
VMA_ASSERT((m_DedicatedAllocation.m_ExtraData != VMA_NULL && m_DedicatedAllocation.m_ExtraData->m_pMappedData != VMA_NULL) ==
|
||||
(m_MapCount != 0 || IsPersistentMap()));
|
||||
return m_DedicatedAllocation.m_ExtraData != VMA_NULL ? m_DedicatedAllocation.m_ExtraData->m_pMappedData : VMA_NULL;
|
||||
default:
|
||||
VMA_ASSERT(0);
|
||||
return VMA_NULL;
|
||||
@@ -10903,12 +11084,14 @@ VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppDa
|
||||
VMA_ASSERT(GetType() == ALLOCATION_TYPE_DEDICATED);
|
||||
VMA_ASSERT(IsMappingAllowed() && "Mapping is not allowed on this allocation! Please use one of the new VMA_ALLOCATION_CREATE_HOST_ACCESS_* flags when creating it.");
|
||||
|
||||
EnsureExtraData(hAllocator);
|
||||
|
||||
if (m_MapCount != 0 || IsPersistentMap())
|
||||
{
|
||||
if (m_MapCount < 0xFF)
|
||||
{
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_pMappedData != VMA_NULL);
|
||||
*ppData = m_DedicatedAllocation.m_pMappedData;
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_ExtraData->m_pMappedData != VMA_NULL);
|
||||
*ppData = m_DedicatedAllocation.m_ExtraData->m_pMappedData;
|
||||
++m_MapCount;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@@ -10929,7 +11112,7 @@ VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppDa
|
||||
ppData);
|
||||
if (result == VK_SUCCESS)
|
||||
{
|
||||
m_DedicatedAllocation.m_pMappedData = *ppData;
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = *ppData;
|
||||
m_MapCount = 1;
|
||||
}
|
||||
return result;
|
||||
@@ -10945,7 +11128,8 @@ void VmaAllocation_T::DedicatedAllocUnmap(VmaAllocator hAllocator)
|
||||
--m_MapCount;
|
||||
if (m_MapCount == 0 && !IsPersistentMap())
|
||||
{
|
||||
m_DedicatedAllocation.m_pMappedData = VMA_NULL;
|
||||
VMA_ASSERT(m_DedicatedAllocation.m_ExtraData != VMA_NULL);
|
||||
m_DedicatedAllocation.m_ExtraData->m_pMappedData = VMA_NULL;
|
||||
(*hAllocator->GetVulkanFunctions().vkUnmapMemory)(
|
||||
hAllocator->m_hDevice,
|
||||
m_DedicatedAllocation.m_hMemory);
|
||||
@@ -10981,8 +11165,33 @@ void VmaAllocation_T::PrintParameters(class VmaJsonWriter& json) const
|
||||
json.WriteString(m_pName);
|
||||
}
|
||||
}
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VkResult VmaAllocation_T::GetWin32Handle(VmaAllocator hAllocator, HANDLE hTargetProcess, HANDLE* pHandle) noexcept
|
||||
{
|
||||
auto pvkGetMemoryWin32HandleKHR = hAllocator->GetVulkanFunctions().vkGetMemoryWin32HandleKHR;
|
||||
switch (m_Type)
|
||||
{
|
||||
case ALLOCATION_TYPE_BLOCK:
|
||||
return m_BlockAllocation.m_Block->CreateWin32Handle(hAllocator, pvkGetMemoryWin32HandleKHR, hTargetProcess, pHandle);
|
||||
case ALLOCATION_TYPE_DEDICATED:
|
||||
EnsureExtraData(hAllocator);
|
||||
return m_DedicatedAllocation.m_ExtraData->m_Handle.GetHandle(hAllocator->m_hDevice, m_DedicatedAllocation.m_hMemory, pvkGetMemoryWin32HandleKHR, hTargetProcess, hAllocator->m_UseMutex, pHandle);
|
||||
default:
|
||||
VMA_ASSERT(0);
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
}
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // VMA_STATS_STRING_ENABLED
|
||||
|
||||
void VmaAllocation_T::EnsureExtraData(VmaAllocator hAllocator)
|
||||
{
|
||||
if (m_DedicatedAllocation.m_ExtraData == VMA_NULL)
|
||||
{
|
||||
m_DedicatedAllocation.m_ExtraData = vma_new(hAllocator, VmaAllocationExtraData)();
|
||||
}
|
||||
}
|
||||
|
||||
void VmaAllocation_T::FreeName(VmaAllocator hAllocator)
|
||||
{
|
||||
if(m_pName)
|
||||
@@ -11399,6 +11608,10 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
|
||||
}
|
||||
|
||||
IncrementallySortBlocks();
|
||||
|
||||
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
|
||||
hAllocation->Destroy(m_hAllocator);
|
||||
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
|
||||
}
|
||||
|
||||
// Destruction of a free block. Deferred until this point, outside of mutex
|
||||
@@ -11409,9 +11622,6 @@ void VmaBlockVector::Free(const VmaAllocation hAllocation)
|
||||
pBlockToDelete->Destroy(m_hAllocator);
|
||||
vma_delete(m_hAllocator, pBlockToDelete);
|
||||
}
|
||||
|
||||
m_hAllocator->m_Budget.RemoveAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), hAllocation->GetSize());
|
||||
m_hAllocator->m_AllocationObjectAllocator.Free(hAllocation);
|
||||
}
|
||||
|
||||
VkDeviceSize VmaBlockVector::CalcMaxBlockSize() const
|
||||
@@ -12711,6 +12921,7 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
||||
m_UseExtMemoryPriority((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT) != 0),
|
||||
m_UseKhrMaintenance4((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT) != 0),
|
||||
m_UseKhrMaintenance5((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT) != 0),
|
||||
m_UseKhrExternalMemoryWin32((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT) != 0),
|
||||
m_hDevice(pCreateInfo->device),
|
||||
m_hInstance(pCreateInfo->instance),
|
||||
m_AllocationCallbacksSpecified(pCreateInfo->pAllocationCallbacks != VMA_NULL),
|
||||
@@ -12802,6 +13013,19 @@ VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) :
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
#if !(VMA_KHR_MAINTENANCE5)
|
||||
if(m_UseKhrMaintenance5)
|
||||
{
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(VMA_EXTERNAL_MEMORY_WIN32)
|
||||
if(m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT is set but required extension is not available in your Vulkan header or its support in VMA has been disabled by a preprocessor macro.");
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(&m_DeviceMemoryCallbacks, 0 ,sizeof(m_DeviceMemoryCallbacks));
|
||||
memset(&m_PhysicalDeviceProperties, 0, sizeof(m_PhysicalDeviceProperties));
|
||||
@@ -13026,7 +13250,9 @@ void VmaAllocator_T::ImportVulkanFunctions_Custom(const VmaVulkanFunctions* pVul
|
||||
VMA_COPY_IF_NOT_NULL(vkGetDeviceBufferMemoryRequirements);
|
||||
VMA_COPY_IF_NOT_NULL(vkGetDeviceImageMemoryRequirements);
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VMA_COPY_IF_NOT_NULL(vkGetMemoryWin32HandleKHR);
|
||||
#endif
|
||||
#undef VMA_COPY_IF_NOT_NULL
|
||||
}
|
||||
|
||||
@@ -13128,7 +13354,12 @@ void VmaAllocator_T::ImportVulkanFunctions_Dynamic()
|
||||
VMA_FETCH_DEVICE_FUNC(vkGetDeviceImageMemoryRequirements, PFN_vkGetDeviceImageMemoryRequirementsKHR, "vkGetDeviceImageMemoryRequirementsKHR");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
if (m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_FETCH_DEVICE_FUNC(vkGetMemoryWin32HandleKHR, PFN_vkGetMemoryWin32HandleKHR, "vkGetMemoryWin32HandleKHR");
|
||||
}
|
||||
#endif
|
||||
#undef VMA_FETCH_DEVICE_FUNC
|
||||
#undef VMA_FETCH_INSTANCE_FUNC
|
||||
}
|
||||
@@ -13177,6 +13408,12 @@ void VmaAllocator_T::ValidateVulkanFunctions()
|
||||
VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR != VMA_NULL);
|
||||
}
|
||||
#endif
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
if (m_UseKhrExternalMemoryWin32)
|
||||
{
|
||||
VMA_ASSERT(m_VulkanFunctions.vkGetMemoryWin32HandleKHR != VMA_NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Not validating these due to suspected driver bugs with these function
|
||||
// pointers being null despite correct extension or Vulkan version is enabled.
|
||||
@@ -13527,7 +13764,7 @@ VkResult VmaAllocator_T::AllocateDedicatedMemoryPage(
|
||||
}
|
||||
|
||||
*pAllocation = m_AllocationObjectAllocator.Allocate(isMappingAllowed);
|
||||
(*pAllocation)->InitDedicatedAllocation(pool, memTypeIndex, hMemory, suballocType, pMappedData, size);
|
||||
(*pAllocation)->InitDedicatedAllocation(this, pool, memTypeIndex, hMemory, suballocType, pMappedData, size);
|
||||
if (isUserDataString)
|
||||
(*pAllocation)->SetName(this, (const char*)pUserData);
|
||||
else
|
||||
@@ -13863,8 +14100,6 @@ void VmaAllocator_T::FreeMemory(
|
||||
FillAllocation(allocation, VMA_ALLOCATION_FILL_PATTERN_DESTROYED);
|
||||
}
|
||||
|
||||
allocation->FreeName(this);
|
||||
|
||||
switch(allocation->GetType())
|
||||
{
|
||||
case VmaAllocation_T::ALLOCATION_TYPE_BLOCK:
|
||||
@@ -14335,7 +14570,6 @@ VkResult VmaAllocator_T::Map(VmaAllocation hAllocation, void** ppData)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
VMA_FALLTHROUGH; // Fallthrough
|
||||
case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED:
|
||||
return hAllocation->DedicatedAllocMap(this, ppData);
|
||||
default:
|
||||
@@ -14549,6 +14783,7 @@ void VmaAllocator_T::FreeDedicatedMemory(const VmaAllocation allocation)
|
||||
FreeVulkanMemory(memTypeIndex, allocation->GetSize(), hMemory);
|
||||
|
||||
m_Budget.RemoveAllocation(MemoryTypeIndexToHeapIndex(allocation->GetMemoryTypeIndex()), allocation->GetSize());
|
||||
allocation->Destroy(this);
|
||||
m_AllocationObjectAllocator.Free(allocation);
|
||||
|
||||
VMA_DEBUG_LOG_FORMAT(" Freed DedicatedMemory MemoryTypeIndex=%" PRIu32, memTypeIndex);
|
||||
@@ -16169,7 +16404,7 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage(
|
||||
pImageCreateInfo,
|
||||
allocator->GetAllocationCallbacks(),
|
||||
pImage);
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
VmaSuballocationType suballocType = pImageCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL ?
|
||||
VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL :
|
||||
@@ -16194,14 +16429,14 @@ VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage(
|
||||
1, // allocationCount
|
||||
pAllocation);
|
||||
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
// 3. Bind image with memory.
|
||||
if((pAllocationCreateInfo->flags & VMA_ALLOCATION_CREATE_DONT_BIND_BIT) == 0)
|
||||
{
|
||||
res = allocator->BindImageMemory(*pAllocation, 0, *pImage, VMA_NULL);
|
||||
}
|
||||
if(res >= 0)
|
||||
if(res == VK_SUCCESS)
|
||||
{
|
||||
// All steps succeeded.
|
||||
#if VMA_STATS_STRING_ENABLED
|
||||
@@ -16434,6 +16669,15 @@ VMA_CALL_PRE void VMA_CALL_POST vmaFreeVirtualBlockStatsString(VmaVirtualBlock V
|
||||
VmaFreeString(virtualBlock->GetAllocationCallbacks(), pStatsString);
|
||||
}
|
||||
}
|
||||
#if VMA_EXTERNAL_MEMORY_WIN32
|
||||
VMA_CALL_PRE VkResult VMA_CALL_POST vmaGetMemoryWin32Handle(VmaAllocator VMA_NOT_NULL allocator,
|
||||
VmaAllocation VMA_NOT_NULL allocation, HANDLE hTargetProcess, HANDLE* VMA_NOT_NULL pHandle)
|
||||
{
|
||||
VMA_ASSERT(allocator && allocation && pHandle);
|
||||
VMA_DEBUG_GLOBAL_MUTEX_LOCK;
|
||||
return allocation->GetWin32Handle(allocator, hTargetProcess, pHandle);
|
||||
}
|
||||
#endif // VMA_EXTERNAL_MEMORY_WIN32
|
||||
#endif // VMA_STATS_STRING_ENABLED
|
||||
#endif // _VMA_PUBLIC_INTERFACE
|
||||
#endif // VMA_IMPLEMENTATION
|
||||
@@ -16567,6 +16811,7 @@ VK_EXT_memory_budget | #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT
|
||||
VK_KHR_buffer_device_address | #VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT
|
||||
VK_EXT_memory_priority | #VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT
|
||||
VK_AMD_device_coherent_memory | #VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT
|
||||
VK_KHR_external_memory_win32 | #VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT
|
||||
|
||||
Example with fetching pointers to Vulkan functions dynamically:
|
||||
|
||||
@@ -17053,7 +17298,7 @@ implementation whether the allocation succeeds or fails. You can change this beh
|
||||
by using #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag. With it, the allocation is
|
||||
not made if it would exceed the budget or if the budget is already exceeded.
|
||||
VMA then tries to make the allocation from the next eligible Vulkan memory type.
|
||||
The all of them fail, the call then fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
|
||||
If all of them fail, the call then fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`.
|
||||
Example usage pattern may be to pass the #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag
|
||||
when creating resources that are not essential for the application (e.g. the texture
|
||||
of a specific object) and not to pass it when creating critically important resources
|
||||
@@ -18193,7 +18438,8 @@ allocCreateInfo.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT |
|
||||
VkBuffer buf;
|
||||
VmaAllocation alloc;
|
||||
VmaAllocationInfo allocInfo;
|
||||
vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);
|
||||
VkResult result = vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo);
|
||||
// Check result...
|
||||
|
||||
VkMemoryPropertyFlags memPropFlags;
|
||||
vmaGetAllocationMemoryProperties(allocator, alloc, &memPropFlags);
|
||||
@@ -18204,10 +18450,24 @@ if(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
|
||||
// [Executed in runtime]:
|
||||
memcpy(allocInfo.pMappedData, myData, myDataSize);
|
||||
result = vmaFlushAllocation(allocator, alloc, 0, VK_WHOLE_SIZE);
|
||||
// Check result...
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
bufMemBarrier.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT;
|
||||
bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.buffer = buf;
|
||||
bufMemBarrier.offset = 0;
|
||||
bufMemBarrier.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allocation ended up in a non-mappable memory - need to transfer.
|
||||
// Allocation ended up in a non-mappable memory - a transfer using a staging buffer is required.
|
||||
VkBufferCreateInfo stagingBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
stagingBufCreateInfo.size = 65536;
|
||||
stagingBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
@@ -18220,18 +18480,46 @@ else
|
||||
VkBuffer stagingBuf;
|
||||
VmaAllocation stagingAlloc;
|
||||
VmaAllocationInfo stagingAllocInfo;
|
||||
vmaCreateBuffer(allocator, &stagingBufCreateInfo, &stagingAllocCreateInfo,
|
||||
&stagingBuf, &stagingAlloc, stagingAllocInfo);
|
||||
result = vmaCreateBuffer(allocator, &stagingBufCreateInfo, &stagingAllocCreateInfo,
|
||||
&stagingBuf, &stagingAlloc, &stagingAllocInfo);
|
||||
// Check result...
|
||||
|
||||
// [Executed in runtime]:
|
||||
memcpy(stagingAllocInfo.pMappedData, myData, myDataSize);
|
||||
vmaFlushAllocation(allocator, stagingAlloc, 0, VK_WHOLE_SIZE);
|
||||
//vkCmdPipelineBarrier: VK_ACCESS_HOST_WRITE_BIT --> VK_ACCESS_TRANSFER_READ_BIT
|
||||
result = vmaFlushAllocation(allocator, stagingAlloc, 0, VK_WHOLE_SIZE);
|
||||
// Check result...
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
bufMemBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier.buffer = stagingBuf;
|
||||
bufMemBarrier.offset = 0;
|
||||
bufMemBarrier.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr);
|
||||
|
||||
VkBufferCopy bufCopy = {
|
||||
0, // srcOffset
|
||||
0, // dstOffset,
|
||||
myDataSize); // size
|
||||
myDataSize, // size
|
||||
};
|
||||
|
||||
vkCmdCopyBuffer(cmdBuf, stagingBuf, buf, 1, &bufCopy);
|
||||
|
||||
VkBufferMemoryBarrier bufMemBarrier2 = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER };
|
||||
bufMemBarrier2.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
bufMemBarrier2.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT; // We created a uniform buffer
|
||||
bufMemBarrier2.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier2.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
bufMemBarrier2.buffer = buf;
|
||||
bufMemBarrier2.offset = 0;
|
||||
bufMemBarrier2.size = VK_WHOLE_SIZE;
|
||||
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
|
||||
0, 0, nullptr, 1, &bufMemBarrier2, 0, nullptr);
|
||||
}
|
||||
\endcode
|
||||
|
||||
@@ -18264,14 +18552,22 @@ Please check "CONFIGURATION SECTION" in the code to find macros that you can def
|
||||
before each include of this file or change directly in this file to provide
|
||||
your own implementation of basic facilities like assert, `min()` and `max()` functions,
|
||||
mutex, atomic etc.
|
||||
The library uses its own implementation of containers by default, but you can switch to using
|
||||
STL containers instead.
|
||||
|
||||
For example, define `VMA_ASSERT(expr)` before including the library to provide
|
||||
custom implementation of the assertion, compatible with your project.
|
||||
By default it is defined to standard C `assert(expr)` in `_DEBUG` configuration
|
||||
and empty otherwise.
|
||||
|
||||
Similarly, you can define `VMA_LEAK_LOG_FORMAT` macro to enable printing of leaked (unfreed) allocations,
|
||||
including their names and other parameters. Example:
|
||||
|
||||
\code
|
||||
#define VMA_LEAK_LOG_FORMAT(format, ...) do { \
|
||||
printf((format), __VA_ARGS__); \
|
||||
printf("\n"); \
|
||||
} while(false)
|
||||
\endcode
|
||||
|
||||
\section config_Vulkan_functions Pointers to Vulkan functions
|
||||
|
||||
There are multiple ways to import pointers to Vulkan functions in the library.
|
||||
@@ -18526,6 +18822,145 @@ Example use of this extension can be found in the code of the sample and test su
|
||||
accompanying this library.
|
||||
|
||||
|
||||
\page vk_khr_external_memory_win32 VK_KHR_external_memory_win32
|
||||
|
||||
On Windows, the VK_KHR_external_memory_win32 device extension allows exporting a Win32 `HANDLE`
|
||||
of a `VkDeviceMemory` block, to be able to reference the memory on other Vulkan logical devices or instances,
|
||||
in multiple processes, and/or in multiple APIs.
|
||||
VMA offers support for it.
|
||||
|
||||
\section vk_khr_external_memory_win32_initialization Initialization
|
||||
|
||||
1) Make sure the extension is defined in the code by including following header before including VMA:
|
||||
|
||||
\code
|
||||
#include <vulkan/vulkan_win32.h>
|
||||
\endcode
|
||||
|
||||
2) Check if "VK_KHR_external_memory_win32" is available among device extensions.
|
||||
Enable it when creating the `VkDevice` object.
|
||||
|
||||
3) Enable the usage of this extension in VMA by setting flag #VMA_ALLOCATOR_CREATE_KHR_EXTERNAL_MEMORY_WIN32_BIT
|
||||
when calling vmaCreateAllocator().
|
||||
|
||||
4) Make sure that VMA has access to the `vkGetMemoryWin32HandleKHR` function by either enabling `VMA_DYNAMIC_VULKAN_FUNCTIONS` macro
|
||||
or setting VmaVulkanFunctions::vkGetMemoryWin32HandleKHR explicitly.
|
||||
For more information, see \ref quick_start_initialization_importing_vulkan_functions.
|
||||
|
||||
\section vk_khr_external_memory_win32_preparations Preparations
|
||||
|
||||
You can find example usage among tests, in file "Tests.cpp", function `TestWin32Handles()`.
|
||||
|
||||
To use the extenion, buffers need to be created with `VkExternalMemoryBufferCreateInfoKHR` attached to their `pNext` chain,
|
||||
and memory allocations need to be made with `VkExportMemoryAllocateInfoKHR` attached to their `pNext` chain.
|
||||
To make use of them, you need to use \ref custom_memory_pools. Example:
|
||||
|
||||
\code
|
||||
// Define an example buffer and allocation parameters.
|
||||
VkExternalMemoryBufferCreateInfoKHR externalMemBufCreateInfo = {
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VkBufferCreateInfo exampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
exampleBufCreateInfo.size = 0x10000; // Doesn't matter here.
|
||||
exampleBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
exampleBufCreateInfo.pNext = &externalMemBufCreateInfo;
|
||||
|
||||
VmaAllocationCreateInfo exampleAllocCreateInfo = {};
|
||||
exampleAllocCreateInfo.usage = VMA_MEMORY_USAGE_AUTO;
|
||||
|
||||
// Find memory type index to use for the custom pool.
|
||||
uint32_t memTypeIndex;
|
||||
VkResult res = vmaFindMemoryTypeIndexForBufferInfo(g_Allocator,
|
||||
&exampleBufCreateInfo, &exampleAllocCreateInfo, &memTypeIndex);
|
||||
// Check res...
|
||||
|
||||
// Create a custom pool.
|
||||
constexpr static VkExportMemoryAllocateInfoKHR exportMemAllocInfo = {
|
||||
VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VmaPoolCreateInfo poolCreateInfo = {};
|
||||
poolCreateInfo.memoryTypeIndex = memTypeIndex;
|
||||
poolCreateInfo.pMemoryAllocateNext = (void*)&exportMemAllocInfo;
|
||||
|
||||
VmaPool pool;
|
||||
res = vmaCreatePool(g_Allocator, &poolCreateInfo, &pool);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, don't forget to destroy it!
|
||||
vmaDestroyPool(g_Allocator, pool);
|
||||
\endcode
|
||||
|
||||
Note that the structure passed as VmaPoolCreateInfo::pMemoryAllocateNext must remain alive and unchanged
|
||||
for the whole lifetime of the custom pool, because it will be used when the pool allocates a new device memory block.
|
||||
No copy is made internally. This is why variable `exportMemAllocInfo` is defined as `static`.
|
||||
|
||||
\section vk_khr_external_memory_win32_memory_allocation Memory allocation
|
||||
|
||||
Finally, you can create a buffer with an allocation out of the custom pool.
|
||||
The buffer should use same flags as the sample buffer used to find the memory type.
|
||||
It should also specify `VkExternalMemoryBufferCreateInfoKHR` in its `pNext` chain.
|
||||
|
||||
\code
|
||||
VkExternalMemoryBufferCreateInfoKHR externalMemBufCreateInfo = {
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR,
|
||||
nullptr,
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT
|
||||
};
|
||||
VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
bufCreateInfo.size = // Your desired buffer size.
|
||||
bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
bufCreateInfo.pNext = &externalMemBufCreateInfo;
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.pool = pool; // It is enough to set this one member.
|
||||
|
||||
VkBuffer buf;
|
||||
VmaAllocation alloc;
|
||||
res = vmaCreateBuffer(g_Allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, nullptr);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, don't forget to destroy it!
|
||||
vmaDestroyBuffer(g_Allocator, buf, alloc);
|
||||
\endcode
|
||||
|
||||
If you need each allocation to have its own device memory block and start at offset 0, you can still do
|
||||
by using #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT flag. It works also with custom pools.
|
||||
|
||||
\section vk_khr_external_memory_win32_exporting_win32_handle Exporting Win32 handle
|
||||
|
||||
After the allocation is created, you can acquire a Win32 `HANDLE` to the `VkDeviceMemory` block it belongs to.
|
||||
VMA function vmaGetMemoryWin32Handle() is a replacement of the Vulkan function `vkGetMemoryWin32HandleKHR`.
|
||||
|
||||
\code
|
||||
HANDLE handle;
|
||||
res = vmaGetMemoryWin32Handle(g_Allocator, alloc, nullptr, &handle);
|
||||
// Check res...
|
||||
|
||||
// YOUR OTHER CODE COMES HERE....
|
||||
|
||||
// At the end, you must close the handle.
|
||||
CloseHandle(handle);
|
||||
\endcode
|
||||
|
||||
Documentation of the VK_KHR_external_memory_win32 extension states that:
|
||||
|
||||
> If handleType is defined as an NT handle, vkGetMemoryWin32HandleKHR must be called no more than once for each valid unique combination of memory and handleType.
|
||||
|
||||
This is ensured automatically inside VMA.
|
||||
The library fetches the handle on first use, remembers it internally, and closes it when the memory block or dedicated allocation is destroyed.
|
||||
Every time you call vmaGetMemoryWin32Handle(), VMA calls `DuplicateHandle` and returns a new handle that you need to close.
|
||||
|
||||
For further information, please check documentation of the vmaGetMemoryWin32Handle() function.
|
||||
|
||||
|
||||
\page enabling_buffer_device_address Enabling buffer device address
|
||||
|
||||
Device extension VK_KHR_buffer_device_address
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -176,8 +176,6 @@
|
||||
030000004f04000020b3000000000000,Dual Trigger,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,
|
||||
03000000bd12000002e0000000000000,Dual Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,
|
||||
03000000ff1100003133000000000000,DualForce,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b1,platform:Windows,
|
||||
030000008f0e00000910000000000000,Sony DualShock 2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,
|
||||
03000000317300000100000000000000,Sony DualShock 3,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,
|
||||
030000006f0e00003001000000000000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000fc0400000250000000000000,Easy Grip,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,start:b9,x:b3,y:b4,platform:Windows,
|
||||
03000000bc2000000091000000000000,EasySMX Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
@@ -247,6 +245,7 @@
|
||||
03000000f025000031c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000f0250000c383000000000000,Gioteck VX2 PlayStation Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000f0250000c483000000000000,Gioteck VX2 PlayStation Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000d11800000094000000000000,Google Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,
|
||||
030000004f04000026b3000000000000,GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
0300000079000000d418000000000000,GPD Win,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000c6240000025b000000000000,GPX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
@@ -489,13 +488,6 @@
|
||||
030000006f0e00000901000000000000,PDP PS3 Versus Fighting,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,
|
||||
030000006f0e00008901000000000000,PDP Realmz Nintendo Switch Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
030000008f0e00004100000000000000,PlaySega,a:b1,b:b0,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b7,rightshoulder:b5,righttrigger:b2,start:b8,x:b4,y:b3,platform:Windows,
|
||||
03000000666600006706000000000000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,
|
||||
03000000e30500009605000000000000,Sony PlayStation Adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||
030000004c050000da0c000000000000,Sony PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000632500002306000000000000,Sony PlayStation Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,
|
||||
03000000f0250000c183000000000000,Sony PlayStation Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000d9040000160f000000000000,Sony PlayStation Controller Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||
030000004c0500003713000000000000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000d620000011a7000000000000,PowerA Core Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000dd62000015a7000000000000,PowerA Fusion Nintendo Switch Arcade Stick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000d620000012a7000000000000,PowerA Fusion Nintendo Switch Fight Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
@@ -601,6 +593,7 @@
|
||||
030000009b2800002c00000000000000,Raphnet Wii Classic Adapter,a:b1,b:b4,back:b2,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a3,righty:a4,start:b3,x:b0,y:b5,platform:Windows,
|
||||
030000009b2800008000000000000000,Raphnet Wii Classic Adapter,a:b1,b:b4,back:b2,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a3,righty:a4,start:b3,x:b0,y:b5,platform:Windows,
|
||||
03000000790000008f18000000000000,Rapoo Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
0300000032150000a602000000000000,Razer Huntsman V3 Pro,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b12,dpright:b13,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000f8270000bf0b000000000000,Razer Kishi,a:b6,b:b7,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b18,leftshoulder:b12,leftstick:b19,lefttrigger:b14,leftx:a0,lefty:a1,rightshoulder:b13,rightstick:b20,righttrigger:b15,rightx:a3,righty:a4,start:b17,x:b9,y:b10,platform:Windows,
|
||||
03000000321500000204000000000000,Razer Panthera PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
@@ -685,13 +678,21 @@
|
||||
03000000811700009d0a000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows,
|
||||
030000008b2800000300000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows,
|
||||
03000000921200004653000000000000,SNES Controller,a:b0,b:b4,back:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Windows,
|
||||
030000008f0e00000910000000000000,Sony DualShock 2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,
|
||||
03000000317300000100000000000000,Sony DualShock 3,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,
|
||||
03000000666600006706000000000000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,
|
||||
03000000e30500009605000000000000,Sony PlayStation Adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,
|
||||
030000004c050000da0c000000000000,Sony PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000632500002306000000000000,Sony PlayStation Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,
|
||||
03000000f0250000c183000000000000,Sony PlayStation Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000d9040000160f000000000000,Sony PlayStation Controller Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000ff000000cb01000000000000,Sony PlayStation Portable,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Windows,
|
||||
030000004c0500003713000000000000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,
|
||||
03000000341a00000208000000000000,Speedlink 6555,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000341a00000908000000000000,Speedlink 6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||
03000000380700001722000000000000,Speedlink Competition Pro,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,x:b2,y:b3,platform:Windows,
|
||||
030000008f0e00000800000000000000,Speedlink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000d11800000094000000000000,Google Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,
|
||||
03000000de280000fc11000000000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000de280000ff11000000000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000120c0000160e000000000000,Steel Play Metaltech PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Windows,
|
||||
@@ -701,7 +702,6 @@
|
||||
03000000381000003014000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000381000003114000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows,
|
||||
03000000790000001c18000000000000,STK 7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||
03000000380700003847000000000000,Street Fighter Fightstick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b10,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b11,start:b7,x:b2,y:b3,platform:Windows,
|
||||
030000001f08000001e4000000000000,Super Famicom Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000790000000418000000000000,Super Famicom Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b33,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Windows,
|
||||
@@ -716,7 +716,8 @@
|
||||
03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,
|
||||
03000000ba2200000701000000000000,Technology Innovation PS2 Adapter,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b2,platform:Windows,
|
||||
03000000c61100001000000000000000,Tencent Xianyou Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,x:b3,y:b4,platform:Windows,
|
||||
03000000790000002601000000000000,TGZ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000790000001c18000000000000,TGZ Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,
|
||||
03000000790000002601000000000000,TGZ Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b3,y:b0,platform:Windows,
|
||||
03000000591c00002400000000000000,THEC64 Joystick,a:b0,b:b1,back:b6,leftshoulder:b4,leftx:a0,lefty:a4,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Windows,
|
||||
03000000591c00002600000000000000,THEGamepad,a:b2,b:b1,back:b6,leftx:a0,lefty:a1,start:b7,x:b3,y:b0,platform:Windows,
|
||||
030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,
|
||||
@@ -883,7 +884,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
03000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a31,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||
03000000491900001904000001010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,
|
||||
0300000008100000e501000019040000,Anbernic Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||
0300000008100000e501000019040000,Anbernic Handheld,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a4,start:b11,x:b4,y:b3,platform:Mac OS X,
|
||||
03000000373500004610000001000000,Anbernic RG P01,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b15,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||
03000000a30c00002700000003030000,Astro City Mini,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||
03000000a30c00002800000003030000,Astro City Mini,a:b2,b:b1,back:b8,leftx:a3,lefty:a4,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||
@@ -920,6 +921,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
03000000c01100000140000000010000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Mac OS X,
|
||||
030000006f0e00000102000000000000,GameStop Xbox 360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000ff1100003133000007010000,GameWare PC Control Pad,a:b2,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b0,platform:Mac OS X,
|
||||
03000000d11800000094000000010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||
030000007d0400000540000001010000,Gravis Eliminator Pro,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
03000000280400000140000000020000,Gravis GamePad Pro,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
030000008f0e00000300000007010000,GreenAsia Joystick,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Mac OS X,
|
||||
@@ -996,11 +998,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
030000007e0500001720000001000000,NSO SNES Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b15,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000550900001472000025050000,NVIDIA Controller,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Mac OS X,
|
||||
030000004b120000014d000000010000,Nyko Airflo EX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000790000001c18000000010000,PB Tails Choc,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,
|
||||
030000006f0e00000901000002010000,PDP PS3 Versus Fighting,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
030000008f0e00000300000000000000,Piranha Xtreme PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||
03000000666600006706000088020000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Mac OS X,
|
||||
030000004c050000da0c000000010000,Sony PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||
030000004c0500003713000000010000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
03000000d620000011a7000000020000,PowerA Core Plus Gamecube Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000d620000011a7000010050000,PowerA Nintendo Switch Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
@@ -1053,7 +1053,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,
|
||||
030000004c050000a00b000000000000,Sony DualShock 4 Adapter,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Mac OS X,
|
||||
030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Mac OS X,
|
||||
03000000d11800000094000000010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000666600006706000088020000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Mac OS X,
|
||||
030000004c050000da0c000000010000,Sony PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,
|
||||
030000004c0500003713000000010000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,
|
||||
03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,
|
||||
@@ -1207,10 +1209,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
05000000491900000204000021000000,Amazon Fire Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000491900001904000011010000,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,platform:Linux,
|
||||
05000000710100001904000000010000,Amazon Luna Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,
|
||||
0300000008100000e501000001010000,Anbernic Gamepad,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a4,start:b11,x:b3,y:b4,platform:Linux,
|
||||
0300000008100000e501000001010000,Anbernic Handheld,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a4,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000020500000913000010010000,Anbernic RG P01,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000373500000710000010010000,Anbernic RG P01,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
030000005e0400008e02000072050000,Anbernic RG P01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
05000000373500004610000001000000,Anbernic RG P01,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b15,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||
03000000a30c00002700000011010000,Astro City Mini,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,rightshoulder:b4,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||
@@ -1284,6 +1285,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
190000004b4800000010000001010000,GO-Advance Controller,a:b1,b:b0,back:b12,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,leftshoulder:b4,leftstick:b13,lefttrigger:b14,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b16,righttrigger:b15,start:b17,x:b2,y:b3,platform:Linux,
|
||||
190000004b4800000011000000010000,GO-Super Controller,a:b1,b:b0,back:b12,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b16,leftshoulder:b4,leftstick:b14,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b2,y:b3,platform:Linux,
|
||||
03000000f0250000c183000010010000,Goodbetterbest Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
03000000d11800000094000011010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
05000000d11800000094000000010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400008e02000001010000,GPD Win Max 2 6800U Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000007d0400000540000000010000,Gravis Eliminator Pro,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,
|
||||
@@ -1299,7 +1302,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
030000000d0f00008400000011010000,Hori Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||
030000000d0f00005f00000011010000,Hori Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
030000000d0f00005e00000011010000,Hori Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
030000000d0f00005001000009040000,Hori Fighting Commander OCTA Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000000d0f00005001000009040000,Hori Fighting Commander Octa Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000000d0f00008500000010010000,Hori Fighting Commander PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
030000000d0f00008600000002010000,Hori Fighting Commander Xbox 360,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||
030000000d0f00003701000013010000,Hori Fighting Stick Mini,a:b1,b:b0,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b3,y:b2,platform:Linux,
|
||||
@@ -1344,6 +1347,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
03000000632500007505000011010000,Ipega PG 9099,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,
|
||||
0500000049190000030400001b010000,Ipega PG9099,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
05000000491900000204000000000000,Ipega PG9118,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000300f00001101000010010000,Jess Tech Colour Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
|
||||
03000000300f00001001000010010000,Jess Tech Dual Analog Rumble,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,
|
||||
03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||
03000000ba2200002010000001010000,Jess Technology Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||
@@ -1494,10 +1498,6 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
030000006f0e0000a702000023020000,PDP Xbox One Raven Black,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000006f0e0000d802000006640000,PDP Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000006f0e0000ef02000007640000,PDP Xbox Series Kinetic Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000666600006706000000010000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,
|
||||
030000004c050000da0c000011010000,Sony PlayStation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||
03000000d9040000160f000000010000,Sony PlayStation Controller Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||
030000004c0500003713000011010000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
|
||||
03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000d620000011a7000011010000,PowerA Core Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
@@ -1534,8 +1534,8 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||
060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||
030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
030000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
@@ -1552,9 +1552,11 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b14,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
030000004c050000e60c000011810000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000004c050000f20d000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b14,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
030000004c050000f20d000011810000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
050000004c050000e60c000000810000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
050000004c050000f20d000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
050000004c050000f20d000000810000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,
|
||||
03000000300f00001211000011010000,Qanba Arcade Joystick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,
|
||||
03000000222c00000225000011010000,Qanba Dragon Arcade Joystick PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
03000000222c00000025000011010000,Qanba Dragon Arcade Joystick PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
@@ -1631,12 +1633,14 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
03000000341a00000908000010010000,SL6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||
030000004b2900000430000011000000,Snakebyte Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
050000004c050000cc09000001000000,Sony DualShock 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,touchpad:b13,x:b0,y:b3,platform:Linux,
|
||||
03000000666600006706000000010000,Sony PlayStation Adapter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,
|
||||
030000004c050000da0c000011010000,Sony PlayStation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,
|
||||
03000000d9040000160f000000010000,Sony PlayStation Controller Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||
03000000ff000000cb01000010010000,Sony PlayStation Portable,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000004c0500003713000011010000,Sony PlayStation Vita,a:b1,b:b2,back:b8,dpdown:b13,dpleft:b15,dpright:b14,dpup:b12,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,
|
||||
03000000250900000500000000010000,Sony PS2 pad with SmartJoy Adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,
|
||||
030000005e0400008e02000073050000,Speedlink Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400008e02000020200000,SpeedLink Xeox Pro Analog,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000d11800000094000011010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
05000000d11800000094000000010000,Google Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000de2800000112000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:+a5,dpleft:-a4,dpright:+a4,dpup:-a5,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,
|
||||
03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
@@ -1666,7 +1670,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
03000000e40a00000307000011010000,Taito Egret II Mini Control Panel,a:b4,b:b2,back:b6,guide:b9,leftx:a0,lefty:a1,rightshoulder:b0,righttrigger:b1,start:b7,x:b8,y:b3,platform:Linux,
|
||||
03000000e40a00000207000011010000,Taito Egret II Mini Controller,a:b4,b:b2,back:b6,guide:b9,leftx:a0,lefty:a1,rightshoulder:b0,righttrigger:b1,start:b7,x:b8,y:b3,platform:Linux,
|
||||
03000000ba2200000701000001010000,Technology Innovation PS2 Adapter,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a5,righty:a2,start:b9,x:b3,y:b2,platform:Linux,
|
||||
03000000790000001c18000011010000,TGZ Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000790000001c18000011010000,TGZ Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
03000000591c00002400000010010000,THEC64 Joystick,a:b0,b:b1,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000591c00002600000010010000,THEGamepad,a:b2,b:b1,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux,
|
||||
030000004f04000015b3000001010000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,
|
||||
@@ -1715,10 +1719,11 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
030000006f0e00001503000000020000,Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400008e02000000010000,Xbox 360 EasySMX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000a102000014010000,Xbox 360 Receiver,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
0000000058626f782047616d65706100,Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400000202000000010000,Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||
030000005e0400008e02000072050000,Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000006f0e00001304000000010000,Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000ffff0000ffff000000010000,Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,
|
||||
0000000058626f782047616d65706100,Xbox Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400000a0b000005040000,Xbox One Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,
|
||||
030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000ea02000000000000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
@@ -1730,9 +1735,9 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,
|
||||
050000005e040000220b000013050000,Xbox One Elite 2 Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
050000005e040000050b000002090000,Xbox One Elite Series 2,a:b0,b:b1,back:b136,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,
|
||||
030000005e040000ea02000011050000,Xbox One S Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000ea02000015050000,Xbox One S Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
060000005e040000ea0200000b050000,Xbox One S Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
060000005e040000ea0200000d050000,Xbox One S Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000ea02000015050000,Xbox One S Controller,a:b0,b:b1,x:b2,y:b3,back:b6,guide:b8,start:b7,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
|
||||
060000005e040000ea02000016050000,Xbox One S Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000120b000001050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e040000120b000005050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
|
||||
@@ -453,6 +453,11 @@ std::string Path::RealPath(const std::string_view path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any relative symlinks were resolved, there may be '.' and '..'
|
||||
// components in the resultant path, which must be removed.
|
||||
realpath = Path::Canonicalize(realpath);
|
||||
|
||||
#endif
|
||||
|
||||
return realpath;
|
||||
@@ -994,6 +999,37 @@ std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode, Error*
|
||||
#endif
|
||||
}
|
||||
|
||||
std::FILE* FileSystem::OpenCFileTryIgnoreCase(const char* filename, const char* mode, Error* error)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
return OpenCFile(filename, mode, error);
|
||||
#else
|
||||
std::FILE* fp = std::fopen(filename, mode);
|
||||
const auto cur_errno = errno;
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
const auto dir = std::string(Path::GetDirectory(filename));
|
||||
FindResultsArray files;
|
||||
if (FindFiles(dir.c_str(), "*", FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES, &files))
|
||||
{
|
||||
for (auto& file : files)
|
||||
{
|
||||
if (StringUtil::compareNoCase(file.FileName, filename))
|
||||
{
|
||||
fp = std::fopen(file.FileName.c_str(), mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fp)
|
||||
Error::SetErrno(error, cur_errno);
|
||||
return fp;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int FileSystem::OpenFDFile(const char* filename, int flags, int mode, Error* error)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -1015,6 +1051,11 @@ FileSystem::ManagedCFilePtr FileSystem::OpenManagedCFile(const char* filename, c
|
||||
return ManagedCFilePtr(OpenCFile(filename, mode, error));
|
||||
}
|
||||
|
||||
FileSystem::ManagedCFilePtr FileSystem::OpenManagedCFileTryIgnoreCase(const char* filename, const char* mode, Error* error)
|
||||
{
|
||||
return ManagedCFilePtr(OpenCFileTryIgnoreCase(filename, mode, error));
|
||||
}
|
||||
|
||||
std::FILE* FileSystem::OpenSharedCFile(const char* filename, const char* mode, FileShareMode share_mode, Error* error)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -1189,6 +1230,14 @@ size_t FileSystem::ReadFileWithProgress(std::FILE* fp, void* dst, size_t length,
|
||||
{
|
||||
progress->SetProgressRange(100);
|
||||
|
||||
return FileSystem::ReadFileWithPartialProgress(fp, dst, length, progress, 0, 100, error, chunk_size);
|
||||
}
|
||||
|
||||
size_t FileSystem::ReadFileWithPartialProgress(std::FILE* fp, void* dst, size_t length,
|
||||
ProgressCallback* progress, int startPercent, int endPercent, Error* error, size_t chunk_size)
|
||||
{
|
||||
const int deltaPercent = endPercent - startPercent;
|
||||
|
||||
size_t done = 0;
|
||||
while (done < length)
|
||||
{
|
||||
@@ -1202,7 +1251,7 @@ size_t FileSystem::ReadFileWithProgress(std::FILE* fp, void* dst, size_t length,
|
||||
break;
|
||||
}
|
||||
|
||||
progress->SetProgressValue((done * 100) / length);
|
||||
progress->SetProgressValue(startPercent + (done * deltaPercent) / length);
|
||||
done += read_size;
|
||||
}
|
||||
|
||||
@@ -1925,6 +1974,26 @@ bool FileSystem::SetPathCompression(const char* path, bool enable)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FileSystem::CreateSymLink(const char* link, const char* target)
|
||||
{
|
||||
// convert to wide string
|
||||
const std::wstring wlink = GetWin32Path(link);
|
||||
if (wlink.empty())
|
||||
return false;
|
||||
|
||||
const std::wstring wtarget = GetWin32Path(target);
|
||||
if (wtarget.empty())
|
||||
return false;
|
||||
|
||||
// check if it's a directory
|
||||
DWORD flags = 0;
|
||||
if (DirectoryExists(target))
|
||||
flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
|
||||
|
||||
// create the symbolic link
|
||||
return CreateSymbolicLinkW(wlink.c_str(), wtarget.c_str(), flags) != 0;
|
||||
}
|
||||
|
||||
bool FileSystem::IsSymbolicLink(const char* path)
|
||||
{
|
||||
// convert to wide string
|
||||
@@ -2505,6 +2574,11 @@ bool FileSystem::SetPathCompression(const char* path, bool enable)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSystem::CreateSymLink(const char* link, const char* target)
|
||||
{
|
||||
return symlink(target, link) == 0;
|
||||
}
|
||||
|
||||
bool FileSystem::IsSymbolicLink(const char* path)
|
||||
{
|
||||
struct stat sysStatData;
|
||||
|
||||
@@ -106,7 +106,16 @@ namespace FileSystem
|
||||
/// open files
|
||||
using ManagedCFilePtr = std::unique_ptr<std::FILE, FileDeleter>;
|
||||
ManagedCFilePtr OpenManagedCFile(const char* filename, const char* mode, Error* error = nullptr);
|
||||
// Tries to open a file using the given filename, but if that fails searches
|
||||
// the directory for a file with a case-insensitive match.
|
||||
// This is the same as OpenManagedCFile on Windows and MacOS
|
||||
ManagedCFilePtr OpenManagedCFileTryIgnoreCase(const char* filename, const char* mode, Error* error = nullptr);
|
||||
std::FILE* OpenCFile(const char* filename, const char* mode, Error* error = nullptr);
|
||||
// Tries to open a file using the given filename, but if that fails searches
|
||||
// the directory for a file with a case-insensitive match.
|
||||
// This is the same as OpenCFile on Windows and MacOS
|
||||
std::FILE* OpenCFileTryIgnoreCase(const char* filename, const char* mode, Error* error = nullptr);
|
||||
|
||||
int FSeek64(std::FILE* fp, s64 offset, int whence);
|
||||
s64 FTell64(std::FILE* fp);
|
||||
s64 FSize64(std::FILE* fp);
|
||||
@@ -135,6 +144,8 @@ namespace FileSystem
|
||||
bool WriteStringToFile(const char* filename, const std::string_view sv);
|
||||
size_t ReadFileWithProgress(std::FILE* fp, void* dst, size_t length, ProgressCallback* progress,
|
||||
Error* error = nullptr, size_t chunk_size = 16 * 1024 * 1024);
|
||||
size_t ReadFileWithPartialProgress(std::FILE* fp, void* dst, size_t length, ProgressCallback* progress,
|
||||
int startPercent, int endPercent, Error* error = nullptr, size_t chunk_size = 16 * 1024 * 1024);
|
||||
|
||||
/// creates a directory in the local filesystem
|
||||
/// if the directory already exists, the return value will be true.
|
||||
@@ -169,6 +180,10 @@ namespace FileSystem
|
||||
/// Does nothing and returns false on non-Windows platforms.
|
||||
bool SetPathCompression(const char* path, bool enable);
|
||||
|
||||
// Creates a symbolic link. Note that on Windows this requires elevated
|
||||
// privileges so this is mostly useful for testing purposes.
|
||||
bool CreateSymLink(const char* link, const char* target);
|
||||
|
||||
/// Checks if a file or directory is a symbolic link.
|
||||
bool IsSymbolicLink(const char* path);
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@
|
||||
|
||||
<!-- MSVC automatically adds __AVX__ and __AVX2__ appropriately -->
|
||||
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_M_X86;__SSE4_1__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet Condition="!$(Configuration.Contains(AVX2)) Or $(Configuration.Contains(Clang))">NotSet</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet Condition="$(Configuration.Contains(AVX2)) And !$(Configuration.Contains(Clang))">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='ARM64' Or !$(Configuration.Contains(AVX2))">NotSet</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='x64' And $(Configuration.Contains(AVX2))">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<!-- Allow SSE4 intrinsics on non-AVX Clang-cl builds -->
|
||||
<AdditionalOptions Condition="'$(Platform)'=='x64' And $(Configuration.Contains(Clang)) And !$(Configuration.Contains(AVX2))"> -march=nehalem %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Platform)'=='x64' And $(Configuration.Contains(Clang)) And $(Configuration.Contains(AVX2))"> -march=haswell %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Platform)'=='ARM64' And $(Configuration.Contains(Clang))"> -march=armv8.4-a %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="!$(Configuration.Contains(Clang))">%(AdditionalOptions) /Zc:externConstexpr /Zc:__cplusplus /Zo /utf-8</AdditionalOptions>
|
||||
|
||||
|
||||
@@ -88,8 +88,6 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.interlacing, "EmuCore/GS", "deinterlace_mode", DEFAULT_INTERLACE_MODE);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(
|
||||
sif, m_ui.bilinearFiltering, "EmuCore/GS", "linear_present_mode", static_cast<int>(GSPostBilinearMode::BilinearSmooth));
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.widescreenPatches, "EmuCore", "EnableWideScreenPatches", false);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.noInterlacingPatches, "EmuCore", "EnableNoInterlacingPatches", false);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.integerScaling, "EmuCore/GS", "IntegerScaling", false);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.PCRTCOffsets, "EmuCore/GS", "pcrtc_offsets", false);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.PCRTCOverscan, "EmuCore/GS", "pcrtc_overscan", false);
|
||||
@@ -321,24 +319,22 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get rid of widescreen/no-interlace checkboxes from per-game settings, unless the user previously had them set.
|
||||
if (m_dialog->isPerGameSettings())
|
||||
// Prompt user to get rid of widescreen/no-interlace config from the ini if the user has enabled them before.
|
||||
if ((m_dialog->getBoolValue("EmuCore", "EnableWideScreenPatches", false) == true ||
|
||||
m_dialog->getBoolValue("EmuCore", "EnableWideScreenPatches", false) == true) &&
|
||||
!m_dialog->containsSettingValue("UI", "UserHasDeniedWSPatchWarning"))
|
||||
{
|
||||
if ((m_dialog->containsSettingValue("EmuCore", "EnableWideScreenPatches") || m_dialog->containsSettingValue("EmuCore", "EnableNoInterlacingPatches")) &&
|
||||
QMessageBox::question(QtUtils::GetRootWidget(this), tr("Remove Unsupported Settings"),
|
||||
tr("You currently have the <strong>Enable Widescreen Patches</strong> or <strong>Enable No-Interlacing Patches</strong> options enabled for this game.<br><br>"
|
||||
"We no longer support these options, instead <strong>you should select the \"Patches\" section, and explicitly enable the patches you want.</strong><br><br>"
|
||||
"Do you want to remove these options from your game configuration now?"),
|
||||
if (QMessageBox::question(QtUtils::GetRootWidget(this), tr("Remove Unsupported Settings"),
|
||||
tr("You previously had the <strong>Enable Widescreen Patches</strong> or <strong>Enable No-Interlacing Patches</strong> options enabled.<br><br>"
|
||||
"We no longer provide these options, instead <strong>you should go to the \"Patches\" section on the per-game settings, and explicitly enable the patches that you want.</strong><br><br>"
|
||||
"Do you want to remove these options from your configuration now?"),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
m_dialog->removeSettingValue("EmuCore", "EnableWideScreenPatches");
|
||||
m_dialog->removeSettingValue("EmuCore", "EnableNoInterlacingPatches");
|
||||
}
|
||||
|
||||
m_ui.displayGridLayout->removeWidget(m_ui.widescreenPatches);
|
||||
m_ui.displayGridLayout->removeWidget(m_ui.noInterlacingPatches);
|
||||
safe_delete(m_ui.widescreenPatches);
|
||||
safe_delete(m_ui.noInterlacingPatches);
|
||||
else
|
||||
m_dialog->setBoolSettingValue("UI", "UserHasDeniedWSPatchWarning", true);
|
||||
}
|
||||
|
||||
// Hide advanced options by default.
|
||||
@@ -350,10 +346,13 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
|
||||
m_ui.advancedTab = nullptr;
|
||||
m_ui.gsDownloadMode = nullptr;
|
||||
m_ui.gsDumpCompression = nullptr;
|
||||
m_ui.texturePreloading = nullptr;
|
||||
m_ui.exclusiveFullscreenControl = nullptr;
|
||||
m_ui.useBlitSwapChain = nullptr;
|
||||
m_ui.disableMailboxPresentation = nullptr;
|
||||
m_ui.extendedUpscales = nullptr;
|
||||
m_ui.spinCPUDuringReadbacks = nullptr;
|
||||
m_ui.spinGPUDuringReadbacks = nullptr;
|
||||
m_ui.skipPresentingDuplicateFrames = nullptr;
|
||||
m_ui.overrideTextureBarriers = nullptr;
|
||||
m_ui.disableFramebufferFetch = nullptr;
|
||||
@@ -428,12 +427,6 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
|
||||
|
||||
// Display tab
|
||||
{
|
||||
dialog->registerWidgetHelp(m_ui.widescreenPatches, tr("Enable Widescreen Patches"), tr("Unchecked"),
|
||||
tr("Automatically loads and applies widescreen patches on game start. Can cause issues."));
|
||||
|
||||
dialog->registerWidgetHelp(m_ui.noInterlacingPatches, tr("Enable No-Interlacing Patches"), tr("Unchecked"),
|
||||
tr("Automatically loads and applies no-interlacing patches on game start. Can cause issues."));
|
||||
|
||||
dialog->registerWidgetHelp(m_ui.DisableInterlaceOffset, tr("Disable Interlace Offset"), tr("Unchecked"),
|
||||
tr("Disables interlacing offset which may reduce blurring in some situations."));
|
||||
|
||||
|
||||
@@ -404,28 +404,28 @@
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="displayGridLayout">
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="integerScaling">
|
||||
<property name="text">
|
||||
<string>Integer Scaling</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="widescreenPatches">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="PCRTCOverscan">
|
||||
<property name="text">
|
||||
<string>Apply Widescreen Patches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="noInterlacingPatches">
|
||||
<property name="text">
|
||||
<string>Apply No-Interlacing Patches</string>
|
||||
<string>Show Overscan</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="PCRTCOffsets">
|
||||
<property name="text">
|
||||
<string>Screen Offsets</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="PCRTCAntiBlur">
|
||||
<property name="text">
|
||||
<string>Anti-Blur</string>
|
||||
@@ -435,27 +435,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="DisableInterlaceOffset">
|
||||
<property name="text">
|
||||
<string>Disable Interlace Offset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="PCRTCOffsets">
|
||||
<property name="text">
|
||||
<string>Screen Offsets</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="PCRTCOverscan">
|
||||
<property name="text">
|
||||
<string>Show Overscan</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -2125,7 +2111,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<layout class="QGridLayout" name="advancedOptionsGrid">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="disableMailboxPresentation">
|
||||
<property name="text">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -155,7 +155,7 @@ void cdvdLoadNVRAM()
|
||||
{
|
||||
Error error;
|
||||
const std::string nvmfile = cdvdGetNVRAMPath();
|
||||
auto fp = FileSystem::OpenManagedCFile(nvmfile.c_str(), "rb", &error);
|
||||
auto fp = FileSystem::OpenManagedCFileTryIgnoreCase(nvmfile.c_str(), "rb", &error);
|
||||
if (!fp || std::fread(s_nvram, sizeof(s_nvram), 1, fp.get()) != 1)
|
||||
{
|
||||
ERROR_LOG("Failed to open or read NVRAM at {}: {}", Path::GetFileName(nvmfile), error.GetDescription());
|
||||
@@ -178,7 +178,7 @@ void cdvdLoadNVRAM()
|
||||
|
||||
// Also load the mechacon version while we're here.
|
||||
const std::string mecfile = Path::ReplaceExtension(BiosPath, "mec");
|
||||
fp = FileSystem::OpenManagedCFile(mecfile.c_str(), "rb", &error);
|
||||
fp = FileSystem::OpenManagedCFileTryIgnoreCase(mecfile.c_str(), "rb", &error);
|
||||
if (!fp || std::fread(&s_mecha_version, sizeof(s_mecha_version), 1, fp.get()) != 1)
|
||||
{
|
||||
s_mecha_version = DEFAULT_MECHA_VERSION;
|
||||
@@ -186,7 +186,7 @@ void cdvdLoadNVRAM()
|
||||
ERROR_LOG("Failed to open or read MEC file at {}: {}, creating default.", Path::GetFileName(nvmfile),
|
||||
error.GetDescription());
|
||||
fp.reset();
|
||||
fp = FileSystem::OpenManagedCFile(mecfile.c_str(), "wb");
|
||||
fp = FileSystem::OpenManagedCFileTryIgnoreCase(mecfile.c_str(), "wb");
|
||||
if (!fp || std::fwrite(&s_mecha_version, sizeof(s_mecha_version), 1, fp.get()) != 1)
|
||||
Host::ReportErrorAsync("Error", "Failed to write MEC file. Check your BIOS setup/permission settings.");
|
||||
}
|
||||
@@ -197,10 +197,10 @@ void cdvdSaveNVRAM()
|
||||
{
|
||||
Error error;
|
||||
const std::string nvmfile = cdvdGetNVRAMPath();
|
||||
auto fp = FileSystem::OpenManagedCFile(nvmfile.c_str(), "r+b", &error);
|
||||
auto fp = FileSystem::OpenManagedCFileTryIgnoreCase(nvmfile.c_str(), "r+b", &error);
|
||||
if (!fp)
|
||||
{
|
||||
fp = FileSystem::OpenManagedCFile(nvmfile.c_str(), "w+b", &error);
|
||||
fp = FileSystem::OpenManagedCFileTryIgnoreCase(nvmfile.c_str(), "w+b", &error);
|
||||
if (!fp) [[unlikely]]
|
||||
{
|
||||
ERROR_LOG("Failed to open NVRAM at {} for updating: {}", Path::GetFileName(nvmfile), error.GetDescription());
|
||||
|
||||
@@ -20,6 +20,186 @@ static constexpr u32 MAX_PARENTS = 32; // Surely someone wouldn't be insane enou
|
||||
static std::vector<std::pair<std::string, chd_header>> s_chd_hash_cache; // <filename, header>
|
||||
static std::recursive_mutex s_chd_hash_cache_mutex;
|
||||
|
||||
// Provides an implementation of core_file which allows us to control if the underlying FILE handle is freed.
|
||||
// Additionally, this class allows greater control and feedback while precaching CHD files.
|
||||
// The lifetime of ChdCoreFileWrapper will be equal to that of the relevant chd_file,
|
||||
// ChdCoreFileWrapper will also get destroyed if chd_open_core_file fails.
|
||||
class ChdCoreFileWrapper
|
||||
{
|
||||
DeclareNoncopyableObject(ChdCoreFileWrapper);
|
||||
|
||||
private:
|
||||
core_file m_core;
|
||||
std::FILE* m_file;
|
||||
bool m_free_file = false;
|
||||
ChdCoreFileWrapper* m_parent = nullptr;
|
||||
std::unique_ptr<u8[]> m_file_cache;
|
||||
s64 m_file_cache_size;
|
||||
s64 m_file_cache_pos;
|
||||
|
||||
public:
|
||||
ChdCoreFileWrapper(std::FILE* file, ChdCoreFileWrapper* parent)
|
||||
: m_file{file}
|
||||
, m_parent{parent}
|
||||
{
|
||||
m_core.argp = this;
|
||||
m_core.fsize = FSize;
|
||||
m_core.fread = FRead;
|
||||
m_core.fclose = FClose;
|
||||
m_core.fseek = FSeek;
|
||||
}
|
||||
|
||||
~ChdCoreFileWrapper()
|
||||
{
|
||||
if (m_free_file && m_file)
|
||||
std::fclose(m_file);
|
||||
}
|
||||
|
||||
core_file* GetCoreFile()
|
||||
{
|
||||
return &m_core;
|
||||
}
|
||||
|
||||
static ChdCoreFileWrapper* FromCoreFile(core_file* file)
|
||||
{
|
||||
return reinterpret_cast<ChdCoreFileWrapper*>(file->argp);
|
||||
}
|
||||
|
||||
void SetFileOwner(bool isOwner)
|
||||
{
|
||||
m_free_file = isOwner;
|
||||
}
|
||||
|
||||
s64 GetPrecacheSize()
|
||||
{
|
||||
const s64 size = static_cast<size_t>(FileSystem::FSize64(m_file));
|
||||
if (m_parent != nullptr)
|
||||
return m_parent->GetPrecacheSize() + size;
|
||||
else
|
||||
return size;
|
||||
}
|
||||
|
||||
bool Precache(ProgressCallback* progress, Error* error)
|
||||
{
|
||||
progress->SetProgressRange(100);
|
||||
|
||||
const s64 size = GetPrecacheSize();
|
||||
return PrecacheInternal(progress, error, 0, size);
|
||||
}
|
||||
|
||||
private:
|
||||
bool PrecacheInternal(ProgressCallback* progress, Error* error, s64 startSize, s64 finalSize)
|
||||
{
|
||||
m_file_cache_size = FileSystem::FSize64(m_file);
|
||||
if (m_file_cache_size <= 0)
|
||||
{
|
||||
Error::SetStringView(error, "Failed to determine file size.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy the current file position.
|
||||
m_file_cache_pos = FileSystem::FTell64(m_file);
|
||||
if (m_file_cache_pos <= 0)
|
||||
{
|
||||
Error::SetStringView(error, "Failed to determine file position.");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_file_cache = std::make_unique_for_overwrite<u8[]>(m_file_cache_size);
|
||||
if (FileSystem::FSeek64(m_file, 0, SEEK_SET) != 0 ||
|
||||
FileSystem::ReadFileWithPartialProgress(
|
||||
m_file, m_file_cache.get(), m_file_cache_size, progress,
|
||||
(startSize * 100) / finalSize,
|
||||
((startSize + m_file_cache_size) * 100) / finalSize,
|
||||
error) != static_cast<size_t>(m_file_cache_size))
|
||||
{
|
||||
m_file_cache.reset();
|
||||
// Precache failed, continue using file
|
||||
// Restore file position incase it's used for subsequent reads
|
||||
FileSystem::FSeek64(m_file, m_file_cache_pos, SEEK_SET);
|
||||
Error::SetStringView(error, "Failed to read part of the file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
startSize += m_file_cache_size;
|
||||
|
||||
if (m_parent)
|
||||
{
|
||||
if (!m_parent->PrecacheInternal(progress, error, startSize, finalSize))
|
||||
{
|
||||
// Precache failed, continue using file
|
||||
// Restore file position incase it's used for subsequent reads
|
||||
FileSystem::FSeek64(m_file, m_file_cache_pos, SEEK_SET);
|
||||
m_file_cache.reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_free_file)
|
||||
std::fclose(m_file);
|
||||
m_file = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static u64 FSize(core_file* file)
|
||||
{
|
||||
ChdCoreFileWrapper* fileWrapper = FromCoreFile(file);
|
||||
if (fileWrapper->m_file_cache)
|
||||
return fileWrapper->m_file_cache_size;
|
||||
else
|
||||
return static_cast<u64>(FileSystem::FSize64(fileWrapper->m_file));
|
||||
}
|
||||
|
||||
static size_t FRead(void* buffer, size_t elmSize, size_t elmCount, core_file* file)
|
||||
{
|
||||
ChdCoreFileWrapper* fileWrapper = FromCoreFile(file);
|
||||
if (fileWrapper->m_file_cache)
|
||||
{
|
||||
// While currently libchdr only uses an elmCount of 1, we can't guarantee that will always be the case.
|
||||
elmCount = std::min<size_t>(elmCount, std::max<s64>(fileWrapper->m_file_cache_size - fileWrapper->m_file_cache_pos, 0) / elmSize);
|
||||
const size_t size = elmSize * elmCount;
|
||||
std::memcpy(buffer, &fileWrapper->m_file_cache[fileWrapper->m_file_cache_pos], size);
|
||||
return elmCount;
|
||||
}
|
||||
else
|
||||
return std::fread(buffer, elmSize, elmCount, fileWrapper->m_file);
|
||||
}
|
||||
|
||||
static int FClose(core_file* file)
|
||||
{
|
||||
// Destructor handles freeing the FILE handle.
|
||||
delete FromCoreFile(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int FSeek(core_file* file, int64_t offset, int whence)
|
||||
{
|
||||
ChdCoreFileWrapper* fileWrapper = FromCoreFile(file);
|
||||
if (fileWrapper->m_file_cache)
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
fileWrapper->m_file_cache_pos = offset;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
fileWrapper->m_file_cache_pos += offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
fileWrapper->m_file_cache_pos = fileWrapper->m_file_cache_size + offset;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return FileSystem::FSeek64(fileWrapper->m_file, offset, whence);
|
||||
}
|
||||
};
|
||||
|
||||
ChdFileReader::ChdFileReader() = default;
|
||||
|
||||
ChdFileReader::~ChdFileReader()
|
||||
@@ -27,13 +207,40 @@ ChdFileReader::~ChdFileReader()
|
||||
pxAssert(!ChdFile);
|
||||
}
|
||||
|
||||
static bool IsHeaderParentCHD(const chd_header& header, const chd_header& parent_header)
|
||||
{
|
||||
static const u8 nullmd5[CHD_MD5_BYTES]{};
|
||||
static const u8 nullsha1[CHD_SHA1_BYTES]{};
|
||||
|
||||
// Check MD5 if it isn't empty.
|
||||
if (std::memcmp(nullmd5, header.parentmd5, CHD_MD5_BYTES) != 0 &&
|
||||
std::memcmp(nullmd5, parent_header.md5, CHD_MD5_BYTES) != 0 &&
|
||||
std::memcmp(parent_header.md5, header.parentmd5, CHD_MD5_BYTES) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check SHA1 if it isn't empty.
|
||||
if (std::memcmp(nullsha1, header.parentsha1, CHD_SHA1_BYTES) != 0 &&
|
||||
std::memcmp(nullsha1, parent_header.sha1, CHD_SHA1_BYTES) != 0 &&
|
||||
std::memcmp(parent_header.sha1, header.parentsha1, CHD_SHA1_BYTES) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePtr fp, Error* error, u32 recursion_level)
|
||||
{
|
||||
chd_file* chd;
|
||||
chd_error err = chd_open_file(fp.get(), CHD_OPEN_READ | CHD_OPEN_TRANSFER_FILE, nullptr, &chd);
|
||||
ChdCoreFileWrapper* core_wrapper = new ChdCoreFileWrapper(fp.get(), nullptr);
|
||||
// libchdr will take ownership of core_wrapper, and will close/free it on failure.
|
||||
chd_error err = chd_open_core_file(core_wrapper->GetCoreFile(), CHD_OPEN_READ, nullptr, &chd);
|
||||
if (err == CHDERR_NONE)
|
||||
{
|
||||
// fp is now managed by libchdr
|
||||
// core_wrapper should manage fp.
|
||||
core_wrapper->SetFileOwner(true);
|
||||
fp.release();
|
||||
return chd;
|
||||
}
|
||||
@@ -73,14 +280,14 @@ static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePt
|
||||
if (!StringUtil::compareNoCase(parent_dir, Path::GetDirectory(it->first)))
|
||||
continue;
|
||||
|
||||
if (!chd_is_matching_parent(&header, &it->second))
|
||||
if (!IsHeaderParentCHD(header, it->second))
|
||||
continue;
|
||||
|
||||
// Re-check the header, it might have changed since we last opened.
|
||||
chd_header parent_header;
|
||||
auto parent_fp = FileSystem::OpenManagedSharedCFile(it->first.c_str(), "rb", FileSystem::FileShareMode::DenyWrite);
|
||||
if (parent_fp && chd_read_header_file(parent_fp.get(), &parent_header) == CHDERR_NONE &&
|
||||
chd_is_matching_parent(&header, &parent_header))
|
||||
IsHeaderParentCHD(header, parent_header))
|
||||
{
|
||||
// Need to take a copy of the string, because the parent might add to the list and invalidate the iterator.
|
||||
const std::string filename_to_open = it->first;
|
||||
@@ -105,7 +312,7 @@ static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePt
|
||||
parent_dir.c_str(), "*.*", FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES | FILESYSTEM_FIND_KEEP_ARRAY, &parent_files);
|
||||
for (FILESYSTEM_FIND_DATA& fd : parent_files)
|
||||
{
|
||||
if (StringUtil::EndsWithNoCase(Path::GetExtension(fd.FileName), ".chd"))
|
||||
if (!StringUtil::EndsWithNoCase(Path::GetExtension(fd.FileName), "chd"))
|
||||
continue;
|
||||
|
||||
// Re-check the header, it might have changed since we last opened.
|
||||
@@ -121,7 +328,7 @@ static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePt
|
||||
else
|
||||
s_chd_hash_cache.emplace_back(fd.FileName, parent_header);
|
||||
|
||||
if (!chd_is_matching_parent(&header, &parent_header))
|
||||
if (!IsHeaderParentCHD(header, parent_header))
|
||||
continue;
|
||||
|
||||
// Match! Open this one.
|
||||
@@ -140,8 +347,10 @@ static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePt
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Our last core file wrapper got freed, so make a new one.
|
||||
core_wrapper = new ChdCoreFileWrapper(fp.get(), ChdCoreFileWrapper::FromCoreFile(chd_core_file(parent_chd)));
|
||||
// Now try re-opening with the parent.
|
||||
err = chd_open_file(fp.get(), CHD_OPEN_READ | CHD_OPEN_TRANSFER_FILE, parent_chd, &chd);
|
||||
err = chd_open_core_file(core_wrapper->GetCoreFile(), CHD_OPEN_READ, parent_chd, &chd);
|
||||
if (err != CHDERR_NONE)
|
||||
{
|
||||
Console.Error(fmt::format("Failed to open CHD '{}': {}", filename, chd_error_string(err)));
|
||||
@@ -149,7 +358,8 @@ static chd_file* OpenCHD(const std::string& filename, FileSystem::ManagedCFilePt
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// fp now owned by libchdr
|
||||
// core_wrapper should manage fp.
|
||||
core_wrapper->SetFileOwner(true);
|
||||
fp.release();
|
||||
return chd;
|
||||
}
|
||||
@@ -192,28 +402,11 @@ bool ChdFileReader::Open2(std::string filename, Error* error)
|
||||
|
||||
bool ChdFileReader::Precache2(ProgressCallback* progress, Error* error)
|
||||
{
|
||||
if (!CheckAvailableMemoryForPrecaching(chd_get_compressed_size(ChdFile), error))
|
||||
ChdCoreFileWrapper* fileWrapper = ChdCoreFileWrapper::FromCoreFile(chd_core_file(ChdFile));
|
||||
if (!CheckAvailableMemoryForPrecaching(fileWrapper->GetPrecacheSize(), error))
|
||||
return false;
|
||||
|
||||
progress->SetProgressRange(100);
|
||||
|
||||
const auto callback = [](size_t pos, size_t total, void* param) -> bool {
|
||||
ProgressCallback* progress = static_cast<ProgressCallback*>(param);
|
||||
const u32 percent = static_cast<u32>((pos * 100) / total);
|
||||
progress->SetProgressValue(std::min<u32>(percent, 100));
|
||||
return !progress->IsCancelled();
|
||||
};
|
||||
|
||||
const chd_error cerror = chd_precache_progress(ChdFile, callback, progress);
|
||||
if (cerror != CHDERR_NONE)
|
||||
{
|
||||
if (cerror != CHDERR_CANCELLED)
|
||||
Error::SetStringView(error, "Failed to read part of the file.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return fileWrapper->Precache(progress, error);
|
||||
}
|
||||
|
||||
ThreadedFileReader::Chunk ChdFileReader::ChunkForOffset(u64 offset)
|
||||
|
||||
177
pcsx2/COP0.cpp
177
pcsx2/COP0.cpp
@@ -230,49 +230,49 @@ void MapTLB(const tlbs& t, int i)
|
||||
u32 saddr, eaddr;
|
||||
|
||||
COP0_LOG("MAP TLB %d: 0x%08X-> [0x%08X 0x%08X] S=%d G=%d ASID=%d Mask=0x%03X EntryLo0 PFN=%x EntryLo0 Cache=%x EntryLo1 PFN=%x EntryLo1 Cache=%x VPN2=%x",
|
||||
i, t.VPN2, t.PFN0, t.PFN1, t.S >> 31, t.G, t.ASID,
|
||||
t.Mask, t.EntryLo0 >> 6, (t.EntryLo0 & 0x38) >> 3, t.EntryLo1 >> 6, (t.EntryLo1 & 0x38) >> 3, t.VPN2);
|
||||
i, t.VPN2(), t.PFN0(), t.PFN1(), t.isSPR() >> 31, t.isGlobal(), t.EntryHi.ASID,
|
||||
t.Mask(), t.EntryLo0.PFN, t.EntryLo0.C, t.EntryLo1.PFN, t.EntryLo1.C, t.VPN2());
|
||||
|
||||
// According to the manual
|
||||
// 'It [SPR] must be mapped into a contiguous 16 KB of virtual address space that is
|
||||
// aligned on a 16KB boundary.Results are not guaranteed if this restriction is not followed.'
|
||||
// Assume that the game isn't doing anything less-than-ideal with the scratchpad mapping and map it directly to eeMem->Scratch.
|
||||
if (t.S)
|
||||
if (t.isSPR())
|
||||
{
|
||||
if (t.VPN2 != 0x70000000)
|
||||
Console.Warning("COP0: Mapping Scratchpad to non-default address 0x%08X", t.VPN2);
|
||||
if (t.VPN2() != 0x70000000)
|
||||
Console.Warning("COP0: Mapping Scratchpad to non-default address 0x%08X", t.VPN2());
|
||||
|
||||
vtlb_VMapBuffer(t.VPN2, eeMem->Scratch, Ps2MemSize::Scratch);
|
||||
vtlb_VMapBuffer(t.VPN2(), eeMem->Scratch, Ps2MemSize::Scratch);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t.EntryLo0 & 0x2)
|
||||
if (t.EntryLo0.V)
|
||||
{
|
||||
mask = ((~t.Mask) << 1) & 0xfffff;
|
||||
saddr = t.VPN2 >> 12;
|
||||
eaddr = saddr + t.Mask + 1;
|
||||
mask = ((~t.Mask()) << 1) & 0xfffff;
|
||||
saddr = t.VPN2() >> 12;
|
||||
eaddr = saddr + t.Mask() + 1;
|
||||
|
||||
for (addr = saddr; addr < eaddr; addr++)
|
||||
{
|
||||
if ((addr & mask) == ((t.VPN2 >> 12) & mask))
|
||||
if ((addr & mask) == ((t.VPN2() >> 12) & mask))
|
||||
{ //match
|
||||
memSetPageAddr(addr << 12, t.PFN0 + ((addr - saddr) << 12));
|
||||
memSetPageAddr(addr << 12, t.PFN0() + ((addr - saddr) << 12));
|
||||
Cpu->Clear(addr << 12, 0x400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (t.EntryLo1 & 0x2)
|
||||
if (t.EntryLo1.V)
|
||||
{
|
||||
mask = ((~t.Mask) << 1) & 0xfffff;
|
||||
saddr = (t.VPN2 >> 12) + t.Mask + 1;
|
||||
eaddr = saddr + t.Mask + 1;
|
||||
mask = ((~t.Mask()) << 1) & 0xfffff;
|
||||
saddr = (t.VPN2() >> 12) + t.Mask() + 1;
|
||||
eaddr = saddr + t.Mask() + 1;
|
||||
|
||||
for (addr = saddr; addr < eaddr; addr++)
|
||||
{
|
||||
if ((addr & mask) == ((t.VPN2 >> 12) & mask))
|
||||
if ((addr & mask) == ((t.VPN2() >> 12) & mask))
|
||||
{ //match
|
||||
memSetPageAddr(addr << 12, t.PFN1 + ((addr - saddr) << 12));
|
||||
memSetPageAddr(addr << 12, t.PFN1() + ((addr - saddr) << 12));
|
||||
Cpu->Clear(addr << 12, 0x400);
|
||||
}
|
||||
}
|
||||
@@ -280,27 +280,36 @@ void MapTLB(const tlbs& t, int i)
|
||||
}
|
||||
}
|
||||
|
||||
__inline u32 ConvertPageMask(const u32 PageMask)
|
||||
{
|
||||
const u32 mask = std::popcount(PageMask >> 13);
|
||||
|
||||
pxAssertMsg(!((mask & 1) || mask > 12), "Invalid page mask for this TLB entry. EE cache doesn't know what to do here.");
|
||||
|
||||
return (1 << (12 + mask)) - 1;
|
||||
}
|
||||
|
||||
void UnmapTLB(const tlbs& t, int i)
|
||||
{
|
||||
//Console.WriteLn("Clear TLB %d: %08x-> [%08x %08x] S=%d G=%d ASID=%d Mask= %03X", i,t.VPN2,t.PFN0,t.PFN1,t.S,t.G,t.ASID,t.Mask);
|
||||
u32 mask, addr;
|
||||
u32 saddr, eaddr;
|
||||
|
||||
if (t.S)
|
||||
if (t.isSPR())
|
||||
{
|
||||
vtlb_VMapUnmap(t.VPN2, 0x4000);
|
||||
vtlb_VMapUnmap(t.VPN2(), 0x4000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.EntryLo0 & 0x2)
|
||||
if (t.EntryLo0.V)
|
||||
{
|
||||
mask = ((~t.Mask) << 1) & 0xfffff;
|
||||
saddr = t.VPN2 >> 12;
|
||||
eaddr = saddr + t.Mask + 1;
|
||||
mask = ((~t.Mask()) << 1) & 0xfffff;
|
||||
saddr = t.VPN2() >> 12;
|
||||
eaddr = saddr + t.Mask() + 1;
|
||||
// Console.WriteLn("Clear TLB: %08x ~ %08x",saddr,eaddr-1);
|
||||
for (addr = saddr; addr < eaddr; addr++)
|
||||
{
|
||||
if ((addr & mask) == ((t.VPN2 >> 12) & mask))
|
||||
if ((addr & mask) == ((t.VPN2() >> 12) & mask))
|
||||
{ //match
|
||||
memClearPageAddr(addr << 12);
|
||||
Cpu->Clear(addr << 12, 0x400);
|
||||
@@ -308,38 +317,74 @@ void UnmapTLB(const tlbs& t, int i)
|
||||
}
|
||||
}
|
||||
|
||||
if (t.EntryLo1 & 0x2)
|
||||
if (t.EntryLo1.V)
|
||||
{
|
||||
mask = ((~t.Mask) << 1) & 0xfffff;
|
||||
saddr = (t.VPN2 >> 12) + t.Mask + 1;
|
||||
eaddr = saddr + t.Mask + 1;
|
||||
mask = ((~t.Mask()) << 1) & 0xfffff;
|
||||
saddr = (t.VPN2() >> 12) + t.Mask() + 1;
|
||||
eaddr = saddr + t.Mask() + 1;
|
||||
// Console.WriteLn("Clear TLB: %08x ~ %08x",saddr,eaddr-1);
|
||||
for (addr = saddr; addr < eaddr; addr++)
|
||||
{
|
||||
if ((addr & mask) == ((t.VPN2 >> 12) & mask))
|
||||
if ((addr & mask) == ((t.VPN2() >> 12) & mask))
|
||||
{ //match
|
||||
memClearPageAddr(addr << 12);
|
||||
Cpu->Clear(addr << 12, 0x400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cachedTlbs.count; i++)
|
||||
{
|
||||
if (cachedTlbs.PFN0s[i] == t.PFN0() && cachedTlbs.PFN1s[i] == t.PFN1() && cachedTlbs.PageMasks[i] == ConvertPageMask(t.PageMask.UL))
|
||||
{
|
||||
for (size_t j = i; j < cachedTlbs.count - 1; j++)
|
||||
{
|
||||
cachedTlbs.CacheEnabled0[j] = cachedTlbs.CacheEnabled0[j + 1];
|
||||
cachedTlbs.CacheEnabled1[j] = cachedTlbs.CacheEnabled1[j + 1];
|
||||
cachedTlbs.PFN0s[j] = cachedTlbs.PFN0s[j + 1];
|
||||
cachedTlbs.PFN1s[j] = cachedTlbs.PFN1s[j + 1];
|
||||
cachedTlbs.PageMasks[j] = cachedTlbs.PageMasks[j + 1];
|
||||
}
|
||||
cachedTlbs.count--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WriteTLB(int i)
|
||||
{
|
||||
tlb[i].PageMask = cpuRegs.CP0.n.PageMask;
|
||||
tlb[i].EntryHi = cpuRegs.CP0.n.EntryHi;
|
||||
tlb[i].EntryLo0 = cpuRegs.CP0.n.EntryLo0;
|
||||
tlb[i].EntryLo1 = cpuRegs.CP0.n.EntryLo1;
|
||||
tlb[i].PageMask.UL = cpuRegs.CP0.n.PageMask;
|
||||
tlb[i].EntryHi.UL = cpuRegs.CP0.n.EntryHi;
|
||||
tlb[i].EntryLo0.UL = cpuRegs.CP0.n.EntryLo0;
|
||||
tlb[i].EntryLo1.UL = cpuRegs.CP0.n.EntryLo1;
|
||||
|
||||
tlb[i].Mask = (cpuRegs.CP0.n.PageMask >> 13) & 0xfff;
|
||||
tlb[i].nMask = (~tlb[i].Mask) & 0xfff;
|
||||
tlb[i].VPN2 = ((cpuRegs.CP0.n.EntryHi >> 13) & (~tlb[i].Mask)) << 13;
|
||||
tlb[i].ASID = cpuRegs.CP0.n.EntryHi & 0xfff;
|
||||
tlb[i].G = cpuRegs.CP0.n.EntryLo0 & cpuRegs.CP0.n.EntryLo1 & 0x1;
|
||||
tlb[i].PFN0 = (((cpuRegs.CP0.n.EntryLo0 >> 6) & 0xFFFFF) & (~tlb[i].Mask)) << 12;
|
||||
tlb[i].PFN1 = (((cpuRegs.CP0.n.EntryLo1 >> 6) & 0xFFFFF) & (~tlb[i].Mask)) << 12;
|
||||
tlb[i].S = cpuRegs.CP0.n.EntryLo0 & 0x80000000;
|
||||
// Setting the cache mode to reserved values is vaguely defined in the manual.
|
||||
// I found that SPR is set to cached regardless.
|
||||
// Non-SPR entries default to uncached on reserved cache modes.
|
||||
if (tlb[i].isSPR())
|
||||
{
|
||||
tlb[i].EntryLo0.C = 3;
|
||||
tlb[i].EntryLo1.C = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!tlb[i].EntryLo0.isValidCacheMode())
|
||||
tlb[i].EntryLo0.C = 2;
|
||||
if (!tlb[i].EntryLo1.isValidCacheMode())
|
||||
tlb[i].EntryLo1.C = 2;
|
||||
}
|
||||
|
||||
if (!tlb[i].isSPR() && ((tlb[i].EntryLo0.V && tlb[i].EntryLo0.isCached()) || (tlb[i].EntryLo1.V && tlb[i].EntryLo1.isCached())))
|
||||
{
|
||||
const size_t idx = cachedTlbs.count;
|
||||
cachedTlbs.CacheEnabled0[idx] = tlb[i].EntryLo0.isCached() ? ~0 : 0;
|
||||
cachedTlbs.CacheEnabled1[idx] = tlb[i].EntryLo1.isCached() ? ~0 : 0;
|
||||
cachedTlbs.PFN1s[idx] = tlb[i].PFN1();
|
||||
cachedTlbs.PFN0s[idx] = tlb[i].PFN0();
|
||||
cachedTlbs.PageMasks[idx] = ConvertPageMask(tlb[i].PageMask.UL);
|
||||
|
||||
cachedTlbs.count++;
|
||||
}
|
||||
|
||||
MapTLB(tlb[i], i);
|
||||
}
|
||||
@@ -355,49 +400,57 @@ namespace COP0 {
|
||||
cpuRegs.CP0.n.Index, cpuRegs.CP0.n.PageMask, cpuRegs.CP0.n.EntryHi,
|
||||
cpuRegs.CP0.n.EntryLo0, cpuRegs.CP0.n.EntryLo1);
|
||||
|
||||
int i = cpuRegs.CP0.n.Index & 0x3f;
|
||||
const u8 i = cpuRegs.CP0.n.Index & 0x3f;
|
||||
|
||||
cpuRegs.CP0.n.PageMask = tlb[i].PageMask;
|
||||
cpuRegs.CP0.n.EntryHi = tlb[i].EntryHi & ~(tlb[i].PageMask | 0x1f00);
|
||||
cpuRegs.CP0.n.EntryLo0 = (tlb[i].EntryLo0 & ~1) | ((tlb[i].EntryHi >> 12) & 1);
|
||||
cpuRegs.CP0.n.EntryLo1 = (tlb[i].EntryLo1 & ~1) | ((tlb[i].EntryHi >> 12) & 1);
|
||||
if (i > 47)
|
||||
{
|
||||
Console.Warning("TLBR with index > 47! (%d)", i);
|
||||
return;
|
||||
}
|
||||
|
||||
cpuRegs.CP0.n.PageMask = tlb[i].PageMask.Mask << 13;
|
||||
cpuRegs.CP0.n.EntryHi = tlb[i].EntryHi.UL & ~((tlb[i].PageMask.Mask << 13) | 0x1f00);
|
||||
cpuRegs.CP0.n.EntryLo0 = tlb[i].EntryLo0.UL & ~(0xFC000000) & ~1;
|
||||
cpuRegs.CP0.n.EntryLo1 = tlb[i].EntryLo1.UL & ~(0x7C000000) & ~1;
|
||||
// "If both the Global bit of EntryLo0 and EntryLo1 are set to 1, the processor ignores the ASID during TLB lookup."
|
||||
// This is reflected during TLBR, where G is only set if both EntryLo0 and EntryLo1 are global.
|
||||
cpuRegs.CP0.n.EntryLo0 |= (tlb[i].EntryLo0.UL & 1) & (tlb[i].EntryLo1.UL & 1);
|
||||
cpuRegs.CP0.n.EntryLo1 |= (tlb[i].EntryLo0.UL & 1) & (tlb[i].EntryLo1.UL & 1);
|
||||
}
|
||||
|
||||
void TLBWI()
|
||||
{
|
||||
int j = cpuRegs.CP0.n.Index & 0x3f;
|
||||
const u8 j = cpuRegs.CP0.n.Index & 0x3f;
|
||||
|
||||
//if (j > 48) return;
|
||||
if (j > 47)
|
||||
{
|
||||
Console.Warning("TLBWI with index > 47! (%d)", j);
|
||||
return;
|
||||
}
|
||||
|
||||
COP0_LOG("COP0_TLBWI %d:%x,%x,%x,%x",
|
||||
cpuRegs.CP0.n.Index, cpuRegs.CP0.n.PageMask, cpuRegs.CP0.n.EntryHi,
|
||||
cpuRegs.CP0.n.EntryLo0, cpuRegs.CP0.n.EntryLo1);
|
||||
|
||||
UnmapTLB(tlb[j], j);
|
||||
tlb[j].PageMask = cpuRegs.CP0.n.PageMask;
|
||||
tlb[j].EntryHi = cpuRegs.CP0.n.EntryHi;
|
||||
tlb[j].EntryLo0 = cpuRegs.CP0.n.EntryLo0;
|
||||
tlb[j].EntryLo1 = cpuRegs.CP0.n.EntryLo1;
|
||||
WriteTLB(j);
|
||||
}
|
||||
|
||||
void TLBWR()
|
||||
{
|
||||
int j = cpuRegs.CP0.n.Random & 0x3f;
|
||||
const u8 j = cpuRegs.CP0.n.Random & 0x3f;
|
||||
|
||||
//if (j > 48) return;
|
||||
if (j > 47)
|
||||
{
|
||||
Console.Warning("TLBWR with random > 47! (%d)", j);
|
||||
return;
|
||||
}
|
||||
|
||||
DevCon.Warning("COP0_TLBWR %d:%x,%x,%x,%x\n",
|
||||
cpuRegs.CP0.n.Random, cpuRegs.CP0.n.PageMask, cpuRegs.CP0.n.EntryHi,
|
||||
cpuRegs.CP0.n.EntryLo0, cpuRegs.CP0.n.EntryLo1);
|
||||
|
||||
//if (j > 48) return;
|
||||
|
||||
UnmapTLB(tlb[j], j);
|
||||
tlb[j].PageMask = cpuRegs.CP0.n.PageMask;
|
||||
tlb[j].EntryHi = cpuRegs.CP0.n.EntryHi;
|
||||
tlb[j].EntryLo0 = cpuRegs.CP0.n.EntryLo0;
|
||||
tlb[j].EntryLo1 = cpuRegs.CP0.n.EntryLo1;
|
||||
WriteTLB(j);
|
||||
}
|
||||
|
||||
@@ -422,7 +475,7 @@ namespace COP0 {
|
||||
cpuRegs.CP0.n.Index = 0xFFFFFFFF;
|
||||
for (i = 0; i < 48; i++)
|
||||
{
|
||||
if (tlb[i].VPN2 == ((~tlb[i].Mask) & (EntryHi32.s.VPN2)) && ((tlb[i].G & 1) || ((tlb[i].ASID & 0xff) == EntryHi32.s.ASID)))
|
||||
if (tlb[i].VPN2() == ((~tlb[i].Mask()) & (EntryHi32.s.VPN2)) && ((tlb[i].isGlobal()) || ((tlb[i].EntryHi.ASID & 0xff) == EntryHi32.s.ASID)))
|
||||
{
|
||||
cpuRegs.CP0.n.Index = i;
|
||||
break;
|
||||
|
||||
@@ -163,6 +163,17 @@ void resetCache()
|
||||
std::memset(&cache, 0, sizeof(cache));
|
||||
}
|
||||
|
||||
void writebackCache()
|
||||
{
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
cache.lineAt(i, j).writeBackIfNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool findInCache(const CacheSet& set, uptr ppf, int* way)
|
||||
{
|
||||
auto check = [&](int checkWay) -> bool {
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "common/SingleRegisterTypes.h"
|
||||
|
||||
void resetCache();
|
||||
// Dumps all dirty cache entries to memory
|
||||
// This is necessary to fix a bug when enabled the recompiler while the cache was enabled.
|
||||
void writebackCache();
|
||||
void writeCache8(u32 mem, u8 value, bool validPFN = true);
|
||||
void writeCache16(u32 mem, u16 value, bool validPFN = true);
|
||||
void writeCache32(u32 mem, u32 value, bool validPFN = true);
|
||||
|
||||
@@ -1268,8 +1268,6 @@ struct Pcsx2Config
|
||||
EnablePatches : 1, // enables patch detection and application
|
||||
EnableCheats : 1, // enables cheat detection and application
|
||||
EnablePINE : 1, // enables inter-process communication
|
||||
EnableWideScreenPatches : 1,
|
||||
EnableNoInterlacingPatches : 1,
|
||||
EnableFastBoot : 1,
|
||||
EnableFastBootFastForward : 1,
|
||||
EnableThreadPinning : 1,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PacketReader::ARP
|
||||
{
|
||||
}
|
||||
|
||||
ARP_Packet::ARP_Packet(u8* buffer, int bufferSize)
|
||||
ARP_Packet::ARP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace PacketReader::ARP
|
||||
std::unique_ptr<u8[]> targetProtocolAddress;
|
||||
|
||||
ARP_Packet(u8 hwAddrLen, u8 procAddrLen);
|
||||
ARP_Packet(u8* buffer, int bufferSize);
|
||||
ARP_Packet(const u8* buffer, int bufferSize);
|
||||
ARP_Packet(const ARP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
||||
@@ -11,59 +11,59 @@
|
||||
|
||||
namespace PacketReader::ARP
|
||||
{
|
||||
ARP_PacketEditor::ARP_PacketEditor(PayloadPtr* pkt)
|
||||
ARP_PacketEditor::ARP_PacketEditor(PayloadPtrEditor* pkt)
|
||||
: basePkt{pkt}
|
||||
{
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetHardwareType()
|
||||
u16 ARP_PacketEditor::GetHardwareType() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[0]);
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetProtocol()
|
||||
u16 ARP_PacketEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[2]);
|
||||
}
|
||||
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength()
|
||||
u8 ARP_PacketEditor::GetHardwareAddressLength() const
|
||||
{
|
||||
return basePkt->data[4];
|
||||
}
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength()
|
||||
u8 ARP_PacketEditor::GetProtocolAddressLength() const
|
||||
{
|
||||
return basePkt->data[5];
|
||||
}
|
||||
|
||||
u16 ARP_PacketEditor::GetOp()
|
||||
u16 ARP_PacketEditor::GetOp() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->data[6]);
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress()
|
||||
u8* ARP_PacketEditor::SenderHardwareAddress() const
|
||||
{
|
||||
return &basePkt->data[8];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress()
|
||||
u8* ARP_PacketEditor::SenderProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress()
|
||||
u8* ARP_PacketEditor::TargetHardwareAddress() const
|
||||
{
|
||||
int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress()
|
||||
u8* ARP_PacketEditor::TargetProtocolAddress() const
|
||||
{
|
||||
int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
const int offset = 8 + 2 * GetHardwareAddressLength() + GetProtocolAddressLength();
|
||||
return &basePkt->data[offset];
|
||||
}
|
||||
|
||||
int ARP_PacketEditor::GetLength()
|
||||
int ARP_PacketEditor::GetLength() const
|
||||
{
|
||||
return 8 + 2 * GetHardwareAddressLength() + 2 * GetProtocolAddressLength();
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ namespace PacketReader::ARP
|
||||
class ARP_PacketEditor
|
||||
{
|
||||
private:
|
||||
PayloadPtr* basePkt;
|
||||
PayloadPtrEditor* basePkt;
|
||||
|
||||
public:
|
||||
ARP_PacketEditor(PayloadPtr* pkt);
|
||||
ARP_PacketEditor(PayloadPtrEditor* pkt);
|
||||
|
||||
u16 GetHardwareType();
|
||||
u16 GetProtocol();
|
||||
u8 GetHardwareAddressLength();
|
||||
u8 GetProtocolAddressLength();
|
||||
u16 GetOp();
|
||||
u16 GetHardwareType() const;
|
||||
u16 GetProtocol() const;
|
||||
u8 GetHardwareAddressLength() const;
|
||||
u8 GetProtocolAddressLength() const;
|
||||
u16 GetOp() const;
|
||||
|
||||
u8* SenderHardwareAddress();
|
||||
u8* SenderProtocolAddress();
|
||||
u8* TargetHardwareAddress();
|
||||
u8* TargetProtocolAddress();
|
||||
u8* SenderHardwareAddress() const;
|
||||
u8* SenderProtocolAddress() const;
|
||||
u8* TargetHardwareAddress() const;
|
||||
u8* TargetProtocolAddress() const;
|
||||
|
||||
int GetLength();
|
||||
int GetLength() const;
|
||||
};
|
||||
} // namespace PacketReader::ARP
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace PacketReader
|
||||
//Note: we don't have to worry about the Ethernet Frame CRC as it is not included in the packet
|
||||
//Note: We don't support tagged frames
|
||||
|
||||
payload = std::make_unique<PayloadPtr>((u8*)&basePkt->buffer[14], pkt->size - headerLength);
|
||||
payload = std::make_unique<PayloadPtrEditor>((u8*)&basePkt->buffer[14], pkt->size - headerLength);
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC()
|
||||
MAC_Address EthernetFrameEditor::GetDestinationMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[0];
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace PacketReader
|
||||
*(MAC_Address*)&basePkt->buffer[0] = value;
|
||||
}
|
||||
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC()
|
||||
MAC_Address EthernetFrameEditor::GetSourceMAC() const
|
||||
{
|
||||
return *(MAC_Address*)&basePkt->buffer[6];
|
||||
}
|
||||
@@ -40,12 +40,12 @@ namespace PacketReader
|
||||
*(MAC_Address*)&basePkt->buffer[6] = value;
|
||||
}
|
||||
|
||||
u16 EthernetFrameEditor::GetProtocol()
|
||||
u16 EthernetFrameEditor::GetProtocol() const
|
||||
{
|
||||
return ntohs(*(u16*)&basePkt->buffer[12]);
|
||||
}
|
||||
|
||||
PayloadPtr* EthernetFrameEditor::GetPayload()
|
||||
PayloadPtrEditor* EthernetFrameEditor::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace PacketReader
|
||||
//Length
|
||||
private:
|
||||
NetPacket* basePkt;
|
||||
std::unique_ptr<PayloadPtr> payload;
|
||||
std::unique_ptr<PayloadPtrEditor> payload;
|
||||
|
||||
public:
|
||||
EthernetFrameEditor(NetPacket* pkt);
|
||||
|
||||
MAC_Address GetDestinationMAC();
|
||||
MAC_Address GetDestinationMAC() const;
|
||||
void SetDestinationMAC(MAC_Address value);
|
||||
MAC_Address GetSourceMAC();
|
||||
MAC_Address GetSourceMAC() const;
|
||||
void SetSourceMAC(MAC_Address value);
|
||||
|
||||
u16 GetProtocol();
|
||||
u16 GetProtocol() const;
|
||||
|
||||
PayloadPtr* GetPayload();
|
||||
PayloadPtrEditor* GetPayload() const;
|
||||
};
|
||||
} // namespace PacketReader
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PacketReader::IP::ICMP
|
||||
: payload{data}
|
||||
{
|
||||
}
|
||||
ICMP_Packet::ICMP_Packet(u8* buffer, int bufferSize)
|
||||
ICMP_Packet::ICMP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -34,7 +34,7 @@ namespace PacketReader::IP::ICMP
|
||||
memcpy(headerData, original.headerData, 4);
|
||||
}
|
||||
|
||||
Payload* ICMP_Packet::GetPayload()
|
||||
Payload* ICMP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace PacketReader::IP::ICMP
|
||||
return new ICMP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 ICMP_Packet::GetProtocol()
|
||||
u8 ICMP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace PacketReader::IP::ICMP
|
||||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(segment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(segment, pHeaderLen);
|
||||
delete[] segment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
||||
@@ -27,16 +27,16 @@ namespace PacketReader::IP::ICMP
|
||||
public:
|
||||
//Takes ownership of payload
|
||||
ICMP_Packet(Payload* data);
|
||||
ICMP_Packet(u8* buffer, int bufferSize);
|
||||
ICMP_Packet(const u8* buffer, int bufferSize);
|
||||
ICMP_Packet(const ICMP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual ICMP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
bool IPOption::IsCopyOnFragment()
|
||||
bool IPOption::IsCopyOnFragment() const
|
||||
{
|
||||
return ((GetCode() & (1 << 0x7)) != 0);
|
||||
}
|
||||
u8 IPOption::GetClass()
|
||||
u8 IPOption::GetClass() const
|
||||
{
|
||||
return (GetCode() >> 5) & 0x3;
|
||||
}
|
||||
u8 IPOption::GetNumber()
|
||||
u8 IPOption::GetNumber() const
|
||||
{
|
||||
return GetCode() & 0x1F;
|
||||
}
|
||||
|
||||
IPopUnk::IPopUnk(u8* data, int offset)
|
||||
IPopUnk::IPopUnk(const u8* data, int offset)
|
||||
{
|
||||
NetLib::ReadByte08(data, &offset, &code);
|
||||
NetLib::ReadByte08(data, &offset, &length);
|
||||
@@ -27,7 +27,7 @@ namespace PacketReader::IP
|
||||
value.resize(length - 2);
|
||||
NetLib::ReadByteArray(data, &offset, length - 2, &value[0]);
|
||||
}
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopUnk::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, code);
|
||||
NetLib::WriteByte08(buffer, offset, length);
|
||||
@@ -38,12 +38,12 @@ namespace PacketReader::IP
|
||||
: value{parValue}
|
||||
{
|
||||
}
|
||||
IPopRouterAlert::IPopRouterAlert(u8* data, int offset)
|
||||
IPopRouterAlert::IPopRouterAlert(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &value);
|
||||
}
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset)
|
||||
void IPopRouterAlert::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace PacketReader::IP
|
||||
class BaseOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() = 0;
|
||||
virtual u8 GetCode() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetLength() const = 0;
|
||||
virtual u8 GetCode() const = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const = 0;
|
||||
virtual BaseOption* Clone() const = 0;
|
||||
virtual ~BaseOption() {}
|
||||
};
|
||||
@@ -22,9 +22,9 @@ namespace PacketReader::IP
|
||||
class IPOption : public BaseOption
|
||||
{
|
||||
public:
|
||||
bool IsCopyOnFragment();
|
||||
u8 GetClass(); //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber();
|
||||
bool IsCopyOnFragment() const;
|
||||
u8 GetClass() const; //0 = control, 2 = debugging and measurement
|
||||
u8 GetNumber() const;
|
||||
virtual IPOption* Clone() const = 0;
|
||||
};
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace PacketReader::IP
|
||||
std::vector<u8> value;
|
||||
|
||||
public:
|
||||
IPopUnk(u8* data, int offset);
|
||||
IPopUnk(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return length; }
|
||||
virtual u8 GetCode() { return code; }
|
||||
virtual u8 GetLength() const { return length; }
|
||||
virtual u8 GetCode() const { return code; }
|
||||
|
||||
void WriteBytes(u8* buffer, int* offset);
|
||||
void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopUnk* Clone() const
|
||||
{
|
||||
@@ -51,10 +51,10 @@ namespace PacketReader::IP
|
||||
class IPopNOP : public IPOption
|
||||
{
|
||||
public:
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -73,12 +73,12 @@ namespace PacketReader::IP
|
||||
u16 value;
|
||||
|
||||
IPopRouterAlert(u16 parValue);
|
||||
IPopRouterAlert(u8* data, int offset);
|
||||
IPopRouterAlert(const u8* data, int offset);
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 148; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 148; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual IPopRouterAlert* Clone() const
|
||||
{
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
namespace PacketReader::IP
|
||||
{
|
||||
int IP_Packet::GetHeaderLength()
|
||||
int IP_Packet::GetHeaderLength() const
|
||||
{
|
||||
return headerLength;
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpValue()
|
||||
u8 IP_Packet::GetDscpValue() const
|
||||
{
|
||||
return (dscp >> 2) & 0x3F;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace PacketReader::IP
|
||||
dscp = (dscp & ~(0x3F << 2)) | ((value & 0x3F) << 2);
|
||||
}
|
||||
|
||||
u8 IP_Packet::GetDscpECN()
|
||||
u8 IP_Packet::GetDscpECN() const
|
||||
{
|
||||
return dscp & 0x3;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace PacketReader::IP
|
||||
dscp = (dscp & ~0x3) | (value & 0x3);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetDoNotFragment()
|
||||
bool IP_Packet::GetDoNotFragment() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 6)) != 0;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace PacketReader::IP
|
||||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool IP_Packet::GetMoreFragments()
|
||||
bool IP_Packet::GetMoreFragments() const
|
||||
{
|
||||
return (fragmentFlags1 & (1 << 5)) != 0;
|
||||
}
|
||||
@@ -50,11 +50,11 @@ namespace PacketReader::IP
|
||||
fragmentFlags1 = (fragmentFlags1 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
u16 IP_Packet::GetFragmentOffset()
|
||||
u16 IP_Packet::GetFragmentOffset() const
|
||||
{
|
||||
int x = 0;
|
||||
u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
const u8 fF1masked = fragmentFlags1 & 0x1F;
|
||||
const u8 data[2] = {fF1masked, fragmentFlags2};
|
||||
u16 offset;
|
||||
NetLib::ReadUInt16(data, &x, &offset);
|
||||
return offset;
|
||||
@@ -66,7 +66,7 @@ namespace PacketReader::IP
|
||||
{
|
||||
}
|
||||
|
||||
IP_Packet::IP_Packet(u8* buffer, int bufferSize, bool fromICMP)
|
||||
IP_Packet::IP_Packet(const u8* buffer, int bufferSize, bool fromICMP)
|
||||
{
|
||||
int offset = 0;
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace PacketReader::IP
|
||||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -154,7 +154,7 @@ namespace PacketReader::IP
|
||||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
IP_Payload* IP_Packet::GetPayload()
|
||||
IP_Payload* IP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace PacketReader::IP
|
||||
|
||||
void IP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
CalculateChecksum(); //ReComputeHeaderLen called in CalculateChecksum
|
||||
payload->CalculateChecksum(sourceIP, destinationIP);
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace PacketReader::IP
|
||||
delete options[i];
|
||||
}
|
||||
|
||||
u16 IP_Packet::InternetChecksum(u8* buffer, int length)
|
||||
u16 IP_Packet::InternetChecksum(const u8* buffer, int length)
|
||||
{
|
||||
//source http://stackoverflow.com/a/2201090
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace PacketReader::IP
|
||||
std::unique_ptr<IP_Payload> payload;
|
||||
|
||||
public:
|
||||
int GetHeaderLength();
|
||||
int GetHeaderLength() const;
|
||||
|
||||
//DSCP/TOS Flags
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace PacketReader::IP
|
||||
* Class 5, Expedited Forwarding, 3
|
||||
* bit0: Set to zero
|
||||
*/
|
||||
u8 GetDscpValue();
|
||||
u8 GetDscpValue() const;
|
||||
void SetDscpValue(u8 value);
|
||||
|
||||
/* 2 bits
|
||||
@@ -97,34 +97,34 @@ namespace PacketReader::IP
|
||||
* 1,2 ECN Supported
|
||||
* 3 = Congestion Encountered
|
||||
*/
|
||||
u8 GetDscpECN();
|
||||
u8 GetDscpECN() const;
|
||||
void SetDscpECN(u8 value);
|
||||
|
||||
//Fragment Flags
|
||||
//bit 0, reserverd
|
||||
|
||||
bool GetDoNotFragment();
|
||||
bool GetDoNotFragment() const;
|
||||
void SetDoNotFragment(bool value);
|
||||
|
||||
bool GetMoreFragments();
|
||||
bool GetMoreFragments() const;
|
||||
void SetMoreFragments(bool value);
|
||||
|
||||
//Untested
|
||||
u16 GetFragmentOffset();
|
||||
u16 GetFragmentOffset() const;
|
||||
|
||||
//Takes ownership of payload
|
||||
IP_Packet(IP_Payload* data);
|
||||
IP_Packet(u8* buffer, int bufferSize, bool fromICMP = false);
|
||||
IP_Packet(const u8* buffer, int bufferSize, bool fromICMP = false);
|
||||
IP_Packet(const IP_Packet&);
|
||||
|
||||
IP_Payload* GetPayload();
|
||||
IP_Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual IP_Packet* Clone() const;
|
||||
|
||||
bool VerifyChecksum();
|
||||
static u16 InternetChecksum(u8* buffer, int length);
|
||||
static u16 InternetChecksum(const u8* buffer, int length);
|
||||
|
||||
~IP_Packet();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PacketReader::IP
|
||||
public: //Nedd GetProtocol
|
||||
virtual int GetLength() = 0;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) = 0;
|
||||
virtual u8 GetProtocol() = 0;
|
||||
virtual u8 GetProtocol() const = 0;
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP) { return false; }
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP) {}
|
||||
virtual IP_Payload* Clone() const = 0;
|
||||
@@ -25,23 +25,21 @@ namespace PacketReader::IP
|
||||
std::unique_ptr<u8[]> data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
u8 protocol;
|
||||
const int length;
|
||||
const u8 protocol;
|
||||
|
||||
public:
|
||||
IP_PayloadData(int len, u8 prot)
|
||||
: length{len}
|
||||
, protocol{prot}
|
||||
{
|
||||
protocol = prot;
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
IP_PayloadData(const IP_PayloadData& original)
|
||||
: length{original.length}
|
||||
, protocol{original.protocol}
|
||||
{
|
||||
protocol = original.protocol;
|
||||
length = original.length;
|
||||
|
||||
if (length != 0)
|
||||
{
|
||||
data = std::make_unique<u8[]>(length);
|
||||
@@ -60,7 +58,7 @@ namespace PacketReader::IP
|
||||
memcpy(&buffer[*offset], data.get(), length);
|
||||
*offset += length;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
@@ -74,18 +72,18 @@ namespace PacketReader::IP
|
||||
class IP_PayloadPtr : public IP_Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
const u8* data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
u8 protocol;
|
||||
const int length;
|
||||
const u8 protocol;
|
||||
|
||||
public:
|
||||
IP_PayloadPtr(u8* ptr, int len, u8 prot)
|
||||
IP_PayloadPtr(const u8* ptr, int len, u8 prot)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
, protocol{prot}
|
||||
{
|
||||
data = ptr;
|
||||
length = len;
|
||||
protocol = prot;
|
||||
}
|
||||
IP_PayloadPtr(const IP_PayloadPtr&) = delete;
|
||||
virtual int GetLength()
|
||||
@@ -108,7 +106,7 @@ namespace PacketReader::IP
|
||||
memcpy(ret->data.get(), data, length);
|
||||
return ret;
|
||||
}
|
||||
virtual u8 GetProtocol()
|
||||
virtual u8 GetProtocol() const
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace PacketReader::IP::TCP
|
||||
: maxSegmentSize{mss}
|
||||
{
|
||||
}
|
||||
TCPopMSS::TCPopMSS(u8* data, int offset)
|
||||
TCPopMSS::TCPopMSS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxSegmentSize);
|
||||
}
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopMSS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
@@ -27,12 +27,12 @@ namespace PacketReader::IP::TCP
|
||||
: windowScale{ws}
|
||||
{
|
||||
}
|
||||
TCPopWS::TCPopWS(u8* data, int offset)
|
||||
TCPopWS::TCPopWS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &windowScale);
|
||||
}
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopWS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
@@ -45,13 +45,13 @@ namespace PacketReader::IP::TCP
|
||||
, echoTimeStamp{echoTS}
|
||||
{
|
||||
}
|
||||
TCPopTS::TCPopTS(u8* data, int offset)
|
||||
TCPopTS::TCPopTS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &senderTimeStamp);
|
||||
NetLib::ReadUInt32(data, &offset, &echoTimeStamp);
|
||||
}
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset)
|
||||
void TCPopTS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength());
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace PacketReader::IP::TCP
|
||||
{
|
||||
class TCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -30,12 +30,12 @@ namespace PacketReader::IP::TCP
|
||||
u16 maxSegmentSize;
|
||||
|
||||
TCPopMSS(u16 mss);
|
||||
TCPopMSS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopMSS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 2; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 2; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopMSS* Clone() const
|
||||
{
|
||||
@@ -49,12 +49,12 @@ namespace PacketReader::IP::TCP
|
||||
u8 windowScale;
|
||||
|
||||
TCPopWS(u8 ws);
|
||||
TCPopWS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopWS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopWS* Clone() const
|
||||
{
|
||||
@@ -69,12 +69,12 @@ namespace PacketReader::IP::TCP
|
||||
u32 echoTimeStamp;
|
||||
|
||||
TCPopTS(u32 senderTS, u32 echoTS);
|
||||
TCPopTS(u8* data, int offset); //Offset will include Kind and Len
|
||||
TCPopTS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 10; }
|
||||
virtual u8 GetCode() { return 8; }
|
||||
virtual u8 GetLength() const { return 10; }
|
||||
virtual u8 GetCode() const { return 8; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual TCPopTS* Clone() const
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace PacketReader::IP::TCP
|
||||
{
|
||||
//Need flags
|
||||
bool TCP_Packet::GetNS()
|
||||
bool TCP_Packet::GetNS() const
|
||||
{
|
||||
return (dataOffsetAndNS_Flag & 1);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace PacketReader::IP::TCP
|
||||
dataOffsetAndNS_Flag = (dataOffsetAndNS_Flag & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetCWR()
|
||||
bool TCP_Packet::GetCWR() const
|
||||
{
|
||||
return (flags & (1 << 7));
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetECE()
|
||||
bool TCP_Packet::GetECE() const
|
||||
{
|
||||
return (flags & (1 << 6));
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetURG()
|
||||
bool TCP_Packet::GetURG() const
|
||||
{
|
||||
return (flags & (1 << 5));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetACK()
|
||||
bool TCP_Packet::GetACK() const
|
||||
{
|
||||
return (flags & (1 << 4));
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetPSH()
|
||||
bool TCP_Packet::GetPSH() const
|
||||
{
|
||||
return (flags & (1 << 3));
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 3)) | ((value & 0x1) << 3);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetRST()
|
||||
bool TCP_Packet::GetRST() const
|
||||
{
|
||||
return (flags & (1 << 2));
|
||||
}
|
||||
@@ -73,7 +73,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetSYN()
|
||||
bool TCP_Packet::GetSYN() const
|
||||
{
|
||||
return (flags & (1 << 1));
|
||||
}
|
||||
@@ -82,7 +82,7 @@ namespace PacketReader::IP::TCP
|
||||
flags = (flags & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool TCP_Packet::GetFIN()
|
||||
bool TCP_Packet::GetFIN() const
|
||||
{
|
||||
return (flags & 1);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace PacketReader::IP::TCP
|
||||
, payload{data}
|
||||
{
|
||||
}
|
||||
TCP_Packet::TCP_Packet(u8* buffer, int bufferSize)
|
||||
TCP_Packet::TCP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -125,8 +125,8 @@ namespace PacketReader::IP::TCP
|
||||
bool opReadFin = false;
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opKind = buffer[offset];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -180,7 +180,7 @@ namespace PacketReader::IP::TCP
|
||||
options.push_back(original.options[i]->Clone());
|
||||
}
|
||||
|
||||
Payload* TCP_Packet::GetPayload()
|
||||
Payload* TCP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace PacketReader::IP::TCP
|
||||
|
||||
void TCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int startOff = *offset;
|
||||
const int startOff = *offset;
|
||||
NetLib::WriteUInt16(buffer, offset, sourcePort);
|
||||
NetLib::WriteUInt16(buffer, offset, destinationPort);
|
||||
NetLib::WriteUInt32(buffer, offset, sequenceNumber);
|
||||
@@ -222,7 +222,7 @@ namespace PacketReader::IP::TCP
|
||||
return new TCP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 TCP_Packet::GetProtocol()
|
||||
u8 TCP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ namespace PacketReader::IP::TCP
|
||||
headerLength = Common::AlignUpPow2(opOffset, 4);
|
||||
|
||||
//Also write into dataOffsetAndNS_Flag
|
||||
u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
const u8 ns = dataOffsetAndNS_Flag & 1;
|
||||
dataOffsetAndNS_Flag = (headerLength >> 2) << 4;
|
||||
dataOffsetAndNS_Flag |= ns;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace PacketReader::IP::TCP
|
||||
if (counter != pHeaderLen)
|
||||
NetLib::WriteByte08(headerSegment, &counter, 0);
|
||||
|
||||
u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
const u16 csumCal = IP_Packet::InternetChecksum(headerSegment, pHeaderLen);
|
||||
delete[] headerSegment;
|
||||
|
||||
return (csumCal == 0);
|
||||
|
||||
@@ -38,45 +38,45 @@ namespace PacketReader::IP::TCP
|
||||
|
||||
public:
|
||||
//Flags
|
||||
bool GetNS();
|
||||
bool GetNS() const;
|
||||
void SetNS(bool value);
|
||||
|
||||
bool GetCWR();
|
||||
bool GetCWR() const;
|
||||
void SetCWR(bool value);
|
||||
|
||||
bool GetECE();
|
||||
bool GetECE() const;
|
||||
void SetECE(bool value);
|
||||
|
||||
bool GetURG();
|
||||
bool GetURG() const;
|
||||
void SetURG(bool value);
|
||||
|
||||
bool GetACK();
|
||||
bool GetACK() const;
|
||||
void SetACK(bool value);
|
||||
|
||||
bool GetPSH();
|
||||
bool GetPSH() const;
|
||||
void SetPSH(bool value);
|
||||
|
||||
bool GetRST();
|
||||
bool GetRST() const;
|
||||
void SetRST(bool value);
|
||||
|
||||
bool GetSYN();
|
||||
bool GetSYN() const;
|
||||
void SetSYN(bool value);
|
||||
|
||||
bool GetFIN();
|
||||
bool GetFIN() const;
|
||||
void SetFIN(bool value);
|
||||
|
||||
//Takes ownership of payload
|
||||
TCP_Packet(Payload* data);
|
||||
TCP_Packet(u8* buffer, int bufferSize);
|
||||
TCP_Packet(const u8* buffer, int bufferSize);
|
||||
TCP_Packet(const TCP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual TCP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -12,12 +12,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: subnetMask{mask}
|
||||
{
|
||||
}
|
||||
DHCPopSubnet::DHCPopSubnet(u8* data, int offset)
|
||||
DHCPopSubnet::DHCPopSubnet(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &subnetMask);
|
||||
}
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSubnet::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -28,7 +28,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: routers{routerIPs}
|
||||
{
|
||||
}
|
||||
DHCPopRouter::DHCPopRouter(u8* data, int offset)
|
||||
DHCPopRouter::DHCPopRouter(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -37,7 +37,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
routers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopRouter::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: dnsServers{dnsIPs}
|
||||
{
|
||||
}
|
||||
DHCPopDNS::DHCPopDNS(u8* data, int offset)
|
||||
DHCPopDNS::DHCPopDNS(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -58,7 +58,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
dnsServers = {(IP_Address*)&data[offset], (IP_Address*)&data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDNS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -76,7 +76,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
hostName = name;
|
||||
}
|
||||
DHCPopHostName::DHCPopHostName(u8* data, int offset)
|
||||
DHCPopHostName::DHCPopHostName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -84,7 +84,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
hostName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopHostName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -92,7 +92,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
NetLib::WriteByteArray(buffer, offset, hostName.size(), (u8*)hostName.c_str());
|
||||
}
|
||||
|
||||
DHCPopDnsName::DHCPopDnsName(std::string name)
|
||||
DHCPopDnsName::DHCPopDnsName(const std::string& name)
|
||||
{
|
||||
if (name.size() > 255)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
domainName = name;
|
||||
}
|
||||
DHCPopDnsName::DHCPopDnsName(u8* data, int offset)
|
||||
DHCPopDnsName::DHCPopDnsName(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -110,7 +110,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
domainName = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopDnsName::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -122,12 +122,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: broadcastIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopBCIP::DHCPopBCIP(u8* data, int offset)
|
||||
DHCPopBCIP::DHCPopBCIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &broadcastIP);
|
||||
}
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopBCIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -135,7 +135,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
NetLib::WriteIPAddress(buffer, offset, broadcastIP);
|
||||
}
|
||||
|
||||
bool DHCPopNBIOSType::GetHNode()
|
||||
bool DHCPopNBIOSType::GetHNode() const
|
||||
{
|
||||
return ((type & (1 << 3)) != 0);
|
||||
}
|
||||
@@ -150,7 +150,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 3);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetMNode()
|
||||
bool DHCPopNBIOSType::GetMNode() const
|
||||
{
|
||||
return ((type & (1 << 2)) != 0);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 2);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetPNode()
|
||||
bool DHCPopNBIOSType::GetPNode() const
|
||||
{
|
||||
return ((type & (1 << 1)) != 0);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
type &= ~(1 << 1);
|
||||
}
|
||||
}
|
||||
bool DHCPopNBIOSType::GetBNode()
|
||||
bool DHCPopNBIOSType::GetBNode() const
|
||||
{
|
||||
return ((type & 1) != 0);
|
||||
}
|
||||
@@ -196,12 +196,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
}
|
||||
}
|
||||
//
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(u8* data, int offset)
|
||||
DHCPopNBIOSType::DHCPopNBIOSType(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &type);
|
||||
}
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopNBIOSType::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -213,12 +213,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: requestedIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopREQIP::DHCPopREQIP(u8* data, int offset)
|
||||
DHCPopREQIP::DHCPopREQIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &requestedIP);
|
||||
}
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -230,12 +230,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipLeaseTime{LeaseTime}
|
||||
{
|
||||
}
|
||||
DHCPopIPLT::DHCPopIPLT(u8* data, int offset)
|
||||
DHCPopIPLT::DHCPopIPLT(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipLeaseTime);
|
||||
}
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopIPLT::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -247,12 +247,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: message{msg}
|
||||
{
|
||||
}
|
||||
DHCPopMSG::DHCPopMSG(u8* data, int offset)
|
||||
DHCPopMSG::DHCPopMSG(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadByte08(data, &offset, &message);
|
||||
}
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSG::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -264,12 +264,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: serverIP{data}
|
||||
{
|
||||
}
|
||||
DHCPopSERVIP::DHCPopSERVIP(u8* data, int offset)
|
||||
DHCPopSERVIP::DHCPopSERVIP(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadIPAddress(data, &offset, &serverIP);
|
||||
}
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopSERVIP::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -281,7 +281,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: requests{requestList}
|
||||
{
|
||||
}
|
||||
DHCPopREQLIST::DHCPopREQLIST(u8* data, int offset)
|
||||
DHCPopREQLIST::DHCPopREQLIST(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -290,7 +290,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
requests = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopREQLIST::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -308,7 +308,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
message = msg;
|
||||
}
|
||||
DHCPopMSGStr::DHCPopMSGStr(u8* data, int offset)
|
||||
DHCPopMSGStr::DHCPopMSGStr(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -316,7 +316,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
message = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMSGStr::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -328,12 +328,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: maxMessageSize{mms}
|
||||
{
|
||||
}
|
||||
DHCPopMMSGS::DHCPopMMSGS(u8* data, int offset)
|
||||
DHCPopMMSGS::DHCPopMMSGS(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt16(data, &offset, &maxMessageSize);
|
||||
}
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopMMSGS::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -345,12 +345,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipRenewalTimeT1{t1}
|
||||
{
|
||||
}
|
||||
DHCPopT1::DHCPopT1(u8* data, int offset)
|
||||
DHCPopT1::DHCPopT1(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRenewalTimeT1);
|
||||
}
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT1::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -362,12 +362,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: ipRebindingTimeT2{t2}
|
||||
{
|
||||
}
|
||||
DHCPopT2::DHCPopT2(u8* data, int offset)
|
||||
DHCPopT2::DHCPopT2(const u8* data, int offset)
|
||||
{
|
||||
offset += 2;
|
||||
NetLib::ReadUInt32(data, &offset, &ipRebindingTimeT2);
|
||||
}
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopT2::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -385,7 +385,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
else
|
||||
classID = id;
|
||||
}
|
||||
DHCPopClassID::DHCPopClassID(u8* data, int offset)
|
||||
DHCPopClassID::DHCPopClassID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -393,7 +393,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
classID = std::string((char*)&data[offset], len);
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClassID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
@@ -405,7 +405,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
: clientID{value}
|
||||
{
|
||||
}
|
||||
DHCPopClientID::DHCPopClientID(u8* data, int offset)
|
||||
DHCPopClientID::DHCPopClientID(const u8* data, int offset)
|
||||
{
|
||||
offset += 1;
|
||||
u8 len;
|
||||
@@ -414,7 +414,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
clientID = {&data[offset], &data[offset + len]};
|
||||
//offset += len;
|
||||
}
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset)
|
||||
void DHCPopClientID::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
NetLib::WriteByte08(buffer, offset, GetCode());
|
||||
NetLib::WriteByte08(buffer, offset, GetLength() - 2);
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
//GetLength(), howver, includes the option header
|
||||
class DHCPopNOP : public BaseOption
|
||||
{
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 0; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 0; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
@@ -35,12 +35,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address subnetMask{};
|
||||
|
||||
DHCPopSubnet(IP_Address mask);
|
||||
DHCPopSubnet(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSubnet(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 1; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 1; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSubnet* Clone() const
|
||||
{
|
||||
@@ -53,12 +53,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
std::vector<IP_Address> routers;
|
||||
DHCPopRouter(const std::vector<IP_Address>& routerIPs);
|
||||
DHCPopRouter(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopRouter(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() { return 3; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * routers.size(); }
|
||||
virtual u8 GetCode() const { return 3; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopRouter* Clone() const
|
||||
{
|
||||
@@ -71,12 +71,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
std::vector<IP_Address> dnsServers;
|
||||
DHCPopDNS(const std::vector<IP_Address>& dnsIPs);
|
||||
DHCPopDNS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDNS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() { return 6; }
|
||||
virtual u8 GetLength() const { return 2 + 4 * dnsServers.size(); }
|
||||
virtual u8 GetCode() const { return 6; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDNS* Clone() const
|
||||
{
|
||||
@@ -91,12 +91,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string hostName;
|
||||
|
||||
DHCPopHostName(const std::string& name);
|
||||
DHCPopHostName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopHostName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() { return 12; }
|
||||
virtual u8 GetLength() const { return 2 + hostName.size(); }
|
||||
virtual u8 GetCode() const { return 12; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopHostName* Clone() const
|
||||
{
|
||||
@@ -110,13 +110,13 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
//ASCII encoding
|
||||
std::string domainName;
|
||||
|
||||
DHCPopDnsName(std::string name);
|
||||
DHCPopDnsName(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopDnsName(const std::string& name);
|
||||
DHCPopDnsName(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() { return 15; }
|
||||
virtual u8 GetLength() const { return 2 + domainName.size(); }
|
||||
virtual u8 GetCode() const { return 15; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopDnsName* Clone() const
|
||||
{
|
||||
@@ -130,12 +130,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address broadcastIP{};
|
||||
|
||||
DHCPopBCIP(IP_Address data);
|
||||
DHCPopBCIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopBCIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 28; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 28; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopBCIP* Clone() const
|
||||
{
|
||||
@@ -151,24 +151,24 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
public:
|
||||
//Getters/Setters
|
||||
bool GetHNode();
|
||||
bool GetHNode() const;
|
||||
void SetHNode(bool value);
|
||||
|
||||
bool GetMNode();
|
||||
bool GetMNode() const;
|
||||
void SetMNode(bool value);
|
||||
|
||||
bool GetPNode();
|
||||
bool GetPNode() const;
|
||||
void SetPNode(bool value);
|
||||
|
||||
bool GetBNode();
|
||||
bool GetBNode() const;
|
||||
void SetBNode(bool value);
|
||||
|
||||
DHCPopNBIOSType(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopNBIOSType(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 46; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 46; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopNBIOSType* Clone() const
|
||||
{
|
||||
@@ -182,12 +182,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address requestedIP{};
|
||||
|
||||
DHCPopREQIP(IP_Address data);
|
||||
DHCPopREQIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 50; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 50; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQIP* Clone() const
|
||||
{
|
||||
@@ -201,12 +201,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipLeaseTime;
|
||||
|
||||
DHCPopIPLT(u32 LeaseTime);
|
||||
DHCPopIPLT(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopIPLT(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 51; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 51; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopIPLT* Clone() const
|
||||
{
|
||||
@@ -219,12 +219,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
u8 message;
|
||||
DHCPopMSG(u8 msg);
|
||||
DHCPopMSG(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSG(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 3; }
|
||||
virtual u8 GetCode() { return 53; }
|
||||
virtual u8 GetLength() const { return 3; }
|
||||
virtual u8 GetCode() const { return 53; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSG* Clone() const
|
||||
{
|
||||
@@ -238,12 +238,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
IP_Address serverIP{};
|
||||
|
||||
DHCPopSERVIP(IP_Address data);
|
||||
DHCPopSERVIP(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopSERVIP(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 54; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 54; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopSERVIP* Clone() const
|
||||
{
|
||||
@@ -257,12 +257,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::vector<u8> requests;
|
||||
|
||||
DHCPopREQLIST(const std::vector<u8>& requestList);
|
||||
DHCPopREQLIST(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopREQLIST(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() { return 55; }
|
||||
virtual u8 GetLength() const { return 2 + requests.size(); }
|
||||
virtual u8 GetCode() const { return 55; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopREQLIST* Clone() const
|
||||
{
|
||||
@@ -277,12 +277,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string message;
|
||||
|
||||
DHCPopMSGStr(const std::string& msg);
|
||||
DHCPopMSGStr(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMSGStr(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + message.size(); }
|
||||
virtual u8 GetCode() { return 56; }
|
||||
virtual u8 GetLength() const { return 2 + message.size(); }
|
||||
virtual u8 GetCode() const { return 56; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMSGStr* Clone() const
|
||||
{
|
||||
@@ -296,12 +296,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u16 maxMessageSize;
|
||||
|
||||
DHCPopMMSGS(u16 mms);
|
||||
DHCPopMMSGS(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopMMSGS(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 4; }
|
||||
virtual u8 GetCode() { return 57; }
|
||||
virtual u8 GetLength() const { return 4; }
|
||||
virtual u8 GetCode() const { return 57; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopMMSGS* Clone() const
|
||||
{
|
||||
@@ -315,12 +315,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipRenewalTimeT1;
|
||||
|
||||
DHCPopT1(u32 t1);
|
||||
DHCPopT1(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT1(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 58; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 58; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT1* Clone() const
|
||||
{
|
||||
@@ -334,12 +334,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
u32 ipRebindingTimeT2;
|
||||
|
||||
DHCPopT2(u32 t2);
|
||||
DHCPopT2(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopT2(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 6; }
|
||||
virtual u8 GetCode() { return 59; }
|
||||
virtual u8 GetLength() const { return 6; }
|
||||
virtual u8 GetCode() const { return 59; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopT2* Clone() const
|
||||
{
|
||||
@@ -354,12 +354,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::string classID;
|
||||
|
||||
DHCPopClassID(const std::string& id);
|
||||
DHCPopClassID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClassID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() { return 60; }
|
||||
virtual u8 GetLength() const { return 2 + classID.size(); }
|
||||
virtual u8 GetCode() const { return 60; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClassID* Clone() const
|
||||
{
|
||||
@@ -373,12 +373,12 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
std::vector<u8> clientID;
|
||||
|
||||
DHCPopClientID(const std::vector<u8>& value);
|
||||
DHCPopClientID(u8* data, int offset); //Offset will include Kind and Len
|
||||
DHCPopClientID(const u8* data, int offset); //Offset will include Kind and Len
|
||||
|
||||
virtual u8 GetLength() { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() { return 61; }
|
||||
virtual u8 GetLength() const { return 2 + clientID.size(); }
|
||||
virtual u8 GetCode() const { return 61; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual DHCPopClientID* Clone() const
|
||||
{
|
||||
@@ -391,10 +391,10 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
public:
|
||||
DHCPopEND() {}
|
||||
|
||||
virtual u8 GetLength() { return 1; }
|
||||
virtual u8 GetCode() { return 255; }
|
||||
virtual u8 GetLength() const { return 1; }
|
||||
virtual u8 GetCode() const { return 255; }
|
||||
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
buffer[*offset] = GetCode();
|
||||
(*offset)++;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace PacketReader::IP::UDP::DHCP
|
||||
{
|
||||
DHCP_Packet::DHCP_Packet(u8* buffer, int bufferSize)
|
||||
DHCP_Packet::DHCP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
@@ -49,7 +49,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
do
|
||||
{
|
||||
u8 opKind = buffer[offset];
|
||||
const u8 opKind = buffer[offset];
|
||||
if (opKind == 255)
|
||||
{
|
||||
options.push_back(new DHCPopEND());
|
||||
@@ -64,7 +64,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
opReadFin = true;
|
||||
continue;
|
||||
}
|
||||
u8 opLen = buffer[offset + 1];
|
||||
const u8 opLen = buffer[offset + 1];
|
||||
switch (opKind)
|
||||
{
|
||||
case 0:
|
||||
@@ -172,7 +172,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
|
||||
void DHCP_Packet::WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
int start = *offset;
|
||||
const int start = *offset;
|
||||
NetLib::WriteByte08(buffer, offset, op);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareType);
|
||||
NetLib::WriteByte08(buffer, offset, hardwareAddressLength);
|
||||
@@ -210,7 +210,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
if (len == maxLength)
|
||||
{
|
||||
i -= 1;
|
||||
int pastLength = options[i]->GetLength();
|
||||
const int pastLength = options[i]->GetLength();
|
||||
len -= pastLength;
|
||||
*offset -= pastLength;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
}
|
||||
}
|
||||
|
||||
int end = start + GetLength();
|
||||
int delta = end - *offset;
|
||||
const int end = start + GetLength();
|
||||
const int delta = end - *offset;
|
||||
|
||||
memset(&buffer[*offset], 0, delta);
|
||||
*offset = start + GetLength();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DHCP
|
||||
int maxLength = 576;
|
||||
|
||||
DHCP_Packet() {}
|
||||
DHCP_Packet(u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const u8* buffer, int bufferSize);
|
||||
DHCP_Packet(const DHCP_Packet&);
|
||||
|
||||
virtual int GetLength();
|
||||
|
||||
@@ -12,20 +12,20 @@ namespace PacketReader::IP::UDP::DNS
|
||||
, entryClass{qClass}
|
||||
{
|
||||
}
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(u8* buffer, int* offset)
|
||||
DNS_QuestionEntry::DNS_QuestionEntry(const u8* buffer, int* offset)
|
||||
{
|
||||
ReadDNS_String(buffer, offset, &name);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryType);
|
||||
NetLib::ReadUInt16(buffer, offset, &entryClass);
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::ReadDNS_String(u8* buffer, int* offset, std::string* value)
|
||||
void DNS_QuestionEntry::ReadDNS_String(const u8* buffer, int* offset, std::string* value) const
|
||||
{
|
||||
*value = "";
|
||||
|
||||
while (buffer[*offset] != 0)
|
||||
{
|
||||
int len = buffer[*offset];
|
||||
const int len = buffer[*offset];
|
||||
|
||||
if (len >= 192)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
//null char
|
||||
*offset += 1;
|
||||
}
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value)
|
||||
void DNS_QuestionEntry::WriteDNS_String(u8* buffer, int* offset, const std::string& value) const
|
||||
{
|
||||
int segmentLength = 0;
|
||||
int segmentStart = 0;
|
||||
@@ -86,12 +86,12 @@ namespace PacketReader::IP::UDP::DNS
|
||||
NetLib::WriteByte08(buffer, offset, 0);
|
||||
}
|
||||
|
||||
int DNS_QuestionEntry::GetLength()
|
||||
int DNS_QuestionEntry::GetLength() const
|
||||
{
|
||||
return 1 + name.size() + 1 + 4;
|
||||
}
|
||||
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_QuestionEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
WriteDNS_String(buffer, offset, name);
|
||||
NetLib::WriteUInt16(buffer, offset, entryType);
|
||||
@@ -105,7 +105,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
{
|
||||
}
|
||||
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(u8* buffer, int* offset)
|
||||
DNS_ResponseEntry::DNS_ResponseEntry(const u8* buffer, int* offset)
|
||||
: DNS_QuestionEntry(buffer, offset)
|
||||
{
|
||||
u16 dataLen;
|
||||
@@ -116,12 +116,12 @@ namespace PacketReader::IP::UDP::DNS
|
||||
*offset += dataLen;
|
||||
}
|
||||
|
||||
int DNS_ResponseEntry::GetLength()
|
||||
int DNS_ResponseEntry::GetLength() const
|
||||
{
|
||||
return DNS_QuestionEntry::GetLength() + 4 + 2 + data.size();
|
||||
}
|
||||
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset)
|
||||
void DNS_ResponseEntry::WriteBytes(u8* buffer, int* offset) const
|
||||
{
|
||||
DNS_QuestionEntry::WriteBytes(buffer, offset);
|
||||
NetLib::WriteUInt32(buffer, offset, timeToLive);
|
||||
|
||||
@@ -18,16 +18,16 @@ namespace PacketReader::IP::UDP::DNS
|
||||
u16 entryClass;
|
||||
|
||||
DNS_QuestionEntry(const std::string& qName, u16 qType, u16 qClass);
|
||||
DNS_QuestionEntry(u8* buffer, int* offset);
|
||||
DNS_QuestionEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_QuestionEntry(){};
|
||||
|
||||
private:
|
||||
void ReadDNS_String(u8* buffer, int* offset, std::string* value);
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value);
|
||||
void ReadDNS_String(const u8* buffer, int* offset, std::string* value) const;
|
||||
void WriteDNS_String(u8* buffer, int* offset, const std::string& value) const;
|
||||
};
|
||||
|
||||
class DNS_ResponseEntry : public DNS_QuestionEntry
|
||||
@@ -37,10 +37,10 @@ namespace PacketReader::IP::UDP::DNS
|
||||
std::vector<u8> data;
|
||||
|
||||
DNS_ResponseEntry(const std::string& rName, u16 rType, u16 rClass, const std::vector<u8>& rData, u32 rTTL);
|
||||
DNS_ResponseEntry(u8* buffer, int* offset);
|
||||
DNS_ResponseEntry(const u8* buffer, int* offset);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual int GetLength() const;
|
||||
virtual void WriteBytes(u8* buffer, int* offset) const;
|
||||
|
||||
virtual ~DNS_ResponseEntry(){};
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace PacketReader::IP::UDP::DNS
|
||||
{
|
||||
bool DNS_Packet::GetQR()
|
||||
bool DNS_Packet::GetQR() const
|
||||
{
|
||||
return (flags1 & (1 << 7)) != 0;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetOpCode()
|
||||
u8 DNS_Packet::GetOpCode() const
|
||||
{
|
||||
return (flags1 >> 3) & 0xF;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0xF << 3)) | ((value & 0xF) << 3);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAA()
|
||||
bool DNS_Packet::GetAA() const
|
||||
{
|
||||
return (flags1 & (1 << 2)) != 0;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 2)) | ((value & 0x1) << 2);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetTC()
|
||||
bool DNS_Packet::GetTC() const
|
||||
{
|
||||
return (flags1 & (1 << 1)) != 0;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~(0x1 << 1)) | ((value & 0x1) << 1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRD()
|
||||
bool DNS_Packet::GetRD() const
|
||||
{
|
||||
return (flags1 & 1) != 0;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags1 & ~0x1) | (value & 0x1);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetRA()
|
||||
bool DNS_Packet::GetRA() const
|
||||
{
|
||||
return (flags2 & (1 << 7)) != 0;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 7)) | ((value & 0x1) << 7);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetZ0()
|
||||
u8 DNS_Packet::GetZ0() const
|
||||
{
|
||||
return (flags2 & (1 << 6)) != 0;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags1 = (flags2 & ~(0x1 << 6)) | ((value & 0x1) << 6);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetAD()
|
||||
bool DNS_Packet::GetAD() const
|
||||
{
|
||||
return (flags2 & (1 << 5)) != 0;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 5)) | ((value & 0x1) << 5);
|
||||
}
|
||||
|
||||
bool DNS_Packet::GetCD()
|
||||
bool DNS_Packet::GetCD() const
|
||||
{
|
||||
return (flags2 & (1 << 4)) != 0;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0x1 << 4)) | ((value & 0x1) << 4);
|
||||
}
|
||||
|
||||
u8 DNS_Packet::GetRCode()
|
||||
u8 DNS_Packet::GetRCode() const
|
||||
{
|
||||
return flags2 & 0xF;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace PacketReader::IP::UDP::DNS
|
||||
flags2 = (flags2 & ~(0xF)) | ((value & 0xF));
|
||||
}
|
||||
|
||||
DNS_Packet::DNS_Packet(u8* buffer, int bufferSize)
|
||||
DNS_Packet::DNS_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31 //Bytes 0-3
|
||||
|
||||
@@ -33,38 +33,38 @@ namespace PacketReader::IP::UDP::DNS
|
||||
std::vector<DNS_ResponseEntry> authorities;
|
||||
std::vector<DNS_ResponseEntry> additional;
|
||||
|
||||
bool GetQR();
|
||||
bool GetQR() const;
|
||||
void SetQR(bool value);
|
||||
|
||||
u8 GetOpCode();
|
||||
u8 GetOpCode() const;
|
||||
void SetOpCode(u8 value);
|
||||
|
||||
bool GetAA();
|
||||
bool GetAA() const;
|
||||
void SetAA(bool value);
|
||||
|
||||
bool GetTC();
|
||||
bool GetTC() const;
|
||||
void SetTC(bool value);
|
||||
|
||||
bool GetRD();
|
||||
bool GetRD() const;
|
||||
void SetRD(bool value);
|
||||
|
||||
bool GetRA();
|
||||
bool GetRA() const;
|
||||
void SetRA(bool value);
|
||||
|
||||
u8 GetZ0();
|
||||
u8 GetZ0() const;
|
||||
void SetZ0(u8 value);
|
||||
|
||||
bool GetAD();
|
||||
bool GetAD() const;
|
||||
void SetAD(bool value);
|
||||
|
||||
bool GetCD();
|
||||
bool GetCD() const;
|
||||
void SetCD(bool value);
|
||||
|
||||
u8 GetRCode();
|
||||
u8 GetRCode() const;
|
||||
void SetRCode(u8 value);
|
||||
|
||||
DNS_Packet() {}
|
||||
DNS_Packet(u8* buffer, int bufferSize);
|
||||
DNS_Packet(const u8* buffer, int bufferSize);
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PacketReader::IP::UDP
|
||||
: payload{data}
|
||||
{
|
||||
}
|
||||
UDP_Packet::UDP_Packet(u8* buffer, int bufferSize)
|
||||
UDP_Packet::UDP_Packet(const u8* buffer, int bufferSize)
|
||||
{
|
||||
int offset = 0;
|
||||
//Bits 0-31
|
||||
@@ -42,7 +42,7 @@ namespace PacketReader::IP::UDP
|
||||
{
|
||||
}
|
||||
|
||||
Payload* UDP_Packet::GetPayload()
|
||||
Payload* UDP_Packet::GetPayload() const
|
||||
{
|
||||
return payload.get();
|
||||
}
|
||||
@@ -67,7 +67,7 @@ namespace PacketReader::IP::UDP
|
||||
return new UDP_Packet(*this);
|
||||
}
|
||||
|
||||
u8 UDP_Packet::GetProtocol()
|
||||
u8 UDP_Packet::GetProtocol() const
|
||||
{
|
||||
return (u8)protocol;
|
||||
}
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace PacketReader::IP::UDP
|
||||
public:
|
||||
//Takes ownership of payload
|
||||
UDP_Packet(Payload* data);
|
||||
UDP_Packet(u8* buffer, int bufferSize);
|
||||
UDP_Packet(const u8* buffer, int bufferSize);
|
||||
UDP_Packet(const UDP_Packet&);
|
||||
|
||||
Payload* GetPayload();
|
||||
Payload* GetPayload() const;
|
||||
|
||||
virtual int GetLength();
|
||||
virtual void WriteBytes(u8* buffer, int* offset);
|
||||
virtual UDP_Packet* Clone() const;
|
||||
|
||||
virtual u8 GetProtocol();
|
||||
virtual u8 GetProtocol() const;
|
||||
|
||||
virtual bool VerifyChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
virtual void CalculateChecksum(IP_Address srcIP, IP_Address dstIP);
|
||||
|
||||
@@ -45,41 +45,41 @@ namespace PacketReader::NetLib
|
||||
*(PacketReader::IP::IP_Address*)&data[*index] = value;
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void WriteByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void WriteByteArray(u8* data, int* index, int length, const u8* value)
|
||||
{
|
||||
memcpy(&data[*index], value, length);
|
||||
*index += length;
|
||||
}
|
||||
|
||||
// Read.
|
||||
inline void ReadByte08(u8* data, int* index, u8* value)
|
||||
inline void ReadByte08(const u8* data, int* index, u8* value)
|
||||
{
|
||||
*value = data[*index];
|
||||
*index += sizeof(u8);
|
||||
}
|
||||
inline void ReadUInt16(u8* data, int* index, u16* value)
|
||||
inline void ReadUInt16(const u8* data, int* index, u16* value)
|
||||
{
|
||||
*value = ntohs(*(u16*)&data[*index]);
|
||||
*index += sizeof(u16);
|
||||
}
|
||||
inline void ReadUInt32(u8* data, int* index, u32* value)
|
||||
inline void ReadUInt32(const u8* data, int* index, u32* value)
|
||||
{
|
||||
*value = ntohl(*(u32*)&data[*index]);
|
||||
*index += sizeof(u32);
|
||||
}
|
||||
|
||||
// Special read.
|
||||
inline void ReadMACAddress(u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
inline void ReadMACAddress(const u8* data, int* index, PacketReader::MAC_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::MAC_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::MAC_Address);
|
||||
}
|
||||
inline void ReadIPAddress(u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
inline void ReadIPAddress(const u8* data, int* index, PacketReader::IP::IP_Address* value)
|
||||
{
|
||||
*value = *(PacketReader::IP::IP_Address*)&data[*index];
|
||||
*index += sizeof(PacketReader::IP::IP_Address);
|
||||
}
|
||||
inline void ReadByteArray(u8* data, int* index, int length, u8* value)
|
||||
inline void ReadByteArray(const u8* data, int* index, int length, u8* value)
|
||||
{
|
||||
memcpy(value, &data[*index], length);
|
||||
*index += length;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
namespace PacketReader
|
||||
@@ -30,16 +31,14 @@ namespace PacketReader
|
||||
|
||||
public:
|
||||
PayloadData(int len)
|
||||
: length{len}
|
||||
{
|
||||
length = len;
|
||||
|
||||
if (len != 0)
|
||||
data = std::make_unique<u8[]>(len);
|
||||
}
|
||||
PayloadData(const PayloadData& original)
|
||||
: length{original.length}
|
||||
{
|
||||
length = original.length;
|
||||
|
||||
if (length != 0)
|
||||
{
|
||||
data = std::make_unique<u8[]>(length);
|
||||
@@ -68,16 +67,16 @@ namespace PacketReader
|
||||
class PayloadPtr : public Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
const u8* data;
|
||||
|
||||
private:
|
||||
int length;
|
||||
const int length;
|
||||
|
||||
public:
|
||||
PayloadPtr(u8* ptr, int len)
|
||||
PayloadPtr(const u8* ptr, int len)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
{
|
||||
data = ptr;
|
||||
length = len;
|
||||
}
|
||||
PayloadPtr(const PayloadPtr&) = delete;
|
||||
virtual int GetLength()
|
||||
@@ -101,4 +100,36 @@ namespace PacketReader
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//Pointer to bytes not owned by class, used by *Editor classes only
|
||||
class PayloadPtrEditor : public Payload
|
||||
{
|
||||
public:
|
||||
u8* data;
|
||||
|
||||
private:
|
||||
const int length;
|
||||
|
||||
public:
|
||||
PayloadPtrEditor(u8* ptr, int len)
|
||||
: data{ptr}
|
||||
, length{len}
|
||||
{
|
||||
}
|
||||
PayloadPtrEditor(const PayloadPtrEditor&) = delete;
|
||||
virtual int GetLength()
|
||||
{
|
||||
return length;
|
||||
}
|
||||
virtual void WriteBytes(u8* buffer, int* offset)
|
||||
{
|
||||
pxAssert(false);
|
||||
}
|
||||
virtual Payload* Clone() const
|
||||
{
|
||||
PayloadData* ret = new PayloadData(length);
|
||||
memcpy(ret->data.get(), data, length);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
} // namespace PacketReader
|
||||
|
||||
@@ -508,10 +508,10 @@ namespace Sessions
|
||||
ipInfo.Ttl = parTimeToLive;
|
||||
DWORD ret;
|
||||
if (parAdapterIP.integer != 0)
|
||||
ret = IcmpSendEcho2Ex(icmpFile, icmpEvent, nullptr, nullptr, parAdapterIP.integer, parDestIP.integer, parPayload->data, parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
ret = IcmpSendEcho2Ex(icmpFile, icmpEvent, nullptr, nullptr, parAdapterIP.integer, parDestIP.integer, const_cast<u8*>(parPayload->data), parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(ICMP_TIMEOUT).count()));
|
||||
else
|
||||
ret = IcmpSendEcho2(icmpFile, icmpEvent, nullptr, nullptr, parDestIP.integer, parPayload->data, parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
ret = IcmpSendEcho2(icmpFile, icmpEvent, nullptr, nullptr, parDestIP.integer, const_cast<u8*>(parPayload->data), parPayload->GetLength(), &ipInfo, icmpResponseBuffer.get(), icmpResponseBufferLen,
|
||||
static_cast<DWORD>(std::chrono::duration_cast<std::chrono::milliseconds>(ICMP_TIMEOUT).count()));
|
||||
|
||||
// Documentation states that IcmpSendEcho2 returns ERROR_IO_PENDING
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Sessions
|
||||
int type;
|
||||
int code;
|
||||
int dataLength;
|
||||
u8* data;
|
||||
const u8* data;
|
||||
};
|
||||
|
||||
class Ping
|
||||
|
||||
@@ -342,7 +342,7 @@ void PCAPAdapter::SetMACBridgedRecv(NetPacket* pkt)
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
// Compare DEST IP in IP with the PS2's IP, if they match, change DEST MAC to ps2MAC.
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
if (ippkt.destinationIP == ps2IP)
|
||||
frame.SetDestinationMAC(ps2MAC);
|
||||
@@ -364,7 +364,7 @@ void PCAPAdapter::SetMACBridgedSend(NetPacket* pkt)
|
||||
EthernetFrameEditor frame(pkt);
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
ps2IP = ippkt.sourceIP;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ void PCAPAdapter::HandleFrameCheckSequence(NetPacket* pkt)
|
||||
int payloadSize = -1;
|
||||
if (frame.GetProtocol() == static_cast<u16>(EtherType::IPv4)) // IP
|
||||
{
|
||||
PayloadPtr* payload = frame.GetPayload();
|
||||
PayloadPtrEditor* payload = frame.GetPayload();
|
||||
IP_Packet ippkt(payload->data, payload->GetLength());
|
||||
payloadSize = ippkt.GetLength();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user