ebb5098def
Vulkan specifies that the Sample Mask Test occurs before fragment shading. This means gl_SampleMaskIn should be influenced by both sample-shading and VkPipelineMultisampleStateCreateInfo::pSampleMask. CTS tests dEQP-VK.pipeline.multisample_shader_builtin.* bear this out. For sample-shading, gl_SampleMaskIn should only have a single bit set, Since Metal does not filter for this, apply a bitmask based on gl_SampleID. For a fixed sample mask, since Metal is unaware of VkPipelineMultisampleStateCreateInfo::pSampleMask, we need to ensure that we apply it to both gl_SampleMaskIn and gl_SampleMask. This has the side effect of a redundant application of pSampleMask if the shader already includes gl_SampleMaskIn when setting gl_SampleMask, but I don't see an easy way around this. Also, simplify the logic for including the fixed sample mask in gl_ShaderMask, and print the fixed sample mask as a hex value for readability of bits.
20 lines
305 B
GLSL
20 lines
305 B
GLSL
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct main0_out
|
|
{
|
|
float4 FragColor [[color(0)]];
|
|
uint gl_SampleMask [[sample_mask]];
|
|
};
|
|
|
|
fragment main0_out main0()
|
|
{
|
|
main0_out out = {};
|
|
out.FragColor = float4(1.0);
|
|
out.gl_SampleMask = 0x22;
|
|
return out;
|
|
}
|
|
|