Implement MSAA properly for Vulkan.

This commit is contained in:
Skyth
2024-10-19 22:22:09 +03:00
parent 7ed7921c54
commit c2ce012155
12 changed files with 258 additions and 51 deletions
+1
View File
@@ -0,0 +1 @@
*.hlsl.*.h
+5
View File
@@ -0,0 +1,5 @@
void main(in uint vertexId : SV_VertexID, out float4 position : SV_Position, out float2 texCoord : TEXCOORD)
{
texCoord = float2((vertexId << 1) & 2, vertexId & 2);
position = float4(texCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
@@ -0,0 +1,18 @@
struct PushConstants
{
uint ResourceDescriptorIndex;
};
[[vk::push_constant]] ConstantBuffer<PushConstants> g_PushConstants : register(b3, space4);
Texture2DMS<float, SAMPLE_COUNT> g_Texture2DMSDescriptorHeap[] : register(t0, space0);
float main(in float4 position : SV_Position) : SV_Depth
{
float result = g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].Load(int2(position.xy), 0);
[unroll] for (int i = 1; i < SAMPLE_COUNT; i++)
result = max(result, g_Texture2DMSDescriptorHeap[g_PushConstants.ResourceDescriptorIndex].Load(int2(position.xy), i));
return result;
}
@@ -0,0 +1,2 @@
#define SAMPLE_COUNT 2
#include "resolve_msaa_depth.hlsli"
@@ -0,0 +1,2 @@
#define SAMPLE_COUNT 4
#include "resolve_msaa_depth.hlsli"
@@ -0,0 +1,2 @@
#define SAMPLE_COUNT 8
#include "resolve_msaa_depth.hlsli"