Skip to content
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

D3D11_CLEAR_FLAG does not implement bit ops and uses i32 instead of u32 internally #1362

Closed
CarePackage17 opened this issue Nov 9, 2022 · 2 comments
Assignees
Labels
bug Something isn't working rust Critical for Rust adoption

Comments

@CarePackage17
Copy link

Which crate is this about?

windows

Crate version

0.43.0

Summary

I'm writing a D3D11 sample app with the windows crate and came across a minor inconvenience: D3D11_CLEAR_FLAG does not implement bit ops, like e.g. D3D11_CREATE_DEVICE_FLAG does, so instead of writing

let clear_flags = D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL;

I need to write

let clear_flags = D3D11_CLEAR_DEPTH.0 | D3D11_CLEAR_STENCIL.0;

Later I want to call ID3D11DeviceContext::ClearDepthStencilView, but the underlying type of clear_flags is i32 while the API expects a u32, so I need to add another cast so it compiles again:

let dsv = ...
let context = ...

context.ClearDepthStencilView(&dsv, clear_flags as u32, 1.0, 0);

I think this could be fixed by using u32 as the underlying type for D3D11_CLEAR_FLAG, like D3D11_CREATE_DEVICE_FLAG does.

Toolchain version/configuration

Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\waved.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.65.0 (897e37553 2022-11-02)

Reproducible example

No response

Crate manifest

No response

Expected behavior

No response

Actual behavior

No response

Additional comments

No response

@CarePackage17 CarePackage17 added the bug Something isn't working label Nov 9, 2022
@kennykerr
Copy link
Contributor

According to the docs, this should be unsigned and needs the Flags attribute. Will transfer to the win32metadata repo for resolution.

https://learn.microsoft.com/en-us/windows/win32/api/d3d11/ne-d3d11-d3d11_clear_flag

@kennykerr kennykerr transferred this issue from microsoft/windows-rs Nov 9, 2022
@kennykerr kennykerr added the rust Critical for Rust adoption label Nov 9, 2022
@mikebattista mikebattista self-assigned this Nov 9, 2022
@mikebattista
Copy link
Collaborator

Windows.Win32.Graphics.Direct3D11.D3D11_CLEAR_FLAG : => [Flags]
Windows.Win32.Graphics.Direct3D11.D3D11_CLEAR_FLAG.value__...System.Int32 => System.UInt32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rust Critical for Rust adoption
Projects
None yet
Development

No branches or pull requests

3 participants