public void Render(CommandList cl, ISurfaceCopyStageModel stage, GpuSurface source) { if (cl == null || stage == null || source == null) { _frameworkMessenger.Report("Warning: you are feeding the Surface Copy Stage Renderer null inputs, aborting"); return; } //Ensure the staging texture is of the correct size var stagingTexture = _gpuSurfaceManager.RetrieveSurface(stage.StagingTextureId); var doStagingTexturePropertiesMatch = source.Texture.Width == stagingTexture.Texture.Width && source.Texture.Height == stagingTexture.Texture.Height; var pixelFormatOfSource = source.Texture.Format; if (pixelFormatOfSource != stagingTexture.Texture.Format) { doStagingTexturePropertiesMatch = false; } if (!doStagingTexturePropertiesMatch) { stage.SetPixelFormatAndCreateStagingTextureAndDataArray(source.Texture.Width, source.Texture.Height, TexturePixelFormatConverter.ConvertVeldridToYak(pixelFormatOfSource)); stagingTexture = _gpuSurfaceManager.RetrieveSurface(stage.StagingTextureId); } cl.CopyTexture(source.Texture, stagingTexture.Texture); }
public IRenderTarget CreateRenderTarget(uint width, uint height, bool autoClearColourAndDepthEachFrame = true, SamplerType samplerType = SamplerType.Anisotropic, uint numberOfMipMapLevels = 1) { if (width == 0 || height == 0) { throw new Yak2DException("Surfaces -> CreateRenderTarget(), dimensions cannot be zero"); } if (numberOfMipMapLevels == 0) { numberOfMipMapLevels = 1; } return(_surfaceManager.CreateRenderSurface( false, width, height, TexturePixelFormatConverter.ConvertYakToVeldrid(_systemComponents.SwapChainFramebufferPixelFormat), true, autoClearColourAndDepthEachFrame, autoClearColourAndDepthEachFrame, samplerType, numberOfMipMapLevels )); }
private ulong CreateSurface(uint width, uint height, SamplerType samplerType) { return(_surfaceManager.CreateRenderSurface(true, width, height, TexturePixelFormatConverter.ConvertYakToVeldrid(_systemComponents.SwapChainFramebufferPixelFormat), false, false, false, samplerType, 1).Id); }
public void SetPixelFormatAndCreateStagingTextureAndDataArray(uint stagingTextureWidth, uint stagingTextureHeight, TexturePixelFormat pixelFormat) { _pixelFormat = TexturePixelFormatConverter.ConvertYakToVeldrid(pixelFormat); _stagingTextureWidth = stagingTextureWidth; _stagingTextureHeight = stagingTextureHeight; if (StagingTextureId != 0UL) { _surfaceManager.DestroySurface(StagingTextureId); } StagingTextureId = _surfaceManager.CreateGpuCpuStagingSurface(_stagingTextureWidth, _stagingTextureHeight, _pixelFormat).Id; _data = new byte[4 * _stagingTextureWidth * _stagingTextureHeight]; }
public ISurfaceCopyStageModel CreateSurfaceCopyDataStage(uint stagingTextureWidth, uint stagingTextureHeight, Action <TextureData> callback, bool useFloat32PixelFormat) { return(new SurfaceCopyStageModel(_frameworkMessenger, _systemComponents, _gpuSurfaceManager, stagingTextureWidth, stagingTextureHeight, useFloat32PixelFormat ? Veldrid.PixelFormat.R32_Float : TexturePixelFormatConverter.ConvertYakToVeldrid(_systemComponents.SwapChainFramebufferPixelFormat), callback)); }
public SurfaceCopyStageModel(IFrameworkMessenger frameworkMessenger, ISystemComponents systemComponents, IGpuSurfaceManager surfaceManager, uint stagingTextureWidth, uint stagingTextureHeight, PixelFormat pixelFormat, Action <TextureData> callback) { _frameworkMessenger = frameworkMessenger; _systemComponents = systemComponents; _surfaceManager = surfaceManager; SetCallback(callback); SetPixelFormatAndCreateStagingTextureAndDataArray(stagingTextureWidth, stagingTextureHeight, TexturePixelFormatConverter.ConvertVeldridToYak(pixelFormat)); }