Fix RenderingDevice::texture_clear() behaving unexpectedly when using the D3D12 driver#117294
Conversation
…ewUint() in command_clear_color_texture()
|
For the record, your commit seems not to be linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info. The CI failures seem unrelated to this commit, it's just a GH fluke, and should be resolved by maintainers restarting the builds manually. |
|
Thank you for pointing that out. I was using an email address that was not yet linked to my GitHub account for the commit. Should be fixed now! |
|
What behavior does this show with integer textures? If it matches how Vulkan looks, then it should be ok. Given this function takes a "Color", it doesn't seem like it was intended to be used for integer textures in the first place. |
|
The behavior with integer textures is very inconsistent and seems to depend on how the underlying graphics driver implements the Vulkan/D3D12 API. I tested this today with different Before:
This PR:
Main conclusion: Clearing integer textures using In my opinion, Furthermore, clearing integer textures with On a note: before this PR, setting |
blueskythlikesclouds
left a comment
There was a problem hiding this comment.
Ok, makes sense. The debug layer also seems happy so let's go with it.
|
Thanks! Congratulations on your first merged contribution! 🎉 |
Fixes: #117210
Using
RenderingDevice::texture_clear()led to different results between the Vulkan and D3D12 driver, depending on theDataFormatof the texture.This PR changes the D3D12 driver to use
ID3D12GraphicsCommandList::ClearUnorderedAccessViewFloat()for clearing color textures instead ofID3D12GraphicsCommandList::ClearUnorderedAccessViewUint().As far as my testing goes, this should make the result of
RenderingDevice::texture_clear()be on par between the D3D12 and Vulkan driver.The following example clears textures with different data formats to
Color.HOT_PINK(left to right:R8G8B8A8_UNORM,R32G32B32A32_SFLOAT,R8_UNORM,R32_SFLOAT).Before:

This PR:

Example project: texture-clear-example.zip
From what I've read about the behavior of those two clearing functions, I think that
ClearUnorderedAccessViewFloat()would be more appropriate for clearing color textures.However, I am not sure whether I am missing something here that might cause issues, as I don't know whether there was a reason for using
ClearUnorderedAccessViewUint()in the first place.