Compare commits

...

2 Commits

Author SHA1 Message Date
Caleb Cornett 5b7c39efb6 textures now have a sample count, not render passes 2023-01-30 16:39:03 -05:00
TheSpydog 88d9119830 Remove warning from DrawInstancedPrimitives doc comment (#44)
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: MoonsideGames/MoonWorks#44
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2023-01-24 00:14:46 +00:00
4 changed files with 24 additions and 28 deletions

View File

@ -71,7 +71,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount;
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format;
#endif
}
@ -111,7 +111,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
#endif
@ -159,7 +159,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -215,7 +215,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -285,7 +285,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount;
currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
#endif
@ -332,7 +332,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
@ -387,7 +387,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -450,7 +450,7 @@ namespace MoonWorks.Graphics
#if DEBUG
renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount;
currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -1489,7 +1489,6 @@ namespace MoonWorks.Graphics
/// <summary>
/// Draws using instanced rendering.
/// It is an error to call this method unless two vertex buffers have been bound.
/// </summary>
/// <param name="baseVertex">The starting index offset for the vertex buffer.</param>
/// <param name="startIndex">The starting index offset for the index buffer.</param>
@ -2047,7 +2046,7 @@ namespace MoonWorks.Graphics
private void AssertSameSampleCount(ColorAttachmentInfo a, ColorAttachmentInfo b)
{
if (a.SampleCount != b.SampleCount)
if (a.Texture.SampleCount != b.Texture.SampleCount)
{
throw new System.ArgumentException("All color attachments in a render pass must have the same SampleCount!");
}

View File

@ -181,7 +181,6 @@ namespace MoonWorks.Graphics
public uint Depth;
public uint Layer;
public uint Level;
public SampleCount SampleCount;
public Color ClearColor;
public LoadOp LoadOp;
public StoreOp StoreOp;
@ -189,15 +188,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo(
Texture texture,
Color clearColor,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store
)
{
) {
Texture = texture;
Depth = 0;
Layer = 0;
Level = 0;
SampleCount = sampleCount;
ClearColor = clearColor;
LoadOp = LoadOp.Clear;
StoreOp = storeOp;
@ -206,15 +202,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo(
Texture texture,
LoadOp loadOp = LoadOp.DontCare,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store
)
{
) {
Texture = texture;
Depth = 0;
Layer = 0;
Level = 0;
SampleCount = sampleCount;
ClearColor = Color.White;
LoadOp = loadOp;
StoreOp = storeOp;
@ -228,7 +221,6 @@ namespace MoonWorks.Graphics
depth = Depth,
layer = Layer,
level = Level,
sampleCount = (Refresh.SampleCount) SampleCount,
clearColor = new Refresh.Vec4
{
x = ClearColor.R / 255f,

View File

@ -15,6 +15,7 @@ namespace MoonWorks.Graphics
public TextureFormat Format { get; internal set; }
public bool IsCube { get; }
public uint LevelCount { get; }
public SampleCount SampleCount { get; }
public TextureUsageFlags UsageFlags { get; }
// FIXME: this allocates a delegate instance
@ -39,13 +40,14 @@ namespace MoonWorks.Graphics
var byteCount = (uint) (width * height * channels);
TextureCreateInfo textureCreateInfo;
TextureCreateInfo textureCreateInfo = new TextureCreateInfo();
textureCreateInfo.Width = (uint) width;
textureCreateInfo.Height = (uint) height;
textureCreateInfo.Depth = 1;
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
textureCreateInfo.IsCube = false;
textureCreateInfo.LevelCount = 1;
textureCreateInfo.SampleCount = SampleCount.One;
textureCreateInfo.UsageFlags = TextureUsageFlags.Sampler;
var texture = new Texture(device, textureCreateInfo);
@ -130,9 +132,9 @@ namespace MoonWorks.Graphics
uint height,
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
uint levelCount = 1,
SampleCount sampleCount = SampleCount.One
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -140,6 +142,7 @@ namespace MoonWorks.Graphics
Depth = 1,
IsCube = false,
LevelCount = levelCount,
SampleCount = sampleCount,
Format = format,
UsageFlags = usageFlags
};
@ -165,8 +168,7 @@ namespace MoonWorks.Graphics
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = width,
@ -195,8 +197,7 @@ namespace MoonWorks.Graphics
TextureFormat format,
TextureUsageFlags usageFlags,
uint levelCount = 1
)
{
) {
var textureCreateInfo = new TextureCreateInfo
{
Width = size,
@ -232,6 +233,7 @@ namespace MoonWorks.Graphics
Depth = textureCreateInfo.Depth;
IsCube = textureCreateInfo.IsCube;
LevelCount = textureCreateInfo.LevelCount;
SampleCount = textureCreateInfo.SampleCount;
UsageFlags = textureCreateInfo.UsageFlags;
}
@ -255,6 +257,7 @@ namespace MoonWorks.Graphics
Depth = 1;
IsCube = false;
LevelCount = 1;
SampleCount = SampleCount.One;
UsageFlags = TextureUsageFlags.ColorTarget;
}

View File

@ -9,6 +9,7 @@ namespace MoonWorks.Graphics
public uint Depth;
public bool IsCube;
public uint LevelCount;
public SampleCount SampleCount;
public TextureFormat Format;
public TextureUsageFlags UsageFlags;
@ -21,6 +22,7 @@ namespace MoonWorks.Graphics
depth = Depth,
isCube = Conversions.BoolToByte(IsCube),
levelCount = LevelCount,
sampleCount = (Refresh.SampleCount) SampleCount,
format = (Refresh.TextureFormat) Format,
usageFlags = (Refresh.TextureUsageFlags) UsageFlags
};