vkd3d-shader/hlsl: Always work with the extern resource's component type.
This fixes runtime errors reported by UBSan, such as this:
vkd3d/libs/vkd3d-shader/tpf.c:6075:87: runtime error: load of value 7, which is not a valid value for type '_Bool'
when trying to compile shaders that contain UAV arrays on 4.0 profiles.
Before this commit, tpf.c accesses the
hlsl_type->e.resource.rasteriser_ordered
field, but on 4.0 and 4.1 profiles these code paths can also be reached by UAV arrays which are HLSL_CLASS_ARRAY and this field is not supposed to be accessed.
By coincidence, the value of hlsl_type->e.array.elements_count is being read because these fields have the same offset in the hlsl_type.e union.
Merge request reports
Activity
I'm not convinced this is the right solution. Take for example
write_sm4_dcl_textures()
: the code clearly assumes that the resource is a texture or a UAV in a few other places (e.g. by readingresource->data_type->e.resource
orresource->data_type->sampler_dim
). So either an array shouldn't reach that code, or the whole function should be ready to accept it.Also, I'd try to avoid duplicating information in
struct extern_resource
. It seems thatresource->data_type
already has all the information that code needs. Maybe we just need to checkresource->data_type->class
before reading from the union.I'm not convinced this is the right solution. Take for example
write_sm4_dcl_textures()
: the code clearly assumes that the resource is a texture or a UAV in a few other places (e.g. by readingresource->data_type->e.resource
orresource->data_type->sampler_dim
). So either an array shouldn't reach that code, or the whole function should be ready to accept it.Yeah, we should probably just be storing the component type in extern_resource. I don't think there's any reason not to do that.
added 30 commits
-
fdb577ab...51abec8c - 29 commits from branch
wine:master
- 419b32ae - vkd3d-shader/hlsl: Always work with the extern resource's component type.
-
fdb577ab...51abec8c - 29 commits from branch
added 25 commits
-
419b32ae...80b2a2eb - 24 commits from branch
wine:master
- 10ed8a68 - vkd3d-shader/hlsl: Always work with the extern resource's component type.
-
419b32ae...80b2a2eb - 24 commits from branch
added 10 commits
-
10ed8a68...9cf479d4 - 9 commits from branch
wine:master
- 412f91a1 - vkd3d-shader/hlsl: Always work with the extern resource's component type.
-
10ed8a68...9cf479d4 - 9 commits from branch