Skip to content
Snippets Groups Projects

vkd3d-shader/hlsl: Add support for sample index argument in Load().

Merged Nikolay Sivov requested to merge nsivov/vkd3d:texture2dms_load into master

Merge request reports

Checking pipeline status.

Approved by

Merged by Alexandre JulliardAlexandre Julliard 1 year ago (May 22, 2023 9:19pm UTC)

Merge details

  • Changes merged into master with dfa00764.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
586 586 struct hlsl_ir_node node;
587 587 enum hlsl_resource_load_type load_type;
588 588 struct hlsl_deref resource, sampler;
589 struct hlsl_src coords, lod, texel_offset;
589 struct hlsl_src coords, lod, sample_index, texel_offset;
  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit 1734fbd6
  • 3498 3498 }
    3499 3499 if (multisampled)
    3500 3500 {
    3501 hlsl_fixme(ctx, loc, "Load() sampling index parameter.");
    3501 struct hlsl_ir_node *sample_index = params->args[1];
    3502
    3503 if (sample_index->type != HLSL_IR_CONSTANT && ctx->profile->major_version == 4 && ctx->profile->minor_version == 0)
    3504 {
    3505 hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expected literal sample index.");
    3506 }
  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on commit 1734fbd6
  • 35 35 probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1)
    36 36 probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8)
    37 37 probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
    38
    39 [pixel shader]
    40 Texture2DMS<float4, 1> t;
    41
    42 float4 main(float4 pos : sv_position) : sv_target
    43 {
    44 return t.Load(int3(pos.xy, 0), 0);
    45 }
    • Comment on lines +40 to +45

      How hard would it be to actually run the shader?

      What happens when you try to perform a multisampled load on a non-multisampled resource, or the other way around?

    • Please register or sign in to reply
  • Nikolay Sivov added 1 commit

    added 1 commit

    • e4cf2b34 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on commit e4cf2b34
  • 37 37 probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
    38
    39 [pixel shader]
    40 Texture2DMS<float4, 1> t;
    41
    42 float4 main(float4 pos : sv_position) : sv_target
    43 {
    44 return t.Load(int3(pos.yx, 0), 0);
    45 }
    46
    47 [test]
    48 draw quad
    49 probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
    50 probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1)
    51 probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8)
    52 probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
    • Comment on lines +49 to +52

      I meant, how hard is it to test this on an actually multisampled texture? Is there a reasonably simple way to create a multisampled texture with given content?

    • Author Developer

      I don't know if you can do that directly. Maybe you can render to it to initialize, but there is no support for that in shader runner I believe. If anyone has an idea please let me know.

      The goal would be to use sample count >1 and Load() with 0 and 1, with observable difference.

    • You can't just upload data to a multisampled texture, no, and I believe that sample positions aren't fixed either, so just rendering a triangle over half of a pixel is not going to give reliable results. It is possible to use a sample frequency shader (i.e. SV_SampleIndex), which would basically amount to porting test_multisample_rendering() to a shader_test, although that requires model 4.1.

      Ultimately I think we do want to port more d3d12 (or d3d11, or d3d9) tests to use the shader-runner infrastructure, so that they can target multiple backends without having to be rewritten. But that is probably reasonable to leave for later.

    • Yeah, if it's not possible to upload directly I don't think we should go too much out of our way for that.

    • Please register or sign in to reply
  • Elizabeth Figura
    Elizabeth Figura @zfigura started a thread on an outdated change in commit e4cf2b34
  • 1464 1466 static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer,
    1465 1467 const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst,
    1466 1468 const struct hlsl_deref *resource, const struct hlsl_ir_node *coords,
    1467 const struct hlsl_ir_node *texel_offset)
    1469 const struct hlsl_ir_node *sample_index, const struct hlsl_ir_node *texel_offset)
    1468 1470 {
    1469 1471 bool uav = (resource_type->base_type == HLSL_TYPE_UAV);
    1472 bool multisampled = resource_type->base_type == HLSL_TYPE_TEXTURE
    1473 && (resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS || resource_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY);
    1470 1474 struct sm4_instruction instr;
    1471 1475 unsigned int dim_count;
    1472 1476
    1473 1477 memset(&instr, 0, sizeof(instr));
    1474 instr.opcode = uav ? VKD3D_SM5_OP_LD_UAV_TYPED : VKD3D_SM4_OP_LD;
    1478 instr.opcode = uav ? VKD3D_SM5_OP_LD_UAV_TYPED : (multisampled ? VKD3D_SM4_OP_LD2DMS : VKD3D_SM4_OP_LD);
  • Elizabeth Figura
    Elizabeth Figura @zfigura started a thread on an outdated change in commit e4cf2b34
  • 1516
    1517 index = hlsl_ir_constant(sample_index);
    1518
    1519 memset(&instr.srcs[2], 0, sizeof(instr.srcs[2]));
    1520 instr.srcs[2].swizzle_type = VKD3D_SM4_SWIZZLE_NONE;
    1521 reg->type = VKD3D_SM4_RT_IMMCONST;
    1522 reg->dim = VKD3D_SM4_DIMENSION_SCALAR;
    1523 reg->immconst_uint[0] = index->value[0].u;
    1524 }
    1525 else if (ctx->profile->major_version == 4 && ctx->profile->minor_version == 0)
    1526 {
    1527 hlsl_error(ctx, &sample_index->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Expected literal sample index.");
    1528 }
    1529 else
    1530 sm4_src_from_node(&instr.srcs[2], sample_index, 0);
    1531
  • Nikolay Sivov added 28 commits

    added 28 commits

    • e4cf2b34...d6d9aab3 - 27 commits from branch wine:master
    • a8bbde42 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit a8bbde42
  • 35 35 probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1)
    36 36 probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8)
    37 37 probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
    38
    39 [pixel shader]
    40 Texture2DMS<float4, 1> t;
    41
    42 float4 main(float4 pos : sv_position) : sv_target
    43 {
    44 return t.Load(int3(pos.yx, 0), 0);
  • Nikolay Sivov added 1 commit

    added 1 commit

    • 26c8ba17 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit 26c8ba17
  • 3579 3581
    3580 3582 /* +1 for the mipmap level */
    3581 3583 if (!(load_params.coords = add_implicit_conversion(ctx, instrs, params->args[0],
    3582 hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + 1), loc)))
    3584 hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + !multisampled), loc)))
  • Nikolay Sivov added 17 commits

    added 17 commits

    • 26c8ba17...94ff9ba5 - 16 commits from branch wine:master
    • 395c7b18 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Giovanni Mascellani approved this merge request

    approved this merge request

  • This is missing

    clone_src(map, &dst->sample_index, &src->sample_index);

    in clone_resource_load().

  • Nikolay Sivov added 28 commits

    added 28 commits

    • 395c7b18...8ed74377 - 27 commits from branch wine:master
    • 23c1924d - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Nikolay Sivov added 15 commits

    added 15 commits

    • 23c1924d...0ce55e8b - 14 commits from branch wine:master
    • 12b366a7 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • We're using a non-multisampled texture with Texture2DMS in this test, which is causing failures with the GL backend and validation errors with Vulkan. I'm looking into it...

  • Nikolay Sivov added 26 commits

    added 26 commits

    • 12b366a7...8e0df3f7 - 25 commits from branch wine:master
    • 2a23a4be - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Nikolay Sivov added 3 commits

    added 3 commits

    • 2a23a4be...b46df551 - 2 commits from branch wine:master
    • 82312fe2 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

  • Nikolay Sivov added 12 commits

    added 12 commits

    • 82312fe2...af4bb037 - 11 commits from branch wine:master
    • 66aaf264 - vkd3d-shader/hlsl: Add support for sample index argument in Load().

    Compare with previous version

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