vkd3d-shader/msl: Implement VKD3DSIH_GATHER4_C.

This commit is contained in:
Henri Verbeet
2025-05-27 23:18:09 +02:00
parent 841cf65a41
commit 449804623a
Notes: Henri Verbeet 2025-06-24 16:32:54 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1593
2 changed files with 16 additions and 12 deletions

View File

@@ -980,8 +980,9 @@ static void msl_sample(struct msl_generator *gen, const struct vkd3d_shader_inst
struct msl_dst dst;
bias = ins->opcode == VKD3DSIH_SAMPLE_B;
compare = ins->opcode == VKD3DSIH_SAMPLE_C || ins->opcode == VKD3DSIH_SAMPLE_C_LZ;
gather = ins->opcode == VKD3DSIH_GATHER4;
compare = ins->opcode == VKD3DSIH_GATHER4_C || ins->opcode == VKD3DSIH_SAMPLE_C
|| ins->opcode == VKD3DSIH_SAMPLE_C_LZ;
gather = ins->opcode == VKD3DSIH_GATHER4 || ins->opcode == VKD3DSIH_GATHER4_C;
grad = ins->opcode == VKD3DSIH_SAMPLE_GRAD;
lod = ins->opcode == VKD3DSIH_SAMPLE_LOD;
lod_zero = ins->opcode == VKD3DSIH_SAMPLE_C_LZ;
@@ -1095,7 +1096,9 @@ static void msl_sample(struct msl_generator *gen, const struct vkd3d_shader_inst
if (ins->dst[0].reg.data_type == VKD3D_DATA_UINT)
vkd3d_string_buffer_printf(sample, "as_type<uint4>(");
msl_print_srv_name(sample, gen, srv_binding, resource_type_info, data_type, compare);
if (gather)
if (gather && compare)
vkd3d_string_buffer_printf(sample, ".gather_compare(");
else if (gather)
vkd3d_string_buffer_printf(sample, ".gather(");
else if (compare)
vkd3d_string_buffer_printf(sample, ".sample_compare(");
@@ -1142,7 +1145,7 @@ static void msl_sample(struct msl_generator *gen, const struct vkd3d_shader_inst
msl_print_src_with_type(sample, gen, &ins->src[3], VKD3DSP_WRITEMASK_0, ins->src[3].reg.data_type);
vkd3d_string_buffer_printf(sample, ")");
}
if (gather && (component_idx = vsir_swizzle_get_component(ins->src[2].swizzle, 0)))
if (gather && !compare && (component_idx = vsir_swizzle_get_component(ins->src[2].swizzle, 0)))
{
if (resource_type_info->offset)
vkd3d_string_buffer_printf(sample, ", int2(0)");
@@ -1151,7 +1154,7 @@ static void msl_sample(struct msl_generator *gen, const struct vkd3d_shader_inst
vkd3d_string_buffer_printf(sample, ")");
if (ins->dst[0].reg.data_type == VKD3D_DATA_UINT)
vkd3d_string_buffer_printf(sample, ")");
if (!compare)
if (!compare || gather)
msl_print_swizzle(sample, ins->src[1].swizzle, ins->dst[0].write_mask);
msl_print_assignment(gen, &dst, "%s", sample->buffer);
@@ -1296,6 +1299,7 @@ static void msl_handle_instruction(struct msl_generator *gen, const struct vkd3d
msl_cast(gen, ins, "uint");
break;
case VKD3DSIH_GATHER4:
case VKD3DSIH_GATHER4_C:
case VKD3DSIH_SAMPLE:
case VKD3DSIH_SAMPLE_B:
case VKD3DSIH_SAMPLE_C:

View File

@@ -23,7 +23,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 1.0, 0.0, 0.0)
[pixel shader]
@@ -36,7 +36,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 0.0, 0.0, 1.0)
[pixel shader]
@@ -49,7 +49,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 1.0, 0.0, 0.0)
[pixel shader]
@@ -62,7 +62,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 1.0, 0.0, 0.0)
[pixel shader]
@@ -75,7 +75,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 1.0, 0.0, 0.0)
[pixel shader]
@@ -88,7 +88,7 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(1.0, 0.0, 0.0, 0.0)
[pixel shader]
@@ -101,5 +101,5 @@ float4 main() : sv_target
}
[test]
todo(msl | glsl) draw quad
todo(glsl) draw quad
probe (0, 0) rgba(0.0, 0.0, 0.0, 1.0)