Files
serenity/Userland/Libraries/LibV3DGPU/ControlList.h
T
Sönke Holz 7e510d374a Libraries: Add an initial LibGL driver for the VideoCore VII 3D
This initial version of the driver only supports glClear{,Color,Depth}()
for now.

Since the only publicly available documentation for the VideoCore 3D
architecture (the VideoCore IV 3D Architecture Reference Guide) just
covers an older revision of the VideoCore 3D architecture, I used
Mesa's v3d_packet.xml as a reference to get definitions for the control
records of the VideoCore VII.

To determine which control records need to be generated for a minimal
example, I used Mesa's `V3D_DEBUG` environment variable and set it to
`cl` to make it dump the control lists it generates for a basic OpenGL
test program.
2026-10-08 16:07:29 +02:00

61 lines
1.2 KiB
C++

/*
* Copyright (c) 2025, Sönke Holz <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Buffer.h"
#include "Definitions.h"
#include <AK/ByteBuffer.h>
#include <AK/Error.h>
#include <AK/Span.h>
#include <AK/Types.h>
namespace V3DGPU {
class ControlList {
public:
template<typename T>
void append(T const& packet)
{
m_data.try_append(&packet, sizeof(packet)).release_value_but_fixme_should_propagate_errors();
}
void clear()
{
m_data.clear();
}
ReadonlyBytes data() const
{
return m_data.bytes();
}
ErrorOr<void> copy_to_gpu_buffer()
{
if (!m_buffer.has_value() || m_buffer->size() < m_data.size()) {
auto buffer_size = align_up_to(m_data.size(), V3D_PAGE_SIZE);
m_buffer = TRY(Buffer::create(buffer_size, "LibV3DGPU: Control List"sv));
}
m_data.bytes().copy_to(m_buffer->data());
return {};
}
Optional<Buffer const&> buffer() const
{
VERIFY(m_buffer.has_value());
return *m_buffer;
}
private:
AK::Detail::ByteBuffer<0> m_data;
Optional<Buffer> m_buffer;
};
}