misc fixes

refresh2
cosmonaut 2024-03-12 16:52:10 -07:00
parent 8813a0139d
commit ee8331a96b
4 changed files with 27 additions and 6 deletions

View File

@ -1388,18 +1388,19 @@ namespace MoonWorks.Graphics
/// </summary>
/// <param name="writeOption">Specifies data dependency behavior.</param>
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();
}

View File

@ -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;

View File

@ -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

View File

@ -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));