presentation API update

main
cosmonaut 2022-03-01 23:39:35 -08:00
parent 9384ad4d4a
commit 16970e0020
3 changed files with 11 additions and 25 deletions

@ -1 +1 @@
Subproject commit 7328cbc13dc0e1f156689aeeae2fd5ae4be24084 Subproject commit ef10be4e9db616e345c995ed04de6b92ba5d1d06

BIN
moonlibs/lib64/libRefresh.so.0 (Stored with Git LFS)

Binary file not shown.

View File

@ -10,8 +10,6 @@ namespace MoonWorksComputeSpriteBatch
{ {
public class TestGame : Game public class TestGame : Game
{ {
private RenderTarget mainColorTarget;
private GraphicsPipeline spritePipeline; private GraphicsPipeline spritePipeline;
private SpriteBatch spriteBatch; private SpriteBatch spriteBatch;
@ -35,14 +33,6 @@ namespace MoonWorksComputeSpriteBatch
var vertexShaderModule = new ShaderModule(GraphicsDevice, Path.Combine(Environment.CurrentDirectory, "Content", "sprite.vert.spv")); var vertexShaderModule = new ShaderModule(GraphicsDevice, Path.Combine(Environment.CurrentDirectory, "Content", "sprite.vert.spv"));
var fragmentShaderModule = new ShaderModule(GraphicsDevice, Path.Combine(Environment.CurrentDirectory, "Content", "sprite.frag.spv")); var fragmentShaderModule = new ShaderModule(GraphicsDevice, Path.Combine(Environment.CurrentDirectory, "Content", "sprite.frag.spv"));
mainColorTarget = RenderTarget.CreateBackedRenderTarget(
GraphicsDevice,
windowWidth,
windowHeight,
TextureFormat.R8G8B8A8,
false
);
/* Pipeline */ /* Pipeline */
ColorBlendState colorBlendState = new ColorBlendState ColorBlendState colorBlendState = new ColorBlendState
@ -121,7 +111,7 @@ namespace MoonWorksComputeSpriteBatch
{ {
new ColorAttachmentDescription new ColorAttachmentDescription
{ {
Format = TextureFormat.R8G8B8A8, Format = GraphicsDevice.GetSwapchainFormat(Window),
SampleCount = SampleCount.One, SampleCount = SampleCount.One,
BlendState = ColorAttachmentBlendState.None BlendState = ColorAttachmentBlendState.None
} }
@ -174,6 +164,7 @@ namespace MoonWorksComputeSpriteBatch
protected override void Draw(TimeSpan dt, double alpha) protected override void Draw(TimeSpan dt, double alpha)
{ {
var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window);
var viewProjection = Matrix4x4.CreateLookAt(new Vector3(windowWidth / 2, windowHeight / 2, 1), new Vector3(windowWidth / 2, windowHeight / 2, 0), Vector3.Up) * Matrix4x4.CreateOrthographic(windowWidth, windowHeight, 0.1f, 1000); var viewProjection = Matrix4x4.CreateLookAt(new Vector3(windowWidth / 2, windowHeight / 2, 1), new Vector3(windowWidth / 2, windowHeight / 2, 0), Vector3.Up) * Matrix4x4.CreateOrthographic(windowWidth, windowHeight, 0.1f, 1000);
spriteBatch.Start(whitePixel, sampler); spriteBatch.Start(whitePixel, sampler);
@ -185,17 +176,12 @@ namespace MoonWorksComputeSpriteBatch
spriteBatch.Add(new Sprite(new Rect { X = 0, Y = 0, W = 0, H = 0 }, 128, 128), transform, color); spriteBatch.Add(new Sprite(new Rect { X = 0, Y = 0, W = 0, H = 0 }, 128, 128), transform, color);
} }
var colorAttachmentInfo = new ColorAttachmentInfo spriteBatch.Flush(
{ commandBuffer,
RenderTarget = mainColorTarget, new ColorAttachmentInfo(swapchainTexture, Color.Black),
ClearColor = Color.Black, spritePipeline,
LoadOp = LoadOp.Clear, new CameraUniforms { viewProjectionMatrix = viewProjection }
StoreOp = StoreOp.DontCare );
};
spriteBatch.Flush(commandBuffer, colorAttachmentInfo, spritePipeline, new CameraUniforms { viewProjectionMatrix = viewProjection });
commandBuffer.QueuePresent(mainColorTarget.TextureSlice, Filter.Nearest, Window);
GraphicsDevice.Submit(commandBuffer); GraphicsDevice.Submit(commandBuffer);
} }