Textures now have a sample count, not render passes (#45)

Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: MoonsideGames/MoonWorks#45
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
remotes/1695061714407202320/main
TheSpydog 2023-01-31 20:27:26 +00:00 committed by cosmonaut
parent 88d9119830
commit b39526ca90
4 changed files with 24 additions and 27 deletions

View File

@ -71,7 +71,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount; currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format; colorFormatOne = colorAttachmentInfo.Texture.Format;
#endif #endif
} }
@ -111,7 +111,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
#endif #endif
@ -159,7 +159,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format; colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -215,7 +215,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format; colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -285,7 +285,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfo.SampleCount; currentSampleCount = colorAttachmentInfo.Texture.SampleCount;
colorFormatOne = colorAttachmentInfo.Texture.Format; colorFormatOne = colorAttachmentInfo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
#endif #endif
@ -332,7 +332,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; depthStencilFormat = depthStencilAttachmentInfo.Texture.Format;
@ -387,7 +387,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format; colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -450,7 +450,7 @@ namespace MoonWorks.Graphics
#if DEBUG #if DEBUG
renderPassActive = true; renderPassActive = true;
currentSampleCount = colorAttachmentInfoOne.SampleCount; currentSampleCount = colorAttachmentInfoOne.Texture.SampleCount;
colorFormatOne = colorAttachmentInfoOne.Texture.Format; colorFormatOne = colorAttachmentInfoOne.Texture.Format;
colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; colorFormatTwo = colorAttachmentInfoTwo.Texture.Format;
colorFormatThree = colorAttachmentInfoThree.Texture.Format; colorFormatThree = colorAttachmentInfoThree.Texture.Format;
@ -2046,7 +2046,7 @@ namespace MoonWorks.Graphics
private void AssertSameSampleCount(ColorAttachmentInfo a, ColorAttachmentInfo b) 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!"); 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 Depth;
public uint Layer; public uint Layer;
public uint Level; public uint Level;
public SampleCount SampleCount;
public Color ClearColor; public Color ClearColor;
public LoadOp LoadOp; public LoadOp LoadOp;
public StoreOp StoreOp; public StoreOp StoreOp;
@ -189,15 +188,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo( public ColorAttachmentInfo(
Texture texture, Texture texture,
Color clearColor, Color clearColor,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store StoreOp storeOp = StoreOp.Store
) ) {
{
Texture = texture; Texture = texture;
Depth = 0; Depth = 0;
Layer = 0; Layer = 0;
Level = 0; Level = 0;
SampleCount = sampleCount;
ClearColor = clearColor; ClearColor = clearColor;
LoadOp = LoadOp.Clear; LoadOp = LoadOp.Clear;
StoreOp = storeOp; StoreOp = storeOp;
@ -206,15 +202,12 @@ namespace MoonWorks.Graphics
public ColorAttachmentInfo( public ColorAttachmentInfo(
Texture texture, Texture texture,
LoadOp loadOp = LoadOp.DontCare, LoadOp loadOp = LoadOp.DontCare,
SampleCount sampleCount = SampleCount.One,
StoreOp storeOp = StoreOp.Store StoreOp storeOp = StoreOp.Store
) ) {
{
Texture = texture; Texture = texture;
Depth = 0; Depth = 0;
Layer = 0; Layer = 0;
Level = 0; Level = 0;
SampleCount = sampleCount;
ClearColor = Color.White; ClearColor = Color.White;
LoadOp = loadOp; LoadOp = loadOp;
StoreOp = storeOp; StoreOp = storeOp;
@ -228,7 +221,6 @@ namespace MoonWorks.Graphics
depth = Depth, depth = Depth,
layer = Layer, layer = Layer,
level = Level, level = Level,
sampleCount = (Refresh.SampleCount) SampleCount,
clearColor = new Refresh.Vec4 clearColor = new Refresh.Vec4
{ {
x = ClearColor.R / 255f, x = ClearColor.R / 255f,

View File

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

View File

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