mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
feat(fp16): remove translation remnants
This commit is contained in:
parent
cb234bde74
commit
6c3571e672
5 changed files with 1 additions and 98 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,9 +1,6 @@
|
|||
[submodule "thirdparty/pe-parse"]
|
||||
path = thirdparty/pe-parse
|
||||
url = https://github.com/trailofbits/pe-parse
|
||||
[submodule "thirdparty/dxbc"]
|
||||
path = thirdparty/dxbc
|
||||
url = https://github.com/PancakeTAS/dxbc.git
|
||||
[submodule "thirdparty/toml11"]
|
||||
path = thirdparty/toml11
|
||||
url = https://github.com/ToruNiina/toml11
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ add_compile_options(-fPIC
|
|||
-Wno-deprecated-declarations
|
||||
-Wno-unused-template)
|
||||
|
||||
add_subdirectory(thirdparty/dxbc EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(thirdparty/pe-parse/pe-parser-library EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(thirdparty/toml11 EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(thirdparty/volk EXCLUDE_FROM_ALL)
|
||||
|
|
@ -45,7 +44,7 @@ set_target_properties(lsfg-vk PROPERTIES
|
|||
target_include_directories(lsfg-vk
|
||||
PUBLIC include)
|
||||
target_link_libraries(lsfg-vk PUBLIC
|
||||
pe-parse dxbc toml11 SPIRV-Tools-opt
|
||||
pe-parse toml11 SPIRV-Tools-opt)
|
||||
lsfg-vk-framegen)
|
||||
|
||||
get_target_property(TOML11_INCLUDE_DIRS toml11 INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace Extract {
|
||||
|
||||
///
|
||||
/// Translate DXBC bytecode to SPIR-V bytecode.
|
||||
///
|
||||
/// @param bytecode The DXBC bytecode to translate.
|
||||
/// @return The translated SPIR-V bytecode.
|
||||
///
|
||||
std::vector<uint8_t> translateShader(std::vector<uint8_t> bytecode);
|
||||
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#include "extract/trans.hpp"
|
||||
|
||||
#include <thirdparty/spirv.hpp>
|
||||
|
||||
#include <dxbc_modinfo.h>
|
||||
#include <dxbc_module.h>
|
||||
#include <dxbc_reader.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
using namespace Extract;
|
||||
|
||||
struct BindingOffsets {
|
||||
uint32_t bindingIndex{};
|
||||
uint32_t bindingOffset{};
|
||||
uint32_t setIndex{};
|
||||
uint32_t setOffset{};
|
||||
};
|
||||
|
||||
std::vector<uint8_t> Extract::translateShader(std::vector<uint8_t> bytecode) {
|
||||
// compile the shader
|
||||
dxvk::DxbcReader reader(reinterpret_cast<const char*>(bytecode.data()), bytecode.size());
|
||||
dxvk::DxbcModule module(reader);
|
||||
const dxvk::DxbcModuleInfo info{};
|
||||
auto code = module.compile(info, "CS");
|
||||
|
||||
// find all bindings
|
||||
std::vector<BindingOffsets> bindingOffsets;
|
||||
std::vector<uint32_t> varIds;
|
||||
for (auto ins : code) {
|
||||
if (ins.opCode() == spv::OpDecorate) {
|
||||
if (ins.arg(2) == spv::DecorationBinding) {
|
||||
const uint32_t varId = ins.arg(1);
|
||||
bindingOffsets.resize(std::max(bindingOffsets.size(), size_t(varId + 1)));
|
||||
bindingOffsets[varId].bindingIndex = ins.arg(3);
|
||||
bindingOffsets[varId].bindingOffset = ins.offset() + 3;
|
||||
varIds.push_back(varId);
|
||||
}
|
||||
|
||||
if (ins.arg(2) == spv::DecorationDescriptorSet) {
|
||||
const uint32_t varId = ins.arg(1);
|
||||
bindingOffsets.resize(std::max(bindingOffsets.size(), size_t(varId + 1)));
|
||||
bindingOffsets[varId].setIndex = ins.arg(3);
|
||||
bindingOffsets[varId].setOffset = ins.offset() + 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (ins.opCode() == spv::OpFunction)
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<BindingOffsets> validBindings;
|
||||
for (const auto varId : varIds) {
|
||||
auto info = bindingOffsets[varId];
|
||||
|
||||
if (info.bindingOffset)
|
||||
validBindings.push_back(info);
|
||||
}
|
||||
|
||||
// patch binding offset
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
||||
for (size_t i = 0; i < validBindings.size(); i++)
|
||||
code.data()[validBindings.at(i).bindingOffset] // NOLINT
|
||||
= static_cast<uint8_t>(i);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// return the new bytecode
|
||||
std::vector<uint8_t> spirvBytecode(code.size());
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(code.data()),
|
||||
code.size(), spirvBytecode.data());
|
||||
return spirvBytecode;
|
||||
}
|
||||
1
thirdparty/dxbc
vendored
1
thirdparty/dxbc
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 78ab59a8aaeb43cd1b0a5e91ba86722433a10b78
|
||||
Loading…
Add table
Reference in a new issue