Files
Juliet/Juliet/include/Graphics/Graphics.h
2025-02-17 22:08:53 -05:00

90 lines
3.2 KiB
C++

#pragma once
#include <core/Common/NonNullPtr.h>
#include <Core/HAL/Display/Display.h>
#include <Graphics/GraphicsConfig.h>
#include <Graphics/RenderPass.h>
#include <Juliet.h>
// Graphics Interface
namespace Juliet
{
// Opaque types
struct CommandList;
struct GraphicsDevice;
// Parameters of an indirect draw command
struct IndirectDrawCommand
{
uint32 VertexCount; // Number of vertices to draw
uint32 InstanceCount; // Number of instanced to draw
uint32 FirstVertex; // Index of the first vertex to draw
uint32 FirstInstance; // ID of the first instance to draw
};
// Parameters of an INDEXED indirect draw command
struct IndexedIndirectDrawCommand
{
uint32 VertexCount; // Number of vertices to draw
uint32 InstanceCount; // Number of instanced to draw
uint32 FirstIndex; // Base Index within the index buffer
int32 VertexOffset; // Offset the vertex index into the buffer
uint32 FirstInstance; // ID of the first instance to draw
};
// Parameters of an INDEXED Indirect Dispatch Command
struct IndirectDispatchCommand
{
uint32 X_WorkGroupCount; // Number of Workgroup to dispatch on dimension X
uint32 Y_WorkGroupCount; // Number of Workgroup to dispatch on dimension Y
uint32 Z_WorkGroupCount; // Number of Workgroup to dispatch on dimension Z
};
enum class QueueType : uint8
{
Graphics = 0,
Compute,
Copy,
Count
};
enum struct SwapChainComposition : uint8
{
SDR,
SDR_LINEAR,
HDR_EXTENDED_LINEAR,
HDR10_ST2084
};
// PresentMode from highest to lowest latency
// Vsync prevents tearing. Enqueue ready images.
// Mailbox prevents tearing. When image is ready, replace any pending image
// Immediate replace current image as soon as possible. Can cause tearing
enum struct PresentMode : uint8
{
VSync,
Mailbox,
Immediate
};
extern JULIET_API GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config);
extern JULIET_API void DestroyGraphicsDevice(NonNullPtr<GraphicsDevice> device);
// Attach To Window
extern JULIET_API bool AttachToWindow(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window);
extern JULIET_API void DetachFromWindow(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window);
// SwapChain
extern JULIET_API bool AcquireSwapChainTexture(NonNullPtr<CommandList> commandList, NonNullPtr<Window> window,
Texture** swapChainTexture);
// Command List
extern JULIET_API CommandList* AcquireCommandList(NonNullPtr<GraphicsDevice> device, QueueType queueType = QueueType::Graphics);
extern JULIET_API void SubmitCommandLists(NonNullPtr<GraphicsDevice> device);
// RenderPass
extern JULIET_API RenderPass* BeginRenderPass(NonNullPtr<CommandList> commandList, ColorTargetInfo& colorTargetInfo);
extern JULIET_API RenderPass* BeginRenderPass(NonNullPtr<CommandList> commandList,
NonNullPtr<const ColorTargetInfo> colorTargetInfos, uint32 colorTargetInfoCount);
} // namespace Juliet