title: How do I setup MSAA in D3D11?
body: <p><strong>Edit:</strong> I've changed the code now everything gets rendered into an MSAA Render Target, and calling ResolveSubresource just before the Present call. This seems to work if I Draw directly to the MSAA Render Target, but Drawing it into another Render target first breaks the Anti-Aliasing effect. Visual Studio's Graphics Analyzer shows that indeed, the Anti-Aliasing effect is applied on the first Render Target (a Texture-Bindable Render Target), but not the second (MSAA Render Target).</p>
  <p>I'm currently trying to remove jaggies from my render, but I'm a bit confused on how to actually set thing up. Currently, Right now I'm using the TEXTURE2DMS as the dimension for everything, and for now arbitrarily setting up the Sample count to 2, and the Quality to 0.</p>
  <h2>DirectX setup:</h2>
  <pre><code>Swapchain.SampleDesc.Count = 2;
  Swapchain.SampleDesc.Quality = 0;
  DepthStencil.SampleDesc.Count = 2; 
  DepthStencil.SampleDesc.Quality = 0;
  DepthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
  </code></pre>
  <h2>RenderTarget(Texture) Setup:</h2>
  <pre><code>TextureDesc.SampleDesc.Count = 2;
  RenderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
  DepthDesc.SampleDesc.Count = 2;
  DepthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
  ShaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
  </code></pre>
  <p>I also have 2 Pixel Shaders:</p>
  <pre><code>struct Pin
  {
      float4 Pos : SV_POSITION;
      float4 Col : COLOR0;
      float2 Tex : TEXCOORD0;
      float2 Texel : TEXCOORD1;
  };
  
  //High pass filter
  Texture2D txBlank : register( t0 );
  SamplerState samLinear : register( s0 );
  
  float RGB2RelativeLuminance(float4 c)
  {
      return (c.x * 0.2126) + (c.y * 0.7152) + (c.z * 0.0722);
  }
  
  float4 PS(Pin input) : SV_TARGET
  {
      float4 color = float4(0, 0, 0, 1);
      float treshhold = 0.3f;
  
      float4 temp = txBlank.Sample(samLinear, input.Tex) * input.Col;
      if(RGB2RelativeLuminance(temp) &gt; treshhold)
          color = temp;
  
      return color;
  }
  
  //Basic
  Texture2DMS&lt;float4&gt; txImage : register( t0 );
  SamplerState samLinear : register( s0 );
  
  float4 PS(Pin input) : SV_TARGET
  {
      return txImage.Load(input.Pos, 1) * input.Col;
  }
  </code></pre>
  <h2>Rasterizer:</h2>
  <pre><code>rasterDesc.AntialiasedLineEnable = true;
  rasterDesc.CullMode = D3D11_CULL_BACK;
  rasterDesc.DepthBias = 0;
  rasterDesc.DepthBiasClamp = 0.0f;
  rasterDesc.DepthClipEnable = true;
  rasterDesc.FillMode = D3D11_FILL_SOLID;
  rasterDesc.FrontCounterClockwise = false;
  rasterDesc.MultisampleEnable = true;
  rasterDesc.ScissorEnable = false;
  rasterDesc.SlopeScaledDepthBias = 0.0f;
  </code></pre>
  <p>And right now, my Program goes like:</p>
  <ol>
  <li>(Init)Initialize D3D Device, Swapchain, Context, Rasterizer, Render Target, Depth Stencil, Viewport</li>
  <li>(Init)Create Render Target(Texture), I'll refer to this as 'ViewTex'</li>
  <li>(Draw)Set ViewTex as Render Target</li>
  <li>(Draw)Set a Blank Texture to Slot 0</li>
  <li>(Draw)Set 'High pass filter' as the Shader</li>
  <li>(Draw)Draw the Object</li>
  <li>(Draw)Set Render Target to Window</li>
  <li>(Draw)Set ViewTex to Slot 0 Texture</li>
  <li>(Draw)Set 'Basic' as the Shader</li>
  <li>(Draw)Draw a Rectangle that covers the whole Render Target</li>
  <li>(Draw)Unset Slot 0 Texture</li>
  </ol>
  <p>Currently, this code doesn't work, and I'm not really sure why, Here's a Close-up of a screenshot of the render:
  <a href="https://i.stack.imgur.com/jHupG.png" rel="nofollow noreferrer">link</a></p>
  <p>Am I misunderstanding something? Is setting up Multisample not equal to MSAA?</p>