mirror of
https://github.com/redstrate/Novus.git
synced 2025-05-01 15:57:45 +00:00
I started writing this late last year, and finally uploading parts of it. Currently, doesn't work, but doesn't crash either. Enable it via the NOVUS_USE_NEW_RENDERER environment variable. The goal is to use the game's own shaders instead of creating our own, it's lacking support for buffers with actual data in them and constants so while it "works" nothing is displayed on screen yet.
67 lines
No EOL
1.9 KiB
C++
67 lines
No EOL
1.9 KiB
C++
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "shpkpart.h"
|
|
#include "dxbc_module.h"
|
|
#include "dxbc_reader.h"
|
|
#include <KLocalizedString>
|
|
#include <QTextEdit>
|
|
#include <QVBoxLayout>
|
|
#include <spirv_glsl.hpp>
|
|
|
|
SHPKPart::SHPKPart(GameData *data, QWidget *parent)
|
|
: QWidget(parent)
|
|
, data(data)
|
|
{
|
|
auto layout = new QVBoxLayout();
|
|
setLayout(layout);
|
|
|
|
pageTabWidget = new QTabWidget();
|
|
layout->addWidget(pageTabWidget);
|
|
}
|
|
|
|
void SHPKPart::load(physis_Buffer buffer)
|
|
{
|
|
auto shader = physis_parse_shpk(buffer);
|
|
|
|
pageTabWidget->clear();
|
|
|
|
const auto addShader = [this](physis_Shader shader, const QString &name) {
|
|
auto shaderTextEdit = new QTextEdit();
|
|
shaderTextEdit->setReadOnly(true);
|
|
|
|
try {
|
|
dxvk::DxbcReader reader(reinterpret_cast<const char *>(shader.bytecode), shader.len);
|
|
|
|
dxvk::DxbcModule module(reader);
|
|
|
|
dxvk::DxbcModuleInfo info;
|
|
auto result = module.compile(info, "test");
|
|
|
|
spirv_cross::CompilerGLSL glsl(result.code.data(), result.code.dwords());
|
|
|
|
glsl.build_combined_image_samplers();
|
|
|
|
spirv_cross::CompilerGLSL::Options options;
|
|
options.version = 310;
|
|
options.vulkan_semantics = true;
|
|
glsl.set_common_options(options);
|
|
|
|
shaderTextEdit->setText(QLatin1String(glsl.compile().c_str()));
|
|
|
|
pageTabWidget->addTab(shaderTextEdit, name);
|
|
} catch (std::exception exception) {
|
|
// TODO: display the error
|
|
}
|
|
};
|
|
|
|
for (int i = 0; i < shader.num_vertex_shaders; i++) {
|
|
addShader(shader.vertex_shaders[i], i18nc("@title:tab", "Vertex Shader %1", i));
|
|
}
|
|
|
|
for (int i = 0; i < shader.num_pixel_shaders; i++) {
|
|
addShader(shader.pixel_shaders[i], i18nc("@title:tab", "Pixel Shader %1", i));
|
|
}
|
|
}
|
|
|
|
#include "moc_shpkpart.cpp" |