diff --git a/source/blender/draw/engines/eevee/eevee_hizbuffer.cc b/source/blender/draw/engines/eevee/eevee_hizbuffer.cc index 1a43e56dc44..996cf791bf7 100644 --- a/source/blender/draw/engines/eevee/eevee_hizbuffer.cc +++ b/source/blender/draw/engines/eevee/eevee_hizbuffer.cc @@ -107,7 +107,7 @@ void HiZBuffer::update() is_dirty_ = false; } -void HiZBuffer::debug_draw(View &view, GPUFrameBuffer *view_fb) +void HiZBuffer::debug_draw(View &view, gpu::FrameBuffer *view_fb) { if (inst_.debug_mode == eDebugMode::DEBUG_HIZ_VALIDATION) { inst_.info_append( diff --git a/source/blender/draw/engines/eevee/eevee_hizbuffer.hh b/source/blender/draw/engines/eevee/eevee_hizbuffer.hh index 0b4492ab4d2..040339281ce 100644 --- a/source/blender/draw/engines/eevee/eevee_hizbuffer.hh +++ b/source/blender/draw/engines/eevee/eevee_hizbuffer.hh @@ -102,7 +102,7 @@ class HiZBuffer { */ void update(); - void debug_draw(View &view, GPUFrameBuffer *view_fb); + void debug_draw(View &view, gpu::FrameBuffer *view_fb); /* Back is Previous layer depth (ex: For refraction). Front for current layer depth. */ struct { diff --git a/source/blender/draw/engines/eevee/eevee_light.cc b/source/blender/draw/engines/eevee/eevee_light.cc index 25b69259b92..5d200003980 100644 --- a/source/blender/draw/engines/eevee/eevee_light.cc +++ b/source/blender/draw/engines/eevee/eevee_light.cc @@ -618,7 +618,7 @@ void LightModule::set_view(View &view, const int2 extent) inst_.manager->submit(update_ps_, view); } -void LightModule::debug_draw(View &view, GPUFrameBuffer *view_fb) +void LightModule::debug_draw(View &view, gpu::FrameBuffer *view_fb) { if (inst_.debug_mode == eDebugMode::DEBUG_LIGHT_CULLING) { inst_.info_append("Debug Mode: Light Culling Validation"); diff --git a/source/blender/draw/engines/eevee/eevee_light.hh b/source/blender/draw/engines/eevee/eevee_light.hh index 03850d35a5a..ce31aed96df 100644 --- a/source/blender/draw/engines/eevee/eevee_light.hh +++ b/source/blender/draw/engines/eevee/eevee_light.hh @@ -187,7 +187,7 @@ class LightModule { */ void set_view(View &view, const int2 extent); - void debug_draw(View &view, GPUFrameBuffer *view_fb); + void debug_draw(View &view, gpu::FrameBuffer *view_fb); template void bind_resources(PassType &pass) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_planar.cc b/source/blender/draw/engines/eevee/eevee_lightprobe_planar.cc index 6a83423213d..7dc9a3dd52a 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_planar.cc +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_planar.cc @@ -147,7 +147,7 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext } } -void PlanarProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) +void PlanarProbeModule::viewport_draw(View &view, gpu::FrameBuffer *view_fb) { if (!do_display_draw_) { return; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_planar.hh b/source/blender/draw/engines/eevee/eevee_lightprobe_planar.hh index c6cf8c17b90..a854e3831bf 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_planar.hh +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_planar.hh @@ -67,7 +67,7 @@ class PlanarProbeModule { void set_view(const draw::View &main_view, int2 main_view_extent); - void viewport_draw(View &view, GPUFrameBuffer *view_fb); + void viewport_draw(View &view, gpu::FrameBuffer *view_fb); template void bind_resources(PassType &pass) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.cc b/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.cc index 8d119948ebf..087ec679872 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.cc +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.cc @@ -335,7 +335,7 @@ void SphereProbeModule::sync_display(Vector &probe_active) display_data_buf_.push_update(); } -void SphereProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) +void SphereProbeModule::viewport_draw(View &view, gpu::FrameBuffer *view_fb) { if (!do_display_draw_) { return; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.hh b/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.hh index 49b9a5545c3..7fce511fb59 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.hh +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_sphere.hh @@ -118,7 +118,7 @@ class SphereProbeModule { void begin_sync(); void end_sync(); - void viewport_draw(View &view, GPUFrameBuffer *view_fb); + void viewport_draw(View &view, gpu::FrameBuffer *view_fb); template void bind_resources(PassType &pass) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_volume.cc b/source/blender/draw/engines/eevee/eevee_lightprobe_volume.cc index e9d880e38f6..480add376d1 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_volume.cc +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_volume.cc @@ -480,7 +480,7 @@ void VolumeProbeModule::set_view(View & /*view*/) do_update_world_ = false; } -void VolumeProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) +void VolumeProbeModule::viewport_draw(View &view, gpu::FrameBuffer *view_fb) { if (!inst_.is_baking()) { debug_pass_draw(view, view_fb); @@ -488,7 +488,7 @@ void VolumeProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) } } -void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) +void VolumeProbeModule::debug_pass_draw(View &view, gpu::FrameBuffer *view_fb) { switch (inst_.debug_mode) { case eDebugMode::DEBUG_IRRADIANCE_CACHE_SURFELS_NORMAL: @@ -618,7 +618,7 @@ void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) } } -void VolumeProbeModule::display_pass_draw(View &view, GPUFrameBuffer *view_fb) +void VolumeProbeModule::display_pass_draw(View &view, gpu::FrameBuffer *view_fb) { if (!display_grids_enabled_) { return; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobe_volume.hh b/source/blender/draw/engines/eevee/eevee_lightprobe_volume.hh index 44e8e3bd864..9aae70df619 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobe_volume.hh +++ b/source/blender/draw/engines/eevee/eevee_lightprobe_volume.hh @@ -246,7 +246,7 @@ class VolumeProbeModule { } void set_view(View &view); - void viewport_draw(View &view, GPUFrameBuffer *view_fb); + void viewport_draw(View &view, gpu::FrameBuffer *view_fb); Vector bricks_alloc(int brick_len); void bricks_free(Vector &bricks); @@ -259,8 +259,8 @@ class VolumeProbeModule { } private: - void debug_pass_draw(View &view, GPUFrameBuffer *view_fb); - void display_pass_draw(View &view, GPUFrameBuffer *view_fb); + void debug_pass_draw(View &view, gpu::FrameBuffer *view_fb); + void display_pass_draw(View &view, gpu::FrameBuffer *view_fb); friend class SphereProbeModule; }; diff --git a/source/blender/draw/engines/eevee/eevee_pipeline.cc b/source/blender/draw/engines/eevee/eevee_pipeline.cc index 1bc2e2f9cdd..a6a4416a0f8 100644 --- a/source/blender/draw/engines/eevee/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee/eevee_pipeline.cc @@ -971,7 +971,7 @@ void DeferredPipeline::debug_pass_sync() pass.draw_procedural(GPU_PRIM_TRIS, 1, 3); } -void DeferredPipeline::debug_draw(draw::View &view, GPUFrameBuffer *combined_fb) +void DeferredPipeline::debug_draw(draw::View &view, gpu::FrameBuffer *combined_fb) { Instance &inst = opaque_layer_.inst_; if (!ELEM(inst.debug_mode, diff --git a/source/blender/draw/engines/eevee/eevee_pipeline.hh b/source/blender/draw/engines/eevee/eevee_pipeline.hh index 75cc276d309..dddc8d47569 100644 --- a/source/blender/draw/engines/eevee/eevee_pipeline.hh +++ b/source/blender/draw/engines/eevee/eevee_pipeline.hh @@ -398,7 +398,7 @@ class DeferredPipeline { return max_ii(opaque_layer_.normal_layer_count(), refraction_layer_.normal_layer_count()); } - void debug_draw(draw::View &view, GPUFrameBuffer *combined_fb); + void debug_draw(draw::View &view, gpu::FrameBuffer *combined_fb); bool is_empty() const { diff --git a/source/blender/draw/engines/eevee/eevee_raytrace.cc b/source/blender/draw/engines/eevee/eevee_raytrace.cc index 3c37d8a776b..346f825b593 100644 --- a/source/blender/draw/engines/eevee/eevee_raytrace.cc +++ b/source/blender/draw/engines/eevee/eevee_raytrace.cc @@ -397,7 +397,7 @@ void RayTraceModule::sync() void RayTraceModule::debug_pass_sync() {} -void RayTraceModule::debug_draw(View & /*view*/, GPUFrameBuffer * /*view_fb*/) {} +void RayTraceModule::debug_draw(View & /*view*/, gpu::FrameBuffer * /*view_fb*/) {} RayTraceResult RayTraceModule::render(RayTraceBuffer &rt_buffer, gpu::Texture *screen_radiance_back_tx, diff --git a/source/blender/draw/engines/eevee/eevee_raytrace.hh b/source/blender/draw/engines/eevee/eevee_raytrace.hh index f6cce991cce..caae1ffe307 100644 --- a/source/blender/draw/engines/eevee/eevee_raytrace.hh +++ b/source/blender/draw/engines/eevee/eevee_raytrace.hh @@ -278,7 +278,7 @@ class RayTraceModule { RayTraceResult alloc_dummy(RayTraceBuffer &rt_buffer); void debug_pass_sync(); - void debug_draw(View &view, GPUFrameBuffer *view_fb); + void debug_draw(View &view, gpu::FrameBuffer *view_fb); bool use_raytracing() const { diff --git a/source/blender/draw/engines/eevee/eevee_shadow.cc b/source/blender/draw/engines/eevee/eevee_shadow.cc index c7e2527741f..8cf77d8ad4f 100644 --- a/source/blender/draw/engines/eevee/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee/eevee_shadow.cc @@ -1282,7 +1282,7 @@ void ShadowModule::set_view(View &view, int2 extent) input_depth_extent_ = extent; - GPUFrameBuffer *prev_fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *prev_fb = GPU_framebuffer_active_get(); dispatch_depth_scan_size_ = int3(math::divide_ceil(extent, int2(SHADOW_DEPTH_SCAN_GROUP_SIZE)), 1); @@ -1399,7 +1399,7 @@ void ShadowModule::set_view(View &view, int2 extent) } } -void ShadowModule::debug_draw(View &view, GPUFrameBuffer *view_fb) +void ShadowModule::debug_draw(View &view, gpu::FrameBuffer *view_fb) { if (!ELEM(inst_.debug_mode, eDebugMode::DEBUG_SHADOW_TILEMAPS, diff --git a/source/blender/draw/engines/eevee/eevee_shadow.hh b/source/blender/draw/engines/eevee/eevee_shadow.hh index 88d08c67905..fa5a32e915f 100644 --- a/source/blender/draw/engines/eevee/eevee_shadow.hh +++ b/source/blender/draw/engines/eevee/eevee_shadow.hh @@ -378,7 +378,7 @@ class ShadowModule { void set_view(View &view, int2 extent); void debug_end_sync(); - void debug_draw(View &view, GPUFrameBuffer *view_fb); + void debug_draw(View &view, gpu::FrameBuffer *view_fb); template void bind_resources(PassType &pass) { diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index 9257bafa77d..0dd6e534db8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -738,7 +738,7 @@ void Instance::draw_object(View &view, tObject *ob) GPU_debug_group_begin("GPencil Object"); - GPUFrameBuffer *fb_object = (ob->vfx.first) ? this->object_fb : this->gpencil_fb; + gpu::FrameBuffer *fb_object = (ob->vfx.first) ? this->object_fb : this->gpencil_fb; GPU_framebuffer_bind(fb_object); GPU_framebuffer_clear_depth_stencil(fb_object, ob->is_drawmode3d ? 1.0f : 0.0f, 0x00); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_private.hh b/source/blender/draw/engines/gpencil/gpencil_engine_private.hh index 7c94ec52c6a..dd3e6ec3523 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_private.hh +++ b/source/blender/draw/engines/gpencil/gpencil_engine_private.hh @@ -72,7 +72,7 @@ struct tVfx { struct tVfx *next = nullptr; std::unique_ptr vfx_ps = std::make_unique("vfx"); /* Frame-buffer reference since it may not be allocated yet. */ - GPUFrameBuffer **target_fb = nullptr; + gpu::FrameBuffer **target_fb = nullptr; }; /* Temporary gpencil layer reflection used by the gpencil::Instance. */ @@ -210,7 +210,7 @@ struct Instance final : public DrawEngine { bool is_sorted; /* Pointer to dtxl->depth */ gpu::Texture *scene_depth_tx; - GPUFrameBuffer *scene_fb; + gpu::FrameBuffer *scene_fb; /* Used for render accumulation antialiasing. */ Texture accumulation_tx = {"gp_accumulation_tx"}; Framebuffer accumulation_fb = {"gp_accumulation_fb"}; @@ -352,7 +352,7 @@ struct Instance final : public DrawEngine { struct VfxFramebufferRef { /* These may not be allocated yet, use address of future pointer. */ - GPUFrameBuffer **fb; + gpu::FrameBuffer **fb; gpu::Texture **color_tx; gpu::Texture **reveal_tx; }; diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.hh b/source/blender/draw/engines/overlay/overlay_antialiasing.hh index b357d8f8a1c..bf7d7bf6f7b 100644 --- a/source/blender/draw/engines/overlay/overlay_antialiasing.hh +++ b/source/blender/draw/engines/overlay/overlay_antialiasing.hh @@ -52,7 +52,7 @@ class AntiAliasing : Overlay { private: PassSimple anti_aliasing_ps_ = {"AntiAliasing"}; - GPUFrameBuffer *framebuffer_ref_ = nullptr; + gpu::FrameBuffer *framebuffer_ref_ = nullptr; public: void begin_sync(Resources &res, const State & /*state*/) final diff --git a/source/blender/draw/engines/overlay/overlay_background.hh b/source/blender/draw/engines/overlay/overlay_background.hh index 4f319e3fb5a..ed0caf58929 100644 --- a/source/blender/draw/engines/overlay/overlay_background.hh +++ b/source/blender/draw/engines/overlay/overlay_background.hh @@ -23,7 +23,7 @@ class Background : Overlay { private: PassSimple bg_ps_ = {"Background"}; - GPUFrameBuffer *framebuffer_ref_ = nullptr; + gpu::FrameBuffer *framebuffer_ref_ = nullptr; public: void begin_sync(Resources &res, const State &state) final diff --git a/source/blender/draw/engines/overlay/overlay_base.hh b/source/blender/draw/engines/overlay/overlay_base.hh index ae0609a4453..7680ecfe3fc 100644 --- a/source/blender/draw/engines/overlay/overlay_base.hh +++ b/source/blender/draw/engines/overlay/overlay_base.hh @@ -96,7 +96,7 @@ struct Overlay { * resolving to the given frame-buffer. */ - virtual void draw_on_render(GPUFrameBuffer * /*fb*/, Manager & /*manager*/, View & /*view*/){}; + virtual void draw_on_render(gpu::FrameBuffer * /*fb*/, Manager & /*manager*/, View & /*view*/){}; virtual void draw(Framebuffer & /*fb*/, Manager & /*manager*/, View & /*view*/){}; virtual void draw_line(Framebuffer & /*fb*/, Manager & /*manager*/, View & /*view*/){}; virtual void draw_line_only(Framebuffer & /*fb*/, Manager & /*manager*/, View & /*view*/){}; diff --git a/source/blender/draw/engines/overlay/overlay_camera.hh b/source/blender/draw/engines/overlay/overlay_camera.hh index 15d79563a41..c0e5ed3e730 100644 --- a/source/blender/draw/engines/overlay/overlay_camera.hh +++ b/source/blender/draw/engines/overlay/overlay_camera.hh @@ -240,7 +240,7 @@ class Cameras : Overlay { manager.submit(ps_, view); } - void draw_scene_background_images(GPUFrameBuffer *framebuffer, Manager &manager, View &view) + void draw_scene_background_images(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) { if (!images_enabled_) { return; diff --git a/source/blender/draw/engines/overlay/overlay_mesh.hh b/source/blender/draw/engines/overlay/overlay_mesh.hh index 4c4184b35e7..b4ae9fd5bc0 100644 --- a/source/blender/draw/engines/overlay/overlay_mesh.hh +++ b/source/blender/draw/engines/overlay/overlay_mesh.hh @@ -1061,7 +1061,7 @@ class MeshUVs : Overlay { GPU_debug_group_end(); } - void draw_on_render(GPUFrameBuffer *framebuffer, Manager &manager, View &view) final + void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final { if (!enabled_) { return; diff --git a/source/blender/draw/engines/overlay/overlay_prepass.hh b/source/blender/draw/engines/overlay/overlay_prepass.hh index 49e0fcf8a84..c6d9cb9b2ba 100644 --- a/source/blender/draw/engines/overlay/overlay_prepass.hh +++ b/source/blender/draw/engines/overlay/overlay_prepass.hh @@ -43,7 +43,7 @@ class ImagePrepass : Overlay { ps_.draw(res.shapes.image_quad.get()); } - void draw_on_render(GPUFrameBuffer *framebuffer, Manager &manager, View &view) final + void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final { if (!enabled_) { return; diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 260e06a99fc..411f4d32ddb 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -606,8 +606,8 @@ struct Resources : public select::SelectMap { /* Render Frame-buffers. Only used for multiplicative blending on top of the render. */ /* TODO(fclem): Remove the usage of these somehow. This is against design. */ - GPUFrameBuffer *render_fb = nullptr; - GPUFrameBuffer *render_in_front_fb = nullptr; + gpu::FrameBuffer *render_fb = nullptr; + gpu::FrameBuffer *render_in_front_fb = nullptr; /* Target containing line direction and data for line expansion and anti-aliasing. */ TextureFromPool line_tx = {"line_tx"}; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt.hh b/source/blender/draw/engines/overlay/overlay_sculpt.hh index 42824e74645..8601d76e938 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt.hh +++ b/source/blender/draw/engines/overlay/overlay_sculpt.hh @@ -240,7 +240,7 @@ class Sculpts : Overlay { manager.submit(sculpt_curve_cage_, view); } - void draw_on_render(GPUFrameBuffer *framebuffer, Manager &manager, View &view) final + void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final { if (!enabled_) { return; diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index d2bf8cff53e..69cb946db52 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -64,7 +64,7 @@ struct Instance : public DrawEngine { public: struct StaticData { - GPUFrameBuffer *framebuffer_select_id; + gpu::FrameBuffer *framebuffer_select_id; blender::gpu::Texture *texture_u32; struct Shaders { @@ -533,7 +533,7 @@ SELECTID_Context *DRW_select_engine_context_get() return &e_data.context; } -GPUFrameBuffer *DRW_engine_select_framebuffer_get() +blender::gpu::FrameBuffer *DRW_engine_select_framebuffer_get() { Instance::StaticData &e_data = Instance::StaticData::get(); return e_data.framebuffer_select_id; diff --git a/source/blender/draw/engines/select/select_engine.hh b/source/blender/draw/engines/select/select_engine.hh index b5fb5fd95b7..e4be3743d62 100644 --- a/source/blender/draw/engines/select/select_engine.hh +++ b/source/blender/draw/engines/select/select_engine.hh @@ -28,7 +28,7 @@ struct Engine : public DrawEngine::Pointer { #endif struct SELECTID_Context *DRW_select_engine_context_get(); -struct GPUFrameBuffer *DRW_engine_select_framebuffer_get(); +blender::gpu::FrameBuffer *DRW_engine_select_framebuffer_get(); blender::gpu::Texture *DRW_engine_select_texture_get(); /* select_instance.cc */ diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index b19f303a1bf..41cb811f651 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -630,7 +630,7 @@ static bool workbench_render_framebuffers_init(const DRWContext *draw_ctx) static void write_render_color_output(RenderLayer *layer, const char *viewname, - GPUFrameBuffer *fb, + gpu::FrameBuffer *fb, const rcti *rect) { RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_COMBINED, viewname); @@ -650,7 +650,7 @@ static void write_render_color_output(RenderLayer *layer, static void write_render_z_output(RenderLayer *layer, const char *viewname, - GPUFrameBuffer *fb, + gpu::FrameBuffer *fb, const rcti *rect, const float4x4 &winmat) { diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index b021876e32b..93eca474887 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -1201,7 +1201,7 @@ static inline gpu::Texture **as_texture(Image **img) class Framebuffer : NonCopyable { private: - GPUFrameBuffer *fb_ = nullptr; + gpu::FrameBuffer *fb_ = nullptr; const char *name_; public: @@ -1262,12 +1262,12 @@ class Framebuffer : NonCopyable { return *this; } - operator GPUFrameBuffer *() const + operator gpu::FrameBuffer *() const { return fb_; } - GPUFrameBuffer **operator&() + gpu::FrameBuffer **operator&() { return &fb_; } diff --git a/source/blender/draw/intern/DRW_render.hh b/source/blender/draw/intern/DRW_render.hh index caffeddacca..967d45559de 100644 --- a/source/blender/draw/intern/DRW_render.hh +++ b/source/blender/draw/intern/DRW_render.hh @@ -25,6 +25,7 @@ class Batch; class Shader; class Texture; class UniformBuf; +class FrameBuffer; } // namespace blender::gpu struct ARegion; struct bContext; @@ -51,7 +52,6 @@ struct World; struct DRWData; struct DRWViewData; struct GPUViewport; -struct GPUFrameBuffer; struct DRWTextStore; struct GSet; struct GPUViewport; @@ -241,7 +241,7 @@ struct DRWContext { blender::float2 inv_size = {0, 0}; /** Returns the viewport's default frame-buffer. */ - GPUFrameBuffer *default_framebuffer(); + blender::gpu::FrameBuffer *default_framebuffer(); /** Returns the viewport's default frame-buffer list. Not all of them might be available. */ DefaultFramebufferList *viewport_framebuffer_list_get() const; /** Returns the viewport's default texture list. Not all of them might be available. */ diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc index ff9e859b49c..1d33cbc3ac6 100644 --- a/source/blender/draw/intern/draw_command.cc +++ b/source/blender/draw/intern/draw_command.cc @@ -63,7 +63,7 @@ void SubPassTransition::execute() const { /* TODO(fclem): Require framebuffer bind to always be part of the pass so that we can track it * inside RecordingState. */ - GPUFrameBuffer *framebuffer = GPU_framebuffer_active_get(); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_active_get(); /* Unpack to the real enum type. */ const GPUAttachmentState states[9] = { GPUAttachmentState(depth_state), @@ -284,13 +284,13 @@ void Barrier::execute() const void Clear::execute() const { - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_clear(fb, (GPUFrameBufferBits)clear_channels, color, depth, stencil); } void ClearMulti::execute() const { - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_multi_clear(fb, (const float(*)[4])colors); } diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index be03c302a7c..57903f9609c 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -142,7 +142,7 @@ struct ShaderBind { }; struct FramebufferBind { - GPUFrameBuffer **framebuffer; + gpu::FrameBuffer **framebuffer; void execute() const; std::string serialize() const; diff --git a/source/blender/draw/intern/draw_context.cc b/source/blender/draw/intern/draw_context.cc index d117f647572..c1c63c9c716 100644 --- a/source/blender/draw/intern/draw_context.cc +++ b/source/blender/draw/intern/draw_context.cc @@ -192,7 +192,7 @@ DRWContext::~DRWContext() g_context = nullptr; } -GPUFrameBuffer *DRWContext::default_framebuffer() +blender::gpu::FrameBuffer *DRWContext::default_framebuffer() { return view_data_active->dfbl.default_fb; } @@ -1797,7 +1797,7 @@ void DRW_render_set_time(RenderEngine *engine, Depsgraph *depsgraph, int frame, } static struct DRWSelectBuffer { - GPUFrameBuffer *framebuffer_depth_only; + blender::gpu::FrameBuffer *framebuffer_depth_only; blender::gpu::Texture *texture_depth; } g_select_buffer = {nullptr}; @@ -2039,7 +2039,7 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph, /* Setup frame-buffer. */ blender::gpu::Texture *depth_tx = GPU_viewport_depth_texture(viewport); - GPUFrameBuffer *depth_fb = nullptr; + blender::gpu::FrameBuffer *depth_fb = nullptr; GPU_framebuffer_ensure_config(&depth_fb, { GPU_ATTACHMENT_TEXTURE(depth_tx), diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh index 56264d88b79..1a401f6fdf9 100644 --- a/source/blender/draw/intern/draw_pass.hh +++ b/source/blender/draw/intern/draw_pass.hh @@ -231,7 +231,7 @@ class PassBase { * \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(gpu::FrameBuffer **framebuffer); /** * Start a new sub-pass and change framebuffer attachments status. @@ -1109,7 +1109,7 @@ template inline void PassBase::shader_set(gpu::Shader *shader) create_command(Type::ShaderBind).shader_bind = {shader}; } -template inline void PassBase::framebuffer_set(GPUFrameBuffer **framebuffer) +template inline void PassBase::framebuffer_set(gpu::FrameBuffer **framebuffer) { create_command(Type::FramebufferBind).framebuffer_bind = {framebuffer}; } diff --git a/source/blender/draw/intern/draw_select_buffer.cc b/source/blender/draw/intern/draw_select_buffer.cc index 573a04cd546..4456af4d0b9 100644 --- a/source/blender/draw/intern/draw_select_buffer.cc +++ b/source/blender/draw/intern/draw_select_buffer.cc @@ -99,7 +99,7 @@ uint *DRW_select_buffer_read( buf_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect); buf = MEM_malloc_arrayN(buf_len, __func__); - GPUFrameBuffer *select_id_fb = DRW_engine_select_framebuffer_get(); + blender::gpu::FrameBuffer *select_id_fb = DRW_engine_select_framebuffer_get(); GPU_framebuffer_bind(select_id_fb); GPU_framebuffer_read_color(select_id_fb, rect_clamp.xmin, diff --git a/source/blender/draw/intern/draw_view_data.hh b/source/blender/draw/intern/draw_view_data.hh index d8607be0e46..d638a2fca4d 100644 --- a/source/blender/draw/intern/draw_view_data.hh +++ b/source/blender/draw/intern/draw_view_data.hh @@ -34,21 +34,21 @@ class Manager; } // namespace blender::draw struct DRWTextStore; -struct GPUFrameBuffer; namespace blender::gpu { +class FrameBuffer; class Texture; -} +} // namespace blender::gpu struct GPUViewport; struct ListBase; /** Buffer and textures used by the viewport by default. */ struct DefaultFramebufferList { - GPUFrameBuffer *default_fb; - GPUFrameBuffer *overlay_fb; - GPUFrameBuffer *in_front_fb; - GPUFrameBuffer *color_only_fb; - GPUFrameBuffer *depth_only_fb; - GPUFrameBuffer *overlay_only_fb; + blender::gpu::FrameBuffer *default_fb; + blender::gpu::FrameBuffer *overlay_fb; + blender::gpu::FrameBuffer *in_front_fb; + blender::gpu::FrameBuffer *color_only_fb; + blender::gpu::FrameBuffer *depth_only_fb; + blender::gpu::FrameBuffer *overlay_only_fb; }; struct DefaultTextureList { diff --git a/source/blender/draw/tests/draw_pass_test.cc b/source/blender/draw/tests/draw_pass_test.cc index 6ad1ba98dd0..43d8cc38928 100644 --- a/source/blender/draw/tests/draw_pass_test.cc +++ b/source/blender/draw/tests/draw_pass_test.cc @@ -32,7 +32,7 @@ static void test_draw_pass_all_commands() /* Won't be dereferenced. */ gpu::VertBuf *vbo = (gpu::VertBuf *)1; gpu::IndexBuf *ibo = (gpu::IndexBuf *)1; - GPUFrameBuffer *fb = nullptr; + gpu::FrameBuffer *fb = nullptr; float4 color(1.0f, 1.0f, 1.0f, 0.0f); int3 dispatch_size(1); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 0767a5d30c2..9c0cc1f8431 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -513,7 +513,7 @@ void ED_region_do_draw(bContext *C, ARegion *region) ED_region_pixelspace(region); /* Remove sRGB override by rebinding the framebuffer. */ - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_bind(fb); ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_PIXEL); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 89eac8ae28d..f67d1c5984b 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1506,7 +1506,7 @@ void draw_nodespace_back_pix(const bContext &C, GPU_matrix_push(); /* The draw manager is used to draw the backdrop image. */ - GPUFrameBuffer *old_fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *old_fb = GPU_framebuffer_active_get(); GPU_framebuffer_restore(); BLI_thread_lock(LOCK_DRAW_IMAGE); DRW_draw_view(&C); diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index f8783fe82c8..27d16489f92 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -4700,7 +4700,7 @@ void node_draw_space(const bContext &C, ARegion ®ion) /* Setup off-screen buffers. */ GPUViewport *viewport = WM_draw_region_get_viewport(®ion); - GPUFrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); + blender::gpu::FrameBuffer *framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport); GPU_framebuffer_bind_no_srgb(framebuffer_overlay); UI_view2d_view_ortho(&v2d); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.hh b/source/blender/editors/space_sequencer/sequencer_intern.hh index 98c82406fa5..a3b0b5e9442 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.hh +++ b/source/blender/editors/space_sequencer/sequencer_intern.hh @@ -122,7 +122,7 @@ struct TimelineDrawContext { Editing *ed; ListBase *channels; GPUViewport *viewport; - GPUFrameBuffer *framebuffer_overlay; + blender::gpu::FrameBuffer *framebuffer_overlay; float pixelx, pixely; /* Width and height of pixel in timeline space. */ blender::Map retiming_selection; diff --git a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc index e89f47bc141..ac75ea4b292 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc @@ -146,7 +146,7 @@ ImBuf *sequencer_ibuf_get(const bContext *C, const int timeline_frame, const cha G.is_break = false; GPUViewport *viewport = WM_draw_region_get_bound_viewport(region); - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); if (viewport) { /* Unbind viewport to release the DRW context. */ GPU_viewport_unbind(viewport); @@ -909,7 +909,7 @@ static void update_gpu_scopes(const ImBuf *input_ibuf, GPU_matrix_ortho_set(0.0f, 1.0f, 0.0f, 1.0f, -1.0, 1.0f); GPU_matrix_identity_set(); - GPUFrameBuffer *fb = nullptr; + blender::gpu::FrameBuffer *fb = nullptr; GPU_framebuffer_ensure_config(&fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(display_texture)}); GPU_framebuffer_bind(fb); @@ -1217,7 +1217,7 @@ static void sequencer_preview_draw_empty(ARegion ®ion) GPUViewport *viewport = WM_draw_region_get_bound_viewport(®ion); BLI_assert(viewport); - GPUFrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); + blender::gpu::FrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); GPU_framebuffer_bind_no_srgb(overlay_fb); sequencer_preview_clear(); @@ -1274,7 +1274,7 @@ static void preview_draw_color_render_begin(ARegion ®ion) GPUViewport *viewport = WM_draw_region_get_bound_viewport(®ion); BLI_assert(viewport); - GPUFrameBuffer *render_fb = GPU_viewport_framebuffer_render_get(viewport); + blender::gpu::FrameBuffer *render_fb = GPU_viewport_framebuffer_render_get(viewport); GPU_framebuffer_bind(render_fb); float col[4] = {0, 0, 0, 0}; @@ -1287,7 +1287,7 @@ static void preview_draw_overlay_begin(ARegion ®ion) GPUViewport *viewport = WM_draw_region_get_bound_viewport(®ion); BLI_assert(viewport); - GPUFrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); + blender::gpu::FrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); GPU_framebuffer_bind_no_srgb(overlay_fb); sequencer_preview_clear(); @@ -1599,7 +1599,7 @@ static void draw_registered_callbacks(const bContext *C, ARegion ®ion) GPUViewport *viewport = WM_draw_region_get_bound_viewport(®ion); BLI_assert(viewport); - GPUFrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); + blender::gpu::FrameBuffer *overlay_fb = GPU_viewport_framebuffer_overlay_get(viewport); GPU_framebuffer_bind(overlay_fb); ED_region_draw_cb_draw(C, ®ion, REGION_DRAW_POST_VIEW); diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 390a17bf525..e1e62e011d6 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -2024,7 +2024,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, ofs = nullptr; } - GPUFrameBuffer *old_fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *old_fb = GPU_framebuffer_active_get(); if (old_fb) { GPU_framebuffer_restore(); @@ -2356,7 +2356,7 @@ static void view3d_gpu_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *da { blender::gpu::Texture *depth_tx = GPU_viewport_depth_texture(viewport); - GPUFrameBuffer *depth_read_fb = nullptr; + blender::gpu::FrameBuffer *depth_read_fb = nullptr; GPU_framebuffer_ensure_config(&depth_read_fb, { GPU_ATTACHMENT_TEXTURE(depth_tx), diff --git a/source/blender/gpu/GPU_framebuffer.hh b/source/blender/gpu/GPU_framebuffer.hh index cd52952b24b..36cd62507f2 100644 --- a/source/blender/gpu/GPU_framebuffer.hh +++ b/source/blender/gpu/GPU_framebuffer.hh @@ -29,7 +29,8 @@ namespace blender::gpu { class Texture; -} +class FrameBuffer; +} // namespace blender::gpu enum GPUFrameBufferBits { GPU_COLOR_BIT = (1 << 0), @@ -47,30 +48,27 @@ struct GPUAttachment { int layer, mip; }; -/** Opaque type hiding blender::gpu::FrameBuffer. */ -struct GPUFrameBuffer; - /* -------------------------------------------------------------------- */ /** \name Creation * \{ */ /** - * Create a #GPUFrameBuffer object. It is not configured and not bound to a specific context until + * Create a #FrameBuffer object. It is not configured and not bound to a specific context until * `GPU_framebuffer_bind()` is called. */ -GPUFrameBuffer *GPU_framebuffer_create(const char *name); +blender::gpu::FrameBuffer *GPU_framebuffer_create(const char *name); /** * Returns the current context active framebuffer. * Return nullptr if no context is active. */ -GPUFrameBuffer *GPU_framebuffer_active_get(); +blender::gpu::FrameBuffer *GPU_framebuffer_active_get(); /** * Returns the default (back-left) frame-buffer. It will always exists even if it's just a dummy. * Return nullptr if no context is active. */ -GPUFrameBuffer *GPU_framebuffer_back_get(); +blender::gpu::FrameBuffer *GPU_framebuffer_back_get(); /** \} */ @@ -79,10 +77,10 @@ GPUFrameBuffer *GPU_framebuffer_back_get(); * \{ */ /** - * Create a #GPUFrameBuffer object. It is not configured and not bound to a specific context until + * Create a #FrameBuffer object. It is not configured and not bound to a specific context until * `GPU_framebuffer_bind()` is called. */ -void GPU_framebuffer_free(GPUFrameBuffer *fb); +void GPU_framebuffer_free(blender::gpu::FrameBuffer *fb); #define GPU_FRAMEBUFFER_FREE_SAFE(fb) \ do { \ @@ -112,14 +110,14 @@ enum GPUBackBuffer { void GPU_backbuffer_bind(GPUBackBuffer back_buffer_type); /** - * Binds a #GPUFrameBuffer making it the active framebuffer for all geometry rendering. + * Binds a #FrameBuffer making it the active framebuffer for all geometry rendering. */ -void GPU_framebuffer_bind(GPUFrameBuffer *fb); +void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb); /** * Same as `GPU_framebuffer_bind` but do not enable the SRGB transform. */ -void GPU_framebuffer_bind_no_srgb(GPUFrameBuffer *fb); +void GPU_framebuffer_bind_no_srgb(blender::gpu::FrameBuffer *fb); /** * Binds back the active context's default frame-buffer. @@ -176,7 +174,7 @@ struct GPULoadStore { * }) * \endcode */ -void GPU_framebuffer_bind_loadstore(GPUFrameBuffer *fb, +void GPU_framebuffer_bind_loadstore(blender::gpu::FrameBuffer *fb, const GPULoadStore *load_store_actions, uint load_store_actions_len); #define GPU_framebuffer_bind_ex(_fb, ...) \ @@ -206,7 +204,7 @@ void GPU_framebuffer_bind_loadstore(GPUFrameBuffer *fb, * * \note Excess attachments will have no effect as long as they are GPU_ATTACHMENT_IGNORE. */ -void GPU_framebuffer_subpass_transition_array(GPUFrameBuffer *fb, +void GPU_framebuffer_subpass_transition_array(blender::gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len); @@ -257,7 +255,9 @@ void GPU_framebuffer_subpass_transition_array(GPUFrameBuffer *fb, * Setting #GPUAttachment.mip to -1 will leave the texture in this slot. * Setting #GPUAttachment.tex to nullptr will detach the texture in this slot. */ -void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *config, int config_len); +void GPU_framebuffer_config_array(blender::gpu::FrameBuffer *fb, + const GPUAttachment *config, + int config_len); /** Empty bind point. */ #define GPU_ATTACHMENT_NONE \ @@ -304,49 +304,49 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *fb, const GPUAttachment *confi } /** - * Attach an entire texture mip level to a #GPUFrameBuffer. + * Attach an entire texture mip level to a #FrameBuffer. * Changes will only take effect next time `GPU_framebuffer_bind()` is called. * \a slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. * \a mip is the mip level of this texture to attach to the framebuffer. - * DEPRECATED: Prefer using multiple #GPUFrameBuffer with different configurations with + * DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with * `GPU_framebuffer_config_array()`. */ -void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, +void GPU_framebuffer_texture_attach(blender::gpu::FrameBuffer *fb, blender::gpu::Texture *texture, int slot, int mip); /** - * Attach a single layer of an array texture mip level to a #GPUFrameBuffer. + * Attach a single layer of an array texture mip level to a #FrameBuffer. * Changes will only take effect next time `GPU_framebuffer_bind()` is called. * \a slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. * \a layer is the layer of this array texture to attach to the framebuffer. * \a mip is the mip level of this texture to attach to the framebuffer. - * DEPRECATED: Prefer using multiple #GPUFrameBuffer with different configurations with + * DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with * `GPU_framebuffer_config_array()`. */ void GPU_framebuffer_texture_layer_attach( - GPUFrameBuffer *fb, blender::gpu::Texture *texture, int slot, int layer, int mip); + blender::gpu::FrameBuffer *fb, blender::gpu::Texture *texture, int slot, int layer, int mip); /** - * Attach a single cube-face of an cube-map texture mip level to a #GPUFrameBuffer. + * Attach a single cube-face of an cube-map texture mip level to a #FrameBuffer. * Changes will only take effect next time `GPU_framebuffer_bind()` is called. * \a slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. * \a face is the cube-face of this cube-map texture to attach to the framebuffer. * \a mip is the mip level of this texture to attach to the framebuffer. - * DEPRECATED: Prefer using multiple #GPUFrameBuffer with different configurations with + * DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with * `GPU_framebuffer_config_array()`. */ void GPU_framebuffer_texture_cubeface_attach( - GPUFrameBuffer *fb, blender::gpu::Texture *texture, int slot, int face, int mip); + blender::gpu::FrameBuffer *fb, blender::gpu::Texture *texture, int slot, int face, int mip); /** - * Detach a texture from a #GPUFrameBuffer. The texture must be attached. + * Detach a texture from a #FrameBuffer. The texture must be attached. * Changes will only take effect next time `GPU_framebuffer_bind()` is called. - * DEPRECATED: Prefer using multiple #GPUFrameBuffer with different configurations with + * DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with * `GPU_framebuffer_config_array()`. */ -void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, blender::gpu::Texture *texture); +void GPU_framebuffer_texture_detach(blender::gpu::FrameBuffer *fb, blender::gpu::Texture *texture); /** * Checks a framebuffer current configuration for errors. @@ -355,7 +355,7 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, blender::gpu::Texture *t * \a err_out is an error output buffer. * \return false if the framebuffer is invalid. */ -bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256]); +bool GPU_framebuffer_check_valid(blender::gpu::FrameBuffer *fb, char err_out[256]); /** \} */ @@ -371,7 +371,7 @@ bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256]); * Default size is used if the frame-buffer contains no attachments. * It needs to be re-specified each time an attachment is added. */ -void GPU_framebuffer_default_size(GPUFrameBuffer *fb, int width, int height); +void GPU_framebuffer_default_size(blender::gpu::FrameBuffer *fb, int width, int height); /** \} */ @@ -388,7 +388,8 @@ void GPU_framebuffer_default_size(GPUFrameBuffer *fb, int width, int height); * \note Setting a singular viewport will only change the state of the first viewport. * \note Must be called after first bind. */ -void GPU_framebuffer_viewport_set(GPUFrameBuffer *fb, int x, int y, int width, int height); +void GPU_framebuffer_viewport_set( + blender::gpu::FrameBuffer *fb, int x, int y, int width, int height); /** * Similar to `GPU_framebuffer_viewport_set()` but specify the bounds of all 16 viewports. @@ -398,20 +399,20 @@ void GPU_framebuffer_viewport_set(GPUFrameBuffer *fb, int x, int y, int width, i * \note Viewport and scissor size is stored per frame-buffer. * \note Must be called after first bind. */ -void GPU_framebuffer_multi_viewports_set(GPUFrameBuffer *gpu_fb, +void GPU_framebuffer_multi_viewports_set(blender::gpu::FrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4]); /** * Return the viewport offset and size in a int quadruple: (x, y, width, height). * \note Viewport and scissor size is stored per frame-buffer. */ -void GPU_framebuffer_viewport_get(GPUFrameBuffer *fb, int r_viewport[4]); +void GPU_framebuffer_viewport_get(blender::gpu::FrameBuffer *fb, int r_viewport[4]); /** * Reset a frame-buffer viewport bounds to its attachment(s) size. * \note Viewport and scissor size is stored per frame-buffer. */ -void GPU_framebuffer_viewport_reset(GPUFrameBuffer *fb); +void GPU_framebuffer_viewport_reset(blender::gpu::FrameBuffer *fb); /** \} */ @@ -431,7 +432,7 @@ void GPU_framebuffer_viewport_reset(GPUFrameBuffer *fb); * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear(GPUFrameBuffer *fb, +void GPU_framebuffer_clear(blender::gpu::FrameBuffer *fb, GPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, @@ -442,21 +443,21 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb, * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_color(GPUFrameBuffer *fb, const float clear_col[4]); +void GPU_framebuffer_clear_color(blender::gpu::FrameBuffer *fb, const float clear_col[4]); /** * Clear the depth attachment texture with the value \a clear_depth . * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_depth(GPUFrameBuffer *fb, float clear_depth); +void GPU_framebuffer_clear_depth(blender::gpu::FrameBuffer *fb, float clear_depth); /** * Clear the stencil attachment with the value \a clear_stencil . * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_stencil(GPUFrameBuffer *fb, uint clear_stencil); +void GPU_framebuffer_clear_stencil(blender::gpu::FrameBuffer *fb, uint clear_stencil); /** * Clear all color attachment textures with the value \a clear_col and the depth attachment texture @@ -464,7 +465,7 @@ void GPU_framebuffer_clear_stencil(GPUFrameBuffer *fb, uint clear_stencil); * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_color_depth(GPUFrameBuffer *fb, +void GPU_framebuffer_clear_color_depth(blender::gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth); @@ -474,7 +475,7 @@ void GPU_framebuffer_clear_color_depth(GPUFrameBuffer *fb, * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_depth_stencil(GPUFrameBuffer *fb, +void GPU_framebuffer_clear_depth_stencil(blender::gpu::FrameBuffer *fb, float clear_depth, uint clear_stencil); /** @@ -483,7 +484,7 @@ void GPU_framebuffer_clear_depth_stencil(GPUFrameBuffer *fb, * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_clear_color_depth_stencil(GPUFrameBuffer *fb, +void GPU_framebuffer_clear_color_depth_stencil(blender::gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth, uint clear_stencil); @@ -494,7 +495,7 @@ void GPU_framebuffer_clear_color_depth_stencil(GPUFrameBuffer *fb, * \note `GPU_write_mask`, and stencil test do not affect this command. * \note Viewport and scissor regions affect this command but are not efficient nor recommended. */ -void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_colors)[4]); +void GPU_framebuffer_multi_clear(blender::gpu::FrameBuffer *fb, const float (*clear_colors)[4]); /** * Clear all color attachment textures of the active frame-buffer with the given red, green, blue, @@ -519,7 +520,7 @@ void GPU_clear_depth(float depth); /** \name Debugging introspection API. * \{ */ -const char *GPU_framebuffer_get_name(GPUFrameBuffer *fb); +const char *GPU_framebuffer_get_name(blender::gpu::FrameBuffer *fb); /** \} */ @@ -535,8 +536,8 @@ const char *GPU_framebuffer_get_name(GPUFrameBuffer *fb); * Points to #BPyGPUFrameBuffer.fb */ #ifndef GPU_NO_USE_PY_REFERENCES -void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *fb); -void GPU_framebuffer_py_reference_set(GPUFrameBuffer *fb, void **py_ref); +void **GPU_framebuffer_py_reference_get(blender::gpu::FrameBuffer *fb); +void GPU_framebuffer_py_reference_set(blender::gpu::FrameBuffer *fb, void **py_ref); #endif /** @@ -546,8 +547,8 @@ void GPU_framebuffer_py_reference_set(GPUFrameBuffer *fb, void **py_ref); */ /* TODO(fclem): This has nothing to do with the GPU module and should be move to the pyGPU module. */ -void GPU_framebuffer_push(GPUFrameBuffer *fb); -GPUFrameBuffer *GPU_framebuffer_pop(); +void GPU_framebuffer_push(blender::gpu::FrameBuffer *fb); +blender::gpu::FrameBuffer *GPU_framebuffer_pop(); uint GPU_framebuffer_stack_level_get(); /** \} */ @@ -561,14 +562,14 @@ uint GPU_framebuffer_stack_level_get(); * \note return false if no context is active. * \note this is undefined behavior if \a framebuffer is `nullptr`. * DEPRECATED: Kept only because of Python GPU API. */ -bool GPU_framebuffer_bound(GPUFrameBuffer *fb); +bool GPU_framebuffer_bound(blender::gpu::FrameBuffer *fb); /** * Read a region of the framebuffer depth attachment and copy it to \a r_data . * The pixel data will be converted to \a data_format but it needs to be compatible with the * attachment type. DEPRECATED: Prefer using `GPU_texture_read()`. */ -void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, +void GPU_framebuffer_read_depth(blender::gpu::FrameBuffer *fb, int x, int y, int width, @@ -581,7 +582,7 @@ void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, * The pixel data will be converted to \a data_format but it needs to be compatible with the * attachment type. DEPRECATED: Prefer using `GPU_texture_read()`. */ -void GPU_framebuffer_read_color(GPUFrameBuffer *fb, +void GPU_framebuffer_read_color(blender::gpu::FrameBuffer *fb, int x, int y, int width, @@ -609,9 +610,9 @@ void GPU_frontbuffer_read_color( * The source and destination frame-buffers dimensions have to match. * DEPRECATED: Prefer using `GPU_texture_copy()`. */ -void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, +void GPU_framebuffer_blit(blender::gpu::FrameBuffer *fb_read, int read_slot, - GPUFrameBuffer *fb_write, + blender::gpu::FrameBuffer *fb_write, int write_slot, GPUFrameBufferBits blit_buffers); @@ -622,7 +623,7 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, * * A `GPUOffScreen` is a convenience type that holds a `GPUFramebuffer` and its associated * `blender::gpu::Texture`s. It is useful for quick drawing surface configuration. - * NOTE: They are still limited by the same single context limitation as #GPUFrameBuffer. + * NOTE: They are still limited by the same single context limitation as #FrameBuffer. * \{ */ struct GPUOffScreen; @@ -708,7 +709,7 @@ blender::gpu::TextureFormat GPU_offscreen_format(const GPUOffScreen *offscreen); * \note only to be used by viewport code! */ void GPU_offscreen_viewport_data_get(GPUOffScreen *offscreen, - GPUFrameBuffer **r_fb, + blender::gpu::FrameBuffer **r_fb, blender::gpu::Texture **r_color, blender::gpu::Texture **r_depth); diff --git a/source/blender/gpu/GPU_shader.hh b/source/blender/gpu/GPU_shader.hh index 627bb6dd53f..0fb41c04034 100644 --- a/source/blender/gpu/GPU_shader.hh +++ b/source/blender/gpu/GPU_shader.hh @@ -334,7 +334,7 @@ void GPU_shader_batch_specializations_cancel(SpecializationBatchHandle &handle); * prime compilations. * * Shaders do not necessarily have to be similar in functionality to be used as a parent, so long - * as the #GPUVertFormt and #GPUFrameBuffer which they are used with remain the same. + * as the #GPUVertFormat and #gpu::FrameBuffer which they are used with remain the same. * Other bindings such as textures, uniforms and UBOs are all assigned independently as dynamic * state. * diff --git a/source/blender/gpu/GPU_viewport.hh b/source/blender/gpu/GPU_viewport.hh index 0e18db6fbc4..9df5e1a1141 100644 --- a/source/blender/gpu/GPU_viewport.hh +++ b/source/blender/gpu/GPU_viewport.hh @@ -18,8 +18,10 @@ struct DRWData; struct GPUViewport; -struct GPUFrameBuffer; struct GPUOffScreen; +namespace blender::gpu { +class FrameBuffer; +} // namespace blender::gpu GPUViewport *GPU_viewport_create(); GPUViewport *GPU_viewport_stereo_create(); @@ -86,5 +88,5 @@ blender::gpu::Texture *GPU_viewport_depth_texture(GPUViewport *viewport); /** * Color render and overlay frame-buffers for drawing outside of DRW module. */ -GPUFrameBuffer *GPU_viewport_framebuffer_render_get(GPUViewport *viewport); -GPUFrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport); +blender::gpu::FrameBuffer *GPU_viewport_framebuffer_render_get(GPUViewport *viewport); +blender::gpu::FrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport); diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index bf2b703cf1e..c8d8ce709f7 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -217,58 +217,58 @@ uint FrameBuffer::get_bits_per_pixel() using namespace blender; using namespace blender::gpu; -GPUFrameBuffer *GPU_framebuffer_create(const char *name) +gpu::FrameBuffer *GPU_framebuffer_create(const char *name) { /* We generate the FB object later at first use in order to * create the frame-buffer in the right opengl context. */ - return wrap(GPUBackend::get()->framebuffer_alloc(name)); + return GPUBackend::get()->framebuffer_alloc(name); } -void GPU_framebuffer_free(GPUFrameBuffer *fb) +void GPU_framebuffer_free(gpu::FrameBuffer *fb) { - delete unwrap(fb); + delete fb; } -const char *GPU_framebuffer_get_name(GPUFrameBuffer *fb) +const char *GPU_framebuffer_get_name(gpu::FrameBuffer *fb) { - return unwrap(fb)->name_get(); + return fb->name_get(); } /* ---------- Binding ----------- */ -void GPU_framebuffer_bind(GPUFrameBuffer *fb) +void GPU_framebuffer_bind(gpu::FrameBuffer *fb) { const bool enable_srgb = true; /* Disable custom loadstore and bind. */ - unwrap(fb)->set_use_explicit_loadstore(false); - unwrap(fb)->bind(enable_srgb); + fb->set_use_explicit_loadstore(false); + fb->bind(enable_srgb); } -void GPU_framebuffer_bind_loadstore(GPUFrameBuffer *fb, +void GPU_framebuffer_bind_loadstore(gpu::FrameBuffer *fb, const GPULoadStore *load_store_actions, uint actions_len) { const bool enable_srgb = true; /* Bind with explicit loadstore state */ - unwrap(fb)->set_use_explicit_loadstore(true); - unwrap(fb)->bind(enable_srgb); + fb->set_use_explicit_loadstore(true); + fb->bind(enable_srgb); /* Update load store */ - unwrap(fb)->load_store_config_array(load_store_actions, actions_len); + fb->load_store_config_array(load_store_actions, actions_len); } -void GPU_framebuffer_subpass_transition_array(GPUFrameBuffer *fb, +void GPU_framebuffer_subpass_transition_array(gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len) { - unwrap(fb)->subpass_transition( - attachment_states[0], Span(attachment_states + 1, attachment_len - 1)); + fb->subpass_transition(attachment_states[0], + Span(attachment_states + 1, attachment_len - 1)); } -void GPU_framebuffer_bind_no_srgb(GPUFrameBuffer *fb) +void GPU_framebuffer_bind_no_srgb(gpu::FrameBuffer *fb) { const bool enable_srgb = false; - unwrap(fb)->bind(enable_srgb); + fb->bind(enable_srgb); } void GPU_backbuffer_bind(GPUBackBuffer back_buffer_type) @@ -288,40 +288,40 @@ void GPU_framebuffer_restore() Context::get()->back_left->bind(false); } -GPUFrameBuffer *GPU_framebuffer_active_get() +gpu::FrameBuffer *GPU_framebuffer_active_get() { Context *ctx = Context::get(); - return wrap(ctx ? ctx->active_fb : nullptr); + return ctx ? ctx->active_fb : nullptr; } -GPUFrameBuffer *GPU_framebuffer_back_get() +gpu::FrameBuffer *GPU_framebuffer_back_get() { Context *ctx = Context::get(); - return wrap(ctx ? ctx->back_left : nullptr); + return ctx ? ctx->back_left : nullptr; } -bool GPU_framebuffer_bound(GPUFrameBuffer *gpu_fb) +bool GPU_framebuffer_bound(gpu::FrameBuffer *gpu_fb) { return (gpu_fb == GPU_framebuffer_active_get()); } /* ---------- Attachment Management ----------- */ -bool GPU_framebuffer_check_valid(GPUFrameBuffer *gpu_fb, char err_out[256]) +bool GPU_framebuffer_check_valid(gpu::FrameBuffer *gpu_fb, char err_out[256]) { - return unwrap(gpu_fb)->check(err_out); + return gpu_fb->check(err_out); } -static void gpu_framebuffer_texture_attach_ex(GPUFrameBuffer *gpu_fb, +static void gpu_framebuffer_texture_attach_ex(gpu::FrameBuffer *gpu_fb, GPUAttachment attachment, int slot) { Texture *tex = reinterpret_cast(attachment.tex); GPUAttachmentType type = tex->attachment_type(slot); - unwrap(gpu_fb)->attachment_set(type, attachment); + gpu_fb->attachment_set(type, attachment); } -void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, +void GPU_framebuffer_texture_attach(gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int mip) @@ -331,30 +331,28 @@ void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, } void GPU_framebuffer_texture_layer_attach( - GPUFrameBuffer *fb, blender::gpu::Texture *tex, int slot, int layer, int mip) + gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int layer, int mip) { GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_LAYER_MIP(tex, layer, mip); gpu_framebuffer_texture_attach_ex(fb, attachment, slot); } void GPU_framebuffer_texture_cubeface_attach( - GPUFrameBuffer *fb, blender::gpu::Texture *tex, int slot, int face, int mip) + gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int face, int mip) { GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP(tex, face, mip); gpu_framebuffer_texture_attach_ex(fb, attachment, slot); } -void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, blender::gpu::Texture *tex) +void GPU_framebuffer_texture_detach(gpu::FrameBuffer *fb, blender::gpu::Texture *tex) { - tex->detach_from(unwrap(fb)); + tex->detach_from(fb); } -void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb, +void GPU_framebuffer_config_array(gpu::FrameBuffer *fb, const GPUAttachment *config, int config_len) { - FrameBuffer *fb = unwrap(gpu_fb); - const GPUAttachment &depth_attachment = config[0]; Span color_attachments(config + 1, config_len - 1); @@ -380,77 +378,79 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb, } } -void GPU_framebuffer_default_size(GPUFrameBuffer *gpu_fb, int width, int height) +void GPU_framebuffer_default_size(gpu::FrameBuffer *gpu_fb, int width, int height) { - unwrap(gpu_fb)->default_size_set(width, height); + gpu_fb->default_size_set(width, height); } /* ---------- Viewport & Scissor Region ----------- */ -void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int width, int height) +void GPU_framebuffer_viewport_set(gpu::FrameBuffer *gpu_fb, int x, int y, int width, int height) { int viewport_rect[4] = {x, y, width, height}; - unwrap(gpu_fb)->viewport_set(viewport_rect); + gpu_fb->viewport_set(viewport_rect); } -void GPU_framebuffer_multi_viewports_set(GPUFrameBuffer *gpu_fb, +void GPU_framebuffer_multi_viewports_set(gpu::FrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4]) { - unwrap(gpu_fb)->viewport_multi_set(viewport_rects); + gpu_fb->viewport_multi_set(viewport_rects); } -void GPU_framebuffer_viewport_get(GPUFrameBuffer *gpu_fb, int r_viewport[4]) +void GPU_framebuffer_viewport_get(gpu::FrameBuffer *gpu_fb, int r_viewport[4]) { - unwrap(gpu_fb)->viewport_get(r_viewport); + gpu_fb->viewport_get(r_viewport); } -void GPU_framebuffer_viewport_reset(GPUFrameBuffer *gpu_fb) +void GPU_framebuffer_viewport_reset(gpu::FrameBuffer *gpu_fb) { - unwrap(gpu_fb)->viewport_reset(); + gpu_fb->viewport_reset(); } /* ---------- Frame-buffer Operations ----------- */ -void GPU_framebuffer_clear(GPUFrameBuffer *gpu_fb, +void GPU_framebuffer_clear(gpu::FrameBuffer *gpu_fb, GPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, uint clear_stencil) { - BLI_assert_msg(unwrap(gpu_fb)->get_use_explicit_loadstore() == false, + BLI_assert_msg(gpu_fb->get_use_explicit_loadstore() == false, "Using GPU_framebuffer_clear_* functions in conjunction with custom load-store " "state via GPU_framebuffer_bind_ex is invalid."); - unwrap(gpu_fb)->clear(buffers, clear_col, clear_depth, clear_stencil); + gpu_fb->clear(buffers, clear_col, clear_depth, clear_stencil); } -void GPU_framebuffer_clear_color(GPUFrameBuffer *fb, const float clear_col[4]) +void GPU_framebuffer_clear_color(gpu::FrameBuffer *fb, const float clear_col[4]) { GPU_framebuffer_clear(fb, GPU_COLOR_BIT, clear_col, 0.0f, 0x00); } -void GPU_framebuffer_clear_depth(GPUFrameBuffer *fb, float clear_depth) +void GPU_framebuffer_clear_depth(gpu::FrameBuffer *fb, float clear_depth) { GPU_framebuffer_clear(fb, GPU_DEPTH_BIT, nullptr, clear_depth, 0x00); } -void GPU_framebuffer_clear_color_depth(GPUFrameBuffer *fb, +void GPU_framebuffer_clear_color_depth(gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth) { GPU_framebuffer_clear(fb, GPU_COLOR_BIT | GPU_DEPTH_BIT, clear_col, clear_depth, 0x00); } -void GPU_framebuffer_clear_stencil(GPUFrameBuffer *fb, uint clear_stencil) +void GPU_framebuffer_clear_stencil(gpu::FrameBuffer *fb, uint clear_stencil) { GPU_framebuffer_clear(fb, GPU_STENCIL_BIT, nullptr, 0.0f, clear_stencil); } -void GPU_framebuffer_clear_depth_stencil(GPUFrameBuffer *fb, float clear_depth, uint clear_stencil) +void GPU_framebuffer_clear_depth_stencil(gpu::FrameBuffer *fb, + float clear_depth, + uint clear_stencil) { GPU_framebuffer_clear(fb, GPU_DEPTH_BIT | GPU_STENCIL_BIT, nullptr, clear_depth, clear_stencil); } -void GPU_framebuffer_clear_color_depth_stencil(GPUFrameBuffer *fb, +void GPU_framebuffer_clear_color_depth_stencil(gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth, uint clear_stencil) @@ -459,12 +459,12 @@ void GPU_framebuffer_clear_color_depth_stencil(GPUFrameBuffer *fb, fb, GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT, clear_col, clear_depth, clear_stencil); } -void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_colors)[4]) +void GPU_framebuffer_multi_clear(gpu::FrameBuffer *fb, const float (*clear_colors)[4]) { - BLI_assert_msg(unwrap(fb)->get_use_explicit_loadstore() == false, + BLI_assert_msg(fb->get_use_explicit_loadstore() == false, "Using GPU_framebuffer_clear_* functions in conjunction with custom load-store " "state via GPU_framebuffer_bind_ex is invalid."); - unwrap(fb)->clear_multi(clear_colors); + fb->clear_multi(clear_colors); } void GPU_clear_color(float red, float green, float blue, float alpha) @@ -486,13 +486,13 @@ void GPU_clear_depth(float depth) } void GPU_framebuffer_read_depth( - GPUFrameBuffer *fb, int x, int y, int w, int h, eGPUDataFormat format, void *data) + gpu::FrameBuffer *fb, int x, int y, int w, int h, eGPUDataFormat format, void *data) { int rect[4] = {x, y, w, h}; - unwrap(fb)->read(GPU_DEPTH_BIT, format, rect, 1, 1, data); + fb->read(GPU_DEPTH_BIT, format, rect, 1, 1, data); } -void GPU_framebuffer_read_color(GPUFrameBuffer *fb, +void GPU_framebuffer_read_color(gpu::FrameBuffer *fb, int x, int y, int w, @@ -503,7 +503,7 @@ void GPU_framebuffer_read_color(GPUFrameBuffer *fb, void *data) { int rect[4] = {x, y, w, h}; - unwrap(fb)->read(GPU_COLOR_BIT, format, rect, channels, slot, data); + fb->read(GPU_COLOR_BIT, format, rect, channels, slot, data); } void GPU_frontbuffer_read_color( @@ -514,14 +514,12 @@ void GPU_frontbuffer_read_color( } /* TODO(fclem): port as texture operation. */ -void GPU_framebuffer_blit(GPUFrameBuffer *gpu_fb_read, +void GPU_framebuffer_blit(gpu::FrameBuffer *fb_read, int read_slot, - GPUFrameBuffer *gpu_fb_write, + gpu::FrameBuffer *fb_write, int write_slot, GPUFrameBufferBits blit_buffers) { - FrameBuffer *fb_read = unwrap(gpu_fb_read); - FrameBuffer *fb_write = unwrap(gpu_fb_write); BLI_assert(blit_buffers != 0); FrameBuffer *prev_fb = Context::get()->active_fb; @@ -555,15 +553,15 @@ void GPU_framebuffer_blit(GPUFrameBuffer *gpu_fb_read, } #ifndef GPU_NO_USE_PY_REFERENCES -void **GPU_framebuffer_py_reference_get(GPUFrameBuffer *fb) +void **GPU_framebuffer_py_reference_get(gpu::FrameBuffer *fb) { - return unwrap(fb)->py_ref; + return fb->py_ref; } -void GPU_framebuffer_py_reference_set(GPUFrameBuffer *fb, void **py_ref) +void GPU_framebuffer_py_reference_set(gpu::FrameBuffer *fb, void **py_ref) { - BLI_assert(py_ref == nullptr || unwrap(fb)->py_ref == nullptr); - unwrap(fb)->py_ref = py_ref; + BLI_assert(py_ref == nullptr || fb->py_ref == nullptr); + fb->py_ref = py_ref; } #endif @@ -578,18 +576,18 @@ void GPU_framebuffer_py_reference_set(GPUFrameBuffer *fb, void **py_ref) #define FRAMEBUFFER_STACK_DEPTH 16 static struct { - GPUFrameBuffer *framebuffers[FRAMEBUFFER_STACK_DEPTH]; + gpu::FrameBuffer *framebuffers[FRAMEBUFFER_STACK_DEPTH]; uint top; } FrameBufferStack = {{nullptr}}; -void GPU_framebuffer_push(GPUFrameBuffer *fb) +void GPU_framebuffer_push(gpu::FrameBuffer *fb) { BLI_assert(FrameBufferStack.top < FRAMEBUFFER_STACK_DEPTH); FrameBufferStack.framebuffers[FrameBufferStack.top] = fb; FrameBufferStack.top++; } -GPUFrameBuffer *GPU_framebuffer_pop() +gpu::FrameBuffer *GPU_framebuffer_pop() { BLI_assert(FrameBufferStack.top > 0); FrameBufferStack.top--; @@ -617,7 +615,7 @@ struct GPUOffScreen { struct { Context *ctx; - GPUFrameBuffer *fb; + gpu::FrameBuffer *fb; } framebuffers[MAX_CTX_FB_LEN]; blender::gpu::Texture *color; @@ -627,7 +625,7 @@ struct GPUOffScreen { /** * Returns the correct frame-buffer for the current context. */ -static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) +static gpu::FrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) { Context *ctx = Context::get(); BLI_assert(ctx); @@ -709,7 +707,7 @@ GPUOffScreen *GPU_offscreen_create(int width, return nullptr; } - GPUFrameBuffer *fb = gpu_offscreen_fb_get(ofs); + gpu::FrameBuffer *fb = gpu_offscreen_fb_get(ofs); /* check validity at the very end! */ if (!GPU_framebuffer_check_valid(fb, err_out)) { @@ -753,15 +751,15 @@ void GPU_offscreen_free(GPUOffScreen *offscreen) void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save) { if (save) { - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_push(fb); } - unwrap(gpu_offscreen_fb_get(offscreen))->bind(false); + gpu_offscreen_fb_get(offscreen)->bind(false); } void GPU_offscreen_unbind(GPUOffScreen * /*offscreen*/, bool restore) { - GPUFrameBuffer *fb = nullptr; + gpu::FrameBuffer *fb = nullptr; if (restore) { fb = GPU_framebuffer_pop(); } @@ -777,7 +775,7 @@ void GPU_offscreen_unbind(GPUOffScreen * /*offscreen*/, bool restore) void GPU_offscreen_draw_to_screen(GPUOffScreen *offscreen, int x, int y) { Context *ctx = Context::get(); - FrameBuffer *ofs_fb = unwrap(gpu_offscreen_fb_get(offscreen)); + FrameBuffer *ofs_fb = gpu_offscreen_fb_get(offscreen); ofs_fb->blit_to(GPU_COLOR_BIT, 0, ctx->active_fb, 0, x, y); } @@ -789,7 +787,7 @@ void GPU_offscreen_read_color_region( BLI_assert(x + w <= GPU_texture_width(offscreen->color)); BLI_assert(y + h <= GPU_texture_height(offscreen->color)); - GPUFrameBuffer *ofs_fb = gpu_offscreen_fb_get(offscreen); + gpu::FrameBuffer *ofs_fb = gpu_offscreen_fb_get(offscreen); GPU_framebuffer_read_color(ofs_fb, x, y, w, h, 4, 0, format, r_data); } @@ -824,7 +822,7 @@ blender::gpu::TextureFormat GPU_offscreen_format(const GPUOffScreen *offscreen) } void GPU_offscreen_viewport_data_get(GPUOffScreen *offscreen, - GPUFrameBuffer **r_fb, + gpu::FrameBuffer **r_fb, blender::gpu::Texture **r_color, blender::gpu::Texture **r_depth) { diff --git a/source/blender/gpu/intern/gpu_framebuffer_private.hh b/source/blender/gpu/intern/gpu_framebuffer_private.hh index b163a05a087..388779e526d 100644 --- a/source/blender/gpu/intern/gpu_framebuffer_private.hh +++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh @@ -269,20 +269,6 @@ class FrameBuffer { } }; -/* Syntactic sugar. */ -static inline GPUFrameBuffer *wrap(FrameBuffer *framebuffer) -{ - return reinterpret_cast(framebuffer); -} -static inline FrameBuffer *unwrap(GPUFrameBuffer *framebuffer) -{ - return reinterpret_cast(framebuffer); -} -static inline const FrameBuffer *unwrap(const GPUFrameBuffer *framebuffer) -{ - return reinterpret_cast(framebuffer); -} - #undef DEBUG_NAME_LEN } // namespace blender::gpu diff --git a/source/blender/gpu/intern/gpu_select_pick.cc b/source/blender/gpu/intern/gpu_select_pick.cc index 421fe5448a0..c3fff9b2ea4 100644 --- a/source/blender/gpu/intern/gpu_select_pick.cc +++ b/source/blender/gpu/intern/gpu_select_pick.cc @@ -486,7 +486,7 @@ bool gpu_select_pick_load_id(uint id, bool end) } const uint rect_len = ps->src.rect_len; - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_read_depth( fb, UNPACK4(ps->gpu.clip_readpixels), GPU_DATA_UINT, ps->gpu.rect_depth_test->buf); /* Perform initial check since most cases the array remains unchanged. */ diff --git a/source/blender/gpu/intern/gpu_viewport.cc b/source/blender/gpu/intern/gpu_viewport.cc index dd4a6a7be13..f24928ca0e7 100644 --- a/source/blender/gpu/intern/gpu_viewport.cc +++ b/source/blender/gpu/intern/gpu_viewport.cc @@ -66,14 +66,14 @@ struct GPUViewport { /** Depth buffer. Can be shared with GPUOffscreen. */ blender::gpu::Texture *depth_tx; /** Compositing framebuffer for stereo viewport. */ - GPUFrameBuffer *stereo_comp_fb; + blender::gpu::FrameBuffer *stereo_comp_fb; /** Color render and overlay frame-buffers for drawing outside of DRW module. * The render framebuffer is expected to be in the linear space and viewport will perform color * management on it to bring it to the display space. * The overlay frame-buffer is expected to be in the display space and viewport does not do any * color management on it. */ - GPUFrameBuffer *render_fb; - GPUFrameBuffer *overlay_fb; + blender::gpu::FrameBuffer *render_fb; + blender::gpu::FrameBuffer *overlay_fb; /* Color management. */ ColorManagedViewSettings view_settings; @@ -229,7 +229,7 @@ void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect) void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool is_xr_surface) { blender::gpu::Texture *color, *depth; - GPUFrameBuffer *fb; + blender::gpu::FrameBuffer *fb; viewport->size[0] = GPU_offscreen_width(ofs); viewport->size[1] = GPU_offscreen_height(ofs); @@ -611,7 +611,7 @@ blender::gpu::Texture *GPU_viewport_depth_texture(GPUViewport *viewport) return viewport->depth_tx; } -GPUFrameBuffer *GPU_viewport_framebuffer_render_get(GPUViewport *viewport) +blender::gpu::FrameBuffer *GPU_viewport_framebuffer_render_get(GPUViewport *viewport) { GPU_framebuffer_ensure_config( &viewport->render_fb, @@ -622,7 +622,7 @@ GPUFrameBuffer *GPU_viewport_framebuffer_render_get(GPUViewport *viewport) return viewport->render_fb; } -GPUFrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport) +blender::gpu::FrameBuffer *GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport) { GPU_framebuffer_ensure_config( &viewport->overlay_fb, diff --git a/source/blender/gpu/metal/mtl_texture.hh b/source/blender/gpu/metal/mtl_texture.hh index a2e8745f00b..a75e328beae 100644 --- a/source/blender/gpu/metal/mtl_texture.hh +++ b/source/blender/gpu/metal/mtl_texture.hh @@ -27,7 +27,9 @@ @class MTLCommandQueue; @class MTLRenderPipelineState; -struct GPUFrameBuffer; +namespace blender::gpu { +class FrameBuffer; +} // namespace blender::gpu /* Texture Update system structs. */ struct TextureUpdateRoutineSpecialisation { @@ -210,7 +212,7 @@ class MTLTexture : public Texture { int tex_buffer_metadata_[4]; /* Blit Frame-buffer. */ - GPUFrameBuffer *blit_fb_ = nullptr; + gpu::FrameBuffer *blit_fb_ = nullptr; uint blit_fb_slice_ = 0; uint blit_fb_mip_ = 0; @@ -387,7 +389,7 @@ class MTLTexture : public Texture { uint dst_slice, int width, int height); - GPUFrameBuffer *get_blit_framebuffer(int dst_slice, uint dst_mip); + gpu::FrameBuffer *get_blit_framebuffer(int dst_slice, uint dst_mip); /* Texture Update function Utilities. */ /* Metal texture updating does not provide the same range of functionality for type conversion * and format compatibility as are available in OpenGL. To achieve the same level of diff --git a/source/blender/gpu/metal/mtl_texture.mm b/source/blender/gpu/metal/mtl_texture.mm index 16cef43704b..3c002f11058 100644 --- a/source/blender/gpu/metal/mtl_texture.mm +++ b/source/blender/gpu/metal/mtl_texture.mm @@ -379,8 +379,8 @@ void gpu::MTLTexture::blit(gpu::MTLTexture *dst, BLI_assert(MTLContext::get()); /* Fetch restore framebuffer and blit target framebuffer from destination texture. */ - GPUFrameBuffer *restore_fb = GPU_framebuffer_active_get(); - GPUFrameBuffer *blit_target_fb = dst->get_blit_framebuffer(dst_slice, dst_mip); + gpu::FrameBuffer *restore_fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *blit_target_fb = dst->get_blit_framebuffer(dst_slice, dst_mip); BLI_assert(blit_target_fb); GPU_framebuffer_bind(blit_target_fb); @@ -436,7 +436,7 @@ void gpu::MTLTexture::blit(gpu::MTLTexture *dst, } } -GPUFrameBuffer *gpu::MTLTexture::get_blit_framebuffer(int dst_slice, uint dst_mip) +gpu::FrameBuffer *gpu::MTLTexture::get_blit_framebuffer(int dst_slice, uint dst_mip) { /* Check if layer has changed. */ @@ -1376,8 +1376,8 @@ void gpu::MTLTexture::clear(eGPUDataFormat data_format, const void *data) if (do_render_pass_clear) { /* Create clear frame-buffer for fast clear. */ - GPUFrameBuffer *prev_fb = GPU_framebuffer_active_get(); - FrameBuffer *fb = unwrap(this->get_blit_framebuffer(-1, 0)); + gpu::FrameBuffer *prev_fb = GPU_framebuffer_active_get(); + FrameBuffer *fb = this->get_blit_framebuffer(-1, 0); fb->bind(true); fb->clear_attachment(this->attachment_type(0), data_format, data); GPU_framebuffer_bind(prev_fb); diff --git a/source/blender/gpu/metal/mtl_texture_util.mm b/source/blender/gpu/metal/mtl_texture_util.mm index 126d1a2228c..f50b8abfd40 100644 --- a/source/blender/gpu/metal/mtl_texture_util.mm +++ b/source/blender/gpu/metal/mtl_texture_util.mm @@ -486,8 +486,8 @@ void gpu::MTLTexture::update_sub_depth_2d( gpu::MTLTexture *mtl_tex = static_cast(r32_tex_tmp); mtl_tex->update_sub(mip, offset, extent, type, data); - GPUFrameBuffer *restore_fb = GPU_framebuffer_active_get(); - GPUFrameBuffer *depth_fb_temp = GPU_framebuffer_create("depth_intermediate_copy_fb"); + gpu::FrameBuffer *restore_fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *depth_fb_temp = GPU_framebuffer_create("depth_intermediate_copy_fb"); GPU_framebuffer_texture_attach(depth_fb_temp, this, 0, mip); GPU_framebuffer_bind(depth_fb_temp); if (extent[0] == w_ && extent[1] == h_) { diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh index 7e337108d2e..89dc1aa49cc 100644 --- a/source/blender/gpu/opengl/gl_context.hh +++ b/source/blender/gpu/opengl/gl_context.hh @@ -79,7 +79,7 @@ class GLContext : public Context { * context is destroyed, we need to remove any reference to it. */ Set vao_caches_; - Set framebuffers_; + Set framebuffers_; /** Mutex for the below structures. */ std::mutex lists_mutex_; /** VertexArrays and framebuffers are not shared across context. */ diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index a3dec02b3e5..e1e976b4645 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -127,7 +127,7 @@ bool GLFrameBuffer::check(char err_out[256]) #undef FORMAT_STATUS - const char *format = "GPUFrameBuffer: %s status %s\n"; + const char *format = "gpu::FrameBuffer: %s status %s\n"; if (err_out) { BLI_snprintf(err_out, 256, format, this->name_, err); diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc index cbe67b00e1f..b8087902fa1 100644 --- a/source/blender/gpu/opengl/gl_texture.cc +++ b/source/blender/gpu/opengl/gl_texture.cc @@ -40,7 +40,7 @@ GLTexture::GLTexture(const char *name) : Texture(name) GLTexture::~GLTexture() { if (framebuffer_) { - GPU_framebuffer_free(wrap(framebuffer_)); + GPU_framebuffer_free(framebuffer_); } GLContext *ctx = GLContext::get(); if (ctx != nullptr && is_bound_) { @@ -331,7 +331,7 @@ void GLTexture::clear(eGPUDataFormat data_format, const void *data) * "pixel data" to exist which is then uploaded CPU -> GPU at bind * time. */ - GPUFrameBuffer *prev_fb = GPU_framebuffer_active_get(); + gpu::FrameBuffer *prev_fb = GPU_framebuffer_active_get(); FrameBuffer *fb = this->framebuffer_get(); fb->bind(true); @@ -456,7 +456,7 @@ FrameBuffer *GLTexture::framebuffer_get() return framebuffer_; } BLI_assert(!(type_ & GPU_TEXTURE_1D)); - framebuffer_ = unwrap(GPU_framebuffer_create(name_)); + framebuffer_ = GPU_framebuffer_create(name_); framebuffer_->attachment_set(this->attachment_type(0), GPU_ATTACHMENT_TEXTURE(this)); has_pixels_ = true; return framebuffer_; diff --git a/source/blender/gpu/tests/framebuffer_test.cc b/source/blender/gpu/tests/framebuffer_test.cc index f1a0e172cf5..d83c25da31d 100644 --- a/source/blender/gpu/tests/framebuffer_test.cc +++ b/source/blender/gpu/tests/framebuffer_test.cc @@ -27,7 +27,7 @@ static void test_framebuffer_clear_color_single_attachment() blender::gpu::Texture *texture = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::SFLOAT_32_32_32_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config(&framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture)}); GPU_framebuffer_bind(framebuffer); @@ -56,7 +56,7 @@ static void test_framebuffer_clear_color_multiple_attachments() blender::gpu::Texture *texture2 = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::UINT_32_32_32_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config( &framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture1), GPU_ATTACHMENT_TEXTURE(texture2)}); @@ -97,7 +97,7 @@ static void test_framebuffer_clear_multiple_color_multiple_attachments() blender::gpu::Texture *texture2 = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::SFLOAT_32_32_32_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config( &framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture1), GPU_ATTACHMENT_TEXTURE(texture2)}); @@ -133,7 +133,7 @@ static void test_framebuffer_clear_depth() blender::gpu::Texture *texture = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::SFLOAT_32_DEPTH, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config(&framebuffer, {GPU_ATTACHMENT_TEXTURE(texture)}); GPU_framebuffer_bind(framebuffer); @@ -161,7 +161,7 @@ static void test_framebuffer_scissor_test() blender::gpu::Texture *texture = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::SFLOAT_32_32_32_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config(&framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture)}); GPU_framebuffer_bind(framebuffer); @@ -212,7 +212,7 @@ static void test_framebuffer_cube() {0.0f, 0.0f, 0.5f, 1.0f}, {0.0f, 0.0f, 1.0f, 1.0f}, }; - GPUFrameBuffer *framebuffers[6] = {nullptr}; + gpu::FrameBuffer *framebuffers[6] = {nullptr}; for (int i : IndexRange(6)) { GPU_framebuffer_ensure_config(&framebuffers[i], @@ -263,7 +263,7 @@ static void test_framebuffer_multi_viewport() blender::gpu::Texture *texture = GPU_texture_create_2d_array( __func__, UNPACK2(size), layers, 1, TextureFormat::SINT_32_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config(&framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture)}); GPU_framebuffer_bind(framebuffer); @@ -338,7 +338,7 @@ static void test_framebuffer_subpass_input() blender::gpu::Texture *texture_b = GPU_texture_create_2d( __func__, UNPACK2(size), 1, TextureFormat::SINT_32, usage, nullptr); - GPUFrameBuffer *framebuffer = GPU_framebuffer_create(__func__); + gpu::FrameBuffer *framebuffer = GPU_framebuffer_create(__func__); GPU_framebuffer_ensure_config( &framebuffer, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(texture_a), GPU_ATTACHMENT_TEXTURE(texture_b)}); diff --git a/source/blender/gpu/tests/shader_test.cc b/source/blender/gpu/tests/shader_test.cc index bc2784ab92d..6c5fe5acf4b 100644 --- a/source/blender/gpu/tests/shader_test.cc +++ b/source/blender/gpu/tests/shader_test.cc @@ -371,7 +371,7 @@ static void gpu_shader_lib_test(const char *test_src_name, const char *additiona eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ; blender::gpu::Texture *tex = GPU_texture_create_2d( "tx", test_output_px_len, test_count, 1, TextureFormat::UINT_32_32_32_32, usage, nullptr); - GPUFrameBuffer *fb = GPU_framebuffer_create("test_fb"); + gpu::FrameBuffer *fb = GPU_framebuffer_create("test_fb"); GPU_framebuffer_ensure_config(&fb, {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(tex)}); GPU_framebuffer_bind(fb); diff --git a/source/blender/gpu/tests/specialization_constants_test.cc b/source/blender/gpu/tests/specialization_constants_test.cc index ebf9e3e4c99..d94834e6143 100644 --- a/source/blender/gpu/tests/specialization_constants_test.cc +++ b/source/blender/gpu/tests/specialization_constants_test.cc @@ -93,7 +93,7 @@ struct ShaderSpecializationConst { void validate(shader::SpecializationConstants &constants) { if (is_graphic) { - GPUFrameBuffer *fb = GPU_framebuffer_create("test_fb"); + gpu::FrameBuffer *fb = GPU_framebuffer_create("test_fb"); GPU_framebuffer_default_size(fb, 1, 1); GPU_framebuffer_bind(fb); diff --git a/source/blender/gpu/vulkan/vk_framebuffer.hh b/source/blender/gpu/vulkan/vk_framebuffer.hh index 1874eeffd42..00903899653 100644 --- a/source/blender/gpu/vulkan/vk_framebuffer.hh +++ b/source/blender/gpu/vulkan/vk_framebuffer.hh @@ -147,7 +147,7 @@ class VKFrameBuffer : public FrameBuffer { void clear(render_graph::VKClearAttachmentsNode::CreateInfo &clear_attachments); }; -static inline VKFrameBuffer *unwrap(FrameBuffer *framebuffer) +static inline VKFrameBuffer *unwrap(gpu::FrameBuffer *framebuffer) { return static_cast(framebuffer); } diff --git a/source/blender/python/gpu/gpu_py_framebuffer.cc b/source/blender/python/gpu/gpu_py_framebuffer.cc index 8ca999471a4..62020d777f8 100644 --- a/source/blender/python/gpu/gpu_py_framebuffer.cc +++ b/source/blender/python/gpu/gpu_py_framebuffer.cc @@ -30,7 +30,7 @@ #include "gpu_py_texture.hh" /* -------------------------------------------------------------------- */ -/** \name GPUFrameBuffer Common Utilities +/** \name gpu::FrameBuffer Common Utilities * \{ */ static int pygpu_framebuffer_valid_check(BPyGPUFrameBuffer *bpygpu_fb) @@ -50,7 +50,7 @@ static int pygpu_framebuffer_valid_check(BPyGPUFrameBuffer *bpygpu_fb) } \ ((void)0) -static void pygpu_framebuffer_free_if_possible(GPUFrameBuffer *fb) +static void pygpu_framebuffer_free_if_possible(blender::gpu::FrameBuffer *fb) { if (GPU_is_init()) { GPU_framebuffer_free(fb); @@ -78,7 +78,7 @@ static void pygpu_framebuffer_free_safe(BPyGPUFrameBuffer *self) /* Keep less than or equal to #FRAMEBUFFER_STACK_DEPTH */ #define GPU_PY_FRAMEBUFFER_STACK_LEN 16 -static bool pygpu_framebuffer_stack_push_and_bind_or_error(GPUFrameBuffer *fb) +static bool pygpu_framebuffer_stack_push_and_bind_or_error(blender::gpu::FrameBuffer *fb) { if (GPU_framebuffer_stack_level_get() >= GPU_PY_FRAMEBUFFER_STACK_LEN) { PyErr_SetString( @@ -91,7 +91,7 @@ static bool pygpu_framebuffer_stack_push_and_bind_or_error(GPUFrameBuffer *fb) return true; } -static bool pygpu_framebuffer_stack_pop_and_restore_or_error(GPUFrameBuffer *fb) +static bool pygpu_framebuffer_stack_pop_and_restore_or_error(blender::gpu::FrameBuffer *fb) { if (GPU_framebuffer_stack_level_get() == 0) { PyErr_SetString(PyExc_RuntimeError, "Minimum framebuffer stack depth reached"); @@ -103,7 +103,7 @@ static bool pygpu_framebuffer_stack_pop_and_restore_or_error(GPUFrameBuffer *fb) return false; } - GPUFrameBuffer *fb_prev = GPU_framebuffer_pop(); + blender::gpu::FrameBuffer *fb_prev = GPU_framebuffer_pop(); GPU_framebuffer_bind(fb_prev); return true; } @@ -347,7 +347,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject * /*self*/, PyObject *ar "|$" /* Optional keyword only arguments. */ "O" /* `depth_slot` */ "O" /* `color_slots` */ - ":GPUFrameBuffer.__new__", + ":gpu::FrameBuffer.__new__", _keywords, nullptr, }; @@ -398,7 +398,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject * /*self*/, PyObject *ar } } - GPUFrameBuffer *fb_python = GPU_framebuffer_create("fb_python"); + blender::gpu::FrameBuffer *fb_python = GPU_framebuffer_create("fb_python"); GPU_framebuffer_config_array(fb_python, config, color_attachements_len + 1); return BPyGPUFrameBuffer_CreatePyObject(fb_python, false); @@ -461,8 +461,8 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args uint stencil = 0; if (py_col && py_col != Py_None) { - if (mathutils_array_parse(col, 3, 4, py_col, "GPUFrameBuffer.clear(), invalid 'color' arg") == - -1) + if (mathutils_array_parse( + col, 3, 4, py_col, "gpu::FrameBuffer.clear(), invalid 'color' arg") == -1) { return nullptr; } @@ -804,7 +804,7 @@ static PyMethodDef pygpu_framebuffer__tp_methods[] = { PyDoc_STRVAR( /* Wrap. */ pygpu_framebuffer__tp_doc, - ".. class:: GPUFrameBuffer(*, depth_slot=None, color_slots=None)\n" + ".. class:: gpu::FrameBuffer(*, depth_slot=None, color_slots=None)\n" "\n" " This object gives access to framebuffer functionalities.\n" " When a 'layer' is specified in a argument, a single layer of a 3D or array " @@ -823,7 +823,7 @@ PyDoc_STRVAR( "None\n"); PyTypeObject BPyGPUFrameBuffer_Type = { /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0) - /*tp_name*/ "GPUFrameBuffer", + /*tp_name*/ "gpu::FrameBuffer", /*tp_basicsize*/ sizeof(BPyGPUFrameBuffer), /*tp_itemsize*/ 0, /*tp_dealloc*/ (destructor)BPyGPUFrameBuffer__tp_dealloc, @@ -879,7 +879,7 @@ PyTypeObject BPyGPUFrameBuffer_Type = { /** \name Public API * \{ */ -PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_reference) +PyObject *BPyGPUFrameBuffer_CreatePyObject(blender::gpu::FrameBuffer *fb, bool shared_reference) { BPyGPUFrameBuffer *self; diff --git a/source/blender/python/gpu/gpu_py_framebuffer.hh b/source/blender/python/gpu/gpu_py_framebuffer.hh index cce4f395226..ea244da78d1 100644 --- a/source/blender/python/gpu/gpu_py_framebuffer.hh +++ b/source/blender/python/gpu/gpu_py_framebuffer.hh @@ -12,7 +12,9 @@ #include "BLI_compiler_attrs.h" -struct GPUFrameBuffer; +namespace blender::gpu { +class FrameBuffer; +} // namespace blender::gpu extern PyTypeObject BPyGPUFrameBuffer_Type; @@ -20,12 +22,12 @@ extern PyTypeObject BPyGPUFrameBuffer_Type; struct BPyGPUFrameBuffer { PyObject_HEAD - GPUFrameBuffer *fb; + blender::gpu::FrameBuffer *fb; #ifndef GPU_NO_USE_PY_REFERENCES bool shared_reference; #endif }; -[[nodiscard]] PyObject *BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_reference) - ATTR_NONNULL(1); +[[nodiscard]] PyObject *BPyGPUFrameBuffer_CreatePyObject(blender::gpu::FrameBuffer *fb, + bool shared_reference) ATTR_NONNULL(1); diff --git a/source/blender/python/gpu/gpu_py_state.cc b/source/blender/python/gpu/gpu_py_state.cc index f7171bf8c75..585f79f5349 100644 --- a/source/blender/python/gpu/gpu_py_state.cc +++ b/source/blender/python/gpu/gpu_py_state.cc @@ -500,7 +500,7 @@ static PyObject *pygpu_state_active_framebuffer_get(PyObject * /*self*/) { BPYGPU_IS_INIT_OR_ERROR_OBJ; - GPUFrameBuffer *fb = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *fb = GPU_framebuffer_active_get(); return BPyGPUFrameBuffer_CreatePyObject(fb, true); } diff --git a/source/blender/render/hydra/render_task_delegate.hh b/source/blender/render/hydra/render_task_delegate.hh index 52793459fc3..c821f260e7a 100644 --- a/source/blender/render/hydra/render_task_delegate.hh +++ b/source/blender/render/hydra/render_task_delegate.hh @@ -46,7 +46,7 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate { class GPURenderTaskDelegate : public RenderTaskDelegate { private: - GPUFrameBuffer *framebuffer_ = nullptr; + blender::gpu::FrameBuffer *framebuffer_ = nullptr; blender::gpu::Texture *tex_color_ = nullptr; blender::gpu::Texture *tex_depth_ = nullptr; unsigned int VAO_ = 0; diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 0522f39e923..5c736adfff4 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -240,7 +240,7 @@ void ViewportEngine::render() render_task_delegate_->add_aov(pxr::HdAovTokens->color); render_task_delegate_->add_aov(pxr::HdAovTokens->depth); - GPUFrameBuffer *view_framebuffer = GPU_framebuffer_active_get(); + blender::gpu::FrameBuffer *view_framebuffer = GPU_framebuffer_active_get(); render_task_delegate_->bind(); auto t = tasks(); diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc index f6771bbf461..7d48805e3e9 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc @@ -712,7 +712,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C, return nullptr; } blender::gpu::Texture *depth_tx = GPU_viewport_depth_texture(viewport); - GPUFrameBuffer *depth_read_fb = nullptr; + blender::gpu::FrameBuffer *depth_read_fb = nullptr; GPU_framebuffer_ensure_config(&depth_read_fb, { GPU_ATTACHMENT_TEXTURE(depth_tx),