vkd3d-shader/tpf: Add support for emitting sample_l instructions
From what I can tell, the recent work on SampleBias/SampleLevel did all of the work for us, we just need to take the same framework and include the case for the sample_l
instruction.
Tested with some shaders from the native Linux version of Little Racers STREET.
Merge request reports
Activity
added 1 commit
- b0d84924 - vkd3d-shader/tpf: Add support for emitting sample_l instructions
Quick push to add
LOD
to what was previously only checking forLOD_BIAS
- this gets LRS to run with the vkd3d HLSL compiler (the error I was getting before looked like BZ#54832 again, turns out that was wrong)!- Resolved by Ethan Lee
I just realized one more thing. I think we are not properly following the specification for both sample_l and sample_b.
In the Restrictions section of the documentation for sample_b it is mentioned that the last src register must use a single component selector if it is not a scalar immediate. This "select_component" is also ilustrated in the sample_l format:
sample_l[_aoffimmi(u,v,w)] dest[.mask], srcAddress[.swizzle], srcResource[.swizzle], srcSampler, srcLOD.select_component
Currently, we are not respecting that since sm4_src_from_node() sets
src->swizzle_type = VKD3D_SM4_SWIZZLE_VEC4;
by default.
It should be VKD3D_SM4_SWIZZLE_SCALAR in this case.
If I am not mistaken, a simple:
instr.srcs[3].swizzle_type = VKD3D_SM4_SWIZZLE_SCALAR;
after calling sm4_src_from_node() should do. The disassembly should show a single component in the swizzle of the last src register.
For the record, before the patch, with the native dissasembler
fxc -dumpbin
, I was getting:sample_l r0.xyzw, r0.xyxx, t0.xyzw, s0, r0.zzzz
and I see that our dissasembler shows the last bit as
r0.z
. So there is a discrepancy there.Anyways, after the patch, I get
sample_l r0.xyzw, r0.xyxx, t0.xyzw, s0, r0.z
with the native dissasembler. So it seems good now. :)
added 1 commit
- 745bb4f1 - vkd3d-shader/tpf: For sample_l/sample_b, set lod swizzle to SCALAR.
For the record, before the patch, with the native dissasembler
fxc -dumpbin
, I was getting:sample_l r0.xyzw, r0.xyxx, t0.xyzw, s0, r0.zzzz
and I see that our dissasembler shows the last bit as
r0.z
. So there is a discrepancy there.That's mostly a consequence of sm1/d3dbc not having a distinction between VKD3D_SM4_SWIZZLE_SCALAR/VKD3D_SM4_SWIZZLE_VEC4; "r0.z" and "r0.zzzz" are equivalent there. See also shader_sm4_read_src_param() and shader_dump_src_param(). We should probably fix that, although there would be consequences for e.g. the SPIR-V backend as well.
added 24 commits
-
745bb4f1...abb207fa - 21 commits from branch
wine:master
- e500f463 - tests: Add a test for SampleLevel() function.
- 4f004638 - vkd3d-shader/tpf: Add support for emitting sample_l instructions
- f5baf8e6 - vkd3d-shader/tpf: For sample_l/sample_b, set lod swizzle to SCALAR.
Toggle commit list-
745bb4f1...abb207fa - 21 commits from branch
The test commit in this MR could be obsoleted by !191 (merged), depending on when each is merged.
Edited by Ethan Leeadded 6 commits
- 719e4a68 - tests/shader_runner: Add support for creating mipmapped textures.
- 99c13c01 - tests: Add a test for loading from nonzero mipmap levels.
- bd229465 - tests: Add a test for sampling from nonzero mipmap levels.
- 82519b62 - tests: Add a test for SampleBias() with multiple mipmap levels.
- 13c092a6 - vkd3d-shader/tpf: Add support for emitting sample_l instructions
- 46f0d606 - vkd3d-shader/tpf: For sample_l/sample_b, set lod swizzle to SCALAR.
Toggle commit listRebased, but instead of rebasing on main I rebased on Zebediah's patchset - !191 (merged) should be prioritized before this MR!
added 27 commits
-
46f0d606...8b57a612 - 21 commits from branch
wine:master
- 4e341a94 - tests/shader_runner: Add support for creating mipmapped textures.
- 1af055be - tests: Add a test for loading from nonzero mipmap levels.
- 462baf3a - tests: Add a test for sampling from nonzero mipmap levels.
- f1124dd7 - tests: Add a test for SampleBias() with multiple mipmap levels.
- d75b42d2 - vkd3d-shader/tpf: Add support for emitting sample_l instructions
- 245c8c80 - vkd3d-shader/tpf: For sample_l/sample_b, set lod swizzle to SCALAR.
Toggle commit list-
46f0d606...8b57a612 - 21 commits from branch
One more rebase, this rebases both !191 (merged) and this MR against latest master, so if !191 (merged)'s current revision is merged, the 2 patches on top should also apply cleanly!
Turns out my sampler patchsets conflicted with one another, so I made this the "third" series - the merge order should now be