-
Notifications
You must be signed in to change notification settings - Fork 134
Description
I apologize in advance for asking several questions in one issue, but since they are all related, I figured that would be okay.
-
Some of the instance flags available in gfx-rs/wgpu aren't exposed in
wgpu.h, namelyALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER,GPU_BASED_VALIDATION,VALIDATION_INDIRECT_CALL, andAUTOMATIC_TIMESTAMP_NORMALIZATION. I guess this is just a matter of updating the headers and the conversion code? -
The current instance flags mapping logic seems a bit flawed: when using
WGPUInstanceFlag_Default, which has the value of zero, meaning no instance flag is present, instead of resolving towgt::InstanceFlags::empty()it resolves towgt::InstanceFlags::default(), which is not the same. So it seems that there is no reasonable way to actually disable all instance flags? -
In turn,
wgt::InstanceFlags::default()invokeswgt::InstanceFlags::from_build_config(), which depends on whetherdebug_assertionsare enabled. I'm not that proficient in Rust build system, so it's not clear whether they are enabled or not in wgpu-native builds. So my question here is: are they? :) -
wgt::InstanceFlagssupports overriding the flags with environment variables, which can be very handy for troubleshooting problems on a remote machine (such as some player's/tester's machine when developing a game). Of course, this can be trivially implemented on the client-side, but it complicates upgrading to newer wgpu versions, and is in general a bit silly (since this code is already present in wgpu). Is there a possibility to expose this functionality in wgpu-native?
If my understanding of the above is correct, I propose changing WGPUInstanceFlags in the following way:
static const WGPUInstanceFlag WGPUInstanceFlag_Empty = 0x00000000;
static const WGPUInstanceFlag WGPUInstanceFlag_Debug = 1 << 0;
static const WGPUInstanceFlag WGPUInstanceFlag_Validation = 1 << 1;
// other actual flags ...
static const WGPUInstanceFlag WGPUInstanceFlag_Default = 1 << 48; // can be anything close to higher bits, I guess
static const WGPUInstanceFlag WGPUInstanceFlag_FromEnv = 1 << 49;
static const WGPUInstanceFlag WGPUInstanceFlag_Debugging = ...; // bitwise-or of some flags
static const WGPUInstanceFlag WGPUInstanceFlag_AdvancedDebugging = ...; // bitwise-or of some flags
static const WGPUInstanceFlag WGPUInstanceFlag_Force32 = 0x7FFFFFFF;
Here,
WGPUInstanceFlag_Emptymaps towgt::InstanceFlags::empty()WGPUInstanceFlag_Defaultmaps towgt::InstanceFlags::default()(bitwise-or'd with any other present bits)WGPUInstanceFlag_FromEnvmaps towgt::InstanceFlags::empty().with_env()(potentially overriding any other present bits)WGPUInstanceFlag_Debuggingcorresponds towgt::InstanceFlags::debugging()WGPUInstanceFlag_AdvancedDebuggingcorresponds towgt::InstanceFlags::advanced_debugging()
We could get rid of Default altogether, but it provides a sane default for many users. However, the proposed scheme changes the flags field of default-constructed InstanceExtras from Default to Empty, which is a breaking change.
I added Debugging and AdvancedDebugging mostly for completeness; I'm not sure how useful they are, but it might be handy for some users for, you know, debugging :)