Skip to content

Commit 6d91713

Browse files
vpkpp: add rtx remix pkg support
1 parent f2a13ef commit 6d91713

7 files changed

Lines changed: 641 additions & 2 deletions

File tree

THIRDPARTY_LEGAL_NOTICES.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,31 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8282
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8383

8484

85+
--------------- dxvk-remix ---------------
86+
87+
MIT License
88+
89+
Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
90+
91+
Permission is hereby granted, free of charge, to any person obtaining a copy
92+
of this software and associated documentation files (the "Software"), to deal
93+
in the Software without restriction, including without limitation the rights
94+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95+
copies of the Software, and to permit persons to whom the Software is
96+
furnished to do so, subject to the following conditions:
97+
98+
The above copyright notice and this permission notice shall be included in all
99+
copies or substantial portions of the Software.
100+
101+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107+
SOFTWARE.
108+
109+
85110
--------------- emscripten ---------------
86111

87112
MIT License
@@ -107,6 +132,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107132
SOFTWARE.
108133

109134

135+
--------------- GDeflate ---------------
136+
137+
Apache License, Version 2.0
138+
139+
Copyright (c) 2020, 2021, 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
140+
Copyright (c) Microsoft Corporation. All rights reserved.
141+
142+
Licensed under the Apache License, Version 2.0 (the "License");
143+
you may not use this file except in compliance with the License.
144+
You may obtain a copy of the License at
145+
146+
http://www.apache.org/licenses/LICENSE-2.0
147+
148+
Unless required by applicable law or agreed to in writing, software
149+
distributed under the License is distributed on an "AS IS" BASIS,
150+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151+
See the License for the specific language governing permissions and
152+
limitations under the License.
153+
154+
110155
--------------- half ---------------
111156

112157
MIT License
@@ -225,6 +270,33 @@ Julian Seward, jseward@acm.org
225270
bzip2/libbzip2 version 1.1.0 of 6 September 2010
226271

227272

273+
--------------- libdeflate ---------------
274+
275+
MIT License
276+
277+
Copyright 2016 Eric Biggers
278+
Copyright 2018 Eric Biggers
279+
Copyright 2017 Jun He <jun.he@linaro.org>
280+
281+
Permission is hereby granted, free of charge, to any person obtaining a copy
282+
of this software and associated documentation files (the "Software"), to deal
283+
in the Software without restriction, including without limitation the rights
284+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
285+
copies of the Software, and to permit persons to whom the Software is
286+
furnished to do so, subject to the following conditions:
287+
288+
The above copyright notice and this permission notice shall be included in all
289+
copies or substantial portions of the Software.
290+
291+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
292+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
293+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
294+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
295+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
296+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
297+
SOFTWARE.
298+
299+
228300
--------------- liblzma ---------------
229301

230302
BSD Zero Clause License

ext/_ext.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ if(SOURCEPP_USE_VPKPP)
3131
endif()
3232

3333

34+
# gdeflate
35+
if(SOURCEPP_USE_VPKPP)
36+
add_sourcepp_remote_library(gdeflate https://github.com/craftablescience/gdeflate 315d565f65b41791eaf9504fae41f0208929f950)
37+
endif()
38+
39+
3440
# ice
3541
if(SOURCEPP_USE_VCRYPTPP)
3642
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ice")

include/vpkpp/format/PKG.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* AssetDesc and BlobDesc structs are taken from the RTX Remix source code.
3+
* https://github.com/NVIDIAGameWorks/dxvk-remix/tree/main/src/dxvk/rtx_render/rtx_asset_package.h
4+
* See THIRDPARTY_LEGAL_NOTICES.txt for more information.
5+
*/
6+
7+
#pragma once
8+
9+
#include "../PackFile.h"
10+
11+
namespace vpkpp {
12+
13+
constexpr uint32_t PKG_SIGNATURE = 0xbaadd00d;
14+
constexpr std::string_view PKG_EXTENSION = ".pkg";
15+
16+
class PKG : public PackFileReadOnly {
17+
protected:
18+
struct Asset {
19+
uint16_t nameIndex;
20+
enum class Type : uint8_t {
21+
UNKNOWN,
22+
IMAGE_1D,
23+
IMAGE_2D,
24+
IMAGE_3D,
25+
IMAGE_CUBE,
26+
BUFFER,
27+
} type;
28+
uint8_t format; // VkFormat
29+
uint16_t width;
30+
uint16_t height;
31+
uint16_t depth;
32+
uint16_t mipCount;
33+
uint16_t tailMipCount;
34+
uint16_t arraySize;
35+
uint16_t startBlobIndex;
36+
uint16_t endBlobIndex;
37+
38+
[[nodiscard]] uint32_t getBlobIndex(int frame, int face, int mip) const;
39+
};
40+
41+
struct Blob {
42+
uint64_t offset;
43+
enum class Compression : uint8_t {
44+
NONE,
45+
GDEFLATE,
46+
} compression;
47+
uint8_t flags;
48+
uint32_t size;
49+
uint32_t crc32;
50+
};
51+
52+
struct Archive {
53+
std::vector<Asset> assets;
54+
std::vector<Blob> blobs;
55+
};
56+
57+
public:
58+
/// Open a PKG file
59+
[[nodiscard]] static std::unique_ptr<PackFile> open(const std::string& path, const EntryCallback& callback = nullptr);
60+
61+
[[nodiscard]] std::optional<std::vector<std::byte>> readEntry(const std::string& path_) const override;
62+
63+
[[nodiscard]] constexpr bool isCaseSensitive() const override {
64+
return true;
65+
}
66+
67+
[[nodiscard]] std::string getTruncatedFilestem() const override;
68+
69+
[[nodiscard]] Attribute getSupportedEntryAttributes() const override;
70+
71+
protected:
72+
using PackFileReadOnly::PackFileReadOnly;
73+
74+
[[nodiscard]] bool openNumbered(uint16_t archiveIndex, const std::string& path, const EntryCallback& callback);
75+
76+
std::unordered_map<uint16_t, Archive> metadata;
77+
78+
private:
79+
VPKPP_REGISTER_PACKFILE_OPEN(PKG_EXTENSION, &PKG::open);
80+
};
81+
82+
} // namespace vpkpp

include/vpkpp/vpkpp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "format/ORE.h"
1717
#include "format/PAK.h"
1818
#include "format/PCK.h"
19+
#include "format/PKG.h"
1920
#include "format/VPK.h"
2021
#include "format/VPK_VTMB.h"
2122
#include "format/VPP.h"

src/vpkpp/_vpkpp.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_pretty_parser(vpkpp
2-
DEPS libzstd_static miniz MINIZIP::minizip sourcepp_crypto sourcepp_parser sourcepp::kvpp
2+
DEPS gdeflate libzstd_static miniz MINIZIP::minizip sourcepp_crypto sourcepp_parser sourcepp::kvpp
33
DEPS_PUBLIC tsl::hat_trie
44
PRECOMPILED_HEADERS
55
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/APK.h"
@@ -13,6 +13,7 @@ add_pretty_parser(vpkpp
1313
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/ORE.h"
1414
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/PAK.h"
1515
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/PCK.h"
16+
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/PKG.h"
1617
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/VPK.h"
1718
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/VPK_VTMB.h"
1819
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/VPP.h"
@@ -36,6 +37,7 @@ add_pretty_parser(vpkpp
3637
"${CMAKE_CURRENT_LIST_DIR}/format/ORE.cpp"
3738
"${CMAKE_CURRENT_LIST_DIR}/format/PAK.cpp"
3839
"${CMAKE_CURRENT_LIST_DIR}/format/PCK.cpp"
40+
"${CMAKE_CURRENT_LIST_DIR}/format/PKG.cpp"
3941
"${CMAKE_CURRENT_LIST_DIR}/format/VPK.cpp"
4042
"${CMAKE_CURRENT_LIST_DIR}/format/VPK_VTMB.cpp"
4143
"${CMAKE_CURRENT_LIST_DIR}/format/VPP.cpp"

src/vpkpp/format/GMA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ std::unique_ptr<PackFile> GMA::open(const std::string& path, const EntryCallback
3939
while (reader.read<uint32_t>() > 0) {
4040
Entry entry = createNewEntry();
4141

42-
auto entryPath = reader.read_string();
42+
auto entryPath = gma->cleanEntryPath(reader.read_string());
4343

4444
entry.length = reader.read<uint64_t>();
4545
reader.read(entry.crc32);

0 commit comments

Comments
 (0)