Debug mode sample count and depth assertions
parent
df3f38a67b
commit
e50fb472b1
|
@ -17,11 +17,14 @@ namespace MoonWorks.Graphics
|
||||||
GraphicsPipeline currentGraphicsPipeline;
|
GraphicsPipeline currentGraphicsPipeline;
|
||||||
ComputePipeline currentComputePipeline;
|
ComputePipeline currentComputePipeline;
|
||||||
bool renderPassActive;
|
bool renderPassActive;
|
||||||
SampleCount currentSampleCount;
|
SampleCount colorAttachmentSampleCount;
|
||||||
|
uint colorAttachmentCount;
|
||||||
TextureFormat colorFormatOne;
|
TextureFormat colorFormatOne;
|
||||||
TextureFormat colorFormatTwo;
|
TextureFormat colorFormatTwo;
|
||||||
TextureFormat colorFormatThree;
|
TextureFormat colorFormatThree;
|
||||||
TextureFormat colorFormatFour;
|
TextureFormat colorFormatFour;
|
||||||
|
bool hasDepthStencilAttachment;
|
||||||
|
SampleCount depthStencilAttachmentSampleCount;
|
||||||
TextureFormat depthStencilFormat;
|
TextureFormat depthStencilFormat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -35,7 +38,9 @@ namespace MoonWorks.Graphics
|
||||||
currentGraphicsPipeline = null;
|
currentGraphicsPipeline = null;
|
||||||
currentComputePipeline = null;
|
currentComputePipeline = null;
|
||||||
renderPassActive = false;
|
renderPassActive = false;
|
||||||
currentSampleCount = SampleCount.One;
|
colorAttachmentSampleCount = SampleCount.One;
|
||||||
|
depthStencilAttachmentSampleCount = SampleCount.One;
|
||||||
|
colorAttachmentCount = 0;
|
||||||
colorFormatOne = TextureFormat.R8G8B8A8;
|
colorFormatOne = TextureFormat.R8G8B8A8;
|
||||||
colorFormatTwo = TextureFormat.R8G8B8A8;
|
colorFormatTwo = TextureFormat.R8G8B8A8;
|
||||||
colorFormatThree = TextureFormat.R8G8B8A8;
|
colorFormatThree = TextureFormat.R8G8B8A8;
|
||||||
|
@ -71,7 +76,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
|
hasDepthStencilAttachment = false;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfo.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 1;
|
||||||
colorFormatOne = colorAttachmentInfo.Texture.Format;
|
colorFormatOne = colorAttachmentInfo.Texture.Format;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -94,7 +101,7 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoTwo);
|
AssertTextureNotNull(colorAttachmentInfoTwo);
|
||||||
AssertColorTarget(colorAttachmentInfoTwo);
|
AssertColorTarget(colorAttachmentInfoTwo);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2];
|
||||||
|
@ -111,7 +118,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = false;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 2;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
#endif
|
#endif
|
||||||
|
@ -140,8 +149,8 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoThree);
|
AssertTextureNotNull(colorAttachmentInfoThree);
|
||||||
AssertColorTarget(colorAttachmentInfoThree);
|
AssertColorTarget(colorAttachmentInfoThree);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoThree);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3];
|
||||||
|
@ -159,7 +168,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = false;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 3;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
||||||
|
@ -194,9 +205,9 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoFour);
|
AssertTextureNotNull(colorAttachmentInfoFour);
|
||||||
AssertColorTarget(colorAttachmentInfoFour);
|
AssertColorTarget(colorAttachmentInfoFour);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoThree);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoFour);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoFour.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4];
|
||||||
|
@ -215,7 +226,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = false;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 4;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
||||||
|
@ -248,6 +261,8 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
|
hasDepthStencilAttachment = true;
|
||||||
|
depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.Texture.SampleCount;
|
||||||
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -268,6 +283,7 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
AssertTextureNotNull(colorAttachmentInfo);
|
AssertTextureNotNull(colorAttachmentInfo);
|
||||||
AssertColorTarget(colorAttachmentInfo);
|
AssertColorTarget(colorAttachmentInfo);
|
||||||
|
AssertSameSampleCount(colorAttachmentInfo.Texture, depthStencilAttachmentInfo.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[1];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[1];
|
||||||
|
@ -285,7 +301,10 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
|
hasDepthStencilAttachment = true;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfo.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 1;
|
||||||
|
depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.Texture.SampleCount;
|
||||||
colorFormatOne = colorAttachmentInfo.Texture.Format;
|
colorFormatOne = colorAttachmentInfo.Texture.Format;
|
||||||
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,7 +332,8 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoTwo);
|
AssertTextureNotNull(colorAttachmentInfoTwo);
|
||||||
AssertColorTarget(colorAttachmentInfoTwo);
|
AssertColorTarget(colorAttachmentInfoTwo);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2];
|
||||||
|
@ -332,7 +352,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = true;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 2;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
|
||||||
|
@ -366,8 +388,9 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoThree);
|
AssertTextureNotNull(colorAttachmentInfoThree);
|
||||||
AssertColorTarget(colorAttachmentInfoThree);
|
AssertColorTarget(colorAttachmentInfoThree);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3];
|
||||||
|
@ -387,7 +410,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = true;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 3;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
||||||
|
@ -427,9 +452,10 @@ namespace MoonWorks.Graphics
|
||||||
AssertTextureNotNull(colorAttachmentInfoFour);
|
AssertTextureNotNull(colorAttachmentInfoFour);
|
||||||
AssertColorTarget(colorAttachmentInfoFour);
|
AssertColorTarget(colorAttachmentInfoFour);
|
||||||
|
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoTwo);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoThree);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture);
|
||||||
AssertSameSampleCount(colorAttachmentInfoOne, colorAttachmentInfoFour);
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoFour.Texture);
|
||||||
|
AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4];
|
var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4];
|
||||||
|
@ -450,7 +476,9 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
renderPassActive = true;
|
renderPassActive = true;
|
||||||
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
hasDepthStencilAttachment = true;
|
||||||
|
colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
|
||||||
|
colorAttachmentCount = 4;
|
||||||
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
|
||||||
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
|
||||||
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
|
||||||
|
@ -784,9 +812,20 @@ namespace MoonWorks.Graphics
|
||||||
AssertRenderPassActive();
|
AssertRenderPassActive();
|
||||||
AssertRenderPassPipelineFormatMatch(graphicsPipeline);
|
AssertRenderPassPipelineFormatMatch(graphicsPipeline);
|
||||||
|
|
||||||
if (graphicsPipeline.SampleCount != currentSampleCount)
|
if (colorAttachmentCount > 0)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentException("The sample count of the bound GraphicsPipeline must match the sample count of the current render pass!");
|
if (graphicsPipeline.SampleCount != colorAttachmentSampleCount)
|
||||||
|
{
|
||||||
|
throw new System.InvalidOperationException($"Sample count mismatch! Graphics pipeline sample count: {graphicsPipeline.SampleCount}, Color attachment sample count: {colorAttachmentSampleCount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasDepthStencilAttachment)
|
||||||
|
{
|
||||||
|
if (graphicsPipeline.SampleCount != depthStencilAttachmentSampleCount)
|
||||||
|
{
|
||||||
|
throw new System.InvalidOperationException($"Sample count mismatch! Graphics pipeline sample count: {graphicsPipeline.SampleCount}, Depth stencil attachment sample count: {depthStencilAttachmentSampleCount}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2103,6 +2142,12 @@ namespace MoonWorks.Graphics
|
||||||
if (graphicsPipeline.AttachmentInfo.HasDepthStencilAttachment)
|
if (graphicsPipeline.AttachmentInfo.HasDepthStencilAttachment)
|
||||||
{
|
{
|
||||||
var pipelineDepthFormat = graphicsPipeline.AttachmentInfo.DepthStencilFormat;
|
var pipelineDepthFormat = graphicsPipeline.AttachmentInfo.DepthStencilFormat;
|
||||||
|
|
||||||
|
if (!hasDepthStencilAttachment)
|
||||||
|
{
|
||||||
|
throw new System.InvalidOperationException("Pipeline expects depth attachment!");
|
||||||
|
}
|
||||||
|
|
||||||
if (pipelineDepthFormat != depthStencilFormat)
|
if (pipelineDepthFormat != depthStencilFormat)
|
||||||
{
|
{
|
||||||
throw new System.InvalidOperationException($"Depth texture format mismatch! Pipeline expects {pipelineDepthFormat}, render pass attachment is {depthStencilFormat}");
|
throw new System.InvalidOperationException($"Depth texture format mismatch! Pipeline expects {pipelineDepthFormat}, render pass attachment is {depthStencilFormat}");
|
||||||
|
@ -2166,11 +2211,11 @@ namespace MoonWorks.Graphics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AssertSameSampleCount(ColorAttachmentInfo a, ColorAttachmentInfo b)
|
private void AssertSameSampleCount(Texture a, Texture b)
|
||||||
{
|
{
|
||||||
if (a.Texture.SampleCount != b.Texture.SampleCount)
|
if (a.SampleCount != b.SampleCount)
|
||||||
{
|
{
|
||||||
throw new System.ArgumentException("All color attachments in a render pass must have the same SampleCount!");
|
throw new System.ArgumentException("All attachments in a render pass must have the same SampleCount!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue