mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +01:00
[tests] Added DXBC disassembler
This commit is contained in:
parent
9017af51ec
commit
46909f82fc
@ -1,3 +1,4 @@
|
||||
test_dxbc_deps = [ dxbc_dep, dxvk_dep ]
|
||||
|
||||
executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true)
|
||||
executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true)
|
||||
executable('dxbc-disasm', files('test_dxbc_disasm.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true)
|
55
tests/dxbc/test_dxbc_disasm.cpp
Normal file
55
tests/dxbc/test_dxbc_disasm.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include <iterator>
|
||||
#include <fstream>
|
||||
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#include <dxbc_module.h>
|
||||
#include <dxvk_shader.h>
|
||||
|
||||
#include <shellapi.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.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) {
|
||||
std::cerr << "Usage: dxbc-disasm input.dxbc" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ifstream ifile(str::fromws(argv[1]), 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);
|
||||
|
||||
Com<ID3DBlob> assembly;
|
||||
|
||||
HRESULT hr = D3DDisassemble(
|
||||
dxbcCode.data(),
|
||||
dxbcCode.size(),
|
||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING, nullptr,
|
||||
&assembly);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
std::cerr << "Failed to disassemble shader" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string data;
|
||||
data.resize(assembly->GetBufferSize());
|
||||
std::memcpy(data.data(), assembly->GetBufferPointer(), data.size());
|
||||
std::cout << data;
|
||||
return 0;
|
||||
}
|
@ -1,3 +1,7 @@
|
||||
lib_d3d11 = dxvk_compiler.find_library('d3d11')
|
||||
lib_dxgi = dxvk_compiler.find_library('dxgi')
|
||||
lib_d3dcompiler_47 = dxvk_compiler.find_library('d3dcompiler_47')
|
||||
|
||||
subdir('d3d11')
|
||||
subdir('dxbc')
|
||||
subdir('dxgi')
|
||||
|
Loading…
x
Reference in New Issue
Block a user