mirror of
https://github.com/Patoke/4JLibs.git
synced 2026-07-18 12:18:06 +00:00
fix: revert matching code for the creation of the depthStencil and renderTargetViews
This commit is contained in:
@@ -418,35 +418,59 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)
|
||||
const float clearColour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
SetClearColour(clearColour);
|
||||
|
||||
m_pDeviceContext->OMGetRenderTargets(1, &this->renderTargetView, &this->depthStencilView);
|
||||
UINT backBufferSampleCount = 1;
|
||||
UINT backBufferSampleQuality = 0;
|
||||
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
|
||||
rtvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
ID3D11Texture2D *backBuffer = NULL;
|
||||
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
|
||||
if (backBuffer)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC backDesc = {};
|
||||
backBuffer->GetDesc(&backDesc);
|
||||
backBufferWidth = backDesc.Width;
|
||||
backBufferHeight = backDesc.Height;
|
||||
backBufferSampleCount = backDesc.SampleDesc.Count;
|
||||
backBufferSampleQuality = backDesc.SampleDesc.Quality;
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = 1;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
m_pDevice->CreateRenderTargetView(backBuffer, NULL, &renderTargetView);
|
||||
|
||||
ID3D11Resource *pBackBufferResource = nullptr;
|
||||
this->renderTargetView->GetResource(&pBackBufferResource);
|
||||
D3D11_TEXTURE2D_DESC srvDesc = backDesc;
|
||||
srvDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
|
||||
srvDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Texture2D *pBackBufferTexture = nullptr;
|
||||
pBackBufferResource->QueryInterface(__uuidof(ID3D11Texture2D), (void **)&pBackBufferTexture);
|
||||
ID3D11Texture2D *srvTexture = NULL;
|
||||
m_pDevice->CreateTexture2D(&srvDesc, NULL, &srvTexture);
|
||||
m_pDevice->CreateShaderResourceView(srvTexture, NULL, &renderTargetShaderResourceView);
|
||||
|
||||
D3D11_TEXTURE2D_DESC texDesc;
|
||||
pBackBufferTexture->GetDesc(&texDesc);
|
||||
srvTexture->Release();
|
||||
backBuffer->Release();
|
||||
}
|
||||
|
||||
this->backBufferWidth = texDesc.Width;
|
||||
this->backBufferHeight = texDesc.Height;
|
||||
this->renderTargetTextures[0] = pBackBufferTexture;
|
||||
ID3D11RenderTargetView *boundRTV = NULL;
|
||||
m_pDeviceContext->OMGetRenderTargets(1, &boundRTV, &depthStencilView);
|
||||
if (boundRTV)
|
||||
boundRTV->Release();
|
||||
|
||||
pDevice->CreateRenderTargetView(pBackBufferTexture, &rtvDesc, &this->renderTargetView);
|
||||
pDevice->CreateShaderResourceView(pBackBufferTexture, &srvDesc, &this->renderTargetShaderResourceView);
|
||||
if (!depthStencilView && backBufferWidth != 0 && backBufferHeight != 0)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC depthDesc = {};
|
||||
depthDesc.Width = backBufferWidth;
|
||||
depthDesc.Height = backBufferHeight;
|
||||
depthDesc.MipLevels = 1;
|
||||
depthDesc.ArraySize = 1;
|
||||
depthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
depthDesc.SampleDesc.Count = backBufferSampleCount;
|
||||
depthDesc.SampleDesc.Quality = backBufferSampleQuality;
|
||||
depthDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
|
||||
pBackBufferResource->Release();
|
||||
ID3D11Texture2D *depthTexture = NULL;
|
||||
if (SUCCEEDED(m_pDevice->CreateTexture2D(&depthDesc, NULL, &depthTexture)))
|
||||
{
|
||||
m_pDevice->CreateDepthStencilView(depthTexture, NULL, &depthStencilView);
|
||||
depthTexture->Release();
|
||||
}
|
||||
}
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
desc.MipLevels = 1;
|
||||
|
||||
Reference in New Issue
Block a user