Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_view.hh
| Show All 26 Lines | |||||
| /* TODO: de-duplicate. */ | /* TODO: de-duplicate. */ | ||||
| using ObjectBoundsBuf = StorageArrayBuffer<ObjectBounds, 128>; | using ObjectBoundsBuf = StorageArrayBuffer<ObjectBounds, 128>; | ||||
| using VisibilityBuf = StorageArrayBuffer<uint, 4, true>; | using VisibilityBuf = StorageArrayBuffer<uint, 4, true>; | ||||
| class View { | class View { | ||||
| friend Manager; | friend Manager; | ||||
| private: | protected: | ||||
| /** TODO(fclem): Maybe try to reduce the minimum cost if the number of view is lower. */ | /** TODO(fclem): Maybe try to reduce the minimum cost if the number of view is lower. */ | ||||
| UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> data_; | UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> data_; | ||||
| UniformArrayBuffer<ViewCullingData, DRW_VIEW_MAX> culling_; | UniformArrayBuffer<ViewCullingData, DRW_VIEW_MAX> culling_; | ||||
| /** Frozen version of data_ used for debugging culling. */ | /** Frozen version of data_ used for debugging culling. */ | ||||
| UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> data_freeze_; | UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> data_freeze_; | ||||
| UniformArrayBuffer<ViewCullingData, DRW_VIEW_MAX> culling_freeze_; | UniformArrayBuffer<ViewCullingData, DRW_VIEW_MAX> culling_freeze_; | ||||
| /** Result of the visibility computation. 1 bit or 1 or 2 word per resource ID per view. */ | /** Result of the visibility computation. 1 bit or 1 or 2 word per resource ID per view. */ | ||||
| Show All 15 Lines | public: | ||||
| { | { | ||||
| BLI_assert(view_len <= DRW_VIEW_MAX); | BLI_assert(view_len <= DRW_VIEW_MAX); | ||||
| } | } | ||||
| /* For compatibility with old system. Will be removed at some point. */ | /* For compatibility with old system. Will be removed at some point. */ | ||||
| View(const char *name, const DRWView *view) | View(const char *name, const DRWView *view) | ||||
| : visibility_buf_(name), debug_name_(name), view_len_(1) | : visibility_buf_(name), debug_name_(name), view_len_(1) | ||||
| { | { | ||||
| float4x4 view_mat, win_mat; | this->sync(view); | ||||
| DRW_view_viewmat_get(view, view_mat.ptr(), false); | |||||
| DRW_view_winmat_get(view, win_mat.ptr(), false); | |||||
| this->sync(view_mat, win_mat); | |||||
| } | } | ||||
| void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id = 0); | void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id = 0); | ||||
| /* For compatibility with old system. Will be removed at some point. */ | |||||
| void sync(const DRWView *view); | |||||
| /** Disable a range in the multi-view array. Disabled view will not produce any instances. */ | /** Disable a range in the multi-view array. Disabled view will not produce any instances. */ | ||||
| void disable(IndexRange range); | void disable(IndexRange range); | ||||
| /** | /** | ||||
| * Update culling data using a compute shader. | * Update culling data using a compute shader. | ||||
| * This is to be used if the matrices were updated externally | * This is to be used if the matrices were updated externally | ||||
| * on the GPU (not using the `sync()` method). | * on the GPU (not using the `sync()` method). | ||||
| **/ | **/ | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | int visibility_word_per_draw() const | ||||
| return (view_len_ == 1) ? 0 : divide_ceil_u(view_len_, 32); | return (view_len_ == 1) ? 0 : divide_ceil_u(view_len_, 32); | ||||
| } | } | ||||
| UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> &matrices_ubo_get() | UniformArrayBuffer<ViewMatrices, DRW_VIEW_MAX> &matrices_ubo_get() | ||||
| { | { | ||||
| return data_; | return data_; | ||||
| } | } | ||||
| private: | protected: | ||||
| /** Called from draw manager. */ | /** Called from draw manager. */ | ||||
| void bind(); | void bind(); | ||||
| void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze); | virtual void compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze); | ||||
| virtual VisibilityBuf &get_visibility_buffer(); | |||||
| void update_viewport_size(); | void update_viewport_size(); | ||||
| /* WARNING: These 3 functions must be called in order */ | /* WARNING: These 3 functions must be called in order */ | ||||
| void frustum_boundbox_calc(int view_id); | void frustum_boundbox_calc(int view_id); | ||||
| void frustum_culling_planes_calc(int view_id); | void frustum_culling_planes_calc(int view_id); | ||||
| void frustum_culling_sphere_calc(int view_id); | void frustum_culling_sphere_calc(int view_id); | ||||
| }; | }; | ||||
| } // namespace blender::draw | } // namespace blender::draw | ||||