2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_context.hh"
|
|
|
|
|
#include "GPU_immediate.hh"
|
|
|
|
|
#include "GPU_shader.hh"
|
|
|
|
|
#include "GPU_state.hh"
|
|
|
|
|
#include "GPU_texture.hh"
|
2022-08-19 20:11:21 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
#include "RE_engine.h"
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-20 03:03:14 +01:00
|
|
|
#include "blender/display_driver.h"
|
|
|
|
|
|
|
|
|
|
#include "device/device.h"
|
|
|
|
|
#include "util/log.h"
|
|
|
|
|
#include "util/math.h"
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* BlenderDisplayShader.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
unique_ptr<BlenderDisplayShader> BlenderDisplayShader::create(BL::RenderEngine &b_engine,
|
|
|
|
|
BL::Scene &b_scene)
|
|
|
|
|
{
|
|
|
|
|
if (b_engine.support_display_space_shader(b_scene)) {
|
|
|
|
|
return make_unique<BlenderDisplaySpaceShader>(b_engine, b_scene);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return make_unique<BlenderFallbackDisplayShader>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BlenderDisplayShader::get_position_attrib_location()
|
|
|
|
|
{
|
|
|
|
|
if (position_attribute_location_ == -1) {
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *shader_program = get_shader_program();
|
|
|
|
|
position_attribute_location_ = GPU_shader_get_attribute(shader_program,
|
|
|
|
|
position_attribute_name);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
return position_attribute_location_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BlenderDisplayShader::get_tex_coord_attrib_location()
|
|
|
|
|
{
|
|
|
|
|
if (tex_coord_attribute_location_ == -1) {
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *shader_program = get_shader_program();
|
|
|
|
|
tex_coord_attribute_location_ = GPU_shader_get_attribute(shader_program,
|
|
|
|
|
tex_coord_attribute_name);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
return tex_coord_attribute_location_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* BlenderFallbackDisplayShader.
|
|
|
|
|
*/
|
2022-12-01 15:33:54 +01:00
|
|
|
static GPUShader *compile_fallback_shader(void)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
/* NOTE: Compilation errors are logged to console. */
|
2023-02-23 14:25:08 +01:00
|
|
|
GPUShader *shader = GPU_shader_create_from_info_name("gpu_shader_cycles_display_fallback");
|
2022-12-01 15:33:54 +01:00
|
|
|
return shader;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *BlenderFallbackDisplayShader::bind(int width, int height)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
create_shader_if_needed();
|
|
|
|
|
|
|
|
|
|
if (!shader_program_) {
|
2022-12-01 15:33:54 +01:00
|
|
|
return nullptr;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Bind shader now to enable uniform assignment. */
|
|
|
|
|
GPU_shader_bind(shader_program_);
|
2023-02-13 12:17:46 +01:00
|
|
|
int slot = 0;
|
2023-02-12 23:39:48 +01:00
|
|
|
GPU_shader_uniform_int_ex(shader_program_, image_texture_location_, 1, 1, &slot);
|
2022-12-01 15:33:54 +01:00
|
|
|
float size[2];
|
|
|
|
|
size[0] = width;
|
|
|
|
|
size[1] = height;
|
2023-02-12 23:39:48 +01:00
|
|
|
GPU_shader_uniform_float_ex(shader_program_, fullscreen_location_, 2, 1, size);
|
2022-12-01 15:33:54 +01:00
|
|
|
return shader_program_;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderFallbackDisplayShader::unbind()
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_shader_unbind();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *BlenderFallbackDisplayShader::get_shader_program()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
return shader_program_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderFallbackDisplayShader::create_shader_if_needed()
|
|
|
|
|
{
|
|
|
|
|
if (shader_program_ || shader_compile_attempted_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shader_compile_attempted_ = true;
|
|
|
|
|
|
|
|
|
|
shader_program_ = compile_fallback_shader();
|
|
|
|
|
if (!shader_program_) {
|
2022-12-01 15:33:54 +01:00
|
|
|
LOG(ERROR) << "Failed to compile fallback shader";
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
image_texture_location_ = GPU_shader_get_uniform(shader_program_, "image_texture");
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (image_texture_location_ < 0) {
|
|
|
|
|
LOG(ERROR) << "Shader doesn't contain the 'image_texture' uniform.";
|
|
|
|
|
destroy_shader();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
fullscreen_location_ = GPU_shader_get_uniform(shader_program_, "fullscreen");
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (fullscreen_location_ < 0) {
|
|
|
|
|
LOG(ERROR) << "Shader doesn't contain the 'fullscreen' uniform.";
|
|
|
|
|
destroy_shader();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderFallbackDisplayShader::destroy_shader()
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
if (shader_program_) {
|
|
|
|
|
GPU_shader_free(shader_program_);
|
|
|
|
|
shader_program_ = nullptr;
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* BlenderDisplaySpaceShader.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
BlenderDisplaySpaceShader::BlenderDisplaySpaceShader(BL::RenderEngine &b_engine,
|
|
|
|
|
BL::Scene &b_scene)
|
|
|
|
|
: b_engine_(b_engine), b_scene_(b_scene)
|
|
|
|
|
{
|
|
|
|
|
DCHECK(b_engine_.support_display_space_shader(b_scene_));
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *BlenderDisplaySpaceShader::bind(int /*width*/, int /*height*/)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
b_engine_.bind_display_space_shader(b_scene_);
|
2022-12-01 15:33:54 +01:00
|
|
|
return GPU_shader_get_bound();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderDisplaySpaceShader::unbind()
|
|
|
|
|
{
|
|
|
|
|
b_engine_.unbind_display_space_shader();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *BlenderDisplaySpaceShader::get_shader_program()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
if (!shader_program_) {
|
2022-12-01 15:33:54 +01:00
|
|
|
shader_program_ = GPU_shader_get_bound();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
if (!shader_program_) {
|
|
|
|
|
LOG(ERROR) << "Error retrieving shader program for display space shader.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return shader_program_;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* DrawTile.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Higher level representation of a texture from the graphics library. */
|
2022-12-01 15:33:54 +01:00
|
|
|
class DisplayGPUTexture {
|
2022-01-06 16:41:44 +01:00
|
|
|
public:
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Global counter for all allocated GPUTextures used by instances of this class. */
|
2022-01-06 16:41:44 +01:00
|
|
|
static inline std::atomic<int> num_used = 0;
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUTexture() = default;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
~DisplayGPUTexture()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
assert(gpu_texture == nullptr);
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUTexture(const DisplayGPUTexture &other) = delete;
|
|
|
|
|
DisplayGPUTexture &operator=(DisplayGPUTexture &other) = delete;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUTexture(DisplayGPUTexture &&other) noexcept
|
|
|
|
|
: gpu_texture(other.gpu_texture), width(other.width), height(other.height)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
|
|
|
|
other.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUTexture &operator=(DisplayGPUTexture &&other)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
gpu_texture = other.gpu_texture;
|
2022-01-06 16:41:44 +01:00
|
|
|
width = other.width;
|
|
|
|
|
height = other.height;
|
|
|
|
|
|
|
|
|
|
other.reset();
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:56:12 +01:00
|
|
|
bool gpu_resources_ensure(const uint texture_width, const uint texture_height)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-02 15:56:12 +01:00
|
|
|
if (width != texture_width || height != texture_height) {
|
|
|
|
|
gpu_resources_destroy();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
if (gpu_texture) {
|
2022-01-06 16:41:44 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:56:12 +01:00
|
|
|
width = texture_width;
|
|
|
|
|
height = texture_height;
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Texture must have a minimum size of 1x1. */
|
2023-02-25 01:52:27 +01:00
|
|
|
gpu_texture = GPU_texture_create_2d("CyclesBlitTexture",
|
|
|
|
|
max(width, 1),
|
|
|
|
|
max(height, 1),
|
|
|
|
|
1,
|
|
|
|
|
GPU_RGBA16F,
|
|
|
|
|
GPU_TEXTURE_USAGE_GENERAL,
|
|
|
|
|
nullptr);
|
2022-12-01 15:33:54 +01:00
|
|
|
|
|
|
|
|
if (!gpu_texture) {
|
2022-01-06 16:41:44 +01:00
|
|
|
LOG(ERROR) << "Error creating texture.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_texture_filter_mode(gpu_texture, false);
|
2023-04-04 15:16:07 +02:00
|
|
|
GPU_texture_extend_mode(gpu_texture, GPU_SAMPLER_EXTEND_MODE_EXTEND);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
++num_used;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
void gpu_resources_destroy()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
if (gpu_texture == nullptr) {
|
2022-01-06 16:41:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_TEXTURE_FREE_SAFE(gpu_texture);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
reset();
|
|
|
|
|
|
|
|
|
|
--num_used;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Texture resource allocated by the GPU module.
|
2022-01-06 16:41:44 +01:00
|
|
|
*
|
|
|
|
|
* NOTE: Allocated on the render engine's context. */
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUTexture *gpu_texture = nullptr;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
/* Dimensions of the texture in pixels. */
|
|
|
|
|
int width = 0;
|
|
|
|
|
int height = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void reset()
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
gpu_texture = nullptr;
|
2022-01-06 16:41:44 +01:00
|
|
|
width = 0;
|
|
|
|
|
height = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Higher level representation of a Pixel Buffer Object (PBO) from the graphics library. */
|
2022-12-01 15:33:54 +01:00
|
|
|
class DisplayGPUPixelBuffer {
|
2022-01-06 16:41:44 +01:00
|
|
|
public:
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Global counter for all allocated GPU module PBOs used by instances of this class. */
|
2022-01-06 16:41:44 +01:00
|
|
|
static inline std::atomic<int> num_used = 0;
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer() = default;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
~DisplayGPUPixelBuffer()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
assert(gpu_pixel_buffer == nullptr);
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer(const DisplayGPUPixelBuffer &other) = delete;
|
|
|
|
|
DisplayGPUPixelBuffer &operator=(DisplayGPUPixelBuffer &other) = delete;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer(DisplayGPUPixelBuffer &&other) noexcept
|
|
|
|
|
: gpu_pixel_buffer(other.gpu_pixel_buffer), width(other.width), height(other.height)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
|
|
|
|
other.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer &operator=(DisplayGPUPixelBuffer &&other)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
gpu_pixel_buffer = other.gpu_pixel_buffer;
|
2022-01-06 16:41:44 +01:00
|
|
|
width = other.width;
|
|
|
|
|
height = other.height;
|
|
|
|
|
|
|
|
|
|
other.reset();
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-02 15:56:12 +01:00
|
|
|
bool gpu_resources_ensure(const uint new_width, const uint new_height)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-02 15:56:12 +01:00
|
|
|
const size_t required_size = sizeof(half4) * new_width * new_height * 4;
|
2022-12-01 15:33:54 +01:00
|
|
|
|
2022-12-02 15:56:12 +01:00
|
|
|
/* Try to re-use the existing PBO if it has usable size. */
|
2022-12-01 15:33:54 +01:00
|
|
|
if (gpu_pixel_buffer) {
|
|
|
|
|
if (new_width != width || new_height != height ||
|
|
|
|
|
GPU_pixel_buffer_size(gpu_pixel_buffer) < required_size)
|
|
|
|
|
{
|
2022-12-02 15:56:12 +01:00
|
|
|
gpu_resources_destroy();
|
2022-12-01 15:33:54 +01:00
|
|
|
}
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Update size. */
|
|
|
|
|
width = new_width;
|
|
|
|
|
height = new_height;
|
|
|
|
|
|
|
|
|
|
/* Create pixel buffer if not already created. */
|
|
|
|
|
if (!gpu_pixel_buffer) {
|
|
|
|
|
gpu_pixel_buffer = GPU_pixel_buffer_create(required_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gpu_pixel_buffer == nullptr) {
|
2022-01-06 16:41:44 +01:00
|
|
|
LOG(ERROR) << "Error creating texture pixel buffer object.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++num_used;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
void gpu_resources_destroy()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
if (!gpu_pixel_buffer) {
|
2022-01-06 16:41:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_pixel_buffer_free(gpu_pixel_buffer);
|
|
|
|
|
gpu_pixel_buffer = nullptr;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
reset();
|
|
|
|
|
|
|
|
|
|
--num_used;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Pixel Buffer Object allocated by the GPU module.
|
2022-01-06 16:41:44 +01:00
|
|
|
*
|
|
|
|
|
* NOTE: Allocated on the render engine's context. */
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUPixelBuffer *gpu_pixel_buffer = nullptr;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
/* Dimensions of the PBO. */
|
|
|
|
|
int width = 0;
|
|
|
|
|
int height = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void reset()
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
gpu_pixel_buffer = 0;
|
2022-01-06 16:41:44 +01:00
|
|
|
width = 0;
|
|
|
|
|
height = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DrawTile {
|
|
|
|
|
public:
|
|
|
|
|
DrawTile() = default;
|
|
|
|
|
~DrawTile() = default;
|
|
|
|
|
|
|
|
|
|
DrawTile(const DrawTile &other) = delete;
|
|
|
|
|
DrawTile &operator=(const DrawTile &other) = delete;
|
|
|
|
|
|
|
|
|
|
DrawTile(DrawTile &&other) noexcept = default;
|
|
|
|
|
|
|
|
|
|
DrawTile &operator=(DrawTile &&other) = default;
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
void gpu_resources_destroy()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
texture.gpu_resources_destroy();
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool ready_to_draw() const
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
return texture.gpu_texture != 0;
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Texture which contains pixels of the tile. */
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUTexture texture;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
/* Display parameters the texture of this tile has been updated for. */
|
|
|
|
|
BlenderDisplayDriver::Params params;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DrawTileAndPBO {
|
|
|
|
|
public:
|
2022-12-01 15:33:54 +01:00
|
|
|
void gpu_resources_destroy()
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
tile.gpu_resources_destroy();
|
|
|
|
|
buffer_object.gpu_resources_destroy();
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawTile tile;
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer buffer_object;
|
2022-08-19 20:11:21 +02:00
|
|
|
bool need_update_texture_pixels = false;
|
2022-01-06 16:41:44 +01:00
|
|
|
};
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* --------------------------------------------------------------------
|
2021-09-14 15:37:47 +02:00
|
|
|
* BlenderDisplayDriver.
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
struct BlenderDisplayDriver::Tiles {
|
|
|
|
|
/* Resources of a tile which is being currently rendered. */
|
|
|
|
|
DrawTileAndPBO current_tile;
|
|
|
|
|
|
|
|
|
|
/* All tiles which rendering is finished and which content will not be changed. */
|
|
|
|
|
struct {
|
|
|
|
|
vector<DrawTile> tiles;
|
|
|
|
|
|
|
|
|
|
void gl_resources_destroy_and_clear()
|
|
|
|
|
{
|
|
|
|
|
for (DrawTile &tile : tiles) {
|
2022-12-01 15:33:54 +01:00
|
|
|
tile.gpu_resources_destroy();
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tiles.clear();
|
|
|
|
|
}
|
|
|
|
|
} finished_tiles;
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
BlenderDisplayDriver::BlenderDisplayDriver(BL::RenderEngine &b_engine,
|
|
|
|
|
BL::Scene &b_scene,
|
|
|
|
|
const bool background)
|
2022-01-06 16:41:44 +01:00
|
|
|
: b_engine_(b_engine),
|
2022-08-20 13:36:12 +02:00
|
|
|
background_(background),
|
2022-01-06 16:41:44 +01:00
|
|
|
display_shader_(BlenderDisplayShader::create(b_engine, b_scene)),
|
|
|
|
|
tiles_(make_unique<Tiles>())
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
/* Create context while on the main thread. */
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_create();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
BlenderDisplayDriver::~BlenderDisplayDriver()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_resources_destroy();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* Update procedure.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
void BlenderDisplayDriver::next_tile_begin()
|
|
|
|
|
{
|
|
|
|
|
if (!tiles_->current_tile.tile.ready_to_draw()) {
|
|
|
|
|
LOG(ERROR)
|
|
|
|
|
<< "Unexpectedly moving to the next tile without any data provided for current tile.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Moving to the next tile without giving render data for the current tile is not an expected
|
|
|
|
|
* situation. */
|
|
|
|
|
DCHECK(!need_clear_);
|
2022-08-19 20:11:21 +02:00
|
|
|
/* Texture should have been updated from the PBO at this point. */
|
|
|
|
|
DCHECK(!tiles_->current_tile.need_update_texture_pixels);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
tiles_->finished_tiles.tiles.emplace_back(std::move(tiles_->current_tile.tile));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
bool BlenderDisplayDriver::update_begin(const Params ¶ms,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
int texture_width,
|
|
|
|
|
int texture_height)
|
|
|
|
|
{
|
2021-09-14 15:37:47 +02:00
|
|
|
/* Note that it's the responsibility of BlenderDisplayDriver to ensure updating and drawing
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
* the texture does not happen at the same time. This is achieved indirectly.
|
|
|
|
|
*
|
2022-12-01 15:33:54 +01:00
|
|
|
* When enabling the OpenGL/GPU context, it uses an internal mutex lock DST.gpu_context_lock.
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
* This same lock is also held when do_draw() is called, which together ensure mutual
|
|
|
|
|
* exclusion.
|
|
|
|
|
*
|
2021-09-14 15:37:47 +02:00
|
|
|
* This locking is not performed on the Cycles side, because that would cause lock inversion. */
|
2022-08-20 13:36:12 +02:00
|
|
|
if (!gpu_context_enable()) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_fence_wait(gpu_render_sync_);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
DrawTile ¤t_tile = tiles_->current_tile.tile;
|
2022-12-01 15:33:54 +01:00
|
|
|
DisplayGPUPixelBuffer ¤t_tile_buffer_object = tiles_->current_tile.buffer_object;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
/* Clear storage of all finished tiles when display clear is requested.
|
|
|
|
|
* Do it when new tile data is provided to handle the display clear flag in a single place.
|
|
|
|
|
* It also makes the logic reliable from the whether drawing did happen or not point of view. */
|
|
|
|
|
if (need_clear_) {
|
|
|
|
|
tiles_->finished_tiles.gl_resources_destroy_and_clear();
|
|
|
|
|
need_clear_ = false;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Update PBO dimensions if needed.
|
|
|
|
|
*
|
2021-11-19 13:01:23 +01:00
|
|
|
* NOTE: Allocate the PBO for the size which will fit the final render resolution (as in,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
* at a resolution divider 1. This was we don't need to recreate graphics interoperability
|
|
|
|
|
* objects which are costly and which are tied to the specific underlying buffer size.
|
2021-09-22 14:48:01 +10:00
|
|
|
* The downside of this approach is that when graphics interoperability is not used we are
|
|
|
|
|
* sending too much data to GPU when resolution divider is not 1. */
|
|
|
|
|
/* TODO(sergey): Investigate whether keeping the PBO exact size of the texture makes non-interop
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
* mode faster. */
|
2022-01-06 16:41:44 +01:00
|
|
|
const int buffer_width = params.size.x;
|
|
|
|
|
const int buffer_height = params.size.y;
|
2022-12-02 15:56:12 +01:00
|
|
|
|
|
|
|
|
if (!current_tile_buffer_object.gpu_resources_ensure(buffer_width, buffer_height) ||
|
|
|
|
|
!current_tile.texture.gpu_resources_ensure(texture_width, texture_height))
|
|
|
|
|
{
|
|
|
|
|
tiles_->current_tile.gpu_resources_destroy();
|
|
|
|
|
gpu_context_disable();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
/* Store an updated parameters of the current tile.
|
|
|
|
|
* In theory it is only needed once per update of the tile, but doing it on every update is
|
|
|
|
|
* the easiest and is not expensive. */
|
|
|
|
|
tiles_->current_tile.tile.params = params;
|
2021-12-07 18:50:48 +01:00
|
|
|
|
2021-12-07 20:49:34 +01:00
|
|
|
return true;
|
2021-12-07 18:50:48 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
static void update_tile_texture_pixels(const DrawTileAndPBO &tile)
|
|
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
const DisplayGPUTexture &texture = tile.tile.texture;
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
if (!DCHECK_NOTNULL(tile.buffer_object.gpu_pixel_buffer)) {
|
|
|
|
|
LOG(ERROR) << "Display driver tile pixel buffer unavailable.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GPU_texture_update_sub_from_pixel_buffer(texture.gpu_texture,
|
|
|
|
|
GPU_DATA_HALF_FLOAT,
|
|
|
|
|
tile.buffer_object.gpu_pixel_buffer,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
texture.width,
|
|
|
|
|
texture.height,
|
|
|
|
|
0);
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::update_end()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-01-06 16:41:44 +01:00
|
|
|
/* Unpack the PBO into the texture as soon as the new content is provided.
|
|
|
|
|
*
|
|
|
|
|
* This allows to ensure that the unpacking happens while resources like graphics interop (which
|
|
|
|
|
* lifetime is outside of control of the display driver) are still valid, as well as allows to
|
|
|
|
|
* move the tile from being current to finished immediately after this call.
|
|
|
|
|
*
|
|
|
|
|
* One concern with this approach is that if the update happens more often than drawing then
|
|
|
|
|
* doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
|
|
|
|
|
* takes care of ensuring updates don't happen that often. In regular applications redraw will
|
2022-08-19 20:11:21 +02:00
|
|
|
* happen much more often than this update.
|
|
|
|
|
*
|
|
|
|
|
* On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
|
|
|
|
|
* renders while Blender is drawing. As a workaround update texture during draw, under assumption
|
|
|
|
|
* that there is no graphics interop on macOS and viewport render has a single tile. */
|
2022-08-20 13:36:12 +02:00
|
|
|
if (!background_ &&
|
2022-08-19 20:11:21 +02:00
|
|
|
GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY))
|
|
|
|
|
{
|
|
|
|
|
tiles_->current_tile.need_update_texture_pixels = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
update_tile_texture_pixels(tiles_->current_tile);
|
|
|
|
|
}
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Ensure GPU fence exists to synchronize upload. */
|
|
|
|
|
GPU_fence_signal(gpu_upload_sync_);
|
|
|
|
|
|
|
|
|
|
GPU_flush();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_disable();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* Texture buffer mapping.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
half4 *BlenderDisplayDriver::map_texture_buffer()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
|
|
|
|
if (!DCHECK_NOTNULL(pix_buf)) {
|
|
|
|
|
LOG(ERROR) << "Display driver tile pixel buffer unavailable.";
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
half4 *mapped_rgba_pixels = reinterpret_cast<half4 *>(GPU_pixel_buffer_map(pix_buf));
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!mapped_rgba_pixels) {
|
2021-09-14 15:37:47 +02:00
|
|
|
LOG(ERROR) << "Error mapping BlenderDisplayDriver pixel buffer object.";
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
return mapped_rgba_pixels;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::unmap_texture_buffer()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
|
|
|
|
if (!DCHECK_NOTNULL(pix_buf)) {
|
|
|
|
|
LOG(ERROR) << "Display driver tile pixel buffer unavailable.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GPU_pixel_buffer_unmap(pix_buf);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* Graphics interoperability.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
BlenderDisplayDriver::GraphicsInterop BlenderDisplayDriver::graphics_interop_get()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2021-09-14 15:37:47 +02:00
|
|
|
GraphicsInterop interop_dst;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
interop_dst.buffer_width = tiles_->current_tile.buffer_object.width;
|
|
|
|
|
interop_dst.buffer_height = tiles_->current_tile.buffer_object.height;
|
2022-12-01 15:42:04 +01:00
|
|
|
interop_dst.opengl_pbo_id = GPU_pixel_buffer_get_native_handle(
|
2022-12-01 15:33:54 +01:00
|
|
|
tiles_->current_tile.buffer_object.gpu_pixel_buffer);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
return interop_dst;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::graphics_interop_activate()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_enable();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::graphics_interop_deactivate()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_disable();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
|
|
* Drawing.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::clear()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-01-06 16:41:44 +01:00
|
|
|
need_clear_ = true;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
void BlenderDisplayDriver::set_zoom(float zoom_x, float zoom_y)
|
2021-09-22 10:59:49 +02:00
|
|
|
{
|
|
|
|
|
zoom_ = make_float2(zoom_x, zoom_y);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
/* Update vertex buffer with new coordinates of vertex positions and texture coordinates.
|
|
|
|
|
* This buffer is used to render texture in the viewport.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: The buffer needs to be bound. */
|
2022-12-01 15:33:54 +01:00
|
|
|
static void vertex_draw(const DisplayDriver::Params ¶ms,
|
|
|
|
|
int texcoord_attribute,
|
|
|
|
|
int position_attribute)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-01-06 16:41:44 +01:00
|
|
|
const int x = params.full_offset.x;
|
|
|
|
|
const int y = params.full_offset.y;
|
|
|
|
|
|
|
|
|
|
const int width = params.size.x;
|
|
|
|
|
const int height = params.size.y;
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immBegin(GPU_PRIM_TRI_STRIP, 4);
|
2021-12-07 18:50:48 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immAttr2f(texcoord_attribute, 1.0f, 0.0f);
|
|
|
|
|
immVertex2f(position_attribute, x + width, y);
|
2021-12-07 18:50:48 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immAttr2f(texcoord_attribute, 1.0f, 1.0f);
|
|
|
|
|
immVertex2f(position_attribute, x + width, y + height);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immAttr2f(texcoord_attribute, 0.0f, 0.0f);
|
|
|
|
|
immVertex2f(position_attribute, x, y);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immAttr2f(texcoord_attribute, 0.0f, 1.0f);
|
|
|
|
|
immVertex2f(position_attribute, x, y + height);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
immEnd();
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_tile(const float2 &zoom,
|
|
|
|
|
const int texcoord_attribute,
|
|
|
|
|
const int position_attribute,
|
2022-12-01 15:33:54 +01:00
|
|
|
const DrawTile &draw_tile)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
|
|
|
|
if (!draw_tile.ready_to_draw()) {
|
2021-09-30 11:44:53 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
const DisplayGPUTexture &texture = draw_tile.texture;
|
2021-12-07 18:50:48 +01:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
if (!DCHECK_NOTNULL(texture.gpu_texture)) {
|
|
|
|
|
LOG(ERROR) << "Display driver tile GPU texture resource unavailable.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2021-09-22 10:59:49 +02:00
|
|
|
/* Trick to keep sharp rendering without jagged edges on all GPUs.
|
|
|
|
|
*
|
2024-05-06 13:46:18 +02:00
|
|
|
* The idea here is to enforce driver to use linear interpolation when the image is zoomed out.
|
2021-09-22 10:59:49 +02:00
|
|
|
* For the render result with a resolution divider in effect we always use nearest interpolation.
|
|
|
|
|
*
|
|
|
|
|
* Use explicit MIN assignment to make sure the driver does not have an undefined behavior at
|
|
|
|
|
* the zoom level 1. The MAG filter is always NEAREST. */
|
2022-01-06 16:41:44 +01:00
|
|
|
const float zoomed_width = draw_tile.params.size.x * zoom.x;
|
|
|
|
|
const float zoomed_height = draw_tile.params.size.y * zoom.y;
|
|
|
|
|
if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
|
2021-09-23 15:02:10 +10:00
|
|
|
/* Resolution divider is different from 1, force nearest interpolation. */
|
2023-04-04 15:16:07 +02:00
|
|
|
GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0);
|
2021-09-22 10:59:49 +02:00
|
|
|
}
|
2024-05-06 13:46:18 +02:00
|
|
|
else if (zoomed_width - draw_tile.params.size.x > -0.5f ||
|
|
|
|
|
zoomed_height - draw_tile.params.size.y > -0.5f)
|
2022-01-06 16:41:44 +01:00
|
|
|
{
|
2023-04-04 15:16:07 +02:00
|
|
|
GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0);
|
2021-09-22 10:59:49 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2023-04-04 15:16:07 +02:00
|
|
|
GPU_texture_bind_ex(texture.gpu_texture, {GPU_SAMPLER_FILTERING_LINEAR}, 0);
|
2021-09-22 10:59:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Draw at the parameters for which the texture has been updated for. This allows to always draw
|
|
|
|
|
* texture during bordered-rendered camera view without flickering. The validness of the display
|
|
|
|
|
* parameters for a texture is guaranteed by the initial "clear" state which makes drawing to
|
|
|
|
|
* have an early output.
|
|
|
|
|
*
|
|
|
|
|
* Such approach can cause some extra "jelly" effect during panning, but it is not more jelly
|
|
|
|
|
* than overlay of selected objects. Also, it's possible to redraw texture at an intersection of
|
|
|
|
|
* the texture draw parameters and the latest updated draw parameters (although, complexity of
|
|
|
|
|
* doing it might not worth it. */
|
|
|
|
|
vertex_draw(draw_tile.params, texcoord_attribute, position_attribute);
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderDisplayDriver::flush()
|
|
|
|
|
{
|
|
|
|
|
/* This is called from the render thread that also calls update_begin/end, right before ending
|
|
|
|
|
* the render loop. We wait for any queued PBO and render commands to be done, before destroying
|
|
|
|
|
* the render thread and activating the context in the main thread to destroy resources.
|
|
|
|
|
*
|
|
|
|
|
* If we don't do this, the NVIDIA driver hangs for a few seconds for when ending 3D viewport
|
|
|
|
|
* rendering, for unknown reasons. This was found with NVIDIA driver version 470.73 and a Quadro
|
|
|
|
|
* RTX 6000 on Linux. */
|
2022-08-20 13:36:12 +02:00
|
|
|
if (!gpu_context_enable()) {
|
2022-01-06 16:41:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_fence_wait(gpu_upload_sync_);
|
|
|
|
|
GPU_fence_wait(gpu_render_sync_);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_disable();
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderDisplayDriver::draw(const Params ¶ms)
|
|
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_lock();
|
2022-01-06 16:41:44 +01:00
|
|
|
|
|
|
|
|
if (need_clear_) {
|
|
|
|
|
/* Texture is requested to be cleared and was not yet cleared.
|
|
|
|
|
*
|
|
|
|
|
* Do early return which should be equivalent of drawing all-zero texture.
|
|
|
|
|
* Watch out for the lock though so that the clear happening during update is properly
|
|
|
|
|
* synchronized here. */
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_unlock();
|
2022-01-06 16:41:44 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_fence_wait(gpu_upload_sync_);
|
|
|
|
|
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUShader *active_shader = display_shader_->bind(params.full_size.x, params.full_size.y);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
|
const int texcoord_attribute = GPU_vertformat_attr_add(
|
|
|
|
|
format, display_shader_->tex_coord_attribute_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
|
const int position_attribute = GPU_vertformat_attr_add(
|
|
|
|
|
format, display_shader_->position_attribute_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2024-06-06 09:43:48 +10:00
|
|
|
/* NOTE: Shader is bound again through IMM to register this shader with the IMM module
|
2022-12-01 15:33:54 +01:00
|
|
|
* and perform required setup for IMM rendering. This is required as the IMM module
|
|
|
|
|
* needs to be aware of which shader is bound, and the main display shader
|
|
|
|
|
* is bound externally. */
|
|
|
|
|
immBindShader(active_shader);
|
2022-01-06 16:41:44 +01:00
|
|
|
|
2022-12-07 18:14:28 +01:00
|
|
|
if (tiles_->current_tile.need_update_texture_pixels) {
|
|
|
|
|
update_tile_texture_pixels(tiles_->current_tile);
|
|
|
|
|
tiles_->current_tile.need_update_texture_pixels = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
draw_tile(zoom_, texcoord_attribute, position_attribute, tiles_->current_tile.tile);
|
2021-12-07 18:50:48 +01:00
|
|
|
|
2022-01-06 16:41:44 +01:00
|
|
|
for (const DrawTile &tile : tiles_->finished_tiles.tiles) {
|
2022-12-01 15:33:54 +01:00
|
|
|
draw_tile(zoom_, texcoord_attribute, position_attribute, tile);
|
2022-01-06 16:41:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
/* Reset IMM shader bind state. */
|
|
|
|
|
immUnbindProgram();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
display_shader_->unbind();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
GPU_fence_signal(gpu_render_sync_);
|
|
|
|
|
GPU_flush();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_unlock();
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
VLOG_DEVICE_STATS << "Display driver number of textures: " << DisplayGPUTexture::num_used;
|
|
|
|
|
VLOG_DEVICE_STATS << "Display driver number of PBOs: " << DisplayGPUPixelBuffer::num_used;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_context_create()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
if (!RE_engine_gpu_context_create(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data))) {
|
2022-12-01 15:33:54 +01:00
|
|
|
LOG(ERROR) << "Error creating GPU context.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create global GPU resources for display driver. */
|
|
|
|
|
if (!gpu_resources_create()) {
|
|
|
|
|
LOG(ERROR) << "Error creating GPU resources for Cycles Display Driver.";
|
|
|
|
|
return;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
bool BlenderDisplayDriver::gpu_context_enable()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
return RE_engine_gpu_context_enable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_context_disable()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
RE_engine_gpu_context_disable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_context_destroy()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
RE_engine_gpu_context_destroy(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_context_lock()
|
|
|
|
|
{
|
|
|
|
|
RE_engine_gpu_context_lock(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_context_unlock()
|
|
|
|
|
{
|
|
|
|
|
RE_engine_gpu_context_unlock(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
bool BlenderDisplayDriver::gpu_resources_create()
|
|
|
|
|
{
|
|
|
|
|
/* Ensure context is active for resource creation. */
|
|
|
|
|
if (!gpu_context_enable()) {
|
|
|
|
|
LOG(ERROR) << "Error enabling GPU context.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpu_upload_sync_ = GPU_fence_create();
|
|
|
|
|
gpu_render_sync_ = GPU_fence_create();
|
|
|
|
|
|
|
|
|
|
if (!DCHECK_NOTNULL(gpu_upload_sync_) || !DCHECK_NOTNULL(gpu_render_sync_)) {
|
2023-07-13 09:37:02 +02:00
|
|
|
LOG(ERROR) << "Error creating GPU synchronization primitives.";
|
2022-12-01 15:33:54 +01:00
|
|
|
assert(0);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpu_context_disable();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
void BlenderDisplayDriver::gpu_resources_destroy()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_enable();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-12-01 15:33:54 +01:00
|
|
|
tiles_->current_tile.gpu_resources_destroy();
|
2022-01-06 16:41:44 +01:00
|
|
|
tiles_->finished_tiles.gl_resources_destroy_and_clear();
|
2022-12-01 15:33:54 +01:00
|
|
|
|
|
|
|
|
/* Fences. */
|
|
|
|
|
if (gpu_render_sync_) {
|
|
|
|
|
GPU_fence_free(gpu_render_sync_);
|
|
|
|
|
gpu_render_sync_ = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (gpu_upload_sync_) {
|
|
|
|
|
GPU_fence_free(gpu_upload_sync_);
|
|
|
|
|
gpu_upload_sync_ = nullptr;
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_disable();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
gpu_context_destroy();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|