mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 10:54:16 +01:00
[tests] Added DXBC compiler executable for testing purposes
This commit is contained in:
parent
0a57a4ddf5
commit
dd20e09708
@ -19,5 +19,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
3
tests/dxbc/meson.build
Normal file
3
tests/dxbc/meson.build
Normal 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)
|
47
tests/dxbc/test_dxbc_compiler.cpp
Normal file
47
tests/dxbc/test_dxbc_compiler.cpp
Normal 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;
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
subdir('d3d11')
|
||||
subdir('dxbc')
|
||||
subdir('dxgi')
|
||||
subdir('dxvk')
|
Loading…
x
Reference in New Issue
Block a user