renderingelement2dvulkan auto buffer size

This commit is contained in:
Jorijn van der Graaf 2026-04-10 22:57:53 +02:00
commit f4a48b20c6

View file

@ -45,6 +45,9 @@ export namespace Crafter {
std::uint16_t bufferX; std::uint16_t bufferX;
std::uint16_t bufferY; std::uint16_t bufferY;
std::array<VulkanBufferBase*, Window::numFrames> buffers; std::array<VulkanBufferBase*, Window::numFrames> buffers;
RenderingElement2DVulkanBase(Anchor2D anchor) : Transform2D(anchor) {
}
RenderingElement2DVulkanBase(Anchor2D anchor, std::uint16_t bufferX, std::uint16_t bufferY) : bufferX(bufferX), bufferY(bufferY), Transform2D(anchor) { RenderingElement2DVulkanBase(Anchor2D anchor, std::uint16_t bufferX, std::uint16_t bufferY) : bufferX(bufferX), bufferY(bufferY), Transform2D(anchor) {
} }
@ -58,6 +61,16 @@ export namespace Crafter {
template<bool Owning, bool Mapped> template<bool Owning, bool Mapped>
struct RenderingElement2DVulkan : RenderingElement2DVulkanBase { struct RenderingElement2DVulkan : RenderingElement2DVulkanBase {
RenderingElement2DVulkan(Anchor2D anchor, RendertargetBase<Window::numFrames>& target, Transform2D& parent) requires(Owning) : RenderingElement2DVulkanBase(anchor) {
renderingElement2DVulkans.push_back(this);
UpdatePosition(target, parent);
this->bufferX = this->scaled.size.x;
this->bufferY = this->scaled.size.y;
for(std::uint8_t i = 0; i < Window::numFrames; i++) {
buffers[i] = new VulkanBuffer<Vector<_Float16, 4, 4>, Mapped>();
reinterpret_cast<VulkanBuffer<Vector<_Float16, 4, 4>, Mapped>*>(buffers[i])->Create(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_2_SHADER_DEVICE_ADDRESS_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bufferX * bufferY);
}
}
RenderingElement2DVulkan(Anchor2D anchor, std::uint16_t bufferX, std::uint16_t bufferY) requires(Owning) : RenderingElement2DVulkanBase(anchor, bufferX, bufferY) { RenderingElement2DVulkan(Anchor2D anchor, std::uint16_t bufferX, std::uint16_t bufferY) requires(Owning) : RenderingElement2DVulkanBase(anchor, bufferX, bufferY) {
renderingElement2DVulkans.push_back(this); renderingElement2DVulkans.push_back(this);
for(std::uint8_t i = 0; i < Window::numFrames; i++) { for(std::uint8_t i = 0; i < Window::numFrames; i++) {