Repository: shader-slang/slang
File: tools/render-test/render-test-main.cpp (C++)

Code before:
            if (options.cacheRhiDevice)
            {
                rhiDevice = DeviceCache::acquireDevice(desc);
            }
            else
            {
                auto result = rhi::getRHI()->createDevice(desc, rhiDevice.writeRef());
                if (SLANG_FAILED(result))
                {
                    rhiDevice = nullptr;
                }
            }
            if (!rhiDevice)
            {
                // We need to be careful here about SLANG_E_NOT_AVAILABLE. This return value means
                // that the renderer couldn't be created because it required *features* that were
                // *not available*. It does not mean the renderer in general couldn't be
                // constructed.
                //
                // Returning SLANG_E_NOT_AVAILABLE will lead to the test infrastructure ignoring
                // this test.
                //
                // We also don't want to output the 'Unable to create renderer' error, as this isn't
                // an error.
                SlangResult res =
                    SLANG_E_NOT_AVAILABLE; // Default to not available if device creation fails
                if (!options.onlyStartup)
                {
                    fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer());
                }

                return res;
            }
            deviceWrapper = CachedDeviceWrapper(rhiDevice);
            SLANG_ASSERT(deviceWrapper);
        }

        for (const auto& feature : requiredFeatureList)
        {
            // If doesn't have required feature... we have to give up
            if (!deviceWrapper->hasFeature(feature))
            {
                return SLANG_E_NOT_AVAILABLE;
            }
        }
    }

    // Print adapter info after device creation but before any other operations
    if (options.showAdapterInfo)
    {
        auto info = deviceWrapper->getInfo();

Review comment (suggestion):
This line doesn't make sense to me.
The previous code was trying to snooze the error message if res is SLANG_E_NOT_AVAILABLE.
That seems to match to the comment described above.

But the new code wouldn't do it anymore.

Code after:
            SlangResult res;
            if (options.cacheRhiDevice)
            {
                res = DeviceCache::acquireDevice(desc, rhiDevice.writeRef());
                if (SLANG_FAILED(res))
                {
                    rhiDevice = nullptr;
                }
            }
            else
            {
                res = rhi::getRHI()->createDevice(desc, rhiDevice.writeRef());
                if (SLANG_FAILED(res))
                {
                    rhiDevice = nullptr;
                }
            }

            // Check result for both cached and non-cached paths
            if (SLANG_FAILED(res) || !rhiDevice)
            {
                // We need to be careful here about SLANG_E_NOT_AVAILABLE. This return value means
                // that the renderer couldn't be created because it required *features* that were
                // *not available*. It does not mean the renderer in general couldn't be
                // constructed.
                //
                // Returning SLANG_E_NOT_AVAILABLE will lead to the test infrastructure ignoring
                // this test.
                //
                // We also don't want to output the 'Unable to create renderer' error, as this isn't
                // an error.
                if (res == SLANG_E_NOT_AVAILABLE)
                {
                    return res;
                }
                if (!options.onlyStartup)
                {
                    fprintf(stderr, "Unable to create renderer %s\n", rendererName.getBuffer());
                }
                return res;
            }
            SLANG_ASSERT(rhiDevice);
            deviceWrapper = CachedDeviceWrapper(rhiDevice);
        }

        for (const auto& feature : requiredFeatureList)
        {
            // If doesn't have required feature... we have to give up
            if (!deviceWrapper->hasFeature(feature))
            {
                return SLANG_E_NOT_AVAILABLE;