Resolve C2360 for VS2026 by hoisting switch-local declarations#125
Resolve C2360 for VS2026 by hoisting switch-local declarations#125BinqAdams wants to merge 1 commit intoNVIDIAGameWorks:mainfrom
Conversation
| # Get path to Visual Studio installation using vswhere. | ||
| # | ||
| $vsPath = &$vsWhere -latest -version "[16.0,18.0)" -products * ` | ||
| $vsPath = &$vsWhere -latest -products * ` |
There was a problem hiding this comment.
Completely removing the version check is probably a bad idea - could cause problems for people with older VS versions installed. Should this just be -version "[16.0,19.0)" instead?
There was a problem hiding this comment.
I've put this in :)
|
Please squash your commits. |
b1d6f64 to
8c65bfd
Compare
Squashed! |
| ctx->dispatch(workgroups.width, workgroups.height, workgroups.depth); | ||
| } | ||
| case RaytraceMode::RayQuery: { | ||
| VkExtent3D workgroups = util::computeBlockCount(rayDims, VkExtent3D { 16, 8, 1 }); |
There was a problem hiding this comment.
(sorry about the long delay, got rather busy for a bit)
Instead of adding large braces like this, a better fix would be to move the VkExtent3D workgroups declarations outside of the switch statements - so it should look like
VkExtent3D workgroups;
switch (blah) {
case RayQuery:
workgroups = blah;
...
When DXVK Remix is built with MSVC 19.x (Visual Studio 2026) under /WX, the compiler emits C2360 / C2361 errors for every case body that declares a local VkExtent3D directly under the case label without an intervening block. The C++ rule is that a non-trivial initialization cannot be jumped over by other case labels in the same switch. Hoist the workgroups computation above the switch in three pathtracer dispatch sites: - rtx_pathtracer_gbuffer.cpp - rtx_pathtracer_integrate_direct.cpp - rtx_pathtracer_integrate_indirect.cpp Each switch only ever uses workgroups in its RayQuery case (other modes call traceRays); the value is the same expression in all three files. Hoisting makes it const, kills the C2360 / C2361, and keeps each case body free of brace-wrapping. The computation is cheap (an integer divide) so the marginal cost in the non-RayQuery modes is negligible. build_common.ps1: bump the vswhere version range from [16.0,18.0) to [16.0,19.0) so VS 2026 satisfies the lower-bound check while still rejecting older releases.
8c65bfd to
a253c52
Compare
|
@MarkEHenderson — apologies for the long delay on this. Force-pushed a rework that addresses your Feb feedback:
Smoke-built |
|
Just merged this internally, it should show up on github soon. |
Summary
Allow DXVK Remix to build cleanly under MSVC 19.x (Visual Studio 2026) with
/WXenabled.Motivation
Three pathtracer dispatch sites declare
VkExtent3D workgroupsdirectly under acase:label inside a switch. MSVC 19.x emits C2360 / C2361 ("initialization ofworkgroupsis skipped bycaselabel") and, with/WX, the build aborts. The C++ rule is that a non-trivial initialization cannot be jumped over by other case labels in the same switch.build_common.ps1separately rejects VS 2026 because itsvswherequery is pinned to[16.0,18.0).What Changed
Hoist
const VkExtent3D workgroups = util::computeBlockCount(rayDims, VkExtent3D { 16, 8, 1 });above theswitchin three files:src/dxvk/rtx_render/rtx_pathtracer_gbuffer.cppsrc/dxvk/rtx_render/rtx_pathtracer_integrate_direct.cppsrc/dxvk/rtx_render/rtx_pathtracer_integrate_indirect.cppOnly the
RayQuerycase usesworkgroups(other modes calltraceRays); the value is the same expression in all three files. Hoisting kills C2360 / C2361 without adding brace-wrapping inside each case body. The marginal cost of computingworkgroupsin non-RayQuerymodes is an integer divide.Bump
build_common.ps1vswhereversion range from[16.0,18.0)to[16.0,19.0)so VS 2026 satisfies the lower-bound check while still rejecting older releases.Net diff: 4 files, +4 / -4.
Testing
Built
_Comp64DebugOptimizedend-to-end against VS 2026 + Vulkan SDK 1.4.x, ninja backend; producedd3d9.dlland ran install steps cleanly with no warnings or errors from any of the three modified pathtracer compilation units.