Render fixes after refactoring #79

Merged
Bogdan Nagirniak merged 5 commits from hydra-refactor-fixes into hydra-render 2023-07-29 11:45:06 +02:00
Showing only changes of commit 23605083da - Show all commits

View File

@ -150,6 +150,7 @@ pxr::SdfPath RenderTaskDelegate::buffer_id(pxr::TfToken const &aov_key) const
GPURenderTaskDelegate::~GPURenderTaskDelegate()
{
unbind();
if (tex_color_) {
GPU_texture_free(tex_color_);
}
@ -253,7 +254,9 @@ void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, GPUTexture *te
void GPURenderTaskDelegate::bind()
{
framebuffer_ = GPU_framebuffer_create("fb_render_hydra");
if (!framebuffer_) {
framebuffer_ = GPU_framebuffer_create("fb_render_hydra");
}
GPU_framebuffer_ensure_config(
&framebuffer_, {GPU_ATTACHMENT_TEXTURE(tex_depth_), GPU_ATTACHMENT_TEXTURE(tex_color_)});
GPU_framebuffer_bind(framebuffer_);
@ -263,7 +266,7 @@ void GPURenderTaskDelegate::bind()
/* Workaround missing/buggy VAOs in hgiGL and hdSt. For OpenGL compatibility
* profile this is not a problem, but for core profile it is. */
if (GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
if (VAO_ == 0 && GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
glGenVertexArrays(1, &VAO_);
glBindVertexArray(VAO_);
}
@ -271,10 +274,14 @@ void GPURenderTaskDelegate::bind()
void GPURenderTaskDelegate::unbind()
{
if (GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
if (VAO_) {
glDeleteVertexArrays(1, &VAO_);
VAO_ = 0;
}
if (framebuffer_) {
GPU_framebuffer_free(framebuffer_);
framebuffer_ = nullptr;
}
GPU_framebuffer_free(framebuffer_);
}
GPUTexture *GPURenderTaskDelegate::aov_texture(pxr::TfToken const &aov_key)