update for render pass ABI break
parent
94f463002d
commit
a828f510af
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cb25e6feff2d9ac3f399b3a43cd11d374f90f127
|
||||
Subproject commit b8b10140a95457a00d658e84d4b67b926f467b15
|
BIN
moonlibs/lib64/libRefresh.so.0 (Stored with Git LFS)
BIN
moonlibs/lib64/libRefresh.so.0 (Stored with Git LFS)
Binary file not shown.
|
@ -43,7 +43,7 @@ namespace MoonWorksComputeSpriteBatch
|
|||
{
|
||||
ShaderModule = computeShaderModule,
|
||||
EntryPointName = "main",
|
||||
UniformBufferSize = (uint) Marshal.SizeOf<SpriteBatchUniforms>()
|
||||
UniformBufferSize = (uint)Marshal.SizeOf<SpriteBatchUniforms>()
|
||||
};
|
||||
|
||||
ComputePipeline = new ComputePipeline(graphicsDevice, computeShaderState, 2, 0);
|
||||
|
@ -128,12 +128,11 @@ namespace MoonWorksComputeSpriteBatch
|
|||
|
||||
public void Flush(
|
||||
CommandBuffer commandBuffer,
|
||||
RenderPass renderPass,
|
||||
Framebuffer framebuffer,
|
||||
Rect renderArea,
|
||||
ColorAttachmentInfo colorAttachmentInfo,
|
||||
GraphicsPipeline graphicsPipeline,
|
||||
CameraUniforms cameraUniforms
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (VertexCount == 0)
|
||||
{
|
||||
return;
|
||||
|
@ -150,7 +149,7 @@ namespace MoonWorksComputeSpriteBatch
|
|||
});
|
||||
commandBuffer.DispatchCompute(System.Math.Max(1, VertexCount / 256), 1, 1, offset);
|
||||
|
||||
commandBuffer.BeginRenderPass(renderPass, framebuffer, renderArea, Vector4.Zero);
|
||||
commandBuffer.BeginRenderPass(colorAttachmentInfo);
|
||||
commandBuffer.BindGraphicsPipeline(graphicsPipeline);
|
||||
commandBuffer.BindVertexBuffers(VertexBuffer);
|
||||
commandBuffer.BindIndexBuffer(IndexBuffer, IndexElementSize.Sixteen);
|
||||
|
|
|
@ -11,10 +11,7 @@ namespace MoonWorksComputeSpriteBatch
|
|||
{
|
||||
public class TestGame : Game
|
||||
{
|
||||
private RenderPass mainRenderPass;
|
||||
private RenderTarget mainColorTarget;
|
||||
private Framebuffer mainFramebuffer;
|
||||
private Rect mainRenderArea;
|
||||
|
||||
private GraphicsPipeline spritePipeline;
|
||||
|
||||
|
@ -39,16 +36,6 @@ namespace MoonWorksComputeSpriteBatch
|
|||
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"));
|
||||
|
||||
ColorTargetDescription colorTargetDescription = new ColorTargetDescription
|
||||
{
|
||||
Format = TextureFormat.R8G8B8A8,
|
||||
MultisampleCount = SampleCount.One,
|
||||
LoadOp = LoadOp.Clear,
|
||||
StoreOp = StoreOp.Store
|
||||
};
|
||||
|
||||
mainRenderPass = new RenderPass(GraphicsDevice, colorTargetDescription);
|
||||
|
||||
mainColorTarget = RenderTarget.CreateBackedRenderTarget(
|
||||
GraphicsDevice,
|
||||
windowWidth,
|
||||
|
@ -57,23 +44,6 @@ namespace MoonWorksComputeSpriteBatch
|
|||
false
|
||||
);
|
||||
|
||||
mainFramebuffer = new Framebuffer(
|
||||
GraphicsDevice,
|
||||
windowWidth,
|
||||
windowHeight,
|
||||
mainRenderPass,
|
||||
null,
|
||||
mainColorTarget
|
||||
);
|
||||
|
||||
mainRenderArea = new Rect
|
||||
{
|
||||
X = 0,
|
||||
Y = 0,
|
||||
W = (int) windowWidth,
|
||||
H = (int) windowHeight
|
||||
};
|
||||
|
||||
/* Pipeline */
|
||||
|
||||
ColorTargetBlendState[] colorTargetBlendStates = new ColorTargetBlendState[1]
|
||||
|
@ -95,7 +65,7 @@ namespace MoonWorksComputeSpriteBatch
|
|||
{
|
||||
ShaderModule = vertexShaderModule,
|
||||
EntryPointName = "main",
|
||||
UniformBufferSize = (uint) Marshal.SizeOf<CameraUniforms>()
|
||||
UniformBufferSize = (uint)Marshal.SizeOf<CameraUniforms>()
|
||||
};
|
||||
|
||||
ShaderStageState fragmentShaderState = new ShaderStageState
|
||||
|
@ -186,6 +156,23 @@ namespace MoonWorksComputeSpriteBatch
|
|||
Scissors = scissors
|
||||
};
|
||||
|
||||
var colorAttachmentDescriptions = new ColorAttachmentDescription[1]
|
||||
{
|
||||
new ColorAttachmentDescription
|
||||
{
|
||||
format = TextureFormat.R8G8B8A8,
|
||||
sampleCount = SampleCount.One
|
||||
}
|
||||
};
|
||||
|
||||
GraphicsPipelineAttachmentInfo graphicsPipelineAttachmentInfo = new GraphicsPipelineAttachmentInfo
|
||||
{
|
||||
colorAttachmentDescriptions = colorAttachmentDescriptions,
|
||||
colorAttachmentCount = 1,
|
||||
hasDepthStencilAttachment = false,
|
||||
depthStencilFormat = 0
|
||||
};
|
||||
|
||||
var graphicsPipelineCreateInfo = new GraphicsPipelineCreateInfo
|
||||
{
|
||||
ColorBlendState = colorBlendState,
|
||||
|
@ -198,7 +185,7 @@ namespace MoonWorksComputeSpriteBatch
|
|||
PrimitiveType = PrimitiveType.TriangleList,
|
||||
VertexInputState = vertexInputState,
|
||||
ViewportState = viewportState,
|
||||
RenderPass = mainRenderPass
|
||||
AttachmentInfo = graphicsPipelineAttachmentInfo
|
||||
};
|
||||
|
||||
spritePipeline = new GraphicsPipeline(GraphicsDevice, graphicsPipelineCreateInfo);
|
||||
|
@ -218,8 +205,8 @@ namespace MoonWorksComputeSpriteBatch
|
|||
{
|
||||
for (var i = 0; i < SPRITECOUNT; i += 1)
|
||||
{
|
||||
positions[i].X = (float) (random.NextDouble() * windowWidth) - 64;
|
||||
positions[i].Y = (float) (random.NextDouble() * windowHeight) - 64;
|
||||
positions[i].X = (float)(random.NextDouble() * windowWidth) - 64;
|
||||
positions[i].Y = (float)(random.NextDouble() * windowHeight) - 64;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,10 +224,23 @@ namespace MoonWorksComputeSpriteBatch
|
|||
spriteBatch.Add(new Sprite(new Rect { X = 0, Y = 0, W = 0, H = 0 }, 128, 128), transform, color);
|
||||
}
|
||||
|
||||
spriteBatch.Flush(commandBuffer, mainRenderPass, mainFramebuffer, mainRenderArea, spritePipeline, new CameraUniforms { viewProjectionMatrix = viewProjection });
|
||||
var colorAttachmentInfo = new ColorAttachmentInfo
|
||||
{
|
||||
renderTarget = mainColorTarget,
|
||||
clearColor = Color.Black,
|
||||
loadOp = LoadOp.Clear,
|
||||
storeOp = StoreOp.DontCare
|
||||
};
|
||||
|
||||
spriteBatch.Flush(commandBuffer, colorAttachmentInfo, spritePipeline, new CameraUniforms { viewProjectionMatrix = viewProjection });
|
||||
|
||||
commandBuffer.QueuePresent(mainColorTarget.TextureSlice, Filter.Nearest, Window);
|
||||
GraphicsDevice.Submit(commandBuffer);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue