From 26e1a67036ac14c422cf9f334f120fd209bd9650 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 9 Nov 2019 00:13:23 +0300 Subject: [PATCH] [GPU] Separate dxbc and dxbctext shader compiler targets --- src/xenia/gpu/shader_compiler_main.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/xenia/gpu/shader_compiler_main.cc b/src/xenia/gpu/shader_compiler_main.cc index 157534f15..43d6c71cd 100644 --- a/src/xenia/gpu/shader_compiler_main.cc +++ b/src/xenia/gpu/shader_compiler_main.cc @@ -33,7 +33,8 @@ DEFINE_string(shader_input_type, "", "GPU"); DEFINE_string(shader_output, "", "Output shader file path.", "GPU"); DEFINE_string(shader_output_type, "ucode", - "Translator to use: [ucode, spirv, spirvtext, dxbc].", "GPU"); + "Translator to use: [ucode, spirv, spirvtext, dxbc, dxbctext].", + "GPU"); DEFINE_string(shader_output_patch, "", "Tessellation patch type in the generated tessellation " "evaluation (domain) shader, or unspecified to produce a vertex " @@ -103,7 +104,8 @@ int shader_compiler_main(const std::vector& args) { if (cvars::shader_output_type == "spirv" || cvars::shader_output_type == "spirvtext") { translator = std::make_unique(); - } else if (cvars::shader_output_type == "dxbc") { + } else if (cvars::shader_output_type == "dxbc" || + cvars::shader_output_type == "dxbctext") { translator = std::make_unique( 0, cvars::shader_output_dxbc_rov); } else { @@ -136,7 +138,7 @@ int shader_compiler_main(const std::vector& args) { } #if XE_PLATFORM_WIN32 ID3DBlob* dxbc_disasm_blob = nullptr; - if (cvars::shader_output_type == "dxbc") { + if (cvars::shader_output_type == "dxbctext") { HMODULE d3d_compiler = LoadLibrary(L"D3DCompiler_47.dll"); if (d3d_compiler != nullptr) { pD3DDisassemble d3d_disassemble = @@ -149,6 +151,13 @@ int shader_compiler_main(const std::vector& args) { nullptr, &dxbc_disasm_blob))) { source_data = dxbc_disasm_blob->GetBufferPointer(); source_data_size = dxbc_disasm_blob->GetBufferSize(); + // Stop at the null terminator. + for (size_t i = 0; i < source_data_size; ++i) { + if (reinterpret_cast(source_data)[i] == '\0') { + source_data_size = i; + break; + } + } } } FreeLibrary(d3d_compiler);