2017-10-16 20:41:40 +02:00
|
|
|
#include <iterator>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include <dxbc_module.h>
|
2017-10-18 09:50:30 +02:00
|
|
|
#include <dxvk_shader.h>
|
2017-10-16 20:41:40 +02:00
|
|
|
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
2017-12-06 23:36:11 +01:00
|
|
|
namespace dxvk {
|
|
|
|
Logger Logger::s_instance("dxbc-compiler.log");
|
|
|
|
}
|
|
|
|
|
2017-10-16 20:41:40 +02: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 < 3) {
|
|
|
|
Logger::err("Usage: dxbc-compiler input.dxbc output.spv");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
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);
|
|
|
|
|
|
|
|
DxbcReader reader(dxbcCode.data(), dxbcCode.size());
|
|
|
|
DxbcModule module(reader);
|
|
|
|
|
2018-01-07 20:05:27 +01:00
|
|
|
Rc<DxvkShader> shader = module.compile(DxbcOptions());
|
2017-12-08 18:14:05 +01:00
|
|
|
shader->dump(std::ofstream(
|
2017-10-16 20:41:40 +02:00
|
|
|
str::fromws(argv[2]), std::ios::binary));
|
|
|
|
return 0;
|
|
|
|
} catch (const DxvkError& e) {
|
|
|
|
Logger::err(e.message());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|