void iSwapChain.end(bool replaceContent) { RenderTarget rt = end(); if (replaceContent) { rt.replace(context, rtv, dsv); // ConsoleLogger.logDebug( "SwapChainBase.end replaced render target content" ); } else { if (null != blender && blender.samplesCount != 0 && blender.samplesCount != sampleCount) { ComUtils.clear(ref blender); } if (null == blender) { using (var dev = context.renderContext.device) blender = new Blender(context, dev, sampleCount); } rt.blend(context, rtv, dsv, blender); } rtv = dsv = null; }
public void Dispose() { textureVariable?.Dispose(); binding?.Dispose(); pipelineState?.Dispose(); ComUtils.clear(ref vertexBuffer); }
public void Dispose() { ComUtils.clear(ref m_staticCBuffer); ComUtils.clear(ref m_staticCBufferForText); ComUtils.clear(ref m_fewDrawCalls); m_indexBuffer?.Dispose(); m_vertexBuffer?.Dispose(); }
public void initTextCBuffer() { DrawDevice dev = (DrawDevice)context.drawDevice; Action actClear = () => { GpuResources res = this; ComUtils.clear(ref res.m_staticCBufferForText); }; dev.fontTextures.subscriveResized(this, actClear); }
public void grab(IRenderDevice device, IDeviceContext context, ITexture texture, ConsumeTextureDelegate consume) { TextureDesc desc = texture.GetDesc(); // Create staging texture if needed if (null == stagingTexture || stagingDesc.Size != desc.Size || stagingDesc.Format != desc.Format) { ComUtils.clear(ref stagingTexture); desc.Type = ResourceDimension.Tex2d; desc.BindFlags = BindFlags.None; desc.CPUAccessFlags = CpuAccessFlags.Read; desc.Usage = Usage.Staging; stagingTexture = device.CreateTexture(ref desc, "ScreenGrabber staging"); stagingDesc = desc; } // In D3D12, Diligent engine fails instead of waiting for GPU. Need to wait manually, need a fence for that. if (RuntimeEnvironment.runningWindows && null == fence) { var fd = new FenceDesc(false); fence = device.CreateFence(ref fd); } // Finish the rendering, if any waitForGpu(context); // Unset the targets context.SetRenderTargets(0, null, null); waitForGpu(context); // Copy source texture to staging context.copyTexture(stagingTexture, texture); waitForGpu(context); // Map the texture Box box = new Box(false) { MaxX = desc.Size.cx, MaxY = desc.Size.cy }; MappedTextureSubresource mapped = context.MapTextureSubresource(stagingTexture, 0, 0, MapType.Read, MapFlags.DoNotWait, ref box); try { consume(desc.Format, desc.Size, mapped); } finally { context.UnmapTextureSubresource(stagingTexture, 0, 0); } }
void createStaticCBuffer(CSize size, double dpiScaling) { var data = new StaticConstantsBuffer(); data.pixelSizeAndDpiScaling.X = 2.0f / size.cx; data.pixelSizeAndDpiScaling.Y = 2.0f / size.cy; data.pixelSizeAndDpiScaling.Z = (float)dpiScaling; data.pixelSizeAndDpiScaling.W = (float)(1.0 / dpiScaling); pixelSizeAndDpiScaling = data.pixelSizeAndDpiScaling; BufferDesc desc = new BufferDesc(false) { uiSizeInBytes = 16, BindFlags = BindFlags.UniformBuffer, Usage = Usage.Static, }; ComUtils.clear(ref m_staticCBuffer); using (var device = context.renderContext.device) m_staticCBuffer = device.CreateBuffer(desc, ref data, "StaticConstantsBuffer"); }
/// <summary>Destroy the resource binding object</summary> /// <remarks>Called when buffers are recreated due to expansion. /// Also called when user resizes window, or drags the window to a monitor with different DPI, invalidating the data in StaticConstantsBuffer.</remarks> protected void dropResourceBindings() { ComUtils.clear(ref resourceBinding); }
void iVideoRenderState.resize(IRenderDevice device, CSize newSize) { ComUtils.clear(ref vertexBuffer); vertexBuffer = createVideoVertexBuffer(device, newSize, ref videoSize); }
public void Dispose() { ComUtils.clear(ref m_textureView); ComUtils.clear(ref texture); }
public override void destroyTargets() { ComUtils.clear(ref renderTarget); }
void onSwapChainResized(CSize newSize, double dpiScaling) { createStaticCBuffer(newSize, dpiScaling); ComUtils.clear(ref m_staticCBufferForText); }