Renderer Module

Description

The abstract base for a render module — a self-contained mini-renderer with its own queue, render pass, pipeline, descriptors, and an offscreen output image. Modules render into their own target; the compositor then samples and blends every module’s output into the swapchain. This is how the VULKAN renderer keeps game/UI/post passes independent and composes them at the end.

A concrete module (e.g. UI Rasterizer Module) supplies its feature set, descriptor layout, render pass, pipeline, and draw commands by overriding the abstract members below.

API summary

MemberKindSummary
rendererType / RendererStageabstract propModule identity (Game / UI / PostProcessing).
features / features12abstract propPhysical-device + Vulkan 1.2 features this module needs; the renderer ORs them together when creating the logical device.
descriptorTypes / shaderStages / descriptorBindingFlags / descriptorMaxCountsabstract propDeclarative descriptor-set layout description.
PrepareObjects()abstractAllocate command pool/queue, build mesh component, hook entity groups.
CreateRenderPass() / CreatePipeline()abstractBuild the module’s render pass + graphics pipeline.
CreateOutputImages()virtualAllocate the offscreen color targets (R8G8B8A8, SampledBit).
CreateModuleFrameBuffers()abstractFramebuffers over the output images.
UpdateModule(frame)abstractPer-frame rebuild (descriptors, instance buffers) when dirty.
WriteCommandBuffers(frame)abstractRecord the draw commands.
DestroySizeDependentResources()virtualTear down output images + framebuffers on window resize (see VULKAN → swapchain recreation).

Fields & Properties

internal Pipeline pipeline;
internal PipelineLayout pipelineLayout;
internal RenderPass renderPass;
internal Framebuffer[] frameBuffers;

public CommandPool moduleCommandPool;
internal CommandBuffer[] commandBuffers;
public bool[] isDirty = { true, true, true };   // per swapchain image

// offscreen render target (sampled by the compositor)
public Image[] outputImages;
public ImageView[] outputImageViews;
public DeviceMemory[] imageDeviceMemory;
public int compositorOrder = 0;                 // blend order in the compositor

internal AuroraCamera camera;
internal FrameResources[] frameResources;       // descriptor pool + sets, one per frame

Methods

Lifecycle (driven by the renderer)

The renderer calls these in order during bootstrap: PrepareObjectsCreateRenderPassCreateOutputImagesCreateModuleFrameBuffersCreatePipeline. Each frame, if the module’s isDirty[image] is set, the renderer calls UpdateModule, which re-records via WriteCommandBuffers.

Descriptors

CreateDescriptorSetLayout (virtual) builds the layouts from the declarative descriptorTypes / shaderStages / descriptorBindingFlags arrays; AllocateDescriptorSets handles the variable-count last binding (bindless arrays). Concrete modules fill them in UpdateDescriptorSets.

Resize

DestroySizeDependentResources (null-safe) drops framebuffers + output images so the renderer can recreate them at the new size; pipelines use dynamic viewport/scissor so they are not rebuilt.

Helpers

internal static ShaderModule CreateShaderModule(ref Vk vk, ref Device logicalDevice, byte[] code);
internal static byte[] ReadFile(string fileName);