Skip to content
Snippets Groups Projects

vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.

Merged Nikolay Sivov requested to merge nsivov/vkd3d:isfrontface into master
2 unresolved threads

Merge request reports

Merge request pipeline #9648 skipped

Merge request pipeline skipped for e4503ad8

Merged by Alexandre JulliardAlexandre Julliard 2 years ago (Apr 13, 2023 9:20pm 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
  • This should be simple to test; we already have support in the shader runner for manual vertex buffers.

  • Author Developer

    I think I found an example in hlsl-struct-semantics.shader_test of what you're talking about regarding manually filled vertex buffers. I couldn't make it work for purposes of this semantic, because I don't fully understand how it works. I did try to specify 3 vertices, and use draw triangle strip 3. With SV_IsFrontFace I was going to switch between returned target colors. Flipping vertices order did not make any difference in shader output. I'm sure I screwed up something.

    Is there a good tutorial for this front face flag?

    For the patch itself, I'm sure having a test would be better and I'm going to look at adding one, but the change is very straightforward and generates what it should, according to disassembly.

  • I think I found an example in hlsl-struct-semantics.shader_test of what you're talking about regarding manually filled vertex buffers. I couldn't make it work for purposes of this semantic, because I don't fully understand how it works. I did try to specify 3 vertices, and use draw triangle strip 3. With SV_IsFrontFace I was going to switch between returned target colors. Flipping vertices order did not make any difference in shader output. I'm sure I screwed up something.

    Changing the vertex order doesn't change anything at all?

    I do realize now that the shader runners all have default (i.e. back face) culling, so it won't render anything at all if the triangle is back-facing. We can probably just disable culling unconditionally.

    That doesn't explain why you're getting the same face by changing the order, though.

  • Author Developer

    Test shader I used returned different color depending on this flag. Changing order gave me zeroes I believe, that shader never returns. I'll need to try again.

  • Nikolay Sivov added 44 commits

    added 44 commits

    • 10bef019...616c4bf5 - 41 commits from branch wine:master
    • c3d629c1 - vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.
    • 3293293b - tests: Disable culling in shader runners.
    • a74ed1dd - tests: Add a test for SV_IsFrontFace.

    Compare with previous version

  • Author Developer

    Pushed some changes to make tests work, please take a look.

  • Elizabeth Figura approved this merge request

    approved this merge request

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit a74ed1dd
35 } m;
36 };
37
38 struct output
39 {
40 struct
41 {
42 float4 color : sv_target;
43 } m;
44 };
45
46 struct output main(struct input i, bool face : sv_isfrontface)
47 {
48 struct output o;
49 o.m.color = i.m.texcoord;
50 if (face) o.m.color += float4(1.0, 1.0, 1.0, 1.0);
  • Giovanni Mascellani approved this merge request

    approved this merge request

  • Nikolay Sivov added 5 commits

    added 5 commits

    • a74ed1dd...94ff9ba5 - 2 commits from branch wine:master
    • e02b837b - vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.
    • 6a6b0296 - tests: Disable culling in shader runners.
    • 95a4e01d - tests: Add a test for SV_IsFrontFace.

    Compare with previous version

    • That pixel shader looks a fair bit more complicated than it needs to be. The texcoord input in particular doesn't seem to add much, but ultimately I think we could just do the following?

      [pixel shader]
      float4 main(bool front : sv_isfrontface) : sv_target
      {
          return front ? float4(1.0f, 2.0f, 1.0f, 2.0f) : float4(0.0f, 1.0f, 0.0f, 1.0f);
      }

      It may also be less total code to add "draw quad cw" and "draw quad ccw" statements to the shader runner, instead of using an explicit input layout, vertex buffer, and vertex shader here.

    • Author Developer

      Thanks, I removed unnecessary parts.

    • Please register or sign in to reply
  • Nikolay Sivov added 11 commits

    added 11 commits

    • 95a4e01d...0c05f240 - 8 commits from branch wine:master
    • bae3cb62 - vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.
    • 929ed847 - tests: Disable culling in shader runners.
    • 0ad66068 - tests: Add a test for SV_IsFrontFace.

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • added 7 commits

    • 0ad66068...a1bd4e08 - 4 commits from branch wine:master
    • ca59a3c3 - vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.
    • a496e3a8 - tests: Disable culling in shader runners.
    • e4503ad8 - tests: Add a test for SV_IsFrontFace.

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading