···66set(DOXYGEN_XML_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml")
7788doxygen_add_docs(doxygen_xml
99- "${PROJECT_SOURCE_DIR}/libvektor/include"
99+ "${PROJECT_SOURCE_DIR}/kestrel/include"
1010 COMMENT "Generating XML API data with Doxygen"
1111)
1212
+2-2
docs/api/index.rst
···11API Reference
22-=========
22+=============
3344Kestrel's API is organized into functional modules. Each module contains
55related structures, enumerations, and functions.
6677.. note::
88- The API docs are generated from :file:`libvektor/include/vektor/vektor.h`.
88+ The API docs are generated from :file:`kestrel/include/kestrel/kestrel.h`.
99 To update this documentation, please edit the header file.
10101111.. toctree::
···11Architecture
22============
33+44+Each driver library (`libkestrel_<platform>.so`) exports only
55+a single symbol.
66+77+.. doxygenfile:: kestrel/interface.h
88+99+When a new Device is created, the Kestrel runtime iterates
1010+the available DRM devices on the system, and tries to resolve
1111+a suitable driver library. The symbol is resolved and bind
1212+all functions to that driver.
···44#include <vector>
5566#include "gpuinfo.h"
77-// #include "pm4.h"
88-99-// @todo: consider redesigning this..
1010-// instead of having multiple CmdStream types; let a commandstream
1111-// just be some kind of buffer (std::vector). We can rename this
1212-// to "PM4 Encoder" or something, directly adding to a provided
1313-// buffer.
147158class Pm4Encoder {
169public:
+67
drivers/amdgpu/queue.cpp
···11+#include "kestrel/kestrel.h"
22+#include "impl.h"
33+44+#include <cstdint>
55+#include <vector>
66+77+uint32_t hw_ip_type_from_queue_type(KesQueueType qt) {
88+ switch(qt) {
99+ case KesQueueTypeGraphics: return AMDGPU_HW_IP_GFX;
1010+ case KesQueueTypeCompute: return AMDGPU_HW_IP_COMPUTE;
1111+ case KesQueueTypeTransfer: return AMDGPU_HW_IP_DMA;
1212+ default:
1313+ not_implemented("no HW_IP type picked for queue type: {}", qt);
1414+ }
1515+}
1616+1717+KesQueue amdgpu_create_queue(KesDevice pd, KesQueueType qt) {
1818+ auto *dev = reinterpret_cast<DeviceImpl *>(pd);
1919+2020+ auto queue = new QueueImpl;
2121+ queue->dev = dev;
2222+ queue->type = qt;
2323+ queue->hw_ip_type = hw_ip_type_from_queue_type(qt);
2424+2525+ // @todo: consider creating ctx at device initialization?
2626+ int r = amdgpu_cs_ctx_create(dev->amd_handle, &queue->ctx_handle);
2727+ if (r != 0) {
2828+ delete queue;
2929+ return nullptr;
3030+ }
3131+3232+ // @todo: cleanup: remove this fkn pointer; shit stuff we don't need!
3333+ auto conf = CommandRing::Config{};
3434+ queue->cmd_ring = new CommandRing(dev->amd_handle, queue->ctx_handle, queue->hw_ip_type, conf);
3535+3636+ return queue;
3737+}
3838+3939+void amdgpu_destroy_queue(KesQueue pq) {
4040+ auto *queue = reinterpret_cast<QueueImpl *>(pq);
4141+ // @todo: actually delete queue.
4242+}
4343+4444+KesCommandList amdgpu_start_recording(KesQueue pq) {
4545+ auto *queue = reinterpret_cast<QueueImpl *>(pq);
4646+ auto cl = new CommandListImpl;
4747+4848+ cl->queue = queue;
4949+ cl->cs = queue->cmd_ring->begin_recording();
5050+5151+ return cl;
5252+}
5353+5454+// @todo: add support for semaphore or other synchronization.
5555+void amdgpu_submit(KesQueue pq, KesCommandList pcl) {
5656+ auto *queue = reinterpret_cast<QueueImpl *>(pq);
5757+ auto *cl = reinterpret_cast<CommandListImpl *>(pcl);
5858+ assert(cl->queue == queue, "submit: commandlist from foreign queue");
5959+6060+ queue->cmd_ring->submit(cl->cs); //, semaphore, value);
6161+6262+ // @todo: to free commandlist, we want to be sure that it is no longer mapped and stuff.
6363+ // then, we can freely-free it. But i think this needs some deferred-cleanup, as
6464+ // the data is on GTT so we cannot just let the CPU start using the range again.
6565+ //
6666+ // think about this.
6767+}