Skip to content

[Breaking] Fold zwin32, zxaudio2 and zd3d12 into zwindows #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 6, 2024
Merged

Conversation

hazeycode
Copy link
Member

@hazeycode hazeycode commented Aug 26, 2024

These libs are almost always used together. Why not just put them together into an uber windows sdk Zig package?

Checklist

  • zwin32 => zwindows
  • zxaudio2 => zwindows/zxaudio2
  • zd3d12 => zwindows/zd3d12
  • Update README

Changes to build.zig usage:

    const zwindows_dependency = b.dependency("zwindows", .{
        // If using the optional helper libs, here are some good settings to start with:
        // (otherwise all default to `false`)
        .zxaudio2_debug_layers = (builtin.mode == .Debug),
        .zd3d12_debug_layers = (builtin.mode == .Debug),
        .zd3d12_gbv = b.option(bool, "zd3d12_gbv", "Enable GPU-Based Validation") orelse false,
    });
    
    // Import the Windows API bindings
    exe.root_module.addImport("zwindows", zwindows_dependency.module("zwindows"));

    // Import the optional zxaudio2 helper library
    exe.root_module.addImport("zxaudio2", zwindows_dependency.module("zxaudio2"));
    
    // Import the optional zd3d12 helper library
    exe.root_module.addImport("zd3d12", zwindows_dependency.module("zd3d12"));

Other changes:

  • w32.zig renamed to bindings/windows.zig as this is now serving as an extension of std.os.windows (parts of which will be upstreamed or deprecated).
const zwindows = @import("zwindows");
const HWND = zwindows.windows.HWND;
const hrPanic = zwindows.windows.hrPanic;
const hrPanicOnFail = zwindows.hrPanicOnFail;
const d3d12 = zwindows.d3d12;
// etc
  • zd3d12_enable_d2d build option deleted. The user can just not call the d2d fns if they don't want it.
  • zd3d12_upload_heap_capacity build option deleted. Now capacity can be set at runtime when calling zd3d12.GraphicsContext.init who's function signature has been changed to take an args struct.
  • Renamed top-level build options for consistency.

@hazeycode hazeycode added the breaking Indicates an API breaking change label Aug 26, 2024
@hazeycode hazeycode changed the title Fold zwin32, zxaudio2 and zd3d12 into zwindows [Breaking] Fold zwin32, zxaudio2 and zd3d12 into zwindows Aug 26, 2024
@hazeycode hazeycode added this to the 0.7.0 milestone Aug 26, 2024
@hazeycode hazeycode mentioned this pull request Aug 26, 2024
21 tasks
@Srekel
Copy link
Member

Srekel commented Aug 27, 2024

Will zxaudio2 and z3d12 be optional submodules to zwindows, or how will it work?

@hazeycode
Copy link
Member Author

Will zxaudio2 and z3d12 be optional submodules to zwindows, or how will it work?

Yes they could be zig modules provided by zwindows dependency. I will update the PR description later to explain better.

@hazeycode hazeycode force-pushed the zwindows branch 3 times, most recently from 939d3b9 to 870cc99 Compare August 27, 2024 23:35
@Srekel
Copy link
Member

Srekel commented Aug 29, 2024

Just in case you're not aware, there's a proposal to remove usingnamespace, so it may be worth avoiding. Seems like it could go either way at the moment.

ziglang/zig#20663

@hazeycode
Copy link
Member Author

I've removed the usingnamespaces except for the one that pulls in std.os.windows. This can be removed later without affecting the public API.

PR description has been updated to reflect the changes.

@hazeycode hazeycode marked this pull request as ready for review August 31, 2024 21:18
@hazeycode
Copy link
Member Author

Any objections to me merging this as is?

@hazeycode hazeycode merged commit 8e03310 into main Sep 6, 2024
3 checks passed
@hazeycode hazeycode deleted the zwindows branch September 6, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Indicates an API breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants