mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-24 00:17:52 +00:00
git normalize all files
This commit is contained in:
+187
-187
@@ -1,187 +1,187 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_D3D11_H
|
||||
#define RENDER_D3D11_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "d3d11")
|
||||
#pragma comment(lib, "d3dcompiler")
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render_d3d11.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: C-side Shader Types
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Rect R_D3D11_Uniforms_Rect;
|
||||
struct R_D3D11_Uniforms_Rect
|
||||
{
|
||||
Vec2F32 viewport_size;
|
||||
F32 opacity;
|
||||
F32 _padding0_;
|
||||
Vec4F32 texture_sample_channel_map[4];
|
||||
Vec2F32 texture_t2d_size;
|
||||
Vec2F32 translate;
|
||||
Vec4F32 xform[3];
|
||||
Vec2F32 xform_scale;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Uniforms_BlurPass R_D3D11_Uniforms_BlurPass;
|
||||
struct R_D3D11_Uniforms_BlurPass
|
||||
{
|
||||
Rng2F32 rect;
|
||||
Vec4F32 corner_radii;
|
||||
Vec2F32 direction;
|
||||
Vec2F32 viewport_size;
|
||||
U32 blur_count;
|
||||
U8 _padding0_[204];
|
||||
};
|
||||
StaticAssert(sizeof(R_D3D11_Uniforms_BlurPass) % 256 == 0, NotAligned); // constant count/offset must be aligned to 256 bytes
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Blur R_D3D11_Uniforms_Blur;
|
||||
struct R_D3D11_Uniforms_Blur
|
||||
{
|
||||
R_D3D11_Uniforms_BlurPass passes[Axis2_COUNT];
|
||||
Vec4F32 kernel[32];
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Mesh R_D3D11_Uniforms_Mesh;
|
||||
struct R_D3D11_Uniforms_Mesh
|
||||
{
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main State Types
|
||||
|
||||
typedef struct R_D3D11_Tex2D R_D3D11_Tex2D;
|
||||
struct R_D3D11_Tex2D
|
||||
{
|
||||
R_D3D11_Tex2D *next;
|
||||
U64 generation;
|
||||
ID3D11Texture2D *texture;
|
||||
ID3D11ShaderResourceView *view;
|
||||
R_ResourceKind kind;
|
||||
Vec2S32 size;
|
||||
R_Tex2DFormat format;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Buffer R_D3D11_Buffer;
|
||||
struct R_D3D11_Buffer
|
||||
{
|
||||
R_D3D11_Buffer *next;
|
||||
U64 generation;
|
||||
ID3D11Buffer *buffer;
|
||||
R_ResourceKind kind;
|
||||
U64 size;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Window R_D3D11_Window;
|
||||
struct R_D3D11_Window
|
||||
{
|
||||
R_D3D11_Window *next;
|
||||
U64 generation;
|
||||
|
||||
// rjf: swapchain/framebuffer
|
||||
IDXGISwapChain1 *swapchain;
|
||||
ID3D11Texture2D *framebuffer;
|
||||
ID3D11RenderTargetView *framebuffer_rtv;
|
||||
|
||||
// rjf: staging buffer
|
||||
ID3D11Texture2D *stage_color;
|
||||
ID3D11RenderTargetView *stage_color_rtv;
|
||||
ID3D11ShaderResourceView *stage_color_srv;
|
||||
ID3D11Texture2D *stage_scratch_color;
|
||||
ID3D11RenderTargetView *stage_scratch_color_rtv;
|
||||
ID3D11ShaderResourceView *stage_scratch_color_srv;
|
||||
|
||||
// rjf: geo3d buffer
|
||||
ID3D11Texture2D *geo3d_color;
|
||||
ID3D11RenderTargetView *geo3d_color_rtv;
|
||||
ID3D11ShaderResourceView *geo3d_color_srv;
|
||||
ID3D11Texture2D *geo3d_depth;
|
||||
ID3D11DepthStencilView *geo3d_depth_dsv;
|
||||
ID3D11ShaderResourceView *geo3d_depth_srv;
|
||||
|
||||
// rjf: last state
|
||||
Vec2S32 last_resolution;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_FlushBuffer R_D3D11_FlushBuffer;
|
||||
struct R_D3D11_FlushBuffer
|
||||
{
|
||||
R_D3D11_FlushBuffer *next;
|
||||
ID3D11Buffer *buffer;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_State R_D3D11_State;
|
||||
struct R_D3D11_State
|
||||
{
|
||||
// rjf: state
|
||||
Arena *arena;
|
||||
R_D3D11_Window *first_free_window;
|
||||
R_D3D11_Tex2D *first_free_tex2d;
|
||||
R_D3D11_Buffer *first_free_buffer;
|
||||
R_D3D11_Tex2D *first_to_free_tex2d;
|
||||
R_D3D11_Buffer *first_to_free_buffer;
|
||||
OS_Handle device_rw_mutex;
|
||||
|
||||
// rjf: base d3d11 objects
|
||||
ID3D11Device *base_device;
|
||||
ID3D11DeviceContext *base_device_ctx;
|
||||
ID3D11Device1 *device;
|
||||
ID3D11DeviceContext1 *device_ctx;
|
||||
IDXGIDevice1 *dxgi_device;
|
||||
IDXGIAdapter *dxgi_adapter;
|
||||
IDXGIFactory2 *dxgi_factory;
|
||||
ID3D11RasterizerState1 *main_rasterizer;
|
||||
ID3D11BlendState *main_blend_state;
|
||||
ID3D11BlendState *no_blend_state;
|
||||
ID3D11SamplerState *samplers[R_Tex2DSampleKind_COUNT];
|
||||
ID3D11DepthStencilState *noop_depth_stencil;
|
||||
ID3D11DepthStencilState *plain_depth_stencil;
|
||||
ID3D11Buffer *instance_scratch_buffer_64kb;
|
||||
|
||||
// rjf: backups
|
||||
R_Handle backup_texture;
|
||||
|
||||
// rjf: vertex shaders
|
||||
ID3D11VertexShader *vshads[R_D3D11_VShadKind_COUNT];
|
||||
ID3D11InputLayout *ilays[R_D3D11_VShadKind_COUNT];
|
||||
ID3D11PixelShader *pshads[R_D3D11_PShadKind_COUNT];
|
||||
ID3D11Buffer *uniform_type_kind_buffers[R_D3D11_UniformTypeKind_COUNT];
|
||||
|
||||
// rjf: buffers to flush at subsequent frame
|
||||
Arena *buffer_flush_arena;
|
||||
R_D3D11_FlushBuffer *first_buffer_to_flush;
|
||||
R_D3D11_FlushBuffer *last_buffer_to_flush;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global R_D3D11_State *r_d3d11_state = 0;
|
||||
global R_D3D11_Window r_d3d11_window_nil = {&r_d3d11_window_nil};
|
||||
global R_D3D11_Tex2D r_d3d11_tex2d_nil = {&r_d3d11_tex2d_nil};
|
||||
global R_D3D11_Buffer r_d3d11_buffer_nil = {&r_d3d11_buffer_nil};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Helpers
|
||||
|
||||
internal R_D3D11_Window *r_d3d11_window_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_window(R_D3D11_Window *window);
|
||||
internal R_D3D11_Tex2D *r_d3d11_tex2d_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_tex2d(R_D3D11_Tex2D *texture);
|
||||
internal R_D3D11_Buffer *r_d3d11_buffer_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_buffer(R_D3D11_Buffer *buffer);
|
||||
internal ID3D11Buffer *r_d3d11_instance_buffer_from_size(U64 size);
|
||||
internal void r_usage_access_flags_from_resource_kind(R_ResourceKind kind, D3D11_USAGE *out_d3d11_usage, UINT *out_cpu_access_flags);
|
||||
|
||||
#endif // RENDER_D3D11_H
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_D3D11_H
|
||||
#define RENDER_D3D11_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "d3d11")
|
||||
#pragma comment(lib, "d3dcompiler")
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render_d3d11.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: C-side Shader Types
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Rect R_D3D11_Uniforms_Rect;
|
||||
struct R_D3D11_Uniforms_Rect
|
||||
{
|
||||
Vec2F32 viewport_size;
|
||||
F32 opacity;
|
||||
F32 _padding0_;
|
||||
Vec4F32 texture_sample_channel_map[4];
|
||||
Vec2F32 texture_t2d_size;
|
||||
Vec2F32 translate;
|
||||
Vec4F32 xform[3];
|
||||
Vec2F32 xform_scale;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Uniforms_BlurPass R_D3D11_Uniforms_BlurPass;
|
||||
struct R_D3D11_Uniforms_BlurPass
|
||||
{
|
||||
Rng2F32 rect;
|
||||
Vec4F32 corner_radii;
|
||||
Vec2F32 direction;
|
||||
Vec2F32 viewport_size;
|
||||
U32 blur_count;
|
||||
U8 _padding0_[204];
|
||||
};
|
||||
StaticAssert(sizeof(R_D3D11_Uniforms_BlurPass) % 256 == 0, NotAligned); // constant count/offset must be aligned to 256 bytes
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Blur R_D3D11_Uniforms_Blur;
|
||||
struct R_D3D11_Uniforms_Blur
|
||||
{
|
||||
R_D3D11_Uniforms_BlurPass passes[Axis2_COUNT];
|
||||
Vec4F32 kernel[32];
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Uniforms_Mesh R_D3D11_Uniforms_Mesh;
|
||||
struct R_D3D11_Uniforms_Mesh
|
||||
{
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main State Types
|
||||
|
||||
typedef struct R_D3D11_Tex2D R_D3D11_Tex2D;
|
||||
struct R_D3D11_Tex2D
|
||||
{
|
||||
R_D3D11_Tex2D *next;
|
||||
U64 generation;
|
||||
ID3D11Texture2D *texture;
|
||||
ID3D11ShaderResourceView *view;
|
||||
R_ResourceKind kind;
|
||||
Vec2S32 size;
|
||||
R_Tex2DFormat format;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Buffer R_D3D11_Buffer;
|
||||
struct R_D3D11_Buffer
|
||||
{
|
||||
R_D3D11_Buffer *next;
|
||||
U64 generation;
|
||||
ID3D11Buffer *buffer;
|
||||
R_ResourceKind kind;
|
||||
U64 size;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_Window R_D3D11_Window;
|
||||
struct R_D3D11_Window
|
||||
{
|
||||
R_D3D11_Window *next;
|
||||
U64 generation;
|
||||
|
||||
// rjf: swapchain/framebuffer
|
||||
IDXGISwapChain1 *swapchain;
|
||||
ID3D11Texture2D *framebuffer;
|
||||
ID3D11RenderTargetView *framebuffer_rtv;
|
||||
|
||||
// rjf: staging buffer
|
||||
ID3D11Texture2D *stage_color;
|
||||
ID3D11RenderTargetView *stage_color_rtv;
|
||||
ID3D11ShaderResourceView *stage_color_srv;
|
||||
ID3D11Texture2D *stage_scratch_color;
|
||||
ID3D11RenderTargetView *stage_scratch_color_rtv;
|
||||
ID3D11ShaderResourceView *stage_scratch_color_srv;
|
||||
|
||||
// rjf: geo3d buffer
|
||||
ID3D11Texture2D *geo3d_color;
|
||||
ID3D11RenderTargetView *geo3d_color_rtv;
|
||||
ID3D11ShaderResourceView *geo3d_color_srv;
|
||||
ID3D11Texture2D *geo3d_depth;
|
||||
ID3D11DepthStencilView *geo3d_depth_dsv;
|
||||
ID3D11ShaderResourceView *geo3d_depth_srv;
|
||||
|
||||
// rjf: last state
|
||||
Vec2S32 last_resolution;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_FlushBuffer R_D3D11_FlushBuffer;
|
||||
struct R_D3D11_FlushBuffer
|
||||
{
|
||||
R_D3D11_FlushBuffer *next;
|
||||
ID3D11Buffer *buffer;
|
||||
};
|
||||
|
||||
typedef struct R_D3D11_State R_D3D11_State;
|
||||
struct R_D3D11_State
|
||||
{
|
||||
// rjf: state
|
||||
Arena *arena;
|
||||
R_D3D11_Window *first_free_window;
|
||||
R_D3D11_Tex2D *first_free_tex2d;
|
||||
R_D3D11_Buffer *first_free_buffer;
|
||||
R_D3D11_Tex2D *first_to_free_tex2d;
|
||||
R_D3D11_Buffer *first_to_free_buffer;
|
||||
OS_Handle device_rw_mutex;
|
||||
|
||||
// rjf: base d3d11 objects
|
||||
ID3D11Device *base_device;
|
||||
ID3D11DeviceContext *base_device_ctx;
|
||||
ID3D11Device1 *device;
|
||||
ID3D11DeviceContext1 *device_ctx;
|
||||
IDXGIDevice1 *dxgi_device;
|
||||
IDXGIAdapter *dxgi_adapter;
|
||||
IDXGIFactory2 *dxgi_factory;
|
||||
ID3D11RasterizerState1 *main_rasterizer;
|
||||
ID3D11BlendState *main_blend_state;
|
||||
ID3D11BlendState *no_blend_state;
|
||||
ID3D11SamplerState *samplers[R_Tex2DSampleKind_COUNT];
|
||||
ID3D11DepthStencilState *noop_depth_stencil;
|
||||
ID3D11DepthStencilState *plain_depth_stencil;
|
||||
ID3D11Buffer *instance_scratch_buffer_64kb;
|
||||
|
||||
// rjf: backups
|
||||
R_Handle backup_texture;
|
||||
|
||||
// rjf: vertex shaders
|
||||
ID3D11VertexShader *vshads[R_D3D11_VShadKind_COUNT];
|
||||
ID3D11InputLayout *ilays[R_D3D11_VShadKind_COUNT];
|
||||
ID3D11PixelShader *pshads[R_D3D11_PShadKind_COUNT];
|
||||
ID3D11Buffer *uniform_type_kind_buffers[R_D3D11_UniformTypeKind_COUNT];
|
||||
|
||||
// rjf: buffers to flush at subsequent frame
|
||||
Arena *buffer_flush_arena;
|
||||
R_D3D11_FlushBuffer *first_buffer_to_flush;
|
||||
R_D3D11_FlushBuffer *last_buffer_to_flush;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
global R_D3D11_State *r_d3d11_state = 0;
|
||||
global R_D3D11_Window r_d3d11_window_nil = {&r_d3d11_window_nil};
|
||||
global R_D3D11_Tex2D r_d3d11_tex2d_nil = {&r_d3d11_tex2d_nil};
|
||||
global R_D3D11_Buffer r_d3d11_buffer_nil = {&r_d3d11_buffer_nil};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Helpers
|
||||
|
||||
internal R_D3D11_Window *r_d3d11_window_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_window(R_D3D11_Window *window);
|
||||
internal R_D3D11_Tex2D *r_d3d11_tex2d_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_tex2d(R_D3D11_Tex2D *texture);
|
||||
internal R_D3D11_Buffer *r_d3d11_buffer_from_handle(R_Handle handle);
|
||||
internal R_Handle r_d3d11_handle_from_buffer(R_D3D11_Buffer *buffer);
|
||||
internal ID3D11Buffer *r_d3d11_instance_buffer_from_size(U64 size);
|
||||
internal void r_usage_access_flags_from_resource_kind(R_ResourceKind kind, D3D11_USAGE *out_d3d11_usage, UINT *out_cpu_access_flags);
|
||||
|
||||
#endif // RENDER_D3D11_H
|
||||
|
||||
+523
-523
File diff suppressed because it is too large
Load Diff
+77
-77
@@ -1,77 +1,77 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render.meta.c"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Type Functions
|
||||
|
||||
internal R_Handle
|
||||
r_handle_zero(void)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
return handle;
|
||||
}
|
||||
|
||||
internal B32
|
||||
r_handle_match(R_Handle a, R_Handle b)
|
||||
{
|
||||
return a.u64[0] == b.u64[0] && a.u64[1] == b.u64[1];
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Type Functions
|
||||
|
||||
internal R_BatchList
|
||||
r_batch_list_make(U64 instance_size)
|
||||
{
|
||||
R_BatchList list = {0};
|
||||
list.bytes_per_inst = instance_size;
|
||||
return list;
|
||||
}
|
||||
|
||||
internal void *
|
||||
r_batch_list_push_inst(Arena *arena, R_BatchList *list, U64 batch_inst_cap)
|
||||
{
|
||||
void *inst = 0;
|
||||
{
|
||||
R_BatchNode *n = list->last;
|
||||
if(n == 0 || n->v.byte_count+list->bytes_per_inst > n->v.byte_cap)
|
||||
{
|
||||
n = push_array(arena, R_BatchNode, 1);
|
||||
n->v.byte_cap = batch_inst_cap*list->bytes_per_inst;
|
||||
n->v.v = push_array_no_zero(arena, U8, n->v.byte_cap);
|
||||
SLLQueuePush(list->first, list->last, n);
|
||||
list->batch_count += 1;
|
||||
}
|
||||
inst = n->v.v + n->v.byte_count;
|
||||
n->v.byte_count += list->bytes_per_inst;
|
||||
list->byte_count += list->bytes_per_inst;
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Type Functions
|
||||
|
||||
internal R_Pass *
|
||||
r_pass_from_kind(Arena *arena, R_PassList *list, R_PassKind kind)
|
||||
{
|
||||
R_PassNode *n = list->last;
|
||||
if(!r_pass_kind_batch_table[kind])
|
||||
{
|
||||
n = 0;
|
||||
}
|
||||
if(n == 0 || n->v.kind != kind)
|
||||
{
|
||||
n = push_array(arena, R_PassNode, 1);
|
||||
SLLQueuePush(list->first, list->last, n);
|
||||
list->count += 1;
|
||||
n->v.kind = kind;
|
||||
n->v.params = push_array(arena, U8, r_pass_kind_params_size_table[kind]);
|
||||
}
|
||||
return &n->v;
|
||||
}
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render.meta.c"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Type Functions
|
||||
|
||||
internal R_Handle
|
||||
r_handle_zero(void)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
return handle;
|
||||
}
|
||||
|
||||
internal B32
|
||||
r_handle_match(R_Handle a, R_Handle b)
|
||||
{
|
||||
return a.u64[0] == b.u64[0] && a.u64[1] == b.u64[1];
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Type Functions
|
||||
|
||||
internal R_BatchList
|
||||
r_batch_list_make(U64 instance_size)
|
||||
{
|
||||
R_BatchList list = {0};
|
||||
list.bytes_per_inst = instance_size;
|
||||
return list;
|
||||
}
|
||||
|
||||
internal void *
|
||||
r_batch_list_push_inst(Arena *arena, R_BatchList *list, U64 batch_inst_cap)
|
||||
{
|
||||
void *inst = 0;
|
||||
{
|
||||
R_BatchNode *n = list->last;
|
||||
if(n == 0 || n->v.byte_count+list->bytes_per_inst > n->v.byte_cap)
|
||||
{
|
||||
n = push_array(arena, R_BatchNode, 1);
|
||||
n->v.byte_cap = batch_inst_cap*list->bytes_per_inst;
|
||||
n->v.v = push_array_no_zero(arena, U8, n->v.byte_cap);
|
||||
SLLQueuePush(list->first, list->last, n);
|
||||
list->batch_count += 1;
|
||||
}
|
||||
inst = n->v.v + n->v.byte_count;
|
||||
n->v.byte_count += list->bytes_per_inst;
|
||||
list->byte_count += list->bytes_per_inst;
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Type Functions
|
||||
|
||||
internal R_Pass *
|
||||
r_pass_from_kind(Arena *arena, R_PassList *list, R_PassKind kind)
|
||||
{
|
||||
R_PassNode *n = list->last;
|
||||
if(!r_pass_kind_batch_table[kind])
|
||||
{
|
||||
n = 0;
|
||||
}
|
||||
if(n == 0 || n->v.kind != kind)
|
||||
{
|
||||
n = push_array(arena, R_PassNode, 1);
|
||||
SLLQueuePush(list->first, list->last, n);
|
||||
list->count += 1;
|
||||
n->v.kind = kind;
|
||||
n->v.params = push_array(arena, U8, r_pass_kind_params_size_table[kind]);
|
||||
}
|
||||
return &n->v;
|
||||
}
|
||||
|
||||
+245
-245
@@ -1,245 +1,245 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_CORE_H
|
||||
#define RENDER_CORE_H
|
||||
|
||||
#define r_hook C_LINKAGE
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Enums
|
||||
|
||||
typedef U32 R_GeoVertexFlags;
|
||||
enum
|
||||
{
|
||||
R_GeoVertexFlag_TexCoord = (1<<0),
|
||||
R_GeoVertexFlag_Normals = (1<<1),
|
||||
R_GeoVertexFlag_RGB = (1<<2),
|
||||
R_GeoVertexFlag_RGBA = (1<<3),
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handle Type
|
||||
|
||||
typedef union R_Handle R_Handle;
|
||||
union R_Handle
|
||||
{
|
||||
U64 u64[2];
|
||||
U32 u32[4];
|
||||
U16 u16[8];
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Instance Types
|
||||
|
||||
typedef struct R_Rect2DInst R_Rect2DInst;
|
||||
struct R_Rect2DInst
|
||||
{
|
||||
Rng2F32 dst;
|
||||
Rng2F32 src;
|
||||
Vec4F32 colors[Corner_COUNT];
|
||||
F32 corner_radii[Corner_COUNT];
|
||||
F32 border_thickness;
|
||||
F32 edge_softness;
|
||||
F32 white_texture_override;
|
||||
F32 _unused_[1];
|
||||
};
|
||||
|
||||
typedef struct R_Mesh3DInst R_Mesh3DInst;
|
||||
struct R_Mesh3DInst
|
||||
{
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Types
|
||||
|
||||
typedef struct R_Batch R_Batch;
|
||||
struct R_Batch
|
||||
{
|
||||
U8 *v;
|
||||
U64 byte_count;
|
||||
U64 byte_cap;
|
||||
};
|
||||
|
||||
typedef struct R_BatchNode R_BatchNode;
|
||||
struct R_BatchNode
|
||||
{
|
||||
R_BatchNode *next;
|
||||
R_Batch v;
|
||||
};
|
||||
|
||||
typedef struct R_BatchList R_BatchList;
|
||||
struct R_BatchList
|
||||
{
|
||||
R_BatchNode *first;
|
||||
R_BatchNode *last;
|
||||
U64 batch_count;
|
||||
U64 byte_count;
|
||||
U64 bytes_per_inst;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DParams R_BatchGroup2DParams;
|
||||
struct R_BatchGroup2DParams
|
||||
{
|
||||
R_Handle tex;
|
||||
R_Tex2DSampleKind tex_sample_kind;
|
||||
Mat3x3F32 xform;
|
||||
Rng2F32 clip;
|
||||
F32 transparency;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DNode R_BatchGroup2DNode;
|
||||
struct R_BatchGroup2DNode
|
||||
{
|
||||
R_BatchGroup2DNode *next;
|
||||
R_BatchList batches;
|
||||
R_BatchGroup2DParams params;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DList R_BatchGroup2DList;
|
||||
struct R_BatchGroup2DList
|
||||
{
|
||||
R_BatchGroup2DNode *first;
|
||||
R_BatchGroup2DNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DParams R_BatchGroup3DParams;
|
||||
struct R_BatchGroup3DParams
|
||||
{
|
||||
R_Handle mesh_vertices;
|
||||
R_Handle mesh_indices;
|
||||
R_GeoTopologyKind mesh_geo_topology;
|
||||
R_GeoVertexFlags mesh_geo_vertex_flags;
|
||||
R_Handle albedo_tex;
|
||||
R_Tex2DSampleKind albedo_tex_sample_kind;
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DMapNode R_BatchGroup3DMapNode;
|
||||
struct R_BatchGroup3DMapNode
|
||||
{
|
||||
R_BatchGroup3DMapNode *next;
|
||||
U64 hash;
|
||||
R_BatchList batches;
|
||||
R_BatchGroup3DParams params;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DMap R_BatchGroup3DMap;
|
||||
struct R_BatchGroup3DMap
|
||||
{
|
||||
R_BatchGroup3DMapNode **slots;
|
||||
U64 slots_count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Types
|
||||
|
||||
typedef struct R_PassParams_UI R_PassParams_UI;
|
||||
struct R_PassParams_UI
|
||||
{
|
||||
R_BatchGroup2DList rects;
|
||||
};
|
||||
|
||||
typedef struct R_PassParams_Blur R_PassParams_Blur;
|
||||
struct R_PassParams_Blur
|
||||
{
|
||||
Rng2F32 rect;
|
||||
Rng2F32 clip;
|
||||
F32 blur_size;
|
||||
F32 corner_radii[Corner_COUNT];
|
||||
};
|
||||
|
||||
typedef struct R_PassParams_Geo3D R_PassParams_Geo3D;
|
||||
struct R_PassParams_Geo3D
|
||||
{
|
||||
Rng2F32 viewport;
|
||||
Rng2F32 clip;
|
||||
Mat4x4F32 view;
|
||||
Mat4x4F32 projection;
|
||||
R_BatchGroup3DMap mesh_batches;
|
||||
};
|
||||
|
||||
typedef struct R_Pass R_Pass;
|
||||
struct R_Pass
|
||||
{
|
||||
R_PassKind kind;
|
||||
union
|
||||
{
|
||||
void *params;
|
||||
R_PassParams_UI *params_ui;
|
||||
R_PassParams_Blur *params_blur;
|
||||
R_PassParams_Geo3D *params_geo3d;
|
||||
};
|
||||
};
|
||||
|
||||
typedef struct R_PassNode R_PassNode;
|
||||
struct R_PassNode
|
||||
{
|
||||
R_PassNode *next;
|
||||
R_Pass v;
|
||||
};
|
||||
|
||||
typedef struct R_PassList R_PassList;
|
||||
struct R_PassList
|
||||
{
|
||||
R_PassNode *first;
|
||||
R_PassNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handle Type Functions
|
||||
|
||||
internal R_Handle r_handle_zero(void);
|
||||
internal B32 r_handle_match(R_Handle a, R_Handle b);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Type Functions
|
||||
|
||||
internal R_BatchList r_batch_list_make(U64 instance_size);
|
||||
internal void *r_batch_list_push_inst(Arena *arena, R_BatchList *list, U64 batch_inst_cap);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Type Functions
|
||||
|
||||
internal R_Pass *r_pass_from_kind(Arena *arena, R_PassList *list, R_PassKind kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Hooks
|
||||
|
||||
//- rjf: top-level layer initialization
|
||||
r_hook void r_init(CmdLine *cmdln);
|
||||
|
||||
//- rjf: window setup/teardown
|
||||
r_hook R_Handle r_window_equip(OS_Handle window);
|
||||
r_hook void r_window_unequip(OS_Handle window, R_Handle window_equip);
|
||||
|
||||
//- rjf: textures
|
||||
r_hook R_Handle r_tex2d_alloc(R_ResourceKind kind, Vec2S32 size, R_Tex2DFormat format, void *data);
|
||||
r_hook void r_tex2d_release(R_Handle texture);
|
||||
r_hook R_ResourceKind r_kind_from_tex2d(R_Handle texture);
|
||||
r_hook Vec2S32 r_size_from_tex2d(R_Handle texture);
|
||||
r_hook R_Tex2DFormat r_format_from_tex2d(R_Handle texture);
|
||||
r_hook void r_fill_tex2d_region(R_Handle texture, Rng2S32 subrect, void *data);
|
||||
|
||||
//- rjf: buffers
|
||||
r_hook R_Handle r_buffer_alloc(R_ResourceKind kind, U64 size, void *data);
|
||||
r_hook void r_buffer_release(R_Handle buffer);
|
||||
|
||||
//- rjf: frame markers
|
||||
r_hook void r_begin_frame(void);
|
||||
r_hook void r_end_frame(void);
|
||||
r_hook void r_window_begin_frame(OS_Handle window, R_Handle window_equip);
|
||||
r_hook void r_window_end_frame(OS_Handle window, R_Handle window_equip);
|
||||
|
||||
//- rjf: render pass submission
|
||||
r_hook void r_window_submit(OS_Handle window, R_Handle window_equip, R_PassList *passes);
|
||||
|
||||
#endif // RENDER_CORE_H
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_CORE_H
|
||||
#define RENDER_CORE_H
|
||||
|
||||
#define r_hook C_LINKAGE
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generated Code
|
||||
|
||||
#include "generated/render.meta.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Enums
|
||||
|
||||
typedef U32 R_GeoVertexFlags;
|
||||
enum
|
||||
{
|
||||
R_GeoVertexFlag_TexCoord = (1<<0),
|
||||
R_GeoVertexFlag_Normals = (1<<1),
|
||||
R_GeoVertexFlag_RGB = (1<<2),
|
||||
R_GeoVertexFlag_RGBA = (1<<3),
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handle Type
|
||||
|
||||
typedef union R_Handle R_Handle;
|
||||
union R_Handle
|
||||
{
|
||||
U64 u64[2];
|
||||
U32 u32[4];
|
||||
U16 u16[8];
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Instance Types
|
||||
|
||||
typedef struct R_Rect2DInst R_Rect2DInst;
|
||||
struct R_Rect2DInst
|
||||
{
|
||||
Rng2F32 dst;
|
||||
Rng2F32 src;
|
||||
Vec4F32 colors[Corner_COUNT];
|
||||
F32 corner_radii[Corner_COUNT];
|
||||
F32 border_thickness;
|
||||
F32 edge_softness;
|
||||
F32 white_texture_override;
|
||||
F32 _unused_[1];
|
||||
};
|
||||
|
||||
typedef struct R_Mesh3DInst R_Mesh3DInst;
|
||||
struct R_Mesh3DInst
|
||||
{
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Types
|
||||
|
||||
typedef struct R_Batch R_Batch;
|
||||
struct R_Batch
|
||||
{
|
||||
U8 *v;
|
||||
U64 byte_count;
|
||||
U64 byte_cap;
|
||||
};
|
||||
|
||||
typedef struct R_BatchNode R_BatchNode;
|
||||
struct R_BatchNode
|
||||
{
|
||||
R_BatchNode *next;
|
||||
R_Batch v;
|
||||
};
|
||||
|
||||
typedef struct R_BatchList R_BatchList;
|
||||
struct R_BatchList
|
||||
{
|
||||
R_BatchNode *first;
|
||||
R_BatchNode *last;
|
||||
U64 batch_count;
|
||||
U64 byte_count;
|
||||
U64 bytes_per_inst;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DParams R_BatchGroup2DParams;
|
||||
struct R_BatchGroup2DParams
|
||||
{
|
||||
R_Handle tex;
|
||||
R_Tex2DSampleKind tex_sample_kind;
|
||||
Mat3x3F32 xform;
|
||||
Rng2F32 clip;
|
||||
F32 transparency;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DNode R_BatchGroup2DNode;
|
||||
struct R_BatchGroup2DNode
|
||||
{
|
||||
R_BatchGroup2DNode *next;
|
||||
R_BatchList batches;
|
||||
R_BatchGroup2DParams params;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup2DList R_BatchGroup2DList;
|
||||
struct R_BatchGroup2DList
|
||||
{
|
||||
R_BatchGroup2DNode *first;
|
||||
R_BatchGroup2DNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DParams R_BatchGroup3DParams;
|
||||
struct R_BatchGroup3DParams
|
||||
{
|
||||
R_Handle mesh_vertices;
|
||||
R_Handle mesh_indices;
|
||||
R_GeoTopologyKind mesh_geo_topology;
|
||||
R_GeoVertexFlags mesh_geo_vertex_flags;
|
||||
R_Handle albedo_tex;
|
||||
R_Tex2DSampleKind albedo_tex_sample_kind;
|
||||
Mat4x4F32 xform;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DMapNode R_BatchGroup3DMapNode;
|
||||
struct R_BatchGroup3DMapNode
|
||||
{
|
||||
R_BatchGroup3DMapNode *next;
|
||||
U64 hash;
|
||||
R_BatchList batches;
|
||||
R_BatchGroup3DParams params;
|
||||
};
|
||||
|
||||
typedef struct R_BatchGroup3DMap R_BatchGroup3DMap;
|
||||
struct R_BatchGroup3DMap
|
||||
{
|
||||
R_BatchGroup3DMapNode **slots;
|
||||
U64 slots_count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Types
|
||||
|
||||
typedef struct R_PassParams_UI R_PassParams_UI;
|
||||
struct R_PassParams_UI
|
||||
{
|
||||
R_BatchGroup2DList rects;
|
||||
};
|
||||
|
||||
typedef struct R_PassParams_Blur R_PassParams_Blur;
|
||||
struct R_PassParams_Blur
|
||||
{
|
||||
Rng2F32 rect;
|
||||
Rng2F32 clip;
|
||||
F32 blur_size;
|
||||
F32 corner_radii[Corner_COUNT];
|
||||
};
|
||||
|
||||
typedef struct R_PassParams_Geo3D R_PassParams_Geo3D;
|
||||
struct R_PassParams_Geo3D
|
||||
{
|
||||
Rng2F32 viewport;
|
||||
Rng2F32 clip;
|
||||
Mat4x4F32 view;
|
||||
Mat4x4F32 projection;
|
||||
R_BatchGroup3DMap mesh_batches;
|
||||
};
|
||||
|
||||
typedef struct R_Pass R_Pass;
|
||||
struct R_Pass
|
||||
{
|
||||
R_PassKind kind;
|
||||
union
|
||||
{
|
||||
void *params;
|
||||
R_PassParams_UI *params_ui;
|
||||
R_PassParams_Blur *params_blur;
|
||||
R_PassParams_Geo3D *params_geo3d;
|
||||
};
|
||||
};
|
||||
|
||||
typedef struct R_PassNode R_PassNode;
|
||||
struct R_PassNode
|
||||
{
|
||||
R_PassNode *next;
|
||||
R_Pass v;
|
||||
};
|
||||
|
||||
typedef struct R_PassList R_PassList;
|
||||
struct R_PassList
|
||||
{
|
||||
R_PassNode *first;
|
||||
R_PassNode *last;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Handle Type Functions
|
||||
|
||||
internal R_Handle r_handle_zero(void);
|
||||
internal B32 r_handle_match(R_Handle a, R_Handle b);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Batch Type Functions
|
||||
|
||||
internal R_BatchList r_batch_list_make(U64 instance_size);
|
||||
internal void *r_batch_list_push_inst(Arena *arena, R_BatchList *list, U64 batch_inst_cap);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Pass Type Functions
|
||||
|
||||
internal R_Pass *r_pass_from_kind(Arena *arena, R_PassList *list, R_PassKind kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Hooks
|
||||
|
||||
//- rjf: top-level layer initialization
|
||||
r_hook void r_init(CmdLine *cmdln);
|
||||
|
||||
//- rjf: window setup/teardown
|
||||
r_hook R_Handle r_window_equip(OS_Handle window);
|
||||
r_hook void r_window_unequip(OS_Handle window, R_Handle window_equip);
|
||||
|
||||
//- rjf: textures
|
||||
r_hook R_Handle r_tex2d_alloc(R_ResourceKind kind, Vec2S32 size, R_Tex2DFormat format, void *data);
|
||||
r_hook void r_tex2d_release(R_Handle texture);
|
||||
r_hook R_ResourceKind r_kind_from_tex2d(R_Handle texture);
|
||||
r_hook Vec2S32 r_size_from_tex2d(R_Handle texture);
|
||||
r_hook R_Tex2DFormat r_format_from_tex2d(R_Handle texture);
|
||||
r_hook void r_fill_tex2d_region(R_Handle texture, Rng2S32 subrect, void *data);
|
||||
|
||||
//- rjf: buffers
|
||||
r_hook R_Handle r_buffer_alloc(R_ResourceKind kind, U64 size, void *data);
|
||||
r_hook void r_buffer_release(R_Handle buffer);
|
||||
|
||||
//- rjf: frame markers
|
||||
r_hook void r_begin_frame(void);
|
||||
r_hook void r_end_frame(void);
|
||||
r_hook void r_window_begin_frame(OS_Handle window, R_Handle window_equip);
|
||||
r_hook void r_window_end_frame(OS_Handle window, R_Handle window_equip);
|
||||
|
||||
//- rjf: render pass submission
|
||||
r_hook void r_window_submit(OS_Handle window, R_Handle window_equip, R_PassList *passes);
|
||||
|
||||
#endif // RENDER_CORE_H
|
||||
|
||||
+131
-131
@@ -1,131 +1,131 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tables
|
||||
|
||||
@table(name, display_string, bytes_per_pixel)
|
||||
R_Tex2DFormatTable:
|
||||
{
|
||||
{R8 "R8" 1}
|
||||
{RG8 "RG8" 2}
|
||||
{RGBA8 "RGBA8" 4}
|
||||
{BGRA8 "BGRA8" 4}
|
||||
{R16 "R16" 2}
|
||||
{RGBA16 "RGBA16" 8}
|
||||
{R32 "R32" 4}
|
||||
{RG32 "RG32" 8}
|
||||
{RGBA32 "RGBA32" 16}
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_ResourceKindTable:
|
||||
{
|
||||
// static resource is immutable
|
||||
// initial data must be provided at creation time
|
||||
// GPU can read the resource
|
||||
// CPU is not allowed to read or write
|
||||
{Static "Static" }
|
||||
|
||||
// dynamic resource allows resource to be modified
|
||||
// GPU can read & write to it
|
||||
// CPU can write to it using UpdateSubresource
|
||||
{Dynamic "Dynamic"}
|
||||
|
||||
// stream resource will be often updated fully overwriting previous data
|
||||
// GPU can only read it
|
||||
// CPU can update via Map (with WRITE_DISCARD flag) + Unmap
|
||||
{Stream "Stream "}
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_Tex2DSampleKindTable:
|
||||
{
|
||||
{Nearest "Nearest" }
|
||||
{Linear "Linear" }
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_GeoTopologyKindTable:
|
||||
{
|
||||
{Lines "Lines" }
|
||||
{LineStrip "Line Strip" }
|
||||
{Triangles "Triangles" }
|
||||
{TriangleStrip "Triangle Strip" }
|
||||
}
|
||||
|
||||
@table(name, batch, display_string)
|
||||
R_PassKindTable:
|
||||
{
|
||||
{UI 1 "UI" }
|
||||
{Blur 0 "Blur" }
|
||||
{Geo3D 1 "Geo3D" }
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generators
|
||||
|
||||
@enum R_Tex2DFormat:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_ResourceKind:
|
||||
{
|
||||
@expand(R_ResourceKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_Tex2DSampleKind:
|
||||
{
|
||||
@expand(R_Tex2DSampleKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_GeoTopologyKind:
|
||||
{
|
||||
@expand(R_GeoTopologyKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_PassKind:
|
||||
{
|
||||
@expand(R_PassKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_format_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(U8) r_tex2d_format_bytes_per_pixel_table:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `$(a.bytes_per_pixel)`;
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_kind_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_sample_kind_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DSampleKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(String8) r_pass_kind_display_string_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(U8) r_pass_kind_batch_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `$(a.batch)`;
|
||||
}
|
||||
|
||||
@data(U64) @c_file r_pass_kind_params_size_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `sizeof(R_PassParams_$(a.name))`;
|
||||
}
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tables
|
||||
|
||||
@table(name, display_string, bytes_per_pixel)
|
||||
R_Tex2DFormatTable:
|
||||
{
|
||||
{R8 "R8" 1}
|
||||
{RG8 "RG8" 2}
|
||||
{RGBA8 "RGBA8" 4}
|
||||
{BGRA8 "BGRA8" 4}
|
||||
{R16 "R16" 2}
|
||||
{RGBA16 "RGBA16" 8}
|
||||
{R32 "R32" 4}
|
||||
{RG32 "RG32" 8}
|
||||
{RGBA32 "RGBA32" 16}
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_ResourceKindTable:
|
||||
{
|
||||
// static resource is immutable
|
||||
// initial data must be provided at creation time
|
||||
// GPU can read the resource
|
||||
// CPU is not allowed to read or write
|
||||
{Static "Static" }
|
||||
|
||||
// dynamic resource allows resource to be modified
|
||||
// GPU can read & write to it
|
||||
// CPU can write to it using UpdateSubresource
|
||||
{Dynamic "Dynamic"}
|
||||
|
||||
// stream resource will be often updated fully overwriting previous data
|
||||
// GPU can only read it
|
||||
// CPU can update via Map (with WRITE_DISCARD flag) + Unmap
|
||||
{Stream "Stream "}
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_Tex2DSampleKindTable:
|
||||
{
|
||||
{Nearest "Nearest" }
|
||||
{Linear "Linear" }
|
||||
}
|
||||
|
||||
@table(name, display_string)
|
||||
R_GeoTopologyKindTable:
|
||||
{
|
||||
{Lines "Lines" }
|
||||
{LineStrip "Line Strip" }
|
||||
{Triangles "Triangles" }
|
||||
{TriangleStrip "Triangle Strip" }
|
||||
}
|
||||
|
||||
@table(name, batch, display_string)
|
||||
R_PassKindTable:
|
||||
{
|
||||
{UI 1 "UI" }
|
||||
{Blur 0 "Blur" }
|
||||
{Geo3D 1 "Geo3D" }
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Generators
|
||||
|
||||
@enum R_Tex2DFormat:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_ResourceKind:
|
||||
{
|
||||
@expand(R_ResourceKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_Tex2DSampleKind:
|
||||
{
|
||||
@expand(R_Tex2DSampleKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_GeoTopologyKind:
|
||||
{
|
||||
@expand(R_GeoTopologyKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@enum R_PassKind:
|
||||
{
|
||||
@expand(R_PassKindTable a) `$(a.name)`,
|
||||
COUNT,
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_format_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(U8) r_tex2d_format_bytes_per_pixel_table:
|
||||
{
|
||||
@expand(R_Tex2DFormatTable a) `$(a.bytes_per_pixel)`;
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_kind_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(String8) r_tex2d_sample_kind_display_string_table:
|
||||
{
|
||||
@expand(R_Tex2DSampleKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(String8) r_pass_kind_display_string_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `str8_lit_comp("$(a.display_string)")`;
|
||||
}
|
||||
|
||||
@data(U8) r_pass_kind_batch_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `$(a.batch)`;
|
||||
}
|
||||
|
||||
@data(U64) @c_file r_pass_kind_params_size_table:
|
||||
{
|
||||
@expand(R_PassKindTable a) `sizeof(R_PassParams_$(a.name))`;
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#include "render_core.c"
|
||||
|
||||
#if R_BACKEND == R_BACKEND_STUB
|
||||
# include "stub/render_stub.c"
|
||||
#elif R_BACKEND == R_BACKEND_D3D11
|
||||
# include "d3d11/render_d3d11.c"
|
||||
#else
|
||||
# error Renderer backend not specified.
|
||||
#endif
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#include "render_core.c"
|
||||
|
||||
#if R_BACKEND == R_BACKEND_STUB
|
||||
# include "stub/render_stub.c"
|
||||
#elif R_BACKEND == R_BACKEND_D3D11
|
||||
# include "d3d11/render_d3d11.c"
|
||||
#else
|
||||
# error Renderer backend not specified.
|
||||
#endif
|
||||
|
||||
+36
-36
@@ -1,36 +1,36 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_INC_H
|
||||
#define RENDER_INC_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Constants
|
||||
|
||||
#define R_BACKEND_STUB 0
|
||||
#define R_BACKEND_D3D11 1
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Decide On Backend
|
||||
|
||||
#if !defined(R_BACKEND) && OS_WINDOWS
|
||||
# define R_BACKEND R_BACKEND_D3D11
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Includes
|
||||
|
||||
#include "render_core.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Includes
|
||||
|
||||
#if R_BACKEND == R_BACKEND_STUB
|
||||
# include "stub/render_stub.h"
|
||||
#elif R_BACKEND == R_BACKEND_D3D11
|
||||
# include "d3d11/render_d3d11.h"
|
||||
#else
|
||||
# error Renderer backend not specified.
|
||||
#endif
|
||||
|
||||
#endif // RENDER_INC_H
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_INC_H
|
||||
#define RENDER_INC_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Constants
|
||||
|
||||
#define R_BACKEND_STUB 0
|
||||
#define R_BACKEND_D3D11 1
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Decide On Backend
|
||||
|
||||
#if !defined(R_BACKEND) && OS_WINDOWS
|
||||
# define R_BACKEND R_BACKEND_D3D11
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Main Includes
|
||||
|
||||
#include "render_core.h"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Backend Includes
|
||||
|
||||
#if R_BACKEND == R_BACKEND_STUB
|
||||
# include "stub/render_stub.h"
|
||||
#elif R_BACKEND == R_BACKEND_D3D11
|
||||
# include "d3d11/render_d3d11.h"
|
||||
#else
|
||||
# error Renderer backend not specified.
|
||||
#endif
|
||||
|
||||
#endif // RENDER_INC_H
|
||||
|
||||
+106
-106
@@ -1,106 +1,106 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- rjf: top-level layer initialization
|
||||
|
||||
r_hook void
|
||||
r_init(CmdLine *cmdln)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: window setup/teardown
|
||||
|
||||
r_hook R_Handle
|
||||
r_window_equip(OS_Handle window)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_unequip(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: textures
|
||||
|
||||
r_hook R_Handle
|
||||
r_tex2d_alloc(R_ResourceKind kind, Vec2S32 size, R_Tex2DFormat format, void *data)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_tex2d_release(R_Handle texture)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook R_ResourceKind
|
||||
r_kind_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return R_ResourceStatic;
|
||||
}
|
||||
|
||||
r_hook Vec2S32
|
||||
r_size_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return v2s32(1, 1);
|
||||
}
|
||||
|
||||
r_hook R_Tex2DFormat
|
||||
r_format_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return R_Tex2DFormat_RGBA8;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_fill_tex2d_region(R_Handle texture, Rng2S32 subrect, void *data)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: buffers
|
||||
|
||||
r_hook R_Handle
|
||||
r_buffer_alloc(R_ResourceKind kind, U64 size, void *data)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_buffer_release(R_Handle buffer)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: frame markers
|
||||
|
||||
r_hook void
|
||||
r_begin_frame(void)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_end_frame(void)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_begin_frame(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_end_frame(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: render pass submission
|
||||
|
||||
r_hook void
|
||||
r_window_submit(OS_Handle window, R_Handle window_equip, R_PassList *passes)
|
||||
{
|
||||
}
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- rjf: top-level layer initialization
|
||||
|
||||
r_hook void
|
||||
r_init(CmdLine *cmdln)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: window setup/teardown
|
||||
|
||||
r_hook R_Handle
|
||||
r_window_equip(OS_Handle window)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_unequip(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: textures
|
||||
|
||||
r_hook R_Handle
|
||||
r_tex2d_alloc(R_ResourceKind kind, Vec2S32 size, R_Tex2DFormat format, void *data)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_tex2d_release(R_Handle texture)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook R_ResourceKind
|
||||
r_kind_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return R_ResourceStatic;
|
||||
}
|
||||
|
||||
r_hook Vec2S32
|
||||
r_size_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return v2s32(1, 1);
|
||||
}
|
||||
|
||||
r_hook R_Tex2DFormat
|
||||
r_format_from_tex2d(R_Handle texture)
|
||||
{
|
||||
return R_Tex2DFormat_RGBA8;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_fill_tex2d_region(R_Handle texture, Rng2S32 subrect, void *data)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: buffers
|
||||
|
||||
r_hook R_Handle
|
||||
r_buffer_alloc(R_ResourceKind kind, U64 size, void *data)
|
||||
{
|
||||
R_Handle handle = {0};
|
||||
handle.u64[0] = 1;
|
||||
return handle;
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_buffer_release(R_Handle buffer)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: frame markers
|
||||
|
||||
r_hook void
|
||||
r_begin_frame(void)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_end_frame(void)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_begin_frame(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
r_hook void
|
||||
r_window_end_frame(OS_Handle window, R_Handle window_equip)
|
||||
{
|
||||
}
|
||||
|
||||
//- rjf: render pass submission
|
||||
|
||||
r_hook void
|
||||
r_window_submit(OS_Handle window, R_Handle window_equip, R_PassList *passes)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_STUB_H
|
||||
#define RENDER_STUB_H
|
||||
|
||||
#endif // RENDER_STUB_H
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef RENDER_STUB_H
|
||||
#define RENDER_STUB_H
|
||||
|
||||
#endif // RENDER_STUB_H
|
||||
|
||||
Reference in New Issue
Block a user