MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Blast / BackBufferResized

Method BackBufferResized

samples/SampleBase/renderer/Renderer.cpp:270–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void Renderer::BackBufferResized(ID3D11Device* /*device*/, const DXGI_SURFACE_DESC* sd)
271{
272 // Setup the camera's projection parameters
273 m_screenWidth = sd->Width;
274 m_screenHeight = sd->Height;
275 float fAspectRatio = m_screenWidth / m_screenHeight;
276 m_camera.SetProjParams(DirectX::XM_PIDIV4, fAspectRatio, CAMERA_CLIP_NEAR, CAMERA_CLIP_FAR);
277
278 SAFE_RELEASE(m_DSTexture);
279 SAFE_RELEASE(m_DSView);
280 SAFE_RELEASE(m_DSTextureSRV);
281
282 // create a new Depth-Stencil texture
283 {
284 D3D11_TEXTURE2D_DESC desc;
285 ZeroMemory(&desc, sizeof(desc));
286 desc.Width = sd->Width;
287 desc.Height = sd->Height;
288 desc.MipLevels = 1;
289 desc.ArraySize = 1;
290 desc.Format = DXGI_FORMAT_R32_TYPELESS; // Use a typeless type here so that it can be both depth-stencil and shader resource.
291 desc.SampleDesc.Count = sd->SampleDesc.Count;
292 desc.SampleDesc.Quality = sd->SampleDesc.Quality;
293 desc.Usage = D3D11_USAGE_DEFAULT;
294 desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
295 desc.CPUAccessFlags = 0;
296 desc.MiscFlags = 0;
297 V(m_device->CreateTexture2D(&desc, NULL, &m_DSTexture));
298 }
299
300 // create Depth-Stencil view
301 {
302 D3D11_DEPTH_STENCIL_VIEW_DESC desc;
303 ZeroMemory(&desc, sizeof(desc));
304 desc.ViewDimension = sd->SampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS : D3D11_DSV_DIMENSION_TEXTURE2D;
305 desc.Format = DXGI_FORMAT_D32_FLOAT; // Make the view see this as D32_FLOAT instead of typeless
306 desc.Texture2D.MipSlice = 0;
307 V(m_device->CreateDepthStencilView(m_DSTexture, &desc, &m_DSView));
308 }
309
310 // create Depth-Stencil shader resource view
311 {
312 D3D11_SHADER_RESOURCE_VIEW_DESC desc;
313 ZeroMemory(&desc, sizeof(desc));
314 desc.Format = DXGI_FORMAT_R32_FLOAT; // Make the shaders see this as R32_FLOAT instead of typeless
315 desc.ViewDimension = sd->SampleDesc.Count > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D;
316 desc.Texture2D.MipLevels = 1;
317 desc.Texture2D.MostDetailedMip = 0;
318 V(m_device->CreateShaderResourceView(m_DSTexture, &desc, &m_DSTextureSRV));
319 }
320
321 // setup viewport
322 m_viewport.Width = (FLOAT)sd->Width;
323 m_viewport.Height = (FLOAT)sd->Height;
324 m_viewport.MinDepth = 0;
325 m_viewport.MaxDepth = 1;
326 m_viewport.TopLeftX = 0;
327 m_viewport.TopLeftY = 0;

Callers

nothing calls this directly

Calls 1

setScreenResolutionMethod · 0.80

Tested by

no test coverage detected