fixing shader execution
This commit is contained in:
@@ -4,8 +4,8 @@ const spv = @import("spv");
|
||||
|
||||
const shader_source = @embedFile("shader.spv");
|
||||
|
||||
const screen_width = 200;
|
||||
const screen_height = 200;
|
||||
const screen_width = 480;
|
||||
const screen_height = 240;
|
||||
|
||||
pub fn main() !void {
|
||||
{
|
||||
@@ -50,9 +50,7 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
var thread_pool: std.Thread.Pool = undefined;
|
||||
try thread_pool.init(.{
|
||||
.allocator = allocator,
|
||||
});
|
||||
try thread_pool.init(.{ .allocator = allocator });
|
||||
|
||||
var timer = try std.time.Timer.start();
|
||||
|
||||
@@ -73,15 +71,15 @@ pub fn main() !void {
|
||||
|
||||
const pixel_map: [*]u32 = @as([*]u32, @ptrCast(@alignCast((surface.getPixels() orelse return).ptr)));
|
||||
|
||||
const delta: f32 = @as(f32, @floatFromInt(timer.read())) / std.time.ns_per_s;
|
||||
|
||||
var frame_timer = try std.time.Timer.start();
|
||||
defer {
|
||||
const ns = frame_timer.lap();
|
||||
const ms = @as(f32, @floatFromInt(ns)) / std.time.ns_per_s;
|
||||
std.log.info("Took {d:.3}s - {d:.3}fps to render", .{ ms, 1.0 / ms });
|
||||
std.log.info("Took {d:.3}s - {d:.3}fps to render {d:.2}", .{ ms, 1.0 / ms, delta });
|
||||
}
|
||||
|
||||
const delta: f32 = @as(f32, @floatFromInt(timer.read())) / std.time.ns_per_s;
|
||||
|
||||
var wait_group: std.Thread.WaitGroup = .{};
|
||||
for (0..screen_height) |y| {
|
||||
const runner = &runner_cache.items[y];
|
||||
@@ -131,10 +129,10 @@ const Runner = struct {
|
||||
try rt.readOutput(f32, output[0..], self.color);
|
||||
|
||||
const rgba = self.surface.mapRgba(
|
||||
@truncate(@as(u32, @intFromFloat(output[0] * 255.0))),
|
||||
@truncate(@as(u32, @intFromFloat(output[1] * 255.0))),
|
||||
@truncate(@as(u32, @intFromFloat(output[2] * 255.0))),
|
||||
@truncate(@as(u32, @intFromFloat(output[3] * 255.0))),
|
||||
@intCast(@max(@min(@as(i32, @intFromFloat(output[0] * 255.0)), 255), 0)),
|
||||
@intCast(@max(@min(@as(i32, @intFromFloat(output[1] * 255.0)), 255), 0)),
|
||||
@intCast(@max(@min(@as(i32, @intFromFloat(output[2] * 255.0)), 255), 0)),
|
||||
@intCast(@max(@min(@as(i32, @intFromFloat(output[3] * 255.0)), 255), 0)),
|
||||
);
|
||||
|
||||
pixel_map[(y * self.surface.getWidth()) + x] = rgba.value;
|
||||
|
||||
6
example/mangohud.conf
git.filemode.normal_file
6
example/mangohud.conf
git.filemode.normal_file
@@ -0,0 +1,6 @@
|
||||
gpu_stats=0
|
||||
font_size=16
|
||||
resolution
|
||||
hud_compact
|
||||
background_alpha=0
|
||||
width=140
|
||||
@@ -16,16 +16,16 @@ struct FragOut
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
const I: i32 = 32;
|
||||
const I: i32 = 128;
|
||||
const A: f32 = 7.5;
|
||||
const MA: f32 = 20.0;
|
||||
const MA: f32 = 100.0;
|
||||
const MI: f32 = 0.001;
|
||||
|
||||
let uv0 = input.pos / input.res * 2.0 - vec2[f32](1.0, 1.0);
|
||||
let uv = vec2[f32](uv0.x * (input.res.x / input.res.y), uv0.y);
|
||||
|
||||
let col = vec3[f32](0.0, 0.0, 0.0);
|
||||
let ro = vec3[f32](0.0, 0.0, -2.0);
|
||||
let col = vec3[f32](0.0, 0.0, 0.0);
|
||||
let ro = vec3[f32](0.0, 0.0, -2.0);
|
||||
let rd = vec3[f32](uv.x, uv.y, 1.0);
|
||||
let dt = 0.0;
|
||||
let ds = 0.0;
|
||||
|
||||
Binary file not shown.
@@ -55,11 +55,11 @@ Schema: 0
|
||||
%29 = OpConstant %3 f32(0.2)
|
||||
%30 = OpConstant %3 f32(4)
|
||||
%31 = OpTypePointer StorageClass(Function) %6
|
||||
%32 = OpConstant %6 i32(32)
|
||||
%32 = OpConstant %6 i32(128)
|
||||
%33 = OpTypeBool
|
||||
%34 = OpConstant %3 f32(0.001)
|
||||
%35 = OpConstant %3 f32(0.35)
|
||||
%36 = OpConstant %3 f32(20)
|
||||
%36 = OpConstant %3 f32(100)
|
||||
%37 = OpConstant %3 f32(0.15)
|
||||
%38 = OpConstant %3 f32(0.05)
|
||||
%39 = OpConstant %3 f32(1.15)
|
||||
|
||||
Reference in New Issue
Block a user