2017-12-06 19:06:23 +01:00
|
|
|
#include <cstring>
|
2017-12-06 18:53:25 +01:00
|
|
|
#include <fstream>
|
2018-01-18 23:59:40 +01:00
|
|
|
#include <vector>
|
2017-12-06 18:53:25 +01:00
|
|
|
|
|
|
|
#include <d3dcompiler.h>
|
|
|
|
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
2017-12-06 19:06:23 +01:00
|
|
|
#include "../test_utils.h"
|
|
|
|
|
2017-12-06 18:53:25 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-18 23:59:40 +01:00
|
|
|
std::string data((const char *)assembly->GetBufferPointer(), assembly->GetBufferSize());
|
2017-12-06 18:53:25 +01:00
|
|
|
std::cout << data;
|
|
|
|
return 0;
|
|
|
|
}
|