From ee8331a96b1ddafee85f60ffdb5e0e1d4db5dc10 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 12 Mar 2024 16:52:10 -0700 Subject: [PATCH] misc fixes --- src/Graphics/CommandBuffer.cs | 11 ++++++----- src/Graphics/Font/TextBatch.cs | 2 ++ src/Graphics/RefreshStructs.cs | 18 ++++++++++++++++++ src/Graphics/ResourceUploader.cs | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 15693ea..d11ec6e 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -1388,18 +1388,19 @@ namespace MoonWorks.Graphics /// /// Specifies data dependency behavior. public void Blit( - TextureSlice source, - TextureSlice destination, + TextureRegion source, + TextureRegion destination, Filter filter, WriteOptions writeOption ) { var sampler = filter == Filter.Linear ? Device.LinearSampler : Device.PointSampler; // FIXME: this will break with non-2D textures - // FIXME: this should take a TextureRegion - BeginRenderPass(new ColorAttachmentInfo(destination, writeOption)); + // FIXME: the source texture region does nothing right now + BeginRenderPass(new ColorAttachmentInfo(destination.TextureSlice, writeOption)); + SetViewport(new Viewport(destination.X, destination.Y, destination.Width, destination.Height)); BindGraphicsPipeline(Device.BlitPipeline); - BindFragmentSamplers(new TextureSamplerBinding(source.Texture, sampler)); + BindFragmentSamplers(new TextureSamplerBinding(source.TextureSlice.Texture, sampler)); DrawPrimitives(0, 2); EndRenderPass(); } diff --git a/src/Graphics/Font/TextBatch.cs b/src/Graphics/Font/TextBatch.cs index e6cfe0c..a64a1b0 100644 --- a/src/Graphics/Font/TextBatch.cs +++ b/src/Graphics/Font/TextBatch.cs @@ -127,8 +127,10 @@ namespace MoonWorks.Graphics.Font TransferBuffer.SetData(vertexSpan, TransferOptions.Cycle); TransferBuffer.SetData(indexSpan, (uint) vertexSpan.Length, TransferOptions.Unsafe); + commandBuffer.BeginCopyPass(); commandBuffer.UploadToBuffer(TransferBuffer, VertexBuffer, new BufferCopy(0, 0, (uint) vertexSpan.Length), WriteOptions.Cycle); commandBuffer.UploadToBuffer(TransferBuffer, IndexBuffer, new BufferCopy((uint) vertexSpan.Length, 0, (uint) indexSpan.Length), WriteOptions.Cycle); + commandBuffer.EndCopyPass(); } PrimitiveCount = vertexCount / 2; diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index 4b30885..9d6d88a 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -386,6 +386,24 @@ namespace MoonWorks.Graphics WriteOption = writeOption; } + public DepthStencilAttachmentInfo( + TextureSlice textureSlice, + WriteOptions writeOption, + DepthStencilValue clearValue, + LoadOp loadOp, + StoreOp storeOp, + LoadOp stencilLoadOp, + StoreOp stencilStoreOp + ) { + TextureSlice = textureSlice; + DepthStencilClearValue = clearValue; + LoadOp = loadOp; + StoreOp = storeOp; + StencilLoadOp = stencilLoadOp; + StencilStoreOp = stencilStoreOp; + WriteOption = writeOption; + } + public Refresh.DepthStencilAttachmentInfo ToRefresh() { return new Refresh.DepthStencilAttachmentInfo diff --git a/src/Graphics/ResourceUploader.cs b/src/Graphics/ResourceUploader.cs index ecc81e5..0475931 100644 --- a/src/Graphics/ResourceUploader.cs +++ b/src/Graphics/ResourceUploader.cs @@ -219,7 +219,7 @@ namespace MoonWorks.Graphics uint resourceOffset; fixed (T* dataPtr = data) { - resourceOffset = CopyTextureData(dataPtr, dataLengthInBytes, Texture.TexelSize(textureRegion.TextureSlice.Texture.Format)); + resourceOffset = CopyTextureData(dataPtr, dataLengthInBytes, Texture.BytesPerPixel(textureRegion.TextureSlice.Texture.Format)); } TextureUploads.Add((textureRegion, resourceOffset, option));