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"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetName>MoonWorksMultiWindow</TargetName> <TargetName>MoonWorksMultiWindow</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> <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 namespace MoonWorksMultiWindow.Graphics
{ {
public class GraphicsObjects public class GraphicsObjects
{ {
public RenderTargets RenderTargets { get; } public RenderTargets RenderTargets { get; }
public Framebuffers Framebuffers { get; }
public RenderPasses RenderPasses { get; }
public GraphicsObjects( public GraphicsObjects(
GraphicsDevice graphicsDevice, GraphicsDevice graphicsDevice,
uint renderDimensionsX, uint renderDimensionsX,
uint renderDimensionsY uint renderDimensionsY
) { )
RenderPasses = new RenderPasses(graphicsDevice); {
RenderTargets = new RenderTargets( RenderTargets = new RenderTargets(
graphicsDevice, graphicsDevice,
renderDimensionsX, renderDimensionsX,
renderDimensionsY renderDimensionsY
); );
Framebuffers = new Framebuffers( }
graphicsDevice, }
RenderPasses,
RenderTargets,
renderDimensionsX,
renderDimensionsY
);
}
}
} }

View File

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