mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-22 16:54:27 +01:00
[tests] Remove DXBC tests
This commit is contained in:
parent
e882a7f8ba
commit
2b6a903ad9
@ -1,6 +0,0 @@
|
|||||||
test_dxbc_deps = [ dxbc_dep, dxvk_dep ]
|
|
||||||
|
|
||||||
executable('dxbc-compiler'+exe_ext, files('test_dxbc_compiler.cpp'), dependencies : test_dxbc_deps, install : true, gui_app : true)
|
|
||||||
executable('dxbc-disasm'+exe_ext, files('test_dxbc_disasm.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true, gui_app : true)
|
|
||||||
executable('hlsl-compiler'+exe_ext, files('test_hlsl_compiler.cpp'), dependencies : [ test_dxbc_deps, lib_d3dcompiler_47 ], install : true, gui_app : true)
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
|||||||
#include <iterator>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "../../src/dxbc/dxbc_module.h"
|
|
||||||
#include "../../src/dxvk/dxvk_shader.h"
|
|
||||||
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
|
|
||||||
namespace dxvk {
|
|
||||||
Logger Logger::s_instance("dxbc-compiler.log");
|
|
||||||
}
|
|
||||||
|
|
||||||
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::string ifileName = str::fromws(argv[1]);
|
|
||||||
std::ifstream ifile(ifileName, 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);
|
|
||||||
|
|
||||||
DxbcModuleInfo moduleInfo;
|
|
||||||
moduleInfo.options.useSubgroupOpsForAtomicCounters = true;
|
|
||||||
moduleInfo.options.minSsboAlignment = 4;
|
|
||||||
moduleInfo.xfb = nullptr;
|
|
||||||
|
|
||||||
Rc<DxvkShader> shader = module.compile(moduleInfo, ifileName);
|
|
||||||
std::ofstream ofile(str::fromws(argv[2]), std::ios::binary);
|
|
||||||
shader->dump(ofile);
|
|
||||||
return 0;
|
|
||||||
} catch (const DxvkError& e) {
|
|
||||||
Logger::err(e.message());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <d3dcompiler.h>
|
|
||||||
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
|
|
||||||
#include "../../src/util/com/com_pointer.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 < 2 || argc > 3) {
|
|
||||||
std::cerr << "Usage: dxbc-disasm input.dxbc [output]" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Com<ID3DBlob> assembly;
|
|
||||||
Com<ID3DBlob> binary;
|
|
||||||
|
|
||||||
// input file
|
|
||||||
if (FAILED(D3DReadFileToBlob(argv[1], &binary))) {
|
|
||||||
std::cerr << "Failed to read shader" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT hr = D3DDisassemble(
|
|
||||||
binary->GetBufferPointer(),
|
|
||||||
binary->GetBufferSize(),
|
|
||||||
D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING, nullptr,
|
|
||||||
&assembly);
|
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
std::cerr << "Failed to disassemble shader" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// output file variant
|
|
||||||
if (argc == 3 && FAILED(D3DWriteBlobToFile(assembly.ptr(), argv[2], 1))) {
|
|
||||||
std::cerr << "Failed to write shader" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// stdout variant
|
|
||||||
if (argc == 2) {
|
|
||||||
std::string data((const char *)assembly->GetBufferPointer(), assembly->GetBufferSize());
|
|
||||||
std::cout << data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
#include <cstring>
|
|
||||||
#include <fstream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <d3dcompiler.h>
|
|
||||||
|
|
||||||
#include <shellapi.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
|
|
||||||
#include "../test_utils.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 < 5) {
|
|
||||||
std::cerr << "Usage: hlsl-compiler target entrypoint input.hlsl output.dxbc [--strip] [--text]" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool strip = false;
|
|
||||||
bool text = false;
|
|
||||||
|
|
||||||
for (int i = 5; i < argc; i++) {
|
|
||||||
strip |= str::fromws(argv[i]) == "--strip";
|
|
||||||
text |= str::fromws(argv[i]) == "--text";
|
|
||||||
}
|
|
||||||
|
|
||||||
const LPWSTR target = argv[1];
|
|
||||||
const LPWSTR entryPoint = argv[2];
|
|
||||||
const LPWSTR inputFile = argv[3];
|
|
||||||
const LPWSTR outputFile = argv[4];
|
|
||||||
|
|
||||||
std::ifstream ifile(str::fromws(inputFile), 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> hlslCode(length);
|
|
||||||
ifile.read(hlslCode.data(), length);
|
|
||||||
|
|
||||||
Com<ID3DBlob> binary;
|
|
||||||
Com<ID3DBlob> errors;
|
|
||||||
|
|
||||||
HRESULT hr = D3DCompile(
|
|
||||||
hlslCode.data(),
|
|
||||||
hlslCode.size(),
|
|
||||||
"Shader", nullptr,
|
|
||||||
D3D_COMPILE_STANDARD_FILE_INCLUDE,
|
|
||||||
str::fromws(entryPoint).c_str(),
|
|
||||||
str::fromws(target).c_str(),
|
|
||||||
D3DCOMPILE_OPTIMIZATION_LEVEL3 |
|
|
||||||
D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES,
|
|
||||||
0, &binary, &errors);
|
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
if (errors != nullptr)
|
|
||||||
std::cerr << reinterpret_cast<const char*>(errors->GetBufferPointer()) << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strip) {
|
|
||||||
Com<ID3DBlob> strippedBlob;
|
|
||||||
|
|
||||||
hr = D3DStripShader(binary->GetBufferPointer(), binary->GetBufferSize(),
|
|
||||||
D3DCOMPILER_STRIP_REFLECTION_DATA | D3DCOMPILER_STRIP_DEBUG_INFO,
|
|
||||||
&strippedBlob);
|
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
std::cerr << "Failed to strip shader" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
binary = strippedBlob;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ofstream file;
|
|
||||||
|
|
||||||
if (str::fromws(outputFile) != "-")
|
|
||||||
file = std::ofstream(str::fromws(outputFile), std::ios::binary | std::ios::trunc);
|
|
||||||
|
|
||||||
std::ostream& outputStream = file.is_open() ? file : std::cout;
|
|
||||||
|
|
||||||
if (text) {
|
|
||||||
auto data = reinterpret_cast<const uint32_t*>(binary->GetBufferPointer());
|
|
||||||
auto size = binary->GetBufferSize() / sizeof(uint32_t);
|
|
||||||
|
|
||||||
outputStream << std::hex;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < size; i++) {
|
|
||||||
if (i && !(i & 0x7))
|
|
||||||
outputStream << std::endl;
|
|
||||||
outputStream << "0x" << std::setfill('0') << std::setw(8) << data[i] << ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
outputStream << std::endl;
|
|
||||||
} else {
|
|
||||||
outputStream.write(reinterpret_cast<const char*>(binary->GetBufferPointer()), binary->GetBufferSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
subdir('d3d9')
|
subdir('d3d9')
|
||||||
subdir('d3d11')
|
subdir('d3d11')
|
||||||
subdir('dxbc')
|
|
||||||
subdir('dxgi')
|
subdir('dxgi')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user