Refresh2 changes

This commit is contained in:
cosmonaut 2024-02-27 10:35:05 -08:00
parent 9d8f4f6089
commit 0cbf877de3
4 changed files with 31 additions and 33 deletions

View File

@ -8,19 +8,19 @@
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))"> <ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">
<Content Include=".\moonlibs\x64\**\*.*"> <Content Include=".\moonlibs\x64\**\*.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))"> <ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))">
<Content Include=".\moonlibs\lib64\**\*.*"> <Content Include=".\moonlibs\lib64\**\*.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))"> <ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))">
<Content Include=".\moonlibs\osx\**\*.*" > <Content Include=".\moonlibs\osx\**\*.*" >
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link> <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>

@ -1 +1 @@
Subproject commit 4dbd5a2cbeab38f78274644f3b44fe1fa727f304 Subproject commit 178a5ea3cfa4ce4ccbcd9e0b6726a8cda791c810

BIN
moonlibs/x64/Refresh.dll (Stored with Git LFS)

Binary file not shown.

View File

@ -19,11 +19,13 @@ class MoonWorksDearImGuiScaffoldGame : Game
private uint VertexCount = 0; private uint VertexCount = 0;
private uint IndexCount = 0; private uint IndexCount = 0;
private MoonWorks.Graphics.Buffer ImGuiVertexBuffer = null; private GpuBuffer ImGuiVertexBuffer = null;
private MoonWorks.Graphics.Buffer ImGuiIndexBuffer = null; private GpuBuffer ImGuiIndexBuffer = null;
private TextureStorage TextureStorage; private TextureStorage TextureStorage;
private ResourceUploader ResourceUploader;
public MoonWorksDearImGuiScaffoldGame( public MoonWorksDearImGuiScaffoldGame(
WindowCreateInfo windowCreateInfo, WindowCreateInfo windowCreateInfo,
FrameLimiterSettings frameLimiterSettings, FrameLimiterSettings frameLimiterSettings,
@ -31,6 +33,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
) : base(windowCreateInfo, frameLimiterSettings, 60, debugMode) ) : base(windowCreateInfo, frameLimiterSettings, 60, debugMode)
{ {
TextureStorage = new TextureStorage(); TextureStorage = new TextureStorage();
ResourceUploader = new ResourceUploader(GraphicsDevice);
ImGui.CreateContext(); ImGui.CreateContext();
@ -177,7 +180,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
ImGuiVertexBuffer?.Dispose(); ImGuiVertexBuffer?.Dispose();
VertexCount = (uint)(drawDataPtr.TotalVtxCount * 1.5f); VertexCount = (uint)(drawDataPtr.TotalVtxCount * 1.5f);
ImGuiVertexBuffer = MoonWorks.Graphics.Buffer.Create<Position2DTextureColorVertex>( ImGuiVertexBuffer = GpuBuffer.Create<Position2DTextureColorVertex>(
GraphicsDevice, GraphicsDevice,
BufferUsageFlags.Vertex, BufferUsageFlags.Vertex,
VertexCount VertexCount
@ -189,7 +192,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
ImGuiIndexBuffer?.Dispose(); ImGuiIndexBuffer?.Dispose();
IndexCount = (uint)(drawDataPtr.TotalIdxCount * 1.5f); IndexCount = (uint)(drawDataPtr.TotalIdxCount * 1.5f);
ImGuiIndexBuffer = MoonWorks.Graphics.Buffer.Create<ushort>( ImGuiIndexBuffer = GpuBuffer.Create<ushort>(
GraphicsDevice, GraphicsDevice,
BufferUsageFlags.Index, BufferUsageFlags.Index,
IndexCount IndexCount
@ -203,24 +206,24 @@ class MoonWorksDearImGuiScaffoldGame : Game
{ {
var cmdList = drawDataPtr.CmdLists[n]; var cmdList = drawDataPtr.CmdLists[n];
commandBuffer.SetBufferData<Position2DTextureColorVertex>( ResourceUploader.SetBufferData(
ImGuiVertexBuffer, ImGuiVertexBuffer,
cmdList.VtxBuffer.Data,
vertexOffset, vertexOffset,
(uint)cmdList.VtxBuffer.Size new Span<Position2DTextureColorVertex>((void*) cmdList.VtxBuffer.Data, cmdList.VtxBuffer.Size)
); );
commandBuffer.SetBufferData<ushort>( ResourceUploader.SetBufferData(
ImGuiIndexBuffer, ImGuiIndexBuffer,
cmdList.IdxBuffer.Data,
indexOffset, indexOffset,
(uint)cmdList.IdxBuffer.Size new Span<ushort>((void*) cmdList.IdxBuffer.Data, cmdList.IdxBuffer.Size)
); );
vertexOffset += (uint) cmdList.VtxBuffer.Size; vertexOffset += (uint) cmdList.VtxBuffer.Size;
indexOffset += (uint) cmdList.IdxBuffer.Size; indexOffset += (uint) cmdList.IdxBuffer.Size;
} }
ResourceUploader.Upload();
GraphicsDevice.Submit(commandBuffer); GraphicsDevice.Submit(commandBuffer);
} }
@ -249,7 +252,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
commandBuffer.BindGraphicsPipeline(ImGuiPipeline); commandBuffer.BindGraphicsPipeline(ImGuiPipeline);
var vertexUniformOffset = commandBuffer.PushVertexShaderUniforms( commandBuffer.PushVertexShaderUniforms(
Matrix4x4.CreateOrthographicOffCenter(0, ioPtr.DisplaySize.X, ioPtr.DisplaySize.Y, 0, -1, 1) Matrix4x4.CreateOrthographicOffCenter(0, ioPtr.DisplaySize.X, ioPtr.DisplaySize.Y, 0, -1, 1)
); );
@ -294,9 +297,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
commandBuffer.DrawIndexedPrimitives( commandBuffer.DrawIndexedPrimitives(
vertexOffset, vertexOffset,
indexOffset, indexOffset,
drawCmd.ElemCount / 3, drawCmd.ElemCount / 3
vertexUniformOffset,
0
); );
indexOffset += drawCmd.ElemCount; indexOffset += drawCmd.ElemCount;
@ -308,9 +309,9 @@ class MoonWorksDearImGuiScaffoldGame : Game
commandBuffer.EndRenderPass(); commandBuffer.EndRenderPass();
} }
private void BuildFontAtlas() private unsafe void BuildFontAtlas()
{ {
var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); var resourceUploader = new ResourceUploader(GraphicsDevice);
var io = ImGui.GetIO(); var io = ImGui.GetIO();
@ -321,17 +322,14 @@ class MoonWorksDearImGuiScaffoldGame : Game
out int bytesPerPixel out int bytesPerPixel
); );
var fontTexture = Texture.CreateTexture2D( var fontTexture = resourceUploader.CreateTexture2D(
GraphicsDevice, new Span<byte>((void*) pixelData, width * height * bytesPerPixel),
(uint) width, (uint) width,
(uint)height, (uint) height
TextureFormat.R8G8B8A8,
TextureUsageFlags.Sampler
); );
commandBuffer.SetTextureData(fontTexture, pixelData, (uint)(width * height * bytesPerPixel)); resourceUploader.Upload();
resourceUploader.Dispose();
GraphicsDevice.Submit(commandBuffer);
io.Fonts.SetTexID(fontTexture.Handle); io.Fonts.SetTexID(fontTexture.Handle);
io.Fonts.ClearTexData(); io.Fonts.ClearTexData();