Fix rendering of Final render for Storm delegate #61

Merged
Bogdan Nagirniak merged 11 commits from BLEN-437 into hydra-render 2023-07-12 23:18:03 +02:00
4 changed files with 13 additions and 8 deletions
Showing only changes of commit bdacb8d2ad - Show all commits

View File

@ -92,6 +92,9 @@ class HydraRenderEngine(bpy.types.RenderEngine):
# final render
def update(self, data, depsgraph):
# Note: if bl_use_gpu_context = True, leave this function empty and move engine creation

is bl_use_gpu_context is true why not just automatically use render()

Then say something here like "if use gpu context is true, this function is ignored and render() is used"

is bl_use_gpu_context is true why not just automatically use render() Then say something here like "if use gpu context is true, this function is ignored and render() is used"
# and syncing to render() function
engine_type = 'PREVIEW' if self.is_preview else 'FINAL'
self.engine_ptr = _bpy_hydra.engine_create(self.as_pointer(), engine_type, self.delegate_id)
if not self.engine_ptr:

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include <pxr/imaging/glf/drawTarget.h>
#include <pxr/imaging/garch/glApi.h>
#include <pxr/imaging/hd/light.h>
#include "BKE_lib_id.h"
@ -115,7 +115,7 @@ void FinalEngine::prepare_for_render(Depsgraph *depsgraph)
std::vector<float>(resolution_[0] * resolution_[1] * 4)); /* 4 - number of channels. */
}
void FinalEngineGL::render(Depsgraph *depsgraph)
void FinalEngineGPU::render(Depsgraph *depsgraph)
{
prepare_for_render(depsgraph);
@ -155,10 +155,11 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
}
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0f);
// Generate vertex array
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
/* Important: we have to create and bind at least one Vertex Array Object (VAO) before render
execution: More info at https://open.gl/drawing */
GLuint VAO;
glGenVertexArrays(1, &VAO);
glBindVertexArray(VAO);
engine_->Execute(render_index_.get(), &tasks_);
@ -197,6 +198,7 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
MEM_freeN(data);
update_render_result();
glDeleteVertexArrays(1, &VAO);
GPU_framebuffer_free(framebuffer);
GPU_texture_free(tex_color);
GPU_texture_free(tex_depth);

View File

@ -26,7 +26,7 @@ class FinalEngine : public Engine {
pxr::GfVec2i resolution_;
};
class FinalEngineGL : public FinalEngine {
class FinalEngineGPU : public FinalEngine {
public:
using FinalEngine::FinalEngine;

View File

@ -75,7 +75,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
}
else {
if (bl_engine->type->flag & RE_USE_GPU_CONTEXT) {
engine = new FinalEngineGL(bl_engine, render_delegate_id);
engine = new FinalEngineGPU(bl_engine, render_delegate_id);
}
else {
engine = new FinalEngine(bl_engine, render_delegate_id);