forked from blender/blender
Render fixes after refactoring #79
@ -150,6 +150,7 @@ pxr::SdfPath RenderTaskDelegate::buffer_id(pxr::TfToken const &aov_key) const
|
|||||||
|
|
||||||
GPURenderTaskDelegate::~GPURenderTaskDelegate()
|
GPURenderTaskDelegate::~GPURenderTaskDelegate()
|
||||||
{
|
{
|
||||||
|
unbind();
|
||||||
if (tex_color_) {
|
if (tex_color_) {
|
||||||
GPU_texture_free(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()
|
void GPURenderTaskDelegate::bind()
|
||||||
{
|
{
|
||||||
|
if (!framebuffer_) {
|
||||||
framebuffer_ = GPU_framebuffer_create("fb_render_hydra");
|
framebuffer_ = GPU_framebuffer_create("fb_render_hydra");
|
||||||
|
}
|
||||||
GPU_framebuffer_ensure_config(
|
GPU_framebuffer_ensure_config(
|
||||||
&framebuffer_, {GPU_ATTACHMENT_TEXTURE(tex_depth_), GPU_ATTACHMENT_TEXTURE(tex_color_)});
|
&framebuffer_, {GPU_ATTACHMENT_TEXTURE(tex_depth_), GPU_ATTACHMENT_TEXTURE(tex_color_)});
|
||||||
GPU_framebuffer_bind(framebuffer_);
|
GPU_framebuffer_bind(framebuffer_);
|
||||||
@ -263,7 +266,7 @@ void GPURenderTaskDelegate::bind()
|
|||||||
|
|
||||||
/* Workaround missing/buggy VAOs in hgiGL and hdSt. For OpenGL compatibility
|
/* Workaround missing/buggy VAOs in hgiGL and hdSt. For OpenGL compatibility
|
||||||
* profile this is not a problem, but for core profile it is. */
|
* 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_);
|
glGenVertexArrays(1, &VAO_);
|
||||||
glBindVertexArray(VAO_);
|
glBindVertexArray(VAO_);
|
||||||
}
|
}
|
||||||
@ -271,10 +274,14 @@ void GPURenderTaskDelegate::bind()
|
|||||||
|
|
||||||
void GPURenderTaskDelegate::unbind()
|
void GPURenderTaskDelegate::unbind()
|
||||||
{
|
{
|
||||||
if (GPU_backend_get_type() == GPU_BACKEND_OPENGL) {
|
if (VAO_) {
|
||||||
glDeleteVertexArrays(1, &VAO_);
|
glDeleteVertexArrays(1, &VAO_);
|
||||||
|
|||||||
|
VAO_ = 0;
|
||||||
}
|
}
|
||||||
|
if (framebuffer_) {
|
||||||
GPU_framebuffer_free(framebuffer_);
|
GPU_framebuffer_free(framebuffer_);
|
||||||
|
framebuffer_ = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUTexture *GPURenderTaskDelegate::aov_texture(pxr::TfToken const &aov_key)
|
GPUTexture *GPURenderTaskDelegate::aov_texture(pxr::TfToken const &aov_key)
|
||||||
|
Loading…
Reference in New Issue
Block a user
Can you set VAO_ to 0 and framebuffer_ to null?
Not strictly required, but more future proof.