fix: 修复超分scaling=1时黑屏问题,确认超分模块在nouveau驱动环境下无法正确运行问题
- 添加参数检查,当scaling<=1时自动关闭超分并WARN - 添加运行环境提示,当渲染器处于nouveau驱动环境中时自动关闭超分并WARNmain
parent
9259bb9c6f
commit
5bb7d461a4
Binary file not shown.
|
|
@ -19,8 +19,9 @@ Denoiser::~Denoiser() {
|
|||
release();
|
||||
}
|
||||
|
||||
bool Denoiser::initialize(const std::shared_ptr<Shader>& shader) {
|
||||
if (initialized_) return true;
|
||||
bool Denoiser::initialize(const std::shared_ptr<Shader> &shader) {
|
||||
if (initialized_)
|
||||
return true;
|
||||
|
||||
if (!shader || !shader->is_valid()) {
|
||||
ARE_LOG_ERROR("Invalid denoise shader");
|
||||
|
|
@ -36,7 +37,8 @@ bool Denoiser::initialize(const std::shared_ptr<Shader>& shader) {
|
|||
}
|
||||
|
||||
void Denoiser::release() {
|
||||
if (!initialized_) return;
|
||||
if (!initialized_)
|
||||
return;
|
||||
|
||||
shader_.reset();
|
||||
|
||||
|
|
@ -55,11 +57,13 @@ void Denoiser::release() {
|
|||
}
|
||||
|
||||
void Denoiser::resize(uint width, uint height) {
|
||||
if (width == width_ && height == height_) return;
|
||||
if (width == width_ && height == height_)
|
||||
return;
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
|
||||
if (!initialized_) return;
|
||||
if (!initialized_)
|
||||
return;
|
||||
|
||||
ResourceManager &rm = ResourceManager::instance();
|
||||
|
||||
|
|
@ -78,7 +82,8 @@ void Denoiser::resize(uint width, uint height) {
|
|||
}
|
||||
|
||||
TextureHandle Denoiser::denoise(TextureHandle input_texture, int radius, float temporal_weight) {
|
||||
if (!initialized_) return input_texture;
|
||||
if (!initialized_)
|
||||
return input_texture;
|
||||
|
||||
radius = (radius < 0) ? 0 : radius;
|
||||
temporal_weight = (temporal_weight < 0.0f) ? 0.0f : ((temporal_weight > 1.0f) ? 1.0f : temporal_weight);
|
||||
|
|
@ -100,7 +105,6 @@ TextureHandle Denoiser::denoise(TextureHandle input_texture, int radius, float t
|
|||
uint groups_x = (width_ + COMPUTE_GROUP_SIZE_X - 1) / COMPUTE_GROUP_SIZE_X;
|
||||
uint groups_y = (height_ + COMPUTE_GROUP_SIZE_Y - 1) / COMPUTE_GROUP_SIZE_Y;
|
||||
glDispatchCompute(groups_x, groups_y, 1);
|
||||
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
|
||||
// Copy output to history for next frame (if temporal accumulation is enabled)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "core/renderer.h"
|
||||
#include "resource/resource_manager.h"
|
||||
#include "utils/logger.h"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <glad/glad.h>
|
||||
|
||||
|
|
@ -24,6 +25,27 @@ bool Renderer::initialize() {
|
|||
|
||||
ARE_LOG_INFO("Initializing Aurora Rendering Engine...");
|
||||
|
||||
// The parameter check for super resolution module
|
||||
if (config_.sr_config.enabled) {
|
||||
// Parameters checking
|
||||
if (config_.sr_config.scaling <= 1) {
|
||||
ARE_LOG_WARN("Super resolution disabled: scaling must be > 1 (got " + std::to_string(config_.sr_config.scaling) + ")");
|
||||
config_.sr_config.enabled = false;
|
||||
config_.sr_config.scaling = 1;
|
||||
}
|
||||
|
||||
// The super resolution module does not support nouveau driver
|
||||
std::string vendor = std::string(reinterpret_cast<const char *>(glGetString(GL_VENDOR)));
|
||||
std::transform(vendor.begin(), vendor.end(), vendor.begin(), ::tolower);
|
||||
std::string renderer = std::string(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
|
||||
std::transform(renderer.begin(), renderer.end(), renderer.begin(), ::tolower);
|
||||
if (vendor.find("mesa") != std::string::npos && renderer.find("nv") != std::string::npos) {
|
||||
ARE_LOG_WARN("Super resolution disabled: The super resolution module on nouveau may produce artifacts. Please switch to the NVIDIA proprietary driver if possible.");
|
||||
config_.sr_config.enabled = false;
|
||||
config_.sr_config.scaling = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize shader manager
|
||||
shader_manager_ = std::make_unique<ShaderManager>();
|
||||
if (!shader_manager_->initialize()) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "utils/logger.h"
|
||||
#include <cmath>
|
||||
#include <glad/glad.h>
|
||||
#include <string>
|
||||
|
||||
namespace are {
|
||||
|
||||
|
|
@ -24,43 +25,51 @@ SuperResolution::~SuperResolution() {
|
|||
|
||||
bool SuperResolution::initialize(const std::shared_ptr<Shader> &shader) {
|
||||
if (initialized_) {
|
||||
ARE_LOG_WARN("SuperResolution already initialized");
|
||||
ARE_LOG_WARN("Super resolution already initialized");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!shader || !shader->is_valid()) {
|
||||
ARE_LOG_ERROR("Invalid shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
compute_shader_ = shader;
|
||||
create_textures_();
|
||||
initialized_ = true;
|
||||
ARE_LOG_INFO("SuperResolution initialized: " + std::to_string(full_width_) + "x" + std::to_string(full_height_) + " scaling_px=" + std::to_string(config_.scaling) + " lowres=" + std::to_string(low_res_w_) + "x" + std::to_string(low_res_h_));
|
||||
ARE_LOG_INFO("Super resolution initialized: " + std::to_string(full_width_) + "x" + std::to_string(full_height_) + " scaling_px=" + std::to_string(config_.scaling) + " lowres=" + std::to_string(low_res_w_) + "x" + std::to_string(low_res_h_));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SuperResolution::release() {
|
||||
if (!initialized_)
|
||||
if (!initialized_) {
|
||||
return;
|
||||
}
|
||||
ResourceManager &rm = ResourceManager::instance();
|
||||
|
||||
if (low_res_rt_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(low_res_rt_texture_);
|
||||
low_res_rt_texture_ = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (accumulated_rt_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(accumulated_rt_texture_);
|
||||
accumulated_rt_texture_ = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (upscaled_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(upscaled_texture_);
|
||||
upscaled_texture_ = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
initialized_ = false;
|
||||
ARE_LOG_INFO("SuperResolution released");
|
||||
}
|
||||
|
||||
TextureHandle SuperResolution::upscale() {
|
||||
if (!initialized_ || !compute_shader_)
|
||||
if (!initialized_ || !compute_shader_) {
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
compute_shader_->use();
|
||||
glBindImageTexture(1, accumulated_rt_texture_, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
|
||||
|
|
@ -84,26 +93,31 @@ void SuperResolution::reset_accumulation() {
|
|||
}
|
||||
|
||||
void SuperResolution::resize(uint full_width, uint full_height) {
|
||||
if (full_width == full_width_ && full_height == full_height_)
|
||||
if (full_width == full_width_ && full_height == full_height_) {
|
||||
return;
|
||||
}
|
||||
full_width_ = full_width;
|
||||
full_height_ = full_height;
|
||||
uint block = compute_block_size_();
|
||||
low_res_w_ = full_width_ / block;
|
||||
low_res_h_ = full_height_ / block;
|
||||
if (!initialized_)
|
||||
if (!initialized_) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceManager &rm = ResourceManager::instance();
|
||||
if (low_res_rt_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(low_res_rt_texture_);
|
||||
}
|
||||
|
||||
if (accumulated_rt_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(accumulated_rt_texture_);
|
||||
}
|
||||
|
||||
if (upscaled_texture_ != INVALID_HANDLE) {
|
||||
rm.destroy_texture(upscaled_texture_);
|
||||
}
|
||||
|
||||
create_textures_();
|
||||
ARE_LOG_INFO("SuperResolution resized to " + std::to_string(full_width) + "x" + std::to_string(full_height));
|
||||
}
|
||||
|
|
@ -122,8 +136,7 @@ void SuperResolution::clear_accumulation_texture_() const {
|
|||
GLuint fbo;
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
accumulated_rt_texture_, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, accumulated_rt_texture_, 0);
|
||||
const GLfloat clear_color[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
glClearBufferfv(GL_COLOR, 0, clear_color);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue