diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:49:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:49:04 +0000 |
commit | 16f504a9dca3fe3b70568f67b7d41241ae485288 (patch) | |
tree | c60f36ada0496ba928b7161059ba5ab1ab224f9d /src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp | |
parent | Initial commit. (diff) | |
download | virtualbox-upstream.tar.xz virtualbox-upstream.zip |
Adding upstream version 7.0.6-dfsg.upstream/7.0.6-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp')
-rw-r--r-- | src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp b/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp new file mode 100644 index 00000000..735604d7 --- /dev/null +++ b/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_compiler.cpp @@ -0,0 +1,58 @@ +#include <iterator> +#include <fstream> + +#include "../../src/dxbc/dxbc_module.h" +#include "../../src/dxvk/dxvk_shader.h" + +#include <shellapi.h> +#include <windows.h> +#include <windowsx.h> + +namespace dxvk { + Logger Logger::s_instance("dxbc-compiler.log"); +} + +using namespace dxvk; + +int WINAPI WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) { + int argc = 0; + LPWSTR* argv = CommandLineToArgvW( + GetCommandLineW(), &argc); + + if (argc < 3) { + Logger::err("Usage: dxbc-compiler input.dxbc output.spv"); + return 1; + } + + try { + std::string ifileName = str::fromws(argv[1]); + std::ifstream ifile(ifileName, std::ios::binary); + ifile.ignore(std::numeric_limits<std::streamsize>::max()); + std::streamsize length = ifile.gcount(); + ifile.clear(); + + ifile.seekg(0, std::ios_base::beg); + std::vector<char> dxbcCode(length); + ifile.read(dxbcCode.data(), length); + + DxbcReader reader(dxbcCode.data(), dxbcCode.size()); + DxbcModule module(reader); + + DxbcModuleInfo moduleInfo; + moduleInfo.options.useSubgroupOpsForAtomicCounters = true; + moduleInfo.options.useDemoteToHelperInvocation = true; + moduleInfo.options.minSsboAlignment = 4; + moduleInfo.xfb = nullptr; + + Rc<DxvkShader> shader = module.compile(moduleInfo, ifileName); + std::ofstream ofile(str::fromws(argv[2]), std::ios::binary); + shader->dump(ofile); + return 0; + } catch (const DxvkError& e) { + Logger::err(e.message()); + return 1; + } +} |