|
|
@@ -183,10 +183,8 @@ Graphics::Graphics(Context* context) :
|
|
|
vsync_(false),
|
|
|
tripleBuffer_(false),
|
|
|
deviceLost_(false),
|
|
|
- systemDepthStencil_(false),
|
|
|
lightPrepassSupport_(false),
|
|
|
deferredSupport_(false),
|
|
|
- hardwareDepthSupport_(false),
|
|
|
hardwareShadowSupport_(false),
|
|
|
streamOffsetSupport_(false),
|
|
|
hasSM3_(false),
|
|
|
@@ -225,8 +223,7 @@ Graphics::~Graphics()
|
|
|
}
|
|
|
if (impl_->defaultDepthStencilSurface_)
|
|
|
{
|
|
|
- if (systemDepthStencil_)
|
|
|
- impl_->defaultDepthStencilSurface_->Release();
|
|
|
+ impl_->defaultDepthStencilSurface_->Release();
|
|
|
impl_->defaultDepthStencilSurface_ = 0;
|
|
|
}
|
|
|
if (impl_->device_)
|
|
|
@@ -361,9 +358,6 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool vsync, bool
|
|
|
impl_->presentParams_.Windowed = true;
|
|
|
}
|
|
|
|
|
|
- // Use AutoDepthStencil normally. However, if INTZ depth is available, create a depth texture instead
|
|
|
- bool autoDepthStencil = multiSample > 1 || !hardwareDepthSupport_;
|
|
|
-
|
|
|
impl_->presentParams_.BackBufferWidth = width;
|
|
|
impl_->presentParams_.BackBufferHeight = height;
|
|
|
impl_->presentParams_.BackBufferCount = tripleBuffer ? 2 : 1;
|
|
|
@@ -371,7 +365,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool vsync, bool
|
|
|
impl_->presentParams_.MultiSampleQuality = 0;
|
|
|
impl_->presentParams_.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
impl_->presentParams_.hDeviceWindow = WIN_GetWindowHandle(impl_->window_);
|
|
|
- impl_->presentParams_.EnableAutoDepthStencil = autoDepthStencil ? TRUE : FALSE;
|
|
|
+ impl_->presentParams_.EnableAutoDepthStencil = TRUE;
|
|
|
impl_->presentParams_.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
impl_->presentParams_.Flags = 0;
|
|
|
impl_->presentParams_.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
|
|
@@ -451,8 +445,6 @@ void Graphics::Close()
|
|
|
{
|
|
|
MutexLock lock(GetStaticMutex());
|
|
|
|
|
|
- depthTexture_.Reset();
|
|
|
-
|
|
|
SDL_ShowCursor(SDL_TRUE);
|
|
|
SDL_DestroyWindow(impl_->window_);
|
|
|
impl_->window_ = 0;
|
|
|
@@ -1796,11 +1788,6 @@ RenderSurface* Graphics::GetRenderTarget(unsigned index) const
|
|
|
return index < MAX_RENDERTARGETS ? renderTargets_[index] : 0;
|
|
|
}
|
|
|
|
|
|
-Texture2D* Graphics::GetDepthTexture() const
|
|
|
-{
|
|
|
- return depthTexture_;
|
|
|
-}
|
|
|
-
|
|
|
unsigned Graphics::GetStreamFrequency(unsigned index) const
|
|
|
{
|
|
|
return index < MAX_VERTEX_STREAMS ? streamFrequencies_[index] : 0;
|
|
|
@@ -2184,32 +2171,13 @@ void Graphics::CheckFeatureSupport()
|
|
|
hasSM3_ = true;
|
|
|
}
|
|
|
|
|
|
- // Check for readable hardware depth-stencil format (INTZ), light pre-pass and deferred rendering support
|
|
|
- if (impl_->CheckFormatSupport((D3DFORMAT)MAKEFOURCC('I', 'N', 'T', 'Z'), D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE))
|
|
|
- {
|
|
|
- // Sampling INTZ buffer directly while also using it for depth test results in performance loss on ATI GPUs,
|
|
|
- // so use INTZ buffer only with other vendors
|
|
|
- if (impl_->adapterIdentifier_.VendorId != 0x1002)
|
|
|
- {
|
|
|
- hardwareDepthSupport_ = false;
|
|
|
- lightPrepassSupport_ = true;
|
|
|
- depthStencilFormat = MAKEFOURCC('I', 'N', 'T', 'Z');
|
|
|
- if (impl_->deviceCaps_.NumSimultaneousRTs >= 3)
|
|
|
- deferredSupport_ = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!hardwareDepthSupport_)
|
|
|
+ // Check for light prepass and deferred rendering support
|
|
|
+ if (impl_->deviceCaps_.NumSimultaneousRTs >= 2 && impl_->CheckFormatSupport(D3DFMT_R32F, D3DUSAGE_RENDERTARGET,
|
|
|
+ D3DRTYPE_TEXTURE))
|
|
|
{
|
|
|
- // If hardware depth is not supported, must support 2 rendertargets and R32F format for light pre-pass,
|
|
|
- // and 4 for deferred rendering
|
|
|
- if (impl_->deviceCaps_.NumSimultaneousRTs >= 2 && impl_->CheckFormatSupport(D3DFMT_R32F, D3DUSAGE_RENDERTARGET,
|
|
|
- D3DRTYPE_TEXTURE))
|
|
|
- {
|
|
|
- lightPrepassSupport_ = true;
|
|
|
- if (impl_->deviceCaps_.NumSimultaneousRTs >= 4)
|
|
|
- deferredSupport_ = true;
|
|
|
- }
|
|
|
+ lightPrepassSupport_ = true;
|
|
|
+ if (impl_->deviceCaps_.NumSimultaneousRTs >= 4)
|
|
|
+ deferredSupport_ = true;
|
|
|
}
|
|
|
|
|
|
// Check for stream offset (needed for instancing)
|
|
|
@@ -2241,8 +2209,7 @@ void Graphics::OnDeviceLost()
|
|
|
}
|
|
|
if (impl_->defaultDepthStencilSurface_)
|
|
|
{
|
|
|
- if (systemDepthStencil_)
|
|
|
- impl_->defaultDepthStencilSurface_->Release();
|
|
|
+ impl_->defaultDepthStencilSurface_->Release();
|
|
|
impl_->defaultDepthStencilSurface_ = 0;
|
|
|
}
|
|
|
|
|
|
@@ -2257,24 +2224,7 @@ void Graphics::OnDeviceReset()
|
|
|
|
|
|
// Get default surfaces
|
|
|
impl_->device_->GetRenderTarget(0, &impl_->defaultColorSurface_);
|
|
|
- if (impl_->presentParams_.EnableAutoDepthStencil)
|
|
|
- {
|
|
|
- impl_->device_->GetDepthStencilSurface(&impl_->defaultDepthStencilSurface_);
|
|
|
- systemDepthStencil_ = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!depthTexture_)
|
|
|
- depthTexture_ = new Texture2D(context_);
|
|
|
-
|
|
|
- depthTexture_->SetSize(width_, height_, (D3DFORMAT)MAKEFOURCC('I', 'N', 'T', 'Z'), TEXTURE_DEPTHSTENCIL);
|
|
|
-
|
|
|
- impl_->defaultDepthStencilSurface_ = (IDirect3DSurface9*)depthTexture_->GetRenderSurface()->GetSurface();
|
|
|
- systemDepthStencil_ = false;
|
|
|
-
|
|
|
- // When AutoDepthStencil is not used, depth buffering must be enabled manually
|
|
|
- impl_->device_->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
|
|
- }
|
|
|
+ impl_->device_->GetDepthStencilSurface(&impl_->defaultDepthStencilSurface_);
|
|
|
|
|
|
ResetCachedState();
|
|
|
}
|