45 lines
1.3 KiB
Zig
45 lines
1.3 KiB
Zig
const std = @import("std");
|
|
const vk = @import("vk");
|
|
const GraphicsContext = @import("GraphicsContext.zig");
|
|
|
|
pub const ShaderManager = @This();
|
|
|
|
pub const DescriptorSets = struct {
|
|
const Global = struct {
|
|
pub const UBO = enum(u32) {
|
|
GlobalUniform = 0,
|
|
};
|
|
};
|
|
};
|
|
|
|
pub const DescriptorSetLayouts = struct {
|
|
global: vk.DescriptorSetLayout = .null_handle,
|
|
};
|
|
|
|
gc: *GraphicsContext,
|
|
descriptor_set_layouts: DescriptorSetLayouts = .{},
|
|
|
|
pub fn init(gc: *GraphicsContext) !ShaderManager {
|
|
var self = ShaderManager{
|
|
.gc = gc,
|
|
};
|
|
|
|
// Global Descriptor Set Layout
|
|
{
|
|
const descriptor_set_layout_bindings = [_]vk.DescriptorSetLayoutBinding{
|
|
vk.DescriptorSetLayoutBinding{
|
|
.descriptor_type = .uniform_buffer,
|
|
.binding = DescriptorSets.Global.UBO.GlobalUniform,
|
|
.descriptor_count = 1,
|
|
.stage_flags = vk.ShaderStageFlags.fromInt(0x7FFFFFFF), // SHADER_STAGE_ALL
|
|
},
|
|
};
|
|
self.descriptor_set_layouts.global = try self.gc.device.createDescriptorSetLayout(&.{
|
|
.p_bindings = &descriptor_set_layout_bindings,
|
|
.binding_count = descriptor_set_layout_bindings.len,
|
|
}, null);
|
|
}
|
|
|
|
return self;
|
|
}
|