Skip to content
Snippets Groups Projects

vkd3d-shader/tpf: Add support for emitting sample_l instructions

Merged Ethan Lee requested to merge flibitijibibo/vkd3d:samplelod into master

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

Merge request pipeline #10753 skipped

Merge request pipeline skipped for ea7d8c65

Merged by Alexandre JulliardAlexandre Julliard 1 year ago (May 24, 2023 8:34pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Ethan Lee added 2 commits

    added 2 commits

    • 8ecf8924 - tests: Add a test for SampleLevel() function.
    • adcf7397 - vkd3d-shader/tpf: Add support for emitting sample_l instructions

    Compare with previous version

  • Ethan Lee resolved all threads

    resolved all threads

    • 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.

    • Author Contributor

      Added this as a new commit on top - the disassembly before this commit shows a single component already, which made me think it might have been getting set elsewhere, but after the change the binary output was different, so it might be a coincidence.

    • 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. :)

    • Please register or sign in to reply
  • Ethan Lee added 1 commit

    added 1 commit

    • 745bb4f1 - vkd3d-shader/tpf: For sample_l/sample_b, set lod swizzle to SCALAR.

    Compare with previous version

  • Francisco Casas approved this merge request

    approved this merge request

  • Ethan Lee resolved all threads

    resolved all threads

  • 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.

  • Ethan Lee added 24 commits

    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.

    Compare with previous version

  • Author Contributor

    The test commit in this MR could be obsoleted by !191 (merged), depending on when each is merged.

    Edited by Ethan Lee
  • Ethan Lee added 6 commits

    added 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.

    Compare with previous version

  • Author Contributor

    Rebased, but instead of rebasing on main I rebased on Zebediah's patchset - !191 (merged) should be prioritized before this MR!

  • Ethan Lee added 27 commits

    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.

    Compare with previous version

  • Author Contributor

    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!

  • Ethan Lee added 4 commits

    added 4 commits

    • 58f96659 - tests: Add a test for SampleGrad() method
    • b5c6fc81 - vkd3d-shader/hlsl: Add support for SampleGrad() method
    • a2919dd9 - vkd3d-shader/tpf: Add support for emitting sample_l instructions
    • 5dc67ed6 - tpf: For sample_l/sample_b, set lod swizzle to SCALAR.

    Compare with previous version

  • Author Contributor

    Turns out my sampler patchsets conflicted with one another, so I made this the "third" series - the merge order should now be

    !191 (merged) -> !184 (merged) -> !188 (merged).

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading