160 lines
5.6 KiB
C
160 lines
5.6 KiB
C
/* "Null" renderer implementation.
|
|
* Useful for headless testing */
|
|
|
|
#include "gfx/renderer_api.h"
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "../common/common_render_graph.h"
|
|
|
|
#define RETURN_HANDLE_STUB2(type, initial) \
|
|
static unsigned int s_next = (initial); \
|
|
return (type) { .index = (s_next++) % RT_RENDER_BACKEND_HANDLE_MAX_INDEX, .version = 1 }
|
|
|
|
#define RETURN_HANDLE_STUB(type) RETURN_HANDLE_STUB2(type, 1)
|
|
|
|
#define RETURN_HANDLE_ARRAY_STUB2(out, count, initial) \
|
|
static unsigned int s_next = (initial); \
|
|
for (uint32_t i = 0; i < (count); ++i) { \
|
|
(out)[i].index = (s_next++) % RT_RENDER_BACKEND_HANDLE_MAX_INDEX; \
|
|
(out)[i].version = 1; \
|
|
}
|
|
|
|
#define RETURN_HANDLE_ARRAY_STUB(out, count) RETURN_HANDLE_ARRAY_STUB2(out, count, 1)
|
|
|
|
void RT_RENDERER_API_FN(RegisterCVars)(void) {
|
|
}
|
|
|
|
rt_result RT_RENDERER_API_FN(Init)(const rt_renderer_init_info *info) {
|
|
RT_UNUSED(info);
|
|
return RT_SUCCESS;
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(Shutdown)(void) {
|
|
}
|
|
|
|
unsigned int RT_RENDERER_API_FN(GetMaxFramesInFlight)(void) {
|
|
return 2;
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(BeginFrame)(unsigned int frame_id) {
|
|
RT_UNUSED(frame_id);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(EndFrame)(unsigned int frame_id) {
|
|
RT_UNUSED(frame_id);
|
|
}
|
|
|
|
rt_pipeline_handle RT_RENDERER_API_FN(CompilePipeline)(const rt_pipeline_info *info) {
|
|
RT_UNUSED(info);
|
|
RETURN_HANDLE_STUB(rt_pipeline_handle);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(DestroyPipeline)(rt_pipeline_handle handle) {
|
|
RT_UNUSED(handle);
|
|
}
|
|
|
|
rt_result RT_RENDERER_API_FN(AllocCommandBuffers)(uint32_t count,
|
|
const rt_alloc_command_buffer_info *info,
|
|
rt_command_buffer_handle *p_command_buffers) {
|
|
RT_UNUSED(info);
|
|
RETURN_HANDLE_ARRAY_STUB(p_command_buffers, count)
|
|
return RT_SUCCESS;
|
|
}
|
|
|
|
rt_result RT_RENDERER_API_FN(SubmitCommandBuffers)(rt_gpu_queue queue,
|
|
const rt_submit_command_buffers_info *info) {
|
|
RT_UNUSED(queue);
|
|
RT_UNUSED(info);
|
|
return RT_SUCCESS;
|
|
}
|
|
|
|
rt_result RT_RENDERER_API_FN(CreateBuffers)(uint32_t count,
|
|
const rt_buffer_info *info,
|
|
rt_buffer_handle *p_buffers) {
|
|
RT_UNUSED(info);
|
|
RETURN_HANDLE_ARRAY_STUB(p_buffers, count);
|
|
return RT_SUCCESS;
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(DestroyBuffers)(uint32_t count, rt_buffer_handle *buffers) {
|
|
RT_UNUSED(count);
|
|
RT_UNUSED(buffers);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdBeginPass)(rt_command_buffer_handle cmd,
|
|
const rt_cmd_begin_pass_info *info) {
|
|
RT_UNUSED(cmd);
|
|
RT_UNUSED(info);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdEndPass)(rt_command_buffer_handle cmd) {
|
|
RT_UNUSED(cmd);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdTransitionRenderTarget)(rt_command_buffer_handle cmd,
|
|
rt_render_target_handle target,
|
|
rt_render_target_state state) {
|
|
RT_UNUSED(cmd);
|
|
RT_UNUSED(target);
|
|
RT_UNUSED(state);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdFlushRenderTargetWrite)(rt_command_buffer_handle cmdbuf_handle,
|
|
rt_render_target_handle render_target) {
|
|
RT_UNUSED(cmdbuf_handle);
|
|
RT_UNUSED(render_target);
|
|
}
|
|
|
|
static rt_render_target_handle CreateRenderTarget(const rt_physical_render_target_info *info) {
|
|
RETURN_HANDLE_STUB(rt_render_target_handle);
|
|
}
|
|
|
|
static int RequireExplicitSync(void) {
|
|
return 0;
|
|
}
|
|
|
|
rt_render_graph_builder RT_RENDERER_API_FN(CreateRenderGraphBuilder)(void) {
|
|
rt_render_graph_builder_platform_callbacks cbs = {.CreateRenderTarget = CreateRenderTarget,
|
|
.RequireExplicitSynchronization =
|
|
RequireExplicitSync};
|
|
return rtCreateRenderGraphBuilder(&cbs);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(DestroyRenderGraphBuilder)(rt_render_graph_builder *builder) {
|
|
rtDestroyRenderGraphBuilder(builder);
|
|
}
|
|
|
|
rt_result RT_RENDERER_API_FN(ExecuteRenderGraph)(rt_render_graph *render_graph) {
|
|
RT_UNUSED(render_graph);
|
|
return RT_SUCCESS;
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(SubmitRenderView)(rt_render_graph *render_graph,
|
|
uint32_t pass_id,
|
|
rt_render_view view,
|
|
unsigned int frame_id) {
|
|
RT_UNUSED(render_graph);
|
|
RT_UNUSED(pass_id);
|
|
RT_UNUSED(view);
|
|
RT_UNUSED(frame_id);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(ResetRenderGraph)(rt_render_graph *graph) {
|
|
RT_UNUSED(graph);
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdBindPipeline)(rt_command_buffer_handle cmdhandle,
|
|
rt_pipeline_handle pipeline_handle) {
|
|
}
|
|
|
|
void RT_RENDERER_API_FN(CmdBindVertexBuffers)(rt_command_buffer_handle cmdhandle,
|
|
uint32_t first_binding,
|
|
uint32_t count,
|
|
const rt_buffer_handle *buffers,
|
|
const uint64_t *_offsets) {
|
|
}
|
|
void RT_RENDERER_API_FN(CmdDraw)(rt_command_buffer_handle cmdhandle,
|
|
uint32_t first,
|
|
uint32_t count) {
|
|
}
|