renderer-mvp/refactor-tech #50

Merged
kayomn merged 3 commits from renderer-mvp/refactor-tech into main 2024-06-05 00:12:26 +02:00
2 changed files with 12 additions and 12 deletions
Showing only changes of commit 26094a04e8 - Show all commits

View File

@ -2,8 +2,6 @@ const Queue = @import("./Queue.zig");
const coral = @import("coral");
const draw_2d = @import("./shaders/draw_2d.glsl.zig");
const ext = @import("../ext.zig");
const gfx = @import("../gfx.zig");
@ -49,6 +47,8 @@ const Render = struct {
};
const instances_per_buffer = 512;
const shader = @import("./shaders/instance_2d.glsl.zig");
};
const Resource = union (enum) {
@ -101,42 +101,42 @@ const Render = struct {
.attrs = get: {
var attrs = [_]sokol.gfx.VertexAttrState{.{}} ** 16;
attrs[draw_2d.ATTR_vs_mesh_xy] = .{
attrs[Instance2D.shader.ATTR_vs_mesh_xy] = .{
.format = .FLOAT2,
.buffer_index = Instance2D.buffer_indices.mesh,
};
attrs[draw_2d.ATTR_vs_mesh_uv] = .{
attrs[Instance2D.shader.ATTR_vs_mesh_uv] = .{
.format = .FLOAT2,
.buffer_index = Instance2D.buffer_indices.mesh,
};
attrs[draw_2d.ATTR_vs_instance_xbasis] = .{
attrs[Instance2D.shader.ATTR_vs_instance_xbasis] = .{
.format = .FLOAT2,
.buffer_index = Instance2D.buffer_indices.instance,
};
attrs[draw_2d.ATTR_vs_instance_ybasis] = .{
attrs[Instance2D.shader.ATTR_vs_instance_ybasis] = .{
.format = .FLOAT2,
.buffer_index = Instance2D.buffer_indices.instance,
};
attrs[draw_2d.ATTR_vs_instance_origin] = .{
attrs[Instance2D.shader.ATTR_vs_instance_origin] = .{
.format = .FLOAT2,
.buffer_index = Instance2D.buffer_indices.instance,
};
attrs[draw_2d.ATTR_vs_instance_tint] = .{
attrs[Instance2D.shader.ATTR_vs_instance_tint] = .{
.format = .UBYTE4N,
.buffer_index = Instance2D.buffer_indices.instance,
};
attrs[draw_2d.ATTR_vs_instance_depth] = .{
attrs[Instance2D.shader.ATTR_vs_instance_depth] = .{
.format = .FLOAT,
.buffer_index = Instance2D.buffer_indices.instance,
};
attrs[draw_2d.ATTR_vs_instance_rect] = .{
attrs[Instance2D.shader.ATTR_vs_instance_rect] = .{
.format = .FLOAT4,
.buffer_index = Instance2D.buffer_indices.instance,
};
@ -153,7 +153,7 @@ const Render = struct {
},
},
.shader = sokol.gfx.makeShader(draw_2d.draw2dShaderDesc(sokol.gfx.queryBackend())),
.shader = sokol.gfx.makeShader(Instance2D.shader.draw2dShaderDesc(sokol.gfx.queryBackend())),
.index_type = .UINT16,
}),
@ -195,7 +195,7 @@ const Render = struct {
sokol.gfx.applyPipeline(self.instance_2d_pipeline);
sokol.gfx.applyUniforms(.VS, draw_2d.SLOT_Screen, sokol.gfx.asRange(&draw_2d.Screen{
sokol.gfx.applyUniforms(.VS, Instance2D.shader.SLOT_Screen, sokol.gfx.asRange(&Instance2D.shader.Screen{
.screen_size = .{@floatFromInt(frame.width), @floatFromInt(frame.height)},
}));