fix&style: 修复screen_blit崩溃问题,微调raytracer内部接口规范
parent
d0a3b1d772
commit
d598b26845
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
/// @brief Initialize ray tracer
|
||||
/// @return True if initialization succeeded
|
||||
bool initialize();
|
||||
bool initialize(const std::shared_ptr<Shader> &shader);
|
||||
|
||||
/// @brief Release resources
|
||||
void release();
|
||||
|
|
@ -69,10 +69,6 @@ public:
|
|||
/// @return True if build succeeded
|
||||
bool rebuild_bvh(const Scene &scene);
|
||||
|
||||
/// @brief Set compute shader (called by renderer)
|
||||
/// @param shader Compute shader
|
||||
void set_compute_shader(const std::shared_ptr<Shader> &shader);
|
||||
|
||||
private:
|
||||
uint width_;
|
||||
uint height_;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
|
||||
/// @brief Initialize screen blit
|
||||
/// @return True if initialization succeeded
|
||||
bool initialize();
|
||||
bool initialize(const std::shared_ptr<Shader> &screen_blit_shader);
|
||||
|
||||
/// @brief Release resources
|
||||
void release();
|
||||
|
|
|
|||
|
|
@ -37,12 +37,14 @@ RayTracer::~RayTracer() {
|
|||
release();
|
||||
}
|
||||
|
||||
bool RayTracer::initialize() {
|
||||
bool RayTracer::initialize(const std::shared_ptr<Shader> &shader) {
|
||||
if (initialized_) {
|
||||
ARE_LOG_WARN("RayTracer already initialized");
|
||||
return true;
|
||||
}
|
||||
|
||||
compute_shader_ = shader;
|
||||
|
||||
// Create accumulation texture
|
||||
glGenTextures(1, &accumulation_texture_);
|
||||
glBindTexture(GL_TEXTURE_2D, accumulation_texture_);
|
||||
|
|
@ -345,9 +347,4 @@ void RayTracer::bind_gbuffer_(const GBuffer &gbuffer) {
|
|||
glBindImageTexture(6, gbuffer.get_texture(GBUFFER_MATERIAL_ID), 0, GL_FALSE, 0, GL_READ_ONLY, GL_R32UI);
|
||||
}
|
||||
|
||||
void RayTracer::set_compute_shader(const std::shared_ptr<Shader> &shader) {
|
||||
compute_shader_ = shader;
|
||||
ARE_LOG_INFO("Compute shader set for RayTracer");
|
||||
}
|
||||
|
||||
} // namespace are
|
||||
|
|
|
|||
|
|
@ -46,23 +46,18 @@ bool Renderer::initialize() {
|
|||
rt_config.enable_accumulation_ = config_.enable_accumulation_;
|
||||
rt_config.use_bvh_ = true;
|
||||
|
||||
// Initialize ray tracer
|
||||
raytracer_ = std::make_unique<RayTracer>(config_.width_, config_.height_, rt_config);
|
||||
if (!raytracer_->initialize()) {
|
||||
const auto& rt_shader = shader_manager_->get_raytracing_shader();
|
||||
if (!raytracer_->initialize(rt_shader)) {
|
||||
ARE_LOG_ERROR("Failed to initialize ray tracer");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pass compute shader to ray tracer
|
||||
const auto& rt_shader = shader_manager_->get_raytracing_shader();
|
||||
if (!rt_shader || !rt_shader->is_valid()) {
|
||||
ARE_LOG_ERROR("Ray tracing shader is invalid");
|
||||
return false;
|
||||
}
|
||||
raytracer_->set_compute_shader(rt_shader);
|
||||
|
||||
// Initialize screen blit
|
||||
screen_blit_ = std::make_unique<ScreenBlit>();
|
||||
if (!screen_blit_->initialize()) {
|
||||
const auto& screen_blit_shader = shader_manager_->get_screen_blit_shader();
|
||||
if (!screen_blit_->initialize(screen_blit_shader)) {
|
||||
ARE_LOG_ERROR("Failed to initialize screen blit");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,13 @@ ScreenBlit::~ScreenBlit() {
|
|||
release();
|
||||
}
|
||||
|
||||
bool ScreenBlit::initialize() {
|
||||
bool ScreenBlit::initialize(const std::shared_ptr<Shader> &screen_blit_shader) {
|
||||
if (initialized_) {
|
||||
ARE_LOG_WARN("ScreenBlit already initialized");
|
||||
return true;
|
||||
}
|
||||
|
||||
shader_ = screen_blit_shader;
|
||||
|
||||
// Create fullscreen quad
|
||||
create_quad_();
|
||||
|
|
|
|||
Loading…
Reference in New Issue