update render pass ABI

main
cosmonaut 2022-02-24 22:07:35 -08:00
parent 86f568fe52
commit f7be55f6c6
6 changed files with 86 additions and 170 deletions

View File

@ -1,13 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<TargetName>MoonWorksMultiWindow</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>

@ -1 +1 @@
Subproject commit 4acc2588e17f2ad1f594e95e9e06d4d2ae7009ac
Subproject commit e5213da686fd4700d16a0c627d5f1ab4fce0ee12

View File

@ -1,36 +0,0 @@
using MoonWorks.Graphics;
namespace MoonWorksMultiWindow.Graphics
{
public class Framebuffers
{
public Framebuffer ExampleFramebuffer { get; }
public Framebuffer ExtraWindowFramebuffer { get; }
public Framebuffers(
GraphicsDevice graphicsDevice,
RenderPasses renderPasses,
RenderTargets renderTargets,
uint renderDimensionsX,
uint renderDimensionsY
) {
ExampleFramebuffer = new Framebuffer(
graphicsDevice,
renderDimensionsX,
renderDimensionsY,
renderPasses.ExampleRenderPass,
null,
renderTargets.ExampleRenderTarget
);
ExtraWindowFramebuffer = new Framebuffer(
graphicsDevice,
renderDimensionsX,
renderDimensionsY,
renderPasses.ExtraWindowRenderPass,
null,
renderTargets.ExtraWindowRenderTarget
);
}
}
}

View File

@ -1,31 +0,0 @@
using MoonWorks.Graphics;
namespace MoonWorksMultiWindow.Graphics
{
public class RenderPasses
{
public RenderPass ExampleRenderPass { get; }
public RenderPass ExtraWindowRenderPass { get; }
public RenderPasses(GraphicsDevice graphicsDevice)
{
var clearPassDescription = new ColorTargetDescription
{
Format = TextureFormat.R8G8B8A8,
LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store,
MultisampleCount = SampleCount.One
};
ExampleRenderPass = new RenderPass(
graphicsDevice,
clearPassDescription
);
ExtraWindowRenderPass = new RenderPass(
graphicsDevice,
clearPassDescription
);
}
}
}

View File

@ -2,30 +2,21 @@ using MoonWorks.Graphics;
namespace MoonWorksMultiWindow.Graphics
{
public class GraphicsObjects
{
public RenderTargets RenderTargets { get; }
public Framebuffers Framebuffers { get; }
public RenderPasses RenderPasses { get; }
public class GraphicsObjects
{
public RenderTargets RenderTargets { get; }
public GraphicsObjects(
GraphicsDevice graphicsDevice,
uint renderDimensionsX,
uint renderDimensionsY
) {
RenderPasses = new RenderPasses(graphicsDevice);
RenderTargets = new RenderTargets(
graphicsDevice,
renderDimensionsX,
renderDimensionsY
);
Framebuffers = new Framebuffers(
graphicsDevice,
RenderPasses,
RenderTargets,
renderDimensionsX,
renderDimensionsY
);
}
}
public GraphicsObjects(
GraphicsDevice graphicsDevice,
uint renderDimensionsX,
uint renderDimensionsY
)
{
RenderTargets = new RenderTargets(
graphicsDevice,
renderDimensionsX,
renderDimensionsY
);
}
}
}

View File

@ -6,29 +6,29 @@ using System.Threading.Tasks;
namespace MoonWorksMultiWindow
{
class MoonWorksMultiWindowGame : Game
{
private GraphicsObjects GraphicsObjects { get; }
class MoonWorksMultiWindowGame : Game
{
private GraphicsObjects GraphicsObjects { get; }
private int RenderWidth { get; }
private int RenderHeight { get; }
private int RenderWidth { get; }
private int RenderHeight { get; }
private OSWindow ExtraWindow { get; }
public MoonWorksMultiWindowGame(
WindowCreateInfo windowCreateInfo,
PresentMode presentMode,
bool debugMode
) : base(windowCreateInfo, presentMode, 60, debugMode)
{
// Insert your game initialization logic here.
GraphicsObjects = new GraphicsObjects(
GraphicsDevice,
windowCreateInfo.WindowWidth,
windowCreateInfo.WindowHeight
);
RenderWidth = (int)windowCreateInfo.WindowWidth;
RenderHeight = (int)windowCreateInfo.WindowHeight;
public MoonWorksMultiWindowGame(
WindowCreateInfo windowCreateInfo,
PresentMode presentMode,
bool debugMode
) : base(windowCreateInfo, presentMode, 60, debugMode)
{
// Insert your game initialization logic here.
GraphicsObjects = new GraphicsObjects(
GraphicsDevice,
windowCreateInfo.WindowWidth,
windowCreateInfo.WindowHeight
);
RenderWidth = (int)windowCreateInfo.WindowWidth;
RenderHeight = (int)windowCreateInfo.WindowHeight;
var extraWindowCreateInfo = new WindowCreateInfo
{
@ -39,67 +39,60 @@ namespace MoonWorksMultiWindow
};
ExtraWindow = new OSWindow(extraWindowCreateInfo);
}
}
protected override void Update(System.TimeSpan dt)
{
// Insert your game update logic here.
}
protected override void Update(System.TimeSpan dt)
{
// Insert your game update logic here.
}
protected override void Draw(System.TimeSpan dt, double alpha)
{
protected override void Draw(System.TimeSpan dt, double alpha)
{
var mainDraw = Task.Run(MainDraw);
var extraDraw = Task.Run(ExtraWindowDraw);
mainDraw.Wait();
extraDraw.Wait();
GraphicsDevice.Submit(mainDraw.Result, extraDraw.Result);
}
private CommandBuffer MainDraw()
{
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
commandBuffer.BeginRenderPass(
GraphicsObjects.RenderPasses.ExampleRenderPass,
GraphicsObjects.Framebuffers.ExampleFramebuffer,
new Rect
{
X = 0,
Y = 0,
W = RenderWidth,
H = RenderHeight
},
Color.CornflowerBlue.ToVector4()
);
commandBuffer.EndRenderPass();
commandBuffer.QueuePresent(
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
Filter.Nearest,
Window
);
return commandBuffer;
}
private CommandBuffer ExtraWindowDraw()
private void MainDraw()
{
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
commandBuffer.BeginRenderPass(
GraphicsObjects.RenderPasses.ExtraWindowRenderPass,
GraphicsObjects.Framebuffers.ExtraWindowFramebuffer,
new Rect
{
X = 0,
Y = 0,
W = RenderWidth,
H = RenderHeight
},
Color.OrangeRed.ToVector4()
);
commandBuffer.BeginRenderPass(
new ColorAttachmentInfo
{
renderTarget = GraphicsObjects.RenderTargets.ExampleRenderTarget,
clearColor = Color.CornflowerBlue,
loadOp = LoadOp.Clear,
storeOp = StoreOp.DontCare
}
);
commandBuffer.EndRenderPass();
commandBuffer.QueuePresent(
GraphicsObjects.RenderTargets.ExampleRenderTarget.TextureSlice,
Filter.Nearest,
Window
);
GraphicsDevice.Submit(commandBuffer);
}
private void ExtraWindowDraw()
{
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
commandBuffer.BeginRenderPass(
new ColorAttachmentInfo
{
renderTarget = GraphicsObjects.RenderTargets.ExtraWindowRenderTarget,
clearColor = Color.OrangeRed,
loadOp = LoadOp.Clear,
storeOp = StoreOp.DontCare
}
);
commandBuffer.EndRenderPass();
@ -109,7 +102,12 @@ namespace MoonWorksMultiWindow
ExtraWindow
);
return commandBuffer;
GraphicsDevice.Submit(commandBuffer);
}
}
protected override void OnDestroy()
{
}
}
}