| 2479 | } |
| 2480 | |
| 2481 | Texture* DXRenderDevice::CreateRenderTarget(int width, int height, bool destAlpha) |
| 2482 | { |
| 2483 | ID3D11ShaderResourceView* d3DShaderResourceView = NULL; |
| 2484 | |
| 2485 | int aWidth = 0; |
| 2486 | int aHeight = 0; |
| 2487 | |
| 2488 | int sampleQuality = 0; |
| 2489 | |
| 2490 | // Create the render target texture |
| 2491 | D3D11_TEXTURE2D_DESC desc; |
| 2492 | ZeroMemory(&desc, sizeof(desc)); |
| 2493 | desc.Width = width; |
| 2494 | desc.Height = height; |
| 2495 | desc.MipLevels = 1; |
| 2496 | desc.ArraySize = 1; |
| 2497 | desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; |
| 2498 | desc.SampleDesc.Count = 1; |
| 2499 | UINT qualityLevels = 0; |
| 2500 | |
| 2501 | int samples = 1; |
| 2502 | //DXCHECK(mD3DDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, samples, &qualityLevels)); |
| 2503 | |
| 2504 | desc.SampleDesc.Count = samples; |
| 2505 | desc.SampleDesc.Quality = sampleQuality; |
| 2506 | |
| 2507 | desc.Usage = D3D11_USAGE_DEFAULT; |
| 2508 | desc.CPUAccessFlags = 0; //D3D11_CPU_ACCESS_WRITE; |
| 2509 | desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; |
| 2510 | |
| 2511 | ID3D11Texture2D* d3DTexture = NULL; |
| 2512 | DXCHECK(mD3DDevice->CreateTexture2D(&desc, NULL, &d3DTexture)); |
| 2513 | |
| 2514 | aWidth = width; |
| 2515 | aHeight = height; |
| 2516 | |
| 2517 | D3D11_SHADER_RESOURCE_VIEW_DESC srDesc; |
| 2518 | srDesc.Format = desc.Format; |
| 2519 | srDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; |
| 2520 | srDesc.Texture2D.MostDetailedMip = 0; |
| 2521 | srDesc.Texture2D.MipLevels = 1; |
| 2522 | |
| 2523 | if (qualityLevels != 0) |
| 2524 | { |
| 2525 | srDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS; |
| 2526 | } |
| 2527 | |
| 2528 | DXCHECK(mD3DDevice->CreateShaderResourceView(d3DTexture, &srDesc, &d3DShaderResourceView)); |
| 2529 | |
| 2530 | ID3D11RenderTargetView* d3DRenderTargetView; |
| 2531 | DXCHECK(mD3DDevice->CreateRenderTargetView(d3DTexture, NULL, &d3DRenderTargetView)); |
| 2532 | |
| 2533 | DXTexture* aRenderTarget = new DXTexture(); |
| 2534 | aRenderTarget->mWidth = width; |
| 2535 | aRenderTarget->mHeight = height; |
| 2536 | aRenderTarget->mRenderDevice = this; |
| 2537 | aRenderTarget->mD3DTexture = d3DTexture; |
| 2538 | aRenderTarget->mD3DResourceView = d3DShaderResourceView; |
no test coverage detected