-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor bounding rect, vertex buffer flow. (#13)
* Refactor `get_bounds()`. - Store `Geometry` in `Drawable`, use that + transform to find bounding rect of all vertices. * Refactor `Mesh`, `Drawable`. - Remove `VertexBufferCache`, allocate scratch on each draw. - Remove `RenderDevice` from `Drawable` constructors. * Remove `Mesh`. * Add `BufferType` as wrapper for buffer usage flags.
- Loading branch information
Showing
40 changed files
with
269 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
#include <bave/graphics/detail/buffer_type.hpp> | ||
#include <bave/graphics/detail/buffering.hpp> | ||
#include <bave/graphics/detail/render_resource.hpp> | ||
#include <bave/logger.hpp> | ||
#include <array> | ||
#include <vector> | ||
|
||
namespace bave::detail { | ||
class BufferCache { | ||
public: | ||
explicit BufferCache(NotNull<RenderDevice*> render_device); | ||
|
||
auto allocate(BufferType type) -> RenderBuffer&; | ||
|
||
[[nodiscard]] auto get_empty(BufferType type) const -> RenderBuffer const& { return m_empty_buffers.at(static_cast<std::size_t>(type)); } | ||
|
||
[[nodiscard]] auto or_empty(Ptr<RenderBuffer const> buffer, BufferType type) const -> RenderBuffer const& { | ||
return buffer == nullptr ? get_empty(type) : *buffer; | ||
} | ||
|
||
auto next_frame() -> void; | ||
auto clear() -> void; | ||
|
||
private: | ||
struct Pool { | ||
std::vector<RenderBuffer> buffers{}; | ||
std::size_t next{}; | ||
}; | ||
|
||
static constexpr auto types_count_v = static_cast<std::size_t>(BufferType::eCOUNT_); | ||
|
||
using Map = std::array<Pool, types_count_v>; | ||
|
||
Logger m_log{"BufferCache"}; | ||
NotNull<RenderDevice*> m_render_device; | ||
std::array<RenderBuffer, types_count_v> m_empty_buffers; | ||
Buffered<Map> m_maps{}; | ||
}; | ||
} // namespace bave::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace bave::detail { | ||
enum class BufferType : int { eVertexIndex, eUniform, eStorage, eCOUNT_ }; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.