Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-11-13 18:08:33 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-11-13 18:16:26 +0300
commit930d14cc6203bf52f7a4f122336994bf47d2765b (patch)
tree7c5456c35de37c8da357339ae5ace4a5f917e587
parentf1466ce9a8e64606d0709b554937733dc3fb6ad9 (diff)
DRW: Manager: Finish / change implementation of `framebuffer_set` command
Use reference instead of direct pointer. This is because framebuffers often use temp textures and are configured later just before submission.
-rw-r--r--source/blender/draw/intern/draw_command.cc5
-rw-r--r--source/blender/draw/intern/draw_command.hh3
-rw-r--r--source/blender/draw/intern/draw_pass.hh11
3 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc
index 6e999815e8d..848d13083d0 100644
--- a/source/blender/draw/intern/draw_command.cc
+++ b/source/blender/draw/intern/draw_command.cc
@@ -32,7 +32,7 @@ void ShaderBind::execute(RecordingState &state) const
void FramebufferBind::execute() const
{
- GPU_framebuffer_bind(framebuffer);
+ GPU_framebuffer_bind(*framebuffer);
}
void ResourceBind::execute() const
@@ -234,7 +234,8 @@ std::string ShaderBind::serialize() const
std::string FramebufferBind::serialize() const
{
- return std::string(".framebuffer_bind(") + GPU_framebuffer_get_name(framebuffer) + ")";
+ return std::string(".framebuffer_bind(") +
+ (*framebuffer == nullptr ? "nullptr" : GPU_framebuffer_get_name(*framebuffer)) + ")";
}
std::string ResourceBind::serialize() const
diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh
index 12c9916ee6d..03499d07041 100644
--- a/source/blender/draw/intern/draw_command.hh
+++ b/source/blender/draw/intern/draw_command.hh
@@ -120,7 +120,7 @@ struct ShaderBind {
};
struct FramebufferBind {
- GPUFrameBuffer *framebuffer;
+ GPUFrameBuffer **framebuffer;
void execute() const;
std::string serialize() const;
@@ -343,6 +343,7 @@ struct StencilSet {
union Undetermined {
ShaderBind shader_bind;
ResourceBind resource_bind;
+ FramebufferBind framebuffer_bind;
PushConstant push_constant;
Draw draw;
DrawMulti draw_multi;
diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh
index 2c1fd16928e..3675a8fb6d9 100644
--- a/source/blender/draw/intern/draw_pass.hh
+++ b/source/blender/draw/intern/draw_pass.hh
@@ -195,8 +195,9 @@ class PassBase {
/**
* Bind a framebuffer. This is equivalent to a deferred GPU_framebuffer_bind() call.
* \note Changes the global GPU state (outside of DRW).
+ * \note Capture reference to the framebuffer so it can be initialized later.
*/
- void framebuffer_set(GPUFrameBuffer *framebuffer);
+ void framebuffer_set(GPUFrameBuffer **framebuffer);
/**
* Bind a material shader along with its associated resources. Any following bind() or
@@ -506,6 +507,9 @@ template<class T> void PassBase<T>::submit(command::RecordingState &state) const
case Type::SubPass:
sub_passes_[header.index].submit(state);
break;
+ case command::Type::FramebufferBind:
+ commands_[header.index].framebuffer_bind.execute();
+ break;
case command::Type::ShaderBind:
commands_[header.index].shader_bind.execute(state);
break;
@@ -561,6 +565,9 @@ template<class T> std::string PassBase<T>::serialize(std::string line_prefix) co
case Type::SubPass:
ss << sub_passes_[header.index].serialize(line_prefix);
break;
+ case Type::FramebufferBind:
+ ss << line_prefix << commands_[header.index].framebuffer_bind.serialize() << std::endl;
+ break;
case Type::ShaderBind:
ss << line_prefix << commands_[header.index].shader_bind.serialize() << std::endl;
break;
@@ -754,7 +761,7 @@ template<class T> inline void PassBase<T>::shader_set(GPUShader *shader)
create_command(Type::ShaderBind).shader_bind = {shader};
}
-template<class T> inline void PassBase<T>::framebuffer_set(GPUFrameBuffer *framebuffer)
+template<class T> inline void PassBase<T>::framebuffer_set(GPUFrameBuffer **framebuffer)
{
create_command(Type::FramebufferBind).framebuffer_bind = {framebuffer};
}