https://bugs.winehq.org/show_bug.cgi?id=56368
Bug ID: 56368 Summary: hlsl_types_are_equal assert when vertex shaders uses SV_VertexID as lookup index Product: vkd3d Version: 1.10 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: hlsl Assignee: wine-bugs@winehq.org Reporter: martins.mozeiko@gmail.com Distribution: ---
Created attachment 76109 --> https://bugs.winehq.org/attachment.cgi?id=76109 test.c
Assertion failed: hlsl_types_are_equal(arg1->data_type, arg2->data_type), file ../wine/libs/vkd3d/libs/vkd3d-shader/hlsl.c, line 1320
This assert happens when D3DCompileFromFile or D3DCompile is called on hlsl vertex shader (vs_5_0 profile) source like this:
struct Input { float4 c0 : COL0; float4 c1 : COL1; float4 c2 : COL2; float4 c3 : COL3; uint id : SV_VertexID; };
float4 vs_main(Input input) : SV_Position { float4 col[] = { input.c0, input.c1, input.c2, input.c3 }; return col[input.id]; }
See attached test.c file that reproduces this assert. On Windows it prints out "ok = 1" and shader is successfully compiler. It can be compiled also with fxc.exe on commandline.
https://bugs.winehq.org/show_bug.cgi?id=56368
--- Comment #1 from Martins martins.mozeiko@gmail.com --- Created attachment 76110 --> https://bugs.winehq.org/attachment.cgi?id=76110 shader.hlsl
https://bugs.winehq.org/show_bug.cgi?id=56368
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW
--- Comment #2 from Nikolay Sivov bunglehead@gmail.com --- Confirming. That's something about variable index access:
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff7d361cf in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 0x00007ffff7ce8472 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff7cd24b2 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7cd23d5 in __assert_fail_base (fmt=0x7ffff7e46dc8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7ffff7f866d0 "hlsl_types_are_equal(arg1->data_type, arg2->data_type)", file=file@entry=0x7ffff7f7c766 "libs/vkd3d-shader/hlsl.c", line=line@entry=1345, function=function@entry=0x7ffff7f93870 <__PRETTY_FUNCTION__.44> "hlsl_new_binary_expr") at ./assert/assert.c:92 #5 0x00007ffff7ce13a2 in __assert_fail (assertion=assertion@entry=0x7ffff7f866d0 "hlsl_types_are_equal(arg1->data_type, arg2->data_type)", file=file@entry=0x7ffff7f7c766 "libs/vkd3d-shader/hlsl.c", line=line@entry=1345, function=function@entry=0x7ffff7f93870 <__PRETTY_FUNCTION__.44> "hlsl_new_binary_expr") at ./assert/assert.c:101 #6 0x00007ffff7f19578 in hlsl_new_binary_expr (ctx=ctx@entry=0x7fffffffd6b0, op=op@entry=HLSL_OP2_MUL, arg1=0x555555583000, arg2=arg2@entry=0x555555572e00) at libs/vkd3d-shader/hlsl.c:1345 #7 0x00007ffff7f21e7a in new_offset_from_path_index (loc=<optimized out>, offset_component=<synthetic pointer>, regset=<optimized out>, idx=<optimized out>, base_offset=0x555555582f70, type=0x55555556aad0, block=0x7fffffffd490, ctx=<optimized out>) at libs/vkd3d-shader/hlsl_codegen.c:63 #8 new_offset_instr_from_deref (loc=0x555555571710, offset_component=<synthetic pointer>, deref=0x555555571738, block=0x7fffffffd480, ctx=0x7fffffffd6b0) at libs/vkd3d-shader/hlsl_codegen.c:132 #9 replace_deref_path_with_offset (ctx=0x7fffffffd6b0, deref=0x555555571738, instr=0x5555555716e0) at libs/vkd3d-shader/hlsl_codegen.c:171 #10 0x00007ffff7f25492 in hlsl_transform_ir (ctx=ctx@entry=0x7fffffffd6b0, func=func@entry=0x7ffff7f220a0 <transform_instr_derefs>, block=block@entry=0x555555569ca0, context=context@entry=0x7ffff7f21c30 <replace_deref_path_with_offset>) at libs/vkd3d-shader/hlsl_codegen.c:631 #11 0x00007ffff7f282a6 in transform_derefs (block=0x555555569ca0, func=0x7ffff7f21c30 <replace_deref_path_with_offset>, ctx=0x7fffffffd6b0) at libs/vkd3d-shader/hlsl_codegen.c:703 #12 hlsl_emit_bytecode (ctx=ctx@entry=0x7fffffffd6b0, entry_func=0x555555569c50, target_type=VKD3D_SHADER_TARGET_DXBC_TPF, out=out@entry=0x7fffffffde10) at libs/vkd3d-shader/hlsl_codegen.c:5121 #13 0x00007ffff7f1e9db in hlsl_compile_shader (hlsl=hlsl@entry=0x7fffffffdc60, compile_info=0x7fffffffdd30, out=out@entry=0x7fffffffde10, message_context=message_context@entry=0x7fffffffdc70) at libs/vkd3d-shader/hlsl.c:3745 #14 0x00007ffff7f5c937 in compile_hlsl (message_context=0x7fffffffdc70, out=0x7fffffffde10, compile_info=<optimized out>) at libs/vkd3d-shader/vkd3d_shader_main.c:1656 #15 vkd3d_shader_compile (compile_info=<optimized out>, out=0x7fffffffde10, messages=0x7fffffffdcf8) at libs/vkd3d-shader/vkd3d_shader_main.c:1725 #16 0x0000555555557040 in main (argc=<optimized out>, argv=<optimized out>) at programs/vkd3d-compiler/main.c:860
https://bugs.winehq.org/show_bug.cgi?id=56368
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- This fixes it for me https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/909.
https://bugs.winehq.org/show_bug.cgi?id=56368
--- Comment #4 from Martins martins.mozeiko@gmail.com --- Thanks! I can confirm that change works for me too. Now wine runs the application with actual shader without problems.
https://bugs.winehq.org/show_bug.cgi?id=56368
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|hlsl_types_are_equal assert |hlsl compilatio fails when |when vertex shaders uses |uint input parameter is |SV_VertexID as lookup index |used to index arrays
https://bugs.winehq.org/show_bug.cgi?id=56368
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|hlsl compilatio fails when |hlsl compilation fails when |uint input parameter is |uint input parameter is |used to index arrays |used to index arrays
https://bugs.winehq.org/show_bug.cgi?id=56368
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED Fixed by SHA1| |d1c2ae3f0eaf0f3b64b0a5f4c50 | |ad402e822a4eb
--- Comment #5 from Nikolay Sivov bunglehead@gmail.com --- This is now fixed, https://gitlab.winehq.org/wine/vkd3d/-/commit/d1c2ae3f0eaf0f3b64b0a5f4c50ad4....
https://bugs.winehq.org/show_bug.cgi?id=56368
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Nikolay Sivov bunglehead@gmail.com --- Closing bugs fixed in 1.14.