gp -> gpu
This commit is contained in:
parent
52c613263d
commit
9fdd8a32f4
@ -4,7 +4,7 @@
|
||||
#include "../base/base.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../ttf/ttf.h"
|
||||
#include "../gp/gp.h"
|
||||
#include "../gpu/gpu.h"
|
||||
#include "../sim/sim.h"
|
||||
#include "../user/user.h"
|
||||
#include "../sprite/sprite.h"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define DRAW_H
|
||||
|
||||
#include "../base/base.h"
|
||||
#include "../gp/gp.h"
|
||||
#include "../gpu/gpu.h"
|
||||
#include "../sprite/sprite.h"
|
||||
#include "../font/font.h"
|
||||
#include "../collider/collider.h"
|
||||
|
||||
@ -16,9 +16,9 @@ D_StartupReceipt D_Startup(F_StartupReceipt *font_sr)
|
||||
////////////////////////////////
|
||||
//~ Material
|
||||
|
||||
void D_DrawMaterial(G_RenderSig *sig, D_MaterialParams params)
|
||||
void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params)
|
||||
{
|
||||
G_RenderCmdDesc cmd = ZI;
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_DRAW_MATERIAL;
|
||||
cmd.material.xf = params.xf;
|
||||
cmd.material.texture = params.texture;
|
||||
@ -32,9 +32,9 @@ void D_DrawMaterial(G_RenderSig *sig, D_MaterialParams params)
|
||||
////////////////////////////////
|
||||
//~ Solid shapes
|
||||
|
||||
void D_DrawPolyEx(G_RenderSig *sig, Vec2Array vertices, G_Indices indices, u32 color)
|
||||
void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color)
|
||||
{
|
||||
G_RenderCmdDesc cmd = ZI;
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_DRAW_UI_SHAPE;
|
||||
cmd.ui_shape.vertices = vertices;
|
||||
cmd.ui_shape.indices = indices;
|
||||
@ -43,7 +43,7 @@ void D_DrawPolyEx(G_RenderSig *sig, Vec2Array vertices, G_Indices indices, u32 c
|
||||
}
|
||||
|
||||
/* Draws a filled polygon using triangles in a fan pattern */
|
||||
void D_DrawPoly(G_RenderSig *sig, Vec2Array vertices, u32 color)
|
||||
void D_DrawPoly(GPU_RenderSig *sig, Vec2Array vertices, u32 color)
|
||||
{
|
||||
if (vertices.count >= 3)
|
||||
{
|
||||
@ -53,7 +53,7 @@ void D_DrawPoly(G_RenderSig *sig, Vec2Array vertices, u32 color)
|
||||
u32 num_indices = num_tris * 3;
|
||||
|
||||
/* Generate indices in a fan pattern */
|
||||
G_Indices indices = ZI;
|
||||
GPU_Indices indices = ZI;
|
||||
indices.count = num_indices;
|
||||
indices.indices = PushStructsNoZero(scratch.arena, u32, num_indices);
|
||||
for (u32 i = 0; i < num_tris; ++i)
|
||||
@ -70,7 +70,7 @@ void D_DrawPoly(G_RenderSig *sig, Vec2Array vertices, u32 color)
|
||||
}
|
||||
}
|
||||
|
||||
void D_DrawCircle(G_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail)
|
||||
void D_DrawCircle(GPU_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
@ -94,21 +94,21 @@ void D_DrawCircle(G_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail)
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
void D_DrawQuad(G_RenderSig *sig, Quad quad, u32 color)
|
||||
void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color)
|
||||
{
|
||||
LocalPersist u32 indices_array[6] = {
|
||||
0, 1, 2,
|
||||
0, 2, 3
|
||||
};
|
||||
Vec2Array vertices = { .count = 4, .points = quad.e };
|
||||
G_Indices indices = { .count = 6, .indices = indices_array };
|
||||
GPU_Indices indices = { .count = 6, .indices = indices_array };
|
||||
D_DrawPolyEx(sig, vertices, indices, color);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Line shapes
|
||||
|
||||
void D_DrawLineGradient(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color)
|
||||
void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color)
|
||||
{
|
||||
#if 0
|
||||
D_SharedState *g = &D_shared_state;
|
||||
@ -122,19 +122,19 @@ void D_DrawLineGradient(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u
|
||||
#endif
|
||||
}
|
||||
|
||||
void D_DrawLine(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 color)
|
||||
void D_DrawLine(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 color)
|
||||
{
|
||||
Quad quad = QuadFromLine(start, end, thickness);
|
||||
D_DrawQuad(sig, quad, color);
|
||||
}
|
||||
|
||||
void D_DrawRay(G_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, u32 color)
|
||||
void D_DrawRay(GPU_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, u32 color)
|
||||
{
|
||||
Quad quad = QuadFromRay(pos, rel, thickness);
|
||||
D_DrawQuad(sig, quad, color);
|
||||
}
|
||||
|
||||
void D_DrawPolyLine(G_RenderSig *sig, Vec2Array points, b32 loop, f32 thickness, u32 color)
|
||||
void D_DrawPolyLine(GPU_RenderSig *sig, Vec2Array points, b32 loop, f32 thickness, u32 color)
|
||||
{
|
||||
if (points.count >= 2)
|
||||
{
|
||||
@ -155,7 +155,7 @@ void D_DrawPolyLine(G_RenderSig *sig, Vec2Array points, b32 loop, f32 thickness,
|
||||
}
|
||||
}
|
||||
|
||||
void D_DrawCircleLine(G_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32 color, u32 detail)
|
||||
void D_DrawCircleLine(GPU_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32 color, u32 detail)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
@ -179,14 +179,14 @@ void D_DrawCircleLine(G_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
void D_DrawQuadLine(G_RenderSig *sig, Quad quad, f32 thickness, u32 color)
|
||||
void D_DrawQuadLine(GPU_RenderSig *sig, Quad quad, f32 thickness, u32 color)
|
||||
{
|
||||
Vec2 points[] = { quad.p0, quad.p1, quad.p2, quad.p3 };
|
||||
Vec2Array a = { .points = points, .count = countof(points) };
|
||||
D_DrawPolyLine(sig, a, 1, thickness, color);
|
||||
}
|
||||
|
||||
void D_DrawArrowLine(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f32 arrowhead_height, u32 color)
|
||||
void D_DrawArrowLine(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f32 arrowhead_height, u32 color)
|
||||
{
|
||||
const f32 head_width_ratio = 0.5f; /* Width of arrowhead relative to its length */
|
||||
|
||||
@ -216,13 +216,13 @@ void D_DrawArrowLine(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f32
|
||||
D_DrawQuad(sig, line_quad, color);
|
||||
}
|
||||
|
||||
void D_DrawArrowRay(G_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, f32 arrowhead_height, u32 color)
|
||||
void D_DrawArrowRay(GPU_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, f32 arrowhead_height, u32 color)
|
||||
{
|
||||
Vec2 end = AddVec2(pos, rel);
|
||||
D_DrawArrowLine(sig, pos, end, thickness, arrowhead_height, color);
|
||||
}
|
||||
|
||||
void D_DrawColliderLine(G_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail)
|
||||
void D_DrawColliderLine(GPU_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
Vec2Array poly = ZI;
|
||||
@ -255,11 +255,11 @@ void D_DrawColliderLine(G_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 t
|
||||
////////////////////////////////
|
||||
//~ Grid
|
||||
|
||||
void D_DrawGrid(G_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset)
|
||||
void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset)
|
||||
{
|
||||
i32 grid_id = 0;
|
||||
{
|
||||
G_RenderCmdDesc cmd = ZI;
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_PUSH_GRID;
|
||||
cmd.grid.bg0_color = bg0_color;
|
||||
cmd.grid.bg1_color = bg1_color;
|
||||
@ -272,7 +272,7 @@ void D_DrawGrid(G_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 li
|
||||
grid_id = gp_push_render_cmd(sig, &cmd);
|
||||
}
|
||||
|
||||
G_RenderCmdDesc cmd = ZI;
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_DRAW_MATERIAL;
|
||||
cmd.material.xf = xf;
|
||||
cmd.material.tint = ColorWhite;
|
||||
@ -283,9 +283,9 @@ void D_DrawGrid(G_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 li
|
||||
////////////////////////////////
|
||||
//~ Ui
|
||||
|
||||
void D_DrawUiRect(G_RenderSig *sig, D_UiRectParams params)
|
||||
void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params)
|
||||
{
|
||||
G_RenderCmdDesc cmd = ZI;
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_DRAW_UI_RECT;
|
||||
cmd.ui_rect.xf = params.xf;
|
||||
cmd.ui_rect.texture = params.texture;
|
||||
@ -298,7 +298,7 @@ void D_DrawUiRect(G_RenderSig *sig, D_UiRectParams params)
|
||||
//~ Text
|
||||
|
||||
/* Returns the rect of the text area */
|
||||
Rect draw_text(G_RenderSig *sig, D_TextParams params)
|
||||
Rect draw_text(GPU_RenderSig *sig, D_TextParams params)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
Struct(D_MaterialParams)
|
||||
{
|
||||
Xform xf;
|
||||
G_Resource *texture;
|
||||
GPU_Resource *texture;
|
||||
ClipRect clip;
|
||||
u32 tint;
|
||||
b32 is_light;
|
||||
@ -22,7 +22,7 @@ Struct(D_MaterialParams)
|
||||
Struct(D_UiRectParams)
|
||||
{
|
||||
Xform xf;
|
||||
G_Resource *texture;
|
||||
GPU_Resource *texture;
|
||||
ClipRect clip;
|
||||
u32 tint;
|
||||
};
|
||||
@ -103,7 +103,7 @@ Struct(D_TextParams)
|
||||
|
||||
Struct(D_SharedState)
|
||||
{
|
||||
G_Resource *solid_white_texture;
|
||||
GPU_Resource *solid_white_texture;
|
||||
};
|
||||
|
||||
extern D_SharedState D_shared_state;
|
||||
@ -117,40 +117,40 @@ D_StartupReceipt D_Startup(F_StartupReceipt *font_sr);
|
||||
////////////////////////////////
|
||||
//~ Material operations
|
||||
|
||||
void D_DrawMaterial(G_RenderSig *sig, D_MaterialParams params);
|
||||
void D_DrawMaterial(GPU_RenderSig *sig, D_MaterialParams params);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Solid shape operations
|
||||
|
||||
void D_DrawPolyEx(G_RenderSig *sig, Vec2Array vertices, G_Indices indices, u32 color);
|
||||
void D_DrawPoly(G_RenderSig *sig, Vec2Array points, u32 color);
|
||||
void D_DrawCircle(G_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail);
|
||||
void D_DrawQuad(G_RenderSig *sig, Quad quad, u32 color);
|
||||
void D_DrawPolyEx(GPU_RenderSig *sig, Vec2Array vertices, GPU_Indices indices, u32 color);
|
||||
void D_DrawPoly(GPU_RenderSig *sig, Vec2Array points, u32 color);
|
||||
void D_DrawCircle(GPU_RenderSig *sig, Vec2 pos, f32 radius, u32 color, u32 detail);
|
||||
void D_DrawQuad(GPU_RenderSig *sig, Quad quad, u32 color);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Line shape operations
|
||||
|
||||
void D_DrawLineGradient(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color);
|
||||
void D_DrawLine(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 color);
|
||||
void D_DrawRay(G_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, u32 color);
|
||||
void D_DrawPolyLine(G_RenderSig *sig, Vec2Array points, b32 loop, f32 thickness, u32 color);
|
||||
void D_DrawCircleLine(G_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32 color, u32 detail);
|
||||
void D_DrawQuadLine(G_RenderSig *sig, Quad quad, f32 thickness, u32 color);
|
||||
void D_DrawArrowLine(G_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f32 arrowhead_height, u32 color);
|
||||
void D_DrawArrowRay(G_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, f32 arrowhead_height, u32 color);
|
||||
void D_DrawColliderLine(G_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail);
|
||||
void D_DrawLineGradient(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 start_color, u32 end_color);
|
||||
void D_DrawLine(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, u32 color);
|
||||
void D_DrawRay(GPU_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, u32 color);
|
||||
void D_DrawPolyLine(GPU_RenderSig *sig, Vec2Array points, b32 loop, f32 thickness, u32 color);
|
||||
void D_DrawCircleLine(GPU_RenderSig *sig, Vec2 pos, f32 radius, f32 thickness, u32 color, u32 detail);
|
||||
void D_DrawQuadLine(GPU_RenderSig *sig, Quad quad, f32 thickness, u32 color);
|
||||
void D_DrawArrowLine(GPU_RenderSig *sig, Vec2 start, Vec2 end, f32 thickness, f32 arrowhead_height, u32 color);
|
||||
void D_DrawArrowRay(GPU_RenderSig *sig, Vec2 pos, Vec2 rel, f32 thickness, f32 arrowhead_height, u32 color);
|
||||
void D_DrawColliderLine(GPU_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 thickness, u32 color, u32 detail);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Grid operations
|
||||
|
||||
void D_DrawGrid(G_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset);
|
||||
void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 line_color, u32 x_color, u32 y_color, f32 thickness, f32 spacing, Vec2 offset);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Ui operations
|
||||
|
||||
void D_DrawUiRect(G_RenderSig *sig, D_UiRectParams params);
|
||||
void D_DrawUiRect(GPU_RenderSig *sig, D_UiRectParams params);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Text operations
|
||||
|
||||
Rect draw_text(G_RenderSig *sig, D_TextParams params);
|
||||
Rect draw_text(GPU_RenderSig *sig, D_TextParams params);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../base/base.h"
|
||||
#include "../ttf/ttf.h"
|
||||
#include "../gp/gp.h"
|
||||
#include "../gpu/gpu.h"
|
||||
#include "../resource/resource.h"
|
||||
#include "../asset_cache/asset_cache.h"
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ P_JobDef(F_LoadAssetJob, job)
|
||||
RES_CloseResource(&res);
|
||||
|
||||
/* Send texture to GPU */
|
||||
G_Resource *texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(result.image_width, result.image_height), result.image_pixels);
|
||||
GPU_Resource *texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, VEC2I32(result.image_width, result.image_height), result.image_pixels);
|
||||
|
||||
/* Allocate store memory */
|
||||
F_Font *font = 0;
|
||||
|
||||
@ -11,7 +11,7 @@ Struct(F_Glyph) {
|
||||
};
|
||||
|
||||
Struct(F_Font) {
|
||||
G_Resource *texture;
|
||||
GPU_Resource *texture;
|
||||
u32 image_width;
|
||||
u32 image_height;
|
||||
f32 point_size;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#include "gp.h"
|
||||
#include "gpu.h"
|
||||
|
||||
#include "../kernel/kernel.h"
|
||||
|
||||
#if PlatformIsWindows
|
||||
# include "gp_core_dx12.c"
|
||||
# include "gpu_core_dx12.c"
|
||||
#else
|
||||
# error Gp core not implemented for this platform
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef GP_H
|
||||
#define GP_H
|
||||
#ifndef GPU_H
|
||||
#define GPU_H
|
||||
|
||||
#include "../base/base.h"
|
||||
#include "../platform/platform.h"
|
||||
@ -10,6 +10,6 @@
|
||||
#include "../resource/resource.h"
|
||||
#include "../watch/watch.h"
|
||||
|
||||
#include "gp_core.h"
|
||||
#include "gpu_core.h"
|
||||
|
||||
#endif
|
||||
@ -1,20 +1,20 @@
|
||||
////////////////////////////////
|
||||
//~ Opaque types
|
||||
|
||||
Struct(G_Resource);
|
||||
Struct(G_RenderSig);
|
||||
Struct(G_Swapchain);
|
||||
Struct(GPU_Resource);
|
||||
Struct(GPU_RenderSig);
|
||||
Struct(GPU_Swapchain);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Render
|
||||
|
||||
Struct(G_Indices)
|
||||
Struct(GPU_Indices)
|
||||
{
|
||||
u32 count;
|
||||
u32 *indices;
|
||||
};
|
||||
|
||||
typedef i32 G_RenderCmdKind; enum
|
||||
typedef i32 GPU_RenderCmdKind; enum
|
||||
{
|
||||
GP_RENDER_CMD_KIND_NONE,
|
||||
GP_RENDER_CMD_KIND_DRAW_MATERIAL,
|
||||
@ -25,15 +25,15 @@ typedef i32 G_RenderCmdKind; enum
|
||||
NUM_GP_RENDER_CMD_KINDS
|
||||
};
|
||||
|
||||
Struct(G_RenderCmdDesc)
|
||||
Struct(GPU_RenderCmdDesc)
|
||||
{
|
||||
G_RenderCmdKind kind;
|
||||
GPU_RenderCmdKind kind;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
Xform xf;
|
||||
G_Resource *texture;
|
||||
GPU_Resource *texture;
|
||||
ClipRect clip;
|
||||
u32 tint;
|
||||
b32 is_light;
|
||||
@ -43,14 +43,14 @@ Struct(G_RenderCmdDesc)
|
||||
struct
|
||||
{
|
||||
Xform xf;
|
||||
G_Resource *texture;
|
||||
GPU_Resource *texture;
|
||||
ClipRect clip;
|
||||
u32 tint;
|
||||
} ui_rect;
|
||||
struct
|
||||
{
|
||||
Vec2Array vertices;
|
||||
G_Indices indices;
|
||||
GPU_Indices indices;
|
||||
u32 color;
|
||||
} ui_shape;
|
||||
struct
|
||||
@ -67,7 +67,7 @@ Struct(G_RenderCmdDesc)
|
||||
};
|
||||
};
|
||||
|
||||
Struct(G_RenderParams)
|
||||
Struct(GPU_RenderParams)
|
||||
{
|
||||
Vec2I32 ui_size;
|
||||
Vec2I32 render_size;
|
||||
@ -79,7 +79,7 @@ Struct(G_RenderParams)
|
||||
////////////////////////////////
|
||||
//~ Texture
|
||||
|
||||
typedef i32 G_TextureFormat; enum
|
||||
typedef i32 GPU_TextureFormat; enum
|
||||
{
|
||||
GP_TEXTURE_FORMAT_NONE,
|
||||
GP_TEXTURE_FORMAT_R8_UNORM,
|
||||
@ -90,7 +90,7 @@ typedef i32 G_TextureFormat; enum
|
||||
NUM_GP_TEXTURE_FORMATS
|
||||
};
|
||||
|
||||
typedef i32 G_TextureFlag; enum
|
||||
typedef i32 GPU_TextureFlag; enum
|
||||
{
|
||||
GP_TEXTURE_FLAG_NONE = 0,
|
||||
GP_TEXTURE_FLAG_TARGETABLE = (1 << 0)
|
||||
@ -99,7 +99,7 @@ typedef i32 G_TextureFlag; enum
|
||||
////////////////////////////////
|
||||
//~ Memory info
|
||||
|
||||
Struct(G_MemoryInfo)
|
||||
Struct(GPU_MemoryInfo)
|
||||
{
|
||||
u64 local_used;
|
||||
u64 local_budget;
|
||||
@ -120,40 +120,40 @@ void gp_startup(void);
|
||||
* the caller to make sure the released resources aren't then referenced in
|
||||
* any runs
|
||||
*/
|
||||
void gp_resource_release(G_Resource *resource);
|
||||
void gp_resource_release(GPU_Resource *resource);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Texture operations
|
||||
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, Vec2I32 size, void *initial_data);
|
||||
GPU_Resource *gp_texture_alloc(GPU_TextureFormat format, u32 flags, Vec2I32 size, void *initial_data);
|
||||
|
||||
Vec2I32 gp_texture_get_size(G_Resource *texture);
|
||||
Vec2I32 gp_texture_get_size(GPU_Resource *texture);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Render operations
|
||||
|
||||
G_RenderSig *gp_render_sig_alloc(void);
|
||||
GPU_RenderSig *gp_render_sig_alloc(void);
|
||||
|
||||
/* Returns a cmd id internal to the sig */
|
||||
u32 gp_push_render_cmd(G_RenderSig *render_sig, G_RenderCmdDesc *desc);
|
||||
u32 gp_push_render_cmd(GPU_RenderSig *render_sig, GPU_RenderCmdDesc *desc);
|
||||
|
||||
G_Resource *gp_run_render(G_RenderSig *gp_render_sig, G_RenderParams render_params);
|
||||
GPU_Resource *gp_run_render(GPU_RenderSig *gp_render_sig, GPU_RenderParams render_params);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Memory query
|
||||
|
||||
G_MemoryInfo gp_query_memory_info(void);
|
||||
GPU_MemoryInfo gp_query_memory_info(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Swapchain
|
||||
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, Vec2I32 resolution);
|
||||
GPU_Swapchain *gp_swapchain_alloc(P_Window *window, Vec2I32 resolution);
|
||||
|
||||
void gp_swapchain_release(G_Swapchain *gp_swapchain);
|
||||
void gp_swapchain_release(GPU_Swapchain *gp_swapchain);
|
||||
|
||||
/* Waits until a new backbuffer is ready to be written to.
|
||||
* This should be called before rendering for minimum latency. */
|
||||
void gp_swapchain_wait(G_Swapchain *gp_swapchain);
|
||||
void gp_swapchain_wait(GPU_Swapchain *gp_swapchain);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Present
|
||||
@ -161,4 +161,4 @@ void gp_swapchain_wait(G_Swapchain *gp_swapchain);
|
||||
/* 1. Clears the backbuffer and ensures it's at size `backbuffer_resolution`
|
||||
* 2. Blits `texture` to the backbuffer using `texture_xf`
|
||||
* 3. Presents the backbuffer */
|
||||
void gp_present(G_Swapchain *gp_swapchain, Vec2I32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync);
|
||||
void gp_present(GPU_Swapchain *gp_swapchain, Vec2I32 backbuffer_resolution, GPU_Resource *texture, Xform texture_xf, i32 vsync);
|
||||
@ -1668,7 +1668,7 @@ internal void dx12_resource_release_now(struct dx12_resource *t)
|
||||
P_Unlock(&lock);
|
||||
}
|
||||
|
||||
void gp_resource_release(G_Resource *resource)
|
||||
void gp_resource_release(GPU_Resource *resource)
|
||||
{
|
||||
struct dx12_resource *r = (struct dx12_resource *)resource;
|
||||
fenced_release(r, FENCED_RELEASE_KIND_RESOURCE);
|
||||
@ -2209,7 +2209,7 @@ internal P_JobDef(dx12_wait_fence_job, job)
|
||||
* Texture
|
||||
* ========================== */
|
||||
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, Vec2I32 size, void *initial_data)
|
||||
GPU_Resource *gp_texture_alloc(GPU_TextureFormat format, u32 flags, Vec2I32 size, void *initial_data)
|
||||
{
|
||||
__prof;
|
||||
if (size.x <= 0 || size.y <= 0) {
|
||||
@ -2273,10 +2273,10 @@ G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, Vec2I32 size, vo
|
||||
P_WaitOnCounter(&counter);
|
||||
}
|
||||
|
||||
return (G_Resource *)r;
|
||||
return (GPU_Resource *)r;
|
||||
}
|
||||
|
||||
Vec2I32 gp_texture_get_size(G_Resource *resource)
|
||||
Vec2I32 gp_texture_get_size(GPU_Resource *resource)
|
||||
{
|
||||
struct dx12_resource *r = (struct dx12_resource *)resource;
|
||||
return r->texture_size;
|
||||
@ -2615,14 +2615,14 @@ internal void render_sig_reset(struct render_sig *sig)
|
||||
ResetArena(sig->material_grid_descs_arena);
|
||||
}
|
||||
|
||||
G_RenderSig *gp_render_sig_alloc(void)
|
||||
GPU_RenderSig *gp_render_sig_alloc(void)
|
||||
{
|
||||
__prof;
|
||||
struct render_sig *sig = render_sig_alloc();
|
||||
return (G_RenderSig *)sig;
|
||||
return (GPU_RenderSig *)sig;
|
||||
}
|
||||
|
||||
u32 gp_push_render_cmd(G_RenderSig *render_sig, G_RenderCmdDesc *cmd_desc)
|
||||
u32 gp_push_render_cmd(GPU_RenderSig *render_sig, GPU_RenderCmdDesc *cmd_desc)
|
||||
{
|
||||
u32 ret = 0;
|
||||
struct render_sig *sig = (struct render_sig *)render_sig;
|
||||
@ -2693,7 +2693,7 @@ u32 gp_push_render_cmd(G_RenderSig *render_sig, G_RenderCmdDesc *cmd_desc)
|
||||
* Render
|
||||
* ========================== */
|
||||
|
||||
G_Resource *gp_run_render(G_RenderSig *gp_render_sig, G_RenderParams params)
|
||||
GPU_Resource *gp_run_render(GPU_RenderSig *gp_render_sig, GPU_RenderParams params)
|
||||
{
|
||||
__prof;
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
@ -3149,16 +3149,16 @@ G_Resource *gp_run_render(G_RenderSig *gp_render_sig, G_RenderParams params)
|
||||
render_sig_reset(rsig);
|
||||
EndScratch(scratch);
|
||||
|
||||
return (G_Resource *)rsig->ui_target;
|
||||
return (GPU_Resource *)rsig->ui_target;
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
* Memory info
|
||||
* ========================== */
|
||||
|
||||
G_MemoryInfo gp_query_memory_info(void)
|
||||
GPU_MemoryInfo gp_query_memory_info(void)
|
||||
{
|
||||
G_MemoryInfo result = ZI;
|
||||
GPU_MemoryInfo result = ZI;
|
||||
|
||||
HRESULT hr = 0;
|
||||
IDXGIAdapter3 *dxgiAdapter3 = 0;
|
||||
@ -3206,7 +3206,7 @@ internal void swapchain_init_resources(struct swapchain *swapchain)
|
||||
}
|
||||
}
|
||||
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, Vec2I32 resolution)
|
||||
GPU_Swapchain *gp_swapchain_alloc(P_Window *window, Vec2I32 resolution)
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
HWND hwnd = (HWND)P_GetInternalWindowHandle(window);
|
||||
@ -3266,16 +3266,16 @@ G_Swapchain *gp_swapchain_alloc(P_Window *window, Vec2I32 resolution)
|
||||
|
||||
swapchain_init_resources(swapchain);
|
||||
|
||||
return (G_Swapchain *)swapchain;
|
||||
return (GPU_Swapchain *)swapchain;
|
||||
}
|
||||
|
||||
void gp_swapchain_release(G_Swapchain *gp_swapchain)
|
||||
void gp_swapchain_release(GPU_Swapchain *gp_swapchain)
|
||||
{
|
||||
/* TODO */
|
||||
(UNUSED)gp_swapchain;
|
||||
}
|
||||
|
||||
void gp_swapchain_wait(G_Swapchain *gp_swapchain)
|
||||
void gp_swapchain_wait(GPU_Swapchain *gp_swapchain)
|
||||
{
|
||||
#if DX12_WAIT_FRAME_LATENCY > 0
|
||||
struct swapchain *swapchain = (struct swapchain *)gp_swapchain;
|
||||
@ -3439,7 +3439,7 @@ internal void present_blit(struct swapchain_buffer *dst, struct dx12_resource *s
|
||||
pipeline_scope_end(pipeline_scope);
|
||||
}
|
||||
|
||||
void gp_present(G_Swapchain *gp_swapchain, Vec2I32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync)
|
||||
void gp_present(GPU_Swapchain *gp_swapchain, Vec2I32 backbuffer_resolution, GPU_Resource *texture, Xform texture_xf, i32 vsync)
|
||||
{
|
||||
__prof;
|
||||
struct swapchain *swapchain = (struct swapchain *)gp_swapchain;
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../base/base.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../gp/gp.h"
|
||||
#include "../gpu/gpu.h"
|
||||
#include "../ase/ase.h"
|
||||
#include "../resource/resource.h"
|
||||
#include "../watch/watch.h"
|
||||
|
||||
@ -45,7 +45,7 @@ typedef struct S_Texture S_Texture;
|
||||
struct S_Texture {
|
||||
b32 loaded;
|
||||
b32 valid;
|
||||
G_Resource *gp_texture;
|
||||
GPU_Resource *gp_texture;
|
||||
u32 width;
|
||||
u32 height;
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../base/base.h"
|
||||
#include "../sim/sim.h"
|
||||
#include "../gp/gp.h"
|
||||
#include "../gpu/gpu.h"
|
||||
#include "../sprite/sprite.h"
|
||||
#include "../font/font.h"
|
||||
#include "../collider/collider.h"
|
||||
|
||||
@ -27,7 +27,7 @@ Global struct {
|
||||
Atomic32 shutdown;
|
||||
P_Counter shutdown_job_counters;
|
||||
P_Window *window;
|
||||
G_Swapchain *swapchain;
|
||||
GPU_Swapchain *swapchain;
|
||||
|
||||
struct sim_ctx *local_sim_ctx;
|
||||
|
||||
@ -45,7 +45,7 @@ Global struct {
|
||||
struct second_stat net_bytes_sent;
|
||||
|
||||
/* Gpu resources */
|
||||
G_RenderSig *render_sig;
|
||||
GPU_RenderSig *render_sig;
|
||||
|
||||
struct bind_state bind_states[USER_BIND_KIND_COUNT];
|
||||
|
||||
@ -1917,7 +1917,7 @@ internal void user_update(P_Window *window)
|
||||
* Query vram
|
||||
* ========================== */
|
||||
|
||||
G_MemoryInfo vram = gp_query_memory_info();
|
||||
GPU_MemoryInfo vram = gp_query_memory_info();
|
||||
|
||||
/* ========================== *
|
||||
* Draw global debug info
|
||||
@ -2055,9 +2055,9 @@ internal void user_update(P_Window *window)
|
||||
Vec2I32 backbuffer_resolution = RoundVec2ToVec2I32(G.screen_size);
|
||||
|
||||
/* Draw world to user texture */
|
||||
G_Resource *render_texture = 0;
|
||||
GPU_Resource *render_texture = 0;
|
||||
{
|
||||
G_RenderParams params = ZI;
|
||||
GPU_RenderParams params = ZI;
|
||||
params.ui_size = user_resolution;
|
||||
params.render_size = world_resolution;
|
||||
params.world_to_render_xf = G.world_to_render_xf;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user