vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().
shader_signature_find_element_for_reg() is also used in the TPF parser, where the program has not been validated yet, so it must not crash on errors.
The I/O normaliser can instead assume that the shader is already validated.
This fixes a crash with a shader used by The Falconeer. The bug is still present, because the shader will be incorrectly rejected, but at least the vkd3d-shader will fail gracefully.
Merge request reports
Activity
@cmccarthy I don't completely understand the logic behind the second part of
shader_signature_find_element_for_reg()
, i.e., after theFIXME()
. Since with this MR the function now returns a failure instead of crashing, is it possibile that that piece of logic can be moved to the caller instead? As far as I understand that's only to prevent a crash once compilation has already failed.I'm not absolutely certain but I think it covers the case where
write_mask
from a dcl_indexrange has components not found in all signature elements of the range, but those components are not used, so we find the element using only the lowest component and it will work. This assumes the lowest cannot be the one missing, which may prove incorrect.
@@ -1325,7 +1331,8 @@ static void io_normaliser_add_index_range(struct io_normaliser *normaliser, reg_idx = reg->idx[reg->idx_count - 1].offset; write_mask = range->dst.write_mask; - element_idx = shader_signature_find_element_for_reg(signature, reg_idx, write_mask); + if (!shader_signature_find_element_for_reg(signature, reg_idx, write_mask, &element_idx)) + vkd3d_unreachable(); range_map_set_register_range(range_map, reg_idx, range->register_count, signature->elements[element_idx].mask, true); }
Arguably we should just use vsir_signature_find_element_for_reg() here, if we're not otherwise going to use "element_idx".
added 1 commit
- 9551e79c - vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().
added 10 commits
-
9551e79c...32ced3bd - 9 commits from branch
wine:master
- 637a3cab - vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().
-
9551e79c...32ced3bd - 9 commits from branch