vkd3d-shader/hlsl: Initialize unused constant values in compilation passes.
Even though the uninitialized values shouldn't be used in the output binary program, they still show up in it, and affect the checksum, so we better make them zeroes.
This error was reported by valgrind:
libtool --mode=execute valgrind --track-origins=yes vkd3d-build/tests/shader_runner vkd3d/tests/hlsl/static-initializer.shader_test
==46180== Conditional jump or move depends on uninitialised value(s)
==46180== at 0x48D98C7: parse_dxbc.isra.0 (dxbc.c:182)
==46180== by 0x48DA044: vkd3d_shader_parse_dxbc (dxbc.c:308)
==46180== by 0x488D1B6: vkd3d_shader_parse_dxbc_source_type (vkd3d_shader_utils.h:37)
==46180== by 0x488D1B6: create_shader_stage.isra.0 (state.c:1988)
==46180== by 0x48926B6: d3d12_pipeline_state_init_graphics (state.c:3084)
==46180== by 0x4893A96: d3d12_pipeline_state_create_graphics (state.c:3280)
==46180== by 0x4878498: d3d12_device_CreateGraphicsPipelineState (device.c:2619)
==46180== by 0x1FFEFFECC7: ???
==46180== by 0xE8: ???
==46180== by 0x47: ???
==46180== by 0x61: ???
==46180== by 0x660066000000023: ???
==46180== by 0x661066100000044: ???
==46180== Uninitialised value was created by a stack allocation
==46180== at 0x48F3FF0: hlsl_fold_constant_swizzles (hlsl_constant_ops.c:1010)
Thank you valgrind!
Merge request reports
Activity
added 1 commit
- 7732afbf - vkd3d-shader/hlsl: Initialize unused constant components to zero.
If the concern is unused components being written in immconst registers, this doesn't seem like the right place to fix it.
You're probably right; I don't think we should be writing these in the backend. I was thinking it's not great to carry uninitialised data in the HLSL IR either, but we should actually simply never access values beyond what's defined by the associated types.
Personally I would just drop 1/3 and 2/3, but I'm willing to be gainsaid.
This error was reported by valgrind:
Incidentally, for the future, the convention for bugs found by tools is to put the tool name in parentheses at the end of the subject line, e.g. "vkd3d-shader/hlsl: Initialize something (Valgrind)."
added 1 commit
- 247e07b7 - vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
Shouldn't the condition be "j < width" rather than "i < width"?
Yes, in fact, I failed to realize that 3 tests were not passing, because I just looked to valgrind's output...
Actually, for that matter, shouldn't "j < width" be an assertion?
No, because we are deliberately passing map_writemask with more than "width" bites on in some places, usually using
VKD3DSP_WRITEMASK_ALL
.Actually, for that matter, shouldn't "j < width" be an assertion?
No, because we are deliberately passing map_writemask with more than "width" bites on in some places, usually using
VKD3DSP_WRITEMASK_ALL
.Fair enough. [To be pedantic, we don't do that for sm4_src_from_constant_value(), but the precedent is set by sm4_src_from_node().]
added 1 commit
- 0eec86e5 - vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
added 1 commit
- e6ac5c3e - vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
added 14 commits
-
e6ac5c3e...89eda518 - 13 commits from branch
wine:master
- ed9e236b - vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
-
e6ac5c3e...89eda518 - 13 commits from branch