gpu: use PowerPreference
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9c2fc82fa3
commit
40f92dd9d9
4 changed files with 6 additions and 7 deletions
|
|
@ -74,7 +74,9 @@ pub fn setup(allocator: std.mem.Allocator) !Setup {
|
||||||
try discoverAdapters(instance, window, backend_type);
|
try discoverAdapters(instance, window, backend_type);
|
||||||
|
|
||||||
// Request an adapter.
|
// Request an adapter.
|
||||||
const backend_adapter = switch (nosuspend gpu_interface.requestAdapter(&.{})) {
|
const backend_adapter = switch (nosuspend gpu_interface.requestAdapter(&.{
|
||||||
|
.power_preference = .high_performance,
|
||||||
|
})) {
|
||||||
.adapter => |v| v,
|
.adapter => |v| v,
|
||||||
.err => |err| {
|
.err => |err| {
|
||||||
std.debug.print("failed to get adapter: error={} {s}\n", .{ err.code, err.message });
|
std.debug.print("failed to get adapter: error={} {s}\n", .{ err.code, err.message });
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ pub const Descriptor = struct {
|
||||||
entries: []const Entry,
|
entries: []const Entry,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: can this be extern struct / ABI compatible?
|
|
||||||
pub const Entry = struct {
|
pub const Entry = struct {
|
||||||
binding: u32,
|
binding: u32,
|
||||||
visibility: ShaderStage,
|
visibility: ShaderStage,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const std = @import("std");
|
||||||
|
|
||||||
const Surface = @import("Surface.zig");
|
const Surface = @import("Surface.zig");
|
||||||
const Adapter = @import("Adapter.zig");
|
const Adapter = @import("Adapter.zig");
|
||||||
|
const PowerPreference = @import("enums.zig").PowerPreference;
|
||||||
|
|
||||||
const Interface = @This();
|
const Interface = @This();
|
||||||
|
|
||||||
|
|
@ -30,8 +31,7 @@ pub inline fn release(interface: Interface) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const RequestAdapterOptions = struct {
|
pub const RequestAdapterOptions = struct {
|
||||||
// TODO:
|
power_preference: PowerPreference,
|
||||||
//power_preference: PowerPreference,
|
|
||||||
force_fallback_adapter: bool = false,
|
force_fallback_adapter: bool = false,
|
||||||
|
|
||||||
/// Only respected by native WebGPU implementations.
|
/// Only respected by native WebGPU implementations.
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,7 @@ const interface_vtable = Interface.VTable{
|
||||||
const opt = c.WGPURequestAdapterOptions{
|
const opt = c.WGPURequestAdapterOptions{
|
||||||
.nextInChain = null,
|
.nextInChain = null,
|
||||||
.compatibleSurface = if (options.compatible_surface) |surface| @ptrCast(c.WGPUSurface, surface.ptr) else null,
|
.compatibleSurface = if (options.compatible_surface) |surface| @ptrCast(c.WGPUSurface, surface.ptr) else null,
|
||||||
// TODO:
|
.powerPreference = @enumToInt(options.power_preference),
|
||||||
//.powerPreference = power_preference,
|
|
||||||
.powerPreference = c.WGPUPowerPreference_Undefined,
|
|
||||||
.forceFallbackAdapter = options.force_fallback_adapter,
|
.forceFallbackAdapter = options.force_fallback_adapter,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue