Hello. I am using sharpdx on WinRT with toolkit.
I draw to multisampled rendertarget and then resolve subresource to backbuffer to see MSAA texture as a result.
It works fine, but then I want just to draw this render target as minivariant of full view using spritebatch. And it also works, but I receive non-multisampled texture and visual studio says that
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: The Shader Resource View dimension declared in the shader code (TEXTURE2D) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2DMS). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH]
In my shader currently I use Texture2D instead Texture2DMS, but I don`t know how to correctly work with Texture2DMS.
Also drawing to texture2D not causing this error. IT appears when executing spriteBatch.End(); method in:
DepthStencilView oldDepth;
RenderTargetView[] oldTargets = GraphicsDevice.GetRenderTargets(out oldDepth);
GraphicsDevice.SetRenderTargets(depthStencilBuffer,rt);
GraphicsDevice.Clear(Color.CornflowerBlue);
{
customEffect.CurrentTechnique.Passes[0].Apply();
//Setup the vertices
GraphicsDevice.SetVertexBuffer(vertices);
// Setup the indices
GraphicsDevice.SetIndexBuffer(indices, true);
GraphicsDevice.SetVertexInputLayout(inputLayout);
GraphicsDevice.DrawIndexed(PrimitiveType.TriangleList, indices.ElementCount);
fpsRenderer.Render(d2DService);
d2DService.Context.BeginDraw();
d2DService.Context.DrawText(D2DText, d2DService.TextFormat, d2DService.RectangleF,
d2DService.TextBrush);
d2DService.Context.EndDraw();
device.ResolveSubresource(rt, 0, GraphicsDevice.BackBuffer, 0, GraphicsDevice.BackBuffer.Format);
GraphicsDevice.SetRenderTargets(oldDepth, oldTargets);
spriteBatch.Begin();
spriteBatch.Draw(rt, new RectangleF((int)SwapChainPanel.ActualWidth - 500, (int)SwapChainPanel.ActualHeight - 350, 500, 350), new Rectangle(0, 0, 500, 350), Color.White, 0.0f, new Vector2(100, 100), SpriteEffects.None, 0.0f);
spriteBatch.End();
What I must do to solve this issue? Can someone help me with it please?