Hi
I'm trying to implement the resizing of render target when window/control is resized.
However when doing so it is not working as expected (maybe cause i'm not doing it correctly) as the rendered texture is not filling my entire render target view.
Now, when ever the window is resized, i reset my render target view and any other render target (texture) [Please see code below]
this.ImgSource.SetRenderTargetDX11(null);
Disposer.SafeDispose(ref this.m_RenderTargetView);
Disposer.SafeDispose(ref this.m_d11Factory);
Disposer.SafeDispose(ref this.RenderTarget);
int width = (int)sizeInfo.Width;
int height = (int)sizeInfo.Height;
Texture2DDescription colordesc = new Texture2DDescription
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = PIXEL_FORMAT,
Width = width,
Height = height,
MipLevels = 1,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
OptionFlags = ResourceOptionFlags.Shared,
CpuAccessFlags = CpuAccessFlags.None,
ArraySize = 1
};
this.RenderTarget = new Texture2D(this.Device, colordesc);
m_RenderTargetView = new RenderTargetView(this.Device, this.RenderTarget);
m_depthStencil = CreateTexture2D(this.Device, width, height, BindFlags.DepthStencil, Format.D24_UNorm_S8_UInt);
m_depthStencilView = new DepthStencilView(this.Device, m_depthStencil);
Device.ImmediateContext.Rasterizer.SetViewport(0, 0, width, height, 0.0f, 1.0f);
Device.ImmediateContext.OutputMerger.SetTargets(m_depthStencilView, m_RenderTargetView);
SetShaderAndVertices(sizeInfo);
Also my texture data is updated from another thread via mapping the bitmap data to my render target.
Note: Texture fills the entire render target view if the mapped image is of same size as my rendered target view.
Please see screen dumps below:
1. When mapped image and render target view are of same dimensions.
[attachment=29725:Capture_SameSizeTexture.JPG]
2. When mapped image and render target view are not of same dimension
[attachment=29726:Capture_DifferentSizeTexture.JPG]
Thus the above screen-dump highlights my issue.
How would i approach this in order to resolve so that the no matter the dimensions of the mapped image my render target view is always filled with it.
Any suggestions ?
PS: Using C# , SharpDx with Directx11 and D3DImage && not using Swapchains
Thanks.