1Texture2DMS<float4> TextureF_MS : register(t0); 2 3// VS_ResolveColor2D: not needed, we reuse VS_Passthrough2D 4 5float4 PS_ResolveColor2D(in float4 inPosition : SV_POSITION, in float2 inTexCoord : TEXCOORD0) : SV_TARGET0 6{ 7 uint width, height, samples; 8 TextureF_MS.GetDimensions(width, height, samples); 9 uint2 coord = uint2(inTexCoord.x * float(width), inTexCoord.y * float(height)); 10 float4 color = float4(0.0, 0.0, 0.0, 0.0); 11 for (uint s = 0; s < samples; s++) 12 { 13 color += TextureF_MS.Load(coord, s).rgba; 14 } 15 return color / float(samples); 16 17 // Potential performance improvement: We could remove the TextureF_MS.GetDimensions() call 18 // and pass width, height, and invSamples via constants to the shader. This would allow us 19 // to calculate the final texture coordinates in the vertex shader already and instead of 20 // dividing by samples we could multiply by invSamples at the end. 21 // But maybe graphics drivers even do these optimizations automatically after the texture 22 // metrics are known at rendering time? 23} 24