forked from blender/blender
Render fixes after refactoring #79
@ -277,4 +277,15 @@ void GPURenderTaskDelegate::unbind()
|
||||
GPU_framebuffer_free(framebuffer_);
|
||||
}
|
||||
|
||||
GPUTexture *GPURenderTaskDelegate::aov_texture(pxr::TfToken const &aov_key)
|
||||
{
|
||||
if (aov_key == pxr::HdAovTokens->color) {
|
||||
return tex_color_;
|
||||
}
|
||||
if (aov_key == pxr::HdAovTokens->depth) {
|
||||
return tex_depth_;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -60,6 +60,7 @@ class GPURenderTaskDelegate : public RenderTaskDelegate {
|
||||
void read_aov(pxr::TfToken const &aov_key, GPUTexture *texture) override;
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
GPUTexture *aov_texture(pxr::TfToken const &aov_key);
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -188,13 +188,11 @@ void DrawTexture::write_data(int width, int height, const void *data)
|
||||
(float *)data);
|
||||
}
|
||||
|
||||
void DrawTexture::draw(GPUShader *shader, const pxr::GfVec4d &viewport)
|
||||
{
|
||||
draw(shader, texture_, viewport);
|
||||
}
|
||||
|
||||
void DrawTexture::draw(GPUShader *shader, GPUTexture *tex, const pxr::GfVec4d &viewport)
|
||||
void DrawTexture::draw(GPUShader *shader, const pxr::GfVec4d &viewport, GPUTexture *tex)
|
||||
{
|
||||
if (!tex) {
|
||||
tex = texture_;
|
||||
}
|
||||
int slot = GPU_shader_get_sampler_binding(shader, "image");
|
||||
GPU_texture_bind(tex, slot);
|
||||
GPU_shader_uniform_1i(shader, "image", slot);
|
||||
@ -256,14 +254,20 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
|
||||
render_task_delegate_->unbind();
|
||||
|
||||
draw_texture_.write_data(view_settings.width(), view_settings.height(), nullptr);
|
||||
render_task_delegate_->read_aov(pxr::HdAovTokens->color, draw_texture_.texture());
|
||||
|
||||
GPU_framebuffer_bind(view_framebuffer);
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
|
||||
GPU_shader_bind(shader);
|
||||
|
||||
GPURenderTaskDelegate *gpu_task = dynamic_cast<GPURenderTaskDelegate *>(
|
||||
render_task_delegate_.get());
|
||||
if (gpu_task) {
|
||||
draw_texture_.draw(shader, viewport, gpu_task->aov_texture(pxr::HdAovTokens->color));
|
||||
}
|
||||
else {
|
||||
draw_texture_.write_data(view_settings.width(), view_settings.height(), nullptr);
|
||||
render_task_delegate_->read_aov(pxr::HdAovTokens->color, draw_texture_.texture());
|
||||
draw_texture_.draw(shader, viewport);
|
||||
}
|
||||
|
||||
GPU_shader_unbind();
|
||||
|
||||
|
@ -23,8 +23,7 @@ class DrawTexture {
|
||||
~DrawTexture();
|
||||
|
||||
void write_data(int width, int height, const void *data);
|
||||
void draw(GPUShader *shader, const pxr::GfVec4d &viewport);
|
||||
void draw(GPUShader *shader, GPUTexture *tex, const pxr::GfVec4d &viewport);
|
||||
void draw(GPUShader *shader, const pxr::GfVec4d &viewport, GPUTexture *tex = nullptr);
|
||||
GPUTexture *texture() const;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user