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_disasm.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_disasm.cpp')
-rw-r--r-- | src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_disasm.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_disasm.cpp b/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_disasm.cpp new file mode 100644 index 00000000..c87ec352 --- /dev/null +++ b/src/libs/dxvk-native-1.9.2a/tests/dxbc/test_dxbc_disasm.cpp @@ -0,0 +1,60 @@ +#include <iostream> +#include <string> + +#include <d3dcompiler.h> + +#include <shellapi.h> +#include <windows.h> +#include <windowsx.h> + +#include "../../src/util/com/com_pointer.h" + +using namespace dxvk; + +int WINAPI WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) { + int argc = 0; + LPWSTR* argv = CommandLineToArgvW( + GetCommandLineW(), &argc); + + if (argc < 2 || argc > 3) { + std::cerr << "Usage: dxbc-disasm input.dxbc [output]" << std::endl; + return 1; + } + + Com<ID3DBlob> assembly; + Com<ID3DBlob> binary; + + // input file + if (FAILED(D3DReadFileToBlob(argv[1], &binary))) { + std::cerr << "Failed to read shader" << std::endl; + return 1; + } + + HRESULT hr = D3DDisassemble( + binary->GetBufferPointer(), + binary->GetBufferSize(), + D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING, nullptr, + &assembly); + + if (FAILED(hr)) { + std::cerr << "Failed to disassemble shader" << std::endl; + return 1; + } + + // output file variant + if (argc == 3 && FAILED(D3DWriteBlobToFile(assembly.ptr(), argv[2], 1))) { + std::cerr << "Failed to write shader" << std::endl; + return 1; + } + + // stdout variant + if (argc == 2) { + std::string data((const char *)assembly->GetBufferPointer(), assembly->GetBufferSize()); + std::cout << data; + } + + return 0; +} |