mirror of
https://github.com/bdnugget/zig-gamedev.git
synced 2026-11-07 09:07:31 +00:00
Updated to the latest Zig compiler (0.11.0-dev.3833).
This commit is contained in:
1 parent
f2d19e5c00
commit
ef83560d6a
95 files changed
+2515
-2511
No files matched your search
@@ -1,7 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
|
||||
pub const min_zig_version = std.SemanticVersion{ .major = 0, .minor = 11, .patch = 0, .pre = "dev.3771" };
|
||||
pub const min_zig_version = std.SemanticVersion{ .major = 0, .minor = 11, .patch = 0, .pre = "dev.3833" };
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
//
|
||||
|
||||
@@ -161,7 +161,7 @@ fn updateFrameStats(window: *sdl.Window, name: [:0]const u8) struct { time: f64,
|
||||
const now_ns = now_ns: {
|
||||
const now_ns = state.timer.read();
|
||||
const this_frame_ns = now_ns - state.previous_time_ns;
|
||||
const wanted_per_frame_ns = @intFromFloat(u64, 1.0 / 60.0 * std.time.ns_per_s);
|
||||
const wanted_per_frame_ns = @as(u64, @intFromFloat(1.0 / 60.0 * std.time.ns_per_s));
|
||||
|
||||
if (this_frame_ns < wanted_per_frame_ns) {
|
||||
std.time.sleep(wanted_per_frame_ns - this_frame_ns);
|
||||
@@ -170,13 +170,13 @@ fn updateFrameStats(window: *sdl.Window, name: [:0]const u8) struct { time: f64,
|
||||
break :now_ns now_ns;
|
||||
};
|
||||
|
||||
const time = @floatFromInt(f64, now_ns) / std.time.ns_per_s;
|
||||
const delta_time = @floatFromInt(f32, now_ns - state.previous_time_ns) / std.time.ns_per_s;
|
||||
const time = @as(f64, @floatFromInt(now_ns)) / std.time.ns_per_s;
|
||||
const delta_time = @as(f32, @floatFromInt(now_ns - state.previous_time_ns)) / std.time.ns_per_s;
|
||||
state.previous_time_ns = now_ns;
|
||||
|
||||
if ((now_ns - state.header_refresh_time_ns) >= std.time.ns_per_s) {
|
||||
const t = @floatFromInt(f64, now_ns - state.header_refresh_time_ns) / std.time.ns_per_s;
|
||||
const fps = @floatFromInt(f64, state.frame_count) / t;
|
||||
const t = @as(f64, @floatFromInt(now_ns - state.header_refresh_time_ns)) / std.time.ns_per_s;
|
||||
const fps = @as(f64, @floatFromInt(state.frame_count)) / t;
|
||||
const ms = (1.0 / fps) * 1000.0;
|
||||
|
||||
var buffer = [_]u8{0} ** 128;
|
||||
|
||||
@@ -94,7 +94,7 @@ fn pdj(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -112,7 +112,7 @@ fn pdj(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -23,7 +23,7 @@ pub fn draw() void {
|
||||
|
||||
gl.pushMatrix();
|
||||
gl.rotatef(rot, 0.0, 0.0, 1.0);
|
||||
gl.translatef(@sin(@floatCast(f32, xcommon.frame_time)), 0, 0);
|
||||
gl.translatef(@sin(@as(f32, @floatCast(xcommon.frame_time))), 0, 0);
|
||||
for (0..6) |_| {
|
||||
gl.begin(gl.POINTS);
|
||||
gl.color3f(0.2, 0.0, 0.0);
|
||||
@@ -49,7 +49,7 @@ pub fn draw() void {
|
||||
|
||||
gl.pushMatrix();
|
||||
gl.rotatef(-rot, 0.0, 0.0, 1.0);
|
||||
gl.translatef(-@sin(@floatCast(f32, xcommon.frame_time)), 0, 0);
|
||||
gl.translatef(-@sin(@as(f32, @floatCast(xcommon.frame_time))), 0, 0);
|
||||
for (0..6) |_| {
|
||||
gl.begin(gl.POINTS);
|
||||
gl.color3f(0.0, 0.01, 0.2);
|
||||
|
||||
@@ -20,13 +20,13 @@ pub fn draw() void {
|
||||
gl.color3f(1, 1, 1);
|
||||
gl.useProgram(fs_draw);
|
||||
|
||||
const t = @floatCast(f32, xcommon.frame_time);
|
||||
const t = @as(f32, @floatCast(xcommon.frame_time));
|
||||
const r = 0.55 + 0.2 * @sin(t);
|
||||
const r1 = @sin(t);
|
||||
|
||||
for (0..4) |i| {
|
||||
gl.pushMatrix();
|
||||
gl.rotatef(rot + @floatFromInt(f32, i) * 45.0, 0.0, 0.0, 1.0);
|
||||
gl.rotatef(rot + @as(f32, @floatFromInt(i)) * 45.0, 0.0, 0.0, 1.0);
|
||||
gl.begin(gl.LINES);
|
||||
gl.vertex2f(0.0, -1.0);
|
||||
gl.vertex2f(0.0, 1.0);
|
||||
@@ -37,7 +37,7 @@ pub fn draw() void {
|
||||
gl.pushMatrix();
|
||||
gl.begin(gl.POINTS);
|
||||
for (0..20) |i| {
|
||||
const fract = @floatFromInt(f32, i) / 20.0;
|
||||
const fract = @as(f32, @floatFromInt(i)) / 20.0;
|
||||
const x = r1 * @cos(math.tau * fract);
|
||||
const y = r1 * @sin(math.tau * fract);
|
||||
gl.vertex2f(x, y);
|
||||
@@ -49,7 +49,7 @@ pub fn draw() void {
|
||||
gl.rotatef(rot, 0.0, 0.0, 1.0);
|
||||
gl.begin(gl.POINTS);
|
||||
for (0..30) |i| {
|
||||
const fract = @floatFromInt(f32, i) / 30.0;
|
||||
const fract = @as(f32, @floatFromInt(i)) / 30.0;
|
||||
const x = 1.25 * r * @cos(math.tau * fract);
|
||||
const y = 1.25 * r * @sin(math.tau * fract);
|
||||
gl.vertex2f(x, y);
|
||||
@@ -61,7 +61,7 @@ pub fn draw() void {
|
||||
gl.rotatef(-rot, 0.0, 0.0, 1.0);
|
||||
gl.begin(gl.POINTS);
|
||||
for (0..40) |i| {
|
||||
const fract = @floatFromInt(f32, i) / 40.0;
|
||||
const fract = @as(f32, @floatFromInt(i)) / 40.0;
|
||||
const x = 1.5 * r * @cos(math.tau * fract);
|
||||
const y = 1.5 * r * @sin(math.tau * fract);
|
||||
gl.vertex2f(x, y);
|
||||
|
||||
@@ -18,7 +18,7 @@ pub fn draw() void {
|
||||
|
||||
gl.useProgram(fs_draw);
|
||||
|
||||
const t = @floatCast(f32, xcommon.frame_time);
|
||||
const t = @as(f32, @floatCast(xcommon.frame_time));
|
||||
const r = @sin(t);
|
||||
|
||||
gl.loadIdentity();
|
||||
@@ -29,7 +29,7 @@ pub fn draw() void {
|
||||
gl.rotatef(rot, 0.0, 0.0, 1.0);
|
||||
gl.begin(gl.POINTS);
|
||||
for (0..10) |i| {
|
||||
const fract = @floatFromInt(f32, i) / 10.0;
|
||||
const fract = @as(f32, @floatFromInt(i)) / 10.0;
|
||||
const x = r * @cos(math.tau * fract);
|
||||
const y = r * @sin(math.tau * fract);
|
||||
gl.vertex2f(x, y);
|
||||
@@ -44,7 +44,7 @@ pub fn draw() void {
|
||||
gl.rotatef(90.0 * @sin(t), 0.0, 0.0, 1.0);
|
||||
gl.begin(gl.POINTS);
|
||||
for (0..10) |i| {
|
||||
const fract = @floatFromInt(f32, i) / 10.0;
|
||||
const fract = @as(f32, @floatFromInt(i)) / 10.0;
|
||||
const x = r * @cos(math.tau * fract);
|
||||
const y = r * @sin(math.tau * fract);
|
||||
gl.vertex2f(x, y);
|
||||
|
||||
@@ -154,7 +154,7 @@ fn pdj(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -132,7 +132,7 @@ fn pdj(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -110,7 +110,7 @@ fn sinusoidal(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -117,7 +117,7 @@ fn sinusoidal(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -118,7 +118,7 @@ fn sinusoidal(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -132,7 +132,7 @@ fn sinusoidal(v: Vec2, scale: f32) Vec2 {
|
||||
fn julia(v: Vec2, scale: f32, rand01: f32) Vec2 {
|
||||
const r = scale * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f32, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f32, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -55,7 +55,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = a1 * @sin(f1 * xn) + a2 * @cos(f2 * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos(f4 * xn) + a5 * @sin(f5 * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
xn = xn1;
|
||||
yn = yn1;
|
||||
|
||||
@@ -61,7 +61,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = a1 * @sin(f1 * xn) + a2 * @cos(f2 * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos(f4 * xn) + a5 * @sin(f5 * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
xn = xn1;
|
||||
yn = yn1;
|
||||
|
||||
@@ -61,7 +61,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = (a1 + r0) * @sin(f1 * xn) + a2 * @cos(f2 * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos(f4 * xn) + (a5 + r1) * @sin(f5 * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
xn = xn1;
|
||||
yn = yn1;
|
||||
|
||||
@@ -93,7 +93,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = (a1 + r0) * @sin(f1 * xn) + a2 * @cos(f2 * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos(f4 * xn) + (a5 + r1) * @sin(f5 * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
const vel = (xn1 - xn) * (xn1 - xn) + (yn1 - yn) * (yn1 - yn);
|
||||
if (vel < 0.5) {
|
||||
|
||||
@@ -65,7 +65,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = a1 * @sin((f1 + r0) * xn) + a2 * @cos((f2 + r0) * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos((f4 + r1) * xn) + a5 * @sin((f5 + r1) * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
const vel = (xn1 - xn) * (xn1 - xn) + (yn1 - yn) * (yn1 - yn) + random.float(f64) * 0.5;
|
||||
if (vel < 0.5) {
|
||||
|
||||
@@ -62,7 +62,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = a1 * @sin((f1 + r0) * xn) + a2 * @cos((f2 + r0) * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos((f4 + r1) * xn) + a5 * @sin((f5 + r1) * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
const velx = @fabs(xn1 - xn);
|
||||
const vely = @fabs(yn1 - yn);
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = a1 * @sin((f1 + r0) * xn) + a2 * @cos((f2 + r0) * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos((f4 + r1) * xn) + a5 * @sin((f5 + r1) * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
xn = xn1;
|
||||
yn = yn1;
|
||||
|
||||
@@ -64,7 +64,7 @@ pub fn draw() void {
|
||||
|
||||
const xn1 = (a1 + r0) * @sin(f1 * xn) + a2 * @cos(f2 * yn) + a3 * @sin(f3 * tn);
|
||||
const yn1 = a4 * @cos(f4 * xn) + (a5 + r1) * @sin(f5 * yn) + a6 * @cos(f6 * tn);
|
||||
const tn1 = @floatFromInt(f64, iter) * v;
|
||||
const tn1 = @as(f64, @floatFromInt(iter)) * v;
|
||||
|
||||
const vel = (xn1 - xn) * (xn1 - xn) + (yn1 - yn) * (yn1 - yn);
|
||||
if (vel < 0.5) {
|
||||
|
||||
@@ -395,7 +395,7 @@ fn sinusoidal(v: Vec2, s: f64) Vec2 {
|
||||
fn julia(v: Vec2, s: f64, rand01: f64) Vec2 {
|
||||
const r = s * @sqrt(@sqrt(v[0] * v[0] + v[1] * v[1]));
|
||||
const theta = 0.5 * math.atan2(f64, v[0], v[1]) +
|
||||
math.pi * @floatFromInt(f64, @intFromFloat(i32, 2.0 * rand01));
|
||||
math.pi * @as(f64, @floatFromInt(@as(i32, @intFromFloat(2.0 * rand01))));
|
||||
const xx = r * math.cos(theta);
|
||||
const yy = r * math.sin(theta);
|
||||
return .{ xx, yy };
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn saveScreenshot(alloc: std.mem.Allocator, filename: [:0]const u8) void {
|
||||
var viewport: [4]gl.Int = undefined;
|
||||
gl.getIntegerv(gl.VIEWPORT, &viewport);
|
||||
|
||||
const mem = alloc.alloc(u8, @intCast(usize, viewport[2] * viewport[3] * 3)) catch @panic("OOM");
|
||||
const mem = alloc.alloc(u8, @as(usize, @intCast(viewport[2] * viewport[3] * 3))) catch @panic("OOM");
|
||||
defer alloc.free(mem);
|
||||
|
||||
gl.readPixels(viewport[0], viewport[1], viewport[2], viewport[3], gl.RGB, gl.UNSIGNED_BYTE, mem.ptr);
|
||||
@@ -27,11 +27,11 @@ pub fn saveScreenshot(alloc: std.mem.Allocator, filename: [:0]const u8) void {
|
||||
|
||||
const image = zstbi.Image{
|
||||
.data = mem,
|
||||
.width = @intCast(u32, viewport[2]),
|
||||
.height = @intCast(u32, viewport[3]),
|
||||
.width = @as(u32, @intCast(viewport[2])),
|
||||
.height = @as(u32, @intCast(viewport[3])),
|
||||
.num_components = 3,
|
||||
.bytes_per_component = 1,
|
||||
.bytes_per_row = @intCast(u32, viewport[2]) * 3,
|
||||
.bytes_per_row = @as(u32, @intCast(viewport[2])) * 3,
|
||||
.is_hdr = false,
|
||||
};
|
||||
image.writeToFile(filename, .png) catch {};
|
||||
|
||||
@@ -41,9 +41,9 @@ pub fn init(
|
||||
var hh: i32 = undefined;
|
||||
c.ImFontAtlas_GetTexDataAsRGBA32(io.*.Fonts, &pp, &ww, &hh, null);
|
||||
break :blk .{
|
||||
.pixels = pp[0..@intCast(usize, ww * hh * 4)],
|
||||
.width = @intCast(u32, ww),
|
||||
.height = @intCast(u32, hh),
|
||||
.pixels = pp[0..@as(usize, @intCast(ww * hh * 4))],
|
||||
.width = @as(u32, @intCast(ww)),
|
||||
.height = @as(u32, @intCast(hh)),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -123,8 +123,8 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
if (draw_data == null or draw_data.?.*.TotalVtxCount == 0) {
|
||||
return;
|
||||
}
|
||||
const num_vertices = @intCast(u32, draw_data.?.*.TotalVtxCount);
|
||||
const num_indices = @intCast(u32, draw_data.?.*.TotalIdxCount);
|
||||
const num_vertices = @as(u32, @intCast(draw_data.?.*.TotalVtxCount));
|
||||
const num_indices = @as(u32, @intCast(draw_data.?.*.TotalIdxCount));
|
||||
|
||||
var vb = gui.vb[gctx.frame_index];
|
||||
var ib = gui.ib[gctx.frame_index];
|
||||
@@ -145,7 +145,7 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
hrPanicOnFail(gctx.lookupResource(vb).?.Map(
|
||||
0,
|
||||
&.{ .Begin = 0, .End = 0 },
|
||||
@ptrCast(*?*anyopaque, &ptr),
|
||||
@as(*?*anyopaque, @ptrCast(&ptr)),
|
||||
));
|
||||
break :blk ptr.?[0..new_size];
|
||||
};
|
||||
@@ -166,7 +166,7 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
hrPanicOnFail(gctx.lookupResource(ib).?.Map(
|
||||
0,
|
||||
&.{ .Begin = 0, .End = 0 },
|
||||
@ptrCast(*?*anyopaque, &ptr),
|
||||
@as(*?*anyopaque, @ptrCast(&ptr)),
|
||||
));
|
||||
break :blk ptr.?[0..new_size];
|
||||
};
|
||||
@@ -178,11 +178,11 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
var vb_idx: u32 = 0;
|
||||
var ib_idx: u32 = 0;
|
||||
var cmdlist_idx: u32 = 0;
|
||||
const num_cmdlists = @intCast(u32, draw_data.?.*.CmdListsCount);
|
||||
const num_cmdlists = @as(u32, @intCast(draw_data.?.*.CmdListsCount));
|
||||
while (cmdlist_idx < num_cmdlists) : (cmdlist_idx += 1) {
|
||||
const list = draw_data.?.*.CmdLists[cmdlist_idx];
|
||||
const list_vb_size = @intCast(u32, list.*.VtxBuffer.Size);
|
||||
const list_ib_size = @intCast(u32, list.*.IdxBuffer.Size);
|
||||
const list_vb_size = @as(u32, @intCast(list.*.VtxBuffer.Size));
|
||||
const list_ib_size = @as(u32, @intCast(list.*.IdxBuffer.Size));
|
||||
std.mem.copy(
|
||||
c.ImDrawVert,
|
||||
vb_slice[vb_idx .. vb_idx + list_vb_size],
|
||||
@@ -243,7 +243,7 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
var global_idx_offset: u32 = 0;
|
||||
|
||||
var cmdlist_idx: u32 = 0;
|
||||
const num_cmdlists = @intCast(u32, draw_data.?.*.CmdListsCount);
|
||||
const num_cmdlists = @as(u32, @intCast(draw_data.?.*.CmdListsCount));
|
||||
while (cmdlist_idx < num_cmdlists) : (cmdlist_idx += 1) {
|
||||
const cmdlist = draw_data.?.*.CmdLists[cmdlist_idx];
|
||||
|
||||
@@ -256,10 +256,10 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
// TODO(mziulek): Call the callback.
|
||||
} else {
|
||||
const rect = [1]d3d12.RECT{.{
|
||||
.left = @intFromFloat(i32, cmd.*.ClipRect.x - display_x),
|
||||
.top = @intFromFloat(i32, cmd.*.ClipRect.y - display_y),
|
||||
.right = @intFromFloat(i32, cmd.*.ClipRect.z - display_x),
|
||||
.bottom = @intFromFloat(i32, cmd.*.ClipRect.w - display_y),
|
||||
.left = @as(i32, @intFromFloat(cmd.*.ClipRect.x - display_x)),
|
||||
.top = @as(i32, @intFromFloat(cmd.*.ClipRect.y - display_y)),
|
||||
.right = @as(i32, @intFromFloat(cmd.*.ClipRect.z - display_x)),
|
||||
.bottom = @as(i32, @intFromFloat(cmd.*.ClipRect.w - display_y)),
|
||||
}};
|
||||
if (rect[0].right > rect[0].left and rect[0].bottom > rect[0].top) {
|
||||
gctx.cmdlist.RSSetScissorRects(1, &rect);
|
||||
@@ -267,13 +267,13 @@ pub fn draw(gui: *GuiRenderer, gctx: *zd3d12.GraphicsContext) void {
|
||||
cmd.*.ElemCount,
|
||||
1,
|
||||
cmd.*.IdxOffset + global_idx_offset,
|
||||
@intCast(i32, cmd.*.VtxOffset) + global_vtx_offset,
|
||||
@as(i32, @intCast(cmd.*.VtxOffset)) + global_vtx_offset,
|
||||
0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
global_idx_offset += @intCast(u32, cmdlist.*.IdxBuffer.Size);
|
||||
global_idx_offset += @as(u32, @intCast(cmdlist.*.IdxBuffer.Size));
|
||||
global_vtx_offset += cmdlist.*.VtxBuffer.Size;
|
||||
}
|
||||
}
|
||||
+26
-26
@@ -43,17 +43,17 @@ pub const FrameStats = struct {
|
||||
|
||||
pub fn update(self: *FrameStats, window: w32.HWND, window_name: []const u8) void {
|
||||
const now_ns = self.timer.read();
|
||||
self.time = @floatFromInt(f64, now_ns) / std.time.ns_per_s;
|
||||
self.delta_time = @floatFromInt(f32, now_ns - self.previous_time_ns) / std.time.ns_per_s;
|
||||
self.time = @as(f64, @floatFromInt(now_ns)) / std.time.ns_per_s;
|
||||
self.delta_time = @as(f32, @floatFromInt(now_ns - self.previous_time_ns)) / std.time.ns_per_s;
|
||||
self.previous_time_ns = now_ns;
|
||||
|
||||
if ((now_ns - self.fps_refresh_time_ns) >= std.time.ns_per_s) {
|
||||
const t = @floatFromInt(f64, now_ns - self.fps_refresh_time_ns) / std.time.ns_per_s;
|
||||
const fps = @floatFromInt(f64, self.frame_counter) / t;
|
||||
const t = @as(f64, @floatFromInt(now_ns - self.fps_refresh_time_ns)) / std.time.ns_per_s;
|
||||
const fps = @as(f64, @floatFromInt(self.frame_counter)) / t;
|
||||
const ms = (1.0 / fps) * 1000.0;
|
||||
|
||||
self.fps = @floatCast(f32, fps);
|
||||
self.average_cpu_time = @floatCast(f32, ms);
|
||||
self.fps = @as(f32, @floatCast(fps));
|
||||
self.average_cpu_time = @as(f32, @floatCast(ms));
|
||||
self.fps_refresh_time_ns = now_ns;
|
||||
self.frame_counter = 0;
|
||||
|
||||
@@ -63,7 +63,7 @@ pub const FrameStats = struct {
|
||||
"FPS: {d:.1} CPU time: {d:.3} ms | {s}",
|
||||
.{ self.fps, self.average_cpu_time, window_name },
|
||||
) catch unreachable;
|
||||
_ = w32.SetWindowTextA(window, @ptrCast([*:0]const u8, text.ptr));
|
||||
_ = w32.SetWindowTextA(window, @as([*:0]const u8, @ptrCast(text.ptr)));
|
||||
}
|
||||
self.frame_counter += 1;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ fn processWindowMessage(
|
||||
) callconv(w32.WINAPI) w32.LRESULT {
|
||||
assert(c.igGetCurrentContext() != null);
|
||||
var ui = c.igGetIO().?;
|
||||
var ui_backend = @ptrCast(*GuiBackendState, @alignCast(8, ui.*.BackendPlatformUserData));
|
||||
var ui_backend = @as(*GuiBackendState, @ptrCast(@alignCast(ui.*.BackendPlatformUserData)));
|
||||
switch (message) {
|
||||
w32.WM_LBUTTONDOWN,
|
||||
w32.WM_RBUTTONDOWN,
|
||||
@@ -93,8 +93,8 @@ fn processWindowMessage(
|
||||
if (ui_backend.*.mouse_buttons_down == 0 and w32.GetCapture() == null) {
|
||||
_ = w32.SetCapture(window);
|
||||
}
|
||||
ui_backend.*.mouse_buttons_down |= @as(u32, 1) << @intCast(u5, button);
|
||||
c.ImGuiIO_AddMouseButtonEvent(ui, @intCast(i32, button), true);
|
||||
ui_backend.*.mouse_buttons_down |= @as(u32, 1) << @as(u5, @intCast(button));
|
||||
c.ImGuiIO_AddMouseButtonEvent(ui, @as(i32, @intCast(button)), true);
|
||||
},
|
||||
w32.WM_LBUTTONUP,
|
||||
w32.WM_RBUTTONUP,
|
||||
@@ -104,17 +104,17 @@ fn processWindowMessage(
|
||||
if (message == w32.WM_LBUTTONUP) button = 0;
|
||||
if (message == w32.WM_RBUTTONUP) button = 1;
|
||||
if (message == w32.WM_MBUTTONUP) button = 2;
|
||||
ui_backend.*.mouse_buttons_down &= ~(@as(u32, 1) << @intCast(u5, button));
|
||||
ui_backend.*.mouse_buttons_down &= ~(@as(u32, 1) << @as(u5, @intCast(button)));
|
||||
if (ui_backend.*.mouse_buttons_down == 0 and w32.GetCapture() == window) {
|
||||
_ = w32.ReleaseCapture();
|
||||
}
|
||||
c.ImGuiIO_AddMouseButtonEvent(ui, @intCast(i32, button), false);
|
||||
c.ImGuiIO_AddMouseButtonEvent(ui, @as(i32, @intCast(button)), false);
|
||||
},
|
||||
w32.WM_MOUSEWHEEL => {
|
||||
c.ImGuiIO_AddMouseWheelEvent(
|
||||
ui,
|
||||
0.0,
|
||||
@floatFromInt(f32, w32.GET_WHEEL_DELTA_WPARAM(wparam)) / @floatFromInt(f32, w32.WHEEL_DELTA),
|
||||
@as(f32, @floatFromInt(w32.GET_WHEEL_DELTA_WPARAM(wparam))) / @as(f32, @floatFromInt(w32.WHEEL_DELTA)),
|
||||
);
|
||||
},
|
||||
w32.WM_MOUSEMOVE => {
|
||||
@@ -131,8 +131,8 @@ fn processWindowMessage(
|
||||
}
|
||||
c.ImGuiIO_AddMousePosEvent(
|
||||
ui,
|
||||
@floatFromInt(f32, w32.GET_X_LPARAM(lparam)),
|
||||
@floatFromInt(f32, w32.GET_Y_LPARAM(lparam)),
|
||||
@as(f32, @floatFromInt(w32.GET_X_LPARAM(lparam))),
|
||||
@as(f32, @floatFromInt(w32.GET_Y_LPARAM(lparam))),
|
||||
);
|
||||
},
|
||||
w32.WM_MOUSELEAVE => {
|
||||
@@ -157,7 +157,7 @@ fn processWindowMessage(
|
||||
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModAlt, isVkKeyDown(w32.VK_MENU));
|
||||
c.ImGuiIO_AddKeyEvent(ui, c.ImGuiKey_ModSuper, isVkKeyDown(w32.VK_APPS));
|
||||
|
||||
var vk = @intCast(i32, wparam);
|
||||
var vk = @as(i32, @intCast(wparam));
|
||||
if (wparam == w32.VK_RETURN and (((lparam >> 16) & 0xffff) & w32.KF_EXTENDED) != 0) {
|
||||
vk = w32.IM_VK_KEYPAD_ENTER;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ fn processWindowMessage(
|
||||
},
|
||||
w32.WM_CHAR => {
|
||||
if (wparam > 0 and wparam < 0x10000) {
|
||||
c.ImGuiIO_AddInputCharacterUTF16(ui, @intCast(u16, wparam & 0xffff));
|
||||
c.ImGuiIO_AddInputCharacterUTF16(ui, @as(u16, @intCast(wparam & 0xffff)));
|
||||
}
|
||||
},
|
||||
w32.WM_DESTROY => {
|
||||
@@ -235,9 +235,9 @@ pub fn initWindow(allocator: std.mem.Allocator, name: [*:0]const u8, width: u32,
|
||||
.lpfnWndProc = processWindowMessage,
|
||||
.cbClsExtra = 0,
|
||||
.cbWndExtra = 0,
|
||||
.hInstance = @ptrCast(w32.HINSTANCE, w32.GetModuleHandleA(null)),
|
||||
.hInstance = @as(w32.HINSTANCE, @ptrCast(w32.GetModuleHandleA(null))),
|
||||
.hIcon = null,
|
||||
.hCursor = w32.LoadCursorA(null, @ptrFromInt(w32.LPCSTR, 32512)),
|
||||
.hCursor = w32.LoadCursorA(null, @as(w32.LPCSTR, @ptrFromInt(32512))),
|
||||
.hbrBackground = null,
|
||||
.lpszMenuName = null,
|
||||
.lpszClassName = name,
|
||||
@@ -250,7 +250,7 @@ pub fn initWindow(allocator: std.mem.Allocator, name: [*:0]const u8, width: u32,
|
||||
w32.WS_CAPTION +
|
||||
w32.WS_MINIMIZEBOX;
|
||||
|
||||
var rect = w32.RECT{ .left = 0, .top = 0, .right = @intCast(i32, width), .bottom = @intCast(i32, height) };
|
||||
var rect = w32.RECT{ .left = 0, .top = 0, .right = @as(i32, @intCast(width)), .bottom = @as(i32, @intCast(height)) };
|
||||
// HACK(mziulek): For exact FullHD window size it is better to stick to requested total window size
|
||||
// (looks better on 1920x1080 displays).
|
||||
if (width != 1920 and height != 1080) {
|
||||
@@ -281,7 +281,7 @@ pub fn initWindow(allocator: std.mem.Allocator, name: [*:0]const u8, width: u32,
|
||||
pub fn deinitWindow(allocator: std.mem.Allocator) void {
|
||||
var ui = c.igGetIO().?;
|
||||
assert(ui.*.BackendPlatformUserData != null);
|
||||
allocator.destroy(@ptrCast(*GuiBackendState, @alignCast(@sizeOf(usize), ui.*.BackendPlatformUserData)));
|
||||
allocator.destroy(@as(*GuiBackendState, @ptrCast(@alignCast(ui.*.BackendPlatformUserData))));
|
||||
c.igDestroyContext(null);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ pub fn handleWindowEvents() bool {
|
||||
}
|
||||
|
||||
fn isVkKeyDown(vk: c_int) bool {
|
||||
return (@bitCast(u16, w32.GetKeyState(vk)) & 0x8000) != 0;
|
||||
return (@as(u16, @bitCast(w32.GetKeyState(vk))) & 0x8000) != 0;
|
||||
}
|
||||
|
||||
fn vkKeyToImGuiKey(wparam: w32.WPARAM) c.ImGuiKey {
|
||||
@@ -415,13 +415,13 @@ pub fn newImGuiFrame(delta_time: f32) void {
|
||||
assert(c.igGetCurrentContext() != null);
|
||||
|
||||
var ui = c.igGetIO().?;
|
||||
var ui_backend = @ptrCast(*GuiBackendState, @alignCast(@sizeOf(usize), ui.*.BackendPlatformUserData));
|
||||
var ui_backend = @as(*GuiBackendState, @ptrCast(@alignCast(ui.*.BackendPlatformUserData)));
|
||||
assert(ui_backend.*.window != null);
|
||||
|
||||
var rect: w32.RECT = undefined;
|
||||
_ = w32.GetClientRect(ui_backend.*.window.?, &rect);
|
||||
const viewport_width = @floatFromInt(f32, rect.right - rect.left);
|
||||
const viewport_height = @floatFromInt(f32, rect.bottom - rect.top);
|
||||
const viewport_width = @as(f32, @floatFromInt(rect.right - rect.left));
|
||||
const viewport_height = @as(f32, @floatFromInt(rect.bottom - rect.top));
|
||||
|
||||
ui.*.DisplaySize = c.ImVec2{ .x = viewport_width, .y = viewport_height };
|
||||
ui.*.DeltaTime = delta_time;
|
||||
@@ -455,7 +455,7 @@ pub fn drawText(
|
||||
utf16[len] = 0;
|
||||
devctx.DrawText(
|
||||
&utf16,
|
||||
@intCast(u32, len),
|
||||
@as(u32, @intCast(len)),
|
||||
format,
|
||||
layout_rect,
|
||||
brush,
|
||||
|
||||
@@ -8,7 +8,7 @@ const epsilon: f32 = 0.00001;
|
||||
pub fn modAngle(in_angle: f32) f32 {
|
||||
const angle = in_angle + math.pi;
|
||||
var temp: f32 = @fabs(angle);
|
||||
temp = temp - (2.0 * math.pi * @floatFromInt(f32, @intFromFloat(i32, temp / math.pi)));
|
||||
temp = temp - (2.0 * math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(temp / math.pi)))));
|
||||
temp = temp - math.pi;
|
||||
if (angle < 0.0) {
|
||||
temp = -temp;
|
||||
|
||||
+17
-17
@@ -424,10 +424,10 @@ pub const DataSource = opaque {
|
||||
fn Methods(comptime T: type) type {
|
||||
return struct {
|
||||
pub fn asDataSource(handle: *const T) *const DataSource {
|
||||
return @ptrCast(*const DataSource, handle);
|
||||
return @as(*const DataSource, @ptrCast(handle));
|
||||
}
|
||||
pub fn asDataSourceMut(handle: *T) *DataSource {
|
||||
return @ptrCast(*DataSource, handle);
|
||||
return @as(*DataSource, @ptrCast(handle));
|
||||
}
|
||||
|
||||
// TODO: Add missing methods.
|
||||
@@ -677,10 +677,10 @@ pub const AudioBuffer = opaque {
|
||||
extern fn zaudioAudioBufferDestroy(handle: *AudioBuffer) void;
|
||||
|
||||
pub fn asDataSource(audio_buffer: *const AudioBuffer) *const DataSource {
|
||||
return @ptrCast(*const DataSource, audio_buffer);
|
||||
return @as(*const DataSource, @ptrCast(audio_buffer));
|
||||
}
|
||||
pub fn asDataSourceMut(audio_buffer: *AudioBuffer) *DataSource {
|
||||
return @ptrCast(*DataSource, audio_buffer);
|
||||
return @as(*DataSource, @ptrCast(audio_buffer));
|
||||
}
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -744,14 +744,14 @@ pub const Node = opaque {
|
||||
fn Methods(comptime T: type) type {
|
||||
return struct {
|
||||
pub fn asNode(node: *const T) *const Node {
|
||||
return @ptrCast(*const Node, node);
|
||||
return @as(*const Node, @ptrCast(node));
|
||||
}
|
||||
pub fn asNodeMut(node: *T) *Node {
|
||||
return @ptrCast(*Node, node);
|
||||
return @as(*Node, @ptrCast(node));
|
||||
}
|
||||
|
||||
pub fn getNodeGraph(node: *const T) *const NodeGraph {
|
||||
return ma_node_get_node_graph(@ptrFromInt(*Node, @intFromPtr(node.asNode())));
|
||||
return ma_node_get_node_graph(@as(*Node, @ptrFromInt(@intFromPtr(node.asNode()))));
|
||||
}
|
||||
pub fn getNodeGraphMut(node: *T) *NodeGraph {
|
||||
return ma_node_get_node_graph(node.asNodeMut());
|
||||
@@ -1307,10 +1307,10 @@ pub const NodeGraph = opaque {
|
||||
pub usingnamespace Node.Methods(T);
|
||||
|
||||
pub fn asNodeGraph(handle: *const T) *const NodeGraph {
|
||||
return @ptrCast(*const NodeGraph, handle);
|
||||
return @as(*const NodeGraph, @ptrCast(handle));
|
||||
}
|
||||
pub fn asNodeGraphMut(handle: *T) *NodeGraph {
|
||||
return @ptrCast(*NodeGraph, handle);
|
||||
return @as(*NodeGraph, @ptrCast(handle));
|
||||
}
|
||||
|
||||
pub fn createDataSourceNode(node_graph: *T, config: DataSourceNode.Config) Error!*DataSourceNode {
|
||||
@@ -1424,7 +1424,7 @@ pub const NodeGraph = opaque {
|
||||
) Result;
|
||||
|
||||
pub fn getEndpoint(handle: *const T) *const Node {
|
||||
return ma_node_graph_get_endpoint(@ptrFromInt(*NodeGraph, @intFromPtr(handle.asNodeGraph())));
|
||||
return ma_node_graph_get_endpoint(@as(*NodeGraph, @ptrFromInt(@intFromPtr(handle.asNodeGraph()))));
|
||||
}
|
||||
pub fn getEndpointMut(handle: *T) *Node {
|
||||
return ma_node_graph_get_endpoint(handle.asNodeGraphMut());
|
||||
@@ -1482,7 +1482,7 @@ pub const Device = opaque {
|
||||
extern fn zaudioDeviceGetUserData(device: *const Device) ?*anyopaque;
|
||||
|
||||
pub fn getContext(device: *const Device) *const Context {
|
||||
return ma_device_get_context(@ptrFromInt(*Device, @intFromPtr(device)));
|
||||
return ma_device_get_context(@as(*Device, @ptrFromInt(@intFromPtr(device))));
|
||||
}
|
||||
pub fn getContextMut(device: *Device) *Context {
|
||||
return ma_device_get_context(device);
|
||||
@@ -1490,7 +1490,7 @@ pub const Device = opaque {
|
||||
extern fn ma_device_get_context(device: *Device) *Context;
|
||||
|
||||
pub fn getLog(device: *const Device) ?*const Log {
|
||||
return ma_device_get_log(@ptrFromInt(*Device, @intFromPtr(device)));
|
||||
return ma_device_get_log(@as(*Device, @ptrFromInt(@intFromPtr(device))));
|
||||
}
|
||||
pub fn getLogMut(device: *Device) ?*Log {
|
||||
return ma_device_get_log(device);
|
||||
@@ -1748,7 +1748,7 @@ pub const Engine = opaque {
|
||||
}
|
||||
|
||||
pub fn getResourceManager(engine: *const Engine) *const ResourceManager {
|
||||
return ma_engine_get_resource_manager(@ptrFromInt(*Engine, @intFromPtr(engine)));
|
||||
return ma_engine_get_resource_manager(@as(*Engine, @ptrFromInt(@intFromPtr(engine))));
|
||||
}
|
||||
pub fn getResourceManagerMut(engine: *Engine) *ResourceManager {
|
||||
return ma_engine_get_resource_manager(engine);
|
||||
@@ -1756,7 +1756,7 @@ pub const Engine = opaque {
|
||||
extern fn ma_engine_get_resource_manager(engine: *Engine) *ResourceManager;
|
||||
|
||||
pub fn getDevice(engine: *const Engine) ?*const Device {
|
||||
return ma_engine_get_device(@ptrFromInt(*Engine, @intFromPtr(engine)));
|
||||
return ma_engine_get_device(@as(*Engine, @ptrFromInt(@intFromPtr(engine))));
|
||||
}
|
||||
pub fn getDeviceMut(engine: *Engine) ?*Device {
|
||||
return ma_engine_get_device(engine);
|
||||
@@ -1764,7 +1764,7 @@ pub const Engine = opaque {
|
||||
extern fn ma_engine_get_device(engine: *Engine) ?*Device;
|
||||
|
||||
pub fn getLog(engine: *const Engine) ?*const Log {
|
||||
return ma_engine_get_log(@ptrFromInt(*Engine, @intFromPtr(engine)));
|
||||
return ma_engine_get_log(@as(*Engine, @ptrFromInt(@intFromPtr(engine))));
|
||||
}
|
||||
pub fn getLogMut(engine: *Engine) ?*Log {
|
||||
return ma_engine_get_log(engine);
|
||||
@@ -2587,7 +2587,7 @@ fn zaudioRealloc(ptr: ?*anyopaque, size: usize, _: ?*anyopaque) callconv(.C) ?*a
|
||||
|
||||
const old_size = if (ptr != null) mem_allocations.?.get(@intFromPtr(ptr.?)).? else 0;
|
||||
const old_mem = if (old_size > 0)
|
||||
@ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..old_size]
|
||||
@as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..old_size]
|
||||
else
|
||||
@as([*]align(mem_alignment) u8, undefined)[0..0];
|
||||
|
||||
@@ -2611,7 +2611,7 @@ fn zaudioFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.C) void {
|
||||
defer mem_mutex.unlock();
|
||||
|
||||
const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
|
||||
const mem = @ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..size];
|
||||
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
|
||||
mem_allocator.?.free(mem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ export fn zbulletAlloc(size: usize, alignment: i32) callconv(.C) ?*anyopaque {
|
||||
|
||||
const ptr = mem_allocator.?.rawAlloc(
|
||||
size,
|
||||
std.math.log2_int(u29, @intCast(u29, alignment)),
|
||||
std.math.log2_int(u29, @as(u29, @intCast(alignment))),
|
||||
@returnAddress(),
|
||||
);
|
||||
if (ptr == null) @panic("zbullet: out of memory");
|
||||
|
||||
mem_allocations.?.put(
|
||||
@intFromPtr(ptr),
|
||||
.{ .size = @intCast(u32, size), .alignment = @intCast(u16, alignment) },
|
||||
.{ .size = @as(u32, @intCast(size)), .alignment = @as(u16, @intCast(alignment)) },
|
||||
) catch @panic("zbullet: out of memory");
|
||||
|
||||
return ptr;
|
||||
@@ -60,11 +60,11 @@ export fn zbulletFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
|
||||
|
||||
const info = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
|
||||
|
||||
const mem = @ptrCast([*]u8, ptr)[0..info.size];
|
||||
const mem = @as([*]u8, @ptrCast(ptr))[0..info.size];
|
||||
|
||||
mem_allocator.?.rawFree(
|
||||
mem,
|
||||
std.math.log2_int(u29, @intCast(u29, info.alignment)),
|
||||
std.math.log2_int(u29, @as(u29, @intCast(info.alignment))),
|
||||
@returnAddress(),
|
||||
);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ pub const CollisionFilter = packed struct {
|
||||
_pad0: u10 = 0,
|
||||
_pad1: u16 = 0,
|
||||
|
||||
pub const all = @bitCast(CollisionFilter, ~@as(u32, 0));
|
||||
pub const all = @as(CollisionFilter, @bitCast(~@as(u32, 0)));
|
||||
|
||||
comptime {
|
||||
std.debug.assert(@sizeOf(@This()) == @sizeOf(u32) and @bitSizeOf(@This()) == @bitSizeOf(u32));
|
||||
@@ -205,12 +205,12 @@ const WorldImpl = opaque {
|
||||
extern fn cbtWorldDebugSetDrawer(world: World, debug: *const DebugDraw) void;
|
||||
|
||||
pub fn debugSetMode(world: World, mode: DebugMode) void {
|
||||
cbtWorldDebugSetMode(world, @bitCast(c_int, mode));
|
||||
cbtWorldDebugSetMode(world, @as(c_int, @bitCast(mode)));
|
||||
}
|
||||
extern fn cbtWorldDebugSetMode(world: World, mode: c_int) void;
|
||||
|
||||
pub fn debugGetMode(world: World) DebugMode {
|
||||
return @bitCast(DebugMode, cbtWorldDebugGetMode(world));
|
||||
return @as(DebugMode, @bitCast(cbtWorldDebugGetMode(world)));
|
||||
}
|
||||
extern fn cbtWorldDebugGetMode(world: World) c_int;
|
||||
|
||||
@@ -255,9 +255,9 @@ const WorldImpl = opaque {
|
||||
world,
|
||||
ray_from_world,
|
||||
ray_to_world,
|
||||
@bitCast(c_int, group),
|
||||
@bitCast(c_int, mask),
|
||||
@bitCast(c_int, flags),
|
||||
@as(c_int, @bitCast(group)),
|
||||
@as(c_int, @bitCast(mask)),
|
||||
@as(c_int, @bitCast(flags)),
|
||||
raycast_result,
|
||||
);
|
||||
}
|
||||
@@ -372,12 +372,12 @@ const ShapeImpl = opaque {
|
||||
} {
|
||||
std.debug.assert(shape.getType() == stype);
|
||||
return switch (stype) {
|
||||
.box => @ptrCast(BoxShape, shape),
|
||||
.sphere => @ptrCast(SphereShape, shape),
|
||||
.cylinder => @ptrCast(CylinderShape, shape),
|
||||
.capsule => @ptrCast(CapsuleShape, shape),
|
||||
.compound => @ptrCast(CompoundShape, shape),
|
||||
.trimesh => @ptrCast(TriangleMeshShape, shape),
|
||||
.box => @as(BoxShape, @ptrCast(shape)),
|
||||
.sphere => @as(SphereShape, @ptrCast(shape)),
|
||||
.cylinder => @as(CylinderShape, @ptrCast(shape)),
|
||||
.capsule => @as(CapsuleShape, @ptrCast(shape)),
|
||||
.compound => @as(CompoundShape, @ptrCast(shape)),
|
||||
.trimesh => @as(TriangleMeshShape, @ptrCast(shape)),
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -385,7 +385,7 @@ const ShapeImpl = opaque {
|
||||
fn ShapeFunctions(comptime T: type) type {
|
||||
return struct {
|
||||
pub fn asShape(shape: T) Shape {
|
||||
return @ptrCast(Shape, shape);
|
||||
return @as(Shape, @ptrCast(shape));
|
||||
}
|
||||
|
||||
pub fn dealloc(shape: T) void {
|
||||
@@ -455,7 +455,7 @@ const BoxShapeImpl = opaque {
|
||||
pub usingnamespace ShapeFunctions(BoxShape);
|
||||
|
||||
fn alloc() BoxShape {
|
||||
return @ptrCast(BoxShape, ShapeImpl.alloc(.box));
|
||||
return @as(BoxShape, @ptrCast(ShapeImpl.alloc(.box)));
|
||||
}
|
||||
|
||||
pub const create = cbtShapeBoxCreate;
|
||||
@@ -478,7 +478,7 @@ const SphereShapeImpl = opaque {
|
||||
pub usingnamespace ShapeFunctions(SphereShape);
|
||||
|
||||
fn alloc() SphereShape {
|
||||
return @ptrCast(SphereShape, ShapeImpl.alloc(.sphere));
|
||||
return @as(SphereShape, @ptrCast(ShapeImpl.alloc(.sphere)));
|
||||
}
|
||||
|
||||
pub const create = cbtShapeSphereCreate;
|
||||
@@ -501,7 +501,7 @@ const CapsuleShapeImpl = opaque {
|
||||
pub usingnamespace ShapeFunctions(CapsuleShape);
|
||||
|
||||
fn alloc() CapsuleShape {
|
||||
return @ptrCast(CapsuleShape, ShapeImpl.alloc(.capsule));
|
||||
return @as(CapsuleShape, @ptrCast(ShapeImpl.alloc(.capsule)));
|
||||
}
|
||||
|
||||
pub const create = cbtShapeCapsuleCreate;
|
||||
@@ -535,7 +535,7 @@ const CylinderShapeImpl = opaque {
|
||||
pub usingnamespace ShapeFunctions(CylinderShape);
|
||||
|
||||
fn alloc() CylinderShape {
|
||||
return @ptrCast(CylinderShape, ShapeImpl.alloc(.cylinder));
|
||||
return @as(CylinderShape, @ptrCast(ShapeImpl.alloc(.cylinder)));
|
||||
}
|
||||
|
||||
pub const create = cbtShapeCylinderCreate;
|
||||
@@ -576,7 +576,7 @@ const CompoundShapeImpl = opaque {
|
||||
pub usingnamespace ShapeFunctions(CompoundShape);
|
||||
|
||||
fn alloc() CompoundShape {
|
||||
return @ptrCast(CompoundShape, ShapeImpl.alloc(.compound));
|
||||
return @as(CompoundShape, @ptrCast(ShapeImpl.alloc(.compound)));
|
||||
}
|
||||
|
||||
pub const create = cbtShapeCompoundCreate;
|
||||
@@ -627,7 +627,7 @@ const TriangleMeshShapeImpl = opaque {
|
||||
}
|
||||
|
||||
fn alloc() TriangleMeshShape {
|
||||
return @ptrCast(TriangleMeshShape, ShapeImpl.alloc(.trimesh));
|
||||
return @as(TriangleMeshShape, @ptrCast(ShapeImpl.alloc(.trimesh)));
|
||||
}
|
||||
|
||||
pub const addIndexVertexArray = cbtShapeTriMeshAddIndexVertexArray;
|
||||
@@ -774,7 +774,7 @@ const BodyImpl = opaque {
|
||||
extern fn cbtBodySetCcdMotionThreshold(body: Body, threshold: f32) void;
|
||||
|
||||
pub fn setCollisionFlags(body: Body, flags: CollisionFlags) void {
|
||||
cbtBodySetCollisionFlags(body, @bitCast(c_int, flags));
|
||||
cbtBodySetCollisionFlags(body, @as(c_int, @bitCast(flags)));
|
||||
}
|
||||
extern fn cbtBodySetCollisionFlags(body: Body, flags: c_int) void;
|
||||
|
||||
@@ -867,7 +867,7 @@ const ConstraintImpl = opaque {
|
||||
fn ConstraintFunctions(comptime T: type) type {
|
||||
return struct {
|
||||
pub fn asConstraint(con: T) Constraint {
|
||||
return @ptrCast(Constraint, con);
|
||||
return @as(Constraint, @ptrCast(con));
|
||||
}
|
||||
pub fn dealloc(con: T) void {
|
||||
con.asConstraint().dealloc();
|
||||
@@ -907,7 +907,7 @@ const Point2PointConstraintImpl = opaque {
|
||||
pub usingnamespace ConstraintFunctions(Point2PointConstraint);
|
||||
|
||||
fn alloc() Point2PointConstraint {
|
||||
return @ptrCast(Point2PointConstraint, ConstraintImpl.alloc(.point2point));
|
||||
return @as(Point2PointConstraint, @ptrCast(ConstraintImpl.alloc(.point2point)));
|
||||
}
|
||||
|
||||
pub const create1 = cbtConPoint2PointCreate1;
|
||||
@@ -955,8 +955,8 @@ pub const DebugMode = packed struct {
|
||||
_pad0: u14 = 0,
|
||||
_pad1: u16 = 0,
|
||||
|
||||
pub const disabled = @bitCast(DebugMode, ~@as(u32, 0));
|
||||
pub const user_only = @bitCast(DebugMode, @as(u32, 0));
|
||||
pub const disabled = @as(DebugMode, @bitCast(~@as(u32, 0)));
|
||||
pub const user_only = @as(DebugMode, @bitCast(@as(u32, 0)));
|
||||
|
||||
comptime {
|
||||
std.debug.assert(@sizeOf(@This()) == @sizeOf(u32) and @bitSizeOf(@This()) == @bitSizeOf(u32));
|
||||
@@ -1025,14 +1025,14 @@ pub const DebugDrawer = struct {
|
||||
p1: *const [3]f32,
|
||||
color: *const [3]f32,
|
||||
) callconv(.C) void {
|
||||
const debug = @ptrCast(
|
||||
const debug = @as(
|
||||
*DebugDrawer,
|
||||
@alignCast(@alignOf(DebugDrawer), context.?),
|
||||
@ptrCast(@alignCast(context.?)),
|
||||
);
|
||||
|
||||
const r = @intFromFloat(u32, color[0] * 255.0);
|
||||
const g = @intFromFloat(u32, color[1] * 255.0) << 8;
|
||||
const b = @intFromFloat(u32, color[2] * 255.0) << 16;
|
||||
const r = @as(u32, @intFromFloat(color[0] * 255.0));
|
||||
const g = @as(u32, @intFromFloat(color[1] * 255.0)) << 8;
|
||||
const b = @as(u32, @intFromFloat(color[2] * 255.0)) << 16;
|
||||
const rgb = r | g | b;
|
||||
|
||||
debug.lines.append(
|
||||
@@ -1050,19 +1050,19 @@ pub const DebugDrawer = struct {
|
||||
color0: *const [3]f32,
|
||||
color1: *const [3]f32,
|
||||
) callconv(.C) void {
|
||||
const debug = @ptrCast(
|
||||
const debug = @as(
|
||||
*DebugDrawer,
|
||||
@alignCast(@alignOf(DebugDrawer), context.?),
|
||||
@ptrCast(@alignCast(context.?)),
|
||||
);
|
||||
|
||||
const r0 = @intFromFloat(u32, color0[0] * 255.0);
|
||||
const g0 = @intFromFloat(u32, color0[1] * 255.0) << 8;
|
||||
const b0 = @intFromFloat(u32, color0[2] * 255.0) << 16;
|
||||
const r0 = @as(u32, @intFromFloat(color0[0] * 255.0));
|
||||
const g0 = @as(u32, @intFromFloat(color0[1] * 255.0)) << 8;
|
||||
const b0 = @as(u32, @intFromFloat(color0[2] * 255.0)) << 16;
|
||||
const rgb0 = r0 | g0 | b0;
|
||||
|
||||
const r1 = @intFromFloat(u32, color1[0] * 255.0);
|
||||
const g1 = @intFromFloat(u32, color1[1] * 255.0) << 8;
|
||||
const b1 = @intFromFloat(u32, color1[2] * 255.0) << 16;
|
||||
const r1 = @as(u32, @intFromFloat(color1[0] * 255.0));
|
||||
const g1 = @as(u32, @intFromFloat(color1[1] * 255.0)) << 8;
|
||||
const b1 = @as(u32, @intFromFloat(color1[2] * 255.0)) << 16;
|
||||
const rgb1 = r1 | g1 | b1;
|
||||
|
||||
debug.lines.append(
|
||||
@@ -1126,7 +1126,7 @@ test "zbullet.shape.box" {
|
||||
try expect(box.getUserPointer() == null);
|
||||
|
||||
box.setUserPointer(&half_extents);
|
||||
try expect(box.getUserPointer() == @ptrCast(*anyopaque, &half_extents));
|
||||
try expect(box.getUserPointer() == @as(*anyopaque, @ptrCast(&half_extents)));
|
||||
|
||||
const shape = box.asShape();
|
||||
try expect(shape.getType() == .box);
|
||||
|
||||
+71
-71
@@ -89,7 +89,7 @@ pub const GraphicsContext = struct {
|
||||
null,
|
||||
w32.CLSCTX_INPROC_SERVER,
|
||||
&wic.IID_IImagingFactory,
|
||||
@ptrCast(*?*anyopaque, &wic_factory),
|
||||
@as(*?*anyopaque, @ptrCast(&wic_factory)),
|
||||
));
|
||||
break :blk wic_factory;
|
||||
};
|
||||
@@ -99,7 +99,7 @@ pub const GraphicsContext = struct {
|
||||
hrPanicOnFail(dxgi.CreateDXGIFactory2(
|
||||
if (enable_debug_layer) dxgi.CREATE_FACTORY_DEBUG else 0,
|
||||
&dxgi.IID_IFactory6,
|
||||
@ptrCast(*?*anyopaque, &factory),
|
||||
@as(*?*anyopaque, @ptrCast(&factory)),
|
||||
));
|
||||
break :blk factory;
|
||||
};
|
||||
@@ -122,7 +122,7 @@ pub const GraphicsContext = struct {
|
||||
|
||||
if (enable_debug_layer) {
|
||||
var maybe_debug: ?*d3d12d.IDebug1 = null;
|
||||
_ = d3d12.GetDebugInterface(&d3d12d.IID_IDebug1, @ptrCast(*?*anyopaque, &maybe_debug));
|
||||
_ = d3d12.GetDebugInterface(&d3d12d.IID_IDebug1, @as(*?*anyopaque, @ptrCast(&maybe_debug)));
|
||||
if (maybe_debug) |debug| {
|
||||
debug.EnableDebugLayer();
|
||||
if (enable_gbv) {
|
||||
@@ -153,7 +153,7 @@ pub const GraphicsContext = struct {
|
||||
}
|
||||
|
||||
const hr = d3d12.CreateDevice(
|
||||
@ptrCast(*w32.IUnknown, adapter3),
|
||||
@as(*w32.IUnknown, @ptrCast(adapter3)),
|
||||
.@"11_1",
|
||||
&d3d12.IID_IDevice9,
|
||||
null,
|
||||
@@ -171,10 +171,10 @@ pub const GraphicsContext = struct {
|
||||
const device = blk: {
|
||||
var device: *d3d12.IDevice9 = undefined;
|
||||
const hr = d3d12.CreateDevice(
|
||||
if (suitable_adapter) |adapter| @ptrCast(*w32.IUnknown, adapter) else null,
|
||||
if (suitable_adapter) |adapter| @as(*w32.IUnknown, @ptrCast(adapter)) else null,
|
||||
.@"11_1",
|
||||
&d3d12.IID_IDevice9,
|
||||
@ptrCast(*?*anyopaque, &device),
|
||||
@as(*?*anyopaque, @ptrCast(&device)),
|
||||
);
|
||||
|
||||
if (hr != w32.S_OK) {
|
||||
@@ -194,7 +194,7 @@ pub const GraphicsContext = struct {
|
||||
if (enable_debug_layer) {
|
||||
hrPanicOnFail(device.QueryInterface(
|
||||
&d3d12.IID_IDebugDevice,
|
||||
@ptrCast(*?*anyopaque, &debug_device),
|
||||
@as(*?*anyopaque, @ptrCast(&debug_device)),
|
||||
));
|
||||
|
||||
_ = debug_device.?.SetFeatureMask(.{ .CONSERVATIVE_RESOURCE_STATE_TRACKING = true });
|
||||
@@ -241,14 +241,14 @@ pub const GraphicsContext = struct {
|
||||
.Priority = @intFromEnum(d3d12.COMMAND_QUEUE_PRIORITY.NORMAL),
|
||||
.Flags = .{},
|
||||
.NodeMask = 0,
|
||||
}, &d3d12.IID_ICommandQueue, @ptrCast(*?*anyopaque, &cmdqueue)));
|
||||
}, &d3d12.IID_ICommandQueue, @as(*?*anyopaque, @ptrCast(&cmdqueue))));
|
||||
break :blk cmdqueue;
|
||||
};
|
||||
|
||||
var rect: w32.RECT = undefined;
|
||||
_ = w32.GetClientRect(window, &rect);
|
||||
const viewport_width = @intCast(u32, rect.right - rect.left);
|
||||
const viewport_height = @intCast(u32, rect.bottom - rect.top);
|
||||
const viewport_width = @as(u32, @intCast(rect.right - rect.left));
|
||||
const viewport_height = @as(u32, @intCast(rect.bottom - rect.top));
|
||||
|
||||
const swapchain = blk: {
|
||||
var desc = dxgi.SWAP_CHAIN_DESC{
|
||||
@@ -270,16 +270,16 @@ pub const GraphicsContext = struct {
|
||||
};
|
||||
var swapchain: *dxgi.ISwapChain = undefined;
|
||||
hrPanicOnFail(factory.CreateSwapChain(
|
||||
@ptrCast(*w32.IUnknown, cmdqueue),
|
||||
@as(*w32.IUnknown, @ptrCast(cmdqueue)),
|
||||
&desc,
|
||||
@ptrCast(*?*dxgi.ISwapChain, &swapchain),
|
||||
@as(*?*dxgi.ISwapChain, @ptrCast(&swapchain)),
|
||||
));
|
||||
defer _ = swapchain.Release();
|
||||
|
||||
var swapchain3: *dxgi.ISwapChain3 = undefined;
|
||||
hrPanicOnFail(swapchain.QueryInterface(
|
||||
&dxgi.IID_ISwapChain3,
|
||||
@ptrCast(*?*anyopaque, &swapchain3),
|
||||
@as(*?*anyopaque, @ptrCast(&swapchain3)),
|
||||
));
|
||||
break :blk swapchain3;
|
||||
};
|
||||
@@ -337,9 +337,9 @@ pub const GraphicsContext = struct {
|
||||
var swapbuffers: [num_swapbuffers]*d3d12.IResource = undefined;
|
||||
for (swapbuffers, 0..) |_, buffer_index| {
|
||||
hrPanicOnFail(swapchain.GetBuffer(
|
||||
@intCast(u32, buffer_index),
|
||||
@as(u32, @intCast(buffer_index)),
|
||||
&d3d12.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &swapbuffers[buffer_index]),
|
||||
@as(*?*anyopaque, @ptrCast(&swapbuffers[buffer_index])),
|
||||
));
|
||||
device.CreateRenderTargetView(
|
||||
swapbuffers[buffer_index],
|
||||
@@ -371,15 +371,15 @@ pub const GraphicsContext = struct {
|
||||
var device11: *d3d11.IDevice = undefined;
|
||||
var device_context11: *d3d11.IDeviceContext = undefined;
|
||||
hrPanicOnFail(d3d11on12.D3D11On12CreateDevice(
|
||||
@ptrCast(*w32.IUnknown, device),
|
||||
@as(*w32.IUnknown, @ptrCast(device)),
|
||||
.{ .DEBUG = enable_debug_layer, .BGRA_SUPPORT = true },
|
||||
null,
|
||||
0,
|
||||
&[_]*w32.IUnknown{@ptrCast(*w32.IUnknown, cmdqueue)},
|
||||
&[_]*w32.IUnknown{@as(*w32.IUnknown, @ptrCast(cmdqueue))},
|
||||
1,
|
||||
0,
|
||||
@ptrCast(*?*d3d11.IDevice, &device11),
|
||||
@ptrCast(*?*d3d11.IDeviceContext, &device_context11),
|
||||
@as(*?*d3d11.IDevice, @ptrCast(&device11)),
|
||||
@as(*?*d3d11.IDeviceContext, @ptrCast(&device_context11)),
|
||||
null,
|
||||
));
|
||||
break :blk .{ .device = device11, .device_context = device_context11 };
|
||||
@@ -389,7 +389,7 @@ pub const GraphicsContext = struct {
|
||||
var device11on12: *d3d11on12.IDevice2 = undefined;
|
||||
hrPanicOnFail(dx11.device.QueryInterface(
|
||||
&d3d11on12.IID_IDevice2,
|
||||
@ptrCast(*?*anyopaque, &device11on12),
|
||||
@as(*?*anyopaque, @ptrCast(&device11on12)),
|
||||
));
|
||||
break :blk device11on12;
|
||||
};
|
||||
@@ -403,7 +403,7 @@ pub const GraphicsContext = struct {
|
||||
&d2d1.FACTORY_OPTIONS{ .debugLevel = .INFORMATION }
|
||||
else
|
||||
&d2d1.FACTORY_OPTIONS{ .debugLevel = .NONE },
|
||||
@ptrCast(*?*anyopaque, &d2d_factory),
|
||||
@as(*?*anyopaque, @ptrCast(&d2d_factory)),
|
||||
));
|
||||
break :blk d2d_factory;
|
||||
};
|
||||
@@ -412,7 +412,7 @@ pub const GraphicsContext = struct {
|
||||
var dxgi_device: *dxgi.IDevice = undefined;
|
||||
hrPanicOnFail(device11on12.QueryInterface(
|
||||
&dxgi.IID_IDevice,
|
||||
@ptrCast(*?*anyopaque, &dxgi_device),
|
||||
@as(*?*anyopaque, @ptrCast(&dxgi_device)),
|
||||
));
|
||||
break :blk dxgi_device;
|
||||
};
|
||||
@@ -422,7 +422,7 @@ pub const GraphicsContext = struct {
|
||||
var d2d_device: *d2d1.IDevice6 = undefined;
|
||||
hrPanicOnFail(d2d_factory.CreateDevice6(
|
||||
dxgi_device,
|
||||
@ptrCast(*?*d2d1.IDevice6, &d2d_device),
|
||||
@as(*?*d2d1.IDevice6, @ptrCast(&d2d_device)),
|
||||
));
|
||||
break :blk d2d_device;
|
||||
};
|
||||
@@ -431,7 +431,7 @@ pub const GraphicsContext = struct {
|
||||
var d2d_device_context: *d2d1.IDeviceContext6 = undefined;
|
||||
hrPanicOnFail(d2d_device.CreateDeviceContext6(
|
||||
d2d1.DEVICE_CONTEXT_OPTIONS_NONE,
|
||||
@ptrCast(*?*d2d1.IDeviceContext6, &d2d_device_context),
|
||||
@as(*?*d2d1.IDeviceContext6, @ptrCast(&d2d_device_context)),
|
||||
));
|
||||
break :blk d2d_device_context;
|
||||
};
|
||||
@@ -441,7 +441,7 @@ pub const GraphicsContext = struct {
|
||||
hrPanicOnFail(dwrite.DWriteCreateFactory(
|
||||
.SHARED,
|
||||
&dwrite.IID_IFactory,
|
||||
@ptrCast(*?*anyopaque, &dwrite_factory),
|
||||
@as(*?*anyopaque, @ptrCast(&dwrite_factory)),
|
||||
));
|
||||
break :blk dwrite_factory;
|
||||
};
|
||||
@@ -450,9 +450,9 @@ pub const GraphicsContext = struct {
|
||||
var swapbuffers11: [num_swapbuffers]*d3d11.IResource = undefined;
|
||||
for (swapbuffers11, 0..) |_, buffer_index| {
|
||||
hrPanicOnFail(device11on12.CreateWrappedResource(
|
||||
@ptrCast(
|
||||
@as(
|
||||
*w32.IUnknown,
|
||||
resource_pool.lookupResource(swapchain_buffers[buffer_index]).?.raw.?,
|
||||
@ptrCast(resource_pool.lookupResource(swapchain_buffers[buffer_index]).?.raw.?),
|
||||
),
|
||||
&d3d11on12.RESOURCE_FLAGS{
|
||||
.BindFlags = .{ .RENDER_TARGET = true },
|
||||
@@ -463,7 +463,7 @@ pub const GraphicsContext = struct {
|
||||
.{ .RENDER_TARGET = true },
|
||||
d3d12.RESOURCE_STATES.PRESENT,
|
||||
&d3d11.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &swapbuffers11[buffer_index]),
|
||||
@as(*?*anyopaque, @ptrCast(&swapbuffers11[buffer_index])),
|
||||
));
|
||||
}
|
||||
break :blk swapbuffers11;
|
||||
@@ -477,7 +477,7 @@ pub const GraphicsContext = struct {
|
||||
var surface: *dxgi.ISurface = undefined;
|
||||
hrPanicOnFail(swapbuffer11.QueryInterface(
|
||||
&dxgi.IID_ISurface,
|
||||
@ptrCast(*?*anyopaque, &surface),
|
||||
@as(*?*anyopaque, @ptrCast(&surface)),
|
||||
));
|
||||
defer _ = surface.Release();
|
||||
|
||||
@@ -490,7 +490,7 @@ pub const GraphicsContext = struct {
|
||||
.bitmapOptions = d2d1.BITMAP_OPTIONS_TARGET | d2d1.BITMAP_OPTIONS_CANNOT_DRAW,
|
||||
.colorContext = null,
|
||||
},
|
||||
@ptrCast(*?*d2d1.IBitmap1, &d2d_targets[target_index]),
|
||||
@as(*?*d2d1.IBitmap1, @ptrCast(&d2d_targets[target_index])),
|
||||
));
|
||||
}
|
||||
break :blk d2d_targets;
|
||||
@@ -511,7 +511,7 @@ pub const GraphicsContext = struct {
|
||||
|
||||
const frame_fence = blk: {
|
||||
var frame_fence: *d3d12.IFence = undefined;
|
||||
hrPanicOnFail(device.CreateFence(0, .{}, &d3d12.IID_IFence, @ptrCast(*?*anyopaque, &frame_fence)));
|
||||
hrPanicOnFail(device.CreateFence(0, .{}, &d3d12.IID_IFence, @as(*?*anyopaque, @ptrCast(&frame_fence))));
|
||||
break :blk frame_fence;
|
||||
};
|
||||
|
||||
@@ -528,7 +528,7 @@ pub const GraphicsContext = struct {
|
||||
hrPanicOnFail(device.CreateCommandAllocator(
|
||||
.DIRECT,
|
||||
&d3d12.IID_ICommandAllocator,
|
||||
@ptrCast(*?*anyopaque, &cmdallocs[cmdalloc_index]),
|
||||
@as(*?*anyopaque, @ptrCast(&cmdallocs[cmdalloc_index])),
|
||||
));
|
||||
}
|
||||
break :blk cmdallocs;
|
||||
@@ -542,7 +542,7 @@ pub const GraphicsContext = struct {
|
||||
cmdallocs[0],
|
||||
null,
|
||||
&d3d12.IID_IGraphicsCommandList6,
|
||||
@ptrCast(*?*anyopaque, &cmdlist),
|
||||
@as(*?*anyopaque, @ptrCast(&cmdlist)),
|
||||
));
|
||||
break :blk cmdlist;
|
||||
};
|
||||
@@ -643,16 +643,16 @@ pub const GraphicsContext = struct {
|
||||
gctx.cmdlist.RSSetViewports(1, &[_]d3d12.VIEWPORT{.{
|
||||
.TopLeftX = 0.0,
|
||||
.TopLeftY = 0.0,
|
||||
.Width = @floatFromInt(f32, gctx.viewport_width),
|
||||
.Height = @floatFromInt(f32, gctx.viewport_height),
|
||||
.Width = @as(f32, @floatFromInt(gctx.viewport_width)),
|
||||
.Height = @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
.MinDepth = 0.0,
|
||||
.MaxDepth = 1.0,
|
||||
}});
|
||||
gctx.cmdlist.RSSetScissorRects(1, &[_]d3d12.RECT{.{
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.right = @intCast(c_long, gctx.viewport_width),
|
||||
.bottom = @intCast(c_long, gctx.viewport_height),
|
||||
.right = @as(c_long, @intCast(gctx.viewport_width)),
|
||||
.bottom = @as(c_long, @intCast(gctx.viewport_height)),
|
||||
}});
|
||||
gctx.current_pipeline = .{};
|
||||
}
|
||||
@@ -691,7 +691,7 @@ pub const GraphicsContext = struct {
|
||||
&[_]*d3d11.IResource{gctx.d2d.?.swapbuffers11[gctx.back_buffer_index]},
|
||||
1,
|
||||
);
|
||||
gctx.d2d.?.context.SetTarget(@ptrCast(*d2d1.IImage, gctx.d2d.?.targets[gctx.back_buffer_index]));
|
||||
gctx.d2d.?.context.SetTarget(@as(*d2d1.IImage, @ptrCast(gctx.d2d.?.targets[gctx.back_buffer_index])));
|
||||
gctx.d2d.?.context.BeginDraw();
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ pub const GraphicsContext = struct {
|
||||
// messages in debug output set 'mute_d2d_completely' to 'false'.
|
||||
hrPanicOnFail(gctx.device.QueryInterface(
|
||||
&d3d12d.IID_IInfoQueue,
|
||||
@ptrCast(*?*anyopaque, &info_queue),
|
||||
@as(*?*anyopaque, @ptrCast(&info_queue)),
|
||||
));
|
||||
|
||||
if (mute_d2d_completely) {
|
||||
@@ -767,7 +767,7 @@ pub const GraphicsContext = struct {
|
||||
gctx.is_cmdlist_opened = false;
|
||||
gctx.cmdqueue.ExecuteCommandLists(
|
||||
1,
|
||||
&[_]*d3d12.ICommandList{@ptrCast(*d3d12.ICommandList, gctx.cmdlist)},
|
||||
&[_]*d3d12.ICommandList{@as(*d3d12.ICommandList, @ptrCast(gctx.cmdlist))},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -849,7 +849,7 @@ pub const GraphicsContext = struct {
|
||||
initial_state,
|
||||
clear_value,
|
||||
&d3d12.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &resource),
|
||||
@as(*?*anyopaque, @ptrCast(&resource)),
|
||||
));
|
||||
break :blk resource;
|
||||
};
|
||||
@@ -898,7 +898,7 @@ pub const GraphicsContext = struct {
|
||||
if (resource == null)
|
||||
return;
|
||||
|
||||
if (@bitCast(u32, state_after) != @bitCast(u32, resource.?.state)) {
|
||||
if (@as(u32, @bitCast(state_after)) != @as(u32, @bitCast(resource.?.state))) {
|
||||
if (gctx.transition_resource_barriers.items.len == max_num_buffered_resource_barriers)
|
||||
gctx.flushResourceBarriers();
|
||||
|
||||
@@ -980,16 +980,16 @@ pub const GraphicsContext = struct {
|
||||
const hash = compute_hash: {
|
||||
var hasher = std.hash.Adler32.init();
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.VS.pShaderBytecode.?)[0..pso_desc.VS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.VS.pShaderBytecode.?))[0..pso_desc.VS.BytecodeLength],
|
||||
);
|
||||
if (pso_desc.GS.pShaderBytecode != null) {
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.GS.pShaderBytecode.?)[0..pso_desc.GS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.GS.pShaderBytecode.?))[0..pso_desc.GS.BytecodeLength],
|
||||
);
|
||||
}
|
||||
if (pso_desc.PS.pShaderBytecode != null) {
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.PS.pShaderBytecode.?)[0..pso_desc.PS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.PS.pShaderBytecode.?))[0..pso_desc.PS.BytecodeLength],
|
||||
);
|
||||
}
|
||||
hasher.update(std.mem.asBytes(&pso_desc.BlendState));
|
||||
@@ -1036,7 +1036,7 @@ pub const GraphicsContext = struct {
|
||||
pso_desc.VS.pShaderBytecode.?,
|
||||
pso_desc.VS.BytecodeLength,
|
||||
&d3d12.IID_IRootSignature,
|
||||
@ptrCast(*?*anyopaque, &rs),
|
||||
@as(*?*anyopaque, @ptrCast(&rs)),
|
||||
));
|
||||
break :blk rs;
|
||||
}
|
||||
@@ -1049,7 +1049,7 @@ pub const GraphicsContext = struct {
|
||||
hrPanicOnFail(gctx.device.CreateGraphicsPipelineState(
|
||||
pso_desc,
|
||||
&d3d12.IID_IPipelineState,
|
||||
@ptrCast(*?*anyopaque, &pso),
|
||||
@as(*?*anyopaque, @ptrCast(&pso)),
|
||||
));
|
||||
break :blk pso;
|
||||
};
|
||||
@@ -1098,15 +1098,15 @@ pub const GraphicsContext = struct {
|
||||
const hash = compute_hash: {
|
||||
var hasher = std.hash.Adler32.init();
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.MS.pShaderBytecode.?)[0..pso_desc.MS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.MS.pShaderBytecode.?))[0..pso_desc.MS.BytecodeLength],
|
||||
);
|
||||
if (pso_desc.AS.pShaderBytecode != null) {
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.AS.pShaderBytecode.?)[0..pso_desc.AS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.AS.pShaderBytecode.?))[0..pso_desc.AS.BytecodeLength],
|
||||
);
|
||||
}
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.PS.pShaderBytecode.?)[0..pso_desc.PS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.PS.pShaderBytecode.?))[0..pso_desc.PS.BytecodeLength],
|
||||
);
|
||||
hasher.update(std.mem.asBytes(&pso_desc.BlendState));
|
||||
hasher.update(std.mem.asBytes(&pso_desc.SampleMask));
|
||||
@@ -1134,7 +1134,7 @@ pub const GraphicsContext = struct {
|
||||
pso_desc.MS.pShaderBytecode.?,
|
||||
pso_desc.MS.BytecodeLength,
|
||||
&d3d12.IID_IRootSignature,
|
||||
@ptrCast(*?*anyopaque, &rs),
|
||||
@as(*?*anyopaque, @ptrCast(&rs)),
|
||||
));
|
||||
break :blk rs;
|
||||
};
|
||||
@@ -1150,7 +1150,7 @@ pub const GraphicsContext = struct {
|
||||
.pPipelineStateSubobjectStream = &stream,
|
||||
},
|
||||
&d3d12.IID_IPipelineState,
|
||||
@ptrCast(*?*anyopaque, &pso),
|
||||
@as(*?*anyopaque, @ptrCast(&pso)),
|
||||
));
|
||||
break :blk pso;
|
||||
};
|
||||
@@ -1180,7 +1180,7 @@ pub const GraphicsContext = struct {
|
||||
const hash = compute_hash: {
|
||||
var hasher = std.hash.Adler32.init();
|
||||
hasher.update(
|
||||
@ptrCast([*]const u8, pso_desc.CS.pShaderBytecode.?)[0..pso_desc.CS.BytecodeLength],
|
||||
@as([*]const u8, @ptrCast(pso_desc.CS.pShaderBytecode.?))[0..pso_desc.CS.BytecodeLength],
|
||||
);
|
||||
break :compute_hash hasher.final();
|
||||
};
|
||||
@@ -1199,7 +1199,7 @@ pub const GraphicsContext = struct {
|
||||
pso_desc.CS.pShaderBytecode.?,
|
||||
pso_desc.CS.BytecodeLength,
|
||||
&d3d12.IID_IRootSignature,
|
||||
@ptrCast(*?*anyopaque, &rs),
|
||||
@as(*?*anyopaque, @ptrCast(&rs)),
|
||||
));
|
||||
break :blk rs;
|
||||
};
|
||||
@@ -1211,7 +1211,7 @@ pub const GraphicsContext = struct {
|
||||
hrPanicOnFail(gctx.device.CreateComputePipelineState(
|
||||
pso_desc,
|
||||
&d3d12.IID_IPipelineState,
|
||||
@ptrCast(*?*anyopaque, &pso),
|
||||
@as(*?*anyopaque, @ptrCast(&pso)),
|
||||
));
|
||||
break :blk pso;
|
||||
};
|
||||
@@ -1264,7 +1264,7 @@ pub const GraphicsContext = struct {
|
||||
memory = gctx.upload_memory_heaps[gctx.frame_index].allocate(size);
|
||||
}
|
||||
return .{
|
||||
.cpu_slice = std.mem.bytesAsSlice(T, @alignCast(@alignOf(T), memory.cpu_slice.?)),
|
||||
.cpu_slice = std.mem.bytesAsSlice(T, @as([]align(@alignOf(T)) u8, @alignCast(memory.cpu_slice.?))),
|
||||
.gpu_base = memory.gpu_base.?,
|
||||
};
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ pub const GraphicsContext = struct {
|
||||
&required_size,
|
||||
);
|
||||
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @intCast(u32, required_size));
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @as(u32, @intCast(required_size)));
|
||||
layout[0].Offset = upload.buffer_offset;
|
||||
|
||||
const pixel_size = resource.?.desc.Format.pixelSizeInBits() / 8;
|
||||
@@ -1506,7 +1506,7 @@ pub const GraphicsContext = struct {
|
||||
defer _ = image_conv.Release();
|
||||
|
||||
hrPanicOnFail(image_conv.Initialize(
|
||||
@ptrCast(*wic.IBitmapSource, bmp_frame),
|
||||
@as(*wic.IBitmapSource, @ptrCast(bmp_frame)),
|
||||
wic_format,
|
||||
.None,
|
||||
null,
|
||||
@@ -1537,7 +1537,7 @@ pub const GraphicsContext = struct {
|
||||
var required_size: u64 = undefined;
|
||||
gctx.device.GetCopyableFootprints(&desc, 0, 1, 0, &layout, null, null, &required_size);
|
||||
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @intCast(u32, required_size));
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @as(u32, @intCast(required_size)));
|
||||
layout[0].Offset = upload.buffer_offset;
|
||||
|
||||
hrPanicOnFail(image_conv.CopyPixels(
|
||||
@@ -1615,7 +1615,7 @@ pub const GraphicsContext = struct {
|
||||
texture_desc = gctx.lookupResource(texture).?.GetDesc();
|
||||
|
||||
for (0..subresources.items.len) |index| {
|
||||
const subresource_index = @intCast(u32, index);
|
||||
const subresource_index = @as(u32, @intCast(index));
|
||||
|
||||
var layout: [1]d3d12.PLACED_SUBRESOURCE_FOOTPRINT = undefined;
|
||||
var num_rows: [1]u32 = undefined;
|
||||
@@ -1632,7 +1632,7 @@ pub const GraphicsContext = struct {
|
||||
&required_size,
|
||||
);
|
||||
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @intCast(u32, required_size));
|
||||
const upload = gctx.allocateUploadBufferRegion(u8, @as(u32, @intCast(required_size)));
|
||||
layout[0].Offset = upload.buffer_offset;
|
||||
|
||||
var subresource = &subresources.items[subresource_index];
|
||||
@@ -1791,11 +1791,11 @@ pub const MipmapGenerator = struct {
|
||||
gctx.cmdlist.SetComputeRoot32BitConstant(0, dispatch_num_mips, 1);
|
||||
gctx.cmdlist.SetComputeRootDescriptorTable(1, table_base);
|
||||
const num_groups_x = @max(
|
||||
@intCast(u32, texture_desc.Width) >> @intCast(u5, 3 + current_src_mip_level),
|
||||
@as(u32, @intCast(texture_desc.Width)) >> @as(u5, @intCast(3 + current_src_mip_level)),
|
||||
1,
|
||||
);
|
||||
const num_groups_y = @max(
|
||||
texture_desc.Height >> @intCast(u5, 3 + current_src_mip_level),
|
||||
texture_desc.Height >> @as(u5, @intCast(3 + current_src_mip_level)),
|
||||
1,
|
||||
);
|
||||
gctx.cmdlist.Dispatch(num_groups_x, num_groups_y, 1);
|
||||
@@ -1823,11 +1823,11 @@ pub const MipmapGenerator = struct {
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.front = 0,
|
||||
.right = @intCast(u32, texture_desc.Width) >> @intCast(
|
||||
.right = @as(u32, @intCast(texture_desc.Width)) >> @as(
|
||||
u5,
|
||||
mip_index + 1 + current_src_mip_level,
|
||||
@intCast(mip_index + 1 + current_src_mip_level),
|
||||
),
|
||||
.bottom = texture_desc.Height >> @intCast(u5, mip_index + 1 + current_src_mip_level),
|
||||
.bottom = texture_desc.Height >> @as(u5, @intCast(mip_index + 1 + current_src_mip_level)),
|
||||
.back = 1,
|
||||
};
|
||||
gctx.cmdlist.CopyTextureRegion(&dst, 0, 0, 0, &src, &box);
|
||||
@@ -1912,7 +1912,7 @@ const ResourcePool = struct {
|
||||
|
||||
pool.resources[slot_idx] = .{ .raw = raw, .state = state, .desc = raw.GetDesc() };
|
||||
return .{
|
||||
.index = @intCast(u16, slot_idx),
|
||||
.index = @as(u16, @intCast(slot_idx)),
|
||||
.generation = blk: {
|
||||
pool.generations[slot_idx] += 1;
|
||||
break :blk pool.generations[slot_idx];
|
||||
@@ -2032,7 +2032,7 @@ const PipelinePool = struct {
|
||||
|
||||
pool.pipelines[slot_idx] = .{ .pso = pso, .rs = rs, .ptype = ptype };
|
||||
const handle = PipelineHandle{
|
||||
.index = @intCast(u16, slot_idx),
|
||||
.index = @as(u16, @intCast(slot_idx)),
|
||||
.generation = blk: {
|
||||
pool.generations[slot_idx] += 1;
|
||||
break :blk pool.generations[slot_idx];
|
||||
@@ -2121,7 +2121,7 @@ const DescriptorHeap = struct {
|
||||
.NumDescriptors = capacity,
|
||||
.Flags = flags,
|
||||
.NodeMask = 0,
|
||||
}, &d3d12.IID_IDescriptorHeap, @ptrCast(*?*anyopaque, &heap)));
|
||||
}, &d3d12.IID_IDescriptorHeap, @as(*?*anyopaque, @ptrCast(&heap))));
|
||||
break :blk heap.?;
|
||||
};
|
||||
return DescriptorHeap{
|
||||
@@ -2188,7 +2188,7 @@ const GpuMemoryHeap = struct {
|
||||
d3d12.RESOURCE_STATES.GENERIC_READ,
|
||||
null,
|
||||
&d3d12.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &resource),
|
||||
@as(*?*anyopaque, @ptrCast(&resource)),
|
||||
));
|
||||
break :blk resource;
|
||||
};
|
||||
@@ -2197,7 +2197,7 @@ const GpuMemoryHeap = struct {
|
||||
hrPanicOnFail(resource.Map(
|
||||
0,
|
||||
&d3d12.RANGE{ .Begin = 0, .End = 0 },
|
||||
@ptrCast(*?*anyopaque, &cpu_base),
|
||||
@as(*?*anyopaque, @ptrCast(&cpu_base)),
|
||||
));
|
||||
break :blk cpu_base;
|
||||
};
|
||||
|
||||
+22
-22
@@ -602,10 +602,10 @@ pub const iter_t = extern struct {
|
||||
chain_it: ?*iter_t,
|
||||
|
||||
pub fn entities(iter: iter_t) []entity_t {
|
||||
return iter.entities_[0..@intCast(usize, iter.count_)];
|
||||
return iter.entities_[0..@as(usize, @intCast(iter.count_))];
|
||||
}
|
||||
pub fn count(iter: iter_t) usize {
|
||||
return @intCast(usize, iter.count_);
|
||||
return @as(usize, @intCast(iter.count_));
|
||||
}
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -828,15 +828,15 @@ const EcsAllocator = struct {
|
||||
return null;
|
||||
}
|
||||
|
||||
var allocation_size = Alignment + @intCast(usize, size);
|
||||
var allocation_size = Alignment + @as(usize, @intCast(size));
|
||||
|
||||
var data = allocator.?.alignedAlloc(u8, Alignment, allocation_size) catch {
|
||||
return null;
|
||||
};
|
||||
|
||||
var allocation_header = @ptrCast(
|
||||
var allocation_header = @as(
|
||||
*AllocationHeader,
|
||||
@alignCast(@alignOf(AllocationHeader), data.ptr),
|
||||
@ptrCast(@alignCast(@alignOf(AllocationHeader), data.ptr)),
|
||||
);
|
||||
|
||||
allocation_header.size = allocation_size;
|
||||
@@ -848,10 +848,10 @@ const EcsAllocator = struct {
|
||||
if (ptr == null) {
|
||||
return;
|
||||
}
|
||||
var ptr_unwrapped = @ptrCast([*]u8, ptr.?) - Alignment;
|
||||
var allocation_header = @ptrCast(
|
||||
var ptr_unwrapped = @as([*]u8, @ptrCast(ptr.?)) - Alignment;
|
||||
var allocation_header = @as(
|
||||
*AllocationHeader,
|
||||
@alignCast(Alignment, ptr_unwrapped),
|
||||
@ptrCast(@alignCast(Alignment, ptr_unwrapped)),
|
||||
);
|
||||
|
||||
allocator.?.free(
|
||||
@@ -867,23 +867,23 @@ const EcsAllocator = struct {
|
||||
return alloc(size);
|
||||
}
|
||||
|
||||
var ptr_unwrapped = @ptrCast([*]u8, old.?) - Alignment;
|
||||
var ptr_unwrapped = @as([*]u8, @ptrCast(old.?)) - Alignment;
|
||||
|
||||
var allocation_header = @ptrCast(
|
||||
var allocation_header = @as(
|
||||
*AllocationHeader,
|
||||
@alignCast(@alignOf(AllocationHeader), ptr_unwrapped),
|
||||
@ptrCast(@alignCast(@alignOf(AllocationHeader), ptr_unwrapped)),
|
||||
);
|
||||
|
||||
const old_allocation_size = allocation_header.size;
|
||||
const old_slice = @ptrCast([*]u8, ptr_unwrapped)[0..old_allocation_size];
|
||||
const old_slice = @as([*]u8, @ptrCast(ptr_unwrapped))[0..old_allocation_size];
|
||||
const old_slice_aligned = @alignCast(Alignment, old_slice);
|
||||
|
||||
const new_allocation_size = Alignment + @intCast(usize, size);
|
||||
const new_allocation_size = Alignment + @as(usize, @intCast(size));
|
||||
var new_data = allocator.?.realloc(old_slice_aligned, new_allocation_size) catch {
|
||||
return null;
|
||||
};
|
||||
|
||||
var new_allocation_header = @ptrCast(*AllocationHeader, @alignCast(Alignment, new_data.ptr));
|
||||
var new_allocation_header = @as(*AllocationHeader, @ptrCast(@alignCast(Alignment, new_data.ptr)));
|
||||
new_allocation_header.size = new_allocation_size;
|
||||
|
||||
return new_data.ptr + Alignment;
|
||||
@@ -892,7 +892,7 @@ const EcsAllocator = struct {
|
||||
fn calloc(size: i32) callconv(.C) ?*anyopaque {
|
||||
var data_maybe = alloc(size);
|
||||
if (data_maybe) |data| {
|
||||
@memset(@ptrCast([*]u8, data)[0..@intCast(usize, size)], 0);
|
||||
@memset(@as([*]u8, @ptrCast(data))[0..@as(usize, @intCast(size))], 0);
|
||||
}
|
||||
|
||||
return data_maybe;
|
||||
@@ -1178,11 +1178,11 @@ pub const make_pair = ecs_make_pair;
|
||||
extern fn ecs_make_pair(first: entity_t, second: entity_t) id_t;
|
||||
|
||||
pub fn pair_first(pair_id: entity_t) entity_t {
|
||||
return @intCast(entity_t, @truncate(u32, (pair_id & COMPONENT_MASK) >> 32));
|
||||
return @as(entity_t, @intCast(@as(u32, @truncate((pair_id & COMPONENT_MASK) >> 32))));
|
||||
}
|
||||
|
||||
pub fn pair_second(pair_id: entity_t) entity_t {
|
||||
return @intCast(entity_t, @truncate(u32, pair_id));
|
||||
return @as(entity_t, @intCast(@as(u32, @truncate(pair_id))));
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
@@ -2201,7 +2201,7 @@ pub fn set_pair(
|
||||
comptime T: type,
|
||||
val: T,
|
||||
) entity_t {
|
||||
return ecs_set_id(world, subject, pair(first, second), @sizeOf(T), @ptrCast(*const anyopaque, &val));
|
||||
return ecs_set_id(world, subject, pair(first, second), @sizeOf(T), @as(*const anyopaque, @ptrCast(&val)));
|
||||
}
|
||||
|
||||
pub fn remove_pair(world: *world_t, subject: entity_t, first: entity_t, second: entity_t) void {
|
||||
@@ -2230,7 +2230,7 @@ pub fn typeName(comptime T: type) @TypeOf(@typeName(T)) {
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn set(world: *world_t, entity: entity_t, comptime T: type, val: T) entity_t {
|
||||
return ecs_set_id(world, entity, id(T), @sizeOf(T), @ptrCast(*const anyopaque, &val));
|
||||
return ecs_set_id(world, entity, id(T), @sizeOf(T), @as(*const anyopaque, @ptrCast(&val)));
|
||||
}
|
||||
|
||||
pub fn get(world: *const world_t, entity: entity_t, comptime T: type) ?*const T {
|
||||
@@ -2261,7 +2261,7 @@ pub fn override(world: *world_t, entity: entity_t, comptime T: type) void {
|
||||
|
||||
pub fn field(it: *iter_t, comptime T: type, index: i32) ?[]T {
|
||||
if (ecs_field_w_size(it, @sizeOf(T), index)) |anyptr| {
|
||||
const ptr = @ptrCast([*]T, @alignCast(@alignOf(T), anyptr));
|
||||
const ptr = @as([*]T, @ptrCast(@alignCast(@alignOf(T), anyptr)));
|
||||
return ptr[0..it.count()];
|
||||
}
|
||||
return null;
|
||||
@@ -2274,11 +2274,11 @@ pub inline fn id(comptime T: type) id_t {
|
||||
pub const pair = make_pair;
|
||||
|
||||
pub fn cast(comptime T: type, val: ?*const anyopaque) *const T {
|
||||
return @ptrCast(*const T, @alignCast(@alignOf(T), val));
|
||||
return @as(*const T, @ptrCast(@alignCast(@alignOf(T), val)));
|
||||
}
|
||||
|
||||
pub fn cast_mut(comptime T: type, val: ?*anyopaque) *T {
|
||||
return @ptrCast(*T, @alignCast(@alignOf(T), val));
|
||||
return @as(*T, @ptrCast(@alignCast(@alignOf(T), val)));
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
fn PerTypeGlobalVar(comptime in_type: type) type {
|
||||
|
||||
+11
-11
@@ -47,7 +47,7 @@ extern fn glfwVulkanSupported() i32;
|
||||
pub fn getRequiredInstanceExtensions() Error![][*:0]const u8 {
|
||||
var count: u32 = 0;
|
||||
if (glfwGetRequiredInstanceExtensions(&count)) |extensions| {
|
||||
return @ptrCast([*][*:0]const u8, extensions)[0..count];
|
||||
return @as([*][*:0]const u8, @ptrCast(extensions))[0..count];
|
||||
}
|
||||
try maybeError();
|
||||
return error.APIUnavailable;
|
||||
@@ -331,32 +331,32 @@ pub const Joystick = struct {
|
||||
};
|
||||
|
||||
pub fn getGuid(self: Joystick) [:0]const u8 {
|
||||
return std.mem.span(glfwGetJoystickGUID(@intCast(i32, self.jid)));
|
||||
return std.mem.span(glfwGetJoystickGUID(@as(i32, @intCast(self.jid))));
|
||||
}
|
||||
extern fn glfwGetJoystickGUID(jid: i32) [*:0]const u8;
|
||||
|
||||
pub fn getAxes(self: Joystick) []const f32 {
|
||||
var count: i32 = undefined;
|
||||
const state = glfwGetJoystickAxes(@intCast(i32, self.jid), &count);
|
||||
const state = glfwGetJoystickAxes(@as(i32, @intCast(self.jid)), &count);
|
||||
if (count == 0) {
|
||||
return @as([*]const f32, undefined)[0..0];
|
||||
}
|
||||
return state[0..@intCast(usize, count)];
|
||||
return state[0..@as(usize, @intCast(count))];
|
||||
}
|
||||
extern fn glfwGetJoystickAxes(jid: i32, count: *i32) [*]const f32;
|
||||
|
||||
pub fn getButtons(self: Joystick) []const ButtonAction {
|
||||
var count: i32 = undefined;
|
||||
const state = glfwGetJoystickButtons(@intCast(i32, self.jid), &count);
|
||||
const state = glfwGetJoystickButtons(@as(i32, @intCast(self.jid)), &count);
|
||||
if (count == 0) {
|
||||
return @as([*]const ButtonAction, undefined)[0..0];
|
||||
}
|
||||
return @ptrCast([]const ButtonAction, state[0..@intCast(usize, count)]);
|
||||
return @as([]const ButtonAction, @ptrCast(state[0..@as(usize, @intCast(count))]));
|
||||
}
|
||||
extern fn glfwGetJoystickButtons(jid: i32, count: *i32) [*]const u8;
|
||||
|
||||
fn isGamepad(self: Joystick) bool {
|
||||
return glfwJoystickIsGamepad(@intCast(i32, self.jid)) == @intFromBool(true);
|
||||
return glfwJoystickIsGamepad(@as(i32, @intCast(self.jid))) == @intFromBool(true);
|
||||
}
|
||||
|
||||
pub fn asGamepad(self: Joystick) ?Gamepad {
|
||||
@@ -365,7 +365,7 @@ pub const Joystick = struct {
|
||||
extern fn glfwJoystickIsGamepad(jid: i32) i32;
|
||||
|
||||
pub fn isPresent(jid: Id) bool {
|
||||
return glfwJoystickPresent(@intCast(i32, jid)) == @intFromBool(true);
|
||||
return glfwJoystickPresent(@as(i32, @intCast(jid))) == @intFromBool(true);
|
||||
}
|
||||
extern fn glfwJoystickPresent(jid: i32) i32;
|
||||
|
||||
@@ -426,13 +426,13 @@ pub const Gamepad = struct {
|
||||
};
|
||||
|
||||
pub fn getName(self: Gamepad) [:0]const u8 {
|
||||
return std.mem.span(glfwGetGamepadName(@intCast(i32, self.jid)));
|
||||
return std.mem.span(glfwGetGamepadName(@as(i32, @intCast(self.jid))));
|
||||
}
|
||||
extern fn glfwGetGamepadName(jid: i32) [*:0]const u8;
|
||||
|
||||
pub fn getState(self: Gamepad) State {
|
||||
var state: State = undefined;
|
||||
_ = glfwGetGamepadState(@intCast(i32, self.jid), &state);
|
||||
_ = glfwGetGamepadState(@as(i32, @intCast(self.jid)), &state);
|
||||
// return value of glfwGetGamepadState is ignored as
|
||||
// it is expected this is guarded by glfwJoystickIsGamepad
|
||||
return state;
|
||||
@@ -465,7 +465,7 @@ pub const Monitor = opaque {
|
||||
pub fn getAll() ?[]*Monitor {
|
||||
var count: i32 = 0;
|
||||
if (glfwGetMonitors(&count)) |monitors| {
|
||||
return monitors[0..@intCast(usize, count)];
|
||||
return monitors[0..@as(usize, @intCast(count))];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+12
-12
@@ -1261,7 +1261,7 @@ pub const Buffer = *opaque {
|
||||
if (len == 0) return null;
|
||||
const ptr = wgpuBufferGetConstMappedRange(buffer, offset, @sizeOf(T) * len);
|
||||
if (ptr == null) return null;
|
||||
return @ptrCast([*]const T, @alignCast(@alignOf(T), ptr))[0..len];
|
||||
return @as([*]const T, @ptrCast(@alignCast(ptr)))[0..len];
|
||||
}
|
||||
extern fn wgpuBufferGetConstMappedRange(buffer: Buffer, offset: usize, size: usize) ?*const anyopaque;
|
||||
|
||||
@@ -1271,7 +1271,7 @@ pub const Buffer = *opaque {
|
||||
if (len == 0) return null;
|
||||
const ptr = wgpuBufferGetMappedRange(buffer, offset, @sizeOf(T) * len);
|
||||
if (ptr == null) return null;
|
||||
return @ptrCast([*]T, @alignCast(@alignOf(T), ptr))[0..len];
|
||||
return @as([*]T, @ptrCast(@alignCast(ptr)))[0..len];
|
||||
}
|
||||
extern fn wgpuBufferGetMappedRange(buffer: Buffer, offset: usize, size: usize) ?*anyopaque;
|
||||
|
||||
@@ -1509,8 +1509,8 @@ pub const CommandEncoder = *opaque {
|
||||
command_encoder,
|
||||
buffer,
|
||||
buffer_offset,
|
||||
@ptrCast([*]const u8, data.ptr),
|
||||
@intCast(u64, data.len) * @sizeOf(T),
|
||||
@as([*]const u8, @ptrCast(data.ptr)),
|
||||
@as(u64, @intCast(data.len)) * @sizeOf(T),
|
||||
);
|
||||
}
|
||||
extern fn wgpuCommandEncoderWriteBuffer(
|
||||
@@ -1611,7 +1611,7 @@ pub const ComputePassEncoder = *opaque {
|
||||
compute_pass_encoder,
|
||||
group_index,
|
||||
bind_group,
|
||||
if (dynamic_offsets) |dynoff| @intCast(u32, dynoff.len) else 0,
|
||||
if (dynamic_offsets) |dynoff| @as(u32, @intCast(dynoff.len)) else 0,
|
||||
if (dynamic_offsets) |dynoff| dynoff.ptr else null,
|
||||
);
|
||||
}
|
||||
@@ -2066,7 +2066,7 @@ pub const Queue = *opaque {
|
||||
extern fn wgpuQueueSetLabel(queue: Queue, label: ?[*:0]const u8) void;
|
||||
|
||||
pub inline fn submit(queue: Queue, commands: []const CommandBuffer) void {
|
||||
wgpuQueueSubmit(queue, @intCast(u32, commands.len), commands.ptr);
|
||||
wgpuQueueSubmit(queue, @as(u32, @intCast(commands.len)), commands.ptr);
|
||||
}
|
||||
extern fn wgpuQueueSubmit(queue: Queue, command_count: u32, commands: [*]const CommandBuffer) void;
|
||||
|
||||
@@ -2081,8 +2081,8 @@ pub const Queue = *opaque {
|
||||
queue,
|
||||
buffer,
|
||||
buffer_offset,
|
||||
@ptrCast(*const anyopaque, data.ptr),
|
||||
@intCast(u64, data.len) * @sizeOf(T),
|
||||
@as(*const anyopaque, @ptrCast(data.ptr)),
|
||||
@as(u64, @intCast(data.len)) * @sizeOf(T),
|
||||
);
|
||||
}
|
||||
extern fn wgpuQueueWriteBuffer(
|
||||
@@ -2104,8 +2104,8 @@ pub const Queue = *opaque {
|
||||
wgpuQueueWriteTexture(
|
||||
queue,
|
||||
&destination,
|
||||
@ptrCast(*const anyopaque, data.ptr),
|
||||
@intCast(usize, data.len) * @sizeOf(T),
|
||||
@as(*const anyopaque, @ptrCast(data.ptr)),
|
||||
@as(usize, @intCast(data.len)) * @sizeOf(T),
|
||||
&data_layout,
|
||||
&write_size,
|
||||
);
|
||||
@@ -2263,7 +2263,7 @@ pub const RenderBundleEncoder = *opaque {
|
||||
render_bundle_encoder,
|
||||
group_index,
|
||||
group,
|
||||
if (dynamic_offsets) |dynoff| @intCast(u32, dynoff.len) else 0,
|
||||
if (dynamic_offsets) |dynoff| @as(u32, @intCast(dynoff.len)) else 0,
|
||||
if (dynamic_offsets) |dynoff| dynoff.ptr else null,
|
||||
);
|
||||
}
|
||||
@@ -2468,7 +2468,7 @@ pub const RenderPassEncoder = *opaque {
|
||||
render_pass_encoder,
|
||||
group_index,
|
||||
group,
|
||||
if (dynamic_offsets) |dynoff| @intCast(u32, dynoff.len) else 0,
|
||||
if (dynamic_offsets) |dynoff| @as(u32, @intCast(dynoff.len)) else 0,
|
||||
if (dynamic_offsets) |dynoff| dynoff.ptr else null,
|
||||
);
|
||||
}
|
||||
|
||||
+37
-37
@@ -107,7 +107,7 @@ pub const GraphicsContext = struct {
|
||||
userdata: ?*anyopaque,
|
||||
) callconv(.C) void {
|
||||
_ = message;
|
||||
const response = @ptrCast(*Response, @alignCast(@sizeOf(usize), userdata));
|
||||
const response = @as(*Response, @ptrCast(@alignCast(userdata)));
|
||||
response.status = status;
|
||||
response.adapter = adapter;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ pub const GraphicsContext = struct {
|
||||
instance.requestAdapter(
|
||||
.{ .power_preference = .high_performance },
|
||||
callback,
|
||||
@ptrCast(*anyopaque, &response),
|
||||
@as(*anyopaque, @ptrCast(&response)),
|
||||
);
|
||||
|
||||
if (response.status != .success) {
|
||||
@@ -151,7 +151,7 @@ pub const GraphicsContext = struct {
|
||||
userdata: ?*anyopaque,
|
||||
) callconv(.C) void {
|
||||
_ = message;
|
||||
const response = @ptrCast(*Response, @alignCast(@sizeOf(usize), userdata));
|
||||
const response = @as(*Response, @ptrCast(@alignCast(userdata)));
|
||||
response.status = status;
|
||||
response.device = device;
|
||||
}
|
||||
@@ -168,12 +168,12 @@ pub const GraphicsContext = struct {
|
||||
adapter.requestDevice(
|
||||
wgpu.DeviceDescriptor{
|
||||
.next_in_chain = if (zgpu_options.dawn_skip_validation)
|
||||
@ptrCast(*const wgpu.ChainedStruct, &dawn_toggles)
|
||||
@as(*const wgpu.ChainedStruct, @ptrCast(&dawn_toggles))
|
||||
else
|
||||
null,
|
||||
},
|
||||
callback,
|
||||
@ptrCast(*anyopaque, &response),
|
||||
@as(*anyopaque, @ptrCast(&response)),
|
||||
);
|
||||
|
||||
if (response.status != .success) {
|
||||
@@ -195,8 +195,8 @@ pub const GraphicsContext = struct {
|
||||
.label = "zig-gamedev-gctx-swapchain",
|
||||
.usage = .{ .render_attachment = true },
|
||||
.format = swapchain_format,
|
||||
.width = @intCast(u32, framebuffer_size[0]),
|
||||
.height = @intCast(u32, framebuffer_size[1]),
|
||||
.width = @as(u32, @intCast(framebuffer_size[0])),
|
||||
.height = @as(u32, @intCast(framebuffer_size[1])),
|
||||
.present_mode = .fifo,
|
||||
.implementation = 0,
|
||||
};
|
||||
@@ -289,7 +289,7 @@ pub const GraphicsContext = struct {
|
||||
|
||||
gctx.uniforms.offset += aligned_size;
|
||||
return .{
|
||||
.slice = std.mem.bytesAsSlice(T, @alignCast(@alignOf(T), slice)),
|
||||
.slice = std.mem.bytesAsSlice(T, @as([]align(@alignOf(T)) u8, @alignCast(slice))),
|
||||
.offset = offset,
|
||||
};
|
||||
}
|
||||
@@ -311,7 +311,7 @@ pub const GraphicsContext = struct {
|
||||
}
|
||||
|
||||
fn uniformsMappedCallback(status: wgpu.BufferMapAsyncStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||
const usb = @ptrCast(*UniformsStagingBuffer, @alignCast(@sizeOf(usize), userdata));
|
||||
const usb = @as(*UniformsStagingBuffer, @ptrCast(@alignCast(userdata)));
|
||||
assert(usb.slice == null);
|
||||
if (status == .success) {
|
||||
usb.slice = usb.buffer.getMappedRange(u8, 0, uniforms_buffer_size).?;
|
||||
@@ -330,7 +330,7 @@ pub const GraphicsContext = struct {
|
||||
0,
|
||||
uniforms_buffer_size,
|
||||
uniformsMappedCallback,
|
||||
@ptrCast(*anyopaque, &gctx.uniforms.stage.buffers[current]),
|
||||
@as(*anyopaque, @ptrCast(&gctx.uniforms.stage.buffers[current])),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ pub const GraphicsContext = struct {
|
||||
command_buffers.append(stage_commands) catch unreachable;
|
||||
command_buffers.appendSlice(commands) catch unreachable;
|
||||
|
||||
gctx.queue.onSubmittedWorkDone(0, gpuWorkDone, @ptrCast(*anyopaque, &gctx.stats.gpu_frame_number));
|
||||
gctx.queue.onSubmittedWorkDone(0, gpuWorkDone, @as(*anyopaque, @ptrCast(&gctx.stats.gpu_frame_number)));
|
||||
gctx.queue.submit(command_buffers.slice());
|
||||
|
||||
gctx.stats.tick();
|
||||
@@ -419,7 +419,7 @@ pub const GraphicsContext = struct {
|
||||
}
|
||||
|
||||
fn gpuWorkDone(status: wgpu.QueueWorkDoneStatus, userdata: ?*anyopaque) callconv(.C) void {
|
||||
const gpu_frame_number = @ptrCast(*u64, @alignCast(@sizeOf(usize), userdata));
|
||||
const gpu_frame_number = @as(*u64, @ptrCast(@alignCast(userdata)));
|
||||
gpu_frame_number.* += 1;
|
||||
if (status != .success) {
|
||||
std.log.err("[zgpu] Failed to complete GPU work (status: {s}).", .{@tagName(status)});
|
||||
@@ -437,8 +437,8 @@ pub const GraphicsContext = struct {
|
||||
gctx.swapchain_descriptor.height != fb_size[1])
|
||||
{
|
||||
if (fb_size[0] != 0 and fb_size[1] != 0) {
|
||||
gctx.swapchain_descriptor.width = @intCast(u32, fb_size[0]);
|
||||
gctx.swapchain_descriptor.height = @intCast(u32, fb_size[1]);
|
||||
gctx.swapchain_descriptor.width = @as(u32, @intCast(fb_size[0]));
|
||||
gctx.swapchain_descriptor.height = @as(u32, @intCast(fb_size[1]));
|
||||
gctx.swapchain.release();
|
||||
|
||||
gctx.swapchain = gctx.device.createSwapChain(gctx.surface, gctx.swapchain_descriptor);
|
||||
@@ -552,7 +552,7 @@ pub const GraphicsContext = struct {
|
||||
message: ?[*:0]const u8,
|
||||
userdata: ?*anyopaque,
|
||||
) callconv(.C) void {
|
||||
const op = @ptrCast(*AsyncCreateOpRender, @alignCast(@sizeOf(usize), userdata));
|
||||
const op = @as(*AsyncCreateOpRender, @ptrCast(@alignCast(userdata)));
|
||||
if (status == .success) {
|
||||
op.result.* = op.gctx.render_pipeline_pool.addResource(
|
||||
op.gctx.*,
|
||||
@@ -585,7 +585,7 @@ pub const GraphicsContext = struct {
|
||||
.pipeline_layout = pipeline_layout,
|
||||
.allocator = allocator,
|
||||
};
|
||||
gctx.device.createRenderPipelineAsync(desc, AsyncCreateOpRender.create, @ptrCast(*anyopaque, op));
|
||||
gctx.device.createRenderPipelineAsync(desc, AsyncCreateOpRender.create, @as(*anyopaque, @ptrCast(op)));
|
||||
}
|
||||
|
||||
pub fn createComputePipeline(
|
||||
@@ -613,7 +613,7 @@ pub const GraphicsContext = struct {
|
||||
message: ?[*:0]const u8,
|
||||
userdata: ?*anyopaque,
|
||||
) callconv(.C) void {
|
||||
const op = @ptrCast(*AsyncCreateOpCompute, @alignCast(@sizeOf(usize), userdata));
|
||||
const op = @as(*AsyncCreateOpCompute, @ptrCast(@alignCast(userdata)));
|
||||
if (status == .success) {
|
||||
op.result.* = op.gctx.compute_pipeline_pool.addResource(
|
||||
op.gctx.*,
|
||||
@@ -646,7 +646,7 @@ pub const GraphicsContext = struct {
|
||||
.pipeline_layout = pipeline_layout,
|
||||
.allocator = allocator,
|
||||
};
|
||||
gctx.device.createComputePipelineAsync(desc, AsyncCreateOpCompute.create, @ptrCast(*anyopaque, op));
|
||||
gctx.device.createComputePipelineAsync(desc, AsyncCreateOpCompute.create, @as(*anyopaque, @ptrCast(op)));
|
||||
}
|
||||
|
||||
pub fn createBindGroup(
|
||||
@@ -656,7 +656,7 @@ pub const GraphicsContext = struct {
|
||||
) BindGroupHandle {
|
||||
assert(entries.len > 0 and entries.len <= max_num_bindings_per_group);
|
||||
|
||||
var bind_group_info = BindGroupInfo{ .num_entries = @intCast(u32, entries.len) };
|
||||
var bind_group_info = BindGroupInfo{ .num_entries = @as(u32, @intCast(entries.len)) };
|
||||
var gpu_bind_group_entries: [max_num_bindings_per_group]wgpu.BindGroupEntry = undefined;
|
||||
|
||||
for (entries, 0..) |entry, i| {
|
||||
@@ -693,7 +693,7 @@ pub const GraphicsContext = struct {
|
||||
}
|
||||
bind_group_info.gpuobj = gctx.device.createBindGroup(.{
|
||||
.layout = gctx.lookupResource(layout).?,
|
||||
.entry_count = @intCast(u32, entries.len),
|
||||
.entry_count = @as(u32, @intCast(entries.len)),
|
||||
.entries = &gpu_bind_group_entries,
|
||||
});
|
||||
return gctx.bind_group_pool.addResource(gctx.*, bind_group_info);
|
||||
@@ -707,10 +707,10 @@ pub const GraphicsContext = struct {
|
||||
|
||||
var bind_group_layout_info = BindGroupLayoutInfo{
|
||||
.gpuobj = gctx.device.createBindGroupLayout(.{
|
||||
.entry_count = @intCast(u32, entries.len),
|
||||
.entry_count = @as(u32, @intCast(entries.len)),
|
||||
.entries = entries.ptr,
|
||||
}),
|
||||
.num_entries = @intCast(u32, entries.len),
|
||||
.num_entries = @as(u32, @intCast(entries.len)),
|
||||
};
|
||||
for (entries, 0..) |entry, i| {
|
||||
bind_group_layout_info.entries[i] = entry;
|
||||
@@ -738,7 +738,7 @@ pub const GraphicsContext = struct {
|
||||
) PipelineLayoutHandle {
|
||||
assert(bind_group_layouts.len > 0);
|
||||
|
||||
var info: PipelineLayoutInfo = .{ .num_bind_group_layouts = @intCast(u32, bind_group_layouts.len) };
|
||||
var info: PipelineLayoutInfo = .{ .num_bind_group_layouts = @as(u32, @intCast(bind_group_layouts.len)) };
|
||||
var gpu_bind_group_layouts: [max_num_bind_groups_per_pipeline]wgpu.BindGroupLayout = undefined;
|
||||
|
||||
for (bind_group_layouts, 0..) |bgl, i| {
|
||||
@@ -937,7 +937,7 @@ pub const GraphicsContext = struct {
|
||||
|
||||
for (&mipgen.scratch_texture_views, 0..) |*view, i| {
|
||||
view.* = gctx.createTextureView(mipgen.scratch_texture, .{
|
||||
.base_mip_level = @intCast(u32, i),
|
||||
.base_mip_level = @as(u32, @intCast(i)),
|
||||
.mip_level_count = 1,
|
||||
.base_array_layer = 0,
|
||||
.array_layer_count = 1,
|
||||
@@ -985,14 +985,14 @@ pub const GraphicsContext = struct {
|
||||
|
||||
const mem = gctx.uniformsAllocate(MipgenUniforms, 1);
|
||||
mem.slice[0] = .{
|
||||
.src_mip_level = @intCast(i32, current_src_mip_level),
|
||||
.src_mip_level = @as(i32, @intCast(current_src_mip_level)),
|
||||
.num_mip_levels = dispatch_num_mips,
|
||||
};
|
||||
pass.setBindGroup(0, gctx.lookupResource(bind_group).?, &.{mem.offset});
|
||||
|
||||
pass.dispatchWorkgroups(
|
||||
@max(texture_info.size.width >> @intCast(u5, 3 + current_src_mip_level), 1),
|
||||
@max(texture_info.size.height >> @intCast(u5, 3 + current_src_mip_level), 1),
|
||||
@max(texture_info.size.width >> @as(u5, @intCast(3 + current_src_mip_level)), 1),
|
||||
@max(texture_info.size.height >> @as(u5, @intCast(3 + current_src_mip_level)), 1),
|
||||
1,
|
||||
);
|
||||
}
|
||||
@@ -1013,8 +1013,8 @@ pub const GraphicsContext = struct {
|
||||
.origin = dst_origin,
|
||||
},
|
||||
.{
|
||||
.width = texture_info.size.width >> @intCast(u5, mip_index + current_src_mip_level + 1),
|
||||
.height = texture_info.size.height >> @intCast(u5, mip_index + current_src_mip_level + 1),
|
||||
.width = texture_info.size.width >> @as(u5, @intCast(mip_index + current_src_mip_level + 1)),
|
||||
.height = texture_info.size.height >> @as(u5, @intCast(mip_index + current_src_mip_level + 1)),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1144,7 +1144,7 @@ pub fn createRenderPipelineSimple(
|
||||
|
||||
const vertex_buffers = if (vertex_stride) |vs| [_]wgpu.VertexBufferLayout{.{
|
||||
.array_stride = vs,
|
||||
.attribute_count = @intCast(u32, vertex_attribs.?.len),
|
||||
.attribute_count = @as(u32, @intCast(vertex_attribs.?.len)),
|
||||
.attributes = vertex_attribs.?.ptr,
|
||||
}} else null;
|
||||
|
||||
@@ -1225,7 +1225,7 @@ pub fn createWgslShaderModule(
|
||||
.source = source,
|
||||
};
|
||||
const desc = wgpu.ShaderModuleDescriptor{
|
||||
.next_in_chain = @ptrCast(*const wgpu.ChainedStruct, &wgsl_desc),
|
||||
.next_in_chain = @as(*const wgpu.ChainedStruct, @ptrCast(&wgsl_desc)),
|
||||
.label = if (label) |l| l else null,
|
||||
};
|
||||
return device.createShaderModule(desc);
|
||||
@@ -1486,12 +1486,12 @@ const FrameStats = struct {
|
||||
|
||||
fn tick(stats: *FrameStats) void {
|
||||
stats.time = zglfw.getTime();
|
||||
stats.delta_time = @floatCast(f32, stats.time - stats.previous_time);
|
||||
stats.delta_time = @as(f32, @floatCast(stats.time - stats.previous_time));
|
||||
stats.previous_time = stats.time;
|
||||
|
||||
if ((stats.time - stats.fps_refresh_time) >= 1.0) {
|
||||
const t = stats.time - stats.fps_refresh_time;
|
||||
const fps = @floatFromInt(f64, stats.fps_counter) / t;
|
||||
const fps = @as(f64, @floatFromInt(stats.fps_counter)) / t;
|
||||
const ms = (1.0 / fps) * 1000.0;
|
||||
|
||||
stats.fps = fps;
|
||||
@@ -1571,7 +1571,7 @@ fn createSurfaceForWindow(instance: wgpu.Instance, window: *zglfw.Window) wgpu.S
|
||||
desc.chain.struct_type = .surface_descriptor_from_metal_layer;
|
||||
desc.layer = src.layer;
|
||||
break :blk instance.createSurface(.{
|
||||
.next_in_chain = @ptrCast(*const wgpu.ChainedStruct, &desc),
|
||||
.next_in_chain = @as(*const wgpu.ChainedStruct, @ptrCast(&desc)),
|
||||
.label = if (src.label) |l| l else null,
|
||||
});
|
||||
},
|
||||
@@ -1582,7 +1582,7 @@ fn createSurfaceForWindow(instance: wgpu.Instance, window: *zglfw.Window) wgpu.S
|
||||
desc.hinstance = src.hinstance;
|
||||
desc.hwnd = src.hwnd;
|
||||
break :blk instance.createSurface(.{
|
||||
.next_in_chain = @ptrCast(*const wgpu.ChainedStruct, &desc),
|
||||
.next_in_chain = @as(*const wgpu.ChainedStruct, @ptrCast(&desc)),
|
||||
.label = if (src.label) |l| l else null,
|
||||
});
|
||||
},
|
||||
@@ -1593,7 +1593,7 @@ fn createSurfaceForWindow(instance: wgpu.Instance, window: *zglfw.Window) wgpu.S
|
||||
desc.display = src.display;
|
||||
desc.window = src.window;
|
||||
break :blk instance.createSurface(.{
|
||||
.next_in_chain = @ptrCast(*const wgpu.ChainedStruct, &desc),
|
||||
.next_in_chain = @as(*const wgpu.ChainedStruct, @ptrCast(&desc)),
|
||||
.label = if (src.label) |l| l else null,
|
||||
});
|
||||
},
|
||||
@@ -1639,7 +1639,7 @@ fn msgSend(obj: anytype, sel_name: [:0]const u8, args: anytype, comptime ReturnT
|
||||
else => @compileError("[zgpu] Unsupported number of args"),
|
||||
};
|
||||
|
||||
const func = @ptrCast(FnType, &objc.objc_msgSend);
|
||||
const func = @as(FnType, @ptrCast(&objc.objc_msgSend));
|
||||
const sel = objc.sel_getUid(sel_name.ptr);
|
||||
|
||||
return @call(.never_inline, func, .{ obj, sel } ++ args);
|
||||
|
||||
@@ -41,7 +41,7 @@ pub fn newFrame(fb_width: u32, fb_height: u32) void {
|
||||
ImGui_ImplWGPU_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
gui.io.setDisplaySize(@floatFromInt(f32, fb_width), @floatFromInt(f32, fb_height));
|
||||
gui.io.setDisplaySize(@as(f32, @floatFromInt(fb_width)), @as(f32, @floatFromInt(fb_height)));
|
||||
gui.io.setDisplayFramebufferScale(1.0, 1.0);
|
||||
|
||||
gui.newFrame();
|
||||
|
||||
@@ -49,7 +49,7 @@ pub fn deinit() void {
|
||||
while (it.next()) |kv| {
|
||||
const address = kv.key_ptr.*;
|
||||
const size = kv.value_ptr.*;
|
||||
mem_allocator.?.free(@ptrFromInt([*]align(mem_alignment) u8, address)[0..size]);
|
||||
mem_allocator.?.free(@as([*]align(mem_alignment) u8, @ptrFromInt(address))[0..size]);
|
||||
std.log.info(
|
||||
"[zgui] Possible memory leak or static memory usage detected: (address: 0x{x}, size: {d})",
|
||||
.{ address, size },
|
||||
@@ -106,7 +106,7 @@ fn zguiMemFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.C) void {
|
||||
|
||||
if (mem_allocations != null) {
|
||||
const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
|
||||
const mem = @ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..size];
|
||||
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
|
||||
mem_allocator.?.free(mem);
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ pub const io = struct {
|
||||
) Font;
|
||||
|
||||
pub fn addFontFromMemory(fontdata: []const u8, size_pixels: f32) Font {
|
||||
return zguiIoAddFontFromMemory(fontdata.ptr, @intCast(i32, fontdata.len), size_pixels);
|
||||
return zguiIoAddFontFromMemory(fontdata.ptr, @as(i32, @intCast(fontdata.len)), size_pixels);
|
||||
}
|
||||
extern fn zguiIoAddFontFromMemory(font_data: *const anyopaque, font_size: i32, size_pixels: f32) Font;
|
||||
|
||||
@@ -191,7 +191,7 @@ pub const io = struct {
|
||||
) Font {
|
||||
return zguiIoAddFontFromMemoryWithConfig(
|
||||
fontdata.ptr,
|
||||
@intCast(i32, fontdata.len),
|
||||
@as(i32, @intCast(fontdata.len)),
|
||||
size_pixels,
|
||||
if (config) |c| &c else null,
|
||||
ranges,
|
||||
@@ -3746,7 +3746,7 @@ pub const DrawList = *opaque {
|
||||
zguiDrawList_AddPolyline(
|
||||
draw_list,
|
||||
points.ptr,
|
||||
@intCast(u32, points.len),
|
||||
@as(u32, @intCast(points.len)),
|
||||
args.col,
|
||||
args.flags,
|
||||
args.thickness,
|
||||
@@ -3769,7 +3769,7 @@ pub const DrawList = *opaque {
|
||||
zguiDrawList_AddConvexPolyFilled(
|
||||
draw_list,
|
||||
points.ptr,
|
||||
@intCast(u32, points.len),
|
||||
@as(u32, @intCast(points.len)),
|
||||
col,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ pub fn plotLineValues(label_id: [:0]const u8, comptime T: type, args: PlotLineVa
|
||||
label_id,
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.v.ptr,
|
||||
@intCast(i32, args.v.len),
|
||||
@as(i32, @intCast(args.v.len)),
|
||||
args.xscale,
|
||||
args.xstart,
|
||||
args.flags,
|
||||
@@ -399,7 +399,7 @@ pub fn plotLine(label_id: [:0]const u8, comptime T: type, args: PlotLineGen(T))
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.xv.ptr,
|
||||
args.yv.ptr,
|
||||
@intCast(i32, args.xv.len),
|
||||
@as(i32, @intCast(args.xv.len)),
|
||||
args.flags,
|
||||
args.offset,
|
||||
args.stride,
|
||||
@@ -445,7 +445,7 @@ pub fn plotScatterValues(label_id: [:0]const u8, comptime T: type, args: PlotSca
|
||||
label_id,
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.v.ptr,
|
||||
@intCast(i32, args.v.len),
|
||||
@as(i32, @intCast(args.v.len)),
|
||||
args.xscale,
|
||||
args.xstart,
|
||||
args.flags,
|
||||
@@ -481,7 +481,7 @@ pub fn plotScatter(label_id: [:0]const u8, comptime T: type, args: PlotScatterGe
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.xv.ptr,
|
||||
args.yv.ptr,
|
||||
@intCast(i32, args.xv.len),
|
||||
@as(i32, @intCast(args.xv.len)),
|
||||
args.flags,
|
||||
args.offset,
|
||||
args.stride,
|
||||
@@ -518,7 +518,7 @@ pub fn plotShaded(label_id: [:0]const u8, comptime T: type, args: PlotShadedGen(
|
||||
gui.typeToDataTypeEnum(T),
|
||||
args.xv.ptr,
|
||||
args.yv.ptr,
|
||||
@intCast(i32, args.xv.len),
|
||||
@as(i32, @intCast(args.xv.len)),
|
||||
args.yref,
|
||||
args.flags,
|
||||
args.offset,
|
||||
|
||||
@@ -48,7 +48,7 @@ pub const JobId = enum(u32) {
|
||||
}
|
||||
|
||||
inline fn fields(id: *const JobId) Fields {
|
||||
return @ptrCast(*const Fields, id).*;
|
||||
return @as(*const Fields, @ptrCast(id)).*;
|
||||
}
|
||||
|
||||
const Fields = packed struct {
|
||||
@@ -61,7 +61,7 @@ pub const JobId = enum(u32) {
|
||||
|
||||
inline fn id(_fields: *const Fields) JobId {
|
||||
comptime assert(@sizeOf(Fields) == @sizeOf(JobId));
|
||||
return @ptrCast(*const JobId, _fields).*;
|
||||
return @as(*const JobId, @ptrCast(_fields)).*;
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1044,7 +1044,7 @@ test "JobQueue throughput" {
|
||||
const job_workload_size = cache_line_size * 1024 * 1024;
|
||||
const job_count = blk: {
|
||||
const total_memory = std.process.totalSystemMemory() catch break :blk min_jobs;
|
||||
const upper_bound = @intFromFloat(usize, @floatFromInt(f64, total_memory) * 0.667);
|
||||
const upper_bound = @as(usize, @intFromFloat(@as(f64, @floatFromInt(total_memory)) * 0.667));
|
||||
var count: usize = min_jobs * 4;
|
||||
while (job_workload_size * count > upper_bound and count > min_jobs) : (count -= min_jobs) {}
|
||||
break :blk count;
|
||||
@@ -1157,7 +1157,7 @@ test "JobQueue throughput" {
|
||||
job_ms += job_stat.ms();
|
||||
}
|
||||
|
||||
const throughput = @floatFromInt(f64, job_ms) / @floatFromInt(f64, main_ms);
|
||||
const throughput = @as(f64, @floatFromInt(job_ms)) / @as(f64, @floatFromInt(main_ms));
|
||||
print("completed {} jobs ({}ms) in {}ms ({d:.1}x)\n", .{ job_count, job_ms, main_ms, throughput });
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ noinline fn mat4MulBenchmark(allocator: std.mem.Allocator, comptime count: compt
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("scalar version: {d:.4}s, ", .{elapsed_s});
|
||||
}
|
||||
@@ -158,7 +158,7 @@ noinline fn mat4MulBenchmark(allocator: std.mem.Allocator, comptime count: compt
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("zmath version: {d:.4}s\n", .{elapsed_s});
|
||||
}
|
||||
@@ -208,7 +208,7 @@ noinline fn cross3ScaleBiasBenchmark(allocator: std.mem.Allocator, comptime coun
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("scalar version: {d:.4}s, ", .{elapsed_s});
|
||||
}
|
||||
@@ -228,7 +228,7 @@ noinline fn cross3ScaleBiasBenchmark(allocator: std.mem.Allocator, comptime coun
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("zmath version: {d:.4}s\n", .{elapsed_s});
|
||||
}
|
||||
@@ -279,7 +279,7 @@ noinline fn cross3Dot3ScaleBiasBenchmark(allocator: std.mem.Allocator, comptime
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("scalar version: {d:.4}s, ", .{elapsed_s});
|
||||
}
|
||||
@@ -299,7 +299,7 @@ noinline fn cross3Dot3ScaleBiasBenchmark(allocator: std.mem.Allocator, comptime
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("zmath version: {d:.4}s\n", .{elapsed_s});
|
||||
}
|
||||
@@ -350,7 +350,7 @@ noinline fn quatBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("scalar version: {d:.4}s, ", .{elapsed_s});
|
||||
}
|
||||
@@ -370,7 +370,7 @@ noinline fn quatBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
}
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("zmath version: {d:.4}s\n", .{elapsed_s});
|
||||
}
|
||||
@@ -393,14 +393,14 @@ noinline fn waveBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
while (iter < count) : (iter += 1) {
|
||||
var z_index: i32 = 0;
|
||||
while (z_index < grid_size) : (z_index += 1) {
|
||||
const z = scale * @floatFromInt(f32, z_index - grid_size / 2);
|
||||
const z = scale * @as(f32, @floatFromInt(z_index - grid_size / 2));
|
||||
|
||||
var x_index: i32 = 0;
|
||||
while (x_index < grid_size) : (x_index += 4) {
|
||||
const x0 = scale * @floatFromInt(f32, x_index + 0 - grid_size / 2);
|
||||
const x1 = scale * @floatFromInt(f32, x_index + 1 - grid_size / 2);
|
||||
const x2 = scale * @floatFromInt(f32, x_index + 2 - grid_size / 2);
|
||||
const x3 = scale * @floatFromInt(f32, x_index + 3 - grid_size / 2);
|
||||
const x0 = scale * @as(f32, @floatFromInt(x_index + 0 - grid_size / 2));
|
||||
const x1 = scale * @as(f32, @floatFromInt(x_index + 1 - grid_size / 2));
|
||||
const x2 = scale * @as(f32, @floatFromInt(x_index + 2 - grid_size / 2));
|
||||
const x3 = scale * @as(f32, @floatFromInt(x_index + 3 - grid_size / 2));
|
||||
|
||||
const d0 = zm.sqrt(x0 * x0 + z * z);
|
||||
const d1 = zm.sqrt(x1 * x1 + z * z);
|
||||
@@ -421,7 +421,7 @@ noinline fn waveBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
t += 0.001;
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("scalar version: {d:.4}s, ", .{elapsed_s});
|
||||
}
|
||||
@@ -444,12 +444,12 @@ noinline fn waveBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
while (iter < count) : (iter += 1) {
|
||||
var z_index: i32 = 0;
|
||||
while (z_index < grid_size) : (z_index += 1) {
|
||||
const z = scale * @floatFromInt(f32, z_index - grid_size / 2);
|
||||
const z = scale * @as(f32, @floatFromInt(z_index - grid_size / 2));
|
||||
const vz = zm.splat(T, z);
|
||||
|
||||
var x_index: i32 = 0;
|
||||
while (x_index < grid_size) : (x_index += zm.veclen(T)) {
|
||||
const x = scale * @floatFromInt(f32, x_index - grid_size / 2);
|
||||
const x = scale * @as(f32, @floatFromInt(x_index - grid_size / 2));
|
||||
const vx = zm.splat(T, x) + voffset * zm.splat(T, scale);
|
||||
|
||||
const d = zm.sqrt(vx * vx + vz * vz);
|
||||
@@ -462,7 +462,7 @@ noinline fn waveBenchmark(allocator: std.mem.Allocator, comptime count: comptime
|
||||
vt += zm.splat(T, 0.001);
|
||||
}
|
||||
const end = timer.read();
|
||||
const elapsed_s = @floatFromInt(f64, end - start) / time.ns_per_s;
|
||||
const elapsed_s = @as(f64, @floatFromInt(end - start)) / time.ns_per_s;
|
||||
|
||||
std.debug.print("zmath version: {d:.4}s\n", .{elapsed_s});
|
||||
}
|
||||
|
||||
+77
-77
@@ -335,7 +335,7 @@ pub inline fn splat(comptime T: type, value: f32) T {
|
||||
return @splat(veclen(T), value);
|
||||
}
|
||||
pub inline fn splatInt(comptime T: type, value: u32) T {
|
||||
return @splat(veclen(T), @bitCast(f32, value));
|
||||
return @splat(veclen(T), @as(f32, @bitCast(value)));
|
||||
}
|
||||
|
||||
pub fn load(mem: []const f32, comptime T: type, comptime len: u32) T {
|
||||
@@ -415,14 +415,14 @@ pub inline fn arr3Ptr(ptr: anytype) *const [3]f32 {
|
||||
comptime assert(@typeInfo(@TypeOf(ptr)) == .Pointer);
|
||||
const T = std.meta.Child(@TypeOf(ptr));
|
||||
comptime assert(T == F32x4);
|
||||
return @ptrCast(*const [3]f32, ptr);
|
||||
return @as(*const [3]f32, @ptrCast(ptr));
|
||||
}
|
||||
|
||||
pub inline fn arrNPtr(ptr: anytype) [*]const f32 {
|
||||
comptime assert(@typeInfo(@TypeOf(ptr)) == .Pointer);
|
||||
const T = std.meta.Child(@TypeOf(ptr));
|
||||
comptime assert(T == Mat or T == F32x4 or T == F32x8 or T == F32x16);
|
||||
return @ptrCast([*]const f32, ptr);
|
||||
return @as([*]const f32, @ptrCast(ptr));
|
||||
}
|
||||
test "zmath.arrNPtr" {
|
||||
{
|
||||
@@ -609,9 +609,9 @@ pub inline fn isInBounds(
|
||||
// 2 x cmpleps, xorps, load, andps
|
||||
const b0 = v <= bounds;
|
||||
const b1 = (bounds * splat(T, -1.0)) <= v;
|
||||
const b0u = @bitCast(Tu, b0);
|
||||
const b1u = @bitCast(Tu, b1);
|
||||
return @bitCast(Tr, b0u & b1u);
|
||||
const b0u = @as(Tu, @bitCast(b0));
|
||||
const b1u = @as(Tu, @bitCast(b1));
|
||||
return @as(Tr, @bitCast(b0u & b1u));
|
||||
}
|
||||
test "zmath.isInBounds" {
|
||||
{
|
||||
@@ -634,20 +634,20 @@ test "zmath.isInBounds" {
|
||||
pub inline fn andInt(v0: anytype, v1: anytype) @TypeOf(v0, v1) {
|
||||
const T = @TypeOf(v0, v1);
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
const v0u = @bitCast(Tu, v0);
|
||||
const v1u = @bitCast(Tu, v1);
|
||||
return @bitCast(T, v0u & v1u); // andps
|
||||
const v0u = @as(Tu, @bitCast(v0));
|
||||
const v1u = @as(Tu, @bitCast(v1));
|
||||
return @as(T, @bitCast(v0u & v1u)); // andps
|
||||
}
|
||||
test "zmath.andInt" {
|
||||
{
|
||||
const v0 = f32x4(0, @bitCast(f32, ~@as(u32, 0)), 0, @bitCast(f32, ~@as(u32, 0)));
|
||||
const v0 = f32x4(0, @as(f32, @bitCast(~@as(u32, 0))), 0, @as(f32, @bitCast(~@as(u32, 0))));
|
||||
const v1 = f32x4(1.0, 2.0, 3.0, math.inf(f32));
|
||||
const v = andInt(v0, v1);
|
||||
try expect(v[3] == math.inf(f32));
|
||||
try expect(approxEqAbs(v, f32x4(0.0, 2.0, 0.0, math.inf(f32)), 0.0));
|
||||
}
|
||||
{
|
||||
const v0 = f32x8(0, 0, 0, 0, 0, @bitCast(f32, ~@as(u32, 0)), 0, @bitCast(f32, ~@as(u32, 0)));
|
||||
const v0 = f32x8(0, 0, 0, 0, 0, @as(f32, @bitCast(~@as(u32, 0))), 0, @as(f32, @bitCast(~@as(u32, 0))));
|
||||
const v1 = f32x8(0, 0, 0, 0, 1.0, 2.0, 3.0, math.inf(f32));
|
||||
const v = andInt(v0, v1);
|
||||
try expect(v[7] == math.inf(f32));
|
||||
@@ -658,20 +658,20 @@ test "zmath.andInt" {
|
||||
pub inline fn andNotInt(v0: anytype, v1: anytype) @TypeOf(v0, v1) {
|
||||
const T = @TypeOf(v0, v1);
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
const v0u = @bitCast(Tu, v0);
|
||||
const v1u = @bitCast(Tu, v1);
|
||||
return @bitCast(T, ~v0u & v1u); // andnps
|
||||
const v0u = @as(Tu, @bitCast(v0));
|
||||
const v1u = @as(Tu, @bitCast(v1));
|
||||
return @as(T, @bitCast(~v0u & v1u)); // andnps
|
||||
}
|
||||
test "zmath.andNotInt" {
|
||||
{
|
||||
const v0 = f32x4(1.0, 2.0, 3.0, 4.0);
|
||||
const v1 = f32x4(0, @bitCast(f32, ~@as(u32, 0)), 0, @bitCast(f32, ~@as(u32, 0)));
|
||||
const v1 = f32x4(0, @as(f32, @bitCast(~@as(u32, 0))), 0, @as(f32, @bitCast(~@as(u32, 0))));
|
||||
const v = andNotInt(v1, v0);
|
||||
try expect(approxEqAbs(v, f32x4(1.0, 0.0, 3.0, 0.0), 0.0));
|
||||
}
|
||||
{
|
||||
const v0 = f32x8(0, 0, 0, 0, 1.0, 2.0, 3.0, 4.0);
|
||||
const v1 = f32x8(0, 0, 0, 0, 0, @bitCast(f32, ~@as(u32, 0)), 0, @bitCast(f32, ~@as(u32, 0)));
|
||||
const v1 = f32x8(0, 0, 0, 0, 0, @as(f32, @bitCast(~@as(u32, 0))), 0, @as(f32, @bitCast(~@as(u32, 0))));
|
||||
const v = andNotInt(v1, v0);
|
||||
try expect(approxEqAbs(v, f32x8(0, 0, 0, 0, 1.0, 0.0, 3.0, 0.0), 0.0));
|
||||
}
|
||||
@@ -680,26 +680,26 @@ test "zmath.andNotInt" {
|
||||
pub inline fn orInt(v0: anytype, v1: anytype) @TypeOf(v0, v1) {
|
||||
const T = @TypeOf(v0, v1);
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
const v0u = @bitCast(Tu, v0);
|
||||
const v1u = @bitCast(Tu, v1);
|
||||
return @bitCast(T, v0u | v1u); // orps
|
||||
const v0u = @as(Tu, @bitCast(v0));
|
||||
const v1u = @as(Tu, @bitCast(v1));
|
||||
return @as(T, @bitCast(v0u | v1u)); // orps
|
||||
}
|
||||
test "zmath.orInt" {
|
||||
{
|
||||
const v0 = f32x4(0, @bitCast(f32, ~@as(u32, 0)), 0, 0);
|
||||
const v0 = f32x4(0, @as(f32, @bitCast(~@as(u32, 0))), 0, 0);
|
||||
const v1 = f32x4(1.0, 2.0, 3.0, 4.0);
|
||||
const v = orInt(v0, v1);
|
||||
try expect(v[0] == 1.0);
|
||||
try expect(@bitCast(u32, v[1]) == ~@as(u32, 0));
|
||||
try expect(@as(u32, @bitCast(v[1])) == ~@as(u32, 0));
|
||||
try expect(v[2] == 3.0);
|
||||
try expect(v[3] == 4.0);
|
||||
}
|
||||
{
|
||||
const v0 = f32x8(0, 0, 0, 0, 0, @bitCast(f32, ~@as(u32, 0)), 0, 0);
|
||||
const v0 = f32x8(0, 0, 0, 0, 0, @as(f32, @bitCast(~@as(u32, 0))), 0, 0);
|
||||
const v1 = f32x8(0, 0, 0, 0, 1.0, 2.0, 3.0, 4.0);
|
||||
const v = orInt(v0, v1);
|
||||
try expect(v[4] == 1.0);
|
||||
try expect(@bitCast(u32, v[5]) == ~@as(u32, 0));
|
||||
try expect(@as(u32, @bitCast(v[5])) == ~@as(u32, 0));
|
||||
try expect(v[6] == 3.0);
|
||||
try expect(v[7] == 4.0);
|
||||
}
|
||||
@@ -708,34 +708,34 @@ test "zmath.orInt" {
|
||||
pub inline fn norInt(v0: anytype, v1: anytype) @TypeOf(v0, v1) {
|
||||
const T = @TypeOf(v0, v1);
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
const v0u = @bitCast(Tu, v0);
|
||||
const v1u = @bitCast(Tu, v1);
|
||||
return @bitCast(T, ~(v0u | v1u)); // por, pcmpeqd, pxor
|
||||
const v0u = @as(Tu, @bitCast(v0));
|
||||
const v1u = @as(Tu, @bitCast(v1));
|
||||
return @as(T, @bitCast(~(v0u | v1u))); // por, pcmpeqd, pxor
|
||||
}
|
||||
|
||||
pub inline fn xorInt(v0: anytype, v1: anytype) @TypeOf(v0, v1) {
|
||||
const T = @TypeOf(v0, v1);
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
const v0u = @bitCast(Tu, v0);
|
||||
const v1u = @bitCast(Tu, v1);
|
||||
return @bitCast(T, v0u ^ v1u); // xorps
|
||||
const v0u = @as(Tu, @bitCast(v0));
|
||||
const v1u = @as(Tu, @bitCast(v1));
|
||||
return @as(T, @bitCast(v0u ^ v1u)); // xorps
|
||||
}
|
||||
test "zmath.xorInt" {
|
||||
{
|
||||
const v0 = f32x4(1.0, @bitCast(f32, ~@as(u32, 0)), 0, 0);
|
||||
const v0 = f32x4(1.0, @as(f32, @bitCast(~@as(u32, 0))), 0, 0);
|
||||
const v1 = f32x4(1.0, 0, 0, 0);
|
||||
const v = xorInt(v0, v1);
|
||||
try expect(v[0] == 0.0);
|
||||
try expect(@bitCast(u32, v[1]) == ~@as(u32, 0));
|
||||
try expect(@as(u32, @bitCast(v[1])) == ~@as(u32, 0));
|
||||
try expect(v[2] == 0.0);
|
||||
try expect(v[3] == 0.0);
|
||||
}
|
||||
{
|
||||
const v0 = f32x8(0, 0, 0, 0, 1.0, @bitCast(f32, ~@as(u32, 0)), 0, 0);
|
||||
const v0 = f32x8(0, 0, 0, 0, 1.0, @as(f32, @bitCast(~@as(u32, 0))), 0, 0);
|
||||
const v1 = f32x8(0, 0, 0, 0, 1.0, 0, 0, 0);
|
||||
const v = xorInt(v0, v1);
|
||||
try expect(v[4] == 0.0);
|
||||
try expect(@bitCast(u32, v[5]) == ~@as(u32, 0));
|
||||
try expect(@as(u32, @bitCast(v[5])) == ~@as(u32, 0));
|
||||
try expect(v[6] == 0.0);
|
||||
try expect(v[7] == 0.0);
|
||||
}
|
||||
@@ -963,7 +963,7 @@ test "zmath.round" {
|
||||
try expect(approxEqAbs(vr, fr, 0.0));
|
||||
try expect(approxEqAbs(vr8, fr8, 0.0));
|
||||
try expect(approxEqAbs(vr16, fr16, 0.0));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1052,7 +1052,7 @@ test "zmath.trunc" {
|
||||
try expect(approxEqAbs(vr, fr, 0.0));
|
||||
try expect(approxEqAbs(vr8, fr8, 0.0));
|
||||
try expect(approxEqAbs(vr16, fr16, 0.0));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,7 +1144,7 @@ test "zmath.floor" {
|
||||
try expect(approxEqAbs(vr, fr, 0.0));
|
||||
try expect(approxEqAbs(vr8, fr8, 0.0));
|
||||
try expect(approxEqAbs(vr16, fr16, 0.0));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,7 +1236,7 @@ test "zmath.ceil" {
|
||||
try expect(approxEqAbs(vr, fr, 0.0));
|
||||
try expect(approxEqAbs(vr8, fr8, 0.0));
|
||||
try expect(approxEqAbs(vr16, fr16, 0.0));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1533,7 +1533,7 @@ test "zmath.sin" {
|
||||
try expect(approxEqAbs(vr, fr, epsilon));
|
||||
try expect(approxEqAbs(vr8, fr8, epsilon));
|
||||
try expect(approxEqAbs(vr16, fr16, epsilon));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,7 +1581,7 @@ test "zmath.cos" {
|
||||
try expect(approxEqAbs(vr, fr, epsilon));
|
||||
try expect(approxEqAbs(vr8, fr8, epsilon));
|
||||
try expect(approxEqAbs(vr16, fr16, epsilon));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1678,7 +1678,7 @@ test "zmath.sincos32xN" {
|
||||
try expect(approxEqAbs(sc[1], c4, epsilon));
|
||||
try expect(approxEqAbs(sc8[1], c8, epsilon));
|
||||
try expect(approxEqAbs(sc16[1], c16, epsilon));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1789,7 +1789,7 @@ pub fn atan2(vy: anytype, vx: anytype) @TypeOf(vx, vy) {
|
||||
const Tu = @Vector(veclen(T), u32);
|
||||
|
||||
const vx_is_positive =
|
||||
(@bitCast(Tu, vx) & @splat(veclen(T), @as(u32, 0x8000_0000))) == @splat(veclen(T), @as(u32, 0));
|
||||
(@as(Tu, @bitCast(vx)) & @splat(veclen(T), @as(u32, 0x8000_0000))) == @splat(veclen(T), @as(u32, 0));
|
||||
|
||||
const vy_sign = andInt(vy, splatNegativeZero(T));
|
||||
const c0_25pi = orInt(vy_sign, splat(T, 0.25 * math.pi));
|
||||
@@ -1803,7 +1803,7 @@ pub fn atan2(vy: anytype, vx: anytype) @TypeOf(vx, vy) {
|
||||
const r4 = select(vx_is_positive, c0_25pi, c0_75pi);
|
||||
const r5 = select(isInf(vx), r4, c0_50pi);
|
||||
const result = select(isInf(vy), r5, r3);
|
||||
const result_valid = @bitCast(Tu, result) == @splat(veclen(T), @as(u32, 0xffff_ffff));
|
||||
const result_valid = @as(Tu, @bitCast(result)) == @splat(veclen(T), @as(u32, 0xffff_ffff));
|
||||
|
||||
const v = vy / vx;
|
||||
const r0 = atan(v);
|
||||
@@ -3370,7 +3370,7 @@ pub fn hsvToRgb(hsv: F32x4) F32x4 {
|
||||
const q = v * (f32x4s(1.0) - f * s);
|
||||
const t = v * (f32x4s(1.0) - (f32x4s(1.0) - f) * s);
|
||||
|
||||
const ii = @intFromFloat(i32, mod(i, f32x4s(6.0))[0]);
|
||||
const ii = @as(i32, @intFromFloat(mod(i, f32x4s(6.0))[0]));
|
||||
const rgb = switch (ii) {
|
||||
0 => blk: {
|
||||
const vt = select(boolx4(true, false, false, false), v, t);
|
||||
@@ -3607,7 +3607,7 @@ test "zmath.sincos32" {
|
||||
try expect(math.approxEqAbs(f32, sc[1], c, epsilon));
|
||||
try expect(math.approxEqAbs(f32, s0, s, epsilon));
|
||||
try expect(math.approxEqAbs(f32, c0, c, epsilon));
|
||||
f += 0.12345 * @floatFromInt(f32, i);
|
||||
f += 0.12345 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3661,7 +3661,7 @@ test "zmath.asin32" {
|
||||
try expect(approxEqAbs(r4, splat(F32x4, r1), epsilon));
|
||||
try expect(approxEqAbs(r8, splat(F32x8, r1), epsilon));
|
||||
try expect(approxEqAbs(r16, splat(F32x16, r1), epsilon));
|
||||
f += 0.09 * @floatFromInt(f32, i);
|
||||
f += 0.09 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3715,14 +3715,14 @@ test "zmath.acos32" {
|
||||
try expect(approxEqAbs(r4, splat(F32x4, r1), epsilon));
|
||||
try expect(approxEqAbs(r8, splat(F32x8, r1), epsilon));
|
||||
try expect(approxEqAbs(r16, splat(F32x16, r1), epsilon));
|
||||
f += 0.09 * @floatFromInt(f32, i);
|
||||
f += 0.09 * @as(f32, @floatFromInt(i));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modAngle32(in_angle: f32) f32 {
|
||||
const angle = in_angle + math.pi;
|
||||
var temp: f32 = @fabs(angle);
|
||||
temp = temp - (2.0 * math.pi * @floatFromInt(f32, @intFromFloat(i32, temp / math.pi)));
|
||||
temp = temp - (2.0 * math.pi * @as(f32, @floatFromInt(@as(i32, @intFromFloat(temp / math.pi)))));
|
||||
temp = temp - math.pi;
|
||||
if (angle < 0.0) {
|
||||
temp = -temp;
|
||||
@@ -4185,7 +4185,7 @@ fn fftUnswizzle(input: []const F32x4, output: []F32x4) void {
|
||||
|
||||
const length = input.len;
|
||||
|
||||
const f32_output = @ptrCast([*]f32, output.ptr)[0 .. output.len * 4];
|
||||
const f32_output = @as([*]f32, @ptrCast(output.ptr))[0 .. output.len * 4];
|
||||
|
||||
const static = struct {
|
||||
const swizzle_table = [256]u8{
|
||||
@@ -4209,31 +4209,31 @@ fn fftUnswizzle(input: []const F32x4, output: []F32x4) void {
|
||||
};
|
||||
|
||||
if ((log2_length & 1) == 0) {
|
||||
const rev32 = @intCast(u6, 32 - log2_length);
|
||||
const rev32 = @as(u6, @intCast(32 - log2_length));
|
||||
var index: usize = 0;
|
||||
while (index < length) : (index += 1) {
|
||||
const n = index * 4;
|
||||
const addr =
|
||||
(@intCast(usize, static.swizzle_table[n & 0xff]) << 24) |
|
||||
(@intCast(usize, static.swizzle_table[(n >> 8) & 0xff]) << 16) |
|
||||
(@intCast(usize, static.swizzle_table[(n >> 16) & 0xff]) << 8) |
|
||||
@intCast(usize, static.swizzle_table[(n >> 24) & 0xff]);
|
||||
(@as(usize, @intCast(static.swizzle_table[n & 0xff])) << 24) |
|
||||
(@as(usize, @intCast(static.swizzle_table[(n >> 8) & 0xff])) << 16) |
|
||||
(@as(usize, @intCast(static.swizzle_table[(n >> 16) & 0xff])) << 8) |
|
||||
@as(usize, @intCast(static.swizzle_table[(n >> 24) & 0xff]));
|
||||
f32_output[addr >> rev32] = input[index][0];
|
||||
f32_output[(0x40000000 | addr) >> rev32] = input[index][1];
|
||||
f32_output[(0x80000000 | addr) >> rev32] = input[index][2];
|
||||
f32_output[(0xC0000000 | addr) >> rev32] = input[index][3];
|
||||
}
|
||||
} else {
|
||||
const rev7 = @as(usize, 1) << @intCast(u6, log2_length - 3);
|
||||
const rev32 = @intCast(u6, 32 - (log2_length - 3));
|
||||
const rev7 = @as(usize, 1) << @as(u6, @intCast(log2_length - 3));
|
||||
const rev32 = @as(u6, @intCast(32 - (log2_length - 3)));
|
||||
var index: usize = 0;
|
||||
while (index < length) : (index += 1) {
|
||||
const n = index / 2;
|
||||
var addr =
|
||||
(((@intCast(usize, static.swizzle_table[n & 0xff]) << 24) |
|
||||
(@intCast(usize, static.swizzle_table[(n >> 8) & 0xff]) << 16) |
|
||||
(@intCast(usize, static.swizzle_table[(n >> 16) & 0xff]) << 8) |
|
||||
(@intCast(usize, static.swizzle_table[(n >> 24) & 0xff]))) >> rev32) |
|
||||
(((@as(usize, @intCast(static.swizzle_table[n & 0xff])) << 24) |
|
||||
(@as(usize, @intCast(static.swizzle_table[(n >> 8) & 0xff])) << 16) |
|
||||
(@as(usize, @intCast(static.swizzle_table[(n >> 16) & 0xff])) << 8) |
|
||||
(@as(usize, @intCast(static.swizzle_table[(n >> 24) & 0xff])))) >> rev32) |
|
||||
((index & 1) * rev7 * 4);
|
||||
f32_output[addr] = input[index][0];
|
||||
addr += rev7;
|
||||
@@ -4254,7 +4254,7 @@ pub fn fftInitUnityTable(out_unity_table: []F32x4) void {
|
||||
|
||||
const v0123 = f32x4(0.0, 1.0, 2.0, 3.0);
|
||||
var length = out_unity_table.len / 4;
|
||||
var vlstep = f32x4s(0.5 * math.pi / @floatFromInt(f32, length));
|
||||
var vlstep = f32x4s(0.5 * math.pi / @as(f32, @floatFromInt(length)));
|
||||
|
||||
while (true) {
|
||||
length /= 4;
|
||||
@@ -4293,7 +4293,7 @@ pub fn fftInitUnityTable(out_unity_table: []F32x4) void {
|
||||
}
|
||||
|
||||
pub fn fft(re: []F32x4, im: []F32x4, unity_table: []const F32x4) void {
|
||||
const length = @intCast(u32, re.len * 4);
|
||||
const length = @as(u32, @intCast(re.len * 4));
|
||||
assert(std.math.isPowerOfTwo(length));
|
||||
assert(length >= 4 and length <= 512);
|
||||
assert(re.len == im.len);
|
||||
@@ -4322,7 +4322,7 @@ pub fn fft(re: []F32x4, im: []F32x4, unity_table: []const F32x4) void {
|
||||
}
|
||||
|
||||
pub fn ifft(re: []F32x4, im: []const F32x4, unity_table: []const F32x4) void {
|
||||
const length = @intCast(u32, re.len * 4);
|
||||
const length = @as(u32, @intCast(re.len * 4));
|
||||
assert(std.math.isPowerOfTwo(length));
|
||||
assert(length >= 4 and length <= 512);
|
||||
assert(re.len == im.len);
|
||||
@@ -4332,8 +4332,8 @@ pub fn ifft(re: []F32x4, im: []const F32x4, unity_table: []const F32x4) void {
|
||||
var re_temp = re_temp_storage[0..re.len];
|
||||
var im_temp = im_temp_storage[0..im.len];
|
||||
|
||||
const rnp = f32x4s(1.0 / @floatFromInt(f32, length));
|
||||
const rnm = f32x4s(-1.0 / @floatFromInt(f32, length));
|
||||
const rnp = f32x4s(1.0 / @as(f32, @floatFromInt(length)));
|
||||
const rnm = f32x4s(-1.0 / @as(f32, @floatFromInt(length)));
|
||||
|
||||
for (re, 0..) |_, i| {
|
||||
re_temp[i] = re[i] * rnp;
|
||||
@@ -4403,7 +4403,7 @@ test "zmath.ifft" {
|
||||
var im = [_]F32x4{f32x4s(0.0)} ** 128;
|
||||
|
||||
for (&re, 0..) |*v, i| {
|
||||
const f = @floatFromInt(f32, i * 4);
|
||||
const f = @as(f32, @floatFromInt(i * 4));
|
||||
v.* = f32x4(f + 1.0, f + 2.0, f + 3.0, f + 4.0);
|
||||
}
|
||||
|
||||
@@ -4411,14 +4411,14 @@ test "zmath.ifft" {
|
||||
fft(re[0..], im[0..], unity_table[0..512]);
|
||||
|
||||
for (re, 0..) |v, i| {
|
||||
const f = @floatFromInt(f32, i * 4);
|
||||
const f = @as(f32, @floatFromInt(i * 4));
|
||||
try expect(!approxEqAbs(v, f32x4(f + 1.0, f + 2.0, f + 3.0, f + 4.0), epsilon));
|
||||
}
|
||||
|
||||
ifft(re[0..], im[0..], unity_table[0..512]);
|
||||
|
||||
for (re, 0..) |v, i| {
|
||||
const f = @floatFromInt(f32, i * 4);
|
||||
const f = @as(f32, @floatFromInt(i * 4));
|
||||
try expect(approxEqAbs(v, f32x4(f + 1.0, f + 2.0, f + 3.0, f + 4.0), epsilon));
|
||||
}
|
||||
}
|
||||
@@ -4428,28 +4428,28 @@ test "zmath.ifft" {
|
||||
// Private functions and constants
|
||||
//
|
||||
// ------------------------------------------------------------------------------
|
||||
const f32x4_sign_mask1: F32x4 = F32x4{ @bitCast(f32, @as(u32, 0x8000_0000)), 0, 0, 0 };
|
||||
const f32x4_sign_mask1: F32x4 = F32x4{ @as(f32, @bitCast(@as(u32, 0x8000_0000))), 0, 0, 0 };
|
||||
const f32x4_mask2: F32x4 = F32x4{
|
||||
@bitCast(f32, @as(u32, 0xffff_ffff)),
|
||||
@bitCast(f32, @as(u32, 0xffff_ffff)),
|
||||
@as(f32, @bitCast(@as(u32, 0xffff_ffff))),
|
||||
@as(f32, @bitCast(@as(u32, 0xffff_ffff))),
|
||||
0,
|
||||
0,
|
||||
};
|
||||
const f32x4_mask3: F32x4 = F32x4{
|
||||
@bitCast(f32, @as(u32, 0xffff_ffff)),
|
||||
@bitCast(f32, @as(u32, 0xffff_ffff)),
|
||||
@bitCast(f32, @as(u32, 0xffff_ffff)),
|
||||
@as(f32, @bitCast(@as(u32, 0xffff_ffff))),
|
||||
@as(f32, @bitCast(@as(u32, 0xffff_ffff))),
|
||||
@as(f32, @bitCast(@as(u32, 0xffff_ffff))),
|
||||
0,
|
||||
};
|
||||
|
||||
inline fn splatNegativeZero(comptime T: type) T {
|
||||
return @splat(veclen(T), @bitCast(f32, @as(u32, 0x8000_0000)));
|
||||
return @splat(veclen(T), @as(f32, @bitCast(@as(u32, 0x8000_0000))));
|
||||
}
|
||||
inline fn splatNoFraction(comptime T: type) T {
|
||||
return @splat(veclen(T), @as(f32, 8_388_608.0));
|
||||
}
|
||||
inline fn splatAbsMask(comptime T: type) T {
|
||||
return @splat(veclen(T), @bitCast(f32, @as(u32, 0x7fff_ffff)));
|
||||
return @splat(veclen(T), @as(f32, @bitCast(@as(u32, 0x7fff_ffff))));
|
||||
}
|
||||
|
||||
fn floatToIntAndBack(v: anytype) @TypeOf(v) {
|
||||
@@ -4463,14 +4463,14 @@ fn floatToIntAndBack(v: anytype) @TypeOf(v) {
|
||||
comptime var i: u32 = 0;
|
||||
// vcvttps2dq
|
||||
inline while (i < len) : (i += 1) {
|
||||
vi32[i] = @intFromFloat(i32, v[i]);
|
||||
vi32[i] = @as(i32, @intFromFloat(v[i]));
|
||||
}
|
||||
|
||||
var vf32: [len]f32 = undefined;
|
||||
i = 0;
|
||||
// vcvtdq2ps
|
||||
inline while (i < len) : (i += 1) {
|
||||
vf32[i] = @floatFromInt(f32, vi32[i]);
|
||||
vf32[i] = @as(f32, @floatFromInt(vi32[i]));
|
||||
}
|
||||
|
||||
return vf32;
|
||||
|
||||
+27
-27
@@ -31,54 +31,54 @@ pub fn init(
|
||||
maybe_texcoords: ?std.ArrayList([2]f32),
|
||||
) Shape {
|
||||
const handle = par_shapes_create_empty();
|
||||
const parmesh = @ptrCast(
|
||||
const parmesh = @as(
|
||||
*ParShape,
|
||||
@alignCast(@alignOf(ParShape), handle),
|
||||
@ptrCast(@alignCast(handle)),
|
||||
);
|
||||
|
||||
parmesh.triangles = @ptrCast(
|
||||
parmesh.triangles = @as(
|
||||
[*]IndexType,
|
||||
@alignCast(@alignOf(IndexType), zmeshMalloc(indices.items.len * @sizeOf(IndexType))),
|
||||
@ptrCast(@alignCast(zmeshMalloc(indices.items.len * @sizeOf(IndexType)))),
|
||||
);
|
||||
parmesh.ntriangles = @intCast(c_int, @divExact(indices.items.len, 3));
|
||||
parmesh.ntriangles = @as(c_int, @intCast(@divExact(indices.items.len, 3)));
|
||||
std.mem.copy(IndexType, parmesh.triangles[0..indices.items.len], indices.items);
|
||||
|
||||
parmesh.points = @ptrCast(
|
||||
parmesh.points = @as(
|
||||
[*]f32,
|
||||
@alignCast(@alignOf(f32), zmeshMalloc(positions.items.len * @sizeOf(f32) * 3)),
|
||||
@ptrCast(@alignCast(zmeshMalloc(positions.items.len * @sizeOf(f32) * 3))),
|
||||
);
|
||||
parmesh.npoints = @intCast(c_int, positions.items.len);
|
||||
parmesh.npoints = @as(c_int, @intCast(positions.items.len));
|
||||
std.mem.copy(
|
||||
f32,
|
||||
parmesh.points[0 .. positions.items.len * 3],
|
||||
@ptrCast([*]f32, positions.items.ptr)[0 .. positions.items.len * 3],
|
||||
@as([*]f32, @ptrCast(positions.items.ptr))[0 .. positions.items.len * 3],
|
||||
);
|
||||
|
||||
if (maybe_normals) |normals| {
|
||||
assert(normals.items.len == positions.items.len);
|
||||
|
||||
parmesh.normals = @ptrCast(
|
||||
parmesh.normals = @as(
|
||||
[*]f32,
|
||||
@alignCast(@alignOf(f32), zmeshMalloc(normals.items.len * @sizeOf(f32) * 3)),
|
||||
@ptrCast(@alignCast(zmeshMalloc(normals.items.len * @sizeOf(f32) * 3))),
|
||||
);
|
||||
std.mem.copy(
|
||||
f32,
|
||||
parmesh.normals.?[0 .. normals.items.len * 3],
|
||||
@ptrCast([*]f32, normals.items.ptr)[0 .. normals.items.len * 3],
|
||||
@as([*]f32, @ptrCast(normals.items.ptr))[0 .. normals.items.len * 3],
|
||||
);
|
||||
}
|
||||
|
||||
if (maybe_texcoords) |texcoords| {
|
||||
assert(texcoords.items.len == positions.items.len);
|
||||
|
||||
parmesh.tcoords = @ptrCast(
|
||||
parmesh.tcoords = @as(
|
||||
[*]f32,
|
||||
@alignCast(@alignOf(f32), zmeshMalloc(texcoords.items.len * @sizeOf(f32) * 2)),
|
||||
@ptrCast(@alignCast(zmeshMalloc(texcoords.items.len * @sizeOf(f32) * 2))),
|
||||
);
|
||||
std.mem.copy(
|
||||
f32,
|
||||
parmesh.tcoords.?[0 .. texcoords.items.len * 2],
|
||||
@ptrCast([*]f32, texcoords.items.ptr)[0 .. texcoords.items.len * 2],
|
||||
@as([*]f32, @ptrCast(texcoords.items.ptr))[0 .. texcoords.items.len * 2],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,31 +150,31 @@ pub fn computeNormals(mesh: *Shape) void {
|
||||
}
|
||||
|
||||
fn initShape(handle: ShapeHandle) Shape {
|
||||
const parmesh = @ptrCast(
|
||||
const parmesh = @as(
|
||||
*ParShape,
|
||||
@alignCast(@alignOf(ParShape), handle),
|
||||
@ptrCast(@alignCast(handle)),
|
||||
);
|
||||
return .{
|
||||
.handle = handle,
|
||||
.positions = @ptrCast(
|
||||
.positions = @as(
|
||||
[*][3]f32,
|
||||
parmesh.points,
|
||||
)[0..@intCast(usize, parmesh.npoints)],
|
||||
.indices = parmesh.triangles[0..@intCast(usize, parmesh.ntriangles * 3)],
|
||||
@ptrCast(parmesh.points),
|
||||
)[0..@as(usize, @intCast(parmesh.npoints))],
|
||||
.indices = parmesh.triangles[0..@as(usize, @intCast(parmesh.ntriangles * 3))],
|
||||
.normals = if (parmesh.normals == null)
|
||||
null
|
||||
else
|
||||
@ptrCast(
|
||||
@as(
|
||||
[*][3]f32,
|
||||
parmesh.normals.?,
|
||||
)[0..@intCast(usize, parmesh.npoints)],
|
||||
@ptrCast(parmesh.normals.?),
|
||||
)[0..@as(usize, @intCast(parmesh.npoints))],
|
||||
.texcoords = if (parmesh.tcoords == null)
|
||||
null
|
||||
else
|
||||
@ptrCast(
|
||||
@as(
|
||||
[*][2]f32,
|
||||
parmesh.tcoords.?,
|
||||
)[0..@intCast(usize, parmesh.npoints)],
|
||||
@ptrCast(parmesh.tcoords.?),
|
||||
)[0..@as(usize, @intCast(parmesh.npoints))],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -39,8 +39,8 @@ pub fn appendMeshPrimitive(
|
||||
const mesh = &data.meshes.?[mesh_index];
|
||||
const prim = &mesh.primitives[prim_index];
|
||||
|
||||
const num_vertices: u32 = @intCast(u32, prim.attributes[0].data.count);
|
||||
const num_indices: u32 = @intCast(u32, prim.indices.?.count);
|
||||
const num_vertices: u32 = @as(u32, @intCast(prim.attributes[0].data.count));
|
||||
const num_indices: u32 = @as(u32, @intCast(prim.indices.?.count));
|
||||
|
||||
// Indices.
|
||||
{
|
||||
@@ -53,26 +53,26 @@ pub fn appendMeshPrimitive(
|
||||
assert(accessor.stride * accessor.count == buffer_view.size);
|
||||
assert(buffer_view.buffer.data != null);
|
||||
|
||||
const data_addr = @alignCast(4, @ptrCast([*]const u8, buffer_view.buffer.data) +
|
||||
accessor.offset + buffer_view.offset);
|
||||
const data_addr = @as([*]const u8, @ptrCast(buffer_view.buffer.data)) +
|
||||
accessor.offset + buffer_view.offset;
|
||||
|
||||
if (accessor.stride == 1) {
|
||||
assert(accessor.component_type == .r_8u);
|
||||
const src = @ptrCast([*]const u8, data_addr);
|
||||
const src = @as([*]const u8, @ptrCast(data_addr));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
}
|
||||
} else if (accessor.stride == 2) {
|
||||
assert(accessor.component_type == .r_16u);
|
||||
const src = @ptrCast([*]const u16, data_addr);
|
||||
const src = @as([*]const u16, @ptrCast(@alignCast(data_addr)));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
}
|
||||
} else if (accessor.stride == 4) {
|
||||
assert(accessor.component_type == .r_32u);
|
||||
const src = @ptrCast([*]const u32, data_addr);
|
||||
const src = @as([*]const u32, @ptrCast(@alignCast(data_addr)));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
@@ -95,29 +95,29 @@ pub fn appendMeshPrimitive(
|
||||
assert(accessor.stride == buffer_view.stride or buffer_view.stride == 0);
|
||||
assert(accessor.stride * accessor.count == buffer_view.size);
|
||||
|
||||
const data_addr = @ptrCast([*]const u8, buffer_view.buffer.data) +
|
||||
const data_addr = @as([*]const u8, @ptrCast(buffer_view.buffer.data)) +
|
||||
accessor.offset + buffer_view.offset;
|
||||
|
||||
if (attrib.type == .position) {
|
||||
assert(accessor.type == .vec3);
|
||||
const slice = @ptrCast([*]const [3]f32, @alignCast(4, data_addr))[0..num_vertices];
|
||||
const slice = @as([*]const [3]f32, @ptrCast(@alignCast(data_addr)))[0..num_vertices];
|
||||
try positions.appendSlice(slice);
|
||||
} else if (attrib.type == .normal) {
|
||||
if (normals) |n| {
|
||||
assert(accessor.type == .vec3);
|
||||
const slice = @ptrCast([*]const [3]f32, @alignCast(4, data_addr))[0..num_vertices];
|
||||
const slice = @as([*]const [3]f32, @ptrCast(@alignCast(data_addr)))[0..num_vertices];
|
||||
try n.appendSlice(slice);
|
||||
}
|
||||
} else if (attrib.type == .texcoord) {
|
||||
if (texcoords0) |tc| {
|
||||
assert(accessor.type == .vec2);
|
||||
const slice = @ptrCast([*]const [2]f32, @alignCast(4, data_addr))[0..num_vertices];
|
||||
const slice = @as([*]const [2]f32, @ptrCast(@alignCast(data_addr)))[0..num_vertices];
|
||||
try tc.appendSlice(slice);
|
||||
}
|
||||
} else if (attrib.type == .tangent) {
|
||||
if (tangents) |tan| {
|
||||
assert(accessor.type == .vec4);
|
||||
const slice = @ptrCast([*]const [4]f32, @alignCast(4, data_addr))[0..num_vertices];
|
||||
const slice = @as([*]const [4]f32, @ptrCast(@alignCast(data_addr)))[0..num_vertices];
|
||||
try tan.appendSlice(slice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ extern var zmeshCallocPtr: ?*const fn (num: usize, size: usize) callconv(.C) ?*a
|
||||
fn zmeshCalloc(num: usize, size: usize) callconv(.C) ?*anyopaque {
|
||||
const ptr = zmeshMalloc(num * size);
|
||||
if (ptr != null) {
|
||||
@memset(@ptrCast([*]u8, ptr)[0 .. num * size], 0);
|
||||
@memset(@as([*]u8, @ptrCast(ptr))[0 .. num * size], 0);
|
||||
return ptr;
|
||||
}
|
||||
return null;
|
||||
@@ -75,7 +75,7 @@ fn zmeshRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {
|
||||
const old_size = if (ptr != null) mem_allocations.?.get(@intFromPtr(ptr.?)).? else 0;
|
||||
|
||||
var old_mem = if (old_size > 0)
|
||||
@ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..old_size]
|
||||
@as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..old_size]
|
||||
else
|
||||
@as([*]align(mem_alignment) u8, undefined)[0..0];
|
||||
|
||||
@@ -99,7 +99,7 @@ fn zmeshFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
|
||||
defer mem_mutex.unlock();
|
||||
|
||||
const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
|
||||
const mem = @ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..size];
|
||||
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
|
||||
mem_allocator.?.free(mem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,10 +1111,10 @@ pub fn texImage2D(args: struct {
|
||||
assert(args.height > 0);
|
||||
bindings.texImage2D(
|
||||
@intFromEnum(args.target),
|
||||
@bitCast(Int, args.level),
|
||||
@as(Int, @bitCast(args.level)),
|
||||
@intFromEnum(args.internal_format),
|
||||
@bitCast(Sizei, args.width),
|
||||
@bitCast(Sizei, args.height),
|
||||
@as(Sizei, @bitCast(args.width)),
|
||||
@as(Sizei, @bitCast(args.height)),
|
||||
0,
|
||||
@intFromEnum(args.format),
|
||||
@intFromEnum(args.pixel_type),
|
||||
@@ -1235,7 +1235,7 @@ pub fn getString(name: StringName) [*:0]const u8 {
|
||||
|
||||
// pub var viewport: *const fn (x: Int, y: Int, width: Sizei, height: Sizei) callconv(.C) void = undefined;
|
||||
pub fn viewport(x: Int, y: Int, width: u32, height: u32) void {
|
||||
bindings.viewport(x, y, @bitCast(Sizei, width), @bitCast(Sizei, height));
|
||||
bindings.viewport(x, y, @as(Sizei, @bitCast(width)), @as(Sizei, @bitCast(height)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1280,7 +1280,7 @@ pub const VERTEX_ARRAY = bindings.VERTEX_ARRAY;
|
||||
|
||||
// pub var drawArrays: *const fn (mode: Enum, first: Int, count: Sizei) callconv(.C) void = undefined;
|
||||
pub fn drawArrays(prim_type: PrimitiveType, first: u32, count: u32) void {
|
||||
bindings.drawArrays(@intFromEnum(prim_type), @bitCast(Int, first), @bitCast(Sizei, count));
|
||||
bindings.drawArrays(@intFromEnum(prim_type), @as(Int, @bitCast(first)), @as(Sizei, @bitCast(count)));
|
||||
}
|
||||
|
||||
// pub var drawElements: *const fn (
|
||||
@@ -1350,28 +1350,28 @@ pub fn drawArrays(prim_type: PrimitiveType, first: u32, count: u32) void {
|
||||
|
||||
// pub var bindTexture: *const fn (target: Enum, texture: Uint) callconv(.C) void = undefined;
|
||||
pub fn bindTexture(target: TextureTarget, texture: Texture) void {
|
||||
bindings.bindTexture(@intFromEnum(target), @bitCast(Uint, texture));
|
||||
bindings.bindTexture(@intFromEnum(target), @as(Uint, @bitCast(texture)));
|
||||
}
|
||||
|
||||
// pub var deleteTextures: *const fn (n: Sizei, textures: [*c]const Uint) callconv(.C) void = undefined;
|
||||
pub fn deleteTexture(ptr: *const Texture) void {
|
||||
bindings.deleteTextures(1, @ptrCast([*c]const Uint, ptr));
|
||||
bindings.deleteTextures(1, @as([*c]const Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn deleteTextures(textures: []const Texture) void {
|
||||
bindings.deleteTextures(textures.len, @ptrCast([*c]const Uint, textures.ptr));
|
||||
bindings.deleteTextures(textures.len, @as([*c]const Uint, @ptrCast(textures.ptr)));
|
||||
}
|
||||
|
||||
// pub var genTextures: *const fn (n: Sizei, textures: [*c]Uint) callconv(.C) void = undefined;
|
||||
pub fn genTexture(ptr: *Texture) void {
|
||||
bindings.genTextures(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.genTextures(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn genTextures(textures: []Texture) void {
|
||||
bindings.genTextures(textures.len, @ptrCast([*c]Uint, textures.ptr));
|
||||
bindings.genTextures(textures.len, @as([*c]Uint, @ptrCast(textures.ptr)));
|
||||
}
|
||||
|
||||
// pub var isTexture: *const fn (texture: Uint) callconv(.C) Boolean = undefined;
|
||||
pub fn isTexture(texture: Texture) bool {
|
||||
return bindings.isTexture(@bitCast(Uint, texture)) == TRUE;
|
||||
return bindings.isTexture(@as(Uint, @bitCast(texture))) == TRUE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1697,17 +1697,17 @@ pub const SRC1_ALPHA = bindings.SRC1_ALPHA;
|
||||
|
||||
// pub var bindBuffer: *const fn (target: Enum, buffer: Uint) callconv(.C) void = undefined;
|
||||
pub fn bindBuffer(target: BufferTarget, buffer: Buffer) void {
|
||||
bindings.bindBuffer(@intFromEnum(target), @bitCast(Uint, buffer));
|
||||
bindings.bindBuffer(@intFromEnum(target), @as(Uint, @bitCast(buffer)));
|
||||
}
|
||||
|
||||
// pub var deleteBuffers: *const fn (n: Sizei, buffers: [*c]const Uint) callconv(.C) void = undefined;
|
||||
|
||||
// pub var genBuffers: *const fn (n: Sizei, buffers: [*c]Uint) callconv(.C) void = undefined;
|
||||
pub fn genBuffer(ptr: *Buffer) void {
|
||||
bindings.genBuffers(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.genBuffers(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn genBuffers(buffers: []Buffer) void {
|
||||
bindings.genBuffers(buffers.len, @ptrCast([*c]Uint, buffers.ptr));
|
||||
bindings.genBuffers(buffers.len, @as([*c]Uint, @ptrCast(buffers.ptr)));
|
||||
}
|
||||
|
||||
// pub var isBuffer: *const fn (buffer: Uint) callconv(.C) Boolean = undefined;
|
||||
@@ -1727,7 +1727,7 @@ pub fn bufferData(
|
||||
assert(size > 0);
|
||||
bindings.bufferData(
|
||||
@intFromEnum(target),
|
||||
@bitCast(Sizeiptr, size),
|
||||
@as(Sizeiptr, @bitCast(size)),
|
||||
bytes,
|
||||
@intFromEnum(usage),
|
||||
);
|
||||
@@ -1743,8 +1743,8 @@ pub fn bufferSubData(target: BufferTarget, offset: usize, bytes: []const u8) voi
|
||||
assert(bytes.len > 0);
|
||||
bindings.bufferSubData(
|
||||
@intFromEnum(target),
|
||||
@bitCast(Intptr, offset),
|
||||
@bitCast(Sizeiptr, bytes.len),
|
||||
@as(Intptr, @bitCast(offset)),
|
||||
@as(Sizeiptr, @bitCast(bytes.len)),
|
||||
bytes.ptr,
|
||||
);
|
||||
}
|
||||
@@ -1867,9 +1867,9 @@ pub const STENCIL_BACK_WRITEMASK = bindings.STENCIL_BACK_WRITEMASK;
|
||||
|
||||
// pub var attachShader: *const fn (program: Uint, shader: Uint) callconv(.C) void = undefined;
|
||||
pub fn attachShader(program: Program, shader: Shader) void {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
bindings.attachShader(@bitCast(Uint, program), @bitCast(Uint, shader));
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
bindings.attachShader(@as(Uint, @bitCast(program)), @as(Uint, @bitCast(shader)));
|
||||
}
|
||||
|
||||
// pub var bindAttribLocation: *const fn (
|
||||
@@ -1880,26 +1880,26 @@ pub fn attachShader(program: Program, shader: Shader) void {
|
||||
|
||||
// pub var compileShader: *const fn (shader: Uint) callconv(.C) void = undefined;
|
||||
pub fn compileShader(shader: Shader) void {
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
bindings.compileShader(@bitCast(Uint, shader));
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
bindings.compileShader(@as(Uint, @bitCast(shader)));
|
||||
}
|
||||
|
||||
// pub var createProgram: *const fn () callconv(.C) Uint = undefined;
|
||||
pub fn createProgram() Program {
|
||||
return @bitCast(Program, bindings.createProgram());
|
||||
return @as(Program, @bitCast(bindings.createProgram()));
|
||||
}
|
||||
|
||||
// pub var createShader: *const fn (type: Enum) callconv(.C) Uint = undefined;
|
||||
pub fn createShader(@"type": ShaderType) Shader {
|
||||
return @bitCast(Shader, bindings.createShader(@intFromEnum(@"type")));
|
||||
return @as(Shader, @bitCast(bindings.createShader(@intFromEnum(@"type"))));
|
||||
}
|
||||
|
||||
// pub var deleteProgram: *const fn (program: Uint) callconv(.C) void = undefined;
|
||||
|
||||
// pub var deleteShader: *const fn (shader: Uint) callconv(.C) void = undefined;
|
||||
pub fn deleteShader(shader: Shader) void {
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
bindings.deleteShader(@bitCast(Uint, shader));
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
bindings.deleteShader(@as(Uint, @bitCast(shader)));
|
||||
}
|
||||
|
||||
// pub var detachShader: *const fn (program: Uint, shader: Uint) callconv(.C) void = undefined;
|
||||
@@ -1907,7 +1907,7 @@ pub fn deleteShader(shader: Shader) void {
|
||||
|
||||
// pub var enableVertexAttribArray: *const fn (index: Uint) callconv(.C) void = undefined;
|
||||
pub fn enableVertexAttribArray(location: VertexAttribLocation) void {
|
||||
bindings.enableVertexAttribArray(@bitCast(Uint, location));
|
||||
bindings.enableVertexAttribArray(@as(Uint, @bitCast(location)));
|
||||
}
|
||||
|
||||
// pub var getActiveAttrib: *const fn (
|
||||
@@ -1937,19 +1937,19 @@ pub fn enableVertexAttribArray(location: VertexAttribLocation) void {
|
||||
|
||||
// pub var getAttribLocation: *const fn (program: Uint, name: [*c]const Char) callconv(.C) Int = undefined;
|
||||
pub fn getAttribLocation(program: Program, name: [:0]const u8) ?VertexAttribLocation {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
const location = bindings.getAttribLocation(
|
||||
@bitCast(Uint, program),
|
||||
@ptrCast([*c]const Char, name.ptr),
|
||||
@as(Uint, @bitCast(program)),
|
||||
@as([*c]const Char, @ptrCast(name.ptr)),
|
||||
);
|
||||
return if (location >= 0) @bitCast(VertexAttribLocation, location) else null;
|
||||
return if (location >= 0) @as(VertexAttribLocation, @bitCast(location)) else null;
|
||||
}
|
||||
|
||||
// pub var getProgramiv: *const fn (program: Uint, pname: Enum, params: [*c]Int) callconv(.C) void = undefined;
|
||||
pub fn getProgramiv(program: Program, parameter: ProgramParameter) Int {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
var value: Int = undefined;
|
||||
bindings.getProgramiv(@bitCast(Uint, program), @intFromEnum(parameter), &value);
|
||||
bindings.getProgramiv(@as(Uint, @bitCast(program)), @intFromEnum(parameter), &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1960,24 +1960,24 @@ pub fn getProgramiv(program: Program, parameter: ProgramParameter) Int {
|
||||
// infoLog: [*c]Char,
|
||||
// ) callconv(.C) void = undefined;
|
||||
pub fn getProgramInfoLog(program: Program, buffer: []u8) ?[]const u8 {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
assert(buffer.len > 0);
|
||||
assert(buffer.len <= std.math.maxInt(u32));
|
||||
var log_len: Sizei = 0;
|
||||
bindings.getProgramInfoLog(
|
||||
@bitCast(Uint, program),
|
||||
@bitCast(Sizei, @intCast(u32, buffer.len)),
|
||||
@as(Uint, @bitCast(program)),
|
||||
@as(Sizei, @bitCast(@as(u32, @intCast(buffer.len)))),
|
||||
&log_len,
|
||||
@ptrCast([*c]Char, buffer.ptr),
|
||||
@as([*c]Char, @ptrCast(buffer.ptr)),
|
||||
);
|
||||
return if (log_len > 0) buffer[0..@intCast(usize, log_len)] else null;
|
||||
return if (log_len > 0) buffer[0..@as(usize, @intCast(log_len))] else null;
|
||||
}
|
||||
|
||||
// pub var getShaderiv: *const fn (shader: Uint, pname: Enum, params: [*c]Int) callconv(.C) void = undefined;
|
||||
pub fn getShaderiv(shader: Shader, parameter: ShaderParameter) Int {
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
var value: Int = undefined;
|
||||
bindings.getShaderiv(@bitCast(Uint, shader), @intFromEnum(parameter), &value);
|
||||
bindings.getShaderiv(@as(Uint, @bitCast(shader)), @intFromEnum(parameter), &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1988,17 +1988,17 @@ pub fn getShaderiv(shader: Shader, parameter: ShaderParameter) Int {
|
||||
// infoLog: [*c]Char,
|
||||
// ) callconv(.C) void = undefined;
|
||||
pub fn getShaderInfoLog(shader: Shader, buffer: []u8) ?[]const u8 {
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
assert(buffer.len > 0);
|
||||
assert(buffer.len <= std.math.maxInt(u32));
|
||||
var log_len: Sizei = 0;
|
||||
bindings.getShaderInfoLog(
|
||||
@bitCast(Uint, shader),
|
||||
@bitCast(Sizei, @intCast(u32, buffer.len)),
|
||||
@as(Uint, @bitCast(shader)),
|
||||
@as(Sizei, @bitCast(@as(u32, @intCast(buffer.len)))),
|
||||
&log_len,
|
||||
@ptrCast([*c]Char, buffer.ptr),
|
||||
@as([*c]Char, @ptrCast(buffer.ptr)),
|
||||
);
|
||||
return if (log_len > 0) buffer[0..@intCast(usize, log_len)] else null;
|
||||
return if (log_len > 0) buffer[0..@as(usize, @intCast(log_len))] else null;
|
||||
}
|
||||
|
||||
// pub var getShaderSource: *const fn (
|
||||
@@ -2010,12 +2010,12 @@ pub fn getShaderInfoLog(shader: Shader, buffer: []u8) ?[]const u8 {
|
||||
|
||||
// pub var getUniformLocation: *const fn (program: Uint, name: [*c]const Char) callconv(.C) Int = undefined;
|
||||
pub fn getUniformLocation(program: Program, name: [:0]const u8) ?UniformLocation {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
const location = bindings.getUniformLocation(
|
||||
@bitCast(Uint, program),
|
||||
@ptrCast([*c]const Char, name.ptr),
|
||||
@as(Uint, @bitCast(program)),
|
||||
@as([*c]const Char, @ptrCast(name.ptr)),
|
||||
);
|
||||
return if (location >= 0) @bitCast(UniformLocation, location) else null;
|
||||
return if (location >= 0) @as(UniformLocation, @bitCast(location)) else null;
|
||||
}
|
||||
|
||||
// pub var getUniformfv: *const fn (program: Uint, location: Int, params: [*c]Float) callconv(.C) void = undefined;
|
||||
@@ -2033,8 +2033,8 @@ pub fn getUniformLocation(program: Program, name: [:0]const u8) ?UniformLocation
|
||||
|
||||
// pub var linkProgram: *const fn (program: Uint) callconv(.C) void = undefined;
|
||||
pub fn linkProgram(program: Program) void {
|
||||
assert(@bitCast(Uint, program) > 0);
|
||||
bindings.linkProgram(@bitCast(Uint, program));
|
||||
assert(@as(Uint, @bitCast(program)) > 0);
|
||||
bindings.linkProgram(@as(Uint, @bitCast(program)));
|
||||
}
|
||||
|
||||
// pub var shaderSource: *const fn (
|
||||
@@ -2044,36 +2044,36 @@ pub fn linkProgram(program: Program) void {
|
||||
// length: [*c]const Int,
|
||||
// ) callconv(.C) void = undefined;
|
||||
pub fn shaderSource(shader: Shader, src_ptrs: []const [*:0]const u8, src_lengths: []const u32) void {
|
||||
assert(@bitCast(Uint, shader) > 0);
|
||||
assert(@as(Uint, @bitCast(shader)) > 0);
|
||||
assert(src_ptrs.len > 0);
|
||||
assert(src_ptrs.len <= std.math.maxInt(u32));
|
||||
assert(src_ptrs.len == src_lengths.len);
|
||||
bindings.shaderSource(
|
||||
@bitCast(Uint, shader),
|
||||
@bitCast(Sizei, @intCast(u32, src_ptrs.len)),
|
||||
@ptrCast([*c]const [*c]const Char, src_ptrs),
|
||||
@ptrCast([*c]const Int, src_lengths.ptr),
|
||||
@as(Uint, @bitCast(shader)),
|
||||
@as(Sizei, @bitCast(@as(u32, @intCast(src_ptrs.len)))),
|
||||
@as([*c]const [*c]const Char, @ptrCast(src_ptrs)),
|
||||
@as([*c]const Int, @ptrCast(src_lengths.ptr)),
|
||||
);
|
||||
}
|
||||
|
||||
// pub var useProgram: *const fn (program: Uint) callconv(.C) void = undefined;
|
||||
pub fn useProgram(program: Program) void {
|
||||
bindings.useProgram(@bitCast(Uint, program));
|
||||
bindings.useProgram(@as(Uint, @bitCast(program)));
|
||||
}
|
||||
|
||||
// pub var uniform1f: *const fn (location: Int, v0: Float) callconv(.C) void = undefined;
|
||||
pub fn uniform1f(location: UniformLocation, v0: f32) void {
|
||||
bindings.uniform1f(@bitCast(Int, location), v0);
|
||||
bindings.uniform1f(@as(Int, @bitCast(location)), v0);
|
||||
}
|
||||
|
||||
// pub var uniform2f: *const fn (location: Int, v0: Float, v1: Float) callconv(.C) void = undefined;
|
||||
pub fn uniform2f(location: UniformLocation, v0: f32, v1: f32) void {
|
||||
bindings.uniform2f(@bitCast(Int, location), v0, v1);
|
||||
bindings.uniform2f(@as(Int, @bitCast(location)), v0, v1);
|
||||
}
|
||||
|
||||
// pub var uniform3f: *const fn (location: Int, v0: Float, v1: Float, v2: Float) callconv(.C) void = undefined;
|
||||
pub fn uniform3f(location: UniformLocation, v0: f32, v1: f32, v2: f32) void {
|
||||
bindings.uniform3f(@bitCast(Int, location), v0, v1, v2);
|
||||
bindings.uniform3f(@as(Int, @bitCast(location)), v0, v1, v2);
|
||||
}
|
||||
|
||||
// pub var uniform4f: *const fn (
|
||||
@@ -2084,12 +2084,12 @@ pub fn uniform3f(location: UniformLocation, v0: f32, v1: f32, v2: f32) void {
|
||||
// v3: Float,
|
||||
// ) callconv(.C) void = undefined;
|
||||
pub fn uniform4f(location: UniformLocation, v0: f32, v1: f32, v2: f32, v3: f32) void {
|
||||
bindings.uniform4f(@bitCast(Int, location), v0, v1, v2, v3);
|
||||
bindings.uniform4f(@as(Int, @bitCast(location)), v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
// pub var uniform1i: *const fn (location: Int, v0: Int) callconv(.C) void = undefined;
|
||||
pub fn uniform1i(location: UniformLocation, value: Int) void {
|
||||
bindings.uniform1i(@bitCast(Int, location), value);
|
||||
bindings.uniform1i(@as(Int, @bitCast(location)), value);
|
||||
}
|
||||
|
||||
// pub var uniform2i: *const fn (location: Int, v0: Int, v1: Int) callconv(.C) void = undefined;
|
||||
@@ -2151,8 +2151,8 @@ pub fn uniformMatrix4fv(
|
||||
value: [*]const f32,
|
||||
) void {
|
||||
bindings.uniformMatrix4fv(
|
||||
@bitCast(Int, location),
|
||||
@bitCast(Sizei, count),
|
||||
@as(Int, @bitCast(location)),
|
||||
@as(Sizei, @bitCast(count)),
|
||||
transpose,
|
||||
value,
|
||||
);
|
||||
@@ -2237,12 +2237,12 @@ pub fn vertexAttribPointer(
|
||||
offset: usize,
|
||||
) void {
|
||||
bindings.vertexAttribPointer(
|
||||
@bitCast(Uint, location),
|
||||
@bitCast(Int, size),
|
||||
@as(Uint, @bitCast(location)),
|
||||
@as(Int, @bitCast(size)),
|
||||
@intFromEnum(attrib_type),
|
||||
normalised,
|
||||
@bitCast(Sizei, stride),
|
||||
@ptrFromInt(*allowzero const anyopaque, offset),
|
||||
@as(Sizei, @bitCast(stride)),
|
||||
@as(*allowzero const anyopaque, @ptrFromInt(offset)),
|
||||
);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2659,28 +2659,28 @@ pub fn getStringi(name: StringName, index: Uint) [*:0]const u8 {
|
||||
|
||||
// pub var isRenderbuffer: *const fn (renderbuffer: Uint) callconv(.C) Boolean = undefined;
|
||||
pub fn isRenderbuffer(renderbuffer: Renderbuffer) bool {
|
||||
return bindings.isRenderbuffer(@bitCast(Uint, renderbuffer)) == TRUE;
|
||||
return bindings.isRenderbuffer(@as(Uint, @bitCast(renderbuffer))) == TRUE;
|
||||
}
|
||||
|
||||
// pub var bindRenderbuffer: *const fn (target: Enum, renderbuffer: Uint) callconv(.C) void = undefined;
|
||||
pub fn bindRenderbuffer(target: RenderbufferTarget, renderbuffer: Renderbuffer) void {
|
||||
bindings.bindRenderbuffer(@intFromEnum(target), @bitCast(Uint, renderbuffer));
|
||||
bindings.bindRenderbuffer(@intFromEnum(target), @as(Uint, @bitCast(renderbuffer)));
|
||||
}
|
||||
|
||||
// pub var deleteRenderbuffers: *const fn (n: Sizei, renderbuffers: [*c]const Uint) callconv(.C) void = undefined;
|
||||
pub fn deleteRenderbuffer(ptr: *const Renderbuffer) void {
|
||||
bindings.deleteRenderbuffers(1, @ptrCast([*c]const Uint, ptr));
|
||||
bindings.deleteRenderbuffers(1, @as([*c]const Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn deleteRenderbuffers(renderbuffers: []const Renderbuffer) void {
|
||||
bindings.deleteRenderbuffers(renderbuffers.len, @ptrCast([*c]const Uint, renderbuffers.ptr));
|
||||
bindings.deleteRenderbuffers(renderbuffers.len, @as([*c]const Uint, @ptrCast(renderbuffers.ptr)));
|
||||
}
|
||||
|
||||
// pub var genRenderbuffers: *const fn (n: Sizei, renderbuffers: [*c]Uint) callconv(.C) void = undefined;
|
||||
pub fn genRenderbuffer(ptr: *Renderbuffer) void {
|
||||
bindings.genRenderbuffers(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.genRenderbuffers(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn genRenderbuffers(renderbuffers: []Renderbuffer) void {
|
||||
bindings.genRenderbuffers(renderbuffers.len, @ptrCast([*c]Uint, renderbuffers.ptr));
|
||||
bindings.genRenderbuffers(renderbuffers.len, @as([*c]Uint, @ptrCast(renderbuffers.ptr)));
|
||||
}
|
||||
|
||||
// pub var renderbufferStorage: *const fn (
|
||||
@@ -2698,8 +2698,8 @@ pub fn renderbufferStorage(
|
||||
bindings.renderbufferStorage(
|
||||
@intFromEnum(target),
|
||||
@intFromEnum(internal_format),
|
||||
@bitCast(Sizei, width),
|
||||
@bitCast(Sizei, height),
|
||||
@as(Sizei, @bitCast(width)),
|
||||
@as(Sizei, @bitCast(height)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2711,28 +2711,28 @@ pub fn renderbufferStorage(
|
||||
|
||||
// pub var isFramebuffer: *const fn (framebuffer: Uint) callconv(.C) Boolean = undefined;
|
||||
pub fn isFramebuffer(framebuffer: Framebuffer) bool {
|
||||
return bindings.isFramebuffer(@bitCast(Uint, framebuffer)) == TRUE;
|
||||
return bindings.isFramebuffer(@as(Uint, @bitCast(framebuffer))) == TRUE;
|
||||
}
|
||||
|
||||
// pub var bindFramebuffer: *const fn (target: Enum, framebuffer: Uint) callconv(.C) void = undefined;
|
||||
pub fn bindFramebuffer(target: FramebufferTarget, framebuffer: Framebuffer) void {
|
||||
bindings.bindFramebuffer(@intFromEnum(target), @bitCast(Uint, framebuffer));
|
||||
bindings.bindFramebuffer(@intFromEnum(target), @as(Uint, @bitCast(framebuffer)));
|
||||
}
|
||||
|
||||
// pub var deleteFramebuffers: *const fn (n: Sizei, framebuffers: [*c]const Uint) callconv(.C) void = undefined;
|
||||
pub fn deleteFramebuffer(ptr: *const Framebuffer) void {
|
||||
bindings.deleteFramebuffers(1, @ptrCast([*c]const Uint, ptr));
|
||||
bindings.deleteFramebuffers(1, @as([*c]const Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn deleteFramebuffers(framebuffers: []const Framebuffer) void {
|
||||
bindings.deleteFramebuffers(framebuffers.len, @ptrCast([*c]const Uint, framebuffers.ptr));
|
||||
bindings.deleteFramebuffers(framebuffers.len, @as([*c]const Uint, @ptrCast(framebuffers.ptr)));
|
||||
}
|
||||
|
||||
// pub var genFramebuffers: *const fn (n: Sizei, framebuffers: [*c]Uint) callconv(.C) void = undefined;
|
||||
pub fn genFramebuffer(ptr: *Framebuffer) void {
|
||||
bindings.genFramebuffers(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.genFramebuffers(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn genFramebuffers(framebuffers: []Framebuffer) void {
|
||||
bindings.genFramebuffers(framebuffers.len, @ptrCast([*c]Uint, framebuffers.ptr));
|
||||
bindings.genFramebuffers(framebuffers.len, @as([*c]Uint, @ptrCast(framebuffers.ptr)));
|
||||
}
|
||||
|
||||
// pub var checkFramebufferStatus: *const fn (target: Enum) callconv(.C) Enum = undefined;
|
||||
@@ -2771,7 +2771,7 @@ pub fn framebufferTexture2D(
|
||||
@intFromEnum(target),
|
||||
@intFromEnum(attachment),
|
||||
@intFromEnum(textarget),
|
||||
@bitCast(Uint, texture),
|
||||
@as(Uint, @bitCast(texture)),
|
||||
level,
|
||||
);
|
||||
}
|
||||
@@ -2801,7 +2801,7 @@ pub fn framebufferRenderbuffer(
|
||||
@intFromEnum(target),
|
||||
@intFromEnum(attachment),
|
||||
@intFromEnum(renderbuffertarget),
|
||||
@bitCast(Uint, renderbuffer),
|
||||
@as(Uint, @bitCast(renderbuffer)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2866,28 +2866,28 @@ pub fn getFramebufferAttachmentParameteriv(
|
||||
|
||||
// pub var bindVertexArray: *const fn (array: Uint) callconv(.C) void = undefined;
|
||||
pub fn bindVertexArray(array: VertexArrayObject) void {
|
||||
bindings.bindVertexArray(@bitCast(Uint, array));
|
||||
bindings.bindVertexArray(@as(Uint, @bitCast(array)));
|
||||
}
|
||||
|
||||
// pub var deleteVertexArrays: *const fn (n: Sizei, arrays: [*c]const Uint) callconv(.C) void = undefined;
|
||||
pub fn deleteVertexArray(ptr: *const VertexArrayObject) void {
|
||||
bindings.deleteVertexArrays(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.deleteVertexArrays(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn deleteVertexArrays(arrays: []const VertexArrayObject) void {
|
||||
bindings.deleteVertexArrays(arrays.len, @ptrCast([*c]Uint, arrays.ptr));
|
||||
bindings.deleteVertexArrays(arrays.len, @as([*c]Uint, @ptrCast(arrays.ptr)));
|
||||
}
|
||||
|
||||
// pub var genVertexArrays: *const fn (n: Sizei, arrays: [*c]Uint) callconv(.C) void = undefined;
|
||||
pub fn genVertexArray(ptr: *VertexArrayObject) void {
|
||||
bindings.genVertexArrays(1, @ptrCast([*c]Uint, ptr));
|
||||
bindings.genVertexArrays(1, @as([*c]Uint, @ptrCast(ptr)));
|
||||
}
|
||||
pub fn genVertexArrays(arrays: []VertexArrayObject) void {
|
||||
bindings.genVertexArrays(arrays.len, @ptrCast([*c]Uint, arrays.ptr));
|
||||
bindings.genVertexArrays(arrays.len, @as([*c]Uint, @ptrCast(arrays.ptr)));
|
||||
}
|
||||
|
||||
// pub var isVertexArray: *const fn (array: Uint) callconv(.C) Boolean = undefined;
|
||||
pub fn isVertexArray(array: VertexArrayObject) bool {
|
||||
return bindings.isVertexArray(@bitCast(Uint, array)) == TRUE;
|
||||
return bindings.isVertexArray(@as(Uint, @bitCast(array))) == TRUE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -3359,7 +3359,7 @@ pub fn debugMessageCallback(
|
||||
callback: DEBUGPROC,
|
||||
userParam: ?*const anyopaque,
|
||||
) void {
|
||||
bindings.debugMessageCallback(@ptrCast(bindings.DEBUGPROC, callback), userParam);
|
||||
bindings.debugMessageCallback(@as(bindings.DEBUGPROC, @ptrCast(callback)), userParam);
|
||||
}
|
||||
|
||||
// pub var getDebugMessageLog: *const fn (
|
||||
|
||||
@@ -1366,7 +1366,7 @@ var loaderFunc: LoaderFn = undefined;
|
||||
|
||||
fn getProcAddress(comptime T: type, name: [:0]const u8) !T {
|
||||
if (loaderFunc(name)) |addr| {
|
||||
return @ptrFromInt(T, @intFromPtr(addr));
|
||||
return @as(T, @ptrFromInt(@intFromPtr(addr)));
|
||||
}
|
||||
std.log.debug("zopengl: {s} not found", .{name});
|
||||
return error.OpenGL_FunctionNotFound;
|
||||
|
||||
+409
-403
File diff suppressed because it is too large.
Load diff
+20
-20
@@ -113,8 +113,8 @@ const WINPIX_EVENT_PIX3BLOB_VERSION: u32 = 2;
|
||||
const D3D12_EVENT_METADATA = WINPIX_EVENT_PIX3BLOB_VERSION;
|
||||
|
||||
fn encodeEventInfo(timestamp: u64, event_type: EventType) u64 {
|
||||
const mask0 = (timestamp & EventsTimestampWriteMask) << @intCast(u6, EventsTimestampBitShift);
|
||||
const mask1 = (@intFromEnum(event_type) & EventsTypeWriteMask) << @intCast(u6, EventsTypeBitShift);
|
||||
const mask0 = (timestamp & EventsTimestampWriteMask) << @as(u6, @intCast(EventsTimestampBitShift));
|
||||
const mask1 = (@intFromEnum(event_type) & EventsTypeWriteMask) << @as(u6, @intCast(EventsTypeBitShift));
|
||||
return mask0 | mask1;
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ const EventsStringIsShortcutBitShift: u64 = 53;
|
||||
|
||||
fn encodeStringInfo(alignment: u64, copy_chunk_size: u64, is_ansi: bool, is_shortcut: bool) u64 {
|
||||
const mask0 = (alignment & EventsStringAlignmentWriteMask) <<
|
||||
@intCast(u6, EventsStringAlignmentBitShift);
|
||||
@as(u6, @intCast(EventsStringAlignmentBitShift));
|
||||
const mask1 = (copy_chunk_size & EventsStringCopyChunkSizeWriteMask) <<
|
||||
@intCast(u6, EventsStringCopyChunkSizeBitShift);
|
||||
@as(u6, @intCast(EventsStringCopyChunkSizeBitShift));
|
||||
const mask2 = (@intFromBool(is_ansi) & EventsStringIsANSIWriteMask) <<
|
||||
@intCast(u6, EventsStringIsANSIBitShift);
|
||||
@as(u6, @intCast(EventsStringIsANSIBitShift));
|
||||
const mask3 = (@intFromBool(is_shortcut) & EventsStringIsShortcutWriteMask) <<
|
||||
@intCast(u6, EventsStringIsShortcutBitShift);
|
||||
@as(u6, @intCast(EventsStringIsShortcutBitShift));
|
||||
return mask0 | mask1 | mask2 | mask3;
|
||||
}
|
||||
|
||||
@@ -202,9 +202,9 @@ const impl = struct {
|
||||
|
||||
fn beginCapture(flags: CAPTURE_FLAGS, params: ?*const CaptureParameters) HRESULT {
|
||||
if (flags.GPU) {
|
||||
const beginProgrammaticGpuCapture = @ptrCast(
|
||||
const beginProgrammaticGpuCapture = @as(
|
||||
?*const fn (?*const CaptureParameters) callconv(WINAPI) HRESULT,
|
||||
getFunctionPtr("BeginProgrammaticGpuCapture"),
|
||||
@ptrCast(getFunctionPtr("BeginProgrammaticGpuCapture")),
|
||||
);
|
||||
if (beginProgrammaticGpuCapture == null) {
|
||||
return w32.E_FAIL;
|
||||
@@ -216,9 +216,9 @@ const impl = struct {
|
||||
}
|
||||
|
||||
fn endCapture() HRESULT {
|
||||
const endProgrammaticGpuCapture = @ptrCast(
|
||||
const endProgrammaticGpuCapture = @as(
|
||||
?*const fn () callconv(WINAPI) HRESULT,
|
||||
getFunctionPtr("EndProgrammaticGpuCapture"),
|
||||
@ptrCast(getFunctionPtr("EndProgrammaticGpuCapture")),
|
||||
);
|
||||
if (endProgrammaticGpuCapture == null) {
|
||||
return w32.E_FAIL;
|
||||
@@ -227,9 +227,9 @@ const impl = struct {
|
||||
}
|
||||
|
||||
fn setTargetWindow(hwnd: HWND) HRESULT {
|
||||
const setGlobalTargetWindow = @ptrCast(
|
||||
const setGlobalTargetWindow = @as(
|
||||
?*const fn (HWND) callconv(WINAPI) void,
|
||||
getFunctionPtr("SetGlobalTargetWindow"),
|
||||
@ptrCast(getFunctionPtr("SetGlobalTargetWindow")),
|
||||
);
|
||||
if (setGlobalTargetWindow == null) {
|
||||
return w32.E_FAIL;
|
||||
@@ -239,9 +239,9 @@ const impl = struct {
|
||||
}
|
||||
|
||||
fn gpuCaptureNextFrames(file_name: LPCWSTR, num_frames: UINT32) HRESULT {
|
||||
const captureNextFrame = @ptrCast(
|
||||
const captureNextFrame = @as(
|
||||
?*const fn (LPCWSTR, UINT32) callconv(WINAPI) HRESULT,
|
||||
getFunctionPtr("CaptureNextFrame"),
|
||||
@ptrCast(getFunctionPtr("CaptureNextFrame")),
|
||||
);
|
||||
if (captureNextFrame == null) {
|
||||
return w32.E_FAIL;
|
||||
@@ -255,7 +255,7 @@ const impl = struct {
|
||||
assert(@hasDecl(T, "SetMarker"));
|
||||
}
|
||||
assert(name.len > 0);
|
||||
const num_name_qwords: u32 = (@intCast(u32, name.len + 1) + 7) / 8;
|
||||
const num_name_qwords: u32 = (@as(u32, @intCast(name.len + 1)) + 7) / 8;
|
||||
assert(num_name_qwords < (EventsGraphicsRecordSpaceQwords / 2));
|
||||
|
||||
var buffer: [EventsGraphicsRecordSpaceQwords]u64 = undefined;
|
||||
@@ -271,9 +271,9 @@ const impl = struct {
|
||||
|
||||
dest[num_name_qwords - 1] = 0;
|
||||
dest[num_name_qwords + 0] = 0;
|
||||
@memcpy(@ptrCast([*]u8, dest), name);
|
||||
@memcpy(@as([*]u8, @ptrCast(dest)), name);
|
||||
|
||||
context.SetMarker(D3D12_EVENT_METADATA, @ptrCast(*anyopaque, &buffer), (3 + num_name_qwords) * 8);
|
||||
context.SetMarker(D3D12_EVENT_METADATA, @as(*anyopaque, @ptrCast(&buffer)), (3 + num_name_qwords) * 8);
|
||||
}
|
||||
|
||||
fn setMarker(target: anytype, name: []const u8) void {
|
||||
@@ -286,7 +286,7 @@ const impl = struct {
|
||||
assert(@hasDecl(T, "BeginEvent"));
|
||||
}
|
||||
assert(name.len > 0);
|
||||
const num_name_qwords: u32 = (@intCast(u32, name.len + 1) + 7) / 8;
|
||||
const num_name_qwords: u32 = (@as(u32, @intCast(name.len + 1)) + 7) / 8;
|
||||
assert(num_name_qwords < (EventsGraphicsRecordSpaceQwords / 2));
|
||||
|
||||
var buffer: [EventsGraphicsRecordSpaceQwords]u64 = undefined;
|
||||
@@ -302,9 +302,9 @@ const impl = struct {
|
||||
|
||||
dest[num_name_qwords - 1] = 0;
|
||||
dest[num_name_qwords + 0] = 0;
|
||||
@memcpy(@ptrCast([*]u8, dest), name);
|
||||
@memcpy(@as([*]u8, @ptrCast(dest)), name);
|
||||
|
||||
context.BeginEvent(D3D12_EVENT_METADATA, @ptrCast(*anyopaque, &buffer), (3 + num_name_qwords) * 8);
|
||||
context.BeginEvent(D3D12_EVENT_METADATA, @as(*anyopaque, @ptrCast(&buffer)), (3 + num_name_qwords) * 8);
|
||||
}
|
||||
|
||||
fn beginEvent(target: anytype, name: []const u8) void {
|
||||
|
||||
@@ -135,8 +135,8 @@ pub fn Handle(
|
||||
/// Returns the corresponding `Handle`
|
||||
pub fn handle(self: AddressableHandle) HandleType {
|
||||
var u = HandleUnion{ .bits = .{
|
||||
.cycle = @intCast(CycleType, self.cycle),
|
||||
.index = @intCast(IndexType, self.index),
|
||||
.cycle = @as(CycleType, @intCast(self.cycle)),
|
||||
.index = @as(IndexType, @intCast(self.index)),
|
||||
} };
|
||||
return .{ .id = u.id };
|
||||
}
|
||||
|
||||
@@ -216,8 +216,7 @@ pub fn Pool(
|
||||
const curr_index = self.next_index;
|
||||
if (curr_index < max_index) {
|
||||
self.next_index += 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.ended = true;
|
||||
}
|
||||
if (isLiveCycle(self.curr_cycle[curr_index]))
|
||||
@@ -258,7 +257,7 @@ pub fn Pool(
|
||||
var ahandle = AddressableHandle{ .index = 0 };
|
||||
for (self._curr_cycle, 0..) |cycle, i| {
|
||||
if (isLiveCycle(cycle)) {
|
||||
ahandle.index = @intCast(AddressableIndex, i);
|
||||
ahandle.index = @as(AddressableIndex, @intCast(i));
|
||||
ahandle.cycle = cycle;
|
||||
self.releaseAddressableHandleUnchecked(ahandle);
|
||||
}
|
||||
@@ -533,7 +532,7 @@ pub fn Pool(
|
||||
inline for (column_fields, 0..) |column_field, i| {
|
||||
const F = column_field.type;
|
||||
const p = slice.ptrs[private_fields.len + i];
|
||||
const f = @ptrCast([*]F, @alignCast(@alignOf(F), p));
|
||||
const f = @as([*]F, @ptrCast(@alignCast(p)));
|
||||
@field(self.columns, column_field.name) = f[0..slice.len];
|
||||
}
|
||||
}
|
||||
@@ -660,7 +659,7 @@ pub fn Pool(
|
||||
const new_index = self._storage.addOneAssumeCapacity();
|
||||
updateSlices(self);
|
||||
self._curr_cycle[new_index] = 1;
|
||||
handle.index = @intCast(AddressableIndex, new_index);
|
||||
handle.index = @as(AddressableIndex, @intCast(new_index));
|
||||
handle.cycle = 1;
|
||||
return true;
|
||||
}
|
||||
@@ -671,7 +670,7 @@ pub fn Pool(
|
||||
const new_index = try self._storage.addOne(self._allocator);
|
||||
updateSlices(self);
|
||||
self._curr_cycle[new_index] = 1;
|
||||
handle.index = @intCast(AddressableIndex, new_index);
|
||||
handle.index = @as(AddressableIndex, @intCast(new_index));
|
||||
handle.cycle = 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -389,7 +389,7 @@ pub const Texture = opaque {
|
||||
extern fn SDL_DestroyTexture(texture: ?*Texture) void;
|
||||
|
||||
pub fn query(texture: *Texture, format: ?*PixelFormat, access: ?*Access, w: ?*i32, h: ?*i32) !void {
|
||||
if (SDL_QueryTexture(texture, @ptrCast(?*u32, format), @ptrCast(?*c_int, access), w, h) != 0) {
|
||||
if (SDL_QueryTexture(texture, @as(?*u32, @ptrCast(format)), @as(?*c_int, @ptrCast(access)), w, h) != 0) {
|
||||
return makeError();
|
||||
}
|
||||
}
|
||||
@@ -733,9 +733,9 @@ pub const Renderer = opaque {
|
||||
r,
|
||||
tex,
|
||||
vertices.ptr,
|
||||
@intCast(i32, vertices.len),
|
||||
if (indices) |idx| @ptrCast([*]const i32, idx.ptr) else null,
|
||||
if (indices) |idx| @intCast(i32, idx.len) else 0,
|
||||
@as(i32, @intCast(vertices.len)),
|
||||
if (indices) |idx| @as([*]const i32, @ptrCast(idx.ptr)) else null,
|
||||
if (indices) |idx| @as(i32, @intCast(idx.len)) else 0,
|
||||
) < 0)
|
||||
return makeError();
|
||||
}
|
||||
@@ -872,7 +872,7 @@ pub const Renderer = opaque {
|
||||
rect,
|
||||
if (format) |f| @intFromEnum(f) else 0,
|
||||
pixels,
|
||||
@intCast(i32, pitch),
|
||||
@as(i32, @intCast(pitch)),
|
||||
) < 0) return makeError();
|
||||
}
|
||||
extern fn SDL_RenderReadPixels(
|
||||
@@ -1235,7 +1235,7 @@ extern fn SDL_PollEvent(event: ?*Event) i32;
|
||||
pub fn getKeyboardState() []const u8 {
|
||||
var numkeys: i32 = 0;
|
||||
const ptr = SDL_GetKeyboardState(&numkeys).?;
|
||||
return ptr[0..@intCast(usize, numkeys)];
|
||||
return ptr[0..@as(usize, @intCast(numkeys))];
|
||||
}
|
||||
extern fn SDL_GetKeyboardState(numkeys: ?*i32) ?[*]const u8;
|
||||
|
||||
@@ -1396,7 +1396,7 @@ pub fn pauseAudioDevice(device: AudioDeviceId, pause: bool) void {
|
||||
extern fn SDL_PauseAudioDevice(AudioDeviceId, pause: c_int) void;
|
||||
|
||||
pub fn queueAudio(comptime SampleType: type, device: AudioDeviceId, data: []const SampleType) bool {
|
||||
return SDL_QueueAudio(device, data.ptr, @sizeOf(SampleType) * @intCast(u32, data.len)) == 0;
|
||||
return SDL_QueueAudio(device, data.ptr, @sizeOf(SampleType) * @as(u32, @intCast(data.len))) == 0;
|
||||
}
|
||||
extern fn SDL_QueueAudio(AudioDeviceId, data: *const anyopaque, len: u32) c_int;
|
||||
|
||||
|
||||
+50
-50
@@ -68,9 +68,9 @@ pub const Image = struct {
|
||||
const is_supported = stbi_info(pathname, &w, &h, &c);
|
||||
return .{
|
||||
.is_supported = if (is_supported == 1) true else false,
|
||||
.width = @intCast(u32, w),
|
||||
.height = @intCast(u32, h),
|
||||
.num_components = @intCast(u32, c),
|
||||
.width = @as(u32, @intCast(w)),
|
||||
.height = @as(u32, @intCast(h)),
|
||||
.num_components = @as(u32, @intCast(c)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,53 +93,53 @@ pub const Image = struct {
|
||||
&x,
|
||||
&y,
|
||||
&ch,
|
||||
@intCast(c_int, forced_num_components),
|
||||
@as(c_int, @intCast(forced_num_components)),
|
||||
);
|
||||
if (ptr == null) return error.ImageInitFailed;
|
||||
|
||||
num_components = if (forced_num_components == 0) @intCast(u32, ch) else forced_num_components;
|
||||
width = @intCast(u32, x);
|
||||
height = @intCast(u32, y);
|
||||
num_components = if (forced_num_components == 0) @as(u32, @intCast(ch)) else forced_num_components;
|
||||
width = @as(u32, @intCast(x));
|
||||
height = @as(u32, @intCast(y));
|
||||
bytes_per_component = 2;
|
||||
bytes_per_row = width * num_components * bytes_per_component;
|
||||
is_hdr = true;
|
||||
|
||||
// Convert each component from f32 to f16.
|
||||
var ptr_f16 = @ptrCast([*]f16, ptr.?);
|
||||
var ptr_f16 = @as([*]f16, @ptrCast(ptr.?));
|
||||
const num = width * height * num_components;
|
||||
var i: u32 = 0;
|
||||
while (i < num) : (i += 1) {
|
||||
ptr_f16[i] = @floatCast(f16, ptr.?[i]);
|
||||
ptr_f16[i] = @as(f16, @floatCast(ptr.?[i]));
|
||||
}
|
||||
break :data @ptrCast([*]u8, ptr_f16)[0 .. height * bytes_per_row];
|
||||
break :data @as([*]u8, @ptrCast(ptr_f16))[0 .. height * bytes_per_row];
|
||||
} else data: {
|
||||
var x: c_int = undefined;
|
||||
var y: c_int = undefined;
|
||||
var ch: c_int = undefined;
|
||||
const is_16bit = is16bit(pathname);
|
||||
const ptr = if (is_16bit) @ptrCast(?[*]u8, stbi_load_16(
|
||||
const ptr = if (is_16bit) @as(?[*]u8, @ptrCast(stbi_load_16(
|
||||
pathname,
|
||||
&x,
|
||||
&y,
|
||||
&ch,
|
||||
@intCast(c_int, forced_num_components),
|
||||
)) else stbi_load(
|
||||
@as(c_int, @intCast(forced_num_components)),
|
||||
))) else stbi_load(
|
||||
pathname,
|
||||
&x,
|
||||
&y,
|
||||
&ch,
|
||||
@intCast(c_int, forced_num_components),
|
||||
@as(c_int, @intCast(forced_num_components)),
|
||||
);
|
||||
if (ptr == null) return error.ImageInitFailed;
|
||||
|
||||
num_components = if (forced_num_components == 0) @intCast(u32, ch) else forced_num_components;
|
||||
width = @intCast(u32, x);
|
||||
height = @intCast(u32, y);
|
||||
num_components = if (forced_num_components == 0) @as(u32, @intCast(ch)) else forced_num_components;
|
||||
width = @as(u32, @intCast(x));
|
||||
height = @as(u32, @intCast(y));
|
||||
bytes_per_component = if (is_16bit) 2 else 1;
|
||||
bytes_per_row = width * num_components * bytes_per_component;
|
||||
is_hdr = false;
|
||||
|
||||
break :data @ptrCast([*]u8, ptr)[0 .. height * bytes_per_row];
|
||||
break :data @as([*]u8, @ptrCast(ptr))[0 .. height * bytes_per_row];
|
||||
};
|
||||
|
||||
return Image{
|
||||
@@ -169,50 +169,50 @@ pub const Image = struct {
|
||||
var ch: c_int = undefined;
|
||||
const ptr = stbi_loadf_from_memory(
|
||||
data.ptr,
|
||||
@intCast(c_int, data.len),
|
||||
@as(c_int, @intCast(data.len)),
|
||||
&x,
|
||||
&y,
|
||||
&ch,
|
||||
@intCast(c_int, forced_num_components),
|
||||
@as(c_int, @intCast(forced_num_components)),
|
||||
);
|
||||
if (ptr == null) return error.ImageInitFailed;
|
||||
|
||||
num_components = if (forced_num_components == 0) @intCast(u32, ch) else forced_num_components;
|
||||
width = @intCast(u32, x);
|
||||
height = @intCast(u32, y);
|
||||
num_components = if (forced_num_components == 0) @as(u32, @intCast(ch)) else forced_num_components;
|
||||
width = @as(u32, @intCast(x));
|
||||
height = @as(u32, @intCast(y));
|
||||
bytes_per_component = 2;
|
||||
bytes_per_row = width * num_components * bytes_per_component;
|
||||
is_hdr = true;
|
||||
|
||||
// Convert each component from f32 to f16.
|
||||
var ptr_f16 = @ptrCast([*]f16, ptr.?);
|
||||
var ptr_f16 = @as([*]f16, @ptrCast(ptr.?));
|
||||
const num = width * height * num_components;
|
||||
var i: u32 = 0;
|
||||
while (i < num) : (i += 1) {
|
||||
ptr_f16[i] = @floatCast(f16, ptr.?[i]);
|
||||
ptr_f16[i] = @as(f16, @floatCast(ptr.?[i]));
|
||||
}
|
||||
break :data @ptrCast([*]u8, ptr_f16)[0 .. height * bytes_per_row];
|
||||
break :data @as([*]u8, @ptrCast(ptr_f16))[0 .. height * bytes_per_row];
|
||||
} else data: {
|
||||
var x: c_int = undefined;
|
||||
var y: c_int = undefined;
|
||||
var ch: c_int = undefined;
|
||||
const ptr = stbi_load_from_memory(
|
||||
data.ptr,
|
||||
@intCast(c_int, data.len),
|
||||
@as(c_int, @intCast(data.len)),
|
||||
&x,
|
||||
&y,
|
||||
&ch,
|
||||
@intCast(c_int, forced_num_components),
|
||||
@as(c_int, @intCast(forced_num_components)),
|
||||
);
|
||||
if (ptr == null) return error.ImageInitFailed;
|
||||
|
||||
num_components = if (forced_num_components == 0) @intCast(u32, ch) else forced_num_components;
|
||||
width = @intCast(u32, x);
|
||||
height = @intCast(u32, y);
|
||||
num_components = if (forced_num_components == 0) @as(u32, @intCast(ch)) else forced_num_components;
|
||||
width = @as(u32, @intCast(x));
|
||||
height = @as(u32, @intCast(y));
|
||||
bytes_per_component = 1;
|
||||
bytes_per_row = width * num_components * bytes_per_component;
|
||||
|
||||
break :data @ptrCast([*]u8, ptr)[0 .. height * bytes_per_row];
|
||||
break :data @as([*]u8, @ptrCast(ptr))[0 .. height * bytes_per_row];
|
||||
};
|
||||
|
||||
return Image{
|
||||
@@ -240,7 +240,7 @@ pub const Image = struct {
|
||||
|
||||
const size = height * bytes_per_row;
|
||||
|
||||
const data = @ptrCast([*]u8, zstbiMalloc(size));
|
||||
const data = @as([*]u8, @ptrCast(zstbiMalloc(size)));
|
||||
@memset(data[0..size], 0);
|
||||
|
||||
return Image{
|
||||
@@ -260,17 +260,17 @@ pub const Image = struct {
|
||||
// TODO: Add support for HDR images
|
||||
const new_bytes_per_row = new_width * image.num_components * image.bytes_per_component;
|
||||
const new_size = new_height * new_bytes_per_row;
|
||||
const new_data = @ptrCast([*]u8, zstbiMalloc(new_size));
|
||||
const new_data = @as([*]u8, @ptrCast(zstbiMalloc(new_size)));
|
||||
stbir_resize_uint8(
|
||||
image.data.ptr,
|
||||
@intCast(c_int, image.width),
|
||||
@intCast(c_int, image.height),
|
||||
@as(c_int, @intCast(image.width)),
|
||||
@as(c_int, @intCast(image.height)),
|
||||
0,
|
||||
new_data,
|
||||
@intCast(c_int, new_width),
|
||||
@intCast(c_int, new_height),
|
||||
@as(c_int, @intCast(new_width)),
|
||||
@as(c_int, @intCast(new_height)),
|
||||
0,
|
||||
@intCast(c_int, image.num_components),
|
||||
@as(c_int, @intCast(image.num_components)),
|
||||
);
|
||||
return .{
|
||||
.data = new_data[0..new_size],
|
||||
@@ -290,9 +290,9 @@ pub const Image = struct {
|
||||
) ImageWriteError!void {
|
||||
assert(mem_allocator != null);
|
||||
|
||||
const w = @intCast(c_int, image.width);
|
||||
const h = @intCast(c_int, image.height);
|
||||
const comp = @intCast(c_int, image.num_components);
|
||||
const w = @as(c_int, @intCast(image.width));
|
||||
const h = @as(c_int, @intCast(image.height));
|
||||
const comp = @as(c_int, @intCast(image.num_components));
|
||||
const result = switch (image_format) {
|
||||
.png => stbi_write_png(filename.ptr, w, h, comp, image.data.ptr, 0),
|
||||
.jpg => |settings| stbi_write_jpg(
|
||||
@@ -301,7 +301,7 @@ pub const Image = struct {
|
||||
h,
|
||||
comp,
|
||||
image.data.ptr,
|
||||
@intCast(c_int, settings.quality),
|
||||
@as(c_int, @intCast(settings.quality)),
|
||||
),
|
||||
};
|
||||
// if the result is 0 then it means an error occured (per stb image write docs)
|
||||
@@ -318,9 +318,9 @@ pub const Image = struct {
|
||||
) ImageWriteError!void {
|
||||
assert(mem_allocator != null);
|
||||
|
||||
const w = @intCast(c_int, image.width);
|
||||
const h = @intCast(c_int, image.height);
|
||||
const comp = @intCast(c_int, image.num_components);
|
||||
const w = @as(c_int, @intCast(image.width));
|
||||
const h = @as(c_int, @intCast(image.height));
|
||||
const comp = @as(c_int, @intCast(image.num_components));
|
||||
const result = switch (image_format) {
|
||||
.png => stbi_write_png_to_func(write_fn, context, w, h, comp, image.data.ptr, 0),
|
||||
.jpg => |settings| stbi_write_jpg_to_func(
|
||||
@@ -330,7 +330,7 @@ pub const Image = struct {
|
||||
h,
|
||||
comp,
|
||||
image.data.ptr,
|
||||
@intCast(c_int, settings.quality),
|
||||
@as(c_int, @intCast(settings.quality)),
|
||||
),
|
||||
};
|
||||
// if the result is 0 then it means an error occured (per stb image write docs)
|
||||
@@ -362,7 +362,7 @@ pub fn isHdr(filename: [:0]const u8) bool {
|
||||
}
|
||||
|
||||
pub fn isHdrFromMem(buffer: []const u8) bool {
|
||||
return stbi_is_hdr_from_memory(buffer.ptr, @intCast(c_int, buffer.len)) != 0;
|
||||
return stbi_is_hdr_from_memory(buffer.ptr, @as(c_int, @intCast(buffer.len))) != 0;
|
||||
}
|
||||
|
||||
pub fn is16bit(filename: [:0]const u8) bool {
|
||||
@@ -409,7 +409,7 @@ fn zstbiRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {
|
||||
|
||||
const old_size = if (ptr != null) mem_allocations.?.get(@intFromPtr(ptr.?)).? else 0;
|
||||
const old_mem = if (old_size > 0)
|
||||
@ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..old_size]
|
||||
@as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..old_size]
|
||||
else
|
||||
@as([*]align(mem_alignment) u8, undefined)[0..0];
|
||||
|
||||
@@ -434,7 +434,7 @@ fn zstbiFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
|
||||
defer mem_mutex.unlock();
|
||||
|
||||
const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
|
||||
const mem = @ptrCast([*]align(mem_alignment) u8, @alignCast(mem_alignment, ptr))[0..size];
|
||||
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
|
||||
mem_allocator.?.free(mem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,10 +530,10 @@ const tracy_full = struct {
|
||||
c.___tracy_emit_plot(name, val);
|
||||
}
|
||||
pub inline fn PlotU(name: [*:0]const u8, val: u64) void {
|
||||
c.___tracy_emit_plot(name, @floatFromInt(f64, val));
|
||||
c.___tracy_emit_plot(name, @as(f64, @floatFromInt(val)));
|
||||
}
|
||||
pub inline fn PlotI(name: [*:0]const u8, val: i64) void {
|
||||
c.___tracy_emit_plot(name, @floatFromInt(f64, val));
|
||||
c.___tracy_emit_plot(name, @as(f64, @floatFromInt(val)));
|
||||
}
|
||||
pub inline fn AppInfo(text: []const u8) void {
|
||||
c.___tracy_emit_message_appinfo(text.ptr, text.len);
|
||||
|
||||
+95
-95
@@ -329,13 +329,13 @@ pub const ISolidColorBrush = extern struct {
|
||||
pub usingnamespace IBrush.Methods(T);
|
||||
|
||||
pub inline fn SetColor(self: *T, color: *const COLOR_F) void {
|
||||
@ptrCast(*const ISolidColorBrush.VTable, self.__v)
|
||||
.SetColor(@ptrCast(*ISolidColorBrush, self), color);
|
||||
@as(*const ISolidColorBrush.VTable, @ptrCast(self.__v))
|
||||
.SetColor(@as(*ISolidColorBrush, @ptrCast(self)), color);
|
||||
}
|
||||
pub inline fn GetColor(self: *T) COLOR_F {
|
||||
var color: COLOR_F = undefined;
|
||||
_ = @ptrCast(*const ISolidColorBrush.VTable, self.__v)
|
||||
.GetColor(@ptrCast(*ISolidColorBrush, self), &color);
|
||||
_ = @as(*const ISolidColorBrush.VTable, @ptrCast(self.__v))
|
||||
.GetColor(@as(*ISolidColorBrush, @ptrCast(self)), &color);
|
||||
return color;
|
||||
}
|
||||
};
|
||||
@@ -580,32 +580,32 @@ pub const ISimplifiedGeometrySink = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn SetFillMode(self: *T, mode: FILL_MODE) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.SetFillMode(@ptrCast(*ISimplifiedGeometrySink, self), mode);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.SetFillMode(@as(*ISimplifiedGeometrySink, @ptrCast(self)), mode);
|
||||
}
|
||||
pub inline fn SetSegmentFlags(self: *T, flags: PATH_SEGMENT) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.SetSegmentFlags(@ptrCast(*ISimplifiedGeometrySink, self), flags);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.SetSegmentFlags(@as(*ISimplifiedGeometrySink, @ptrCast(self)), flags);
|
||||
}
|
||||
pub inline fn BeginFigure(self: *T, point: POINT_2F, begin: FIGURE_BEGIN) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.BeginFigure(@ptrCast(*ISimplifiedGeometrySink, self), point, begin);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.BeginFigure(@as(*ISimplifiedGeometrySink, @ptrCast(self)), point, begin);
|
||||
}
|
||||
pub inline fn AddLines(self: *T, points: [*]const POINT_2F, count: UINT32) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.AddLines(@ptrCast(*ISimplifiedGeometrySink, self), points, count);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.AddLines(@as(*ISimplifiedGeometrySink, @ptrCast(self)), points, count);
|
||||
}
|
||||
pub inline fn AddBeziers(self: *T, segments: [*]const BEZIER_SEGMENT, count: UINT32) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.AddBeziers(@ptrCast(*ISimplifiedGeometrySink, self), segments, count);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.AddBeziers(@as(*ISimplifiedGeometrySink, @ptrCast(self)), segments, count);
|
||||
}
|
||||
pub inline fn EndFigure(self: *T, end: FIGURE_END) void {
|
||||
@ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.EndFigure(@ptrCast(*ISimplifiedGeometrySink, self), end);
|
||||
@as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.EndFigure(@as(*ISimplifiedGeometrySink, @ptrCast(self)), end);
|
||||
}
|
||||
pub inline fn Close(self: *T) HRESULT {
|
||||
return @ptrCast(*const ISimplifiedGeometrySink.VTable, self.__v)
|
||||
.Close(@ptrCast(*ISimplifiedGeometrySink, self));
|
||||
return @as(*const ISimplifiedGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.Close(@as(*ISimplifiedGeometrySink, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -633,25 +633,25 @@ pub const IGeometrySink = extern struct {
|
||||
pub usingnamespace ISimplifiedGeometrySink.Methods(T);
|
||||
|
||||
pub inline fn AddLine(self: *T, point: POINT_2F) void {
|
||||
@ptrCast(*const IGeometrySink.VTable, self.__v).AddLine(@ptrCast(*IGeometrySink, self), point);
|
||||
@as(*const IGeometrySink.VTable, @ptrCast(self.__v)).AddLine(@as(*IGeometrySink, @ptrCast(self)), point);
|
||||
}
|
||||
pub inline fn AddBezier(self: *T, segment: *const BEZIER_SEGMENT) void {
|
||||
@ptrCast(*const IGeometrySink.VTable, self.__v).AddBezier(@ptrCast(*IGeometrySink, self), segment);
|
||||
@as(*const IGeometrySink.VTable, @ptrCast(self.__v)).AddBezier(@as(*IGeometrySink, @ptrCast(self)), segment);
|
||||
}
|
||||
pub inline fn AddQuadraticBezier(self: *T, segment: *const QUADRATIC_BEZIER_SEGMENT) void {
|
||||
@ptrCast(*const IGeometrySink.VTable, self.__v)
|
||||
.AddQuadraticBezier(@ptrCast(*IGeometrySink, self), segment);
|
||||
@as(*const IGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.AddQuadraticBezier(@as(*IGeometrySink, @ptrCast(self)), segment);
|
||||
}
|
||||
pub inline fn AddQuadraticBeziers(
|
||||
self: *T,
|
||||
segments: [*]const QUADRATIC_BEZIER_SEGMENT,
|
||||
count: UINT32,
|
||||
) void {
|
||||
@ptrCast(*const IGeometrySink.VTable, self.__v)
|
||||
.AddQuadraticBeziers(@ptrCast(*IGeometrySink, self), segments, count);
|
||||
@as(*const IGeometrySink.VTable, @ptrCast(self.__v))
|
||||
.AddQuadraticBeziers(@as(*IGeometrySink, @ptrCast(self)), segments, count);
|
||||
}
|
||||
pub inline fn AddArc(self: *T, segment: *const ARC_SEGMENT) void {
|
||||
@ptrCast(*const IGeometrySink.VTable, self.__v).AddArc(@ptrCast(*IGeometrySink, self), segment);
|
||||
@as(*const IGeometrySink.VTable, @ptrCast(self.__v)).AddArc(@as(*IGeometrySink, @ptrCast(self)), segment);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -677,15 +677,15 @@ pub const IPathGeometry = extern struct {
|
||||
pub usingnamespace IGeometry.Methods(T);
|
||||
|
||||
pub inline fn Open(self: *T, sink: *?*IGeometrySink) HRESULT {
|
||||
return @ptrCast(*const IPathGeometry.VTable, self.__v).Open(@ptrCast(*IPathGeometry, self), sink);
|
||||
return @as(*const IPathGeometry.VTable, @ptrCast(self.__v)).Open(@as(*IPathGeometry, @ptrCast(self)), sink);
|
||||
}
|
||||
pub inline fn GetSegmentCount(self: *T, count: *UINT32) HRESULT {
|
||||
return @ptrCast(*const IPathGeometry.VTable, self.__v)
|
||||
.GetSegmentCount(@ptrCast(*IPathGeometry, self), count);
|
||||
return @as(*const IPathGeometry.VTable, @ptrCast(self.__v))
|
||||
.GetSegmentCount(@as(*IPathGeometry, @ptrCast(self)), count);
|
||||
}
|
||||
pub inline fn GetFigureCount(self: *T, count: *UINT32) HRESULT {
|
||||
return @ptrCast(*const IPathGeometry.VTable, self.__v)
|
||||
.GetFigureCount(@ptrCast(*IPathGeometry, self), count);
|
||||
return @as(*const IPathGeometry.VTable, @ptrCast(self.__v))
|
||||
.GetFigureCount(@as(*IPathGeometry, @ptrCast(self)), count);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -746,8 +746,8 @@ pub const IRenderTarget = extern struct {
|
||||
properties: ?*const BRUSH_PROPERTIES,
|
||||
brush: *?*ISolidColorBrush,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.CreateSolidColorBrush(@ptrCast(*IRenderTarget, self), color, properties, brush);
|
||||
return @as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.CreateSolidColorBrush(@as(*IRenderTarget, @ptrCast(self)), color, properties, brush);
|
||||
}
|
||||
pub inline fn CreateGradientStopCollection(
|
||||
self: *T,
|
||||
@@ -757,8 +757,8 @@ pub const IRenderTarget = extern struct {
|
||||
extend_mode: EXTEND_MODE,
|
||||
stop_collection: *?*IGradientStopCollection,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IRenderTarget.VTable, self.__v).CreateGradientStopCollection(
|
||||
@ptrCast(*IRenderTarget, self),
|
||||
return @as(*const IRenderTarget.VTable, @ptrCast(self.__v)).CreateGradientStopCollection(
|
||||
@as(*IRenderTarget, @ptrCast(self)),
|
||||
stops,
|
||||
num_stops,
|
||||
gamma,
|
||||
@@ -773,8 +773,8 @@ pub const IRenderTarget = extern struct {
|
||||
stop_collection: *IGradientStopCollection,
|
||||
brush: *?*IRadialGradientBrush,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IRenderTarget.VTable, self.__v).CreateRadialGradientBrush(
|
||||
@ptrCast(*IRenderTarget, self),
|
||||
return @as(*const IRenderTarget.VTable, @ptrCast(self.__v)).CreateRadialGradientBrush(
|
||||
@as(*IRenderTarget, @ptrCast(self)),
|
||||
gradient_properties,
|
||||
brush_properties,
|
||||
stop_collection,
|
||||
@@ -789,8 +789,8 @@ pub const IRenderTarget = extern struct {
|
||||
width: FLOAT,
|
||||
style: ?*IStrokeStyle,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.DrawLine(@ptrCast(*IRenderTarget, self), p0, p1, brush, width, style);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.DrawLine(@as(*IRenderTarget, @ptrCast(self)), p0, p1, brush, width, style);
|
||||
}
|
||||
pub inline fn DrawRectangle(
|
||||
self: *T,
|
||||
@@ -799,12 +799,12 @@ pub const IRenderTarget = extern struct {
|
||||
width: FLOAT,
|
||||
stroke: ?*IStrokeStyle,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.DrawRectangle(@ptrCast(*IRenderTarget, self), rect, brush, width, stroke);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.DrawRectangle(@as(*IRenderTarget, @ptrCast(self)), rect, brush, width, stroke);
|
||||
}
|
||||
pub inline fn FillRectangle(self: *T, rect: *const RECT_F, brush: *IBrush) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.FillRectangle(@ptrCast(*IRenderTarget, self), rect, brush);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.FillRectangle(@as(*IRenderTarget, @ptrCast(self)), rect, brush);
|
||||
}
|
||||
pub inline fn DrawRoundedRectangle(
|
||||
self: *T,
|
||||
@@ -813,12 +813,12 @@ pub const IRenderTarget = extern struct {
|
||||
width: FLOAT,
|
||||
stroke: ?*IStrokeStyle,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.DrawRoundedRectangle(@ptrCast(*IRenderTarget, self), rect, brush, width, stroke);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.DrawRoundedRectangle(@as(*IRenderTarget, @ptrCast(self)), rect, brush, width, stroke);
|
||||
}
|
||||
pub inline fn FillRoundedRectangle(self: *T, rect: *const ROUNDED_RECT, brush: *IBrush) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.FillRoundedRectangle(@ptrCast(*IRenderTarget, self), rect, brush);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.FillRoundedRectangle(@as(*IRenderTarget, @ptrCast(self)), rect, brush);
|
||||
}
|
||||
pub inline fn DrawEllipse(
|
||||
self: *T,
|
||||
@@ -827,12 +827,12 @@ pub const IRenderTarget = extern struct {
|
||||
width: FLOAT,
|
||||
stroke: ?*IStrokeStyle,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.DrawEllipse(@ptrCast(*IRenderTarget, self), ellipse, brush, width, stroke);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.DrawEllipse(@as(*IRenderTarget, @ptrCast(self)), ellipse, brush, width, stroke);
|
||||
}
|
||||
pub inline fn FillEllipse(self: *T, ellipse: *const ELLIPSE, brush: *IBrush) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.FillEllipse(@ptrCast(*IRenderTarget, self), ellipse, brush);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.FillEllipse(@as(*IRenderTarget, @ptrCast(self)), ellipse, brush);
|
||||
}
|
||||
pub inline fn DrawGeometry(
|
||||
self: *T,
|
||||
@@ -841,12 +841,12 @@ pub const IRenderTarget = extern struct {
|
||||
width: FLOAT,
|
||||
stroke: ?*IStrokeStyle,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.DrawGeometry(@ptrCast(*IRenderTarget, self), geo, brush, width, stroke);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.DrawGeometry(@as(*IRenderTarget, @ptrCast(self)), geo, brush, width, stroke);
|
||||
}
|
||||
pub inline fn FillGeometry(self: *T, geo: *IGeometry, brush: *IBrush, opacity_brush: ?*IBrush) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.FillGeometry(@ptrCast(*IRenderTarget, self), geo, brush, opacity_brush);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.FillGeometry(@as(*IRenderTarget, @ptrCast(self)), geo, brush, opacity_brush);
|
||||
}
|
||||
pub inline fn DrawBitmap(
|
||||
self: *T,
|
||||
@@ -856,8 +856,8 @@ pub const IRenderTarget = extern struct {
|
||||
interpolation_mode: BITMAP_INTERPOLATION_MODE,
|
||||
src_rect: ?*const RECT_F,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v).DrawBitmap(
|
||||
@ptrCast(*IRenderTarget, self),
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v)).DrawBitmap(
|
||||
@as(*IRenderTarget, @ptrCast(self)),
|
||||
bitmap,
|
||||
dst_rect,
|
||||
opacity,
|
||||
@@ -875,8 +875,8 @@ pub const IRenderTarget = extern struct {
|
||||
options: DRAW_TEXT_OPTIONS,
|
||||
measuring_mode: dwrite.MEASURING_MODE,
|
||||
) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v).DrawText(
|
||||
@ptrCast(*IRenderTarget, self),
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v)).DrawText(
|
||||
@as(*IRenderTarget, @ptrCast(self)),
|
||||
string,
|
||||
length,
|
||||
format,
|
||||
@@ -887,17 +887,17 @@ pub const IRenderTarget = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn SetTransform(self: *T, m: *const MATRIX_3X2_F) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v).SetTransform(@ptrCast(*IRenderTarget, self), m);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v)).SetTransform(@as(*IRenderTarget, @ptrCast(self)), m);
|
||||
}
|
||||
pub inline fn Clear(self: *T, color: ?*const COLOR_F) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v).Clear(@ptrCast(*IRenderTarget, self), color);
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v)).Clear(@as(*IRenderTarget, @ptrCast(self)), color);
|
||||
}
|
||||
pub inline fn BeginDraw(self: *T) void {
|
||||
@ptrCast(*const IRenderTarget.VTable, self.__v).BeginDraw(@ptrCast(*IRenderTarget, self));
|
||||
@as(*const IRenderTarget.VTable, @ptrCast(self.__v)).BeginDraw(@as(*IRenderTarget, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn EndDraw(self: *T, tag1: ?*TAG, tag2: ?*TAG) HRESULT {
|
||||
return @ptrCast(*const IRenderTarget.VTable, self.__v)
|
||||
.EndDraw(@ptrCast(*IRenderTarget, self), tag1, tag2);
|
||||
return @as(*const IRenderTarget.VTable, @ptrCast(self.__v))
|
||||
.EndDraw(@as(*IRenderTarget, @ptrCast(self)), tag1, tag2);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1022,27 +1022,27 @@ pub const IFactory = extern struct {
|
||||
rect: *const RECT_F,
|
||||
geo: *?*IRectangleGeometry,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateRectangleGeometry(@ptrCast(*IFactory, self), rect, geo);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateRectangleGeometry(@as(*IFactory, @ptrCast(self)), rect, geo);
|
||||
}
|
||||
pub inline fn CreateRoundedRectangleGeometry(
|
||||
self: *T,
|
||||
rect: *const ROUNDED_RECT,
|
||||
geo: *?*IRoundedRectangleGeometry,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateRoundedRectangleGeometry(@ptrCast(*IFactory, self), rect, geo);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateRoundedRectangleGeometry(@as(*IFactory, @ptrCast(self)), rect, geo);
|
||||
}
|
||||
pub inline fn CreateEllipseGeometry(
|
||||
self: *T,
|
||||
ellipse: *const ELLIPSE,
|
||||
geo: *?*IEllipseGeometry,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateEllipseGeometry(@ptrCast(*IFactory, self), ellipse, geo);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateEllipseGeometry(@as(*IFactory, @ptrCast(self)), ellipse, geo);
|
||||
}
|
||||
pub inline fn CreatePathGeometry(self: *T, geo: *?*IPathGeometry) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v).CreatePathGeometry(@ptrCast(*IFactory, self), geo);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v)).CreatePathGeometry(@as(*IFactory, @ptrCast(self)), geo);
|
||||
}
|
||||
pub inline fn CreateStrokeStyle(
|
||||
self: *T,
|
||||
@@ -1051,8 +1051,8 @@ pub const IFactory = extern struct {
|
||||
dashes_count: UINT32,
|
||||
stroke_style: *?*IStrokeStyle,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateStrokeStyle(@ptrCast(*IFactory, self), properties, dashes, dashes_count, stroke_style);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateStrokeStyle(@as(*IFactory, @ptrCast(self)), properties, dashes, dashes_count, stroke_style);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1184,11 +1184,11 @@ pub const IDeviceContext = extern struct {
|
||||
properties: ?*const BITMAP_PROPERTIES1,
|
||||
bitmap: *?*IBitmap1,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.CreateBitmapFromDxgiSurface(@ptrCast(*IDeviceContext, self), surface, properties, bitmap);
|
||||
return @as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.CreateBitmapFromDxgiSurface(@as(*IDeviceContext, @ptrCast(self)), surface, properties, bitmap);
|
||||
}
|
||||
pub inline fn SetTarget(self: *T, image: ?*IImage) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).SetTarget(@ptrCast(*IDeviceContext, self), image);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).SetTarget(@as(*IDeviceContext, @ptrCast(self)), image);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1373,18 +1373,18 @@ pub const IInk = extern struct {
|
||||
pub usingnamespace IResource.Methods(T);
|
||||
|
||||
pub inline fn SetStartPoint(self: *T, point: *const INK_POINT) void {
|
||||
@ptrCast(*const IInk.VTable, self.__v).SetStartPoint(@ptrCast(*IInk, self), point);
|
||||
@as(*const IInk.VTable, @ptrCast(self.__v)).SetStartPoint(@as(*IInk, @ptrCast(self)), point);
|
||||
}
|
||||
pub inline fn GetStartPoint(self: *T) INK_POINT {
|
||||
var point: INK_POINT = undefined;
|
||||
_ = @ptrCast(*const IInk.VTable, self.__v).GetStartPoint(@ptrCast(*IInk, self), &point);
|
||||
_ = @as(*const IInk.VTable, @ptrCast(self.__v)).GetStartPoint(@as(*IInk, @ptrCast(self)), &point);
|
||||
return point;
|
||||
}
|
||||
pub inline fn AddSegments(self: *T, segments: [*]const INK_BEZIER_SEGMENT, count: UINT32) HRESULT {
|
||||
return @ptrCast(*const IInk.VTable, self.__v).AddSegments(@ptrCast(*IInk, self), segments, count);
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v)).AddSegments(@as(*IInk, @ptrCast(self)), segments, count);
|
||||
}
|
||||
pub inline fn RemoveSegmentsAtEnd(self: *T, count: UINT32) HRESULT {
|
||||
return @ptrCast(*const IInk.VTable, self.__v).RemoveSegmentsAtEnd(@ptrCast(*IInk, self), count);
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v)).RemoveSegmentsAtEnd(@as(*IInk, @ptrCast(self)), count);
|
||||
}
|
||||
pub inline fn SetSegments(
|
||||
self: *T,
|
||||
@@ -1392,14 +1392,14 @@ pub const IInk = extern struct {
|
||||
segments: [*]const INK_BEZIER_SEGMENT,
|
||||
count: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IInk.VTable, self.__v)
|
||||
.SetSegments(@ptrCast(*IInk, self), start_segment, segments, count);
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v))
|
||||
.SetSegments(@as(*IInk, @ptrCast(self)), start_segment, segments, count);
|
||||
}
|
||||
pub inline fn SetSegmentAtEnd(self: *T, segment: *const INK_BEZIER_SEGMENT) HRESULT {
|
||||
return @ptrCast(*const IInk.VTable, self.__v).SetSegmentAtEnd(@ptrCast(*IInk, self), segment);
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v)).SetSegmentAtEnd(@as(*IInk, @ptrCast(self)), segment);
|
||||
}
|
||||
pub inline fn GetSegmentCount(self: *T) UINT32 {
|
||||
return @ptrCast(*const IInk.VTable, self.__v).GetSegmentCount(@ptrCast(*IInk, self));
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v)).GetSegmentCount(@as(*IInk, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetSegments(
|
||||
self: *T,
|
||||
@@ -1407,8 +1407,8 @@ pub const IInk = extern struct {
|
||||
segments: [*]const INK_BEZIER_SEGMENT,
|
||||
count: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IInk.VTable, self.__v)
|
||||
.GetSegments(@ptrCast(*IInk, self), start_segment, segments, count);
|
||||
return @as(*const IInk.VTable, @ptrCast(self.__v))
|
||||
.GetSegments(@as(*IInk, @ptrCast(self)), start_segment, segments, count);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1459,20 +1459,20 @@ pub const IDeviceContext2 = extern struct {
|
||||
pub usingnamespace IDeviceContext1.Methods(T);
|
||||
|
||||
pub inline fn CreateInk(self: *T, start_point: *const INK_POINT, ink: *?*IInk) HRESULT {
|
||||
return @ptrCast(*const IDeviceContext2.VTable, self.__v)
|
||||
.CreateInk(@ptrCast(*IDeviceContext2, self), start_point, ink);
|
||||
return @as(*const IDeviceContext2.VTable, @ptrCast(self.__v))
|
||||
.CreateInk(@as(*IDeviceContext2, @ptrCast(self)), start_point, ink);
|
||||
}
|
||||
pub inline fn CreateInkStyle(
|
||||
self: *T,
|
||||
properties: ?*const INK_STYLE_PROPERTIES,
|
||||
ink_style: *?*IInkStyle,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDeviceContext2.VTable, self.__v)
|
||||
.CreateInkStyle(@ptrCast(*IDeviceContext2, self), properties, ink_style);
|
||||
return @as(*const IDeviceContext2.VTable, @ptrCast(self.__v))
|
||||
.CreateInkStyle(@as(*IDeviceContext2, @ptrCast(self)), properties, ink_style);
|
||||
}
|
||||
pub inline fn DrawInk(self: *T, ink: *IInk, brush: *IBrush, style: ?*IInkStyle) void {
|
||||
return @ptrCast(*const IDeviceContext2.VTable, self.__v)
|
||||
.DrawInk(@ptrCast(*IDeviceContext2, self), ink, brush, style);
|
||||
return @as(*const IDeviceContext2.VTable, @ptrCast(self.__v))
|
||||
.DrawInk(@as(*IDeviceContext2, @ptrCast(self)), ink, brush, style);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1650,8 +1650,8 @@ pub const IFactory7 = extern struct {
|
||||
pub usingnamespace IFactory6.Methods(T);
|
||||
|
||||
pub inline fn CreateDevice6(self: *T, dxgi_device: *dxgi.IDevice, d2d_device6: *?*IDevice6) HRESULT {
|
||||
return @ptrCast(*const IFactory7.VTable, self.__v)
|
||||
.CreateDevice6(@ptrCast(*IFactory7, self), dxgi_device, d2d_device6);
|
||||
return @as(*const IFactory7.VTable, @ptrCast(self.__v))
|
||||
.CreateDevice6(@as(*IFactory7, @ptrCast(self)), dxgi_device, d2d_device6);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1748,8 +1748,8 @@ pub const IDevice6 = extern struct {
|
||||
options: DEVICE_CONTEXT_OPTIONS,
|
||||
devctx: *?*IDeviceContext6,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice6.VTable, self.__v)
|
||||
.CreateDeviceContext6(@ptrCast(*IDevice6, self), options, devctx);
|
||||
return @as(*const IDevice6.VTable, @ptrCast(self.__v))
|
||||
.CreateDeviceContext6(@as(*IDevice6, @ptrCast(self)), options, devctx);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+63
-63
@@ -596,8 +596,8 @@ pub const IDeviceContext = extern struct {
|
||||
NumBuffers: UINT,
|
||||
ppConstantBuffers: ?[*]const *IBuffer,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).VSSetConstantBuffers(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).VSSetConstantBuffers(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumBuffers,
|
||||
ppConstantBuffers,
|
||||
@@ -609,8 +609,8 @@ pub const IDeviceContext = extern struct {
|
||||
NumViews: UINT,
|
||||
ppShaderResourceViews: ?[*]const *IShaderResourceView,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).PSSetShaderResources(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).PSSetShaderResources(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumViews,
|
||||
ppShaderResourceViews,
|
||||
@@ -622,8 +622,8 @@ pub const IDeviceContext = extern struct {
|
||||
ppClassInstance: ?[*]const *IClassInstance,
|
||||
NumClassInstances: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).PSSetShader(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).PSSetShader(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
pPixelShader,
|
||||
ppClassInstance,
|
||||
NumClassInstances,
|
||||
@@ -635,8 +635,8 @@ pub const IDeviceContext = extern struct {
|
||||
NumSamplers: UINT,
|
||||
ppSamplers: ?[*]const *ISamplerState,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).PSSetSamplers(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).PSSetSamplers(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumSamplers,
|
||||
ppSamplers,
|
||||
@@ -648,8 +648,8 @@ pub const IDeviceContext = extern struct {
|
||||
ppClassInstance: ?[*]const *IClassInstance,
|
||||
NumClassInstances: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).VSSetShader(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).VSSetShader(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
pVertexShader,
|
||||
ppClassInstance,
|
||||
NumClassInstances,
|
||||
@@ -660,8 +660,8 @@ pub const IDeviceContext = extern struct {
|
||||
VertexCount: UINT,
|
||||
StartVertexLocation: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.Draw(@ptrCast(*IDeviceContext, self), VertexCount, StartVertexLocation);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.Draw(@as(*IDeviceContext, @ptrCast(self)), VertexCount, StartVertexLocation);
|
||||
}
|
||||
pub inline fn Map(
|
||||
self: *T,
|
||||
@@ -671,8 +671,8 @@ pub const IDeviceContext = extern struct {
|
||||
MapFlags: MAP_FLAG,
|
||||
pMappedResource: ?*MAPPED_SUBRESOURCE,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDeviceContext.VTable, self.__v).Map(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
return @as(*const IDeviceContext.VTable, @ptrCast(self.__v)).Map(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
pResource,
|
||||
Subresource,
|
||||
MapType,
|
||||
@@ -681,8 +681,8 @@ pub const IDeviceContext = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn Unmap(self: *T, pResource: *IResource, Subresource: UINT) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.Unmap(@ptrCast(*IDeviceContext, self), pResource, Subresource);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.Unmap(@as(*IDeviceContext, @ptrCast(self)), pResource, Subresource);
|
||||
}
|
||||
pub inline fn PSSetConstantBuffers(
|
||||
self: *T,
|
||||
@@ -690,16 +690,16 @@ pub const IDeviceContext = extern struct {
|
||||
NumBuffers: UINT,
|
||||
ppConstantBuffers: ?[*]const *IBuffer,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).PSSetConstantBuffers(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).PSSetConstantBuffers(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumBuffers,
|
||||
ppConstantBuffers,
|
||||
);
|
||||
}
|
||||
pub inline fn IASetInputLayout(self: *T, pInputLayout: ?*IInputLayout) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.IASetInputLayout(@ptrCast(*IDeviceContext, self), pInputLayout);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.IASetInputLayout(@as(*IDeviceContext, @ptrCast(self)), pInputLayout);
|
||||
}
|
||||
pub inline fn IASetVertexBuffers(
|
||||
self: *T,
|
||||
@@ -709,8 +709,8 @@ pub const IDeviceContext = extern struct {
|
||||
pStrides: ?[*]const UINT,
|
||||
pOffsets: ?[*]const UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).IASetVertexBuffers(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).IASetVertexBuffers(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumBuffers,
|
||||
ppVertexBuffers,
|
||||
@@ -719,8 +719,8 @@ pub const IDeviceContext = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn IASetPrimitiveTopology(self: *T, Topology: PRIMITIVE_TOPOLOGY) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.IASetPrimitiveTopology(@ptrCast(*IDeviceContext, self), Topology);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.IASetPrimitiveTopology(@as(*IDeviceContext, @ptrCast(self)), Topology);
|
||||
}
|
||||
pub inline fn VSSetShaderResources(
|
||||
self: *T,
|
||||
@@ -728,8 +728,8 @@ pub const IDeviceContext = extern struct {
|
||||
NumViews: UINT,
|
||||
ppShaderResourceViews: ?[*]const *IShaderResourceView,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).VSSetShaderResources(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).VSSetShaderResources(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
StartSlot,
|
||||
NumViews,
|
||||
ppShaderResourceViews,
|
||||
@@ -741,8 +741,8 @@ pub const IDeviceContext = extern struct {
|
||||
ppRenderTargetViews: ?[*]const IRenderTargetView,
|
||||
pDepthStencilView: ?*IDepthStencilView,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).OMSetRenderTargets(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).OMSetRenderTargets(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
NumViews,
|
||||
ppRenderTargetViews,
|
||||
pDepthStencilView,
|
||||
@@ -754,39 +754,39 @@ pub const IDeviceContext = extern struct {
|
||||
BlendFactor: ?*const [4]FLOAT,
|
||||
SampleMask: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).OMSetBlendState(
|
||||
@ptrCast(*IDeviceContext, self),
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).OMSetBlendState(
|
||||
@as(*IDeviceContext, @ptrCast(self)),
|
||||
pBlendState,
|
||||
BlendFactor,
|
||||
SampleMask,
|
||||
);
|
||||
}
|
||||
pub inline fn RSSetState(self: *T, pRasterizerState: ?*IRasterizerState) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.RSSetState(@ptrCast(*IDeviceContext, self), pRasterizerState);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.RSSetState(@as(*IDeviceContext, @ptrCast(self)), pRasterizerState);
|
||||
}
|
||||
pub inline fn RSSetViewports(
|
||||
self: *T,
|
||||
NumViewports: UINT,
|
||||
pViewports: [*]const VIEWPORT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.RSSetViewports(@ptrCast(*IDeviceContext, self), NumViewports, pViewports);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.RSSetViewports(@as(*IDeviceContext, @ptrCast(self)), NumViewports, pViewports);
|
||||
}
|
||||
pub inline fn RSSetScissorRects(self: *T, NumRects: UINT, pRects: ?[*]const RECT) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.RSSetScissorRects(@ptrCast(*IDeviceContext, self), NumRects, pRects);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.RSSetScissorRects(@as(*IDeviceContext, @ptrCast(self)), NumRects, pRects);
|
||||
}
|
||||
pub inline fn ClearRenderTargetView(
|
||||
self: *T,
|
||||
pRenderTargetView: *IRenderTargetView,
|
||||
ColorRGBA: *const [4]FLOAT,
|
||||
) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v)
|
||||
.ClearRenderTargetView(@ptrCast(*IDeviceContext, self), pRenderTargetView, ColorRGBA);
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v))
|
||||
.ClearRenderTargetView(@as(*IDeviceContext, @ptrCast(self)), pRenderTargetView, ColorRGBA);
|
||||
}
|
||||
pub inline fn Flush(self: *T) void {
|
||||
@ptrCast(*const IDeviceContext.VTable, self.__v).Flush(@ptrCast(*IDeviceContext, self));
|
||||
@as(*const IDeviceContext.VTable, @ptrCast(self.__v)).Flush(@as(*IDeviceContext, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -980,8 +980,8 @@ pub const IDevice = extern struct {
|
||||
pInitialData: ?*const SUBRESOURCE_DATA,
|
||||
ppBuffer: *?*IBuffer,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateBuffer(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateBuffer(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pDesc,
|
||||
pInitialData,
|
||||
ppBuffer,
|
||||
@@ -993,8 +993,8 @@ pub const IDevice = extern struct {
|
||||
pInitialData: ?*const SUBRESOURCE_DATA,
|
||||
ppTexture2D: ?*?*ITexture2D,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateTexture2D(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateTexture2D(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pDesc,
|
||||
pInitialData,
|
||||
ppTexture2D,
|
||||
@@ -1006,8 +1006,8 @@ pub const IDevice = extern struct {
|
||||
pDesc: ?*const SHADER_RESOURCE_VIEW_DESC,
|
||||
ppSRView: ?*?*IShaderResourceView,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateShaderResourceView(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateShaderResourceView(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pResource,
|
||||
pDesc,
|
||||
ppSRView,
|
||||
@@ -1019,8 +1019,8 @@ pub const IDevice = extern struct {
|
||||
pDesc: ?*const RENDER_TARGET_VIEW_DESC,
|
||||
ppRTView: ?*?*IRenderTargetView,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateRenderTargetView(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateRenderTargetView(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pResource,
|
||||
pDesc,
|
||||
ppRTView,
|
||||
@@ -1034,8 +1034,8 @@ pub const IDevice = extern struct {
|
||||
BytecodeLength: SIZE_T,
|
||||
ppInputLayout: *?*IInputLayout,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateInputLayout(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateInputLayout(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pInputElementDescs,
|
||||
NumElements,
|
||||
pShaderBytecodeWithInputSignature,
|
||||
@@ -1050,8 +1050,8 @@ pub const IDevice = extern struct {
|
||||
pClassLinkage: ?*IClassLinkage,
|
||||
ppVertexShader: ?*?*IVertexShader,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateVertexShader(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateVertexShader(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pShaderBytecode,
|
||||
BytecodeLength,
|
||||
pClassLinkage,
|
||||
@@ -1065,8 +1065,8 @@ pub const IDevice = extern struct {
|
||||
pClassLinkage: ?*IClassLinkage,
|
||||
ppPixelShader: ?*?*IPixelShader,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreatePixelShader(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreatePixelShader(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pShaderBytecode,
|
||||
BytecodeLength,
|
||||
pClassLinkage,
|
||||
@@ -1078,16 +1078,16 @@ pub const IDevice = extern struct {
|
||||
pBlendStateDesc: *const BLEND_DESC,
|
||||
ppBlendState: ?*?*IBlendState,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CreateBlendState(@ptrCast(*IDevice, self), pBlendStateDesc, ppBlendState);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CreateBlendState(@as(*IDevice, @ptrCast(self)), pBlendStateDesc, ppBlendState);
|
||||
}
|
||||
pub inline fn CreateRasterizerState(
|
||||
self: *T,
|
||||
pRasterizerDesc: *const RASTERIZER_DESC,
|
||||
ppRasterizerState: ?*?*IRasterizerState,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateRasterizerState(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateRasterizerState(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pRasterizerDesc,
|
||||
ppRasterizerState,
|
||||
);
|
||||
@@ -1097,8 +1097,8 @@ pub const IDevice = extern struct {
|
||||
pSamplerDesc: *const SAMPLER_DESC,
|
||||
ppSamplerState: ?*?*ISamplerState,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateSamplerState(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateSamplerState(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
pSamplerDesc,
|
||||
ppSamplerState,
|
||||
);
|
||||
@@ -1436,10 +1436,10 @@ pub extern "d3d11" fn D3D11CreateDeviceAndSwapChain(
|
||||
|
||||
// Return codes as defined here:
|
||||
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d11-graphics-reference-returnvalues
|
||||
pub const ERROR_FILE_NOT_FOUND = @bitCast(HRESULT, @as(c_ulong, 0x887C0002));
|
||||
pub const ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS = @bitCast(HRESULT, @as(c_ulong, 0x887C0001));
|
||||
pub const ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS = @bitCast(HRESULT, @as(c_ulong, 0x887C0003));
|
||||
pub const ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD = @bitCast(HRESULT, @as(c_ulong, 0x887C0004));
|
||||
pub const ERROR_FILE_NOT_FOUND = @as(HRESULT, @bitCast(@as(c_ulong, 0x887C0002)));
|
||||
pub const ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS = @as(HRESULT, @bitCast(@as(c_ulong, 0x887C0001)));
|
||||
pub const ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS = @as(HRESULT, @bitCast(@as(c_ulong, 0x887C0003)));
|
||||
pub const ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD = @as(HRESULT, @bitCast(@as(c_ulong, 0x887C0004)));
|
||||
|
||||
// error set corresponding to the above return codes
|
||||
pub const Error = error{
|
||||
|
||||
@@ -33,8 +33,8 @@ pub const IDevice = extern struct {
|
||||
guid: *const GUID,
|
||||
resource11: ?*?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateWrappedResource(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateWrappedResource(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
resource12,
|
||||
flags11,
|
||||
in_state,
|
||||
@@ -48,16 +48,16 @@ pub const IDevice = extern struct {
|
||||
resources: [*]const *d3d11.IResource,
|
||||
num_resources: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDevice.VTable, self.__v)
|
||||
.ReleaseWrappedResources(@ptrCast(*IDevice, self), resources, num_resources);
|
||||
@as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.ReleaseWrappedResources(@as(*IDevice, @ptrCast(self)), resources, num_resources);
|
||||
}
|
||||
pub inline fn AcquireWrappedResources(
|
||||
self: *T,
|
||||
resources: [*]const *d3d11.IResource,
|
||||
num_resources: UINT,
|
||||
) void {
|
||||
@ptrCast(*const IDevice.VTable, self.__v)
|
||||
.AcquireWrappedResources(@ptrCast(*IDevice, self), resources, num_resources);
|
||||
@as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.AcquireWrappedResources(@as(*IDevice, @ptrCast(self)), resources, num_resources);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1407,34 +1407,34 @@ pub const IInfoQueue = extern struct {
|
||||
pMessage: ?*MESSAGE,
|
||||
pMessageByteLength: *SIZE_T,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v).GetMessage(
|
||||
@ptrCast(*IInfoQueue, self),
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v)).GetMessage(
|
||||
@as(*IInfoQueue, @ptrCast(self)),
|
||||
MessageIndex,
|
||||
pMessage,
|
||||
pMessageByteLength,
|
||||
);
|
||||
}
|
||||
pub inline fn GetNumStoredMessages(self: *T) UINT64 {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.GetNumStoredMessages(@ptrCast(*IInfoQueue, self));
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.GetNumStoredMessages(@as(*IInfoQueue, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn AddStorageFilterEntries(self: *T, filter: *INFO_QUEUE_FILTER) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.AddStorageFilterEntries(@ptrCast(*IInfoQueue, self), filter);
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.AddStorageFilterEntries(@as(*IInfoQueue, @ptrCast(self)), filter);
|
||||
}
|
||||
pub inline fn PushEmptyStorageFilter(self: *T) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.PushEmptyStorageFilter(@ptrCast(*IInfoQueue, self));
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.PushEmptyStorageFilter(@as(*IInfoQueue, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn PushStorageFilter(self: *T, filter: *INFO_QUEUE_FILTER) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.PushStorageFilter(@ptrCast(*IInfoQueue, self), filter);
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.PushStorageFilter(@as(*IInfoQueue, @ptrCast(self)), filter);
|
||||
}
|
||||
pub inline fn PopStorageFilter(self: *T) void {
|
||||
@ptrCast(*const IInfoQueue.VTable, self.__v).PopStorageFilter();
|
||||
@as(*const IInfoQueue.VTable, @ptrCast(self.__v)).PopStorageFilter();
|
||||
}
|
||||
pub inline fn SetMuteDebugOutput(self: *T, mute: BOOL) void {
|
||||
@ptrCast(*const IInfoQueue.VTable, self.__v).SetMuteDebugOutput(@ptrCast(*IInfoQueue, self), mute);
|
||||
@as(*const IInfoQueue.VTable, @ptrCast(self.__v)).SetMuteDebugOutput(@as(*IInfoQueue, @ptrCast(self)), mute);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+377
-377
File diff suppressed because it is too large.
Load diff
@@ -21,7 +21,7 @@ pub const IDebug = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn EnableDebugLayer(self: *T) void {
|
||||
@ptrCast(*const IDebug.VTable, self.__v).EnableDebugLayer(@ptrCast(*IDebug, self));
|
||||
@as(*const IDebug.VTable, @ptrCast(self.__v)).EnableDebugLayer(@as(*IDebug, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -42,15 +42,15 @@ pub const IDebug1 = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn EnableDebugLayer(self: *T) void {
|
||||
@ptrCast(*const IDebug1.VTable, self.__v).EnableDebugLayer(@ptrCast(*IDebug1, self));
|
||||
@as(*const IDebug1.VTable, @ptrCast(self.__v)).EnableDebugLayer(@as(*IDebug1, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn SetEnableGPUBasedValidation(self: *T, enable: BOOL) void {
|
||||
@ptrCast(*const IDebug1.VTable, self.__v)
|
||||
.SetEnableGPUBasedValidation(@ptrCast(*IDebug1, self), enable);
|
||||
@as(*const IDebug1.VTable, @ptrCast(self.__v))
|
||||
.SetEnableGPUBasedValidation(@as(*IDebug1, @ptrCast(self)), enable);
|
||||
}
|
||||
pub inline fn SetEnableSynchronizedCommandQueueValidation(self: *T, enable: BOOL) void {
|
||||
@ptrCast(*const IDebug1.VTable, self.__v)
|
||||
.SetEnableSynchronizedCommandQueueValidation(@ptrCast(*IDebug1, self), enable);
|
||||
@as(*const IDebug1.VTable, @ptrCast(self.__v))
|
||||
.SetEnableSynchronizedCommandQueueValidation(@as(*IDebug1, @ptrCast(self)), enable);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -73,8 +73,8 @@ pub const IDebug2 = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn SetGPUBasedValidationFlags(self: *T, flags: GPU_BASED_VALIDATION_FLAGS) void {
|
||||
@ptrCast(*const IDebug2.VTable, self.__v)
|
||||
.SetGPUBasedValidationFlags(@ptrCast(*IDebug2, self), flags);
|
||||
@as(*const IDebug2.VTable, @ptrCast(self.__v))
|
||||
.SetGPUBasedValidationFlags(@as(*IDebug2, @ptrCast(self)), flags);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -95,16 +95,16 @@ pub const IDebug3 = extern struct {
|
||||
pub usingnamespace IDebug.Methods(T);
|
||||
|
||||
pub inline fn SetEnableGPUBasedValidation(self: *T, enable: BOOL) void {
|
||||
@ptrCast(*const IDebug3.VTable, self.__v)
|
||||
.SetEnableGPUBasedValidation(@ptrCast(*IDebug3, self), enable);
|
||||
@as(*const IDebug3.VTable, @ptrCast(self.__v))
|
||||
.SetEnableGPUBasedValidation(@as(*IDebug3, @ptrCast(self)), enable);
|
||||
}
|
||||
pub inline fn SetEnableSynchronizedCommandQueueValidation(self: *T, enable: BOOL) void {
|
||||
@ptrCast(*const IDebug3.VTable, self.__v)
|
||||
.SetEnableSynchronizedCommandQueueValidation(@ptrCast(*IDebug3, self), enable);
|
||||
@as(*const IDebug3.VTable, @ptrCast(self.__v))
|
||||
.SetEnableSynchronizedCommandQueueValidation(@as(*IDebug3, @ptrCast(self)), enable);
|
||||
}
|
||||
pub inline fn SetGPUBasedValidationFlags(self: *T, flags: GPU_BASED_VALIDATION_FLAGS) void {
|
||||
@ptrCast(*const IDebug3.VTable, self.__v)
|
||||
.SetGPUBasedValidationFlags(@ptrCast(*IDebug3, self), flags);
|
||||
@as(*const IDebug3.VTable, @ptrCast(self.__v))
|
||||
.SetGPUBasedValidationFlags(@as(*IDebug3, @ptrCast(self)), flags);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -127,7 +127,7 @@ pub const IDebug4 = extern struct {
|
||||
pub usingnamespace IDebug3.Methods(T);
|
||||
|
||||
pub inline fn DisableDebugLayer(self: *T) void {
|
||||
@ptrCast(*const IDebug4.VTable, self.__v).DisableDebugLayer(@ptrCast(*IDebug4, self));
|
||||
@as(*const IDebug4.VTable, @ptrCast(self.__v)).DisableDebugLayer(@as(*IDebug4, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -148,7 +148,7 @@ pub const IDebug5 = extern struct {
|
||||
pub usingnamespace IDebug4.Methods(T);
|
||||
|
||||
pub inline fn SetEnableAutoName(self: *T, enable: BOOL) void {
|
||||
@ptrCast(*const IDebug5.VTable, self.__v).SetEnableAutoName(@ptrCast(*IDebug5, self), enable);
|
||||
@as(*const IDebug5.VTable, @ptrCast(self.__v)).SetEnableAutoName(@as(*IDebug5, @ptrCast(self)), enable);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -211,18 +211,18 @@ pub const IInfoQueue = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn AddStorageFilterEntries(self: *T, filter: *INFO_QUEUE_FILTER) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.AddStorageFilterEntries(@ptrCast(*IInfoQueue, self), filter);
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.AddStorageFilterEntries(@as(*IInfoQueue, @ptrCast(self)), filter);
|
||||
}
|
||||
pub inline fn PushStorageFilter(self: *T, filter: *INFO_QUEUE_FILTER) HRESULT {
|
||||
return @ptrCast(*const IInfoQueue.VTable, self.__v)
|
||||
.PushStorageFilter(@ptrCast(*IInfoQueue, self), filter);
|
||||
return @as(*const IInfoQueue.VTable, @ptrCast(self.__v))
|
||||
.PushStorageFilter(@as(*IInfoQueue, @ptrCast(self)), filter);
|
||||
}
|
||||
pub inline fn PopStorageFilter(self: *T) void {
|
||||
@ptrCast(*const IInfoQueue.VTable, self.__v).PopStorageFilter(@ptrCast(*IInfoQueue, self));
|
||||
@as(*const IInfoQueue.VTable, @ptrCast(self.__v)).PopStorageFilter(@as(*IInfoQueue, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn SetMuteDebugOutput(self: *T, mute: BOOL) void {
|
||||
@ptrCast(*const IInfoQueue.VTable, self.__v).SetMuteDebugOutput(@ptrCast(*IInfoQueue, self), mute);
|
||||
@as(*const IInfoQueue.VTable, @ptrCast(self.__v)).SetMuteDebugOutput(@as(*IInfoQueue, @ptrCast(self)), mute);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -95,10 +95,10 @@ pub const IBlob = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetBufferPointer(self: *T) *anyopaque {
|
||||
return @ptrCast(*const IBlob.VTable, self.__v).GetBufferPointer(@ptrCast(*IBlob, self));
|
||||
return @as(*const IBlob.VTable, @ptrCast(self.__v)).GetBufferPointer(@as(*IBlob, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetBufferSize(self: *T) SIZE_T {
|
||||
return @ptrCast(*const IBlob.VTable, self.__v).GetBufferSize(@ptrCast(*IBlob, self));
|
||||
return @as(*const IBlob.VTable, @ptrCast(self.__v)).GetBufferSize(@as(*IBlob, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ const DDS_PAL8: u32 = 0x00000020; // DDPF_PALETTEINDEXED8
|
||||
const DDS_BUMPDUDV: u32 = 0x00080000; // DDPF_BUMPDUDV
|
||||
|
||||
inline fn makeFourCC(ch0: u8, ch1: u8, ch2: u8, ch3: u8) u32 {
|
||||
return (@intCast(u32, ch0)) | (@intCast(u32, ch1) << 8) | (@intCast(u32, ch2) << 16) | (@intCast(u32, ch3) << 24);
|
||||
return (@as(u32, @intCast(ch0))) | (@as(u32, @intCast(ch1)) << 8) | (@as(u32, @intCast(ch2)) << 16) | (@as(u32, @intCast(ch3)) << 24);
|
||||
}
|
||||
|
||||
inline fn isBitMask(pixelFormat: DDS_PIXELFORMAT, r: u32, g: u32, b: u32, a: u32) bool {
|
||||
@@ -162,11 +162,11 @@ pub fn loadTextureFromMemory(file_data: []u8, arena: std.mem.Allocator, device:
|
||||
|
||||
// Extract DDS_HEADER
|
||||
const header = try reader.readStruct(DDS_HEADER);
|
||||
if (header.dwSize != @intCast(u32, @sizeOf(DDS_HEADER))) {
|
||||
if (header.dwSize != @as(u32, @intCast(@sizeOf(DDS_HEADER)))) {
|
||||
return DdsError.InvalidDDSData;
|
||||
}
|
||||
|
||||
if (header.ddspf.dwSize != @intCast(u32, @sizeOf(DDS_PIXELFORMAT))) {
|
||||
if (header.ddspf.dwSize != @as(u32, @intCast(@sizeOf(DDS_PIXELFORMAT)))) {
|
||||
return DdsError.InvalidDDSData;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ pub fn loadTextureFromMemory(file_data: []u8, arena: std.mem.Allocator, device:
|
||||
// Check alpha mode
|
||||
var alpha_mode = DDS_ALPHA_MODE.unknown;
|
||||
if (has_dx10_extension) {
|
||||
alpha_mode = @enumFromInt(DDS_ALPHA_MODE, dx10.miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
||||
alpha_mode = @as(DDS_ALPHA_MODE, @enumFromInt(dx10.miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK));
|
||||
} else {
|
||||
if (makeFourCC('D', 'X', 'T', '2') == header.ddspf.dwFourCC or makeFourCC('D', 'X', 'T', '4') == header.ddspf.dwFourCC) {
|
||||
alpha_mode = .premultiplied;
|
||||
@@ -253,7 +253,7 @@ pub fn loadTextureFromMemory(file_data: []u8, arena: std.mem.Allocator, device:
|
||||
return DdsError.InvalidDDSData;
|
||||
}
|
||||
|
||||
resource_dimension = @enumFromInt(d3d12.RESOURCE_DIMENSION, dx10.resourceDimension);
|
||||
resource_dimension = @as(d3d12.RESOURCE_DIMENSION, @enumFromInt(dx10.resourceDimension));
|
||||
} else {
|
||||
format = getDXGIFormat(header.ddspf);
|
||||
|
||||
@@ -372,9 +372,9 @@ pub fn loadTextureFromMemory(file_data: []u8, arena: std.mem.Allocator, device:
|
||||
}
|
||||
|
||||
var resource = d3d12.SUBRESOURCE_DATA{
|
||||
.pData = @ptrCast([*]u8, data[data_offset..]),
|
||||
.RowPitch = @intCast(c_uint, surface_info.row_bytes),
|
||||
.SlicePitch = @intCast(c_uint, surface_info.num_bytes),
|
||||
.pData = @as([*]u8, @ptrCast(data[data_offset..])),
|
||||
.RowPitch = @as(c_uint, @intCast(surface_info.row_bytes)),
|
||||
.SlicePitch = @as(c_uint, @intCast(surface_info.num_bytes)),
|
||||
};
|
||||
|
||||
adjustPlaneResource(format, h, plane_index, &resource);
|
||||
@@ -384,7 +384,7 @@ pub fn loadTextureFromMemory(file_data: []u8, arena: std.mem.Allocator, device:
|
||||
skip_mip += 1;
|
||||
}
|
||||
|
||||
data_offset += @intCast(u32, surface_info.num_bytes) * d;
|
||||
data_offset += @as(u32, @intCast(surface_info.num_bytes)) * d;
|
||||
if (data_offset > data.len) {
|
||||
return DdsError.EndOfFile;
|
||||
}
|
||||
@@ -742,33 +742,33 @@ fn getSurfaceInfo(
|
||||
if (format_data.bc) {
|
||||
var num_blocks_wide: u64 = 0;
|
||||
if (width > 0) {
|
||||
num_blocks_wide = @max(1, @divTrunc(@intCast(u64, width) + 3, 4));
|
||||
num_blocks_wide = @max(1, @divTrunc(@as(u64, @intCast(width)) + 3, 4));
|
||||
}
|
||||
var num_blocks_high: u64 = 0;
|
||||
if (height > 0) {
|
||||
num_blocks_high = @max(1, @divTrunc(@intCast(u64, height) + 3, 4));
|
||||
num_blocks_high = @max(1, @divTrunc(@as(u64, @intCast(height)) + 3, 4));
|
||||
}
|
||||
row_bytes = num_blocks_wide * format_data.bpe;
|
||||
num_rows = num_blocks_high;
|
||||
num_bytes = row_bytes * num_blocks_high;
|
||||
} else if (format_data.@"packed") {
|
||||
row_bytes = ((@intCast(u64, width) + 1) >> 1) * format_data.bpe;
|
||||
num_rows = @intCast(u64, height);
|
||||
row_bytes = ((@as(u64, @intCast(width)) + 1) >> 1) * format_data.bpe;
|
||||
num_rows = @as(u64, @intCast(height));
|
||||
num_bytes = row_bytes * height;
|
||||
} else if (format == .NV11) {
|
||||
row_bytes = ((@intCast(u64, width) + 3) >> 2) * 4;
|
||||
num_rows = @intCast(u64, height) * 2; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data
|
||||
row_bytes = ((@as(u64, @intCast(width)) + 3) >> 2) * 4;
|
||||
num_rows = @as(u64, @intCast(height)) * 2; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data
|
||||
num_bytes = row_bytes * num_rows;
|
||||
} else if (format_data.planar) {
|
||||
row_bytes = ((@intCast(u64, width) + 1) >> 1) * format_data.bpe;
|
||||
num_bytes = (row_bytes * @intCast(u64, height)) + ((row_bytes * @intCast(u64, height) + 1) >> 1);
|
||||
num_rows = height + ((@intCast(u64, height) + 1) >> 1);
|
||||
row_bytes = ((@as(u64, @intCast(width)) + 1) >> 1) * format_data.bpe;
|
||||
num_bytes = (row_bytes * @as(u64, @intCast(height))) + ((row_bytes * @as(u64, @intCast(height)) + 1) >> 1);
|
||||
num_rows = height + ((@as(u64, @intCast(height)) + 1) >> 1);
|
||||
} else {
|
||||
const bpp = format.pixelSizeInBits();
|
||||
assert(bpp > 0);
|
||||
|
||||
row_bytes = @divFloor(@intCast(u64, width) * bpp + 7, 8); // round up to nearest byte
|
||||
num_rows = @intCast(u64, height);
|
||||
row_bytes = @divFloor(@as(u64, @intCast(width)) * bpp + 7, 8); // round up to nearest byte
|
||||
num_rows = @as(u64, @intCast(height));
|
||||
num_bytes = row_bytes * height;
|
||||
}
|
||||
|
||||
|
||||
@@ -352,8 +352,8 @@ pub const IObject = extern struct {
|
||||
data_size: *UINT,
|
||||
data: ?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.GetPrivateData(@ptrCast(*IObject, self), guid, data_size, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.GetPrivateData(@as(*IObject, @ptrCast(self)), guid, data_size, data);
|
||||
}
|
||||
pub inline fn SetPrivateData(
|
||||
self: *T,
|
||||
@@ -361,20 +361,20 @@ pub const IObject = extern struct {
|
||||
data_size: UINT,
|
||||
data: ?*const anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.SetPrivateData(@ptrCast(*IObject, self), guid, data_size, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.SetPrivateData(@as(*IObject, @ptrCast(self)), guid, data_size, data);
|
||||
}
|
||||
pub inline fn SetPrivateDataInterface(
|
||||
self: *T,
|
||||
guid: *const GUID,
|
||||
data: ?*const IUnknown,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.SetPrivateDataInterface(@ptrCast(*IObject, self), guid, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.SetPrivateDataInterface(@as(*IObject, @ptrCast(self)), guid, data);
|
||||
}
|
||||
pub inline fn SetName(self: *T, name: LPCWSTR) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.SetName(@ptrCast(*IObject, self), name);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.SetName(@as(*IObject, @ptrCast(self)), name);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -399,8 +399,8 @@ pub const IDeviceChild = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn GetDevice(self: *T, guid: *const GUID, device: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IDeviceChild.VTable, self.__v)
|
||||
.GetDevice(@ptrCast(*IDeviceChild, self), guid, device);
|
||||
return @as(*const IDeviceChild.VTable, @ptrCast(self.__v))
|
||||
.GetDevice(@as(*IDeviceChild, @ptrCast(self)), guid, device);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -463,8 +463,8 @@ pub const IDispatchable = extern struct {
|
||||
|
||||
pub inline fn GetBindingProperties(self: *T) BINDING_PROPERTIES {
|
||||
var properties: BINDING_PROPERTIES = undefined;
|
||||
_ = @ptrCast(*const IDispatchable.VTable, self.__v)
|
||||
.GetBindingProperties(@ptrCast(*IDispatchable, self), &properties);
|
||||
_ = @as(*const IDispatchable.VTable, @ptrCast(self.__v))
|
||||
.GetBindingProperties(@as(*IDispatchable, @ptrCast(self)), &properties);
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
@@ -507,8 +507,8 @@ pub const IOperatorInitializer = extern struct {
|
||||
pub usingnamespace IDispatchable.Methods(T);
|
||||
|
||||
pub inline fn Reset(self: *T, num_operators: UINT, operators: [*]const *ICompiledOperator) HRESULT {
|
||||
return @ptrCast(*const IOperatorInitializer.VTable, self.__v)
|
||||
.Reset(@ptrCast(*IOperatorInitializer, self), num_operators, operators);
|
||||
return @as(*const IOperatorInitializer.VTable, @ptrCast(self.__v))
|
||||
.Reset(@as(*IOperatorInitializer, @ptrCast(self)), num_operators, operators);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -552,24 +552,24 @@ pub const IBindingTable = extern struct {
|
||||
pub usingnamespace IDeviceChild.Methods(T);
|
||||
|
||||
pub inline fn BindInputs(self: *T, num: UINT, bindings: ?[*]const BINDING_DESC) void {
|
||||
@ptrCast(*const IBindingTable.VTable, self.__v)
|
||||
.BindInputs(@ptrCast(*IBindingTable, self), num, bindings);
|
||||
@as(*const IBindingTable.VTable, @ptrCast(self.__v))
|
||||
.BindInputs(@as(*IBindingTable, @ptrCast(self)), num, bindings);
|
||||
}
|
||||
pub inline fn BindOutputs(self: *T, num: UINT, bindings: ?[*]const BINDING_DESC) void {
|
||||
@ptrCast(*const IBindingTable.VTable, self.__v)
|
||||
.BindOutputs(@ptrCast(*IBindingTable, self), num, bindings);
|
||||
@as(*const IBindingTable.VTable, @ptrCast(self.__v))
|
||||
.BindOutputs(@as(*IBindingTable, @ptrCast(self)), num, bindings);
|
||||
}
|
||||
pub inline fn BindTemporaryResource(self: *T, binding: ?*const BINDING_DESC) void {
|
||||
@ptrCast(*const IBindingTable.VTable, self.__v)
|
||||
.BindTemporaryResource(@ptrCast(*IBindingTable, self), binding);
|
||||
@as(*const IBindingTable.VTable, @ptrCast(self.__v))
|
||||
.BindTemporaryResource(@as(*IBindingTable, @ptrCast(self)), binding);
|
||||
}
|
||||
pub inline fn BindPersistentResource(self: *T, binding: ?*const BINDING_DESC) void {
|
||||
@ptrCast(*const IBindingTable.VTable, self.__v)
|
||||
.BindPersistentResource(@ptrCast(*IBindingTable, self), binding);
|
||||
@as(*const IBindingTable.VTable, @ptrCast(self.__v))
|
||||
.BindPersistentResource(@as(*IBindingTable, @ptrCast(self)), binding);
|
||||
}
|
||||
pub inline fn Reset(self: *T, desc: ?*const BINDING_TABLE_DESC) HRESULT {
|
||||
return @ptrCast(*const IBindingTable.VTable, self.__v)
|
||||
.Reset(@ptrCast(*IBindingTable, self), desc);
|
||||
return @as(*const IBindingTable.VTable, @ptrCast(self.__v))
|
||||
.Reset(@as(*IBindingTable, @ptrCast(self)), desc);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -600,8 +600,8 @@ pub const ICommandRecorder = extern struct {
|
||||
dispatchable: *IDispatchable,
|
||||
bindings: *IBindingTable,
|
||||
) void {
|
||||
@ptrCast(*const ICommandRecorder.VTable, self.__v)
|
||||
.RecordDispatch(@ptrCast(*ICommandRecorder, self), cmdlist, dispatchable, bindings);
|
||||
@as(*const ICommandRecorder.VTable, @ptrCast(self.__v))
|
||||
.RecordDispatch(@as(*ICommandRecorder, @ptrCast(self)), cmdlist, dispatchable, bindings);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -628,8 +628,8 @@ pub const IDebugDevice = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn SetMuteDebugOutput(self: *T, mute: BOOL) void {
|
||||
@ptrCast(*const IDebugDevice.VTable, self.v)
|
||||
.SetMuteDebugOutput(@ptrCast(*IDebugDevice, self), mute);
|
||||
@as(*const IDebugDevice.VTable, @ptrCast(self.v))
|
||||
.SetMuteDebugOutput(@as(*IDebugDevice, @ptrCast(self)), mute);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -658,8 +658,8 @@ pub const IDevice = extern struct {
|
||||
feature_support_data_size: UINT,
|
||||
feature_support_data: *anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CheckFeatureSupport(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CheckFeatureSupport(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
feature,
|
||||
feature_query_data_size,
|
||||
feature_query_data,
|
||||
@@ -673,8 +673,8 @@ pub const IDevice = extern struct {
|
||||
guid: *const GUID,
|
||||
ppv: ?*?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CreateOperator(@ptrCast(*IDevice, self), desc, guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CreateOperator(@as(*IDevice, @ptrCast(self)), desc, guid, ppv);
|
||||
}
|
||||
pub inline fn CompileOperator(
|
||||
self: *T,
|
||||
@@ -683,8 +683,8 @@ pub const IDevice = extern struct {
|
||||
guid: *const GUID,
|
||||
ppv: ?*?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CompileOperator(@ptrCast(*IDevice, self), op, flags, guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CompileOperator(@as(*IDevice, @ptrCast(self)), op, flags, guid, ppv);
|
||||
}
|
||||
pub inline fn CreateOperatorInitializer(
|
||||
self: *T,
|
||||
@@ -693,12 +693,12 @@ pub const IDevice = extern struct {
|
||||
guid: *const GUID,
|
||||
ppv: *?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CreateOperatorInitializer(@ptrCast(*IDevice, self), num_ops, ops, guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CreateOperatorInitializer(@as(*IDevice, @ptrCast(self)), num_ops, ops, guid, ppv);
|
||||
}
|
||||
pub inline fn CreateCommandRecorder(self: *T, guid: *const GUID, ppv: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CreateCommandRecorder(@ptrCast(*IDevice, self), guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CreateCommandRecorder(@as(*IDevice, @ptrCast(self)), guid, ppv);
|
||||
}
|
||||
pub inline fn CreateBindingTable(
|
||||
self: *T,
|
||||
@@ -706,24 +706,24 @@ pub const IDevice = extern struct {
|
||||
guid: *const GUID,
|
||||
ppv: *?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.CreateBindingTable(@ptrCast(*IDevice, self), desc, guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.CreateBindingTable(@as(*IDevice, @ptrCast(self)), desc, guid, ppv);
|
||||
}
|
||||
pub inline fn Evict(self: *T, num: UINT, objs: [*]const *IPageable) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.Evict(@ptrCast(*IDevice, self), num, objs);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.Evict(@as(*IDevice, @ptrCast(self)), num, objs);
|
||||
}
|
||||
pub inline fn MakeResident(self: *T, num: UINT, objs: [*]const *IPageable) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.MakeResident(@ptrCast(*IDevice, self), num, objs);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.MakeResident(@as(*IDevice, @ptrCast(self)), num, objs);
|
||||
}
|
||||
pub inline fn GetDeviceRemovedReason(self: *T) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.GetDeviceRemovedReason(@ptrCast(*IDevice, self));
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.GetDeviceRemovedReason(@as(*IDevice, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetParentDevice(self: *T, guid: *const GUID, ppv: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.GetParentDevice(@ptrCast(*IDevice, self), guid, ppv);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.GetParentDevice(@as(*IDevice, @ptrCast(self)), guid, ppv);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -855,8 +855,8 @@ pub const IDevice1 = extern struct {
|
||||
guid: *const GUID,
|
||||
ppv: ?*?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice1.VTable, self.__v)
|
||||
.CompileGraph(@ptrCast(*IDevice1, self), desc, flags, guid, ppv);
|
||||
return @as(*const IDevice1.VTable, @ptrCast(self.__v))
|
||||
.CompileGraph(@as(*IDevice1, @ptrCast(self)), desc, flags, guid, ppv);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -953,9 +953,9 @@ pub fn createDevice(
|
||||
?*?*anyopaque,
|
||||
) callconv(WINAPI) HRESULT = undefined;
|
||||
|
||||
dmlCreateDevice1 = @ptrCast(
|
||||
dmlCreateDevice1 = @as(
|
||||
@TypeOf(dmlCreateDevice1),
|
||||
w32.GetProcAddress(directml_dll.?, "DMLCreateDevice1").?,
|
||||
@ptrCast(w32.GetProcAddress(directml_dll.?, "DMLCreateDevice1").?),
|
||||
);
|
||||
|
||||
return dmlCreateDevice1(d3d12_device, flags, min_feature_level, guid, ppv);
|
||||
|
||||
@@ -94,12 +94,12 @@ pub const ITextFormat = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn SetTextAlignment(self: *T, alignment: TEXT_ALIGNMENT) HRESULT {
|
||||
return @ptrCast(*const ITextFormat.VTable, self.__v)
|
||||
.SetTextAlignment(@ptrCast(*ITextFormat, self), alignment);
|
||||
return @as(*const ITextFormat.VTable, @ptrCast(self.__v))
|
||||
.SetTextAlignment(@as(*ITextFormat, @ptrCast(self)), alignment);
|
||||
}
|
||||
pub inline fn SetParagraphAlignment(self: *T, alignment: PARAGRAPH_ALIGNMENT) HRESULT {
|
||||
return @ptrCast(*const ITextFormat.VTable, self.__v)
|
||||
.SetParagraphAlignment(@ptrCast(*ITextFormat, self), alignment);
|
||||
return @as(*const ITextFormat.VTable, @ptrCast(self.__v))
|
||||
.SetParagraphAlignment(@as(*ITextFormat, @ptrCast(self)), alignment);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -154,8 +154,8 @@ pub const IFactory = extern struct {
|
||||
locale_name: LPCWSTR,
|
||||
text_format: *?*ITextFormat,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v).CreateTextFormat(
|
||||
@ptrCast(*IFactory, self),
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v)).CreateTextFormat(
|
||||
@as(*IFactory, @ptrCast(self)),
|
||||
font_family_name,
|
||||
font_collection,
|
||||
font_weight,
|
||||
@@ -218,7 +218,7 @@ pub extern "dwrite" fn DWriteCreateFactory(
|
||||
factory: *?*anyopaque,
|
||||
) callconv(WINAPI) HRESULT;
|
||||
|
||||
pub const E_FILEFORMAT = @bitCast(HRESULT, @as(c_ulong, 0x88985000));
|
||||
pub const E_FILEFORMAT = @as(HRESULT, @bitCast(@as(c_ulong, 0x88985000)));
|
||||
|
||||
pub const Error = error{
|
||||
E_FILEFORMAT,
|
||||
|
||||
+181
-182
@@ -276,8 +276,7 @@ pub const FORMAT = enum(UINT) {
|
||||
.BC7_UNORM_SRGB,
|
||||
=> 8,
|
||||
|
||||
.R1_UNORM,
|
||||
=> 1,
|
||||
.R1_UNORM => 1,
|
||||
|
||||
.BC1_TYPELESS,
|
||||
.BC1_UNORM,
|
||||
@@ -546,19 +545,19 @@ pub const IObject = extern struct {
|
||||
data_size: UINT,
|
||||
data: *const anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.SetPrivateData(@ptrCast(*IObject, self), guid, data_size, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.SetPrivateData(@as(*IObject, @ptrCast(self)), guid, data_size, data);
|
||||
}
|
||||
pub inline fn SetPrivateDataInterface(self: *T, guid: *const GUID, data: ?*const IUnknown) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.SetPrivateDataInterface(@ptrCast(*IObject, self), guid, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.SetPrivateDataInterface(@as(*IObject, @ptrCast(self)), guid, data);
|
||||
}
|
||||
pub inline fn GetPrivateData(self: *T, guid: *const GUID, data_size: *UINT, data: *anyopaque) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v)
|
||||
.GetPrivateData(@ptrCast(*IObject, self), guid, data_size, data);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v))
|
||||
.GetPrivateData(@as(*IObject, @ptrCast(self)), guid, data_size, data);
|
||||
}
|
||||
pub inline fn GetParent(self: *T, guid: *const GUID, parent: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IObject.VTable, self.__v).GetParent(@ptrCast(*IObject, self), guid, parent);
|
||||
return @as(*const IObject.VTable, @ptrCast(self.__v)).GetParent(@as(*IObject, @ptrCast(self)), guid, parent);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -583,8 +582,8 @@ pub const IDeviceSubObject = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn GetDevice(self: *T, guid: *const GUID, parent: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IDeviceSubObject.VTable, self.__v)
|
||||
.GetDevice(@ptrCast(*IDeviceSubObject, self), guid, parent);
|
||||
return @as(*const IDeviceSubObject.VTable, @ptrCast(self.__v))
|
||||
.GetDevice(@as(*IDeviceSubObject, @ptrCast(self)), guid, parent);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -605,19 +604,19 @@ pub const IResource = extern struct {
|
||||
pub usingnamespace IDeviceSubObject.Methods(T);
|
||||
|
||||
pub inline fn GetSharedHandle(self: *T, handle: *HANDLE) HRESULT {
|
||||
return @ptrCast(*const IResource.VTable, self.__v)
|
||||
.GetSharedHandle(@ptrCast(*IResource, self), handle);
|
||||
return @as(*const IResource.VTable, @ptrCast(self.__v))
|
||||
.GetSharedHandle(@as(*IResource, @ptrCast(self)), handle);
|
||||
}
|
||||
pub inline fn GetUsage(self: *T, usage: *USAGE) HRESULT {
|
||||
return @ptrCast(*const IResource.VTable, self.__v).GetUsage(@ptrCast(*IResource, self), usage);
|
||||
return @as(*const IResource.VTable, @ptrCast(self.__v)).GetUsage(@as(*IResource, @ptrCast(self)), usage);
|
||||
}
|
||||
pub inline fn SetEvictionPriority(self: *T, priority: UINT) HRESULT {
|
||||
return @ptrCast(*const IResource.VTable, self.__v)
|
||||
.SetEvictionPriority(@ptrCast(*IResource, self), priority);
|
||||
return @as(*const IResource.VTable, @ptrCast(self.__v))
|
||||
.SetEvictionPriority(@as(*IResource, @ptrCast(self)), priority);
|
||||
}
|
||||
pub inline fn GetEvictionPriority(self: *T, priority: *UINT) HRESULT {
|
||||
return @ptrCast(*const IResource.VTable, self.__v)
|
||||
.GetEvictionPriority(@ptrCast(*IResource, self), priority);
|
||||
return @as(*const IResource.VTable, @ptrCast(self.__v))
|
||||
.GetEvictionPriority(@as(*IResource, @ptrCast(self)), priority);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -642,11 +641,11 @@ pub const IKeyedMutex = extern struct {
|
||||
pub usingnamespace IDeviceSubObject.Methods(T);
|
||||
|
||||
pub inline fn AcquireSync(self: *T, key: UINT64, milliseconds: DWORD) HRESULT {
|
||||
return @ptrCast(*const IKeyedMutex.VTable, self.__v)
|
||||
.AcquireSync(@ptrCast(*IKeyedMutex, self), key, milliseconds);
|
||||
return @as(*const IKeyedMutex.VTable, @ptrCast(self.__v))
|
||||
.AcquireSync(@as(*IKeyedMutex, @ptrCast(self)), key, milliseconds);
|
||||
}
|
||||
pub inline fn ReleaseSync(self: *T, key: UINT64) HRESULT {
|
||||
return @ptrCast(*const IKeyedMutex.VTable, self.__v).ReleaseSync(@ptrCast(*IKeyedMutex, self), key);
|
||||
return @as(*const IKeyedMutex.VTable, @ptrCast(self.__v)).ReleaseSync(@as(*IKeyedMutex, @ptrCast(self)), key);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -675,13 +674,13 @@ pub const ISurface = extern struct {
|
||||
pub usingnamespace IDeviceSubObject.Methods(T);
|
||||
|
||||
pub inline fn GetDesc(self: *T, desc: *SURFACE_DESC) HRESULT {
|
||||
return @ptrCast(*const ISurface.VTable, self.__v).GetDesc(@ptrCast(*ISurface, self), desc);
|
||||
return @as(*const ISurface.VTable, @ptrCast(self.__v)).GetDesc(@as(*ISurface, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn Map(self: *T, locked_rect: *MAPPED_RECT, flags: MAP_FLAG) HRESULT {
|
||||
return @ptrCast(*const ISurface.VTable, self.__v).Map(@ptrCast(*ISurface, self), locked_rect, flags);
|
||||
return @as(*const ISurface.VTable, @ptrCast(self.__v)).Map(@as(*ISurface, @ptrCast(self)), locked_rect, flags);
|
||||
}
|
||||
pub inline fn Unmap(self: *T) HRESULT {
|
||||
return @ptrCast(*const ISurface.VTable, self.__v).Unmap(@ptrCast(*ISurface, self));
|
||||
return @as(*const ISurface.VTable, @ptrCast(self.__v)).Unmap(@as(*ISurface, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -704,15 +703,15 @@ pub const IAdapter = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn EnumOutputs(self: *T, index: UINT, output: *?*IOutput) HRESULT {
|
||||
return @ptrCast(*const IAdapter.VTable, self.__v)
|
||||
.EnumOutputs(@ptrCast(*IAdapter, self), index, output);
|
||||
return @as(*const IAdapter.VTable, @ptrCast(self.__v))
|
||||
.EnumOutputs(@as(*IAdapter, @ptrCast(self)), index, output);
|
||||
}
|
||||
pub inline fn GetDesc(self: *T, desc: *ADAPTER_DESC) HRESULT {
|
||||
return @ptrCast(*const IAdapter.VTable, self.__v).GetDesc(@ptrCast(*IAdapter, self), desc);
|
||||
return @as(*const IAdapter.VTable, @ptrCast(self.__v)).GetDesc(@as(*IAdapter, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn CheckInterfaceSupport(self: *T, guid: *const GUID, umd_ver: *LARGE_INTEGER) HRESULT {
|
||||
return @ptrCast(*const IAdapter.VTable, self.__v)
|
||||
.CheckInterfaceSupport(@ptrCast(*IAdapter, self), guid, umd_ver);
|
||||
return @as(*const IAdapter.VTable, @ptrCast(self.__v))
|
||||
.CheckInterfaceSupport(@as(*IAdapter, @ptrCast(self)), guid, umd_ver);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -743,7 +742,7 @@ pub const IOutput = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn GetDesc(self: *T, desc: *OUTPUT_DESC) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).GetDesc(@ptrCast(*IOutput, self), desc);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).GetDesc(@as(*IOutput, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn GetDisplayModeList(
|
||||
self: *T,
|
||||
@@ -752,8 +751,8 @@ pub const IOutput = extern struct {
|
||||
num_nodes: *UINT,
|
||||
desc: ?*MODE_DESC,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v)
|
||||
.GetDisplayModeList(@ptrCast(*IOutput, self), enum_format, flags, num_nodes, desc);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v))
|
||||
.GetDisplayModeList(@as(*IOutput, @ptrCast(self)), enum_format, flags, num_nodes, desc);
|
||||
}
|
||||
pub inline fn FindClosestMatchingMode(
|
||||
self: *T,
|
||||
@@ -761,43 +760,43 @@ pub const IOutput = extern struct {
|
||||
closest_match: *MODE_DESC,
|
||||
concerned_device: ?*IUnknown,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).FindClosestMatchingMode(
|
||||
@ptrCast(*IOutput, self),
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).FindClosestMatchingMode(
|
||||
@as(*IOutput, @ptrCast(self)),
|
||||
mode_to_match,
|
||||
closest_match,
|
||||
concerned_device,
|
||||
);
|
||||
}
|
||||
pub inline fn WaitForVBlank(self: *T) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).WaitForVBlank(@ptrCast(*IOutput, self));
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).WaitForVBlank(@as(*IOutput, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn TakeOwnership(self: *T, device: *IUnknown, exclusive: BOOL) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v)
|
||||
.TakeOwnership(@ptrCast(*IOutput, self), device, exclusive);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v))
|
||||
.TakeOwnership(@as(*IOutput, @ptrCast(self)), device, exclusive);
|
||||
}
|
||||
pub inline fn ReleaseOwnership(self: *T) void {
|
||||
@ptrCast(*const IOutput.VTable, self.__v).ReleaseOwnership(@ptrCast(*IOutput, self));
|
||||
@as(*const IOutput.VTable, @ptrCast(self.__v)).ReleaseOwnership(@as(*IOutput, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetGammaControlCapabilities(self: *T, gamma_caps: *GAMMA_CONTROL_CAPABILITIES) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v)
|
||||
.GetGammaControlCapabilities(@ptrCast(*IOutput, self), gamma_caps);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v))
|
||||
.GetGammaControlCapabilities(@as(*IOutput, @ptrCast(self)), gamma_caps);
|
||||
}
|
||||
pub inline fn SetGammaControl(self: *T, array: *const GAMMA_CONTROL) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).SetGammaControl(@ptrCast(*IOutput, self), array);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).SetGammaControl(@as(*IOutput, @ptrCast(self)), array);
|
||||
}
|
||||
pub inline fn GetGammaControl(self: *T, array: *GAMMA_CONTROL) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).GetGammaControl(@ptrCast(*IOutput, self), array);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).GetGammaControl(@as(*IOutput, @ptrCast(self)), array);
|
||||
}
|
||||
pub inline fn SetDisplaySurface(self: *T, scanout_surface: *ISurface) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v)
|
||||
.SetDisplaySurface(@ptrCast(*IOutput, self), scanout_surface);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v))
|
||||
.SetDisplaySurface(@as(*IOutput, @ptrCast(self)), scanout_surface);
|
||||
}
|
||||
pub inline fn GetDisplaySurfaceData(self: *T, destination: *ISurface) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v)
|
||||
.GetDisplaySurfaceData(@ptrCast(*IOutput, self), destination);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v))
|
||||
.GetDisplaySurfaceData(@as(*IOutput, @ptrCast(self)), destination);
|
||||
}
|
||||
pub inline fn GetFrameStatistics(self: *T, stats: *FRAME_STATISTICS) HRESULT {
|
||||
return @ptrCast(*const IOutput.VTable, self.__v).GetFrameStatistics(@ptrCast(*IOutput, self), stats);
|
||||
return @as(*const IOutput.VTable, @ptrCast(self.__v)).GetFrameStatistics(@as(*IOutput, @ptrCast(self)), stats);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -851,23 +850,23 @@ pub const ISwapChain = extern struct {
|
||||
pub usingnamespace IDeviceSubObject.Methods(T);
|
||||
|
||||
pub inline fn Present(self: *T, sync_interval: UINT, flags: PRESENT_FLAG) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.Present(@ptrCast(*ISwapChain, self), sync_interval, flags);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.Present(@as(*ISwapChain, @ptrCast(self)), sync_interval, flags);
|
||||
}
|
||||
pub inline fn GetBuffer(self: *T, index: u32, guid: *const GUID, surface: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.GetBuffer(@ptrCast(*ISwapChain, self), index, guid, surface);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.GetBuffer(@as(*ISwapChain, @ptrCast(self)), index, guid, surface);
|
||||
}
|
||||
pub inline fn SetFullscreenState(self: *T, target: ?*IOutput) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.SetFullscreenState(@ptrCast(*ISwapChain, self), target);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.SetFullscreenState(@as(*ISwapChain, @ptrCast(self)), target);
|
||||
}
|
||||
pub inline fn GetFullscreenState(self: *T, fullscreen: ?*BOOL, target: ?*?*IOutput) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.GetFullscreenState(@ptrCast(*ISwapChain, self), fullscreen, target);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.GetFullscreenState(@as(*ISwapChain, @ptrCast(self)), fullscreen, target);
|
||||
}
|
||||
pub inline fn GetDesc(self: *T, desc: *SWAP_CHAIN_DESC) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v).GetDesc(@ptrCast(*ISwapChain, self), desc);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v)).GetDesc(@as(*ISwapChain, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn ResizeBuffers(
|
||||
self: *T,
|
||||
@@ -877,24 +876,24 @@ pub const ISwapChain = extern struct {
|
||||
format: FORMAT,
|
||||
flags: SWAP_CHAIN_FLAG,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.ResizeBuffers(@ptrCast(*ISwapChain, self), count, width, height, format, flags);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.ResizeBuffers(@as(*ISwapChain, @ptrCast(self)), count, width, height, format, flags);
|
||||
}
|
||||
pub inline fn ResizeTarget(self: *T, params: *const MODE_DESC) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.ResizeTarget(@ptrCast(*ISwapChain, self), params);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.ResizeTarget(@as(*ISwapChain, @ptrCast(self)), params);
|
||||
}
|
||||
pub inline fn GetContainingOutput(self: *T, output: *?*IOutput) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.GetContainingOutput(@ptrCast(*ISwapChain, self), output);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.GetContainingOutput(@as(*ISwapChain, @ptrCast(self)), output);
|
||||
}
|
||||
pub inline fn GetFrameStatistics(self: *T, stats: *FRAME_STATISTICS) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.GetFrameStatistics(@ptrCast(*ISwapChain, self), stats);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.GetFrameStatistics(@as(*ISwapChain, @ptrCast(self)), stats);
|
||||
}
|
||||
pub inline fn GetLastPresentCount(self: *T, count: *UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain.VTable, self.__v)
|
||||
.GetLastPresentCount(@ptrCast(*ISwapChain, self), count);
|
||||
return @as(*const ISwapChain.VTable, @ptrCast(self.__v))
|
||||
.GetLastPresentCount(@as(*ISwapChain, @ptrCast(self)), count);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -932,16 +931,16 @@ pub const IFactory = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn EnumAdapters(self: *T, index: UINT, adapter: *?*IAdapter) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.EnumAdapters(@ptrCast(*IFactory, self), index, adapter);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.EnumAdapters(@as(*IFactory, @ptrCast(self)), index, adapter);
|
||||
}
|
||||
pub inline fn MakeWindowAssociation(self: *T, window: HWND, flags: MWA_FLAGS) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.MakeWindowAssociation(@ptrCast(*IFactory, self), window, flags);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.MakeWindowAssociation(@as(*IFactory, @ptrCast(self)), window, flags);
|
||||
}
|
||||
pub inline fn GetWindowAssociation(self: *T, window: *HWND) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.GetWindowAssociation(@ptrCast(*IFactory, self), window);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.GetWindowAssociation(@as(*IFactory, @ptrCast(self)), window);
|
||||
}
|
||||
pub inline fn CreateSwapChain(
|
||||
self: *T,
|
||||
@@ -949,12 +948,12 @@ pub const IFactory = extern struct {
|
||||
desc: *SWAP_CHAIN_DESC,
|
||||
swapchain: *?*ISwapChain,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateSwapChain(@ptrCast(*IFactory, self), device, desc, swapchain);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateSwapChain(@as(*IFactory, @ptrCast(self)), device, desc, swapchain);
|
||||
}
|
||||
pub inline fn CreateSoftwareAdapter(self: *T, adapter: *?*IAdapter) HRESULT {
|
||||
return @ptrCast(*const IFactory.VTable, self.__v)
|
||||
.CreateSoftwareAdapter(@ptrCast(*IFactory, self), adapter);
|
||||
return @as(*const IFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateSoftwareAdapter(@as(*IFactory, @ptrCast(self)), adapter);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -980,7 +979,7 @@ pub const IDevice = extern struct {
|
||||
pub usingnamespace IObject.Methods(T);
|
||||
|
||||
pub inline fn GetAdapter(self: *T, adapter: *?*IAdapter) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).GetAdapter(@ptrCast(*IDevice, self), adapter);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).GetAdapter(@as(*IDevice, @ptrCast(self)), adapter);
|
||||
}
|
||||
pub inline fn CreateSurface(
|
||||
self: *T,
|
||||
@@ -990,8 +989,8 @@ pub const IDevice = extern struct {
|
||||
shared_resource: ?*const SHARED_RESOURCE,
|
||||
surface: *?*ISurface,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v).CreateSurface(
|
||||
@ptrCast(*IDevice, self),
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v)).CreateSurface(
|
||||
@as(*IDevice, @ptrCast(self)),
|
||||
desc,
|
||||
num_surfaces,
|
||||
usage,
|
||||
@@ -1005,16 +1004,16 @@ pub const IDevice = extern struct {
|
||||
status: [*]RESIDENCY,
|
||||
num_resources: UINT,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.QueryResourceResidency(@ptrCast(*IDevice, self), resources, status, num_resources);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.QueryResourceResidency(@as(*IDevice, @ptrCast(self)), resources, status, num_resources);
|
||||
}
|
||||
pub inline fn SetGPUThreadPriority(self: *T, priority: INT) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.SetGPUThreadPriority(@ptrCast(*IDevice, self), priority);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.SetGPUThreadPriority(@as(*IDevice, @ptrCast(self)), priority);
|
||||
}
|
||||
pub inline fn GetGPUThreadPriority(self: *T, priority: *INT) HRESULT {
|
||||
return @ptrCast(*const IDevice.VTable, self.__v)
|
||||
.GetGPUThreadPriority(@ptrCast(*IDevice, self), priority);
|
||||
return @as(*const IDevice.VTable, @ptrCast(self.__v))
|
||||
.GetGPUThreadPriority(@as(*IDevice, @ptrCast(self)), priority);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1102,12 +1101,12 @@ pub const IFactory1 = extern struct {
|
||||
pub usingnamespace IFactory.Methods(T);
|
||||
|
||||
pub inline fn EnumAdapters1(self: *T, index: UINT, adapter: *?*IAdapter1) HRESULT {
|
||||
return @ptrCast(*const IFactory1.VTable, self.__v)
|
||||
.EnumAdapters1(@ptrCast(*IFactory1, self), index, adapter);
|
||||
return @as(*const IFactory1.VTable, @ptrCast(self.__v))
|
||||
.EnumAdapters1(@as(*IFactory1, @ptrCast(self)), index, adapter);
|
||||
}
|
||||
pub inline fn IsCurrent(self: *T) BOOL {
|
||||
return @ptrCast(*const IFactory1.VTable, self.__v)
|
||||
.IsCurrent(@ptrCast(*IFactory1, self));
|
||||
return @as(*const IFactory1.VTable, @ptrCast(self.__v))
|
||||
.IsCurrent(@as(*IFactory1, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1201,8 +1200,8 @@ pub const IFactory5 = extern struct {
|
||||
support_data: *anyopaque,
|
||||
support_data_size: UINT,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory5.VTable, self.__v).CheckFeatureSupport(
|
||||
@ptrCast(*IFactory5, self),
|
||||
return @as(*const IFactory5.VTable, @ptrCast(self.__v)).CheckFeatureSupport(
|
||||
@as(*IFactory5, @ptrCast(self)),
|
||||
feature,
|
||||
support_data,
|
||||
support_data_size,
|
||||
@@ -1240,8 +1239,8 @@ pub const IFactory6 = extern struct {
|
||||
riid: *const GUID,
|
||||
adapter: *?*IAdapter3,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFactory6.VTable, self.__v).EnumAdapterByGpuPreference(
|
||||
@ptrCast(*IFactory6, self),
|
||||
return @as(*const IFactory6.VTable, @ptrCast(self.__v)).EnumAdapterByGpuPreference(
|
||||
@as(*IFactory6, @ptrCast(self)),
|
||||
adapter_index,
|
||||
gpu_preference,
|
||||
riid,
|
||||
@@ -1274,8 +1273,8 @@ pub const IAdapter1 = extern struct {
|
||||
pub usingnamespace IAdapter.Methods(T);
|
||||
|
||||
pub inline fn GetDesc1(self: *T, desc: *ADAPTER_DESC1) HRESULT {
|
||||
return @ptrCast(*const IAdapter1.VTable, self.__v)
|
||||
.GetDesc1(@ptrCast(*IAdapter1, self), desc);
|
||||
return @as(*const IAdapter1.VTable, @ptrCast(self.__v))
|
||||
.GetDesc1(@as(*IAdapter1, @ptrCast(self)), desc);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1297,8 +1296,8 @@ pub const IAdapter2 = extern struct {
|
||||
pub usingnamespace IAdapter1.Methods(T);
|
||||
|
||||
pub inline fn GetDesc2(self: *T, desc: *ADAPTER_DESC2) HRESULT {
|
||||
return @ptrCast(*const IAdapter2.VTable, self.__v)
|
||||
.GetDesc2(@ptrCast(*IAdapter2, self), desc);
|
||||
return @as(*const IAdapter2.VTable, @ptrCast(self.__v))
|
||||
.GetDesc2(@as(*IAdapter2, @ptrCast(self)), desc);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1332,33 +1331,33 @@ pub const IAdapter3 = extern struct {
|
||||
pub usingnamespace IAdapter2.Methods(T);
|
||||
|
||||
pub inline fn RegisterHardwareContentProtectionTeardownStatusEvent(self: *T, event: HANDLE, cookie: *DWORD) HRESULT {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.RegisterHardwareContentProtectionTeardownStatusEvent(@ptrCast(*IAdapter3, self), event, cookie);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.RegisterHardwareContentProtectionTeardownStatusEvent(@as(*IAdapter3, @ptrCast(self)), event, cookie);
|
||||
}
|
||||
|
||||
pub inline fn UnregisterHardwareContentProtectionTeardownStatus(self: *T, cookie: DWORD) void {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.UnregisterHardwareContentProtectionTeardownStatus(@ptrCast(*IAdapter3, self), cookie);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.UnregisterHardwareContentProtectionTeardownStatus(@as(*IAdapter3, @ptrCast(self)), cookie);
|
||||
}
|
||||
|
||||
pub inline fn QueryVideoMemoryInfo(self: *T, node_index: UINT, memory_segment_group: MEMORY_SEGMENT_GROUP, video_memory_info: *QUERY_VIDEO_MEMORY_INFO) HRESULT {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.QueryVideoMemoryInfo(@ptrCast(*IAdapter3, self), node_index, memory_segment_group, video_memory_info);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.QueryVideoMemoryInfo(@as(*IAdapter3, @ptrCast(self)), node_index, memory_segment_group, video_memory_info);
|
||||
}
|
||||
|
||||
pub inline fn SetVideoMemoryReservation(self: *T, node_index: UINT, memory_segment_group: MEMORY_SEGMENT_GROUP, reservation: UINT64) HRESULT {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.SetVideoMemoryReservation(@ptrCast(*IAdapter3, self), node_index, memory_segment_group, reservation);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.SetVideoMemoryReservation(@as(*IAdapter3, @ptrCast(self)), node_index, memory_segment_group, reservation);
|
||||
}
|
||||
|
||||
pub inline fn RegisterVideoMemoryBudgetChangeNotificationEvent(self: *T, event: HANDLE, cookie: *DWORD) HRESULT {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.RegisterVideoMemoryBudgetChangeNotificationEvent(@ptrCast(*IAdapter3, self), event, cookie);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.RegisterVideoMemoryBudgetChangeNotificationEvent(@as(*IAdapter3, @ptrCast(self)), event, cookie);
|
||||
}
|
||||
|
||||
pub inline fn UnregisterVideoMemoryBudgetChangeNotification(self: *T, cookie: DWORD) void {
|
||||
return @ptrCast(*const IAdapter3.VTable, self.__v)
|
||||
.UnregisterVideoMemoryBudgetChangeNotification(@ptrCast(*IAdapter3, self), cookie);
|
||||
return @as(*const IAdapter3.VTable, @ptrCast(self.__v))
|
||||
.UnregisterVideoMemoryBudgetChangeNotification(@as(*IAdapter3, @ptrCast(self)), cookie);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1384,12 +1383,12 @@ pub const IDevice1 = extern struct {
|
||||
pub usingnamespace IDevice.Methods(T);
|
||||
|
||||
pub inline fn SetMaximumFrameLatency(self: *T, max_latency: UINT) HRESULT {
|
||||
return @ptrCast(*const IDevice1.VTable, self.__v)
|
||||
.SetMaximumFrameLatency(@ptrCast(*IDevice1, self), max_latency);
|
||||
return @as(*const IDevice1.VTable, @ptrCast(self.__v))
|
||||
.SetMaximumFrameLatency(@as(*IDevice1, @ptrCast(self)), max_latency);
|
||||
}
|
||||
pub inline fn GetMaximumFrameLatency(self: *T, max_latency: *UINT) HRESULT {
|
||||
return @ptrCast(*const IDevice1.VTable, self.__v)
|
||||
.GetMaximumFrameLatency(@ptrCast(*IDevice1, self), max_latency);
|
||||
return @as(*const IDevice1.VTable, @ptrCast(self.__v))
|
||||
.GetMaximumFrameLatency(@as(*IDevice1, @ptrCast(self)), max_latency);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1478,18 +1477,18 @@ pub const ISwapChain1 = extern struct {
|
||||
pub usingnamespace ISwapChain.Methods(T);
|
||||
|
||||
pub inline fn GetDesc1(self: *T, desc: *SWAP_CHAIN_DESC1) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v).GetDesc1(@ptrCast(*ISwapChain1, self), desc);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v)).GetDesc1(@as(*ISwapChain1, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn GetFullscreenDesc(self: *T, desc: *SWAP_CHAIN_FULLSCREEN_DESC) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.GetFullscreenDesc(@ptrCast(*ISwapChain1, self), desc);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.GetFullscreenDesc(@as(*ISwapChain1, @ptrCast(self)), desc);
|
||||
}
|
||||
pub inline fn GetHwnd(self: *T, hwnd: *HWND) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v).GetHwnd(@ptrCast(*ISwapChain1, self), hwnd);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v)).GetHwnd(@as(*ISwapChain1, @ptrCast(self)), hwnd);
|
||||
}
|
||||
pub inline fn GetCoreWindow(self: *T, guid: *const GUID, unknown: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.GetCoreWindow(@ptrCast(*ISwapChain1, self), guid, unknown);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.GetCoreWindow(@as(*ISwapChain1, @ptrCast(self)), guid, unknown);
|
||||
}
|
||||
pub inline fn Present1(
|
||||
self: *T,
|
||||
@@ -1497,32 +1496,32 @@ pub const ISwapChain1 = extern struct {
|
||||
flags: PRESENT_FLAG,
|
||||
params: *const PRESENT_PARAMETERS,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.Present1(@ptrCast(*ISwapChain1, self), sync_interval, flags, params);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.Present1(@as(*ISwapChain1, @ptrCast(self)), sync_interval, flags, params);
|
||||
}
|
||||
pub inline fn IsTemporaryMonoSupported(self: *T) BOOL {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.IsTemporaryMonoSupported(@ptrCast(*ISwapChain1, self));
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.IsTemporaryMonoSupported(@as(*ISwapChain1, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetRestrictToOutput(self: *T, output: *?*IOutput) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.GetRestrictToOutput(@ptrCast(*ISwapChain1, self), output);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.GetRestrictToOutput(@as(*ISwapChain1, @ptrCast(self)), output);
|
||||
}
|
||||
pub inline fn SetBackgroundColor(self: *T, color: *const RGBA) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.SetBackgroundColor(@ptrCast(*ISwapChain1, self), color);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.SetBackgroundColor(@as(*ISwapChain1, @ptrCast(self)), color);
|
||||
}
|
||||
pub inline fn GetBackgroundColor(self: *T, color: *RGBA) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.GetBackgroundColor(@ptrCast(*ISwapChain1, self), color);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.GetBackgroundColor(@as(*ISwapChain1, @ptrCast(self)), color);
|
||||
}
|
||||
pub inline fn SetRotation(self: *T, rotation: MODE_ROTATION) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.SetRotation(@ptrCast(*ISwapChain1, self), rotation);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.SetRotation(@as(*ISwapChain1, @ptrCast(self)), rotation);
|
||||
}
|
||||
pub inline fn GetRotation(self: *T, rotation: *MODE_ROTATION) HRESULT {
|
||||
return @ptrCast(*const ISwapChain1.VTable, self.__v)
|
||||
.GetRotation(@ptrCast(*ISwapChain1, self), rotation);
|
||||
return @as(*const ISwapChain1.VTable, @ptrCast(self.__v))
|
||||
.GetRotation(@as(*ISwapChain1, @ptrCast(self)), rotation);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1570,32 +1569,32 @@ pub const ISwapChain2 = extern struct {
|
||||
pub usingnamespace ISwapChain1.Methods(T);
|
||||
|
||||
pub inline fn SetSourceSize(self: *T, width: UINT, height: UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.SetSourceSize(@ptrCast(*ISwapChain2, self), width, height);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.SetSourceSize(@as(*ISwapChain2, @ptrCast(self)), width, height);
|
||||
}
|
||||
pub inline fn GetSourceSize(self: *T, width: *UINT, height: *UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.GetSourceSize(@ptrCast(*ISwapChain2, self), width, height);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.GetSourceSize(@as(*ISwapChain2, @ptrCast(self)), width, height);
|
||||
}
|
||||
pub inline fn SetMaximumFrameLatency(self: *T, max_latency: UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.SetMaximumFrameLatency(@ptrCast(*ISwapChain2, self), max_latency);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.SetMaximumFrameLatency(@as(*ISwapChain2, @ptrCast(self)), max_latency);
|
||||
}
|
||||
pub inline fn GetMaximumFrameLatency(self: *T, max_latency: *UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.GetMaximumFrameLatency(@ptrCast(*ISwapChain2, self), max_latency);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.GetMaximumFrameLatency(@as(*ISwapChain2, @ptrCast(self)), max_latency);
|
||||
}
|
||||
pub inline fn GetFrameLatencyWaitableObject(self: *T) HANDLE {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.GetFrameLatencyWaitableObject(@ptrCast(*ISwapChain2, self));
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.GetFrameLatencyWaitableObject(@as(*ISwapChain2, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn SetMatrixTransform(self: *T, matrix: *const MATRIX_3X2_F) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.SetMatrixTransform(@ptrCast(*ISwapChain2, self), matrix);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.SetMatrixTransform(@as(*ISwapChain2, @ptrCast(self)), matrix);
|
||||
}
|
||||
pub inline fn GetMatrixTransform(self: *T, matrix: *MATRIX_3X2_F) HRESULT {
|
||||
return @ptrCast(*const ISwapChain2.VTable, self.__v)
|
||||
.GetMatrixTransform(@ptrCast(*ISwapChain2, self), matrix);
|
||||
return @as(*const ISwapChain2.VTable, @ptrCast(self.__v))
|
||||
.GetMatrixTransform(@as(*ISwapChain2, @ptrCast(self)), matrix);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1630,16 +1629,16 @@ pub const ISwapChain3 = extern struct {
|
||||
pub usingnamespace ISwapChain2.Methods(T);
|
||||
|
||||
pub inline fn GetCurrentBackBufferIndex(self: *T) UINT {
|
||||
return @ptrCast(*const ISwapChain3.VTable, self.__v)
|
||||
.GetCurrentBackBufferIndex(@ptrCast(*ISwapChain3, self));
|
||||
return @as(*const ISwapChain3.VTable, @ptrCast(self.__v))
|
||||
.GetCurrentBackBufferIndex(@as(*ISwapChain3, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn CheckColorSpaceSupport(self: *T, space: COLOR_SPACE_TYPE, support: *UINT) HRESULT {
|
||||
return @ptrCast(*const ISwapChain3.VTable, self.__v)
|
||||
.CheckColorSpaceSupport(@ptrCast(*const ISwapChain3.VTable, self.__v), space, support);
|
||||
return @as(*const ISwapChain3.VTable, @ptrCast(self.__v))
|
||||
.CheckColorSpaceSupport(@as(*const ISwapChain3.VTable, @ptrCast(self.__v)), space, support);
|
||||
}
|
||||
pub inline fn SetColorSpace1(self: *T, space: COLOR_SPACE_TYPE) HRESULT {
|
||||
return @ptrCast(*const ISwapChain3.VTable, self.__v)
|
||||
.SetColorSpace1(@ptrCast(*const ISwapChain3.VTable, self.__v), space);
|
||||
return @as(*const ISwapChain3.VTable, @ptrCast(self.__v))
|
||||
.SetColorSpace1(@as(*const ISwapChain3.VTable, @ptrCast(self.__v)), space);
|
||||
}
|
||||
pub inline fn ResizeBuffers1(
|
||||
self: *T,
|
||||
@@ -1651,8 +1650,8 @@ pub const ISwapChain3 = extern struct {
|
||||
creation_node_mask: [*]const UINT,
|
||||
present_queue: [*]const *IUnknown,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISwapChain3.VTable, self.__v).ResizeBuffers1(
|
||||
@ptrCast(*const ISwapChain3.VTable, self.__v),
|
||||
return @as(*const ISwapChain3.VTable, @ptrCast(self.__v)).ResizeBuffers1(
|
||||
@as(*const ISwapChain3.VTable, @ptrCast(self.__v)),
|
||||
buffer_count,
|
||||
width,
|
||||
height,
|
||||
@@ -1692,35 +1691,35 @@ pub const IID_ISwapChain3 = GUID{
|
||||
};
|
||||
|
||||
// Status return codes as defined here: https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-status
|
||||
pub const STATUS_OCCLUDED = @bitCast(HRESULT, @as(c_ulong, 0x087A0001));
|
||||
pub const STATUS_MODE_CHANGED = @bitCast(HRESULT, @as(c_ulong, 0x087A0007));
|
||||
pub const STATUS_MODE_CHANGE_IN_PROGRESS = @bitCast(HRESULT, @as(c_ulong, 0x087A0008));
|
||||
pub const STATUS_OCCLUDED = @as(HRESULT, @bitCast(@as(c_ulong, 0x087A0001)));
|
||||
pub const STATUS_MODE_CHANGED = @as(HRESULT, @bitCast(@as(c_ulong, 0x087A0007)));
|
||||
pub const STATUS_MODE_CHANGE_IN_PROGRESS = @as(HRESULT, @bitCast(@as(c_ulong, 0x087A0008)));
|
||||
|
||||
// Return codes as defined here: https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-error
|
||||
pub const ERROR_ACCESS_DENIED = @bitCast(HRESULT, @as(c_ulong, 0x887A002B));
|
||||
pub const ERROR_ACCESS_LOST = @bitCast(HRESULT, @as(c_ulong, 0x887A0026));
|
||||
pub const ERROR_ALREADY_EXISTS = @bitCast(HRESULT, @as(c_ulong, 0x887A0036));
|
||||
pub const ERROR_CANNOT_PROTECT_CONTENT = @bitCast(HRESULT, @as(c_ulong, 0x887A002A));
|
||||
pub const ERROR_DEVICE_HUNG = @bitCast(HRESULT, @as(c_ulong, 0x887A0006));
|
||||
pub const ERROR_DEVICE_REMOVED = @bitCast(HRESULT, @as(c_ulong, 0x887A0005));
|
||||
pub const ERROR_DEVICE_RESET = @bitCast(HRESULT, @as(c_ulong, 0x887A0007));
|
||||
pub const ERROR_DRIVER_INTERNAL_ERROR = @bitCast(HRESULT, @as(c_ulong, 0x887A0020));
|
||||
pub const ERROR_FRAME_STATISTICS_DISJOINT = @bitCast(HRESULT, @as(c_ulong, 0x887A000B));
|
||||
pub const ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE = @bitCast(HRESULT, @as(c_ulong, 0x887A000C));
|
||||
pub const ERROR_INVALID_CALL = @bitCast(HRESULT, @as(c_ulong, 0x887A0001));
|
||||
pub const ERROR_MORE_DATA = @bitCast(HRESULT, @as(c_ulong, 0x887A0003));
|
||||
pub const ERROR_NAME_ALREADY_EXISTS = @bitCast(HRESULT, @as(c_ulong, 0x887A002C));
|
||||
pub const ERROR_NONEXCLUSIVE = @bitCast(HRESULT, @as(c_ulong, 0x887A0021));
|
||||
pub const ERROR_NOT_CURRENTLY_AVAILABLE = @bitCast(HRESULT, @as(c_ulong, 0x887A0022));
|
||||
pub const ERROR_NOT_FOUND = @bitCast(HRESULT, @as(c_ulong, 0x887A0002));
|
||||
pub const ERROR_REMOTE_CLIENT_DISCONNECTED = @bitCast(HRESULT, @as(c_ulong, 0x887A0023));
|
||||
pub const ERROR_REMOTE_OUTOFMEMORY = @bitCast(HRESULT, @as(c_ulong, 0x887A0024));
|
||||
pub const ERROR_RESTRICT_TO_OUTPUT_STALE = @bitCast(HRESULT, @as(c_ulong, 0x887A0029));
|
||||
pub const ERROR_SDK_COMPONENT_MISSING = @bitCast(HRESULT, @as(c_ulong, 0x887A002D));
|
||||
pub const ERROR_SESSION_DISCONNECTED = @bitCast(HRESULT, @as(c_ulong, 0x887A0028));
|
||||
pub const ERROR_UNSUPPORTED = @bitCast(HRESULT, @as(c_ulong, 0x887A0004));
|
||||
pub const ERROR_WAIT_TIMEOUT = @bitCast(HRESULT, @as(c_ulong, 0x887A0027));
|
||||
pub const ERROR_WAS_STILL_DRAWING = @bitCast(HRESULT, @as(c_ulong, 0x887A000A));
|
||||
pub const ERROR_ACCESS_DENIED = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A002B)));
|
||||
pub const ERROR_ACCESS_LOST = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0026)));
|
||||
pub const ERROR_ALREADY_EXISTS = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0036)));
|
||||
pub const ERROR_CANNOT_PROTECT_CONTENT = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A002A)));
|
||||
pub const ERROR_DEVICE_HUNG = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0006)));
|
||||
pub const ERROR_DEVICE_REMOVED = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0005)));
|
||||
pub const ERROR_DEVICE_RESET = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0007)));
|
||||
pub const ERROR_DRIVER_INTERNAL_ERROR = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0020)));
|
||||
pub const ERROR_FRAME_STATISTICS_DISJOINT = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A000B)));
|
||||
pub const ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A000C)));
|
||||
pub const ERROR_INVALID_CALL = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0001)));
|
||||
pub const ERROR_MORE_DATA = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0003)));
|
||||
pub const ERROR_NAME_ALREADY_EXISTS = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A002C)));
|
||||
pub const ERROR_NONEXCLUSIVE = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0021)));
|
||||
pub const ERROR_NOT_CURRENTLY_AVAILABLE = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0022)));
|
||||
pub const ERROR_NOT_FOUND = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0002)));
|
||||
pub const ERROR_REMOTE_CLIENT_DISCONNECTED = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0023)));
|
||||
pub const ERROR_REMOTE_OUTOFMEMORY = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0024)));
|
||||
pub const ERROR_RESTRICT_TO_OUTPUT_STALE = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0029)));
|
||||
pub const ERROR_SDK_COMPONENT_MISSING = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A002D)));
|
||||
pub const ERROR_SESSION_DISCONNECTED = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0028)));
|
||||
pub const ERROR_UNSUPPORTED = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0004)));
|
||||
pub const ERROR_WAIT_TIMEOUT = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A0027)));
|
||||
pub const ERROR_WAS_STILL_DRAWING = @as(HRESULT, @bitCast(@as(c_ulong, 0x887A000A)));
|
||||
|
||||
// Error set corresponding to the above error return codes
|
||||
pub const Error = error{
|
||||
|
||||
+43
-43
@@ -63,27 +63,27 @@ pub const IAttributes = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetUINT32(self: *T, guid: *const GUID, value: *UINT32) HRESULT {
|
||||
return @ptrCast(*const IAttributes.VTable, self.__v).GetUINT32(
|
||||
@ptrCast(*IAttributes, self),
|
||||
return @as(*const IAttributes.VTable, @ptrCast(self.__v)).GetUINT32(
|
||||
@as(*IAttributes, @ptrCast(self)),
|
||||
guid,
|
||||
value,
|
||||
);
|
||||
}
|
||||
pub inline fn GetGUID(self: *T, key: *const GUID, value: *GUID) HRESULT {
|
||||
return @ptrCast(*const IAttributes.VTable, self.__v)
|
||||
.GetGUID(@ptrCast(*IAttributes, self), key, value);
|
||||
return @as(*const IAttributes.VTable, @ptrCast(self.__v))
|
||||
.GetGUID(@as(*IAttributes, @ptrCast(self)), key, value);
|
||||
}
|
||||
pub inline fn SetUINT32(self: *T, guid: *const GUID, value: UINT32) HRESULT {
|
||||
return @ptrCast(*const IAttributes.VTable, self.__v)
|
||||
.SetUINT32(@ptrCast(*IAttributes, self), guid, value);
|
||||
return @as(*const IAttributes.VTable, @ptrCast(self.__v))
|
||||
.SetUINT32(@as(*IAttributes, @ptrCast(self)), guid, value);
|
||||
}
|
||||
pub inline fn SetGUID(self: *T, key: *const GUID, value: *const GUID) HRESULT {
|
||||
return @ptrCast(*const IAttributes.VTable, self.__v)
|
||||
.SetGUID(@ptrCast(*IAttributes, self), key, value);
|
||||
return @as(*const IAttributes.VTable, @ptrCast(self.__v))
|
||||
.SetGUID(@as(*IAttributes, @ptrCast(self)), key, value);
|
||||
}
|
||||
pub inline fn SetUnknown(self: *T, guid: *const GUID, unknown: ?*IUnknown) HRESULT {
|
||||
return @ptrCast(*const IAttributes.VTable, self.__v)
|
||||
.SetUnknown(@ptrCast(*IAttributes, self), guid, unknown);
|
||||
return @as(*const IAttributes.VTable, @ptrCast(self.__v))
|
||||
.SetUnknown(@as(*IAttributes, @ptrCast(self)), guid, unknown);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -133,20 +133,20 @@ pub const IMediaEvent = extern struct {
|
||||
pub usingnamespace IAttributes.Methods(T);
|
||||
|
||||
pub inline fn GetType(self: *T, met: *MediaEventType) HRESULT {
|
||||
return @ptrCast(*const IMediaEvent.VTable, self.__v)
|
||||
.GetType(@ptrCast(*IMediaEvent, self), met);
|
||||
return @as(*const IMediaEvent.VTable, @ptrCast(self.__v))
|
||||
.GetType(@as(*IMediaEvent, @ptrCast(self)), met);
|
||||
}
|
||||
pub inline fn GetExtendedType(self: *T, ex_met: *GUID) HRESULT {
|
||||
return @ptrCast(*const IMediaEvent.VTable, self.__v)
|
||||
.GetExtendedType(@ptrCast(*IMediaEvent, self), ex_met);
|
||||
return @as(*const IMediaEvent.VTable, @ptrCast(self.__v))
|
||||
.GetExtendedType(@as(*IMediaEvent, @ptrCast(self)), ex_met);
|
||||
}
|
||||
pub inline fn GetStatus(self: *T, status: *HRESULT) HRESULT {
|
||||
return @ptrCast(*const IMediaEvent.VTable, self.__v)
|
||||
.GetStatus(@ptrCast(*IMediaEvent, self), status);
|
||||
return @as(*const IMediaEvent.VTable, @ptrCast(self.__v))
|
||||
.GetStatus(@as(*IMediaEvent, @ptrCast(self)), status);
|
||||
}
|
||||
pub inline fn GetValue(self: *T, value: *PROPVARIANT) HRESULT {
|
||||
return @ptrCast(*const IMediaEvent.VTable, self.__v)
|
||||
.GetValue(@ptrCast(*IMediaEvent, self), value);
|
||||
return @as(*const IMediaEvent.VTable, @ptrCast(self.__v))
|
||||
.GetValue(@as(*IMediaEvent, @ptrCast(self)), value);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -175,8 +175,8 @@ pub const ISourceReader = extern struct {
|
||||
media_type_index: DWORD,
|
||||
media_type: **IMediaType,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceReader.VTable, self.__v).GetNativeMediaType(
|
||||
@ptrCast(*ISourceReader, self),
|
||||
return @as(*const ISourceReader.VTable, @ptrCast(self.__v)).GetNativeMediaType(
|
||||
@as(*ISourceReader, @ptrCast(self)),
|
||||
stream_index,
|
||||
media_type_index,
|
||||
media_type,
|
||||
@@ -187,8 +187,8 @@ pub const ISourceReader = extern struct {
|
||||
stream_index: DWORD,
|
||||
media_type: **IMediaType,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceReader.VTable, self.__v)
|
||||
.GetCurrentMediaType(@ptrCast(*ISourceReader, self), stream_index, media_type);
|
||||
return @as(*const ISourceReader.VTable, @ptrCast(self.__v))
|
||||
.GetCurrentMediaType(@as(*ISourceReader, @ptrCast(self)), stream_index, media_type);
|
||||
}
|
||||
pub inline fn SetCurrentMediaType(
|
||||
self: *T,
|
||||
@@ -196,8 +196,8 @@ pub const ISourceReader = extern struct {
|
||||
reserved: ?*DWORD,
|
||||
media_type: *IMediaType,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceReader.VTable, self.__v)
|
||||
.SetCurrentMediaType(@ptrCast(*ISourceReader, self), stream_index, reserved, media_type);
|
||||
return @as(*const ISourceReader.VTable, @ptrCast(self.__v))
|
||||
.SetCurrentMediaType(@as(*ISourceReader, @ptrCast(self)), stream_index, reserved, media_type);
|
||||
}
|
||||
pub inline fn ReadSample(
|
||||
self: *T,
|
||||
@@ -208,8 +208,8 @@ pub const ISourceReader = extern struct {
|
||||
timestamp: ?*LONGLONG,
|
||||
sample: ?*?*ISample,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceReader.VTable, self.__v).ReadSample(
|
||||
@ptrCast(*ISourceReader, self),
|
||||
return @as(*const ISourceReader.VTable, @ptrCast(self.__v)).ReadSample(
|
||||
@as(*ISourceReader, @ptrCast(self)),
|
||||
stream_index,
|
||||
control_flags,
|
||||
actual_stream_index,
|
||||
@@ -219,8 +219,8 @@ pub const ISourceReader = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn SetCurrentPosition(self: *T, guid: *const GUID, prop: *const PROPVARIANT) HRESULT {
|
||||
return @ptrCast(*const ISourceReader.VTable, self.__v)
|
||||
.SetCurrentPosition(@ptrCast(*ISourceReader, self), guid, prop);
|
||||
return @as(*const ISourceReader.VTable, @ptrCast(self.__v))
|
||||
.SetCurrentPosition(@as(*ISourceReader, @ptrCast(self)), guid, prop);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -279,12 +279,12 @@ pub const ISample = extern struct {
|
||||
pub usingnamespace IAttributes.Methods(T);
|
||||
|
||||
pub inline fn ConvertToContiguousBuffer(self: *T, buffer: **IMediaBuffer) HRESULT {
|
||||
return @ptrCast(*const ISample.VTable, self.__v)
|
||||
.ConvertToContiguousBuffer(@ptrCast(*ISample, self), buffer);
|
||||
return @as(*const ISample.VTable, @ptrCast(self.__v))
|
||||
.ConvertToContiguousBuffer(@as(*ISample, @ptrCast(self)), buffer);
|
||||
}
|
||||
pub inline fn GetBufferByIndex(self: *T, index: DWORD, buffer: **IMediaBuffer) HRESULT {
|
||||
return @ptrCast(*const ISample.VTable, self.__v)
|
||||
.GetBufferByIndex(@ptrCast(*ISample, self), index, buffer);
|
||||
return @as(*const ISample.VTable, @ptrCast(self.__v))
|
||||
.GetBufferByIndex(@as(*ISample, @ptrCast(self)), index, buffer);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -318,15 +318,15 @@ pub const IMediaBuffer = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn Lock(self: *T, ptr: *[*]BYTE, max_len: ?*DWORD, current_len: ?*DWORD) HRESULT {
|
||||
return @ptrCast(*const IMediaBuffer.VTable, self.__v)
|
||||
.Lock(@ptrCast(*IMediaBuffer, self), ptr, max_len, current_len);
|
||||
return @as(*const IMediaBuffer.VTable, @ptrCast(self.__v))
|
||||
.Lock(@as(*IMediaBuffer, @ptrCast(self)), ptr, max_len, current_len);
|
||||
}
|
||||
pub inline fn Unlock(self: *T) HRESULT {
|
||||
return @ptrCast(*const IMediaBuffer.VTable, self.__v).Unlock(@ptrCast(*IMediaBuffer, self));
|
||||
return @as(*const IMediaBuffer.VTable, @ptrCast(self.__v)).Unlock(@as(*IMediaBuffer, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn GetCurrentLength(self: *T, length: *DWORD) HRESULT {
|
||||
return @ptrCast(*const IMediaBuffer.VTable, self.__v)
|
||||
.GetCurrentLength(@ptrCast(*IMediaBuffer, self), length);
|
||||
return @as(*const IMediaBuffer.VTable, @ptrCast(self.__v))
|
||||
.GetCurrentLength(@as(*IMediaBuffer, @ptrCast(self)), length);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -361,8 +361,8 @@ pub const ISourceReaderCallback = extern struct {
|
||||
timestamp: LONGLONG,
|
||||
sample: ?*ISample,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceReaderCallback.VTable, self.__v).OnReadSample(
|
||||
@ptrCast(*ISourceReaderCallback, self),
|
||||
return @as(*const ISourceReaderCallback.VTable, @ptrCast(self.__v)).OnReadSample(
|
||||
@as(*ISourceReaderCallback, @ptrCast(self)),
|
||||
status,
|
||||
stream_index,
|
||||
stream_flags,
|
||||
@@ -371,12 +371,12 @@ pub const ISourceReaderCallback = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn OnFlush(self: *T, stream_index: DWORD) HRESULT {
|
||||
return @ptrCast(*const ISourceReaderCallback.VTable, self.__v)
|
||||
.OnFlush(@ptrCast(*ISourceReaderCallback, self), stream_index);
|
||||
return @as(*const ISourceReaderCallback.VTable, @ptrCast(self.__v))
|
||||
.OnFlush(@as(*ISourceReaderCallback, @ptrCast(self)), stream_index);
|
||||
}
|
||||
pub inline fn OnEvent(self: *T, stream_index: DWORD, event: *IMediaEvent) HRESULT {
|
||||
return @ptrCast(*const ISourceReaderCallback.VTable, self.__v)
|
||||
.OnEvent(@ptrCast(*ISourceReaderCallback, self), stream_index, event);
|
||||
return @as(*const ISourceReaderCallback.VTable, @ptrCast(self.__v))
|
||||
.OnEvent(@as(*ISourceReaderCallback, @ptrCast(self)), stream_index, event);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+22
-22
@@ -77,18 +77,18 @@ pub const FALSE = 0;
|
||||
pub const MAX_PATH = 260;
|
||||
|
||||
pub const S_OK = 0;
|
||||
pub const S_FALSE = @bitCast(HRESULT, @as(c_ulong, 0x00000001));
|
||||
pub const E_NOTIMPL = @bitCast(c_long, @as(c_ulong, 0x80004001));
|
||||
pub const E_NOINTERFACE = @bitCast(c_long, @as(c_ulong, 0x80004002));
|
||||
pub const E_POINTER = @bitCast(c_long, @as(c_ulong, 0x80004003));
|
||||
pub const E_ABORT = @bitCast(c_long, @as(c_ulong, 0x80004004));
|
||||
pub const E_FAIL = @bitCast(c_long, @as(c_ulong, 0x80004005));
|
||||
pub const E_UNEXPECTED = @bitCast(c_long, @as(c_ulong, 0x8000FFFF));
|
||||
pub const E_ACCESSDENIED = @bitCast(c_long, @as(c_ulong, 0x80070005));
|
||||
pub const E_HANDLE = @bitCast(c_long, @as(c_ulong, 0x80070006));
|
||||
pub const E_OUTOFMEMORY = @bitCast(c_long, @as(c_ulong, 0x8007000E));
|
||||
pub const E_INVALIDARG = @bitCast(c_long, @as(c_ulong, 0x80070057));
|
||||
pub const E_FILE_NOT_FOUND = @bitCast(HRESULT, @as(c_ulong, 0x80070002));
|
||||
pub const S_FALSE = @as(HRESULT, @bitCast(@as(c_ulong, 0x00000001)));
|
||||
pub const E_NOTIMPL = @as(c_long, @bitCast(@as(c_ulong, 0x80004001)));
|
||||
pub const E_NOINTERFACE = @as(c_long, @bitCast(@as(c_ulong, 0x80004002)));
|
||||
pub const E_POINTER = @as(c_long, @bitCast(@as(c_ulong, 0x80004003)));
|
||||
pub const E_ABORT = @as(c_long, @bitCast(@as(c_ulong, 0x80004004)));
|
||||
pub const E_FAIL = @as(c_long, @bitCast(@as(c_ulong, 0x80004005)));
|
||||
pub const E_UNEXPECTED = @as(c_long, @bitCast(@as(c_ulong, 0x8000FFFF)));
|
||||
pub const E_ACCESSDENIED = @as(c_long, @bitCast(@as(c_ulong, 0x80070005)));
|
||||
pub const E_HANDLE = @as(c_long, @bitCast(@as(c_ulong, 0x80070006)));
|
||||
pub const E_OUTOFMEMORY = @as(c_long, @bitCast(@as(c_ulong, 0x8007000E)));
|
||||
pub const E_INVALIDARG = @as(c_long, @bitCast(@as(c_ulong, 0x80070057)));
|
||||
pub const E_FILE_NOT_FOUND = @as(HRESULT, @bitCast(@as(c_ulong, 0x80070002)));
|
||||
|
||||
pub const Error = error{
|
||||
UNEXPECTED,
|
||||
@@ -123,7 +123,7 @@ pub const GENERIC_WRITE = 0x40000000;
|
||||
pub const GENERIC_EXECUTE = 0x20000000;
|
||||
pub const GENERIC_ALL = 0x10000000;
|
||||
|
||||
pub const CW_USEDEFAULT = @bitCast(i32, @as(u32, 0x80000000));
|
||||
pub const CW_USEDEFAULT = @as(i32, @bitCast(@as(u32, 0x80000000)));
|
||||
|
||||
pub const RECT = extern struct {
|
||||
left: LONG,
|
||||
@@ -421,23 +421,23 @@ comptime {
|
||||
pub const WHEEL_DELTA = 120;
|
||||
|
||||
pub inline fn GET_WHEEL_DELTA_WPARAM(wparam: WPARAM) i16 {
|
||||
return @bitCast(i16, @intCast(u16, (wparam >> 16) & 0xffff));
|
||||
return @as(i16, @bitCast(@as(u16, @intCast((wparam >> 16) & 0xffff))));
|
||||
}
|
||||
|
||||
pub inline fn GET_X_LPARAM(lparam: LPARAM) i32 {
|
||||
return @intCast(i32, @bitCast(i16, @intCast(u16, lparam & 0xffff)));
|
||||
return @as(i32, @intCast(@as(i16, @bitCast(@as(u16, @intCast(lparam & 0xffff))))));
|
||||
}
|
||||
|
||||
pub inline fn GET_Y_LPARAM(lparam: LPARAM) i32 {
|
||||
return @intCast(i32, @bitCast(i16, @intCast(u16, (lparam >> 16) & 0xffff)));
|
||||
return @as(i32, @intCast(@as(i16, @bitCast(@as(u16, @intCast((lparam >> 16) & 0xffff))))));
|
||||
}
|
||||
|
||||
pub inline fn LOWORD(dword: DWORD) WORD {
|
||||
return @bitCast(WORD, @intCast(u16, dword & 0xffff));
|
||||
return @as(WORD, @bitCast(@as(u16, @intCast(dword & 0xffff))));
|
||||
}
|
||||
|
||||
pub inline fn HIWORD(dword: DWORD) WORD {
|
||||
return @bitCast(WORD, @intCast(u16, (dword >> 16) & 0xffff));
|
||||
return @as(WORD, @bitCast(@as(u16, @intCast((dword >> 16) & 0xffff))));
|
||||
}
|
||||
|
||||
pub const IID_IUnknown = GUID.parse("{00000000-0000-0000-C000-000000000046}");
|
||||
@@ -449,14 +449,14 @@ pub const IUnknown = extern struct {
|
||||
pub fn Methods(comptime T: type) type {
|
||||
return extern struct {
|
||||
pub inline fn QueryInterface(self: *T, guid: *const GUID, outobj: ?*?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IUnknown.VTable, self.__v)
|
||||
.QueryInterface(@ptrCast(*IUnknown, self), guid, outobj);
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.__v))
|
||||
.QueryInterface(@as(*IUnknown, @ptrCast(self)), guid, outobj);
|
||||
}
|
||||
pub inline fn AddRef(self: *T) ULONG {
|
||||
return @ptrCast(*const IUnknown.VTable, self.__v).AddRef(@ptrCast(*IUnknown, self));
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.__v)).AddRef(@as(*IUnknown, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Release(self: *T) ULONG {
|
||||
return @ptrCast(*const IUnknown.VTable, self.__v).Release(@ptrCast(*IUnknown, self));
|
||||
return @as(*const IUnknown.VTable, @ptrCast(self.__v)).Release(@as(*IUnknown, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+29
-29
@@ -43,8 +43,8 @@ pub const IMMDevice = extern struct {
|
||||
params: ?*PROPVARIANT,
|
||||
iface: *?*anyopaque,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IMMDevice.VTable, self.__v)
|
||||
.Activate(@ptrCast(*IMMDevice, self), guid, clsctx, params, iface);
|
||||
return @as(*const IMMDevice.VTable, @ptrCast(self.__v))
|
||||
.Activate(@as(*IMMDevice, @ptrCast(self)), guid, clsctx, params, iface);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -79,8 +79,8 @@ pub const IMMDeviceEnumerator = extern struct {
|
||||
role: ERole,
|
||||
endpoint: *?*IMMDevice,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IMMDeviceEnumerator.VTable, self.__v)
|
||||
.GetDefaultAudioEndpoint(@ptrCast(*IMMDeviceEnumerator, self), flow, role, endpoint);
|
||||
return @as(*const IMMDeviceEnumerator.VTable, @ptrCast(self.__v))
|
||||
.GetDefaultAudioEndpoint(@as(*IMMDeviceEnumerator, @ptrCast(self)), flow, role, endpoint);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -164,8 +164,8 @@ pub const IAudioClient = extern struct {
|
||||
format: *const WAVEFORMATEX,
|
||||
audio_session: ?*?*GUID,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v).Initialize(
|
||||
@ptrCast(*IAudioClient, self),
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v)).Initialize(
|
||||
@as(*IAudioClient, @ptrCast(self)),
|
||||
mode,
|
||||
stream_flags,
|
||||
buffer_duration,
|
||||
@@ -175,16 +175,16 @@ pub const IAudioClient = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn GetBufferSize(self: *T, size: *UINT32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetBufferSize(@ptrCast(*IAudioClient, self), size);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetBufferSize(@as(*IAudioClient, @ptrCast(self)), size);
|
||||
}
|
||||
pub inline fn GetStreamLatency(self: *T, latency: *REFERENCE_TIME) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetStreamLatency(@ptrCast(*IAudioClient, self), latency);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetStreamLatency(@as(*IAudioClient, @ptrCast(self)), latency);
|
||||
}
|
||||
pub inline fn GetCurrentPadding(self: *T, padding: *UINT32) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetCurrentPadding(@ptrCast(*IAudioClient, self), padding);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetCurrentPadding(@as(*IAudioClient, @ptrCast(self)), padding);
|
||||
}
|
||||
pub inline fn IsFormatSupported(
|
||||
self: *T,
|
||||
@@ -192,33 +192,33 @@ pub const IAudioClient = extern struct {
|
||||
format: *const WAVEFORMATEX,
|
||||
closest_format: ?*?*WAVEFORMATEX,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.IsFormatSupported(@ptrCast(*IAudioClient, self), mode, format, closest_format);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.IsFormatSupported(@as(*IAudioClient, @ptrCast(self)), mode, format, closest_format);
|
||||
}
|
||||
pub inline fn GetMixFormat(self: *T, format: **WAVEFORMATEX) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetMixFormat(@ptrCast(*IAudioClient, self), format);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetMixFormat(@as(*IAudioClient, @ptrCast(self)), format);
|
||||
}
|
||||
pub inline fn GetDevicePeriod(self: *T, default: ?*REFERENCE_TIME, minimum: ?*REFERENCE_TIME) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetDevicePeriod(@ptrCast(*IAudioClient, self), default, minimum);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetDevicePeriod(@as(*IAudioClient, @ptrCast(self)), default, minimum);
|
||||
}
|
||||
pub inline fn Start(self: *T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v).Start(@ptrCast(*IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v)).Start(@as(*IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Stop(self: *T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v).Stop(@ptrCast(*IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v)).Stop(@as(*IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Reset(self: *T) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v).Reset(@ptrCast(*IAudioClient, self));
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v)).Reset(@as(*IAudioClient, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn SetEventHandle(self: *T, handle: HANDLE) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.SetEventHandle(@ptrCast(*IAudioClient, self), handle);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.SetEventHandle(@as(*IAudioClient, @ptrCast(self)), handle);
|
||||
}
|
||||
pub inline fn GetService(self: *T, guid: *const GUID, iface: *?*anyopaque) HRESULT {
|
||||
return @ptrCast(*const IAudioClient.VTable, self.__v)
|
||||
.GetService(@ptrCast(*IAudioClient, self), guid, iface);
|
||||
return @as(*const IAudioClient.VTable, @ptrCast(self.__v))
|
||||
.GetService(@as(*IAudioClient, @ptrCast(self)), guid, iface);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -302,12 +302,12 @@ pub const IAudioRenderClient = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetBuffer(self: *T, num_frames_requested: UINT32, data: ?*?[*]BYTE) HRESULT {
|
||||
return @ptrCast(*const IAudioRenderClient.VTable, self.__v)
|
||||
.GetBuffer(@ptrCast(*IAudioRenderClient, self), num_frames_requested, data);
|
||||
return @as(*const IAudioRenderClient.VTable, @ptrCast(self.__v))
|
||||
.GetBuffer(@as(*IAudioRenderClient, @ptrCast(self)), num_frames_requested, data);
|
||||
}
|
||||
pub inline fn ReleaseBuffer(self: *T, num_frames_written: UINT32, flags: DWORD) HRESULT {
|
||||
return @ptrCast(*const IAudioRenderClient.VTable, self.__v)
|
||||
.ReleaseBuffer(@ptrCast(*IAudioRenderClient, self), num_frames_written, flags);
|
||||
return @as(*const IAudioRenderClient.VTable, @ptrCast(self.__v))
|
||||
.ReleaseBuffer(@as(*IAudioRenderClient, @ptrCast(self)), num_frames_written, flags);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ pub const IBitmapDecoder = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetFrame(self: *T, index: UINT, frame: ?*?*IBitmapFrameDecode) HRESULT {
|
||||
return @ptrCast(*const IBitmapDecoder.VTable, self.__v)
|
||||
.GetFrame(@ptrCast(*IBitmapDecoder, self), index, frame);
|
||||
return @as(*const IBitmapDecoder.VTable, @ptrCast(self.__v))
|
||||
.GetFrame(@as(*IBitmapDecoder, @ptrCast(self)), index, frame);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -107,12 +107,12 @@ pub const IBitmapSource = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetSize(self: *T, width: *UINT, height: *UINT) HRESULT {
|
||||
return @ptrCast(*const IBitmapSource.VTable, self.__v)
|
||||
.GetSize(@ptrCast(*IBitmapSource, self), width, height);
|
||||
return @as(*const IBitmapSource.VTable, @ptrCast(self.__v))
|
||||
.GetSize(@as(*IBitmapSource, @ptrCast(self)), width, height);
|
||||
}
|
||||
pub inline fn GetPixelFormat(self: *T, guid: *PixelFormatGUID) HRESULT {
|
||||
return @ptrCast(*const IBitmapSource.VTable, self.__v)
|
||||
.GetPixelFormat(@ptrCast(*IBitmapSource, self), guid);
|
||||
return @as(*const IBitmapSource.VTable, @ptrCast(self.__v))
|
||||
.GetPixelFormat(@as(*IBitmapSource, @ptrCast(self)), guid);
|
||||
}
|
||||
pub inline fn CopyPixels(
|
||||
self: *T,
|
||||
@@ -121,8 +121,8 @@ pub const IBitmapSource = extern struct {
|
||||
size: UINT,
|
||||
buffer: [*]BYTE,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IBitmapSource.VTable, self.__v)
|
||||
.CopyPixels(@ptrCast(*IBitmapSource, self), rect, stride, size, buffer);
|
||||
return @as(*const IBitmapSource.VTable, @ptrCast(self.__v))
|
||||
.CopyPixels(@as(*IBitmapSource, @ptrCast(self)), rect, stride, size, buffer);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -204,8 +204,8 @@ pub const IFormatConverter = extern struct {
|
||||
alpha_threshold_percent: f64,
|
||||
palette_translate: BitmapPaletteType,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IFormatConverter.VTable, self.__v).Initialize(
|
||||
@ptrCast(*IFormatConverter, self),
|
||||
return @as(*const IFormatConverter.VTable, @ptrCast(self.__v)).Initialize(
|
||||
@as(*IFormatConverter, @ptrCast(self)),
|
||||
source,
|
||||
dest_format,
|
||||
dither,
|
||||
@@ -249,8 +249,8 @@ pub const IImagingFactory = extern struct {
|
||||
metadata: DecodeOptions,
|
||||
decoder: ?*?*IBitmapDecoder,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IImagingFactory.VTable, self.__v).CreateDecoderFromFilename(
|
||||
@ptrCast(*IImagingFactory, self),
|
||||
return @as(*const IImagingFactory.VTable, @ptrCast(self.__v)).CreateDecoderFromFilename(
|
||||
@as(*IImagingFactory, @ptrCast(self)),
|
||||
filename,
|
||||
vendor,
|
||||
access,
|
||||
@@ -259,8 +259,8 @@ pub const IImagingFactory = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn CreateFormatConverter(self: *T, converter: ?*?*IFormatConverter) HRESULT {
|
||||
return @ptrCast(*const IImagingFactory.VTable, self.__v)
|
||||
.CreateFormatConverter(@ptrCast(*IImagingFactory, self), converter);
|
||||
return @as(*const IImagingFactory.VTable, @ptrCast(self.__v))
|
||||
.CreateFormatConverter(@as(*IImagingFactory, @ptrCast(self)), converter);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+23
-23
@@ -72,8 +72,8 @@ pub const IXAPO = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn GetRegistrationProperties(self: *T, props: **REGISTRATION_PROPERTIES) HRESULT {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v)
|
||||
.GetRegistrationProperties(@ptrCast(*IXAPO, self), props);
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v))
|
||||
.GetRegistrationProperties(@as(*IXAPO, @ptrCast(self)), props);
|
||||
}
|
||||
pub inline fn IsInputFormatSupported(
|
||||
self: *T,
|
||||
@@ -81,8 +81,8 @@ pub const IXAPO = extern struct {
|
||||
requested_input_format: *const WAVEFORMATEX,
|
||||
supported_input_format: ?**WAVEFORMATEX,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v).IsInputFormatSupported(
|
||||
@ptrCast(*IXAPO, self),
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v)).IsInputFormatSupported(
|
||||
@as(*IXAPO, @ptrCast(self)),
|
||||
output_format,
|
||||
requested_input_format,
|
||||
supported_input_format,
|
||||
@@ -94,19 +94,19 @@ pub const IXAPO = extern struct {
|
||||
requested_output_format: *const WAVEFORMATEX,
|
||||
supported_output_format: ?**WAVEFORMATEX,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v).IsOutputFormatSupported(
|
||||
@ptrCast(*IXAPO, self),
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v)).IsOutputFormatSupported(
|
||||
@as(*IXAPO, @ptrCast(self)),
|
||||
input_format,
|
||||
requested_output_format,
|
||||
supported_output_format,
|
||||
);
|
||||
}
|
||||
pub inline fn Initialize(self: *T, data: ?*const anyopaque, data_size: UINT32) HRESULT {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v)
|
||||
.Initialize(@ptrCast(*IXAPO, self), data, data_size);
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v))
|
||||
.Initialize(@as(*IXAPO, @ptrCast(self)), data, data_size);
|
||||
}
|
||||
pub inline fn Reset(self: *T) void {
|
||||
@ptrCast(*const IXAPO.VTable, self.__v).Reset(@ptrCast(*IXAPO, self));
|
||||
@as(*const IXAPO.VTable, @ptrCast(self.__v)).Reset(@as(*IXAPO, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn LockForProcess(
|
||||
self: *T,
|
||||
@@ -115,8 +115,8 @@ pub const IXAPO = extern struct {
|
||||
num_output_params: UINT32,
|
||||
output_params: ?[*]const LOCKFORPROCESS_BUFFER_PARAMETERS,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v).LockForProcess(
|
||||
@ptrCast(*IXAPO, self),
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v)).LockForProcess(
|
||||
@as(*IXAPO, @ptrCast(self)),
|
||||
num_input_params,
|
||||
input_params,
|
||||
num_output_params,
|
||||
@@ -124,7 +124,7 @@ pub const IXAPO = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn UnlockForProcess(self: *T) void {
|
||||
@ptrCast(*const IXAPO.VTable, self.__v).UnlockForProcess(@ptrCast(*IXAPO, self));
|
||||
@as(*const IXAPO.VTable, @ptrCast(self.__v)).UnlockForProcess(@as(*IXAPO, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Process(
|
||||
self: *T,
|
||||
@@ -134,8 +134,8 @@ pub const IXAPO = extern struct {
|
||||
output_params: ?[*]PROCESS_BUFFER_PARAMETERS,
|
||||
is_enabled: BOOL,
|
||||
) void {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v).Process(
|
||||
@ptrCast(*IXAPO, self),
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v)).Process(
|
||||
@as(*IXAPO, @ptrCast(self)),
|
||||
num_input_params,
|
||||
input_params,
|
||||
num_output_params,
|
||||
@@ -144,12 +144,12 @@ pub const IXAPO = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn CalcInputFrames(self: *T, num_output_frames: UINT32) UINT32 {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v)
|
||||
.CalcInputFrames(@ptrCast(*IXAPO, self), num_output_frames);
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v))
|
||||
.CalcInputFrames(@as(*IXAPO, @ptrCast(self)), num_output_frames);
|
||||
}
|
||||
pub inline fn CalcOutputFrames(self: *T, num_input_frames: UINT32) UINT32 {
|
||||
return @ptrCast(*const IXAPO.VTable, self.__v)
|
||||
.CalcOutputFrames(@ptrCast(*IXAPO, self), num_input_frames);
|
||||
return @as(*const IXAPO.VTable, @ptrCast(self.__v))
|
||||
.CalcOutputFrames(@as(*IXAPO, @ptrCast(self)), num_input_frames);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -203,12 +203,12 @@ pub const IXAPOParameters = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn SetParameters(self: *T, params: *const anyopaque, size: UINT32) void {
|
||||
@ptrCast(*const IXAPOParameters.VTable, self.__v)
|
||||
.SetParameters(@ptrCast(*IXAPOParameters, self), params, size);
|
||||
@as(*const IXAPOParameters.VTable, @ptrCast(self.__v))
|
||||
.SetParameters(@as(*IXAPOParameters, @ptrCast(self)), params, size);
|
||||
}
|
||||
pub inline fn GetParameters(self: *T, params: *anyopaque, size: UINT32) void {
|
||||
@ptrCast(*const IXAPOParameters.VTable, self.__v)
|
||||
.GetParameters(@ptrCast(*IXAPOParameters, self), params, size);
|
||||
@as(*const IXAPOParameters.VTable, @ptrCast(self.__v))
|
||||
.GetParameters(@as(*IXAPOParameters, @ptrCast(self)), params, size);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -220,7 +220,7 @@ pub const IXAPOParameters = extern struct {
|
||||
};
|
||||
};
|
||||
|
||||
pub const E_FORMAT_UNSUPPORTED = @bitCast(HRESULT, @as(c_ulong, 0x88970001));
|
||||
pub const E_FORMAT_UNSUPPORTED = @as(HRESULT, @bitCast(@as(c_ulong, 0x88970001)));
|
||||
|
||||
pub const Error = error{
|
||||
E_FORMAT_UNSUPPORTED,
|
||||
|
||||
+94
-94
@@ -194,12 +194,12 @@ pub const IXAudio2 = extern struct {
|
||||
pub usingnamespace IUnknown.Methods(T);
|
||||
|
||||
pub inline fn RegisterForCallbacks(self: *T, cb: *IEngineCallback) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.RegisterForCallbacks(@ptrCast(*IXAudio2, self), cb);
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.RegisterForCallbacks(@as(*IXAudio2, @ptrCast(self)), cb);
|
||||
}
|
||||
pub inline fn UnregisterForCallbacks(self: *T, cb: *IEngineCallback) void {
|
||||
@ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.UnregisterForCallbacks(@ptrCast(*IXAudio2, self), cb);
|
||||
@as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.UnregisterForCallbacks(@as(*IXAudio2, @ptrCast(self)), cb);
|
||||
}
|
||||
pub inline fn CreateSourceVoice(
|
||||
self: *T,
|
||||
@@ -211,8 +211,8 @@ pub const IXAudio2 = extern struct {
|
||||
send_list: ?*const VOICE_SENDS,
|
||||
effect_chain: ?*const EFFECT_CHAIN,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v).CreateSourceVoice(
|
||||
@ptrCast(*IXAudio2, self),
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v)).CreateSourceVoice(
|
||||
@as(*IXAudio2, @ptrCast(self)),
|
||||
source_voice,
|
||||
source_format,
|
||||
flags,
|
||||
@@ -232,8 +232,8 @@ pub const IXAudio2 = extern struct {
|
||||
send_list: ?*const VOICE_SENDS,
|
||||
effect_chain: ?*const EFFECT_CHAIN,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v).CreateSubmixVoice(
|
||||
@ptrCast(*IXAudio2, self),
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v)).CreateSubmixVoice(
|
||||
@as(*IXAudio2, @ptrCast(self)),
|
||||
submix_voice,
|
||||
input_channels,
|
||||
input_sample_rate,
|
||||
@@ -253,8 +253,8 @@ pub const IXAudio2 = extern struct {
|
||||
effect_chain: ?*const EFFECT_CHAIN,
|
||||
stream_category: AUDIO_STREAM_CATEGORY,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v).CreateMasteringVoice(
|
||||
@ptrCast(*IXAudio2, self),
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v)).CreateMasteringVoice(
|
||||
@as(*IXAudio2, @ptrCast(self)),
|
||||
mastering_voice,
|
||||
input_channels,
|
||||
input_sample_rate,
|
||||
@@ -265,27 +265,27 @@ pub const IXAudio2 = extern struct {
|
||||
);
|
||||
}
|
||||
pub inline fn StartEngine(self: *T) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.StartEngine(@ptrCast(*IXAudio2, self));
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.StartEngine(@as(*IXAudio2, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn StopEngine(self: *T) void {
|
||||
@ptrCast(*const IXAudio2.VTable, self.__v).StopEngine(@ptrCast(*IXAudio2, self));
|
||||
@as(*const IXAudio2.VTable, @ptrCast(self.__v)).StopEngine(@as(*IXAudio2, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn CommitChanges(self: *T, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.CommitChanges(@ptrCast(*IXAudio2, self), operation_set);
|
||||
return @as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.CommitChanges(@as(*IXAudio2, @ptrCast(self)), operation_set);
|
||||
}
|
||||
pub inline fn GetPerformanceData(self: *T, data: *PERFORMANCE_DATA) void {
|
||||
@ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.GetPerformanceData(@ptrCast(*IXAudio2, self), data);
|
||||
@as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.GetPerformanceData(@as(*IXAudio2, @ptrCast(self)), data);
|
||||
}
|
||||
pub inline fn SetDebugConfiguration(
|
||||
self: *T,
|
||||
config: ?*const DEBUG_CONFIGURATION,
|
||||
reserved: ?*anyopaque,
|
||||
) void {
|
||||
@ptrCast(*const IXAudio2.VTable, self.__v)
|
||||
.SetDebugConfiguration(@ptrCast(*IXAudio2, self), config, reserved);
|
||||
@as(*const IXAudio2.VTable, @ptrCast(self.__v))
|
||||
.SetDebugConfiguration(@as(*IXAudio2, @ptrCast(self)), config, reserved);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -345,28 +345,28 @@ pub const IVoice = extern struct {
|
||||
pub fn Methods(comptime T: type) type {
|
||||
return extern struct {
|
||||
pub inline fn GetVoiceDetails(self: *T, details: *VOICE_DETAILS) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetVoiceDetails(@ptrCast(*IVoice, self), details);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetVoiceDetails(@as(*IVoice, @ptrCast(self)), details);
|
||||
}
|
||||
pub inline fn SetOutputVoices(self: *T, send_list: ?*const VOICE_SENDS) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.SetOutputVoices(@ptrCast(*IVoice, self), send_list);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.SetOutputVoices(@as(*IVoice, @ptrCast(self)), send_list);
|
||||
}
|
||||
pub inline fn SetEffectChain(self: *T, effect_chain: ?*const EFFECT_CHAIN) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.SetEffectChain(@ptrCast(*IVoice, self), effect_chain);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.SetEffectChain(@as(*IVoice, @ptrCast(self)), effect_chain);
|
||||
}
|
||||
pub inline fn EnableEffect(self: *T, effect_index: UINT32, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.EnableEffect(@ptrCast(*IVoice, self), effect_index, operation_set);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.EnableEffect(@as(*IVoice, @ptrCast(self)), effect_index, operation_set);
|
||||
}
|
||||
pub inline fn DisableEffect(self: *T, effect_index: UINT32, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.DisableEffect(@ptrCast(*IVoice, self), effect_index, operation_set);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.DisableEffect(@as(*IVoice, @ptrCast(self)), effect_index, operation_set);
|
||||
}
|
||||
pub inline fn GetEffectState(self: *T, effect_index: UINT32, enabled: *BOOL) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetEffectState(@ptrCast(*IVoice, self), effect_index, enabled);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetEffectState(@as(*IVoice, @ptrCast(self)), effect_index, enabled);
|
||||
}
|
||||
pub inline fn SetEffectParameters(
|
||||
self: *T,
|
||||
@@ -375,8 +375,8 @@ pub const IVoice = extern struct {
|
||||
params_size: UINT32,
|
||||
operation_set: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v).SetEffectParameters(
|
||||
@ptrCast(*IVoice, self),
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v)).SetEffectParameters(
|
||||
@as(*IVoice, @ptrCast(self)),
|
||||
effect_index,
|
||||
params,
|
||||
params_size,
|
||||
@@ -389,20 +389,20 @@ pub const IVoice = extern struct {
|
||||
params: *anyopaque,
|
||||
params_size: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetEffectParameters(@ptrCast(*IVoice, self), effect_index, params, params_size);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetEffectParameters(@as(*IVoice, @ptrCast(self)), effect_index, params, params_size);
|
||||
}
|
||||
pub inline fn SetFilterParameters(
|
||||
self: *T,
|
||||
params: *const FILTER_PARAMETERS,
|
||||
operation_set: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.SetFilterParameters(@ptrCast(*IVoice, self), params, operation_set);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.SetFilterParameters(@as(*IVoice, @ptrCast(self)), params, operation_set);
|
||||
}
|
||||
pub inline fn GetFilterParameters(self: *T, params: *FILTER_PARAMETERS) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetFilterParameters(@ptrCast(*IVoice, self), params);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetFilterParameters(@as(*IVoice, @ptrCast(self)), params);
|
||||
}
|
||||
pub inline fn SetOutputFilterParameters(
|
||||
self: *T,
|
||||
@@ -410,22 +410,22 @@ pub const IVoice = extern struct {
|
||||
params: *const FILTER_PARAMETERS,
|
||||
operation_set: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.SetOutputFilterParameters(@ptrCast(*IVoice, self), dst_voice, params, operation_set);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.SetOutputFilterParameters(@as(*IVoice, @ptrCast(self)), dst_voice, params, operation_set);
|
||||
}
|
||||
pub inline fn GetOutputFilterParameters(
|
||||
self: *T,
|
||||
dst_voice: ?*IVoice,
|
||||
params: *FILTER_PARAMETERS,
|
||||
) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetOutputFilterParameters(@ptrCast(*IVoice, self), dst_voice, params);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetOutputFilterParameters(@as(*IVoice, @ptrCast(self)), dst_voice, params);
|
||||
}
|
||||
pub inline fn SetVolume(self: *T, volume: f32) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v).SetVolume(@ptrCast(*IVoice, self), volume);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v)).SetVolume(@as(*IVoice, @ptrCast(self)), volume);
|
||||
}
|
||||
pub inline fn GetVolume(self: *T, volume: *f32) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v).GetVolume(@ptrCast(*IVoice, self), volume);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v)).GetVolume(@as(*IVoice, @ptrCast(self)), volume);
|
||||
}
|
||||
pub inline fn SetChannelVolumes(
|
||||
self: *T,
|
||||
@@ -433,15 +433,15 @@ pub const IVoice = extern struct {
|
||||
volumes: [*]const f32,
|
||||
operation_set: UINT32,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const IVoice.VTable, self.__v)
|
||||
.SetChannelVolumes(@ptrCast(*IVoice, self), num_channels, volumes, operation_set);
|
||||
return @as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.SetChannelVolumes(@as(*IVoice, @ptrCast(self)), num_channels, volumes, operation_set);
|
||||
}
|
||||
pub inline fn GetChannelVolumes(self: *T, num_channels: UINT32, volumes: [*]f32) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v)
|
||||
.GetChannelVolumes(@ptrCast(*IVoice, self), num_channels, volumes);
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v))
|
||||
.GetChannelVolumes(@as(*IVoice, @ptrCast(self)), num_channels, volumes);
|
||||
}
|
||||
pub inline fn DestroyVoice(self: *T) void {
|
||||
@ptrCast(*const IVoice.VTable, self.__v).DestroyVoice(@ptrCast(*IVoice, self));
|
||||
@as(*const IVoice.VTable, @ptrCast(self.__v)).DestroyVoice(@as(*IVoice, @ptrCast(self)));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -495,48 +495,48 @@ pub const ISourceVoice = extern struct {
|
||||
pub usingnamespace IVoice.Methods(T);
|
||||
|
||||
pub inline fn Start(self: *T, flags: FLAGS, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.Start(@ptrCast(*ISourceVoice, self), flags, operation_set);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.Start(@as(*ISourceVoice, @ptrCast(self)), flags, operation_set);
|
||||
}
|
||||
pub inline fn Stop(self: *T, flags: FLAGS, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.Stop(@ptrCast(*ISourceVoice, self), flags, operation_set);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.Stop(@as(*ISourceVoice, @ptrCast(self)), flags, operation_set);
|
||||
}
|
||||
pub inline fn SubmitSourceBuffer(
|
||||
self: *T,
|
||||
buffer: *const BUFFER,
|
||||
wmabuffer: ?*const BUFFER_WMA,
|
||||
) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.SubmitSourceBuffer(@ptrCast(*ISourceVoice, self), buffer, wmabuffer);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.SubmitSourceBuffer(@as(*ISourceVoice, @ptrCast(self)), buffer, wmabuffer);
|
||||
}
|
||||
pub inline fn FlushSourceBuffers(self: *T) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.FlushSourceBuffers(@ptrCast(*ISourceVoice, self));
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.FlushSourceBuffers(@as(*ISourceVoice, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn Discontinuity(self: *T) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.Discontinuity(@ptrCast(*ISourceVoice, self));
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.Discontinuity(@as(*ISourceVoice, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn ExitLoop(self: *T, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.ExitLoop(@ptrCast(*ISourceVoice, self), operation_set);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.ExitLoop(@as(*ISourceVoice, @ptrCast(self)), operation_set);
|
||||
}
|
||||
pub inline fn GetState(self: *T, state: *VOICE_STATE, flags: FLAGS) void {
|
||||
@ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.GetState(@ptrCast(*ISourceVoice, self), state, flags);
|
||||
@as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.GetState(@as(*ISourceVoice, @ptrCast(self)), state, flags);
|
||||
}
|
||||
pub inline fn SetFrequencyRatio(self: *T, ratio: f32, operation_set: UINT32) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.SetFrequencyRatio(@ptrCast(*ISourceVoice, self), ratio, operation_set);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.SetFrequencyRatio(@as(*ISourceVoice, @ptrCast(self)), ratio, operation_set);
|
||||
}
|
||||
pub inline fn GetFrequencyRatio(self: *T, ratio: *f32) void {
|
||||
@ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.GetFrequencyRatio(@ptrCast(*ISourceVoice, self), ratio);
|
||||
@as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.GetFrequencyRatio(@as(*ISourceVoice, @ptrCast(self)), ratio);
|
||||
}
|
||||
pub inline fn SetSourceSampleRate(self: *T, sample_rate: UINT32) HRESULT {
|
||||
return @ptrCast(*const ISourceVoice.VTable, self.__v)
|
||||
.SetSourceSampleRate(@ptrCast(*ISourceVoice, self), sample_rate);
|
||||
return @as(*const ISourceVoice.VTable, @ptrCast(self.__v))
|
||||
.SetSourceSampleRate(@as(*ISourceVoice, @ptrCast(self)), sample_rate);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -587,8 +587,8 @@ pub const IMasteringVoice = extern struct {
|
||||
pub usingnamespace IVoice.Methods(T);
|
||||
|
||||
pub inline fn GetChannelMask(self: *T, channel_mask: *DWORD) HRESULT {
|
||||
return @ptrCast(*const IMasteringVoice.VTable, self.__v)
|
||||
.GetChannelMask(@ptrCast(*IMasteringVoice, self), channel_mask);
|
||||
return @as(*const IMasteringVoice.VTable, @ptrCast(self.__v))
|
||||
.GetChannelMask(@as(*IMasteringVoice, @ptrCast(self)), channel_mask);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -607,16 +607,16 @@ pub const IEngineCallback = extern struct {
|
||||
pub fn Methods(comptime T: type) type {
|
||||
return extern struct {
|
||||
pub inline fn OnProcessingPassStart(self: *T) void {
|
||||
@ptrCast(*const IEngineCallback.VTable, self.__v)
|
||||
.OnProcessingPassStart(@ptrCast(*IEngineCallback, self));
|
||||
@as(*const IEngineCallback.VTable, @ptrCast(self.__v))
|
||||
.OnProcessingPassStart(@as(*IEngineCallback, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn OnProcessingPassEnd(self: *T) void {
|
||||
@ptrCast(*const IEngineCallback.VTable, self.__v)
|
||||
.OnProcessingPassEnd(@ptrCast(*IEngineCallback, self));
|
||||
@as(*const IEngineCallback.VTable, @ptrCast(self.__v))
|
||||
.OnProcessingPassEnd(@as(*IEngineCallback, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn OnCriticalError(self: *T, err: HRESULT) void {
|
||||
@ptrCast(*const IEngineCallback.VTable, self.__v)
|
||||
.OnCriticalError(@ptrCast(*IEngineCallback, self), err);
|
||||
@as(*const IEngineCallback.VTable, @ptrCast(self.__v))
|
||||
.OnCriticalError(@as(*IEngineCallback, @ptrCast(self)), err);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -643,32 +643,32 @@ pub const IVoiceCallback = extern struct {
|
||||
pub fn Methods(comptime T: type) type {
|
||||
return extern struct {
|
||||
pub inline fn OnVoiceProcessingPassStart(self: *T, bytes_required: UINT32) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnVoiceProcessingPassStart(@ptrCast(*IVoiceCallback, self), bytes_required);
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnVoiceProcessingPassStart(@as(*IVoiceCallback, @ptrCast(self)), bytes_required);
|
||||
}
|
||||
pub inline fn OnVoiceProcessingPassEnd(self: *T) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnVoiceProcessingPassEnd(@ptrCast(*IVoiceCallback, self));
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnVoiceProcessingPassEnd(@as(*IVoiceCallback, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn OnStreamEnd(self: *T) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnStreamEnd(@ptrCast(*IVoiceCallback, self));
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnStreamEnd(@as(*IVoiceCallback, @ptrCast(self)));
|
||||
}
|
||||
pub inline fn OnBufferStart(self: *T, context: ?*anyopaque) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnBufferStart(@ptrCast(*IVoiceCallback, self), context);
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnBufferStart(@as(*IVoiceCallback, @ptrCast(self)), context);
|
||||
}
|
||||
pub inline fn OnBufferEnd(self: *T, context: ?*anyopaque) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnBufferEnd(@ptrCast(*IVoiceCallback, self), context);
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnBufferEnd(@as(*IVoiceCallback, @ptrCast(self)), context);
|
||||
}
|
||||
pub inline fn OnLoopEnd(self: *T, context: ?*anyopaque) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnLoopEnd(@ptrCast(*IVoiceCallback, self), context);
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnLoopEnd(@as(*IVoiceCallback, @ptrCast(self)), context);
|
||||
}
|
||||
pub inline fn OnVoiceError(self: *T, context: ?*anyopaque, err: HRESULT) void {
|
||||
@ptrCast(*const IVoiceCallback.VTable, self.__v)
|
||||
.OnVoiceError(@ptrCast(*IVoiceCallback, self), context, err);
|
||||
@as(*const IVoiceCallback.VTable, @ptrCast(self.__v))
|
||||
.OnVoiceError(@as(*IVoiceCallback, @ptrCast(self)), context, err);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -712,9 +712,9 @@ pub fn create(
|
||||
}
|
||||
|
||||
var xaudio2Create: *const fn (*?*IXAudio2, FLAGS, UINT32) callconv(WINAPI) HRESULT = undefined;
|
||||
xaudio2Create = @ptrCast(
|
||||
xaudio2Create = @as(
|
||||
@TypeOf(xaudio2Create),
|
||||
w32.GetProcAddress(xaudio2_dll.?, "XAudio2Create").?,
|
||||
@ptrCast(w32.GetProcAddress(xaudio2_dll.?, "XAudio2Create").?),
|
||||
);
|
||||
|
||||
return xaudio2Create(ppv, flags, processor);
|
||||
|
||||
@@ -145,9 +145,9 @@ pub fn createVolumeMeter(apo: *?*IUnknown, _: UINT32) HRESULT {
|
||||
}
|
||||
|
||||
var createAudioVolumeMeter: *const fn (*?*IUnknown) callconv(WINAPI) HRESULT = undefined;
|
||||
createAudioVolumeMeter = @ptrCast(
|
||||
createAudioVolumeMeter = @as(
|
||||
@TypeOf(createAudioVolumeMeter),
|
||||
w32.GetProcAddress(xaudio2_dll.?, "CreateAudioVolumeMeter").?,
|
||||
@ptrCast(w32.GetProcAddress(xaudio2_dll.?, "CreateAudioVolumeMeter").?),
|
||||
);
|
||||
|
||||
return createAudioVolumeMeter(apo);
|
||||
@@ -160,9 +160,9 @@ pub fn createReverb(apo: *?*IUnknown, _: UINT32) HRESULT {
|
||||
}
|
||||
|
||||
var createAudioReverb: *const fn (*?*IUnknown) callconv(WINAPI) HRESULT = undefined;
|
||||
createAudioReverb = @ptrCast(
|
||||
createAudioReverb = @as(
|
||||
@TypeOf(createAudioReverb),
|
||||
w32.GetProcAddress(xaudio2_dll.?, "CreateAudioReverb").?,
|
||||
@ptrCast(w32.GetProcAddress(xaudio2_dll.?, "CreateAudioReverb").?),
|
||||
);
|
||||
|
||||
return createAudioReverb(apo);
|
||||
|
||||
@@ -37,7 +37,7 @@ pub const HResultError =
|
||||
pub fn hrPanic(err: HResultError) noreturn {
|
||||
panic(
|
||||
"HRESULT error detected (0x{x}, {}).",
|
||||
.{ @bitCast(c_ulong, errorToHRESULT(err)), err },
|
||||
.{ @as(c_ulong, @bitCast(errorToHRESULT(err))), err },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ pub fn hrToError(hr: HRESULT) HResultError {
|
||||
w32.S_FALSE => w32.MiscError.S_FALSE,
|
||||
// treat unknown error return codes as E_FAIL
|
||||
else => blk: {
|
||||
std.log.debug("HRESULT error 0x{x} not recognized treating as E_FAIL.", .{@bitCast(c_ulong, hr)});
|
||||
std.log.debug("HRESULT error 0x{x} not recognized treating as E_FAIL.", .{@as(c_ulong, @bitCast(hr))});
|
||||
break :blk w32.Error.FAIL;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ const StopOnBufferEndVoiceCallback = extern struct {
|
||||
const vtable = xaudio2.IVoiceCallback.VTable{ .OnBufferEnd = _onBufferEnd };
|
||||
|
||||
fn _onBufferEnd(_: *xaudio2.IVoiceCallback, context: ?*anyopaque) callconv(WINAPI) void {
|
||||
const voice = @ptrCast(*xaudio2.ISourceVoice, @alignCast(@sizeOf(usize), context));
|
||||
const voice = @as(*xaudio2.ISourceVoice, @ptrCast(@alignCast(context)));
|
||||
hrPanicOnFail(voice.Stop(.{}, xaudio2.COMMIT_NOW));
|
||||
}
|
||||
};
|
||||
@@ -92,7 +92,7 @@ pub const AudioContext = struct {
|
||||
&optimal_voice_format,
|
||||
.{},
|
||||
xaudio2.DEFAULT_FREQ_RATIO,
|
||||
@ptrCast(*xaudio2.IVoiceCallback, &stop_on_buffer_end_vcb),
|
||||
@as(*xaudio2.IVoiceCallback, @ptrCast(&stop_on_buffer_end_vcb)),
|
||||
null,
|
||||
null,
|
||||
));
|
||||
@@ -140,7 +140,7 @@ pub const AudioContext = struct {
|
||||
&optimal_voice_format,
|
||||
.{},
|
||||
xaudio2.DEFAULT_FREQ_RATIO,
|
||||
@ptrCast(*xaudio2.IVoiceCallback, &stop_on_buffer_end_vcb),
|
||||
@as(*xaudio2.IVoiceCallback, @ptrCast(&stop_on_buffer_end_vcb)),
|
||||
null,
|
||||
null,
|
||||
));
|
||||
@@ -173,7 +173,7 @@ pub const AudioContext = struct {
|
||||
|
||||
hrPanicOnFail(voice.SubmitSourceBuffer(&.{
|
||||
.Flags = .{ .END_OF_STREAM = true },
|
||||
.AudioBytes = @intCast(u32, sound.?.data.?.len),
|
||||
.AudioBytes = @as(u32, @intCast(sound.?.data.?.len)),
|
||||
.pAudioData = sound.?.data.?.ptr,
|
||||
.PlayBegin = params.play_begin,
|
||||
.PlayLength = params.play_length,
|
||||
@@ -230,7 +230,7 @@ pub const Stream = struct {
|
||||
|
||||
hrPanicOnFail(attribs.SetUnknown(
|
||||
&mf.SOURCE_READER_ASYNC_CALLBACK,
|
||||
@ptrCast(*w32.IUnknown, source_reader_cb),
|
||||
@as(*w32.IUnknown, @ptrCast(source_reader_cb)),
|
||||
));
|
||||
|
||||
var arena_state = std.heap.ArenaAllocator.init(allocator);
|
||||
@@ -278,7 +278,7 @@ pub const Stream = struct {
|
||||
.nBlockAlign = 4,
|
||||
.wBitsPerSample = 16,
|
||||
.cbSize = @sizeOf(wasapi.WAVEFORMATEX),
|
||||
}, .{}, xaudio2.DEFAULT_FREQ_RATIO, @ptrCast(*xaudio2.IVoiceCallback, voice_cb), null, null));
|
||||
}, .{}, xaudio2.DEFAULT_FREQ_RATIO, @as(*xaudio2.IVoiceCallback, @ptrCast(voice_cb)), null, null));
|
||||
break :blk voice.?;
|
||||
};
|
||||
|
||||
@@ -396,8 +396,8 @@ const StreamVoiceCallback = extern struct {
|
||||
const vtable = xaudio2.IVoiceCallback.VTable{ .OnBufferEnd = _onBufferEnd };
|
||||
|
||||
fn _onBufferEnd(iself: *xaudio2.IVoiceCallback, context: ?*anyopaque) callconv(WINAPI) void {
|
||||
const self = @ptrCast(*StreamVoiceCallback, iself);
|
||||
self.stream.?.endOfStreamChunk(@ptrCast(*mf.IMediaBuffer, @alignCast(@sizeOf(usize), context)));
|
||||
const self = @as(*StreamVoiceCallback, @ptrCast(iself));
|
||||
self.stream.?.endOfStreamChunk(@as(*mf.IMediaBuffer, @ptrCast(@alignCast(context))));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -423,7 +423,7 @@ const SourceReaderCallback = extern struct {
|
||||
outobj: ?*?*anyopaque,
|
||||
) callconv(WINAPI) HRESULT {
|
||||
assert(outobj != null);
|
||||
const self = @ptrCast(*SourceReaderCallback, iself);
|
||||
const self = @as(*SourceReaderCallback, @ptrCast(iself));
|
||||
|
||||
if (std.mem.eql(u8, std.mem.asBytes(guid), std.mem.asBytes(&w32.IID_IUnknown))) {
|
||||
outobj.?.* = self;
|
||||
@@ -440,13 +440,13 @@ const SourceReaderCallback = extern struct {
|
||||
}
|
||||
|
||||
fn _addRef(iself: *IUnknown) callconv(WINAPI) ULONG {
|
||||
const self = @ptrCast(*SourceReaderCallback, iself);
|
||||
const self = @as(*SourceReaderCallback, @ptrCast(iself));
|
||||
const prev_refcount = @atomicRmw(u32, &self.refcount, .Add, 1, .Monotonic);
|
||||
return prev_refcount + 1;
|
||||
}
|
||||
|
||||
fn _release(iself: *IUnknown) callconv(WINAPI) ULONG {
|
||||
const self = @ptrCast(*SourceReaderCallback, iself);
|
||||
const self = @as(*SourceReaderCallback, @ptrCast(iself));
|
||||
const prev_refcount = @atomicRmw(u32, &self.refcount, .Sub, 1, .Monotonic);
|
||||
assert(prev_refcount > 0);
|
||||
return prev_refcount - 1;
|
||||
@@ -460,7 +460,7 @@ const SourceReaderCallback = extern struct {
|
||||
timestamp: LONGLONG,
|
||||
sample: ?*mf.ISample,
|
||||
) callconv(WINAPI) HRESULT {
|
||||
const self = @ptrCast(*SourceReaderCallback, iself);
|
||||
const self = @as(*SourceReaderCallback, @ptrCast(iself));
|
||||
self.stream.?.playStreamChunk(status, stream_index, stream_flags, timestamp, sample);
|
||||
return w32.S_OK;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ const SoundPool = struct {
|
||||
|
||||
pool.sounds[slot_idx] = .{ .data = data };
|
||||
return .{
|
||||
.index = @intCast(u16, slot_idx),
|
||||
.index = @as(u16, @intCast(slot_idx)),
|
||||
.generation = blk: {
|
||||
pool.generations[slot_idx] += 1;
|
||||
break :blk pool.generations[slot_idx];
|
||||
@@ -665,7 +665,7 @@ const SimpleAudioProcessor = extern struct {
|
||||
outobj: ?*?*anyopaque,
|
||||
) callconv(WINAPI) HRESULT {
|
||||
assert(outobj != null);
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
|
||||
if (std.mem.eql(u8, std.mem.asBytes(guid), std.mem.asBytes(&w32.IID_IUnknown))) {
|
||||
outobj.?.* = self;
|
||||
@@ -682,12 +682,12 @@ const SimpleAudioProcessor = extern struct {
|
||||
}
|
||||
|
||||
fn _addRef(iself: *IUnknown) callconv(WINAPI) ULONG {
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
return @atomicRmw(u32, &self.refcount, .Add, 1, .Monotonic) + 1;
|
||||
}
|
||||
|
||||
fn _release(iself: *IUnknown) callconv(WINAPI) ULONG {
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
const prev_refcount = @atomicRmw(u32, &self.refcount, .Sub, 1, .Monotonic);
|
||||
if (prev_refcount == 1) {
|
||||
w32.CoTaskMemFree(self);
|
||||
@@ -701,7 +701,7 @@ const SimpleAudioProcessor = extern struct {
|
||||
) callconv(WINAPI) HRESULT {
|
||||
const ptr = w32.CoTaskMemAlloc(@sizeOf(xapo.REGISTRATION_PROPERTIES));
|
||||
if (ptr != null) {
|
||||
props.* = @ptrCast(*xapo.REGISTRATION_PROPERTIES, @alignCast(@sizeOf(usize), ptr.?));
|
||||
props.* = @as(*xapo.REGISTRATION_PROPERTIES, @ptrCast(@alignCast(ptr.?)));
|
||||
props.*.* = info;
|
||||
return w32.S_OK;
|
||||
}
|
||||
@@ -726,8 +726,8 @@ const SimpleAudioProcessor = extern struct {
|
||||
supported_input_format.?.*.wBitsPerSample = 32;
|
||||
supported_input_format.?.*.nChannels = std.math.clamp(
|
||||
requested_input_format.nChannels,
|
||||
@intCast(u16, xapo.MIN_CHANNELS),
|
||||
@intCast(u16, xapo.MAX_CHANNELS),
|
||||
@as(u16, @intCast(xapo.MIN_CHANNELS)),
|
||||
@as(u16, @intCast(xapo.MAX_CHANNELS)),
|
||||
);
|
||||
supported_input_format.?.*.nSamplesPerSec = std.math.clamp(
|
||||
requested_input_format.nSamplesPerSec,
|
||||
@@ -758,8 +758,8 @@ const SimpleAudioProcessor = extern struct {
|
||||
supported_output_format.?.*.wBitsPerSample = 32;
|
||||
supported_output_format.?.*.nChannels = std.math.clamp(
|
||||
requested_output_format.nChannels,
|
||||
@intCast(u16, xapo.MIN_CHANNELS),
|
||||
@intCast(u16, xapo.MAX_CHANNELS),
|
||||
@as(u16, @intCast(xapo.MIN_CHANNELS)),
|
||||
@as(u16, @intCast(xapo.MAX_CHANNELS)),
|
||||
);
|
||||
supported_output_format.?.*.nSamplesPerSec = std.math.clamp(
|
||||
requested_output_format.nSamplesPerSec,
|
||||
@@ -787,7 +787,7 @@ const SimpleAudioProcessor = extern struct {
|
||||
num_output_params: UINT32,
|
||||
output_params: ?[*]const xapo.LOCKFORPROCESS_BUFFER_PARAMETERS,
|
||||
) callconv(WINAPI) HRESULT {
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
assert(self.is_locked == false);
|
||||
assert(num_input_params == 1 and num_output_params == 1);
|
||||
assert(input_params != null and output_params != null);
|
||||
@@ -804,7 +804,7 @@ const SimpleAudioProcessor = extern struct {
|
||||
}
|
||||
|
||||
fn _unlockForProcess(iself: *xapo.IXAPO) callconv(WINAPI) void {
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
assert(self.is_locked == true);
|
||||
self.num_channels = 0;
|
||||
self.is_locked = false;
|
||||
@@ -818,14 +818,14 @@ const SimpleAudioProcessor = extern struct {
|
||||
output_params: ?[*]xapo.PROCESS_BUFFER_PARAMETERS,
|
||||
is_enabled: BOOL,
|
||||
) callconv(WINAPI) void {
|
||||
const self = @ptrCast(*SimpleAudioProcessor, iself);
|
||||
const self = @as(*SimpleAudioProcessor, @ptrCast(iself));
|
||||
assert(self.is_locked and self.num_channels > 0);
|
||||
assert(num_input_params == 1 and num_output_params == 1);
|
||||
assert(input_params != null and output_params != null);
|
||||
assert(input_params.?[0].pBuffer == output_params.?[0].pBuffer);
|
||||
|
||||
if (is_enabled == w32.TRUE) {
|
||||
var samples = @ptrCast([*]f32, @alignCast(16, input_params.?[0].pBuffer)); // XAudio2 aligns data to 16.
|
||||
var samples = @as([*]f32, @ptrCast(@alignCast(input_params.?[0].pBuffer)));
|
||||
const num_samples = input_params.?[0].ValidFrameCount * self.num_channels;
|
||||
|
||||
self.process(
|
||||
@@ -853,10 +853,10 @@ pub fn createSimpleProcessor(
|
||||
context: ?*anyopaque,
|
||||
) *IUnknown {
|
||||
const ptr = w32.CoTaskMemAlloc(@sizeOf(SimpleAudioProcessor)).?;
|
||||
const comptr = @ptrCast(*SimpleAudioProcessor, @alignCast(@sizeOf(usize), ptr));
|
||||
const comptr = @as(*SimpleAudioProcessor, @ptrCast(@alignCast(ptr)));
|
||||
comptr.* = .{
|
||||
.process = process,
|
||||
.context = context,
|
||||
};
|
||||
return @ptrCast(*IUnknown, comptr);
|
||||
return @as(*IUnknown, @ptrCast(comptr));
|
||||
}
|
||||
@@ -105,7 +105,7 @@ const DemoState = struct {
|
||||
};
|
||||
|
||||
fn processAudio(samples: []f32, num_channels: u32, context: ?*anyopaque) void {
|
||||
const audio_data = @ptrCast(*AudioData, @alignCast(@sizeOf(usize), context));
|
||||
const audio_data = @as(*AudioData, @ptrCast(@alignCast(context)));
|
||||
|
||||
audio_data.mutex.lock();
|
||||
defer audio_data.mutex.unlock();
|
||||
@@ -286,7 +286,7 @@ fn update(demo: *DemoState) void {
|
||||
common.newImGuiFrame(dt);
|
||||
|
||||
c.igSetNextWindowPos(
|
||||
c.ImVec2{ .x = @floatFromInt(f32, demo.gctx.viewport_width) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImVec2{ .x = @as(f32, @floatFromInt(demo.gctx.viewport_width)) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImGuiCond_FirstUseEver,
|
||||
c.ImVec2{ .x = 0.0, .y = 0.0 },
|
||||
);
|
||||
@@ -358,8 +358,8 @@ fn update(demo: *DemoState) void {
|
||||
{
|
||||
var pos: w32.POINT = undefined;
|
||||
_ = w32.GetCursorPos(&pos);
|
||||
const delta_x = @floatFromInt(f32, pos.x) - @floatFromInt(f32, demo.mouse.cursor_prev_x);
|
||||
const delta_y = @floatFromInt(f32, pos.y) - @floatFromInt(f32, demo.mouse.cursor_prev_y);
|
||||
const delta_x = @as(f32, @floatFromInt(pos.x)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_x));
|
||||
const delta_y = @as(f32, @floatFromInt(pos.y)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_y));
|
||||
demo.mouse.cursor_prev_x = pos.x;
|
||||
demo.mouse.cursor_prev_y = pos.y;
|
||||
|
||||
@@ -413,7 +413,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, gctx.viewport_width) / @floatFromInt(f32, gctx.viewport_height),
|
||||
@as(f32, @floatFromInt(gctx.viewport_width)) / @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -468,7 +468,7 @@ fn draw(demo: *DemoState) void {
|
||||
const mem = gctx.allocateUploadMemory(Pso_Vertex, num_vertices);
|
||||
|
||||
const z = (demo.audio_data.cursor_position + row) % 100;
|
||||
const f = if (row == 0) 1.0 else 0.010101 * @floatFromInt(f32, row - 1);
|
||||
const f = if (row == 0) 1.0 else 0.010101 * @as(f32, @floatFromInt(row - 1));
|
||||
|
||||
var x: u32 = 0;
|
||||
while (x < num_vertices) : (x += 1) {
|
||||
@@ -483,9 +483,9 @@ fn draw(demo: *DemoState) void {
|
||||
|
||||
mem.cpu_slice[x] = Pso_Vertex{
|
||||
.position = [_]f32{
|
||||
0.1 * @floatFromInt(f32, x),
|
||||
0.1 * @as(f32, @floatFromInt(x)),
|
||||
f * f * f * 10.0 * sample,
|
||||
0.5 * @floatFromInt(f32, z),
|
||||
0.5 * @as(f32, @floatFromInt(z)),
|
||||
},
|
||||
.color = color,
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ const AudioState = struct {
|
||||
_: ?*const anyopaque,
|
||||
num_frames: u32,
|
||||
) callconv(.C) void {
|
||||
const audio = @ptrCast(*AudioState, @alignCast(@alignOf(AudioState), device.getUserData()));
|
||||
const audio = @as(*AudioState, @ptrCast(@alignCast(device.getUserData())));
|
||||
|
||||
audio.engine.readPcmFrames(output.?, num_frames, null) catch {};
|
||||
|
||||
@@ -131,7 +131,7 @@ const AudioState = struct {
|
||||
|
||||
const num_channels = 2;
|
||||
const base_index = samples_per_set * audio.current_set;
|
||||
const frames = @ptrCast([*]f32, @alignCast(@sizeOf(f32), output));
|
||||
const frames = @as([*]f32, @ptrCast(@alignCast(output)));
|
||||
|
||||
var i: u32 = 0;
|
||||
while (i < @min(num_frames, usable_samples_per_set)) : (i += 1) {
|
||||
@@ -546,7 +546,7 @@ fn update(demo: *DemoState) !void {
|
||||
if (zgui.selectable(name, .{ .selected = (selected_item == index) }) and
|
||||
selected_item != index)
|
||||
{
|
||||
demo.waveform_config.waveform_type = @enumFromInt(zaudio.Waveform.Type, index);
|
||||
demo.waveform_config.waveform_type = @as(zaudio.Waveform.Type, @enumFromInt(index));
|
||||
try demo.waveform_data_source.setType(demo.waveform_config.waveform_type);
|
||||
}
|
||||
}
|
||||
@@ -595,7 +595,7 @@ fn update(demo: *DemoState) !void {
|
||||
if (zgui.selectable(name, .{ .selected = (selected_item == index) }) and
|
||||
selected_item != index)
|
||||
{
|
||||
demo.noise_config.noise_type = @enumFromInt(zaudio.Noise.Type, index);
|
||||
demo.noise_config.noise_type = @as(zaudio.Noise.Type, @enumFromInt(index));
|
||||
try demo.noise_data_source.setType(demo.noise_config.noise_type);
|
||||
}
|
||||
}
|
||||
@@ -633,7 +633,7 @@ fn update(demo: *DemoState) !void {
|
||||
if (zgui.selectable(name, .{ .selected = (selected_item == index) }) and
|
||||
selected_item != index)
|
||||
{
|
||||
demo.audio_filter.current_type = @enumFromInt(AudioFilterType, index);
|
||||
demo.audio_filter.current_type = @as(AudioFilterType, @enumFromInt(index));
|
||||
try updateAudioGraph(demo.*);
|
||||
}
|
||||
}
|
||||
@@ -758,8 +758,8 @@ fn update(demo: *DemoState) !void {
|
||||
// Handle camera rotation with mouse.
|
||||
{
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const delta_x = @floatCast(f32, cursor_pos[0] - demo.mouse.cursor_pos[0]);
|
||||
const delta_y = @floatCast(f32, cursor_pos[1] - demo.mouse.cursor_pos[1]);
|
||||
const delta_x = @as(f32, @floatCast(cursor_pos[0] - demo.mouse.cursor_pos[0]));
|
||||
const delta_y = @as(f32, @floatCast(cursor_pos[1] - demo.mouse.cursor_pos[1]));
|
||||
demo.mouse.cursor_pos = cursor_pos;
|
||||
|
||||
if (window.getMouseButton(.right) == .press) {
|
||||
@@ -816,7 +816,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -839,11 +839,11 @@ fn draw(demo: *DemoState) void {
|
||||
demo.audio.mutex.lock();
|
||||
defer demo.audio.mutex.unlock();
|
||||
|
||||
const rcp_num_sets = 1.0 / @floatFromInt(f32, AudioState.num_sets - 1);
|
||||
const rcp_num_sets = 1.0 / @as(f32, @floatFromInt(AudioState.num_sets - 1));
|
||||
var set: u32 = 0;
|
||||
while (set < AudioState.num_sets) : (set += 1) {
|
||||
const z = (demo.audio.current_set + set) % AudioState.num_sets;
|
||||
const f = if (set == 0) 1.0 else rcp_num_sets * @floatFromInt(f32, set - 1);
|
||||
const f = if (set == 0) 1.0 else rcp_num_sets * @as(f32, @floatFromInt(set - 1));
|
||||
|
||||
var x: u32 = 0;
|
||||
while (x < AudioState.usable_samples_per_set) : (x += 1) {
|
||||
@@ -857,9 +857,9 @@ fn draw(demo: *DemoState) void {
|
||||
|
||||
mem[x + set * AudioState.usable_samples_per_set] = Vertex{
|
||||
.position = [_]f32{
|
||||
0.1 * @floatFromInt(f32, x),
|
||||
0.1 * @as(f32, @floatFromInt(x)),
|
||||
f * f * f * 10.0 * sample,
|
||||
0.5 * @floatFromInt(f32, z),
|
||||
0.5 * @as(f32, @floatFromInt(z)),
|
||||
},
|
||||
.color = color,
|
||||
};
|
||||
|
||||
@@ -64,13 +64,13 @@ fn fillAudioBuffer(audio: *AudioContex) void {
|
||||
const num_frames = audio.buffer_size_in_frames - buffer_padding_in_frames;
|
||||
|
||||
var ptr: [*]f32 = undefined;
|
||||
hrPanicOnFail(audio.render_client.GetBuffer(num_frames, @ptrCast(*?[*]w32.BYTE, &ptr)));
|
||||
hrPanicOnFail(audio.render_client.GetBuffer(num_frames, @as(*?[*]w32.BYTE, @ptrCast(&ptr))));
|
||||
|
||||
var i: u32 = 0;
|
||||
while (i < num_frames) : (i += 1) {
|
||||
const frame = audio.current_frame_index;
|
||||
ptr[i * 2 + 0] = @floatFromInt(f32, audio.samples.items[frame * 2 + 0]) / @floatFromInt(f32, 0x7fff);
|
||||
ptr[i * 2 + 1] = @floatFromInt(f32, audio.samples.items[frame * 2 + 1]) / @floatFromInt(f32, 0x7fff);
|
||||
ptr[i * 2 + 0] = @as(f32, @floatFromInt(audio.samples.items[frame * 2 + 0])) / @as(f32, @floatFromInt(0x7fff));
|
||||
ptr[i * 2 + 1] = @as(f32, @floatFromInt(audio.samples.items[frame * 2 + 1])) / @as(f32, @floatFromInt(0x7fff));
|
||||
|
||||
audio.current_frame_index += 1;
|
||||
if (audio.current_frame_index * 2 >= audio.samples.items.len) {
|
||||
@@ -81,7 +81,7 @@ fn fillAudioBuffer(audio: *AudioContex) void {
|
||||
}
|
||||
|
||||
fn audioThread(ctx: ?*anyopaque) callconv(.C) w32.DWORD {
|
||||
const audio = @ptrCast(*AudioContex, @alignCast(@sizeOf(usize), ctx));
|
||||
const audio = @as(*AudioContex, @ptrCast(@alignCast(ctx)));
|
||||
|
||||
fillAudioBuffer(audio);
|
||||
while (true) {
|
||||
@@ -111,7 +111,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
null,
|
||||
w32.CLSCTX_INPROC_SERVER,
|
||||
&wasapi.IID_IMMDeviceEnumerator,
|
||||
@ptrCast(*?*anyopaque, &audio_device_enumerator),
|
||||
@as(*?*anyopaque, @ptrCast(&audio_device_enumerator)),
|
||||
));
|
||||
break :blk audio_device_enumerator;
|
||||
};
|
||||
@@ -122,7 +122,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
hrPanicOnFail(audio_device_enumerator.GetDefaultAudioEndpoint(
|
||||
.eRender,
|
||||
.eConsole,
|
||||
@ptrCast(*?*wasapi.IMMDevice, &audio_device),
|
||||
@as(*?*wasapi.IMMDevice, @ptrCast(&audio_device)),
|
||||
));
|
||||
break :blk audio_device;
|
||||
};
|
||||
@@ -134,7 +134,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
&wasapi.IID_IAudioClient3,
|
||||
w32.CLSCTX_INPROC_SERVER,
|
||||
null,
|
||||
@ptrCast(*?*anyopaque, &audio_client),
|
||||
@as(*?*anyopaque, @ptrCast(&audio_client)),
|
||||
));
|
||||
break :blk audio_client;
|
||||
};
|
||||
@@ -168,7 +168,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
var audio_render_client: *wasapi.IAudioRenderClient = undefined;
|
||||
hrPanicOnFail(audio_client.GetService(
|
||||
&wasapi.IID_IAudioRenderClient,
|
||||
@ptrCast(*?*anyopaque, &audio_render_client),
|
||||
@as(*?*anyopaque, @ptrCast(&audio_render_client)),
|
||||
));
|
||||
break :blk audio_render_client;
|
||||
};
|
||||
@@ -244,7 +244,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
var data_ptr: [*]i16 = undefined;
|
||||
var data_len: u32 = 0;
|
||||
hrPanicOnFail(buffer.Lock(@ptrCast(*[*]u8, &data_ptr), null, &data_len));
|
||||
hrPanicOnFail(buffer.Lock(@as(*[*]u8, @ptrCast(&data_ptr)), null, &data_len));
|
||||
const data = data_ptr[0..@divExact(data_len, 2)];
|
||||
|
||||
for (data) |s| {
|
||||
@@ -385,14 +385,14 @@ fn draw(demo: *DemoState) void {
|
||||
if ((frame + i) * 2 >= demo.audio.samples.items.len) {
|
||||
break :blk 0.0;
|
||||
} else {
|
||||
const l = @floatFromInt(f32, demo.audio.samples.items[(frame + i) * 2 + 0]) /
|
||||
@floatFromInt(f32, 0x7fff);
|
||||
const r = @floatFromInt(f32, demo.audio.samples.items[(frame + i) * 2 + 1]) /
|
||||
@floatFromInt(f32, 0x7fff);
|
||||
const l = @as(f32, @floatFromInt(demo.audio.samples.items[(frame + i) * 2 + 0])) /
|
||||
@as(f32, @floatFromInt(0x7fff));
|
||||
const r = @as(f32, @floatFromInt(demo.audio.samples.items[(frame + i) * 2 + 1])) /
|
||||
@as(f32, @floatFromInt(0x7fff));
|
||||
break :blk (l + r) * 0.5;
|
||||
}
|
||||
};
|
||||
const x = -1.0 + 2.0 * @floatFromInt(f32, i) / @floatFromInt(f32, num_vis_samples - 1);
|
||||
const x = -1.0 + 2.0 * @as(f32, @floatFromInt(i)) / @as(f32, @floatFromInt(num_vis_samples - 1));
|
||||
upload.cpu_slice[i] = Vec2.init(0.95 * x, y);
|
||||
}
|
||||
gctx.cmdlist.CopyBufferRegion(
|
||||
@@ -460,7 +460,7 @@ pub fn main() !void {
|
||||
null,
|
||||
0,
|
||||
audioThread,
|
||||
@ptrCast(*anyopaque, &demo.audio),
|
||||
@as(*anyopaque, @ptrCast(&demo.audio)),
|
||||
0,
|
||||
null,
|
||||
).?;
|
||||
|
||||
@@ -159,14 +159,14 @@ fn loadMesh(
|
||||
try zmesh.io.appendMeshPrimitive(data, 0, 0, &indices, &positions, &normals, &texcoords0, &tangents);
|
||||
|
||||
var mesh = Mesh{
|
||||
.vertex_offset = @intCast(u32, pre_positions_len),
|
||||
.vertex_offset = @as(u32, @intCast(pre_positions_len)),
|
||||
.num_lods = 1,
|
||||
.lods = undefined,
|
||||
};
|
||||
|
||||
mesh.lods[0] = .{
|
||||
.index_offset = @intCast(u32, pre_indices_len),
|
||||
.num_indices = @intCast(u32, indices.items.len),
|
||||
.index_offset = @as(u32, @intCast(pre_indices_len)),
|
||||
.num_indices = @as(u32, @intCast(indices.items.len)),
|
||||
};
|
||||
|
||||
if (generate_lods > 0) {
|
||||
@@ -177,8 +177,8 @@ fn loadMesh(
|
||||
while (lod_index < generate_lods) : (lod_index += 1) {
|
||||
mesh.num_lods += 1;
|
||||
|
||||
const threshold: f32 = 1.0 - @floatFromInt(f32, lod_index) / @floatFromInt(f32, max_num_lods);
|
||||
const target_index_count: usize = @intFromFloat(usize, @floatFromInt(f32, indices.items.len) * threshold);
|
||||
const threshold: f32 = 1.0 - @as(f32, @floatFromInt(lod_index)) / @as(f32, @floatFromInt(max_num_lods));
|
||||
const target_index_count: usize = @as(usize, @intFromFloat(@as(f32, @floatFromInt(indices.items.len)) * threshold));
|
||||
const target_error: f32 = 1e-2;
|
||||
|
||||
var lod_indices = std.ArrayList(u32).init(arena);
|
||||
@@ -199,7 +199,7 @@ fn loadMesh(
|
||||
|
||||
mesh.lods[lod_index] = .{
|
||||
.index_offset = mesh.lods[lod_index - 1].index_offset + mesh.lods[lod_index - 1].num_indices,
|
||||
.num_indices = @intCast(u32, lod_indices_count),
|
||||
.num_indices = @as(u32, @intCast(lod_indices_count)),
|
||||
};
|
||||
|
||||
all_lods_indices.appendSlice(lod_indices.items) catch unreachable;
|
||||
@@ -233,23 +233,23 @@ fn drawToCubeTexture(
|
||||
) void {
|
||||
const desc = gctx.getResourceDesc(dest_texture);
|
||||
assert(dest_mip_level < desc.MipLevels);
|
||||
const texture_width = @intCast(u32, desc.Width) >> @intCast(u5, dest_mip_level);
|
||||
const texture_height = desc.Height >> @intCast(u5, dest_mip_level);
|
||||
const texture_width = @as(u32, @intCast(desc.Width)) >> @as(u5, @intCast(dest_mip_level));
|
||||
const texture_height = desc.Height >> @as(u5, @intCast(dest_mip_level));
|
||||
assert(texture_width == texture_height);
|
||||
|
||||
gctx.cmdlist.RSSetViewports(1, &[_]d3d12.VIEWPORT{.{
|
||||
.TopLeftX = 0.0,
|
||||
.TopLeftY = 0.0,
|
||||
.Width = @floatFromInt(f32, texture_width),
|
||||
.Height = @floatFromInt(f32, texture_height),
|
||||
.Width = @as(f32, @floatFromInt(texture_width)),
|
||||
.Height = @as(f32, @floatFromInt(texture_height)),
|
||||
.MinDepth = 0.0,
|
||||
.MaxDepth = 1.0,
|
||||
}});
|
||||
gctx.cmdlist.RSSetScissorRects(1, &[_]d3d12.RECT{.{
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.right = @intCast(c_long, texture_width),
|
||||
.bottom = @intCast(c_long, texture_height),
|
||||
.right = @as(c_long, @intCast(texture_width)),
|
||||
.bottom = @as(c_long, @intCast(texture_height)),
|
||||
}});
|
||||
gctx.cmdlist.IASetPrimitiveTopology(.TRIANGLELIST);
|
||||
|
||||
@@ -471,7 +471,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
.{ .COPY_DEST = true },
|
||||
null,
|
||||
) catch |err| hrPanic(err);
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @intCast(u32, all_vertices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @as(u32, @intCast(all_vertices.items.len)));
|
||||
for (all_vertices.items, 0..) |vertex, i| {
|
||||
upload.cpu_slice[i] = vertex;
|
||||
}
|
||||
@@ -494,7 +494,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
.{ .COPY_DEST = true },
|
||||
null,
|
||||
) catch |err| hrPanic(err);
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @intCast(u32, all_indices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @as(u32, @intCast(all_indices.items.len)));
|
||||
for (all_indices.items, 0..) |index, i| {
|
||||
upload.cpu_slice[i] = index;
|
||||
}
|
||||
@@ -796,12 +796,12 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
gctx.cmdlist.IASetVertexBuffers(0, 1, &[_]d3d12.VERTEX_BUFFER_VIEW{.{
|
||||
.BufferLocation = gctx.lookupResource(vertex_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(vertex_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(vertex_buffer))),
|
||||
.StrideInBytes = @sizeOf(Vertex),
|
||||
}});
|
||||
gctx.cmdlist.IASetIndexBuffer(&.{
|
||||
.BufferLocation = gctx.lookupResource(index_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(index_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(index_buffer))),
|
||||
.Format = .R32_UINT,
|
||||
});
|
||||
|
||||
@@ -833,9 +833,9 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
{
|
||||
var mip_level: u32 = 0;
|
||||
while (mip_level < prefiltered_env_texture_num_mip_levels) : (mip_level += 1) {
|
||||
const roughness = @floatFromInt(f32, mip_level) /
|
||||
@floatFromInt(f32, prefiltered_env_texture_num_mip_levels - 1);
|
||||
gctx.cmdlist.SetGraphicsRoot32BitConstant(1, @bitCast(u32, roughness), 0);
|
||||
const roughness = @as(f32, @floatFromInt(mip_level)) /
|
||||
@as(f32, @floatFromInt(prefiltered_env_texture_num_mip_levels - 1));
|
||||
gctx.cmdlist.SetGraphicsRoot32BitConstant(1, @as(u32, @bitCast(roughness)), 0);
|
||||
drawToCubeTexture(&gctx, prefiltered_env_texture.resource, mip_level);
|
||||
}
|
||||
}
|
||||
@@ -921,7 +921,7 @@ fn update(demo: *DemoState) void {
|
||||
common.newImGuiFrame(demo.frame_stats.delta_time);
|
||||
|
||||
c.igSetNextWindowPos(
|
||||
c.ImVec2{ .x = @floatFromInt(f32, demo.gctx.viewport_width) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImVec2{ .x = @as(f32, @floatFromInt(demo.gctx.viewport_width)) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImGuiCond_FirstUseEver,
|
||||
c.ImVec2{ .x = 0.0, .y = 0.0 },
|
||||
);
|
||||
@@ -944,8 +944,8 @@ fn update(demo: *DemoState) void {
|
||||
{
|
||||
var pos: w32.POINT = undefined;
|
||||
_ = w32.GetCursorPos(&pos);
|
||||
const delta_x = @floatFromInt(f32, pos.x) - @floatFromInt(f32, demo.mouse.cursor_prev_x);
|
||||
const delta_y = @floatFromInt(f32, pos.y) - @floatFromInt(f32, demo.mouse.cursor_prev_y);
|
||||
const delta_x = @as(f32, @floatFromInt(pos.x)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_x));
|
||||
const delta_y = @as(f32, @floatFromInt(pos.y)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_y));
|
||||
demo.mouse.cursor_prev_x = pos.x;
|
||||
demo.mouse.cursor_prev_y = pos.y;
|
||||
|
||||
@@ -993,7 +993,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = vm.Mat4.initPerspectiveFovLh(
|
||||
math.pi / 3.0,
|
||||
@floatFromInt(f32, gctx.viewport_width) / @floatFromInt(f32, gctx.viewport_height),
|
||||
@as(f32, @floatFromInt(gctx.viewport_width)) / @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
0.1,
|
||||
100.0,
|
||||
);
|
||||
@@ -1021,12 +1021,12 @@ fn draw(demo: *DemoState) void {
|
||||
gctx.cmdlist.IASetPrimitiveTopology(.TRIANGLELIST);
|
||||
gctx.cmdlist.IASetVertexBuffers(0, 1, &[_]d3d12.VERTEX_BUFFER_VIEW{.{
|
||||
.BufferLocation = gctx.lookupResource(demo.vertex_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(demo.vertex_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(demo.vertex_buffer))),
|
||||
.StrideInBytes = @sizeOf(Vertex),
|
||||
}});
|
||||
gctx.cmdlist.IASetIndexBuffer(&.{
|
||||
.BufferLocation = gctx.lookupResource(demo.index_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(demo.index_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(demo.index_buffer))),
|
||||
.Format = .R32_UINT,
|
||||
});
|
||||
|
||||
@@ -1045,7 +1045,7 @@ fn draw(demo: *DemoState) void {
|
||||
|
||||
// Draw SciFiHelmet.
|
||||
{
|
||||
const object_to_world = vm.Mat4.initRotationY(@floatCast(f32, 0.25 * demo.frame_stats.time));
|
||||
const object_to_world = vm.Mat4.initRotationY(@as(f32, @floatCast(0.25 * demo.frame_stats.time)));
|
||||
|
||||
const mem = gctx.allocateUploadMemory(Draw_Const, 1);
|
||||
mem.cpu_slice[0] = .{
|
||||
@@ -1066,10 +1066,10 @@ fn draw(demo: *DemoState) void {
|
||||
});
|
||||
|
||||
gctx.cmdlist.DrawIndexedInstanced(
|
||||
demo.meshes.items[mesh_helmet].lods[@intCast(usize, demo.current_lod)].num_indices,
|
||||
demo.meshes.items[mesh_helmet].lods[@as(usize, @intCast(demo.current_lod))].num_indices,
|
||||
1,
|
||||
demo.meshes.items[mesh_helmet].lods[@intCast(usize, demo.current_lod)].index_offset,
|
||||
@intCast(i32, demo.meshes.items[mesh_helmet].vertex_offset),
|
||||
demo.meshes.items[mesh_helmet].lods[@as(usize, @intCast(demo.current_lod))].index_offset,
|
||||
@as(i32, @intCast(demo.meshes.items[mesh_helmet].vertex_offset)),
|
||||
0,
|
||||
);
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ fn draw(demo: *DemoState) void {
|
||||
demo.meshes.items[mesh_cube].lods[0].num_indices,
|
||||
1,
|
||||
demo.meshes.items[mesh_cube].lods[0].index_offset,
|
||||
@intCast(i32, demo.meshes.items[mesh_cube].vertex_offset),
|
||||
@as(i32, @intCast(demo.meshes.items[mesh_cube].vertex_offset)),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ fn create(allocator: std.mem.Allocator, window: *zglfw.Window) !*DemoState {
|
||||
var normals = std.ArrayList([3]f32).init(arena);
|
||||
try initMeshes(arena, &common_shapes, &meshes, &indices, &positions, &normals);
|
||||
|
||||
const total_num_vertices = @intCast(u32, positions.items.len);
|
||||
const total_num_indices = @intCast(u32, indices.items.len);
|
||||
const total_num_vertices = @as(u32, @intCast(positions.items.len));
|
||||
const total_num_indices = @as(u32, @intCast(indices.items.len));
|
||||
|
||||
// Create a vertex buffer.
|
||||
const vertex_buf = gctx.createBuffer(.{
|
||||
@@ -336,7 +336,7 @@ fn update(demo: *DemoState) void {
|
||||
if (zgui.button(" Setup Scene ", .{})) {
|
||||
cleanupScene(demo.physics.world, &demo.physics.scene_shapes, &demo.entities);
|
||||
// Call scene-setup function.
|
||||
scenes[@intCast(usize, demo.current_scene_index)].setup(
|
||||
scenes[@as(usize, @intCast(demo.current_scene_index))].setup(
|
||||
demo.physics.world,
|
||||
demo.physics.common_shapes,
|
||||
&demo.physics.scene_shapes,
|
||||
@@ -347,7 +347,7 @@ fn update(demo: *DemoState) void {
|
||||
}
|
||||
// Gravity.
|
||||
{
|
||||
const is_enabled = scenes[@intCast(usize, demo.current_scene_index)].has_gravity_ui;
|
||||
const is_enabled = scenes[@as(usize, @intCast(demo.current_scene_index))].has_gravity_ui;
|
||||
if (!is_enabled) {
|
||||
zgui.beginDisabled(.{});
|
||||
}
|
||||
@@ -384,8 +384,8 @@ fn update(demo: *DemoState) void {
|
||||
// Handle camera rotation with mouse.
|
||||
{
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const delta_x = @floatCast(f32, cursor_pos[0] - demo.mouse.cursor_pos[0]);
|
||||
const delta_y = @floatCast(f32, cursor_pos[1] - demo.mouse.cursor_pos[1]);
|
||||
const delta_x = @as(f32, @floatCast(cursor_pos[0] - demo.mouse.cursor_pos[0]));
|
||||
const delta_y = @as(f32, @floatCast(cursor_pos[1] - demo.mouse.cursor_pos[1]));
|
||||
demo.mouse.cursor_pos = cursor_pos;
|
||||
|
||||
if (window.getMouseButton(.right) == .press) {
|
||||
@@ -460,7 +460,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
camera_fovy,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -500,7 +500,7 @@ fn draw(demo: *DemoState) void {
|
||||
var body_index: i32 = 0;
|
||||
while (body_index < num_bodies) : (body_index += 1) {
|
||||
const body = demo.physics.world.getBody(body_index);
|
||||
const entity = &demo.entities.items[@intCast(usize, body.getUserIndex(0))];
|
||||
const entity = &demo.entities.items[@as(usize, @intCast(body.getUserIndex(0)))];
|
||||
|
||||
// Get transform matrix from the physics simulator.
|
||||
const transform = object_to_world: {
|
||||
@@ -521,7 +521,7 @@ fn draw(demo: *DemoState) void {
|
||||
demo.meshes.items[entity.mesh_index].num_indices,
|
||||
1,
|
||||
demo.meshes.items[entity.mesh_index].index_offset,
|
||||
@intCast(i32, demo.meshes.items[entity.mesh_index].vertex_offset),
|
||||
@as(i32, @intCast(demo.meshes.items[entity.mesh_index].vertex_offset)),
|
||||
0,
|
||||
);
|
||||
}
|
||||
@@ -530,7 +530,7 @@ fn draw(demo: *DemoState) void {
|
||||
// Physics debug pass.
|
||||
pass: {
|
||||
demo.physics.world.debugDrawAll();
|
||||
const num_vertices = @intCast(u32, demo.physics.debug.lines.items.len);
|
||||
const num_vertices = @as(u32, @intCast(demo.physics.debug.lines.items.len));
|
||||
if (num_vertices == 0) break :pass;
|
||||
|
||||
var vb_info = gctx.lookupResourceInfo(demo.physics_debug_buf) orelse break :pass;
|
||||
@@ -680,7 +680,7 @@ fn setupScene0(
|
||||
}
|
||||
{
|
||||
const box = zbt.initBoxShape(&.{ 0.5, 1.0, 2.0 });
|
||||
box.setUserIndex(0, @intCast(i32, mesh_index_cube));
|
||||
box.setUserIndex(0, @as(i32, @intCast(mesh_index_cube)));
|
||||
scene_shapes.append(box.asShape()) catch unreachable;
|
||||
|
||||
const box_body = zbt.initBody(15.0, &zm.matToArr43(zm.translation(-5.0, 5.0, 5.0)), box.asShape());
|
||||
@@ -688,7 +688,7 @@ fn setupScene0(
|
||||
}
|
||||
{
|
||||
const sphere = zbt.initSphereShape(1.5);
|
||||
sphere.setUserIndex(0, @intCast(i32, mesh_index_sphere));
|
||||
sphere.setUserIndex(0, @as(i32, @intCast(mesh_index_sphere)));
|
||||
scene_shapes.append(sphere.asShape()) catch unreachable;
|
||||
|
||||
const sphere_body = zbt.initBody(
|
||||
@@ -728,14 +728,14 @@ fn setupScene1(
|
||||
|
||||
var j: u32 = 0;
|
||||
while (j < num_stacks) : (j += 1) {
|
||||
const theta = @floatFromInt(f32, j) * math.tau / @floatFromInt(f32, num_stacks);
|
||||
const theta = @as(f32, @floatFromInt(j)) * math.tau / @as(f32, @floatFromInt(num_stacks));
|
||||
const x = radius * @cos(theta);
|
||||
const z = radius * @sin(theta);
|
||||
var i: u32 = 0;
|
||||
while (i < num_cubes_per_stack) : (i += 1) {
|
||||
const box_body = zbt.initBody(
|
||||
2.5,
|
||||
&zm.matToArr43(zm.translation(x, 2.2 + @floatFromInt(f32, i) * 2.0 + 0.05, z)),
|
||||
&zm.matToArr43(zm.translation(x, 2.2 + @as(f32, @floatFromInt(i)) * 2.0 + 0.05, z)),
|
||||
common_shapes.items[mesh_index_cube],
|
||||
);
|
||||
createEntity(
|
||||
@@ -817,7 +817,7 @@ fn setupScene3(
|
||||
createEntity(world, world_body, .{ 0.25, 0.25, 0.25, 0.125 }, entities);
|
||||
|
||||
const box = zbt.initBoxShape(&.{ 0.5, 3.0, 1.5 });
|
||||
box.setUserIndex(0, @intCast(i32, mesh_index_cube));
|
||||
box.setUserIndex(0, @as(i32, @intCast(mesh_index_cube)));
|
||||
scene_shapes.append(box.asShape()) catch unreachable;
|
||||
|
||||
const mass: f32 = 10.0;
|
||||
@@ -830,7 +830,7 @@ fn setupScene3(
|
||||
while (j < heights.len) : (j += 1) {
|
||||
var i: u32 = 0;
|
||||
while (i < heights[j]) : (i += 1) {
|
||||
const y = 4.0 + @floatFromInt(f32, i) * 7.0;
|
||||
const y = 4.0 + @as(f32, @floatFromInt(i)) * 7.0;
|
||||
|
||||
const left_body = zbt.initBody(
|
||||
mass,
|
||||
@@ -864,7 +864,7 @@ fn setupScene3(
|
||||
const radius: f32 = 25.0;
|
||||
var i: u32 = 0;
|
||||
while (i < num_boxes) : (i += 1) {
|
||||
const theta = @floatFromInt(f32, i) * math.tau / @floatFromInt(f32, num_boxes);
|
||||
const theta = @as(f32, @floatFromInt(i)) * math.tau / @as(f32, @floatFromInt(num_boxes));
|
||||
const x = radius * @cos(theta);
|
||||
const z = radius * @sin(theta);
|
||||
|
||||
@@ -911,7 +911,7 @@ fn createEntity(
|
||||
entities: *std.ArrayList(Entity),
|
||||
) void {
|
||||
const shape = body.getShape();
|
||||
const mesh_index = @intCast(u32, shape.getUserIndex(0));
|
||||
const mesh_index = @as(u32, @intCast(shape.getUserIndex(0)));
|
||||
const mesh_size = switch (shape.getType()) {
|
||||
.box => mesh_size: {
|
||||
var half_extents: [3]f32 = undefined;
|
||||
@@ -935,7 +935,7 @@ fn createEntity(
|
||||
body.setCcdSweptSphereRadius(ccd_swept_sphere_radius);
|
||||
body.setCcdMotionThreshold(ccd_motion_threshold);
|
||||
}
|
||||
const entity_index = @intCast(i32, entities.items.len);
|
||||
const entity_index = @as(i32, @intCast(entities.items.len));
|
||||
entities.append(.{
|
||||
.body = body,
|
||||
.basecolor_roughness = basecolor_roughness,
|
||||
@@ -955,12 +955,12 @@ fn appendMesh(
|
||||
all_positions: *std.ArrayList([3]f32),
|
||||
all_normals: *std.ArrayList([3]f32),
|
||||
) !u32 {
|
||||
const mesh_index = @intCast(u32, all_meshes.items.len);
|
||||
const mesh_index = @as(u32, @intCast(all_meshes.items.len));
|
||||
try all_meshes.append(.{
|
||||
.index_offset = @intCast(u32, all_indices.items.len),
|
||||
.vertex_offset = @intCast(u32, all_positions.items.len),
|
||||
.num_indices = @intCast(u32, mesh.indices.len),
|
||||
.num_vertices = @intCast(u32, mesh.positions.len),
|
||||
.index_offset = @as(u32, @intCast(all_indices.items.len)),
|
||||
.vertex_offset = @as(u32, @intCast(all_positions.items.len)),
|
||||
.num_indices = @as(u32, @intCast(mesh.indices.len)),
|
||||
.num_vertices = @as(u32, @intCast(mesh.positions.len)),
|
||||
});
|
||||
try all_indices.appendSlice(mesh.indices);
|
||||
try all_positions.appendSlice(mesh.positions);
|
||||
@@ -992,7 +992,7 @@ fn initMeshes(
|
||||
assert(mesh_index == mesh_index_cube);
|
||||
|
||||
shapes.items[mesh_index] = zbt.initBoxShape(&.{ 1.0, 1.0, 1.0 }).asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index)));
|
||||
}
|
||||
|
||||
// Parametric sphere mesh.
|
||||
@@ -1006,7 +1006,7 @@ fn initMeshes(
|
||||
assert(mesh_index == mesh_index_sphere);
|
||||
|
||||
shapes.items[mesh_index] = zbt.initSphereShape(1.0).asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index)));
|
||||
}
|
||||
|
||||
// Cylinder mesh.
|
||||
@@ -1037,7 +1037,7 @@ fn initMeshes(
|
||||
assert(mesh_index == mesh_index_cylinder);
|
||||
|
||||
shapes.items[mesh_index] = zbt.initCylinderShape(&.{ 1.0, 1.0, 1.0 }, .y).asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index)));
|
||||
}
|
||||
|
||||
// Capsule mesh.
|
||||
@@ -1066,7 +1066,7 @@ fn initMeshes(
|
||||
assert(mesh_index == mesh_index_capsule);
|
||||
|
||||
shapes.items[mesh_index] = zbt.initCapsuleShape(1.0, 1.0, .y).asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index)));
|
||||
}
|
||||
|
||||
// Compound0 mesh.
|
||||
@@ -1103,7 +1103,7 @@ fn initMeshes(
|
||||
compound.addChild(&zm.matToArr43(zm.translation(0.0, 2.0, 0.0)), shapes.items[mesh_index_cube]);
|
||||
compound.addChild(&zm.matToArr43(zm.translation(0.0, -2.0, 0.0)), shapes.items[mesh_index_cube]);
|
||||
shapes.items[mesh_index] = compound.asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index_compound0));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index_compound0)));
|
||||
}
|
||||
|
||||
// Compound1 mesh.
|
||||
@@ -1143,14 +1143,14 @@ fn initMeshes(
|
||||
compound.addChild(&zm.matToArr43(zm.translation(0.0, 4.0, 0.0)), shapes.items[mesh_index_sphere]);
|
||||
compound.addChild(&zm.matToArr43(zm.translation(0.0, 2.5, 0.0)), cylinder_shape);
|
||||
shapes.items[mesh_index] = compound.asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index_compound1));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index_compound1)));
|
||||
}
|
||||
|
||||
// World mesh.
|
||||
{
|
||||
const mesh_index = @intCast(u32, all_meshes.items.len);
|
||||
const index_offset = @intCast(u32, all_indices.items.len);
|
||||
const vertex_offset = @intCast(u32, all_positions.items.len);
|
||||
const mesh_index = @as(u32, @intCast(all_meshes.items.len));
|
||||
const index_offset = @as(u32, @intCast(all_indices.items.len));
|
||||
const vertex_offset = @as(u32, @intCast(all_positions.items.len));
|
||||
|
||||
var indices = std.ArrayList(u32).init(arena);
|
||||
defer indices.deinit();
|
||||
@@ -1168,28 +1168,28 @@ fn initMeshes(
|
||||
for (indices.items, 0..) |ind, i| {
|
||||
try all_positions.append(positions.items[ind]);
|
||||
try all_normals.append(normals.items[ind]);
|
||||
try all_indices.append(@intCast(u32, i));
|
||||
try all_indices.append(@as(u32, @intCast(i)));
|
||||
}
|
||||
|
||||
try all_meshes.append(.{
|
||||
.index_offset = index_offset,
|
||||
.vertex_offset = vertex_offset,
|
||||
.num_indices = @intCast(u32, all_indices.items.len) - index_offset,
|
||||
.num_vertices = @intCast(u32, all_positions.items.len) - vertex_offset,
|
||||
.num_indices = @as(u32, @intCast(all_indices.items.len)) - index_offset,
|
||||
.num_vertices = @as(u32, @intCast(all_positions.items.len)) - vertex_offset,
|
||||
});
|
||||
|
||||
const trimesh = zbt.initTriangleMeshShape();
|
||||
trimesh.addIndexVertexArray(
|
||||
@intCast(u32, indices.items.len / 3),
|
||||
@as(u32, @intCast(indices.items.len / 3)),
|
||||
indices.items.ptr,
|
||||
@sizeOf([3]u32),
|
||||
@intCast(u32, positions.items.len),
|
||||
@as(u32, @intCast(positions.items.len)),
|
||||
positions.items.ptr,
|
||||
@sizeOf([3]f32),
|
||||
);
|
||||
trimesh.finish();
|
||||
shapes.items[mesh_index] = trimesh.asShape();
|
||||
shapes.items[mesh_index].setUserIndex(0, @intCast(i32, mesh_index));
|
||||
shapes.items[mesh_index].setUserIndex(0, @as(i32, @intCast(mesh_index)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1201,14 +1201,14 @@ fn objectPicking(demo: *DemoState, want_capture_mouse: bool) void {
|
||||
const ray_from = zm.loadArr3(demo.camera.position);
|
||||
const ray_to = ray_to: {
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const mousex = @floatCast(f32, cursor_pos[0]);
|
||||
const mousey = @floatCast(f32, cursor_pos[1]);
|
||||
const mousex = @as(f32, @floatCast(cursor_pos[0]));
|
||||
const mousey = @as(f32, @floatCast(cursor_pos[1]));
|
||||
|
||||
const far_plane = zm.f32x4s(10_000.0);
|
||||
const tanfov = zm.f32x4s(@tan(0.5 * camera_fovy));
|
||||
const winsize = window.getSize();
|
||||
const width = @floatFromInt(f32, winsize[0]);
|
||||
const height = @floatFromInt(f32, winsize[1]);
|
||||
const width = @as(f32, @floatFromInt(winsize[0]));
|
||||
const height = @as(f32, @floatFromInt(winsize[1]));
|
||||
const aspect = zm.f32x4s(width / height);
|
||||
|
||||
const ray_forward = zm.loadArr3(demo.camera.forward) * far_plane;
|
||||
|
||||
@@ -125,11 +125,11 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
var dml_device: *dml.IDevice1 = undefined;
|
||||
hrPanicOnFail(dml.createDevice(
|
||||
@ptrCast(*d3d12.IDevice, gctx.device),
|
||||
@as(*d3d12.IDevice, @ptrCast(gctx.device)),
|
||||
.{ .DEBUG = enable_dx_debug },
|
||||
.@"4_1",
|
||||
&dml.IID_IDevice1,
|
||||
@ptrCast(*?*anyopaque, &dml_device),
|
||||
@as(*?*anyopaque, @ptrCast(&dml_device)),
|
||||
));
|
||||
|
||||
const input_tensor_desc = dml.TENSOR_DESC{
|
||||
@@ -197,7 +197,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
};
|
||||
|
||||
var op: *dml.IOperator = undefined;
|
||||
hrPanicOnFail(dml_device.CreateOperator(&desc, &dml.IID_IOperator, @ptrCast(*?*anyopaque, &op)));
|
||||
hrPanicOnFail(dml_device.CreateOperator(&desc, &dml.IID_IOperator, @as(*?*anyopaque, @ptrCast(&op))));
|
||||
break :blk op;
|
||||
};
|
||||
defer _ = conv_op.Release();
|
||||
@@ -208,7 +208,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
conv_op,
|
||||
.{},
|
||||
&dml.IID_ICompiledOperator,
|
||||
@ptrCast(*?*anyopaque, &cop),
|
||||
@as(*?*anyopaque, @ptrCast(&cop)),
|
||||
));
|
||||
break :blk cop;
|
||||
};
|
||||
@@ -221,7 +221,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
operators.len,
|
||||
&operators,
|
||||
&dml.IID_IOperatorInitializer,
|
||||
@ptrCast(*?*anyopaque, &iop),
|
||||
@as(*?*anyopaque, @ptrCast(&iop)),
|
||||
));
|
||||
break :blk iop;
|
||||
};
|
||||
@@ -321,7 +321,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
var dml_cmd_recorder: *dml.ICommandRecorder = undefined;
|
||||
hrPanicOnFail(dml_device.CreateCommandRecorder(
|
||||
&dml.IID_ICommandRecorder,
|
||||
@ptrCast(*?*anyopaque, &dml_cmd_recorder),
|
||||
@as(*?*anyopaque, @ptrCast(&dml_cmd_recorder)),
|
||||
));
|
||||
break :blk dml_cmd_recorder;
|
||||
};
|
||||
@@ -368,14 +368,14 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
const conv_op_state = blk: {
|
||||
const base_descriptor = gctx.allocateGpuDescriptors(conv_info.RequiredDescriptorCount);
|
||||
const desc = dml.BINDING_TABLE_DESC{
|
||||
.Dispatchable = @ptrCast(*dml.IDispatchable, conv_cop),
|
||||
.Dispatchable = @as(*dml.IDispatchable, @ptrCast(conv_cop)),
|
||||
.CPUDescriptorHandle = base_descriptor.cpu_handle,
|
||||
.GPUDescriptorHandle = base_descriptor.gpu_handle,
|
||||
.SizeInDescriptors = conv_info.RequiredDescriptorCount,
|
||||
};
|
||||
|
||||
var table: *dml.IBindingTable = undefined;
|
||||
hrPanicOnFail(dml_device.CreateBindingTable(&desc, &dml.IID_IBindingTable, @ptrCast(*?*anyopaque, &table)));
|
||||
hrPanicOnFail(dml_device.CreateBindingTable(&desc, &dml.IID_IBindingTable, @as(*?*anyopaque, @ptrCast(&table))));
|
||||
|
||||
break :blk .{
|
||||
.cop = conv_cop,
|
||||
@@ -387,14 +387,14 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
const init_dtbl = blk: {
|
||||
const base_descriptor = gctx.allocateGpuDescriptors(init_info.RequiredDescriptorCount + 1);
|
||||
const desc = dml.BINDING_TABLE_DESC{
|
||||
.Dispatchable = @ptrCast(*dml.IDispatchable, init_op),
|
||||
.Dispatchable = @as(*dml.IDispatchable, @ptrCast(init_op)),
|
||||
.CPUDescriptorHandle = base_descriptor.cpu_handle,
|
||||
.GPUDescriptorHandle = base_descriptor.gpu_handle,
|
||||
.SizeInDescriptors = init_info.RequiredDescriptorCount,
|
||||
};
|
||||
|
||||
var table: *dml.IBindingTable = undefined;
|
||||
hrPanicOnFail(dml_device.CreateBindingTable(&desc, &dml.IID_IBindingTable, @ptrCast(*?*anyopaque, &table)));
|
||||
hrPanicOnFail(dml_device.CreateBindingTable(&desc, &dml.IID_IBindingTable, @as(*?*anyopaque, @ptrCast(&table))));
|
||||
break :blk table;
|
||||
};
|
||||
defer _ = init_dtbl.Release();
|
||||
@@ -429,8 +429,8 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
}
|
||||
|
||||
dml_cmd_recorder.RecordDispatch(
|
||||
@ptrCast(*d3d12.ICommandList, gctx.cmdlist),
|
||||
@ptrCast(*dml.IDispatchable, init_op),
|
||||
@as(*d3d12.ICommandList, @ptrCast(gctx.cmdlist)),
|
||||
@as(*dml.IDispatchable, @ptrCast(init_op)),
|
||||
init_dtbl,
|
||||
);
|
||||
|
||||
@@ -486,7 +486,7 @@ fn dispatchConvOperator(demo: *DemoState) void {
|
||||
const base_descriptor = gctx.allocateGpuDescriptors(num_descriptors);
|
||||
|
||||
hrPanicOnFail(demo.conv_op_state.dtbl.Reset(&dml.BINDING_TABLE_DESC{
|
||||
.Dispatchable = @ptrCast(*dml.IDispatchable, demo.conv_op_state.cop),
|
||||
.Dispatchable = @as(*dml.IDispatchable, @ptrCast(demo.conv_op_state.cop)),
|
||||
.CPUDescriptorHandle = base_descriptor.cpu_handle,
|
||||
.GPUDescriptorHandle = base_descriptor.gpu_handle,
|
||||
.SizeInDescriptors = num_descriptors,
|
||||
@@ -552,8 +552,8 @@ fn dispatchConvOperator(demo: *DemoState) void {
|
||||
}});
|
||||
|
||||
demo.dml_cmd_recorder.RecordDispatch(
|
||||
@ptrCast(*d3d12.ICommandList, gctx.cmdlist),
|
||||
@ptrCast(*dml.IDispatchable, demo.conv_op_state.cop),
|
||||
@as(*d3d12.ICommandList, @ptrCast(gctx.cmdlist)),
|
||||
@as(*dml.IDispatchable, @ptrCast(demo.conv_op_state.cop)),
|
||||
demo.conv_op_state.dtbl,
|
||||
);
|
||||
}
|
||||
@@ -644,8 +644,8 @@ fn draw(demo: *DemoState) void {
|
||||
gctx.cmdlist.RSSetViewports(1, &[_]d3d12.VIEWPORT{.{
|
||||
.TopLeftX = 0.0,
|
||||
.TopLeftY = 0.0,
|
||||
.Width = @floatFromInt(f32, gctx.viewport_width / 2),
|
||||
.Height = @floatFromInt(f32, gctx.viewport_width / 2),
|
||||
.Width = @as(f32, @floatFromInt(gctx.viewport_width / 2)),
|
||||
.Height = @as(f32, @floatFromInt(gctx.viewport_width / 2)),
|
||||
.MinDepth = 0.0,
|
||||
.MaxDepth = 1.0,
|
||||
}});
|
||||
@@ -674,10 +674,10 @@ fn draw(demo: *DemoState) void {
|
||||
gctx.flushResourceBarriers();
|
||||
|
||||
gctx.cmdlist.RSSetViewports(1, &[_]d3d12.VIEWPORT{.{
|
||||
.TopLeftX = @floatFromInt(f32, gctx.viewport_width / 2),
|
||||
.TopLeftX = @as(f32, @floatFromInt(gctx.viewport_width / 2)),
|
||||
.TopLeftY = 0.0,
|
||||
.Width = @floatFromInt(f32, gctx.viewport_width / 2),
|
||||
.Height = @floatFromInt(f32, gctx.viewport_width / 2),
|
||||
.Width = @as(f32, @floatFromInt(gctx.viewport_width / 2)),
|
||||
.Height = @as(f32, @floatFromInt(gctx.viewport_width / 2)),
|
||||
.MinDepth = 0.0,
|
||||
.MaxDepth = 1.0,
|
||||
}});
|
||||
|
||||
@@ -123,7 +123,7 @@ fn update(allocator: std.mem.Allocator, demo: *DemoState) !void {
|
||||
try std.fmt.allocPrintZ(arena.allocator(), "Joystick {}", .{jid + 1}),
|
||||
.{},
|
||||
)) {
|
||||
if (zglfw.Joystick.get(@intCast(zglfw.Joystick.Id, jid))) |joystick| {
|
||||
if (zglfw.Joystick.get(@as(zglfw.Joystick.Id, @intCast(jid)))) |joystick| {
|
||||
zgui.text("Present: yes", .{});
|
||||
zgui.newLine();
|
||||
zgui.beginGroup();
|
||||
|
||||
@@ -253,7 +253,7 @@ fn update(demo: *DemoState) !void {
|
||||
const items = [_][:0]const u8{ "aaa", "bbb", "ccc", "ddd", "eee", "FFF", "ggg", "hhh" };
|
||||
if (zgui.beginCombo("Combo 0", .{ .preview_value = items[static.selection_index] })) {
|
||||
for (items, 0..) |item, index| {
|
||||
const i = @intCast(u32, index);
|
||||
const i = @as(u32, @intCast(index));
|
||||
if (zgui.selectable(item, .{ .selected = static.selection_index == i }))
|
||||
static.selection_index = i;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ fn update(demo: *DemoState) !void {
|
||||
const items = [_][:0]const u8{ "aaa", "bbb", "ccc", "ddd", "eee", "FFF", "ggg", "hhh" };
|
||||
if (zgui.beginListBox("List Box 0", .{})) {
|
||||
for (items, 0..) |item, index| {
|
||||
const i = @intCast(u32, index);
|
||||
const i = @as(u32, @intCast(index));
|
||||
if (zgui.selectable(item, .{ .selected = static.selection_index == i }))
|
||||
static.selection_index = i;
|
||||
}
|
||||
@@ -547,7 +547,7 @@ fn update(demo: *DemoState) !void {
|
||||
.p = .{ 200, 700 },
|
||||
.r = 30,
|
||||
.col = zgui.colorConvertFloat3ToU32([_]f32{ 1, 1, 0 }),
|
||||
.thickness = 15 + 15 * @floatCast(f32, @sin(demo.gctx.stats.time)),
|
||||
.thickness = 15 + 15 * @as(f32, @floatCast(@sin(demo.gctx.stats.time))),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -317,10 +317,10 @@ const DemoState = struct {
|
||||
const gctx = demo.gctx;
|
||||
|
||||
const vertex_count = 2 * (segments + 1);
|
||||
var vertex_data = try allocator.alloc(Vertex, @intCast(usize, vertex_count));
|
||||
var vertex_data = try allocator.alloc(Vertex, @as(usize, @intCast(vertex_count)));
|
||||
defer allocator.free(vertex_data);
|
||||
|
||||
var index_data = try allocator.alloc(u16, @intCast(usize, vertex_count));
|
||||
var index_data = try allocator.alloc(u16, @as(usize, @intCast(vertex_count)));
|
||||
defer allocator.free(index_data);
|
||||
|
||||
vertex_generator.pill(segments, vertex_data, index_data);
|
||||
@@ -401,7 +401,7 @@ const DemoState = struct {
|
||||
.{ .v = &single_pill.segments, .min = 2, .max = 20 },
|
||||
);
|
||||
if (tab_activated or init_buffers or needs_vertex_update) {
|
||||
const segments = @intCast(u16, single_pill.segments);
|
||||
const segments = @as(u16, @intCast(single_pill.segments));
|
||||
try demo.recreateVertexBuffers(segments, allocator);
|
||||
demo.recreateInstanceBuffer(1);
|
||||
}
|
||||
@@ -458,8 +458,8 @@ const DemoState = struct {
|
||||
const scale = gctx.window.getContentScale();
|
||||
const screen_to_clip = zm.mul(
|
||||
zm.scaling(
|
||||
2 * scale[0] / @floatFromInt(f32, gctx.swapchain_descriptor.width),
|
||||
-2 * scale[1] / @floatFromInt(f32, gctx.swapchain_descriptor.height),
|
||||
2 * scale[0] / @as(f32, @floatFromInt(gctx.swapchain_descriptor.width)),
|
||||
-2 * scale[1] / @as(f32, @floatFromInt(gctx.swapchain_descriptor.height)),
|
||||
1,
|
||||
),
|
||||
zm.translation(-1, 1, 0.0),
|
||||
@@ -468,8 +468,8 @@ const DemoState = struct {
|
||||
|
||||
const cursor_position = demo.gctx.window.getCursorPos();
|
||||
const screen_position = zm.f32x4(
|
||||
@floatCast(f32, cursor_position[0]),
|
||||
@floatCast(f32, cursor_position[1]),
|
||||
@as(f32, @floatCast(cursor_position[0])),
|
||||
@as(f32, @floatCast(cursor_position[1])),
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
@@ -568,7 +568,7 @@ const DemoState = struct {
|
||||
.{ .v = &multiple_pills.segments, .min = 2, .max = 20 },
|
||||
);
|
||||
if (tab_activated or needs_vertex_update) {
|
||||
const segments = @intCast(u16, multiple_pills.segments);
|
||||
const segments = @as(u16, @intCast(multiple_pills.segments));
|
||||
try demo.recreateVertexBuffers(segments, allocator);
|
||||
}
|
||||
const InstanceValues = [_]usize{ 1000, 10000, 100000, 1000000 };
|
||||
@@ -577,10 +577,10 @@ const DemoState = struct {
|
||||
.v = &multiple_pills.instance_index,
|
||||
.min = 0,
|
||||
.max = InstanceValues.len - 1,
|
||||
.cfmt = InstanceStrings[@intCast(usize, multiple_pills.instance_index)],
|
||||
.cfmt = InstanceStrings[@as(usize, @intCast(multiple_pills.instance_index))],
|
||||
});
|
||||
if (tab_activated or need_instance_update) {
|
||||
const instances = InstanceValues[@intCast(usize, multiple_pills.instance_index)];
|
||||
const instances = InstanceValues[@as(usize, @intCast(multiple_pills.instance_index))];
|
||||
demo.pills.clearRetainingCapacity();
|
||||
var i: usize = 0;
|
||||
while (i < instances) : (i += 1) {
|
||||
@@ -668,7 +668,7 @@ const DemoState = struct {
|
||||
mem.slice[0] = zm.transpose(object_to_clip);
|
||||
|
||||
pass.setBindGroup(0, bind_group, &.{mem.offset});
|
||||
pass.drawIndexed(demo.vertex_count, @intCast(u32, demo.pills.items.len), 0, 0, 0);
|
||||
pass.drawIndexed(demo.vertex_count, @as(u32, @intCast(demo.pills.items.len)), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -715,10 +715,10 @@ fn ensureFourByteMultiple(size: usize) usize {
|
||||
}
|
||||
|
||||
fn calculateDimensions(gctx: *zgpu.GraphicsContext) Dimension {
|
||||
const width = @floatFromInt(f32, gctx.swapchain_descriptor.width);
|
||||
const height = @floatFromInt(f32, gctx.swapchain_descriptor.height);
|
||||
const width = @as(f32, @floatFromInt(gctx.swapchain_descriptor.width));
|
||||
const height = @as(f32, @floatFromInt(gctx.swapchain_descriptor.height));
|
||||
const delta = math.sign(
|
||||
@bitCast(i32, gctx.swapchain_descriptor.width) - @bitCast(i32, gctx.swapchain_descriptor.height),
|
||||
@as(i32, @bitCast(gctx.swapchain_descriptor.width)) - @as(i32, @bitCast(gctx.swapchain_descriptor.height)),
|
||||
);
|
||||
return switch (delta) {
|
||||
-1 => .{ .width = 2.0, .height = 2 * width / height },
|
||||
|
||||
@@ -18,7 +18,7 @@ pub fn pill(segments: u16, vertex_data: []Vertex, index_data: []u16) void {
|
||||
{
|
||||
var i: usize = 0;
|
||||
while (i <= segments) : (i += 1) {
|
||||
const angle = lerp(3.0 * tau / 4.0, tau / 4.0, @floatFromInt(f32, i) / @floatFromInt(f32, segments));
|
||||
const angle = lerp(3.0 * tau / 4.0, tau / 4.0, @as(f32, @floatFromInt(i)) / @as(f32, @floatFromInt(segments)));
|
||||
vertex_data[i] = .{
|
||||
.position = .{ @cos(angle), @sin(angle) },
|
||||
.side = -1.0,
|
||||
@@ -43,7 +43,7 @@ pub fn pill(segments: u16, vertex_data: []Vertex, index_data: []u16) void {
|
||||
index_data[i + 1] = down;
|
||||
up += 1;
|
||||
if (down == 0) {
|
||||
down = @intCast(u16, index_data.len);
|
||||
down = @as(u16, @intCast(index_data.len));
|
||||
}
|
||||
down -= 1;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ pub const State = struct {
|
||||
} else null,
|
||||
.pipeline = layer.pipeline,
|
||||
|
||||
.vertex_count = @intCast(u32, layer.vertices.items.len),
|
||||
.vertex_count = @as(u32, @intCast(layer.vertices.items.len)),
|
||||
.vertex_buffer = layer.vertex_buffer,
|
||||
.index_buffer = layer.index_buffer,
|
||||
|
||||
.instance_count = @intCast(u32, layer.instances.items.len),
|
||||
.instance_count = @as(u32, @intCast(layer.instances.items.len)),
|
||||
.instance_buffer = layer.instance_buffer,
|
||||
});
|
||||
}
|
||||
@@ -271,10 +271,10 @@ pub const State = struct {
|
||||
};
|
||||
|
||||
fn calculateDimensions(gctx: *zgpu.GraphicsContext) Dimension {
|
||||
const width = @floatFromInt(f32, gctx.swapchain_descriptor.width);
|
||||
const height = @floatFromInt(f32, gctx.swapchain_descriptor.height);
|
||||
const width = @as(f32, @floatFromInt(gctx.swapchain_descriptor.width));
|
||||
const height = @as(f32, @floatFromInt(gctx.swapchain_descriptor.height));
|
||||
const delta = math.sign(
|
||||
@bitCast(i32, gctx.swapchain_descriptor.width) - @bitCast(i32, gctx.swapchain_descriptor.height),
|
||||
@as(i32, @bitCast(gctx.swapchain_descriptor.width)) - @as(i32, @bitCast(gctx.swapchain_descriptor.height)),
|
||||
);
|
||||
return switch (delta) {
|
||||
-1 => .{ .width = 2.0, .height = 2 * width / height },
|
||||
|
||||
@@ -152,12 +152,12 @@ pub fn Layer(comptime Vertex: type, comptime Instance: type) type {
|
||||
|
||||
const vertex_buffers = [_]wgpu.VertexBufferLayout{ .{
|
||||
.array_stride = @sizeOf(Vertex),
|
||||
.attribute_count = @intCast(u32, vertex_attributes.len),
|
||||
.attribute_count = @as(u32, @intCast(vertex_attributes.len)),
|
||||
.attributes = vertex_attributes.ptr,
|
||||
}, .{
|
||||
.array_stride = @sizeOf(Instance),
|
||||
.step_mode = .instance,
|
||||
.attribute_count = @intCast(u32, instance_attributes.len),
|
||||
.attribute_count = @as(u32, @intCast(instance_attributes.len)),
|
||||
.attributes = instance_attributes.ptr,
|
||||
} };
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn generateVertices(segments: u16, verticies: *std.ArrayList(Vertex)) !void
|
||||
{
|
||||
var i: usize = 0;
|
||||
while (i <= segments) : (i += 1) {
|
||||
const angle = lerp(3.0 * tau / 4.0, tau / 4.0, @floatFromInt(f32, i) / @floatFromInt(f32, segments));
|
||||
const angle = lerp(3.0 * tau / 4.0, tau / 4.0, @as(f32, @floatFromInt(i)) / @as(f32, @floatFromInt(segments)));
|
||||
try verticies.append(.{
|
||||
.position = .{ @cos(angle), @sin(angle) },
|
||||
.side = -1.0,
|
||||
|
||||
@@ -208,19 +208,19 @@ fn loadMeshAndGenerateMeshlets(
|
||||
try meshlets.resize(num_meshlets);
|
||||
|
||||
try all_meshes.append(.{
|
||||
.index_offset = @intCast(u32, all_indices.items.len),
|
||||
.vertex_offset = @intCast(u32, all_vertices.items.len),
|
||||
.meshlet_offset = @intCast(u32, all_meshlets.items.len),
|
||||
.num_indices = @intCast(u32, opt_indices.items.len),
|
||||
.num_vertices = @intCast(u32, opt_vertices.items.len),
|
||||
.num_meshlets = @intCast(u32, meshlets.items.len),
|
||||
.index_offset = @as(u32, @intCast(all_indices.items.len)),
|
||||
.vertex_offset = @as(u32, @intCast(all_vertices.items.len)),
|
||||
.meshlet_offset = @as(u32, @intCast(all_meshlets.items.len)),
|
||||
.num_indices = @as(u32, @intCast(opt_indices.items.len)),
|
||||
.num_vertices = @as(u32, @intCast(opt_vertices.items.len)),
|
||||
.num_meshlets = @as(u32, @intCast(meshlets.items.len)),
|
||||
});
|
||||
|
||||
for (meshlets.items) |src_meshlet| {
|
||||
const meshlet = Meshlet{
|
||||
.data_offset = @intCast(u32, all_meshlets_data.items.len),
|
||||
.num_vertices = @intCast(u16, src_meshlet.vertex_count),
|
||||
.num_triangles = @intCast(u16, src_meshlet.triangle_count),
|
||||
.data_offset = @as(u32, @intCast(all_meshlets_data.items.len)),
|
||||
.num_vertices = @as(u16, @intCast(src_meshlet.vertex_count)),
|
||||
.num_triangles = @as(u16, @intCast(src_meshlet.triangle_count)),
|
||||
};
|
||||
try all_meshlets.append(meshlet);
|
||||
|
||||
@@ -231,10 +231,10 @@ fn loadMeshAndGenerateMeshlets(
|
||||
|
||||
i = 0;
|
||||
while (i < src_meshlet.triangle_count) : (i += 1) {
|
||||
const index0 = @intCast(u10, meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 0]);
|
||||
const index1 = @intCast(u10, meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 1]);
|
||||
const index2 = @intCast(u10, meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 2]);
|
||||
const prim = @intCast(u32, index0) | (@intCast(u32, index1) << 10) | (@intCast(u32, index2) << 20);
|
||||
const index0 = @as(u10, @intCast(meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 0]));
|
||||
const index1 = @as(u10, @intCast(meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 1]));
|
||||
const index2 = @as(u10, @intCast(meshlet_triangles.items[src_meshlet.triangle_offset + i * 3 + 2]));
|
||||
const prim = @as(u32, @intCast(index0)) | (@as(u32, @intCast(index1)) << 10) | (@as(u32, @intCast(index2)) << 20);
|
||||
try all_meshlets_data.append(prim);
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
gctx.lookupResource(vertex_buffer).?,
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initStructuredBuffer(
|
||||
0,
|
||||
@intCast(u32, all_vertices.items.len),
|
||||
@as(u32, @intCast(all_vertices.items.len)),
|
||||
@sizeOf(Vertex),
|
||||
),
|
||||
srv,
|
||||
@@ -394,7 +394,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
const srv = gctx.allocateCpuDescriptors(.CBV_SRV_UAV, 1);
|
||||
gctx.device.CreateShaderResourceView(
|
||||
gctx.lookupResource(index_buffer).?,
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initTypedBuffer(.R32_UINT, 0, @intCast(u32, all_indices.items.len)),
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initTypedBuffer(.R32_UINT, 0, @as(u32, @intCast(all_indices.items.len))),
|
||||
srv,
|
||||
);
|
||||
break :blk srv;
|
||||
@@ -414,7 +414,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
gctx.lookupResource(meshlet_buffer).?,
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initStructuredBuffer(
|
||||
0,
|
||||
@intCast(u32, all_meshlets.items.len),
|
||||
@as(u32, @intCast(all_meshlets.items.len)),
|
||||
@sizeOf(Meshlet),
|
||||
),
|
||||
srv,
|
||||
@@ -437,7 +437,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initTypedBuffer(
|
||||
.R32_UINT,
|
||||
0,
|
||||
@intCast(u32, all_meshlets_data.items.len),
|
||||
@as(u32, @intCast(all_meshlets_data.items.len)),
|
||||
),
|
||||
srv,
|
||||
);
|
||||
@@ -471,7 +471,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
// Upload vertex buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @intCast(u32, all_vertices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @as(u32, @intCast(all_vertices.items.len)));
|
||||
for (all_vertices.items, 0..) |vertex, i| upload.cpu_slice[i] = vertex;
|
||||
gctx.cmdlist.CopyBufferRegion(
|
||||
gctx.lookupResource(vertex_buffer).?,
|
||||
@@ -486,7 +486,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
// Upload index buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @intCast(u32, all_indices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @as(u32, @intCast(all_indices.items.len)));
|
||||
for (all_indices.items, 0..) |index, i| upload.cpu_slice[i] = index;
|
||||
gctx.cmdlist.CopyBufferRegion(
|
||||
gctx.lookupResource(index_buffer).?,
|
||||
@@ -501,7 +501,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
// Upload meshlet buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(Meshlet, @intCast(u32, all_meshlets.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(Meshlet, @as(u32, @intCast(all_meshlets.items.len)));
|
||||
for (all_meshlets.items, 0..) |meshlet, i| upload.cpu_slice[i] = meshlet;
|
||||
gctx.cmdlist.CopyBufferRegion(
|
||||
gctx.lookupResource(meshlet_buffer).?,
|
||||
@@ -516,7 +516,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
// Upload meshlet data buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @intCast(u32, all_meshlets_data.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @as(u32, @intCast(all_meshlets_data.items.len)));
|
||||
for (all_meshlets_data.items, 0..) |meshlet_data, i| upload.cpu_slice[i] = meshlet_data;
|
||||
gctx.cmdlist.CopyBufferRegion(
|
||||
gctx.lookupResource(meshlet_data_buffer).?,
|
||||
@@ -580,7 +580,7 @@ fn update(demo: *DemoState) void {
|
||||
common.newImGuiFrame(dt);
|
||||
|
||||
c.igSetNextWindowPos(
|
||||
c.ImVec2{ .x = @floatFromInt(f32, demo.gctx.viewport_width) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImVec2{ .x = @as(f32, @floatFromInt(demo.gctx.viewport_width)) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImGuiCond_FirstUseEver,
|
||||
c.ImVec2{ .x = 0.0, .y = 0.0 },
|
||||
);
|
||||
@@ -612,7 +612,7 @@ fn update(demo: *DemoState) void {
|
||||
_ = c.igRadioButton_IntPtr("Mesh Shader emulating VS (no culling)", &draw_mode, 0);
|
||||
_ = c.igRadioButton_IntPtr("VS with manual vertex fetching (no HW index buffer)", &draw_mode, 1);
|
||||
_ = c.igRadioButton_IntPtr("VS with fixed function vertex fetching", &draw_mode, 2);
|
||||
demo.draw_mode = @enumFromInt(DrawMode, draw_mode);
|
||||
demo.draw_mode = @as(DrawMode, @enumFromInt(draw_mode));
|
||||
|
||||
_ = c.igSliderInt("Num. objects", &demo.num_objects_to_draw, 1, 1000, null, c.ImGuiSliderFlags_None);
|
||||
|
||||
@@ -625,8 +625,8 @@ fn update(demo: *DemoState) void {
|
||||
c.igTextColored(
|
||||
.{ .x = 0, .y = 0.8, .z = 0, .w = 1 },
|
||||
"%.3f M",
|
||||
@floatFromInt(f64, demo.num_objects_to_draw) *
|
||||
@floatFromInt(f64, demo.meshes.items[mesh_engine].num_indices / 3) / 1_000_000.0,
|
||||
@as(f64, @floatFromInt(demo.num_objects_to_draw)) *
|
||||
@as(f64, @floatFromInt(demo.meshes.items[mesh_engine].num_indices / 3)) / 1_000_000.0,
|
||||
);
|
||||
|
||||
c.igText("Vertices: ");
|
||||
@@ -634,8 +634,8 @@ fn update(demo: *DemoState) void {
|
||||
c.igTextColored(
|
||||
.{ .x = 0, .y = 0.8, .z = 0, .w = 1 },
|
||||
"%.3f M",
|
||||
@floatFromInt(f64, demo.num_objects_to_draw) *
|
||||
@floatFromInt(f64, demo.meshes.items[mesh_engine].num_vertices) / 1_000_000.0,
|
||||
@as(f64, @floatFromInt(demo.num_objects_to_draw)) *
|
||||
@as(f64, @floatFromInt(demo.meshes.items[mesh_engine].num_vertices)) / 1_000_000.0,
|
||||
);
|
||||
|
||||
if (demo.draw_mode == .mesh_shader) {
|
||||
@@ -644,8 +644,8 @@ fn update(demo: *DemoState) void {
|
||||
c.igTextColored(
|
||||
.{ .x = 0, .y = 0.8, .z = 0, .w = 1 },
|
||||
"%.3f K",
|
||||
@floatFromInt(f64, demo.num_objects_to_draw) *
|
||||
@floatFromInt(f64, demo.meshes.items[mesh_engine].num_meshlets) / 1_000.0,
|
||||
@as(f64, @floatFromInt(demo.num_objects_to_draw)) *
|
||||
@as(f64, @floatFromInt(demo.meshes.items[mesh_engine].num_meshlets)) / 1_000.0,
|
||||
);
|
||||
|
||||
c.igSpacing();
|
||||
@@ -660,8 +660,8 @@ fn update(demo: *DemoState) void {
|
||||
{
|
||||
var pos: w32.POINT = undefined;
|
||||
_ = w32.GetCursorPos(&pos);
|
||||
const delta_x = @floatFromInt(f32, pos.x) - @floatFromInt(f32, demo.mouse.cursor_prev_x);
|
||||
const delta_y = @floatFromInt(f32, pos.y) - @floatFromInt(f32, demo.mouse.cursor_prev_y);
|
||||
const delta_x = @as(f32, @floatFromInt(pos.x)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_x));
|
||||
const delta_y = @as(f32, @floatFromInt(pos.y)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_y));
|
||||
demo.mouse.cursor_prev_x = pos.x;
|
||||
demo.mouse.cursor_prev_y = pos.y;
|
||||
|
||||
@@ -709,7 +709,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = Mat4.initPerspectiveFovLh(
|
||||
math.pi / 3.0,
|
||||
@floatFromInt(f32, gctx.viewport_width) / @floatFromInt(f32, gctx.viewport_height),
|
||||
@as(f32, @floatFromInt(gctx.viewport_width)) / @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -765,12 +765,12 @@ fn draw(demo: *DemoState) void {
|
||||
|
||||
gctx.cmdlist.IASetVertexBuffers(0, 1, &[_]d3d12.VERTEX_BUFFER_VIEW{.{
|
||||
.BufferLocation = gctx.lookupResource(demo.vertex_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(demo.vertex_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(demo.vertex_buffer))),
|
||||
.StrideInBytes = @sizeOf(Vertex),
|
||||
}});
|
||||
gctx.cmdlist.IASetIndexBuffer(&.{
|
||||
.BufferLocation = gctx.lookupResource(demo.index_buffer).?.GetGPUVirtualAddress(),
|
||||
.SizeInBytes = @intCast(u32, gctx.getResourceSize(demo.index_buffer)),
|
||||
.SizeInBytes = @as(u32, @intCast(gctx.getResourceSize(demo.index_buffer))),
|
||||
.Format = .R32_UINT,
|
||||
});
|
||||
},
|
||||
@@ -780,7 +780,7 @@ fn draw(demo: *DemoState) void {
|
||||
while (entity_index < demo.num_objects_to_draw) : (entity_index += 1) {
|
||||
// Upload per-draw constant data.
|
||||
{
|
||||
const position = Vec3.init(0.0, 0.0, @floatFromInt(f32, entity_index) * 2.5);
|
||||
const position = Vec3.init(0.0, 0.0, @as(f32, @floatFromInt(entity_index)) * 2.5);
|
||||
const mem = gctx.allocateUploadMemory(Pso_DrawConst, 1);
|
||||
mem.cpu_slice[0] = .{
|
||||
.object_to_clip = Mat4.initTranslation(position).mul(cam_world_to_clip).transpose(),
|
||||
@@ -812,7 +812,7 @@ fn draw(demo: *DemoState) void {
|
||||
mesh.num_indices,
|
||||
1,
|
||||
mesh.index_offset,
|
||||
@intCast(i32, mesh.vertex_offset),
|
||||
@as(i32, @intCast(mesh.vertex_offset)),
|
||||
0,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -39,9 +39,9 @@ fn createWindow(width: u32, height: u32) w32.HWND {
|
||||
.lpfnWndProc = processWindowMessage,
|
||||
.cbClsExtra = 0,
|
||||
.cbWndExtra = 0,
|
||||
.hInstance = @ptrCast(w32.HINSTANCE, w32.GetModuleHandleA(null)),
|
||||
.hInstance = @as(w32.HINSTANCE, @ptrCast(w32.GetModuleHandleA(null))),
|
||||
.hIcon = null,
|
||||
.hCursor = w32.LoadCursorA(null, @ptrFromInt(w32.LPCSTR, 32512)),
|
||||
.hCursor = w32.LoadCursorA(null, @as(w32.LPCSTR, @ptrFromInt(32512))),
|
||||
.hbrBackground = null,
|
||||
.lpszMenuName = null,
|
||||
.lpszClassName = window_name,
|
||||
@@ -54,8 +54,8 @@ fn createWindow(width: u32, height: u32) w32.HWND {
|
||||
var rect = w32.RECT{
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.right = @intCast(w32.LONG, width),
|
||||
.bottom = @intCast(w32.LONG, height),
|
||||
.right = @as(w32.LONG, @intCast(width)),
|
||||
.bottom = @as(w32.LONG, @intCast(height)),
|
||||
};
|
||||
_ = w32.AdjustWindowRectEx(&rect, style, w32.FALSE, 0);
|
||||
|
||||
@@ -110,12 +110,12 @@ pub fn main() !void {
|
||||
pso_desc.VS.pShaderBytecode.?,
|
||||
pso_desc.VS.BytecodeLength,
|
||||
&d3d12.IID_IRootSignature,
|
||||
@ptrCast(*?*anyopaque, &root_signature),
|
||||
@as(*?*anyopaque, @ptrCast(&root_signature)),
|
||||
));
|
||||
hrPanicOnFail(dx12.device.CreateGraphicsPipelineState(
|
||||
&pso_desc,
|
||||
&d3d12.IID_IPipelineState,
|
||||
@ptrCast(*?*anyopaque, &pipeline),
|
||||
@as(*?*anyopaque, @ptrCast(&pipeline)),
|
||||
));
|
||||
}
|
||||
defer _ = pipeline.Release();
|
||||
@@ -165,9 +165,9 @@ pub fn main() !void {
|
||||
|
||||
for (&dx12.swap_chain_textures, 0..) |*texture, i| {
|
||||
hrPanicOnFail(dx12.swap_chain.GetBuffer(
|
||||
@intCast(u32, i),
|
||||
@as(u32, @intCast(i)),
|
||||
&d3d12.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &texture.*),
|
||||
@as(*?*anyopaque, @ptrCast(&texture.*)),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -191,16 +191,16 @@ pub fn main() !void {
|
||||
dx12.command_list.RSSetViewports(1, &[_]d3d12.VIEWPORT{.{
|
||||
.TopLeftX = 0.0,
|
||||
.TopLeftY = 0.0,
|
||||
.Width = @floatFromInt(f32, window_rect.right),
|
||||
.Height = @floatFromInt(f32, window_rect.bottom),
|
||||
.Width = @as(f32, @floatFromInt(window_rect.right)),
|
||||
.Height = @as(f32, @floatFromInt(window_rect.bottom)),
|
||||
.MinDepth = 0.0,
|
||||
.MaxDepth = 1.0,
|
||||
}});
|
||||
dx12.command_list.RSSetScissorRects(1, &[_]d3d12.RECT{.{
|
||||
.left = 0,
|
||||
.top = 0,
|
||||
.right = @intCast(c_long, window_rect.right),
|
||||
.bottom = @intCast(c_long, window_rect.bottom),
|
||||
.right = @as(c_long, @intCast(window_rect.right)),
|
||||
.bottom = @as(c_long, @intCast(window_rect.bottom)),
|
||||
}});
|
||||
|
||||
const back_buffer_index = dx12.swap_chain.GetCurrentBackBufferIndex();
|
||||
@@ -251,7 +251,7 @@ pub fn main() !void {
|
||||
|
||||
dx12.command_queue.ExecuteCommandLists(
|
||||
1,
|
||||
&[_]*d3d12.ICommandList{@ptrCast(*d3d12.ICommandList, dx12.command_list)},
|
||||
&[_]*d3d12.ICommandList{@as(*d3d12.ICommandList, @ptrCast(dx12.command_list))},
|
||||
);
|
||||
|
||||
dx12.present();
|
||||
@@ -294,14 +294,14 @@ const Dx12State = struct {
|
||||
hrPanicOnFail(dxgi.CreateDXGIFactory2(
|
||||
0,
|
||||
&dxgi.IID_IFactory6,
|
||||
@ptrCast(*?*anyopaque, &dxgi_factory),
|
||||
@as(*?*anyopaque, @ptrCast(&dxgi_factory)),
|
||||
));
|
||||
|
||||
std.log.info("DXGI factory created", .{});
|
||||
|
||||
{
|
||||
var maybe_debug: ?*d3d12d.IDebug1 = null;
|
||||
_ = d3d12.GetDebugInterface(&d3d12d.IID_IDebug1, @ptrCast(*?*anyopaque, &maybe_debug));
|
||||
_ = d3d12.GetDebugInterface(&d3d12d.IID_IDebug1, @as(*?*anyopaque, @ptrCast(&maybe_debug)));
|
||||
if (maybe_debug) |debug| {
|
||||
// Uncomment below line to enable debug layer
|
||||
//debug.EnableDebugLayer();
|
||||
@@ -317,7 +317,7 @@ const Dx12State = struct {
|
||||
null,
|
||||
.@"11_0",
|
||||
&d3d12.IID_IDevice9,
|
||||
@ptrCast(?*?*anyopaque, &device),
|
||||
@as(?*?*anyopaque, @ptrCast(&device)),
|
||||
) != w32.S_OK) {
|
||||
_ = w32.MessageBoxA(
|
||||
window,
|
||||
@@ -340,7 +340,7 @@ const Dx12State = struct {
|
||||
.Priority = @intFromEnum(d3d12.COMMAND_QUEUE_PRIORITY.NORMAL),
|
||||
.Flags = .{},
|
||||
.NodeMask = 0,
|
||||
}, &d3d12.IID_ICommandQueue, @ptrCast(*?*anyopaque, &command_queue)));
|
||||
}, &d3d12.IID_ICommandQueue, @as(*?*anyopaque, @ptrCast(&command_queue))));
|
||||
|
||||
std.log.info("D3D12 command queue created", .{});
|
||||
|
||||
@@ -354,8 +354,8 @@ const Dx12State = struct {
|
||||
{
|
||||
var desc = dxgi.SWAP_CHAIN_DESC{
|
||||
.BufferDesc = .{
|
||||
.Width = @intCast(u32, rect.right),
|
||||
.Height = @intCast(u32, rect.bottom),
|
||||
.Width = @as(u32, @intCast(rect.right)),
|
||||
.Height = @as(u32, @intCast(rect.bottom)),
|
||||
.RefreshRate = .{ .Numerator = 0, .Denominator = 0 },
|
||||
.Format = .R8G8B8A8_UNORM,
|
||||
.ScanlineOrdering = .UNSPECIFIED,
|
||||
@@ -371,15 +371,15 @@ const Dx12State = struct {
|
||||
};
|
||||
var temp_swap_chain: *dxgi.ISwapChain = undefined;
|
||||
hrPanicOnFail(dxgi_factory.CreateSwapChain(
|
||||
@ptrCast(*w32.IUnknown, command_queue),
|
||||
@as(*w32.IUnknown, @ptrCast(command_queue)),
|
||||
&desc,
|
||||
@ptrCast(*?*dxgi.ISwapChain, &temp_swap_chain),
|
||||
@as(*?*dxgi.ISwapChain, @ptrCast(&temp_swap_chain)),
|
||||
));
|
||||
defer _ = temp_swap_chain.Release();
|
||||
|
||||
hrPanicOnFail(temp_swap_chain.QueryInterface(
|
||||
&dxgi.IID_ISwapChain3,
|
||||
@ptrCast(*?*anyopaque, &swap_chain),
|
||||
@as(*?*anyopaque, @ptrCast(&swap_chain)),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -390,9 +390,9 @@ const Dx12State = struct {
|
||||
|
||||
for (&swap_chain_textures, 0..) |*texture, i| {
|
||||
hrPanicOnFail(swap_chain.GetBuffer(
|
||||
@intCast(u32, i),
|
||||
@as(u32, @intCast(i)),
|
||||
&d3d12.IID_IResource,
|
||||
@ptrCast(*?*anyopaque, &texture.*),
|
||||
@as(*?*anyopaque, @ptrCast(&texture.*)),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ const Dx12State = struct {
|
||||
.NumDescriptors = 16,
|
||||
.Flags = .{},
|
||||
.NodeMask = 0,
|
||||
}, &d3d12.IID_IDescriptorHeap, @ptrCast(*?*anyopaque, &rtv_heap)));
|
||||
}, &d3d12.IID_IDescriptorHeap, @as(*?*anyopaque, @ptrCast(&rtv_heap))));
|
||||
|
||||
const rtv_heap_start = rtv_heap.GetCPUDescriptorHandleForHeapStart();
|
||||
|
||||
@@ -425,7 +425,7 @@ const Dx12State = struct {
|
||||
// Frame Fence
|
||||
//
|
||||
var frame_fence: *d3d12.IFence = undefined;
|
||||
hrPanicOnFail(device.CreateFence(0, .{}, &d3d12.IID_IFence, @ptrCast(*?*anyopaque, &frame_fence)));
|
||||
hrPanicOnFail(device.CreateFence(0, .{}, &d3d12.IID_IFence, @as(*?*anyopaque, @ptrCast(&frame_fence))));
|
||||
|
||||
var frame_fence_event = w32.CreateEventExA(null, "frame_fence_event", 0, w32.EVENT_ALL_ACCESS).?;
|
||||
|
||||
@@ -440,7 +440,7 @@ const Dx12State = struct {
|
||||
hrPanicOnFail(device.CreateCommandAllocator(
|
||||
.DIRECT,
|
||||
&d3d12.IID_ICommandAllocator,
|
||||
@ptrCast(*?*anyopaque, &cmdalloc.*),
|
||||
@as(*?*anyopaque, @ptrCast(&cmdalloc.*)),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ const Dx12State = struct {
|
||||
command_allocators[0],
|
||||
null,
|
||||
&d3d12.IID_IGraphicsCommandList6,
|
||||
@ptrCast(*?*anyopaque, &command_list),
|
||||
@as(*?*anyopaque, @ptrCast(&command_list)),
|
||||
));
|
||||
hrPanicOnFail(command_list.Close());
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ pub fn main() !void {
|
||||
try sdl.gl.setAttribute(.context_profile_mask, @intFromEnum(sdl.gl.Profile.core));
|
||||
try sdl.gl.setAttribute(.context_major_version, gl_major);
|
||||
try sdl.gl.setAttribute(.context_minor_version, gl_minor);
|
||||
try sdl.gl.setAttribute(.context_flags, @bitCast(i32, sdl.gl.ContextFlags{ .forward_compatible = true }));
|
||||
try sdl.gl.setAttribute(.context_flags, @as(i32, @bitCast(sdl.gl.ContextFlags{ .forward_compatible = true })));
|
||||
|
||||
const window = try sdl.Window.create(
|
||||
"zig-gamedev: minimal gl",
|
||||
|
||||
@@ -125,10 +125,10 @@ fn loadAllMeshes(
|
||||
try zmesh.io.appendMeshPrimitive(data, 0, 0, &indices, &positions, &normals, &texcoords, &tangents);
|
||||
|
||||
try out_meshes.append(.{
|
||||
.index_offset = @intCast(u32, pre_indices_len),
|
||||
.vertex_offset = @intCast(i32, pre_positions_len),
|
||||
.num_indices = @intCast(u32, indices.items.len - pre_indices_len),
|
||||
.num_vertices = @intCast(u32, positions.items.len - pre_positions_len),
|
||||
.index_offset = @as(u32, @intCast(pre_indices_len)),
|
||||
.vertex_offset = @as(i32, @intCast(pre_positions_len)),
|
||||
.num_indices = @as(u32, @intCast(indices.items.len - pre_indices_len)),
|
||||
.num_vertices = @as(u32, @intCast(positions.items.len - pre_positions_len)),
|
||||
});
|
||||
}
|
||||
{
|
||||
@@ -140,10 +140,10 @@ fn loadAllMeshes(
|
||||
try zmesh.io.appendMeshPrimitive(data, 0, 0, &indices, &positions, &normals, &texcoords, &tangents);
|
||||
|
||||
try out_meshes.append(.{
|
||||
.index_offset = @intCast(u32, pre_indices_len),
|
||||
.vertex_offset = @intCast(i32, pre_positions_len),
|
||||
.num_indices = @intCast(u32, indices.items.len - pre_indices_len),
|
||||
.num_vertices = @intCast(u32, positions.items.len - pre_positions_len),
|
||||
.index_offset = @as(u32, @intCast(pre_indices_len)),
|
||||
.vertex_offset = @as(i32, @intCast(pre_positions_len)),
|
||||
.num_indices = @as(u32, @intCast(indices.items.len - pre_indices_len)),
|
||||
.num_vertices = @as(u32, @intCast(positions.items.len - pre_positions_len)),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -211,8 +211,8 @@ fn create(allocator: std.mem.Allocator, window: *zglfw.Window) !*DemoState {
|
||||
var indices = std.ArrayList(u32).init(arena);
|
||||
try loadAllMeshes(arena, &meshes, &vertices, &indices);
|
||||
|
||||
const total_num_vertices = @intCast(u32, vertices.items.len);
|
||||
const total_num_indices = @intCast(u32, indices.items.len);
|
||||
const total_num_vertices = @as(u32, @intCast(vertices.items.len));
|
||||
const total_num_indices = @as(u32, @intCast(indices.items.len));
|
||||
|
||||
// Create a vertex buffer.
|
||||
const vertex_buf = gctx.createBuffer(.{
|
||||
@@ -556,8 +556,8 @@ fn update(demo: *DemoState) void {
|
||||
// Handle camera rotation with mouse.
|
||||
{
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const delta_x = @floatCast(f32, cursor_pos[0] - demo.mouse.cursor_pos[0]);
|
||||
const delta_y = @floatCast(f32, cursor_pos[1] - demo.mouse.cursor_pos[1]);
|
||||
const delta_x = @as(f32, @floatCast(cursor_pos[0] - demo.mouse.cursor_pos[0]));
|
||||
const delta_y = @as(f32, @floatCast(cursor_pos[1] - demo.mouse.cursor_pos[1]));
|
||||
demo.mouse.cursor_pos = cursor_pos;
|
||||
|
||||
if (window.getMouseButton(.left) == .press) {
|
||||
@@ -613,7 +613,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -809,7 +809,7 @@ fn precomputeImageLighting(
|
||||
};
|
||||
zstbi.setFlipVerticallyOnLoad(true);
|
||||
var image = zstbi.Image.loadFromFile(
|
||||
hdri_paths[@intCast(usize, demo.current_hdri_index)],
|
||||
hdri_paths[@as(usize, @intCast(demo.current_hdri_index))],
|
||||
4,
|
||||
) catch unreachable;
|
||||
defer {
|
||||
@@ -946,8 +946,8 @@ fn drawToCubeTexture(
|
||||
const pipeline = gctx.lookupResource(pipe) orelse return;
|
||||
|
||||
assert(dest_mip_level < dest_tex_info.mip_level_count);
|
||||
const dest_tex_width = dest_tex_info.size.width >> @intCast(u5, dest_mip_level);
|
||||
const dest_tex_height = dest_tex_info.size.height >> @intCast(u5, dest_mip_level);
|
||||
const dest_tex_width = dest_tex_info.size.width >> @as(u5, @intCast(dest_mip_level));
|
||||
const dest_tex_height = dest_tex_info.size.height >> @as(u5, @intCast(dest_mip_level));
|
||||
assert(dest_tex_width == dest_tex_height);
|
||||
|
||||
const sam = gctx.createSampler(.{
|
||||
@@ -1014,7 +1014,7 @@ fn drawToCubeTexture(
|
||||
const mem = gctx.uniformsAllocate(Uniforms, 1);
|
||||
mem.slice[0] = .{
|
||||
.object_to_clip = zm.transpose(zm.mul(object_to_view[cube_face_idx], view_to_clip)),
|
||||
.roughness = @floatFromInt(f32, dest_mip_level + 1) / @floatFromInt(f32, filtered_env_tex_mip_levels),
|
||||
.roughness = @as(f32, @floatFromInt(dest_mip_level + 1)) / @as(f32, @floatFromInt(filtered_env_tex_mip_levels)),
|
||||
};
|
||||
pass.setBindGroup(0, gctx.lookupResource(bg).?, &.{mem.offset});
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ const BroadPhaseLayerInterface = extern struct {
|
||||
iself: *const zphy.BroadPhaseLayerInterface,
|
||||
layer: zphy.ObjectLayer,
|
||||
) callconv(.C) zphy.BroadPhaseLayer {
|
||||
const self = @ptrCast(*const BroadPhaseLayerInterface, iself);
|
||||
const self = @as(*const BroadPhaseLayerInterface, @ptrCast(iself));
|
||||
return self.object_to_broad_phase[layer];
|
||||
}
|
||||
};
|
||||
@@ -178,10 +178,10 @@ fn appendMesh(
|
||||
meshes_normals: *std.ArrayList([3]f32),
|
||||
) void {
|
||||
meshes.append(.{
|
||||
.index_offset = @intCast(u32, meshes_indices.items.len),
|
||||
.vertex_offset = @intCast(i32, meshes_positions.items.len),
|
||||
.num_indices = @intCast(u32, mesh.indices.len),
|
||||
.num_vertices = @intCast(u32, mesh.positions.len),
|
||||
.index_offset = @as(u32, @intCast(meshes_indices.items.len)),
|
||||
.vertex_offset = @as(i32, @intCast(meshes_positions.items.len)),
|
||||
.num_indices = @as(u32, @intCast(mesh.indices.len)),
|
||||
.num_vertices = @as(u32, @intCast(mesh.positions.len)),
|
||||
}) catch unreachable;
|
||||
|
||||
meshes_indices.appendSlice(mesh.indices) catch unreachable;
|
||||
@@ -251,8 +251,8 @@ fn create(allocator: std.mem.Allocator, window: *zglfw.Window) !*DemoState {
|
||||
var meshes_normals = std.ArrayList([3]f32).init(arena);
|
||||
generateMeshes(allocator, &meshes, &meshes_indices, &meshes_positions, &meshes_normals);
|
||||
|
||||
const total_num_vertices = @intCast(u32, meshes_positions.items.len);
|
||||
const total_num_indices = @intCast(u32, meshes_indices.items.len);
|
||||
const total_num_vertices = @as(u32, @intCast(meshes_positions.items.len));
|
||||
const total_num_indices = @as(u32, @intCast(meshes_indices.items.len));
|
||||
|
||||
//
|
||||
// Graphics
|
||||
@@ -319,9 +319,9 @@ fn create(allocator: std.mem.Allocator, window: *zglfw.Window) !*DemoState {
|
||||
contact_listener.* = .{};
|
||||
|
||||
const physics_system = try zphy.PhysicsSystem.create(
|
||||
@ptrCast(*const zphy.BroadPhaseLayerInterface, broad_phase_layer_interface),
|
||||
@ptrCast(*const zphy.ObjectVsBroadPhaseLayerFilter, object_vs_broad_phase_layer_filter),
|
||||
@ptrCast(*const zphy.ObjectLayerPairFilter, object_layer_pair_filter),
|
||||
@as(*const zphy.BroadPhaseLayerInterface, @ptrCast(broad_phase_layer_interface)),
|
||||
@as(*const zphy.ObjectVsBroadPhaseLayerFilter, @ptrCast(object_vs_broad_phase_layer_filter)),
|
||||
@as(*const zphy.ObjectLayerPairFilter, @ptrCast(object_layer_pair_filter)),
|
||||
.{
|
||||
.max_bodies = 1024,
|
||||
.num_body_mutexes = 0,
|
||||
@@ -355,7 +355,7 @@ fn create(allocator: std.mem.Allocator, window: *zglfw.Window) !*DemoState {
|
||||
|
||||
var i: u32 = 0;
|
||||
while (i < 16) : (i += 1) {
|
||||
const fi = @floatFromInt(f32, i);
|
||||
const fi = @as(f32, @floatFromInt(i));
|
||||
_ = try body_interface.createAndAddBody(.{
|
||||
.position = .{ 0.0, 8.0 + fi * 1.2, 8.0, 1.0 },
|
||||
.rotation = .{ 0.0, 0.0, 0.0, 1.0 },
|
||||
@@ -437,8 +437,8 @@ fn update(demo: *DemoState) void {
|
||||
// Handle camera rotation with mouse.
|
||||
{
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const delta_x = @floatCast(f32, cursor_pos[0] - demo.mouse.cursor_pos[0]);
|
||||
const delta_y = @floatCast(f32, cursor_pos[1] - demo.mouse.cursor_pos[1]);
|
||||
const delta_x = @as(f32, @floatCast(cursor_pos[0] - demo.mouse.cursor_pos[0]));
|
||||
const delta_y = @as(f32, @floatCast(cursor_pos[1] - demo.mouse.cursor_pos[1]));
|
||||
demo.mouse.cursor_pos = cursor_pos;
|
||||
|
||||
if (window.getMouseButton(.right) == .press) {
|
||||
@@ -492,7 +492,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -570,10 +570,10 @@ fn draw(demo: *DemoState) void {
|
||||
zm.loadArr4(body.position)
|
||||
else
|
||||
zm.loadArr4(.{
|
||||
@floatCast(f32, body.position[0]),
|
||||
@floatCast(f32, body.position[1]),
|
||||
@floatCast(f32, body.position[2]),
|
||||
@floatCast(f32, body.position[3]),
|
||||
@as(f32, @floatCast(body.position[0])),
|
||||
@as(f32, @floatCast(body.position[1])),
|
||||
@as(f32, @floatCast(body.position[2])),
|
||||
@as(f32, @floatCast(body.position[3])),
|
||||
});
|
||||
const rotation = zm.loadArr4(body.rotation);
|
||||
var xform = zm.matFromQuat(rotation);
|
||||
|
||||
@@ -77,10 +77,10 @@ fn appendMesh(
|
||||
meshes_normals: *std.ArrayList([3]f32),
|
||||
) void {
|
||||
meshes.append(.{
|
||||
.index_offset = @intCast(u32, meshes_indices.items.len),
|
||||
.vertex_offset = @intCast(i32, meshes_positions.items.len),
|
||||
.num_indices = @intCast(u32, mesh.indices.len),
|
||||
.num_vertices = @intCast(u32, mesh.positions.len),
|
||||
.index_offset = @as(u32, @intCast(meshes_indices.items.len)),
|
||||
.vertex_offset = @as(i32, @intCast(meshes_positions.items.len)),
|
||||
.num_indices = @as(u32, @intCast(mesh.indices.len)),
|
||||
.num_vertices = @as(u32, @intCast(mesh.positions.len)),
|
||||
}) catch unreachable;
|
||||
|
||||
meshes_indices.appendSlice(mesh.indices) catch unreachable;
|
||||
@@ -115,7 +115,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 0, 1, 0 },
|
||||
.basecolor_roughness = .{ 0.0, 0.7, 0.0, 0.6 },
|
||||
}) catch unreachable;
|
||||
@@ -131,7 +131,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 3, 1, 0 },
|
||||
.basecolor_roughness = .{ 0.7, 0.0, 0.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -146,7 +146,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ -3, 1, 0 },
|
||||
.basecolor_roughness = .{ 0.7, 0.6, 0.0, 0.4 },
|
||||
}) catch unreachable;
|
||||
@@ -161,7 +161,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 0, 1, 3 },
|
||||
.basecolor_roughness = .{ 0.0, 0.1, 1.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -189,7 +189,7 @@ fn initScene(
|
||||
cylinder.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ -3, 0, 3 },
|
||||
.basecolor_roughness = .{ 1.0, 0.0, 0.0, 0.3 },
|
||||
}) catch unreachable;
|
||||
@@ -202,7 +202,7 @@ fn initScene(
|
||||
defer mesh.deinit();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 3, 1.5, 3 },
|
||||
.basecolor_roughness = .{ 1.0, 0.5, 0.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -217,7 +217,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 3, 1, 6 },
|
||||
.basecolor_roughness = .{ 0.0, 1.0, 0.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -232,7 +232,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 0, 0.5, 6 },
|
||||
.basecolor_roughness = .{ 1.0, 0.0, 1.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -247,7 +247,7 @@ fn initScene(
|
||||
mesh.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ -3, 1, 6 },
|
||||
.basecolor_roughness = .{ 0.2, 0.0, 1.0, 0.2 },
|
||||
}) catch unreachable;
|
||||
@@ -262,7 +262,7 @@ fn initScene(
|
||||
rock.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ -6, 0, 3 },
|
||||
.basecolor_roughness = .{ 1.0, 1.0, 1.0, 1.0 },
|
||||
}) catch unreachable;
|
||||
@@ -293,7 +293,7 @@ fn initScene(
|
||||
ground.computeNormals();
|
||||
|
||||
drawables.append(.{
|
||||
.mesh_index = @intCast(u32, meshes.items.len),
|
||||
.mesh_index = @as(u32, @intCast(meshes.items.len)),
|
||||
.position = .{ 0, 0, 0 },
|
||||
.basecolor_roughness = .{ 0.1, 0.1, 0.1, 1.0 },
|
||||
}) catch unreachable;
|
||||
@@ -383,8 +383,8 @@ fn init(allocator: std.mem.Allocator, window: *zglfw.Window) !DemoState {
|
||||
var meshes_normals = std.ArrayList([3]f32).init(arena);
|
||||
initScene(allocator, &drawables, &meshes, &meshes_indices, &meshes_positions, &meshes_normals);
|
||||
|
||||
const total_num_vertices = @intCast(u32, meshes_positions.items.len);
|
||||
const total_num_indices = @intCast(u32, meshes_indices.items.len);
|
||||
const total_num_vertices = @as(u32, @intCast(meshes_positions.items.len));
|
||||
const total_num_indices = @as(u32, @intCast(meshes_indices.items.len));
|
||||
|
||||
// Create a vertex buffer.
|
||||
const vertex_buffer = gctx.createBuffer(.{
|
||||
@@ -457,8 +457,8 @@ fn update(demo: *DemoState) void {
|
||||
// Handle camera rotation with mouse.
|
||||
{
|
||||
const cursor_pos = window.getCursorPos();
|
||||
const delta_x = @floatCast(f32, cursor_pos[0] - demo.mouse.cursor_pos[0]);
|
||||
const delta_y = @floatCast(f32, cursor_pos[1] - demo.mouse.cursor_pos[1]);
|
||||
const delta_x = @as(f32, @floatCast(cursor_pos[0] - demo.mouse.cursor_pos[0]));
|
||||
const delta_y = @as(f32, @floatCast(cursor_pos[1] - demo.mouse.cursor_pos[1]));
|
||||
demo.mouse.cursor_pos = cursor_pos;
|
||||
|
||||
if (window.getMouseButton(.right) == .press) {
|
||||
@@ -511,7 +511,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
|
||||
@@ -229,8 +229,8 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
&mesh_tangents,
|
||||
);
|
||||
}
|
||||
const mesh_num_indices = @intCast(u32, mesh_indices.items.len);
|
||||
const mesh_num_vertices = @intCast(u32, mesh_positions.items.len);
|
||||
const mesh_num_indices = @as(u32, @intCast(mesh_indices.items.len));
|
||||
const mesh_num_vertices = @as(u32, @intCast(mesh_positions.items.len));
|
||||
|
||||
const vertex_buffer = gctx.createCommittedResource(
|
||||
.DEFAULT,
|
||||
@@ -468,7 +468,7 @@ fn update(demo: *DemoState) void {
|
||||
common.newImGuiFrame(dt);
|
||||
|
||||
c.igSetNextWindowPos(
|
||||
c.ImVec2{ .x = @floatFromInt(f32, demo.gctx.viewport_width) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImVec2{ .x = @as(f32, @floatFromInt(demo.gctx.viewport_width)) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImGuiCond_FirstUseEver,
|
||||
c.ImVec2{ .x = 0.0, .y = 0.0 },
|
||||
);
|
||||
@@ -513,8 +513,8 @@ fn update(demo: *DemoState) void {
|
||||
{
|
||||
var pos: w32.POINT = undefined;
|
||||
_ = w32.GetCursorPos(&pos);
|
||||
const delta_x = @floatFromInt(f32, pos.x) - @floatFromInt(f32, demo.mouse.cursor_prev_x);
|
||||
const delta_y = @floatFromInt(f32, pos.y) - @floatFromInt(f32, demo.mouse.cursor_prev_y);
|
||||
const delta_x = @as(f32, @floatFromInt(pos.x)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_x));
|
||||
const delta_y = @as(f32, @floatFromInt(pos.y)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_y));
|
||||
demo.mouse.cursor_prev_x = pos.x;
|
||||
demo.mouse.cursor_prev_y = pos.y;
|
||||
|
||||
@@ -567,7 +567,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, gctx.viewport_width) / @floatFromInt(f32, gctx.viewport_height),
|
||||
@as(f32, @floatFromInt(gctx.viewport_width)) / @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
@@ -731,7 +731,7 @@ fn draw(demo: *DemoState) void {
|
||||
}
|
||||
|
||||
// Increase number of drawn pixels to achieve animation effect.
|
||||
demo.num_pixel_groups += @intCast(u32, demo.raster_speed);
|
||||
demo.num_pixel_groups += @as(u32, @intCast(demo.raster_speed));
|
||||
if (demo.num_pixel_groups > gctx.viewport_width * gctx.viewport_height / compute_group_size) {
|
||||
demo.num_pixel_groups = gctx.viewport_width * gctx.viewport_height / compute_group_size;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ fn parseAndLoadGltfFile(path: []const u8) *c.cgltf_data {
|
||||
const result = c.cgltf_parse_file(
|
||||
&options,
|
||||
full_path.ptr,
|
||||
@ptrCast([*c][*c]c.cgltf_data, &data),
|
||||
@as([*c][*c]c.cgltf_data, @ptrCast(&data)),
|
||||
);
|
||||
assert(result == c.cgltf_result_success);
|
||||
}
|
||||
@@ -176,8 +176,8 @@ fn appendMeshPrimitive(
|
||||
) void {
|
||||
assert(mesh_index < data.meshes_count);
|
||||
assert(prim_index < data.meshes[mesh_index].primitives_count);
|
||||
const num_vertices: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].attributes[0].data.*.count);
|
||||
const num_indices: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].indices.*.count);
|
||||
const num_vertices: u32 = @as(u32, @intCast(data.meshes[mesh_index].primitives[prim_index].attributes[0].data.*.count));
|
||||
const num_indices: u32 = @as(u32, @intCast(data.meshes[mesh_index].primitives[prim_index].indices.*.count));
|
||||
|
||||
// Indices.
|
||||
{
|
||||
@@ -190,26 +190,26 @@ fn appendMeshPrimitive(
|
||||
assert((accessor.*.stride * accessor.*.count) == accessor.*.buffer_view.*.size);
|
||||
assert(accessor.*.buffer_view.*.buffer.*.data != null);
|
||||
|
||||
const data_addr = @alignCast(4, @ptrCast([*]const u8, accessor.*.buffer_view.*.buffer.*.data) +
|
||||
accessor.*.offset + accessor.*.buffer_view.*.offset);
|
||||
const data_addr = @as([*]const u8, @ptrCast(accessor.*.buffer_view.*.buffer.*.data)) +
|
||||
accessor.*.offset + accessor.*.buffer_view.*.offset;
|
||||
|
||||
if (accessor.*.stride == 1) {
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_8u);
|
||||
const src = @ptrCast([*]const u8, data_addr);
|
||||
const src = @as([*]const u8, @ptrCast(data_addr));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
}
|
||||
} else if (accessor.*.stride == 2) {
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_16u);
|
||||
const src = @ptrCast([*]const u16, data_addr);
|
||||
const src = @as([*]const u16, @ptrCast(@alignCast(data_addr)));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
}
|
||||
} else if (accessor.*.stride == 4) {
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_32u);
|
||||
const src = @ptrCast([*]const u32, data_addr);
|
||||
const src = @as([*]const u32, @ptrCast(@alignCast(data_addr)));
|
||||
var i: u32 = 0;
|
||||
while (i < num_indices) : (i += 1) {
|
||||
indices.appendAssumeCapacity(src[i]);
|
||||
@@ -226,7 +226,7 @@ fn appendMeshPrimitive(
|
||||
if (texcoords0 != null) texcoords0.?.resize(texcoords0.?.items.len + num_vertices) catch unreachable;
|
||||
if (tangents != null) tangents.?.resize(tangents.?.items.len + num_vertices) catch unreachable;
|
||||
|
||||
const num_attribs: u32 = @intCast(u32, data.meshes[mesh_index].primitives[prim_index].attributes_count);
|
||||
const num_attribs: u32 = @as(u32, @intCast(data.meshes[mesh_index].primitives[prim_index].attributes_count));
|
||||
|
||||
var attrib_index: u32 = 0;
|
||||
while (attrib_index < num_attribs) : (attrib_index += 1) {
|
||||
@@ -238,7 +238,7 @@ fn appendMeshPrimitive(
|
||||
assert((accessor.*.stride * accessor.*.count) == accessor.*.buffer_view.*.size);
|
||||
assert(accessor.*.buffer_view.*.buffer.*.data != null);
|
||||
|
||||
const data_addr = @ptrCast([*]const u8, accessor.*.buffer_view.*.buffer.*.data) +
|
||||
const data_addr = @as([*]const u8, @ptrCast(accessor.*.buffer_view.*.buffer.*.data)) +
|
||||
accessor.*.offset + accessor.*.buffer_view.*.offset;
|
||||
|
||||
const len = accessor.*.count * accessor.*.stride;
|
||||
@@ -247,28 +247,28 @@ fn appendMeshPrimitive(
|
||||
assert(accessor.*.type == c.cgltf_type_vec3);
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
|
||||
@memcpy(
|
||||
@ptrCast([*]u8, positions.items.ptr + positions.items.len - num_vertices)[0..len],
|
||||
@as([*]u8, @ptrCast(positions.items.ptr + positions.items.len - num_vertices))[0..len],
|
||||
data_addr[0..len],
|
||||
);
|
||||
} else if (attrib.*.type == c.cgltf_attribute_type_normal and normals != null) {
|
||||
assert(accessor.*.type == c.cgltf_type_vec3);
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
|
||||
@memcpy(
|
||||
@ptrCast([*]u8, normals.?.items.ptr + normals.?.items.len - num_vertices)[0..len],
|
||||
@as([*]u8, @ptrCast(normals.?.items.ptr + normals.?.items.len - num_vertices))[0..len],
|
||||
data_addr[0..len],
|
||||
);
|
||||
} else if (attrib.*.type == c.cgltf_attribute_type_texcoord and texcoords0 != null) {
|
||||
assert(accessor.*.type == c.cgltf_type_vec2);
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
|
||||
@memcpy(
|
||||
@ptrCast([*]u8, texcoords0.?.items.ptr + texcoords0.?.items.len - num_vertices)[0..len],
|
||||
@as([*]u8, @ptrCast(texcoords0.?.items.ptr + texcoords0.?.items.len - num_vertices))[0..len],
|
||||
data_addr[0..len],
|
||||
);
|
||||
} else if (attrib.*.type == c.cgltf_attribute_type_tangent and tangents != null) {
|
||||
assert(accessor.*.type == c.cgltf_type_vec4);
|
||||
assert(accessor.*.component_type == c.cgltf_component_type_r_32f);
|
||||
@memcpy(
|
||||
@ptrCast([*]u8, tangents.?.items.ptr + tangents.?.items.len - num_vertices)[0..len],
|
||||
@as([*]u8, @ptrCast(tangents.?.items.ptr + tangents.?.items.len - num_vertices))[0..len],
|
||||
data_addr[0..len],
|
||||
);
|
||||
}
|
||||
@@ -294,11 +294,11 @@ fn loadScene(
|
||||
const data = parseAndLoadGltfFile(content_dir ++ "Sponza/Sponza.gltf");
|
||||
defer c.cgltf_free(data);
|
||||
|
||||
const num_meshes = @intCast(u32, data.meshes_count);
|
||||
const num_meshes = @as(u32, @intCast(data.meshes_count));
|
||||
var mesh_index: u32 = 0;
|
||||
|
||||
while (mesh_index < num_meshes) : (mesh_index += 1) {
|
||||
const num_prims = @intCast(u32, data.meshes[mesh_index].primitives_count);
|
||||
const num_prims = @as(u32, @intCast(data.meshes[mesh_index].primitives_count));
|
||||
var prim_index: u32 = 0;
|
||||
|
||||
while (prim_index < num_prims) : (prim_index += 1) {
|
||||
@@ -316,7 +316,7 @@ fn loadScene(
|
||||
&tangents,
|
||||
);
|
||||
|
||||
const num_materials = @intCast(u32, data.materials_count);
|
||||
const num_materials = @as(u32, @intCast(data.materials_count));
|
||||
var material_index: u32 = 0;
|
||||
var assigned_material_index: u32 = 0xffff_ffff;
|
||||
|
||||
@@ -330,10 +330,10 @@ fn loadScene(
|
||||
assert(assigned_material_index != 0xffff_ffff);
|
||||
|
||||
all_meshes.append(.{
|
||||
.index_offset = @intCast(u32, pre_indices_len),
|
||||
.vertex_offset = @intCast(u32, pre_positions_len),
|
||||
.num_indices = @intCast(u32, indices.items.len - pre_indices_len),
|
||||
.num_vertices = @intCast(u32, positions.items.len - pre_positions_len),
|
||||
.index_offset = @as(u32, @intCast(pre_indices_len)),
|
||||
.vertex_offset = @as(u32, @intCast(pre_positions_len)),
|
||||
.num_indices = @as(u32, @intCast(indices.items.len - pre_indices_len)),
|
||||
.num_vertices = @as(u32, @intCast(positions.items.len - pre_positions_len)),
|
||||
.material_index = assigned_material_index,
|
||||
}) catch unreachable;
|
||||
}
|
||||
@@ -354,7 +354,7 @@ fn loadScene(
|
||||
});
|
||||
}
|
||||
|
||||
const num_materials = @intCast(u32, data.materials_count);
|
||||
const num_materials = @as(u32, @intCast(data.materials_count));
|
||||
var material_index: u32 = 0;
|
||||
all_materials.ensureTotalCapacity(num_materials) catch unreachable;
|
||||
|
||||
@@ -364,7 +364,7 @@ fn loadScene(
|
||||
|
||||
const mr = &gltf_material.pbr_metallic_roughness;
|
||||
|
||||
const num_images = @intCast(u32, data.images_count);
|
||||
const num_images = @as(u32, @intCast(data.images_count));
|
||||
const invalid_image_index = num_images;
|
||||
|
||||
var base_color_tex_index: u32 = invalid_image_index;
|
||||
@@ -404,13 +404,13 @@ fn loadScene(
|
||||
.base_color = Vec3.init(mr.base_color_factor[0], mr.base_color_factor[1], mr.base_color_factor[2]),
|
||||
.roughness = mr.roughness_factor,
|
||||
.metallic = mr.metallic_factor,
|
||||
.base_color_tex_index = @intCast(u16, base_color_tex_index),
|
||||
.metallic_roughness_tex_index = @intCast(u16, metallic_roughness_tex_index),
|
||||
.normal_tex_index = @intCast(u16, normal_tex_index),
|
||||
.base_color_tex_index = @as(u16, @intCast(base_color_tex_index)),
|
||||
.metallic_roughness_tex_index = @as(u16, @intCast(metallic_roughness_tex_index)),
|
||||
.normal_tex_index = @as(u16, @intCast(normal_tex_index)),
|
||||
});
|
||||
}
|
||||
|
||||
const num_images = @intCast(u32, data.images_count);
|
||||
const num_images = @as(u32, @intCast(data.images_count));
|
||||
var image_index: u32 = 0;
|
||||
all_textures.ensureTotalCapacity(num_images + 1) catch unreachable;
|
||||
|
||||
@@ -552,20 +552,20 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
const state_object_desc = d3d12.STATE_OBJECT_DESC{
|
||||
.Type = .RAYTRACING_PIPELINE,
|
||||
.NumSubobjects = 1,
|
||||
.pSubobjects = @ptrCast([*]const d3d12.STATE_SUBOBJECT, &subobject),
|
||||
.pSubobjects = @as([*]const d3d12.STATE_SUBOBJECT, @ptrCast(&subobject)),
|
||||
};
|
||||
|
||||
hrPanicOnFail(gctx.device.CreateStateObject(
|
||||
&state_object_desc,
|
||||
&d3d12.IID_IStateObject,
|
||||
@ptrCast(*?*anyopaque, &trace_shadow_rays_stateobj),
|
||||
@as(*?*anyopaque, @ptrCast(&trace_shadow_rays_stateobj)),
|
||||
));
|
||||
hrPanicOnFail(gctx.device.CreateRootSignature(
|
||||
0,
|
||||
cso_code.ptr,
|
||||
cso_code.len,
|
||||
&d3d12.IID_IRootSignature,
|
||||
@ptrCast(*?*anyopaque, &trace_shadow_rays_rs),
|
||||
@as(*?*anyopaque, @ptrCast(&trace_shadow_rays_rs)),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
gctx.lookupResource(vertex_buffer.resource).?,
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initStructuredBuffer(
|
||||
0,
|
||||
@intCast(u32, all_vertices.items.len),
|
||||
@as(u32, @intCast(all_vertices.items.len)),
|
||||
@sizeOf(Vertex),
|
||||
),
|
||||
vertex_buffer.view,
|
||||
@@ -731,13 +731,13 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
};
|
||||
gctx.device.CreateShaderResourceView(
|
||||
gctx.lookupResource(index_buffer.resource).?,
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initTypedBuffer(.R32_UINT, 0, @intCast(u32, all_indices.items.len)),
|
||||
&d3d12.SHADER_RESOURCE_VIEW_DESC.initTypedBuffer(.R32_UINT, 0, @as(u32, @intCast(all_indices.items.len))),
|
||||
index_buffer.view,
|
||||
);
|
||||
|
||||
// Upload vertex buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @intCast(u32, all_vertices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(Vertex, @as(u32, @intCast(all_vertices.items.len)));
|
||||
for (all_vertices.items, 0..) |vertex, i| {
|
||||
upload.cpu_slice[i] = vertex;
|
||||
}
|
||||
@@ -754,7 +754,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
// Upload index buffer.
|
||||
{
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @intCast(u32, all_indices.items.len));
|
||||
const upload = gctx.allocateUploadBufferRegion(u32, @as(u32, @intCast(all_indices.items.len)));
|
||||
for (all_indices.items, 0..) |index, i| {
|
||||
upload.cpu_slice[i] = index;
|
||||
}
|
||||
@@ -806,7 +806,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
const blas_inputs = d3d12.BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS{
|
||||
.Type = .BOTTOM_LEVEL,
|
||||
.Flags = .{ .PREFER_FAST_TRACE = true },
|
||||
.NumDescs = @intCast(u32, geometry_descs.items.len),
|
||||
.NumDescs = @as(u32, @intCast(geometry_descs.items.len)),
|
||||
.DescsLayout = .ARRAY,
|
||||
.u = .{
|
||||
.pGeometryDescs = geometry_descs.items.ptr,
|
||||
@@ -1048,7 +1048,7 @@ fn update(demo: *DemoState) void {
|
||||
common.newImGuiFrame(demo.frame_stats.delta_time);
|
||||
|
||||
c.igSetNextWindowPos(
|
||||
c.ImVec2{ .x = @floatFromInt(f32, demo.gctx.viewport_width) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImVec2{ .x = @as(f32, @floatFromInt(demo.gctx.viewport_width)) - 600.0 - 20, .y = 20.0 },
|
||||
c.ImGuiCond_FirstUseEver,
|
||||
c.ImVec2{ .x = 0.0, .y = 0.0 },
|
||||
);
|
||||
@@ -1082,8 +1082,8 @@ fn update(demo: *DemoState) void {
|
||||
{
|
||||
var pos: w32.POINT = undefined;
|
||||
_ = w32.GetCursorPos(&pos);
|
||||
const delta_x = @floatFromInt(f32, pos.x) - @floatFromInt(f32, demo.mouse.cursor_prev_x);
|
||||
const delta_y = @floatFromInt(f32, pos.y) - @floatFromInt(f32, demo.mouse.cursor_prev_y);
|
||||
const delta_x = @as(f32, @floatFromInt(pos.x)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_x));
|
||||
const delta_y = @as(f32, @floatFromInt(pos.y)) - @as(f32, @floatFromInt(demo.mouse.cursor_prev_y));
|
||||
demo.mouse.cursor_prev_x = pos.x;
|
||||
demo.mouse.cursor_prev_y = pos.y;
|
||||
|
||||
@@ -1119,7 +1119,7 @@ fn update(demo: *DemoState) void {
|
||||
}
|
||||
}
|
||||
|
||||
demo.light_position.c[0] = @floatCast(f32, 0.5 * @sin(0.25 * demo.frame_stats.time));
|
||||
demo.light_position.c[0] = @as(f32, @floatCast(0.5 * @sin(0.25 * demo.frame_stats.time)));
|
||||
}
|
||||
|
||||
fn draw(demo: *DemoState) void {
|
||||
@@ -1133,7 +1133,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = vm.Mat4.initPerspectiveFovLh(
|
||||
math.pi / 3.0,
|
||||
@floatFromInt(f32, gctx.viewport_width) / @floatFromInt(f32, gctx.viewport_height),
|
||||
@as(f32, @floatFromInt(gctx.viewport_width)) / @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
0.1,
|
||||
50.0,
|
||||
);
|
||||
@@ -1253,7 +1253,7 @@ fn draw(demo: *DemoState) void {
|
||||
var properties: *d3d12.IStateObjectProperties = undefined;
|
||||
hrPanicOnFail(demo.trace_shadow_rays_stateobj.?.QueryInterface(
|
||||
&d3d12.IID_IStateObjectProperties,
|
||||
@ptrCast(*?*anyopaque, &properties),
|
||||
@as(*?*anyopaque, @ptrCast(&properties)),
|
||||
));
|
||||
defer _ = properties.Release();
|
||||
|
||||
@@ -1262,17 +1262,17 @@ fn draw(demo: *DemoState) void {
|
||||
// ----------------------------------------------------------------------------------
|
||||
@memcpy(
|
||||
upload.cpu_slice[0..32],
|
||||
@ptrCast([*]const u8, properties.GetShaderIdentifier(L("generateShadowRay")))[0..32],
|
||||
@as([*]const u8, @ptrCast(properties.GetShaderIdentifier(L("generateShadowRay"))))[0..32],
|
||||
);
|
||||
@memset(upload.cpu_slice[32..][0..32], 0);
|
||||
@memcpy(
|
||||
upload.cpu_slice[64..][0..32],
|
||||
@ptrCast([*]const u8, properties.GetShaderIdentifier(L("shadowMiss")))[0..32],
|
||||
@as([*]const u8, @ptrCast(properties.GetShaderIdentifier(L("shadowMiss"))))[0..32],
|
||||
);
|
||||
@memset(upload.cpu_slice[96..][0..32], 0);
|
||||
@memcpy(
|
||||
upload.cpu_slice[128..][0..32],
|
||||
@ptrCast([*]const u8, properties.GetShaderIdentifier(L("g_shadow_hit_group")))[0..32],
|
||||
@as([*]const u8, @ptrCast(properties.GetShaderIdentifier(L("g_shadow_hit_group"))))[0..32],
|
||||
);
|
||||
@memset(upload.cpu_slice[160..][0..32], 0);
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ fn update(demo: *DemoState) void {
|
||||
_ = zgui.sliderInt("Mipmap Level", .{
|
||||
.v = &demo.mip_level,
|
||||
.min = 0,
|
||||
.max = @intCast(i32, demo.gctx.lookupResourceInfo(demo.texture).?.mip_level_count - 1),
|
||||
.max = @as(i32, @intCast(demo.gctx.lookupResourceInfo(demo.texture).?.mip_level_count - 1)),
|
||||
});
|
||||
}
|
||||
zgui.end();
|
||||
@@ -295,8 +295,8 @@ fn draw(demo: *DemoState) void {
|
||||
|
||||
const mem = gctx.uniformsAllocate(Uniforms, 1);
|
||||
mem.slice[0] = .{
|
||||
.aspect_ratio = @floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
.mip_level = @floatFromInt(f32, demo.mip_level),
|
||||
.aspect_ratio = @as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
.mip_level = @as(f32, @floatFromInt(demo.mip_level)),
|
||||
};
|
||||
pass.setBindGroup(0, bind_group, &.{mem.offset});
|
||||
pass.drawIndexed(6, 1, 0, 0, 0);
|
||||
|
||||
@@ -168,7 +168,7 @@ fn draw(demo: *DemoState) void {
|
||||
const gctx = demo.gctx;
|
||||
const fb_width = gctx.swapchain_descriptor.width;
|
||||
const fb_height = gctx.swapchain_descriptor.height;
|
||||
const t = @floatCast(f32, gctx.stats.time);
|
||||
const t = @as(f32, @floatCast(gctx.stats.time));
|
||||
|
||||
const cam_world_to_view = zm.lookAtLh(
|
||||
zm.f32x4(3.0, 3.0, -3.0, 1.0),
|
||||
@@ -177,7 +177,7 @@ fn draw(demo: *DemoState) void {
|
||||
);
|
||||
const cam_view_to_clip = zm.perspectiveFovLh(
|
||||
0.25 * math.pi,
|
||||
@floatFromInt(f32, fb_width) / @floatFromInt(f32, fb_height),
|
||||
@as(f32, @floatFromInt(fb_width)) / @as(f32, @floatFromInt(fb_height)),
|
||||
0.01,
|
||||
200.0,
|
||||
);
|
||||
|
||||
@@ -126,10 +126,10 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
const path = blk: {
|
||||
var path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
@@ -155,7 +155,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
var ink_style: *d2d1.IInkStyle = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.context.CreateInkStyle(
|
||||
&.{ .nibShape = .ROUND, .nibTransform = d2d1.MATRIX_3X2_F.initIdentity() },
|
||||
@ptrCast(*?*d2d1.IInkStyle, &ink_style),
|
||||
@as(*?*d2d1.IInkStyle, @ptrCast(&ink_style)),
|
||||
));
|
||||
break :blk ink_style;
|
||||
};
|
||||
@@ -164,7 +164,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
var ink: *d2d1.IInk = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.context.CreateInk(
|
||||
&.{ .x = 0.0, .y = 0.0, .radius = 0.0 },
|
||||
@ptrCast(*?*d2d1.IInk, &ink),
|
||||
@as(*?*d2d1.IInk, @ptrCast(&ink)),
|
||||
));
|
||||
|
||||
var p0 = d2d1.POINT_2F{ .x = 0.0, .y = 0.0 };
|
||||
@@ -208,26 +208,26 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
|
||||
const bezier_lines_path = blk: {
|
||||
var bezier_lines_path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &bezier_lines_path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&bezier_lines_path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(bezier_lines_path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(bezier_lines_path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
}
|
||||
sink.BeginFigure(.{ .x = 0.0, .y = 0.0 }, .FILLED);
|
||||
sink.AddLines(ink_points.items.ptr + 1, @intCast(u32, ink_points.items.len - 1));
|
||||
sink.AddLines(ink_points.items.ptr + 1, @as(u32, @intCast(ink_points.items.len - 1)));
|
||||
sink.EndFigure(.OPEN);
|
||||
break :blk bezier_lines_path;
|
||||
};
|
||||
|
||||
const left_mountain_geo = blk: {
|
||||
var left_mountain_path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &left_mountain_path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&left_mountain_path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(left_mountain_path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(left_mountain_path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
@@ -244,15 +244,15 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
};
|
||||
sink.AddLines(&points, points.len);
|
||||
sink.EndFigure(.CLOSED);
|
||||
break :blk @ptrCast(*d2d1.IGeometry, left_mountain_path);
|
||||
break :blk @as(*d2d1.IGeometry, @ptrCast(left_mountain_path));
|
||||
};
|
||||
|
||||
const right_mountain_geo = blk: {
|
||||
var right_mountain_path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &right_mountain_path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&right_mountain_path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(right_mountain_path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(right_mountain_path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
@@ -271,15 +271,15 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
};
|
||||
sink.AddLines(&points, points.len);
|
||||
sink.EndFigure(.CLOSED);
|
||||
break :blk @ptrCast(*d2d1.IGeometry, right_mountain_path);
|
||||
break :blk @as(*d2d1.IGeometry, @ptrCast(right_mountain_path));
|
||||
};
|
||||
|
||||
const sun_geo = blk: {
|
||||
var sun_path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &sun_path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&sun_path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(sun_path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(sun_path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
@@ -361,15 +361,15 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
});
|
||||
sink.EndFigure(.OPEN);
|
||||
|
||||
break :blk @ptrCast(*d2d1.IGeometry, sun_path);
|
||||
break :blk @as(*d2d1.IGeometry, @ptrCast(sun_path));
|
||||
};
|
||||
|
||||
const river_geo = blk: {
|
||||
var river_path: *d2d1.IPathGeometry = undefined;
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@ptrCast(*?*d2d1.IPathGeometry, &river_path)));
|
||||
hrPanicOnFail(gctx.d2d.?.factory.CreatePathGeometry(@as(*?*d2d1.IPathGeometry, @ptrCast(&river_path))));
|
||||
|
||||
var sink: *d2d1.IGeometrySink = undefined;
|
||||
hrPanicOnFail(river_path.Open(@ptrCast(*?*d2d1.IGeometrySink, &sink)));
|
||||
hrPanicOnFail(river_path.Open(@as(*?*d2d1.IGeometrySink, @ptrCast(&sink))));
|
||||
defer {
|
||||
hrPanicOnFail(sink.Close());
|
||||
_ = sink.Release();
|
||||
@@ -398,7 +398,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
.point3 = .{ .x = 296.0, .y = 392.0 },
|
||||
});
|
||||
sink.EndFigure(.CLOSED);
|
||||
break :blk @ptrCast(*d2d1.IGeometry, river_path);
|
||||
break :blk @as(*d2d1.IGeometry, @ptrCast(river_path));
|
||||
};
|
||||
|
||||
const radial_gradient_brush = blk: {
|
||||
@@ -412,7 +412,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
2,
|
||||
._2_2,
|
||||
.CLAMP,
|
||||
@ptrCast(*?*d2d1.IGradientStopCollection, &stop_collection),
|
||||
@as(*?*d2d1.IGradientStopCollection, @ptrCast(&stop_collection)),
|
||||
));
|
||||
defer _ = stop_collection.Release();
|
||||
|
||||
@@ -426,7 +426,7 @@ fn init(allocator: std.mem.Allocator) !DemoState {
|
||||
},
|
||||
null,
|
||||
stop_collection,
|
||||
@ptrCast(*?*d2d1.IRadialGradientBrush, &radial_gradient_brush),
|
||||
@as(*?*d2d1.IRadialGradientBrush, @ptrCast(&radial_gradient_brush)),
|
||||
));
|
||||
break :blk radial_gradient_brush;
|
||||
};
|
||||
@@ -458,34 +458,34 @@ fn drawShapes(demo: DemoState) void {
|
||||
gctx.d2d.?.context.DrawLine(
|
||||
.{ .x = 20.0, .y = 200.0 },
|
||||
.{ .x = 120.0, .y = 300.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
33.0,
|
||||
demo.stroke_style,
|
||||
);
|
||||
gctx.d2d.?.context.DrawLine(
|
||||
.{ .x = 160.0, .y = 300.0 },
|
||||
.{ .x = 260.0, .y = 200.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
33.0,
|
||||
demo.stroke_style,
|
||||
);
|
||||
gctx.d2d.?.context.DrawLine(
|
||||
.{ .x = 300.0, .y = 200.0 },
|
||||
.{ .x = 400.0, .y = 300.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
33.0,
|
||||
demo.stroke_style,
|
||||
);
|
||||
|
||||
gctx.d2d.?.context.DrawRectangle(
|
||||
&.{ .left = 500.0, .top = 100.0, .right = 600.0, .bottom = 200.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
5.0,
|
||||
null,
|
||||
);
|
||||
gctx.d2d.?.context.FillRectangle(
|
||||
&.{ .left = 610.0, .top = 100.0, .right = 710.0, .bottom = 200.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
gctx.d2d.?.context.FillRoundedRectangle(
|
||||
&.{
|
||||
@@ -493,29 +493,29 @@ fn drawShapes(demo: DemoState) void {
|
||||
.radiusX = 20.0,
|
||||
.radiusY = 20.0,
|
||||
},
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
|
||||
gctx.d2d.?.context.DrawEllipse(
|
||||
&.{ .point = .{ .x = 990.0, .y = 150.0 }, .radiusX = 50.0, .radiusY = 70.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
5.0,
|
||||
null,
|
||||
);
|
||||
gctx.d2d.?.context.FillEllipse(
|
||||
&.{ .point = .{ .x = 1100.0, .y = 150.0 }, .radiusX = 50.0, .radiusY = 70.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
gctx.d2d.?.context.DrawGeometry(
|
||||
@ptrCast(*d2d1.IGeometry, demo.ellipse),
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IGeometry, @ptrCast(demo.ellipse)),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
7.0,
|
||||
null,
|
||||
);
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(110.0, 0.0));
|
||||
gctx.d2d.?.context.FillGeometry(
|
||||
@ptrCast(*d2d1.IGeometry, demo.ellipse),
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IGeometry, @ptrCast(demo.ellipse)),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
null,
|
||||
);
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initIdentity());
|
||||
@@ -523,22 +523,22 @@ fn drawShapes(demo: DemoState) void {
|
||||
demo.brush.SetColor(&d2d1.COLOR_F{ .r = 0.2, .g = 0.4, .b = 0.8, .a = 1.0 });
|
||||
var i: u32 = 0;
|
||||
while (i < 5) : (i += 1) {
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(0.0, @floatFromInt(f32, i) * 50.0));
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(0.0, @as(f32, @floatFromInt(i)) * 50.0));
|
||||
gctx.d2d.?.context.DrawGeometry(
|
||||
@ptrCast(*d2d1.IGeometry, demo.path),
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IGeometry, @ptrCast(demo.path)),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
15.0,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(500.0, 800.0));
|
||||
gctx.d2d.?.context.DrawInk(demo.ink, @ptrCast(*d2d1.IBrush, demo.brush), demo.ink_style);
|
||||
gctx.d2d.?.context.DrawInk(demo.ink, @as(*d2d1.IBrush, @ptrCast(demo.brush)), demo.ink_style);
|
||||
|
||||
demo.brush.SetColor(&d2d1.COLOR_F{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 });
|
||||
gctx.d2d.?.context.DrawGeometry(
|
||||
@ptrCast(*d2d1.IGeometry, demo.bezier_lines_path),
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IGeometry, @ptrCast(demo.bezier_lines_path)),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
3.0,
|
||||
null,
|
||||
);
|
||||
@@ -547,12 +547,12 @@ fn drawShapes(demo: DemoState) void {
|
||||
for (demo.ink_points.items) |cp| {
|
||||
gctx.d2d.?.context.FillEllipse(
|
||||
&.{ .point = cp, .radiusX = 9.0, .radiusY = 9.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
}
|
||||
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(750.0, 900.0));
|
||||
gctx.d2d.?.context.DrawInk(demo.ink, @ptrCast(*d2d1.IBrush, demo.brush), demo.ink_style);
|
||||
gctx.d2d.?.context.DrawInk(demo.ink, @as(*d2d1.IBrush, @ptrCast(demo.brush)), demo.ink_style);
|
||||
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initTranslation(1080.0, 640.0));
|
||||
|
||||
@@ -560,7 +560,7 @@ fn drawShapes(demo: DemoState) void {
|
||||
demo.brush.SetColor(&d2d1.colorf.White);
|
||||
gctx.d2d.?.context.FillRectangle(
|
||||
&.{ .left = 100.0, .top = 100.0, .right = 620.0, .bottom = 420.0 },
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
|
||||
// NOTE(mziulek): D2D1 is slow. It creates and destroys resources every frame (see graphics.endDraw2d()).
|
||||
@@ -570,31 +570,31 @@ fn drawShapes(demo: DemoState) void {
|
||||
// NOTE(mziulek): Using 'demo.radial_gradient_brush' causes GPU-Based Validation errors (D3D11on12 bug?).
|
||||
// As a workaround we use 'demo.brush' (solid color brush).
|
||||
demo.brush.SetColor(&d2d1.colorf.DarkOrange);
|
||||
gctx.d2d.?.context.FillGeometry(demo.sun_geo, @ptrCast(*d2d1.IBrush, demo.brush), null);
|
||||
gctx.d2d.?.context.FillGeometry(demo.sun_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), null);
|
||||
|
||||
demo.brush.SetColor(&d2d1.colorf.Black);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.sun_geo, @ptrCast(*d2d1.IBrush, demo.brush), 5.0, null);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.sun_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), 5.0, null);
|
||||
|
||||
// Draw left mountain geometry.
|
||||
demo.brush.SetColor(&d2d1.colorf.OliveDrab);
|
||||
gctx.d2d.?.context.FillGeometry(demo.left_mountain_geo, @ptrCast(*d2d1.IBrush, demo.brush), null);
|
||||
gctx.d2d.?.context.FillGeometry(demo.left_mountain_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), null);
|
||||
|
||||
demo.brush.SetColor(&d2d1.colorf.Black);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.left_mountain_geo, @ptrCast(*d2d1.IBrush, demo.brush), 5.0, null);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.left_mountain_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), 5.0, null);
|
||||
|
||||
// Draw river geometry.
|
||||
demo.brush.SetColor(&d2d1.colorf.LightSkyBlue);
|
||||
gctx.d2d.?.context.FillGeometry(demo.river_geo, @ptrCast(*d2d1.IBrush, demo.brush), null);
|
||||
gctx.d2d.?.context.FillGeometry(demo.river_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), null);
|
||||
|
||||
demo.brush.SetColor(&d2d1.colorf.Black);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.river_geo, @ptrCast(*d2d1.IBrush, demo.brush), 5.0, null);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.river_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), 5.0, null);
|
||||
|
||||
// Draw right mountain geometry.
|
||||
demo.brush.SetColor(&d2d1.colorf.YellowGreen);
|
||||
gctx.d2d.?.context.FillGeometry(demo.right_mountain_geo, @ptrCast(*d2d1.IBrush, demo.brush), null);
|
||||
gctx.d2d.?.context.FillGeometry(demo.right_mountain_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), null);
|
||||
|
||||
demo.brush.SetColor(&d2d1.colorf.Black);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.right_mountain_geo, @ptrCast(*d2d1.IBrush, demo.brush), 5.0, null);
|
||||
gctx.d2d.?.context.DrawGeometry(demo.right_mountain_geo, @as(*d2d1.IBrush, @ptrCast(demo.brush)), 5.0, null);
|
||||
|
||||
gctx.d2d.?.context.SetTransform(&d2d1.MATRIX_3X2_F.initIdentity());
|
||||
}
|
||||
@@ -665,10 +665,10 @@ fn draw(demo: *DemoState) void {
|
||||
&d2d1.RECT_F{
|
||||
.left = 10.0,
|
||||
.top = 10.0,
|
||||
.right = @floatFromInt(f32, gctx.viewport_width),
|
||||
.bottom = @floatFromInt(f32, gctx.viewport_height),
|
||||
.right = @as(f32, @floatFromInt(gctx.viewport_width)),
|
||||
.bottom = @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
},
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
|
||||
demo.brush.SetColor(&d2d1.COLOR_F{ .r = 0.6, .g = 0.0, .b = 1.0, .a = 1.0 });
|
||||
@@ -683,10 +683,10 @@ fn draw(demo: *DemoState) void {
|
||||
&d2d1.RECT_F{
|
||||
.left = 1030.0,
|
||||
.top = 220.0,
|
||||
.right = @floatFromInt(f32, gctx.viewport_width),
|
||||
.bottom = @floatFromInt(f32, gctx.viewport_height),
|
||||
.right = @as(f32, @floatFromInt(gctx.viewport_width)),
|
||||
.bottom = @as(f32, @floatFromInt(gctx.viewport_height)),
|
||||
},
|
||||
@ptrCast(*d2d1.IBrush, demo.brush),
|
||||
@as(*d2d1.IBrush, @ptrCast(demo.brush)),
|
||||
);
|
||||
|
||||
demo.brush.SetColor(&d2d1.COLOR_F{ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 });
|
||||
|
||||
Reference in new issue
Block a user