NVIDIAGameWorks / NVIDIAImageScaling

NVIDIA Image Scaling SDK
MIT License
507 stars 59 forks source link

Sample code has some uninitialized values causing random D3D failures #3

Closed mbucchia closed 2 years ago

mbucchia commented 2 years ago

Hi! I'm on 38402c9efb67ee5a004d03d3545362b9435d1bae and integrating the DX11 sample code into my application, I noticed that a few data structures are not zero'ed and have uninitialized fields. This leads to some D3D calls randomly failing.

The one I hit last night was with the samplerDesc in the bilinear upscaler:

https://github.com/NVIDIAGameWorks/NVIDIAImageScaling/blob/main/samples/DX11/src/BilinearUpscale.cpp#L105

There is no ZeroMemory() and the MinLOD fields is left uninitialized. Somehow this works OK when I am using a certain device, but with another one, I get this error with the D3D debug layer:

D3D11 ERROR: ID3D11Device::CreateSamplerState: MinLOD be in the range [-INF to +INF].  -1.#QNAN0 specified. [ STATE_CREATION ERROR #228: CREATESAMPLERSTATE_INVALIDMINLOD]

Same remark in the DeviceResources implementation here:

https://github.com/NVIDIAGameWorks/NVIDIAImageScaling/blob/main/samples/DX11/src/DeviceResources.cpp#L127

This goes away by explicitly setting MinLOD to 0.

Thanks!

PS: You have done an amazing job with both the NIS shader and the the sample code! It's been super smooth to integrate into my application. Thank you!

abernalnv commented 2 years ago

@mbucchia, thanks for reporting the bug and the fix :). We're glad that you found the shaders easy to integrate with your application!

mbucchia commented 2 years ago

Awesome! I also see you committed a fix for the pixel shift that started in 1.0.1, which I intended to report soon. Looking forward to trying it out!