finish vulkan init (outside of description)
This commit is contained in:
parent
f9cf8e26ab
commit
77ce53d4f1
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
dub.json
2
dub.json
@ -16,7 +16,7 @@
|
||||
"versions": ["VULKAN_DEBUG"],
|
||||
"preGenerateCommands-linux": ["./build.sh"],
|
||||
"preGenerateCommands-windows": [],
|
||||
"dflags": ["-Xcc=-mno-sse", "-P-I/usr/include/freetype2", "-vgc", "-Jbuild", "-Jassets/fonts"],
|
||||
"dflags": ["-Xcc=-mno-sse", "-P-I/usr/include/freetype2", "-Jbuild", "-Jassets/fonts"],
|
||||
"dflags-dmd": ["-P=-DSTBI_NO_SIMD"]
|
||||
},
|
||||
{
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 53c500c302e87799b01bb99356780c9c51b41170
|
||||
Subproject commit 1b4d9979765ca8a1c1f45ddf8420edc93d1b79dc
|
||||
@ -14,12 +14,28 @@ struct RenderState
|
||||
{
|
||||
Renderer rd;
|
||||
Arena[2] frame_arenas;
|
||||
|
||||
PushConst pc;
|
||||
ShaderGlobals globals;
|
||||
|
||||
Pipeline pipeline_pbr;
|
||||
DescSetLayout desc_layout_globals;
|
||||
DescSetLayout desc_layout_resources;
|
||||
DescSet[2] desc_set_globals;
|
||||
DescSet[2] desc_set_resources;
|
||||
PipelineLayout pipeline_layout_pbr;
|
||||
|
||||
ImageView placeholder_tex;
|
||||
Buffer globals_buffer;
|
||||
}
|
||||
|
||||
struct ShaderGlobals
|
||||
{
|
||||
Vec4 ambient;
|
||||
Vec4 diffuse;
|
||||
Vec4 specular;
|
||||
f32 shininess = 0.0;
|
||||
f32 alpha = 0.0;
|
||||
}
|
||||
|
||||
struct PushConst
|
||||
@ -76,7 +92,7 @@ Init(RenderState* rds, PlatformWindow* window)
|
||||
};
|
||||
}
|
||||
|
||||
DescLayoutBinding[5] global_bindings = [
|
||||
DescLayoutBinding[3] global_bindings = [
|
||||
{ binding: 0, descriptorType: DT.Uniform, descriptorCount: 1, stageFlags: SS.All },
|
||||
{ binding: 1, descriptorType: DT.StorageTexelBuf, descriptorCount: 1, stageFlags: SS.All },
|
||||
{ binding: 2, descriptorType: DT.StorageImage, descriptorCount: 1, stageFlags: SS.All },
|
||||
@ -124,4 +140,24 @@ Init(RenderState* rds, PlatformWindow* window)
|
||||
|
||||
bool result = CreateGraphicsPipeline(&rds.rd, &rds.pipeline_pbr, &pbr_info);
|
||||
assert(result);
|
||||
|
||||
const u64 tex_size = 32*32*4;
|
||||
u8[tex_size] placeholder_tex;
|
||||
|
||||
u8[4] magenta = [255, 0, 255, 255];
|
||||
u8[4] black = [0, 0, 0, 255];
|
||||
u64 half = tex_size/2;
|
||||
for(u64 i = 0; i < tex_size; i += 32)
|
||||
{
|
||||
bool swap = i <= half;
|
||||
for(u64 j = 0; j < 16; j += 4)
|
||||
{
|
||||
placeholder_tex[i+j .. i+j+4] = !swap ? magenta[0 .. $] : black[0 .. $];
|
||||
placeholder_tex[i+j+16 .. i+j+16+4] = !swap ? black[0 .. $] : magenta[0 .. $];
|
||||
}
|
||||
}
|
||||
|
||||
CreateImageView(&rds.rd, &rds.placeholder_tex, 32, 32, 4, placeholder_tex);
|
||||
|
||||
CreateBuffer(&rds.rd, &rds.globals_buffer, BT.Uniform, ShaderGlobals.sizeof, false);
|
||||
}
|
||||
|
||||
@ -32,25 +32,21 @@ layout (set = 1, binding = 0) uniform Globals {
|
||||
|
||||
layout (set = 1, binding = 1, rg32ui) uniform coherent uimageBuffer ImageABuffer;
|
||||
|
||||
layout (set = 2, binding = 2, r32ui) uniform coherent uimage2D ImageAux;
|
||||
layout (set = 1, binding = 2, r32ui) uniform coherent uimage2D ImageAux;
|
||||
|
||||
// SET 2
|
||||
|
||||
layout (set = 1, binding = 0) uniform texture2D Textures[IMG_MAX];
|
||||
layout (set = 2, binding = 0) uniform texture2D Textures[IMG_MAX];
|
||||
|
||||
layout (set = 1, binding = 1) uniform Material {
|
||||
vec4 ambient;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
bool albedo_has_texture;
|
||||
bool ambient_has_texture;
|
||||
bool specular_has_texture;
|
||||
bool alpha_has_texture;
|
||||
layout (set = 2, binding = 1) uniform Material {
|
||||
vec4 ambient;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
float shininess;
|
||||
float alpha;
|
||||
} Materials[BUF_MAX];
|
||||
|
||||
layout (set = 1, binding = 2) uniform ModelState {
|
||||
layout (set = 2, binding = 2) uniform ModelState {
|
||||
mat4 model_matrix;
|
||||
} State[UNI_MAX];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user