1 | #include <iterator>
|
---|
2 | #include <fstream>
|
---|
3 |
|
---|
4 | #include "../../src/dxbc/dxbc_module.h"
|
---|
5 | #include "../../src/dxvk/dxvk_shader.h"
|
---|
6 |
|
---|
7 | #include <shellapi.h>
|
---|
8 | #include <windows.h>
|
---|
9 | #include <windowsx.h>
|
---|
10 |
|
---|
11 | namespace dxvk {
|
---|
12 | Logger Logger::s_instance("dxbc-compiler.log");
|
---|
13 | }
|
---|
14 |
|
---|
15 | using namespace dxvk;
|
---|
16 |
|
---|
17 | int WINAPI WinMain(HINSTANCE hInstance,
|
---|
18 | HINSTANCE hPrevInstance,
|
---|
19 | LPSTR lpCmdLine,
|
---|
20 | int nCmdShow) {
|
---|
21 | int argc = 0;
|
---|
22 | LPWSTR* argv = CommandLineToArgvW(
|
---|
23 | GetCommandLineW(), &argc);
|
---|
24 |
|
---|
25 | if (argc < 3) {
|
---|
26 | Logger::err("Usage: dxbc-compiler input.dxbc output.spv");
|
---|
27 | return 1;
|
---|
28 | }
|
---|
29 |
|
---|
30 | try {
|
---|
31 | std::string ifileName = str::fromws(argv[1]);
|
---|
32 | std::ifstream ifile(ifileName, std::ios::binary);
|
---|
33 | ifile.ignore(std::numeric_limits<std::streamsize>::max());
|
---|
34 | std::streamsize length = ifile.gcount();
|
---|
35 | ifile.clear();
|
---|
36 |
|
---|
37 | ifile.seekg(0, std::ios_base::beg);
|
---|
38 | std::vector<char> dxbcCode(length);
|
---|
39 | ifile.read(dxbcCode.data(), length);
|
---|
40 |
|
---|
41 | DxbcReader reader(dxbcCode.data(), dxbcCode.size());
|
---|
42 | DxbcModule module(reader);
|
---|
43 |
|
---|
44 | DxbcModuleInfo moduleInfo;
|
---|
45 | moduleInfo.options.useSubgroupOpsForAtomicCounters = true;
|
---|
46 | moduleInfo.options.useDemoteToHelperInvocation = true;
|
---|
47 | moduleInfo.options.minSsboAlignment = 4;
|
---|
48 | moduleInfo.xfb = nullptr;
|
---|
49 |
|
---|
50 | Rc<DxvkShader> shader = module.compile(moduleInfo, ifileName);
|
---|
51 | std::ofstream ofile(str::fromws(argv[2]), std::ios::binary);
|
---|
52 | shader->dump(ofile);
|
---|
53 | return 0;
|
---|
54 | } catch (const DxvkError& e) {
|
---|
55 | Logger::err(e.message());
|
---|
56 | return 1;
|
---|
57 | }
|
---|
58 | }
|
---|