[PATCH vkd3d 2/2] vkd3d-shader/hlsl: Implement floor().

Nikolay Sivov nsivov at codeweavers.com
Mon Dec 13 04:12:34 CST 2021



On 12/13/21 13:09, Giovanni Mascellani wrote:
> Hi,
>
> On 13/12/21 10:56, Nikolay Sivov wrote:
>>> For the record, add_unary_arithmetic_expr is not completely correct 
>>> here, because, for example, it produces an int4 output type when 
>>> input is int4, while native would convert to float4.
>>>
>>> However, integer floor is not implemented anyway, and other 
>>> intrinsics are broken in the same way, so there's not reason to 
>>> delay this patch.
>>>
>>> Eventually I think it would make sense to have another helper called 
>>> something like "add_unary_float_arithmetic_expr" that always 
>>> converts its input to half4 or float4.
>>>
>> I don't think it needs to convert anything. For integer input it 
>> simply should returns it as a result, for 
>> floor()/round()/trunc()/ceil().
>> After that normal cast should happen, resulting in ftoi/itof. Or 
>> maybe for integer case it's enough to return cast node to arg type.
>
> As far as I can see it really returns a float4 for an int4 input. This 
> matters, for example, if function overloading is done on the output 
> (and possibly, in edge cases, for very big integers).
How do you check that?

>
>> By the way, is it possible to get textual output right away, without 
>> going through dxbc -> disasm?
>
> What I usually do is enable logging and run some .shader_test that 
> compiles and run that code. It will dump to the log both the IR and 
> the compiled code. Of course is still compilation and disassembling, 
> but you don't have to do it by hand.
>
> OTOH, I think you're not the first one to ask for that thing (hlsl -> 
> d3d_asm directly in vkd3d-compiler), so it might eventually happen.
>
> Giovanni.
>




More information about the wine-devel mailing list