Skip to content
Snippets Groups Projects

vkd3d-shader/hlsl: Implement trigonometry functions for SM1.

Merged Shaun Ren requested to merge shaunren/vkd3d:sm1-sincos into master
All threads resolved!

Merge request reports

Loading
Loading

Activity

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

    added 11 commits

    • 01345c24...ccb6150a - 6 commits from branch wine:master
    • cbadf380 - vkd3d-shader/hlsl: Implement the mad instruction for SM1.
    • 14a3d272 - vkd3d-shader/spirv: Implement VKD3DSIH_SINCOS for SM1.
    • b7d081cf - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • 899d29a2 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 3aff00fe - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

  • Shaun Ren resolved all threads

    resolved all threads

  • Elizabeth Figura approved this merge request

    approved this merge request

    • Resolved by Shaun Ren

      Subject: [PATCH 1/5] vkd3d-shader/hlsl: Implement the mad instruction for SM1.

      It looks like HLSL_OP3_MAD isn't generated anywhere until 5/5.

      Subject: [PATCH 2/5] vkd3d-shader/spirv: Implement VKD3DSIH_SINCOS for SM1.

      Could we handle that in vsir_program_lower_instructions() instead?

  • Shaun Ren added 54 commits

    added 54 commits

    • 3aff00fe...746222b3 - 49 commits from branch wine:master
    • b576fea5 - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • cdc427ea - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • bcdbb042 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 64692494 - vkd3d-shader/hlsl: Implement the MAD instruction for SM1.
    • 715c061e - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

  • Shaun Ren resolved all threads

    resolved all threads

  • Shaun Ren added 3 commits

    added 3 commits

    • 131e28ca - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 2593e151 - vkd3d-shader/hlsl: Implement the MAD instruction for SM1.
    • 2a07e175 - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

  • Shaun Ren added 6 commits

    added 6 commits

    • 039dff0d - vkd3d-shader/d3dbc: Replace remaining D3DSPR_TEMP with VKD3DSPR_TEMP.
    • 5808c485 - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • 8c523fb6 - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • 26644e09 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 6db5a5e1 - vkd3d-shader/hlsl: Implement the MAD instruction for SM1.
    • b34b2b2a - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

  • Shaun Ren added 5 commits

    added 5 commits

    • d7638171 - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • 70d1c519 - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • 15931ac0 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 0b4d1cf8 - vkd3d-shader/hlsl: Implement the MAD instruction for SM1.
    • 5c1e07fe - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

  • Shaun Ren added 6 commits

    added 6 commits

    • 67c690aa - 1 commit from branch wine:master
    • 2aa674cb - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • 1204409a - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • bbde3d67 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 523f100c - vkd3d-shader/hlsl: Implement the MAD instruction for SM1.
    • 97b1348c - vkd3d-shader/hlsl: Implement sin/cos for SM1.

    Compare with previous version

    • Resolved by Shaun Ren
      +    if (!(vsir_instruction_init_with_params(program, ins, &sincos->location, VKD3DSIH_SINCOS, 2, 1)))
      +        return VKD3D_ERROR_OUT_OF_MEMORY;
      +
      +    ins->flags = sincos->flags;
      +    *ins->src = *sincos->src;
      +
      +    if (sincos->dst->write_mask & VKD3DSP_WRITEMASK_1)
      +    {
      +        ins->dst[0] = *sincos->dst;
      +        ins->dst[0].write_mask = VKD3DSP_WRITEMASK_1;
      +    }
      +    else
      +        vsir_dst_param_init(&ins->dst[0], VKD3DSPR_NULL, VKD3D_DATA_UNUSED, 0);
      +
      +    if (sincos->dst->write_mask & VKD3DSP_WRITEMASK_0)
      +    {
      +        ins->dst[1] = *sincos->dst;
      +        ins->dst[1].write_mask = VKD3DSP_WRITEMASK_0;
      +    }
      +    else
      +        vsir_dst_param_init(&ins->dst[1], VKD3DSPR_NULL, VKD3D_DATA_UNUSED, 0);

      As I understand it, d3dbc sincos operates on the first component of the source parameter. (But I wouldn't be surprised if it used the third component instead...) The documentation claims the source parameter should have a replicate swizzle, but I suspect that isn't consistently enforced. The code above would turn d3dbc "sincos r1.xy, r0.xyzw, ..." into vsir "sincos r1.y, r1.x, r0.xyzw", assigning the sine of r0.y to r1.y.

      Ideally we'd have some tests for how the swizzle is supposed behave, although those may be inconvenient to write without d3d-asm source support in the shader runner, or at least the ability to load binary shaders instead of HLSL source. Extending Wine's d3d9 sincos_test() would be much easier though, and sufficient for me. I'd also already feel better about this if it modified the source swizzle to replicate the first component to the other channels; that would at least retain the current wined3d behaviour.

      +    assert(instruction->dst_count == 2);

      Don't do that. If we're worried about this condition slipping through, there's spirv_compiler_error() with VKD3D_SHADER_ERROR_SPV_INVALID_SHADER. Arguably this belongs in vsir_validate_instruction() in any case, although you'd have to do some work to differentiate between the different stages at which that could be called.

      Subject: [PATCH 4/5] vkd3d-shader/hlsl: Implement the MAD instruction for SM1.

      That's better, in a way, but HLSL_OP3_MAD still isn't generated anywhere until patch 5/5; that's the patch that should introduce the operation, and then the d3dbc implementation could come in a subsequent patch.

      To some extent that applies to patch 2/5 and 3/5 as well; HLSL_OP1_COS_REDUCED/HLSL_OP1_SIN_REDUCED already exist because they were imported from Wine in the initial import of Wine's HLSL compiler, but they're not generated anywhere either.

  • Shaun Ren added 6 commits

    added 6 commits

    • 0bd29c64 - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • a4a1f48a - vkd3d-shader/hlsl: Implement sin/cos for SM1.
    • 1d690878 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 7fa4e033 - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.
    • 7e3fe09f - vkd3d-shader/d3dbc: Implement HLSL_OP3_MAD for SM1.
    • fb653357 - tests: Test SM1 trigonometry functions.

    Compare with previous version

  • Shaun Ren resolved all threads

    resolved all threads

  • Shaun Ren added 3 commits

    added 3 commits

    • 8c17b114 - vkd3d-shader/d3dbc: Implement HLSL_OP3_MAD for SM1.
    • 8d04ad99 - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 895c76c1 - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • Henri Verbeet added 34 commits

    added 34 commits

    • 895c76c1...5a53b739 - 29 commits from branch wine:master
    • b3a11a9e - vkd3d-shader/ir: Lower SM1 SINCOS to SM4 SINCOS.
    • b4845b9d - vkd3d-shader/hlsl: Implement sin/cos for SM1.
    • 8724cbe5 - vkd3d-shader/d3dbc: Implement HLSL_OP3_MAD for SM1.
    • ea2ffc0b - vkd3d-shader/hlsl: Allocate registers for HLSL_OP1_{COS,SIN}_REDUCED with the required writemasks.
    • 0202393d - vkd3d-shader/d3dbc: Implement HLSL_OP1_{COS,SIN}_REDUCED for SM1.

    Compare with previous version

  • Please register or sign in to reply
    Loading