compiling with vulkan as external library
This commit is contained in:
parent
89d2cb7407
commit
acbfe339ab
Binary file not shown.
@ -1 +1 @@
|
|||||||
Subproject commit c6a92fa58a25fc204198bcd158e170847344d799
|
Subproject commit 7a10601f51b651db006de6d1c5cafb547f90dc87
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import aliases;
|
import aliases;
|
||||||
import includes;
|
import includes;
|
||||||
|
public import vulkan : PlatformHandles;
|
||||||
import vulkan : Destroy;
|
import vulkan : Destroy;
|
||||||
import vulkan;
|
import vulkan;
|
||||||
import assets;
|
import assets;
|
||||||
@ -12,6 +13,8 @@ import std.algorithm.sorting;
|
|||||||
import fonts;
|
import fonts;
|
||||||
import main;
|
import main;
|
||||||
|
|
||||||
|
const UI_COUNT = 50000;
|
||||||
|
|
||||||
f32 g_DELTA;
|
f32 g_DELTA;
|
||||||
|
|
||||||
struct UIVertex
|
struct UIVertex
|
||||||
@ -74,6 +77,8 @@ struct Game
|
|||||||
DescSet ui_desc_set;
|
DescSet ui_desc_set;
|
||||||
PipelineLayout ui_layout;
|
PipelineLayout ui_layout;
|
||||||
|
|
||||||
|
MappedBuffer!(UIVertex) ui_vertex_mapped_buf;
|
||||||
|
MappedBuffer!(u32) ui_index_mapped_buf;
|
||||||
UIVertex[] ui_vertex_buf;
|
UIVertex[] ui_vertex_buf;
|
||||||
u32[] ui_index_buf;
|
u32[] ui_index_buf;
|
||||||
u32 ui_count;
|
u32 ui_count;
|
||||||
@ -95,19 +100,32 @@ struct Game
|
|||||||
Game
|
Game
|
||||||
InitGame(PlatformWindow* window)
|
InitGame(PlatformWindow* window)
|
||||||
{
|
{
|
||||||
|
version(linux)
|
||||||
|
{
|
||||||
|
PlatformHandles handles = {
|
||||||
|
conn: window.conn,
|
||||||
|
window: window.window,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
version(Windows)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Game g = {
|
Game g = {
|
||||||
rd: InitRenderer(window, MB(24), MB(32)),
|
rd: InitRenderer(handles, MB(24), MB(32)),
|
||||||
arena: CreateArena(MB(32)),
|
arena: CreateArena(MB(32)),
|
||||||
frame_arena: CreateArena(MB(16)),
|
frame_arena: CreateArena(MB(16)),
|
||||||
window: window,
|
window: window,
|
||||||
timer: CreateTimer(),
|
timer: CreateTimer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
UVec2 ext = GetExtent(&g.rd);
|
UVec2 ext = UVec2(GetExtent(&g.rd));
|
||||||
|
|
||||||
DescLayoutBinding[2] layout_bindings = [
|
DescLayoutBinding[2] layout_bindings = [
|
||||||
{ binding: 0, descriptorType: VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, descriptorCount: 1, stageFlags: VK_SHADER_STAGE_ALL },
|
{ binding: 0, descriptorType: DT.Image, descriptorCount: 1, stageFlags: SS.All },
|
||||||
{ binding: 1, descriptorType: VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, descriptorCount: 1, stageFlags: VK_SHADER_STAGE_ALL },
|
{ binding: 1, descriptorType: DT.Storage, descriptorCount: 1, stageFlags: SS.All },
|
||||||
];
|
];
|
||||||
|
|
||||||
g.ui_desc_layout = CreateDescSetLayout(&g.rd, layout_bindings);
|
g.ui_desc_layout = CreateDescSetLayout(&g.rd, layout_bindings);
|
||||||
@ -126,21 +144,20 @@ InitGame(PlatformWindow* window)
|
|||||||
];
|
];
|
||||||
|
|
||||||
GfxPipelineInfo ui_info = {
|
GfxPipelineInfo ui_info = {
|
||||||
vertex_shader: "shaders/gui.vert.spv",
|
vertex_shader: LoadAssetData(&g.frame_arena, "shaders/gui.vert.spv"),
|
||||||
frag_shader: "shaders/gui.frag.spv",
|
frag_shader: LoadAssetData(&g.frame_arena, "shaders/gui.frag.spv"),
|
||||||
input_rate: IR.Instance,
|
input_rate: IR.Instance,
|
||||||
input_rate_stride: UIVertex.sizeof,
|
input_rate_stride: UIVertex.sizeof,
|
||||||
layout: g.ui_layout,
|
layout: g.ui_layout,
|
||||||
vertex_attributes: attributes,
|
vertex_attributes: attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
g.ui_pipeline = CreateGraphicsPipeline(&g.rd, &ui_info);
|
assert(CreateGraphicsPipeline(&g.rd, &g.ui_pipeline, &ui_info), "Unable to build UI pipeline");
|
||||||
|
|
||||||
PrintShaderDisassembly(&g.rd, g.ui_pipeline, VK_SHADER_STAGE_VERTEX_BIT);
|
g.ui_vertex_mapped_buf = CreateMappedBuffer!(UIVertex)(&g.rd, BT.Vertex, UIVertex.sizeof * UI_COUNT);
|
||||||
PrintShaderDisassembly(&g.rd, g.ui_pipeline, VK_SHADER_STAGE_FRAGMENT_BIT);
|
g.ui_index_mapped_buf = CreateMappedBuffer!(u32)(&g.rd, BT.Index, u32.sizeof * UI_COUNT);
|
||||||
|
g.ui_vertex_buf = g.ui_vertex_mapped_buf.data;
|
||||||
g.ui_vertex_buf = GetUIVertexBuffer(&g.rd);
|
g.ui_index_buf = g.ui_index_mapped_buf.data;
|
||||||
g.ui_index_buf = GetUIIndexBuffer(&g.rd);
|
|
||||||
|
|
||||||
u8[] font_data = LoadAssetData(&g.arena, "fonts/NuberNextCondensed-DemiBold.otf");
|
u8[] font_data = LoadAssetData(&g.arena, "fonts/NuberNextCondensed-DemiBold.otf");
|
||||||
g.font = OpenFont(font_data);
|
g.font = OpenFont(font_data);
|
||||||
@ -202,7 +219,7 @@ Cycle(Game* g)
|
|||||||
|
|
||||||
BeginFrame(&g.rd);
|
BeginFrame(&g.rd);
|
||||||
|
|
||||||
UVec2 ext = GetExtent(&g.rd);
|
UVec2 ext = UVec2(GetExtent(&g.rd));
|
||||||
g.ui_pc.res.x = cast(f32)ext.x;
|
g.ui_pc.res.x = cast(f32)ext.x;
|
||||||
g.ui_pc.res.y = cast(f32)ext.y;
|
g.ui_pc.res.y = cast(f32)ext.y;
|
||||||
|
|
||||||
@ -212,7 +229,7 @@ Cycle(Game* g)
|
|||||||
|
|
||||||
Bind(&g.rd, g.ui_pipeline, g.ui_desc_set);
|
Bind(&g.rd, g.ui_pipeline, g.ui_desc_set);
|
||||||
|
|
||||||
BindUIBuffers(&g.rd);
|
BindBuffers(&g.rd, &g.ui_index_mapped_buf, &g.ui_vertex_mapped_buf);
|
||||||
|
|
||||||
DrawIndexed(&g.rd, 6, g.ui_count, 0);
|
DrawIndexed(&g.rd, 6, g.ui_count, 0);
|
||||||
|
|
||||||
@ -328,16 +345,12 @@ Sort(Game* g, Vec3 pos, Model* model)
|
|||||||
|
|
||||||
makeIndex!("a < b")(lengths, model.pos_indices);
|
makeIndex!("a < b")(lengths, model.pos_indices);
|
||||||
|
|
||||||
Logf("%s", model.positions.length);
|
|
||||||
|
|
||||||
foreach(i, v; model.pos_indices)
|
foreach(i, v; model.pos_indices)
|
||||||
{
|
{
|
||||||
model.indices[i+0] = cast(u32)((3*v)+0);
|
model.indices[i+0] = cast(u32)((3*v)+0);
|
||||||
model.indices[i+1] = cast(u32)((3*v)+1);
|
model.indices[i+1] = cast(u32)((3*v)+1);
|
||||||
model.indices[i+2] = cast(u32)((3*v)+2);
|
model.indices[i+2] = cast(u32)((3*v)+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateIndexBuffer(&g.rd, model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -20,6 +20,7 @@ void main(string[] argv)
|
|||||||
InitFreeType();
|
InitFreeType();
|
||||||
|
|
||||||
PlatformWindow window = CreateWindow("Video Game", 1920, 1080);
|
PlatformWindow window = CreateWindow("Video Game", 1920, 1080);
|
||||||
|
|
||||||
Game g = InitGame(&window);
|
Game g = InitGame(&window);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
#version 460
|
#version 460
|
||||||
|
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#extension GL_GOOGLE_include_directive : require
|
|
||||||
|
|
||||||
#include "structures.layout"
|
|
||||||
|
|
||||||
layout (constant_id = 0) const int CHANNELS = 3;
|
layout (constant_id = 0) const int CHANNELS = 3;
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,11 @@ struct Vector(T, int N)
|
|||||||
w = f;
|
w = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this(Arr)(Arr arr) if (is(Arr: typeof(v)))
|
||||||
|
{
|
||||||
|
this.v = arr;
|
||||||
|
}
|
||||||
|
|
||||||
this(Args...)(Args args)
|
this(Args...)(Args args)
|
||||||
{
|
{
|
||||||
static if (args.length == 1)
|
static if (args.length == 1)
|
||||||
|
|||||||
@ -653,8 +653,9 @@ MemCpy(void* dst_p, void* src_p, u64 length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
u8[]
|
||||||
MemSet(void* dst, char ch, usize length)
|
Embed(string file_name)
|
||||||
{
|
{
|
||||||
|
import std.file;
|
||||||
|
return cast(u8[])read(file_name);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user