[tests] Added DXBC compiler executable for testing purposes

This commit is contained in:
Philip Rebohle 2017-10-16 20:41:40 +02:00
parent 0a57a4ddf5
commit dd20e09708
4 changed files with 53 additions and 0 deletions

View File

@ -19,5 +19,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
return 1;
}
return 0;
}

3
tests/dxbc/meson.build Normal file
View File

@ -0,0 +1,3 @@
test_dxbc_deps = [ dxbc_dep, dxvk_dep ]
executable('dxbc-compiler', files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true)

View File

@ -0,0 +1,47 @@
#include <iterator>
#include <fstream>
#include <spirv/dxvk_spirv_code_buffer.h>
#include <dxbc_module.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 < 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);
auto shader = module.compile();
shader->code(0).store(std::ofstream(
str::fromws(argv[2]), std::ios::binary));
return 0;
} catch (const DxvkError& e) {
Logger::err(e.message());
return 1;
}
}

View File

@ -1,3 +1,4 @@
subdir('d3d11')
subdir('dxbc')
subdir('dxgi')
subdir('dxvk')