Skip to content

Commit

Permalink
Remove unneeded cubemap SRV's
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiyansKing committed Oct 1, 2021
1 parent 586984d commit fe3caeb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 78 deletions.
48 changes: 0 additions & 48 deletions D3D11Engine/D3D11PointLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,54 +268,6 @@ void D3D11PointLight::OnRenderLight() {
DepthCubemap->BindToPixelShader( ((D3D11GraphicsEngineBase*)Engine::GraphicsEngine)->GetContext().Get(), 3 );
}

/** Debug-draws the cubemap to the screen */
void D3D11PointLight::DebugDrawCubeMap() {
if ( !InitDone )
return;

D3D11GraphicsEngineBase* engineBase = (D3D11GraphicsEngineBase*)Engine::GraphicsEngine;
D3D11GraphicsEngine* engine = (D3D11GraphicsEngine*)engineBase; // TODO: Remove and use newer system!

const int previewSize = POINTLIGHT_SHADOWMAP_SIZE;
const int previewDownscale = 4;

for ( int i = 0; i < 6; i++ ) {
INT2 pPosition;
int stride = (previewSize / previewDownscale);
if ( i == 1 ) // x-
{
pPosition.x = 0;
pPosition.y = stride;
} else if ( i == 3 ) // y-
{
pPosition.x = stride;
pPosition.y = stride;
} else if ( i == 0 ) // x+
{
pPosition.x = stride * 2;
pPosition.y = stride;
} else if ( i == 2 ) // y+
{
pPosition.x = stride * 3;
pPosition.y = stride;
} else if ( i == 5 ) // z-
{
pPosition.x = stride;
pPosition.y = 0;
} else if ( i == 4 ) // z+
{
pPosition.x = stride;
pPosition.y = stride * 2;
}

INT2 pSize = INT2( previewSize / previewDownscale, previewSize / previewDownscale );

Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv = engine->GetDummyCubeRT()->GetSRVCubemapFace( i ).Get();
engine->GetContext()->PSSetShaderResources( 0, 1, srv.GetAddressOf() );
Engine::GraphicsEngine->DrawQuad( pPosition, pSize );
}
}

/** Called when a vob got removed from the world */
void D3D11PointLight::OnVobRemovedFromWorld( BaseVobInfo* vob ) {
// Wait for cache initialization to finish first
Expand Down
3 changes: 0 additions & 3 deletions D3D11Engine/D3D11PointLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class D3D11PointLight : public BaseShadowedPointLight {
/** Binds the shadowmap to the pixelshader */
void OnRenderLight();

/** Debug-draws the cubemap to the screen */
void DebugDrawCubeMap();

/** Returns if this light needs an update */
bool NeedsUpdate();

Expand Down
27 changes: 0 additions & 27 deletions D3D11Engine/RenderToTextureBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct RenderToTextureBuffer {
HRESULT hr = S_OK;

ZeroMemory( CubeMapRTVs, sizeof( CubeMapRTVs ) );
ZeroMemory( CubeMapSRVs, sizeof( CubeMapSRVs ) );

if ( SizeX == 0 || SizeY == 0 ) {
LogError() << L"SizeX or SizeY can't be 0";
Expand Down Expand Up @@ -84,16 +83,6 @@ struct RenderToTextureBuffer {
DescRV.Texture2D.MostDetailedMip = 0;
LE( device->CreateShaderResourceView( Texture.Get(), &DescRV, ShaderResView.GetAddressOf() ) );

if ( arraySize > 1 ) {
// Create the one-face render target views
DescRV.Texture2DArray.ArraySize = 1;
DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
for ( int i = 0; i < 6; ++i ) {
DescRV.Texture2DArray.FirstArraySlice = i;
LE( device->CreateShaderResourceView( Texture.Get(), &DescRV, CubeMapSRVs[i].GetAddressOf() ) );
}
}

if ( FAILED( hr ) ) {
LogError() << L"Coould not create ID3D11Texture2D, ID3D11ShaderResourceView, or ID3D11RenderTargetView. Killing created resources (If any).";
ReleaseAll();
Expand All @@ -119,7 +108,6 @@ struct RenderToTextureBuffer {
//void SetRenderTargetView( Microsoft::WRL::ComPtr<ID3D11RenderTargetView> rtv ) { RenderTargetView = rtv.Get(); }

Microsoft::WRL::ComPtr<ID3D11RenderTargetView>& GetRTVCubemapFace( UINT i ) { return CubeMapRTVs[i]; }
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>& GetSRVCubemapFace( UINT i ) { return CubeMapSRVs[i]; }

UINT GetSizeX() { return SizeX; }
UINT GetSizeY() { return SizeY; }
Expand All @@ -134,7 +122,6 @@ struct RenderToTextureBuffer {

// Rendertargets for the cubemap-faces, if this is a cubemap
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> CubeMapRTVs[6];
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> CubeMapSRVs[6];

UINT SizeX;
UINT SizeY;
Expand All @@ -160,8 +147,6 @@ struct RenderToDepthStencilBuffer {
return;
}



if ( SizeX == 0 || SizeY == 0 ) {
LogError() << L"SizeX or SizeY can't be 0";
}
Expand Down Expand Up @@ -232,16 +217,6 @@ struct RenderToDepthStencilBuffer {
DescRV.Texture2D.MostDetailedMip = 0;
LE( device->CreateShaderResourceView( Texture.Get(), &DescRV, ShaderResView.GetAddressOf() ) );

if ( arraySize > 1 ) {
// Create the one-face render target views
DescRV.Texture2DArray.ArraySize = 1;
DescRV.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
for ( int i = 0; i < 6; ++i ) {
DescRV.Texture2DArray.FirstArraySlice = i;
LE( device->CreateShaderResourceView( Texture.Get(), &DescRV, CubeMapSRVs[i].GetAddressOf() ) );
}
}

if ( FAILED( hr ) ) {
LogError() << L"Could not create ID3D11Texture2D, ID3D11ShaderResourceView, or ID3D11DepthStencilView. Killing created resources (If any).";
if ( Result )*Result = hr;
Expand All @@ -268,7 +243,6 @@ struct RenderToDepthStencilBuffer {
UINT GetSizeY() const { return SizeY; }

Microsoft::WRL::ComPtr<ID3D11DepthStencilView> GetDSVCubemapFace( UINT i ) { return CubeMapDSVs[i].Get(); }
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> GetSRVCubemapFace( UINT i ) { return CubeMapSRVs[i].Get(); }

//void SetTexture( Microsoft::WRL::ComPtr<ID3D11Texture2D> tx ) { Texture = tx.Get(); }
//void SetShaderResView( Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv ) { ShaderResView = srv.Get(); }
Expand All @@ -288,5 +262,4 @@ struct RenderToDepthStencilBuffer {

// Rendertargets for the cubemap-faces, if this is a cubemap
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> CubeMapDSVs[6];
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> CubeMapSRVs[6];
};

0 comments on commit fe3caeb

Please sign in to comment.