GPU: FrameBuffer: Remove GPUFrameBuffer wrapper opaque type

This is the first step into merging DRW_gpu_wrapper.hh into
the GPU module.

This is very similar to #119825.

Pull Request: https://projects.blender.org/blender/blender/pulls/146372
This commit is contained in:
Clément Foucault
2025-09-16 17:50:48 +02:00
committed by Clément Foucault
parent ecc495ac39
commit 9d0fe5573b
67 changed files with 273 additions and 282 deletions

View File

@@ -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(

View File

@@ -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 {

View File

@@ -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");

View File

@@ -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<typename PassType> void bind_resources(PassType &pass)
{

View File

@@ -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;

View File

@@ -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<typename PassType> void bind_resources(PassType &pass)
{

View File

@@ -335,7 +335,7 @@ void SphereProbeModule::sync_display(Vector<SphereProbe *> &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;

View File

@@ -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<typename PassType> void bind_resources(PassType &pass)
{

View File

@@ -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;

View File

@@ -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<IrradianceBrickPacked> bricks_alloc(int brick_len);
void bricks_free(Vector<IrradianceBrickPacked> &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;
};

View File

@@ -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,

View File

@@ -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
{

View File

@@ -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,

View File

@@ -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
{

View File

@@ -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,

View File

@@ -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<typename PassType> void bind_resources(PassType &pass)
{

View File

@@ -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);

View File

@@ -72,7 +72,7 @@ struct tVfx {
struct tVfx *next = nullptr;
std::unique_ptr<PassSimple> vfx_ps = std::make_unique<PassSimple>("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;
};

View File

@@ -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

View File

@@ -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

View File

@@ -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*/){};

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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"};

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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)
{

View File

@@ -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_;
}

View File

@@ -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. */

View File

@@ -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);
}

View File

@@ -142,7 +142,7 @@ struct ShaderBind {
};
struct FramebufferBind {
GPUFrameBuffer **framebuffer;
gpu::FrameBuffer **framebuffer;
void execute() const;
std::string serialize() const;

View File

@@ -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),

View File

@@ -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<class T> inline void PassBase<T>::shader_set(gpu::Shader *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(gpu::FrameBuffer **framebuffer)
{
create_command(Type::FramebufferBind).framebuffer_bind = {framebuffer};
}

View File

@@ -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<uint>(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,

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -4700,7 +4700,7 @@ void node_draw_space(const bContext &C, ARegion &region)
/* Setup off-screen buffers. */
GPUViewport *viewport = WM_draw_region_get_viewport(&region);
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);

View File

@@ -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<SeqRetimingKey *, Strip *> retiming_selection;

View File

@@ -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 &region)
GPUViewport *viewport = WM_draw_region_get_bound_viewport(&region);
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 &region)
GPUViewport *viewport = WM_draw_region_get_bound_viewport(&region);
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 &region)
GPUViewport *viewport = WM_draw_region_get_bound_viewport(&region);
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 &region)
GPUViewport *viewport = WM_draw_region_get_bound_viewport(&region);
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, &region, REGION_DRAW_POST_VIEW);

View File

@@ -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),

View File

@@ -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);

View File

@@ -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.
*

View File

@@ -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);

View File

@@ -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<GPUAttachmentState>(attachment_states + 1, attachment_len - 1));
fb->subpass_transition(attachment_states[0],
Span<GPUAttachmentState>(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<Texture *>(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<GPUAttachment> 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)
{

View File

@@ -269,20 +269,6 @@ class FrameBuffer {
}
};
/* Syntactic sugar. */
static inline GPUFrameBuffer *wrap(FrameBuffer *framebuffer)
{
return reinterpret_cast<GPUFrameBuffer *>(framebuffer);
}
static inline FrameBuffer *unwrap(GPUFrameBuffer *framebuffer)
{
return reinterpret_cast<FrameBuffer *>(framebuffer);
}
static inline const FrameBuffer *unwrap(const GPUFrameBuffer *framebuffer)
{
return reinterpret_cast<const FrameBuffer *>(framebuffer);
}
#undef DEBUG_NAME_LEN
} // namespace blender::gpu

View File

@@ -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. */

View File

@@ -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,

View File

@@ -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

View File

@@ -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);

View File

@@ -486,8 +486,8 @@ void gpu::MTLTexture::update_sub_depth_2d(
gpu::MTLTexture *mtl_tex = static_cast<gpu::MTLTexture *>(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_) {

View File

@@ -79,7 +79,7 @@ class GLContext : public Context {
* context is destroyed, we need to remove any reference to it.
*/
Set<GLVaoCache *> vao_caches_;
Set<GPUFrameBuffer *> framebuffers_;
Set<gpu::FrameBuffer *> framebuffers_;
/** Mutex for the below structures. */
std::mutex lists_mutex_;
/** VertexArrays and framebuffers are not shared across context. */

View File

@@ -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);

View File

@@ -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_;

View File

@@ -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)});

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<VKFrameBuffer *>(framebuffer);
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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),