mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-29 10:24:10 +01:00
[d3d11] Make D3D11 context methods more robust to null pointers
Assetto Corsa tries to do some questionable things when reflections are disabled in the game options. Refs #648.
This commit is contained in:
parent
c1190e81b2
commit
35238ec4d1
@ -63,10 +63,13 @@ namespace dxvk {
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::DiscardResource(ID3D11Resource* pResource) {
|
||||
if (!pResource)
|
||||
return;
|
||||
|
||||
// We don't support the Discard API for images
|
||||
D3D11_RESOURCE_DIMENSION resType = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
pResource->GetType(&resType);
|
||||
|
||||
// We don't support the Discard API for images
|
||||
if (resType == D3D11_RESOURCE_DIMENSION_BUFFER)
|
||||
DiscardBuffer(static_cast<D3D11Buffer*>(pResource));
|
||||
}
|
||||
@ -197,7 +200,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::Begin(ID3D11Asynchronous *pAsync) {
|
||||
if (pAsync == nullptr)
|
||||
if (!pAsync)
|
||||
return;
|
||||
|
||||
Com<ID3D11Query> query;
|
||||
@ -217,7 +220,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::End(ID3D11Asynchronous *pAsync) {
|
||||
if (pAsync == nullptr)
|
||||
if (!pAsync)
|
||||
return;
|
||||
|
||||
Com<ID3D11Query> query;
|
||||
@ -508,6 +511,9 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::CopyResource(
|
||||
ID3D11Resource* pDstResource,
|
||||
ID3D11Resource* pSrcResource) {
|
||||
if (!pDstResource || !pSrcResource)
|
||||
return;
|
||||
|
||||
D3D11_RESOURCE_DIMENSION dstResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
D3D11_RESOURCE_DIMENSION srcResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
|
||||
@ -606,6 +612,9 @@ namespace dxvk {
|
||||
auto buf = static_cast<D3D11Buffer*>(pDstBuffer);
|
||||
auto uav = static_cast<D3D11UnorderedAccessView*>(pSrcView);
|
||||
|
||||
if (!buf || !uav)
|
||||
return;
|
||||
|
||||
EmitCs([
|
||||
cDstSlice = buf->GetBufferSlice(DstAlignedByteOffset),
|
||||
cSrcSlice = uav->GetCounterSlice()
|
||||
@ -625,7 +634,7 @@ namespace dxvk {
|
||||
const FLOAT ColorRGBA[4]) {
|
||||
auto rtv = static_cast<D3D11RenderTargetView*>(pRenderTargetView);
|
||||
|
||||
if (rtv == nullptr)
|
||||
if (!rtv)
|
||||
return;
|
||||
|
||||
const Rc<DxvkImageView> view = rtv->GetImageView();
|
||||
@ -653,7 +662,7 @@ namespace dxvk {
|
||||
const UINT Values[4]) {
|
||||
auto uav = static_cast<D3D11UnorderedAccessView*>(pUnorderedAccessView);
|
||||
|
||||
if (uav == nullptr)
|
||||
if (!uav)
|
||||
return;
|
||||
|
||||
// Gather UAV format info. We'll use this to determine
|
||||
@ -746,7 +755,7 @@ namespace dxvk {
|
||||
const FLOAT Values[4]) {
|
||||
auto uav = static_cast<D3D11UnorderedAccessView*>(pUnorderedAccessView);
|
||||
|
||||
if (uav == nullptr)
|
||||
if (!uav)
|
||||
return;
|
||||
|
||||
VkClearValue clearValue;
|
||||
@ -786,7 +795,7 @@ namespace dxvk {
|
||||
UINT8 Stencil) {
|
||||
auto dsv = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
||||
|
||||
if (dsv == nullptr)
|
||||
if (!dsv)
|
||||
return;
|
||||
|
||||
// Figure out which aspects to clear based
|
||||
@ -966,8 +975,8 @@ namespace dxvk {
|
||||
|
||||
void STDMETHODCALLTYPE D3D11DeviceContext::GenerateMips(ID3D11ShaderResourceView* pShaderResourceView) {
|
||||
auto view = static_cast<D3D11ShaderResourceView*>(pShaderResourceView);
|
||||
|
||||
if (view->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER)
|
||||
|
||||
if (!view || view->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER)
|
||||
return;
|
||||
|
||||
EmitCs([cDstImageView = view->GetImageView()]
|
||||
@ -998,6 +1007,9 @@ namespace dxvk {
|
||||
UINT SrcRowPitch,
|
||||
UINT SrcDepthPitch,
|
||||
UINT CopyFlags) {
|
||||
if (!pDstResource)
|
||||
return;
|
||||
|
||||
// We need a different code path for buffers
|
||||
D3D11_RESOURCE_DIMENSION resourceType;
|
||||
pDstResource->GetType(&resourceType);
|
||||
@ -1134,6 +1146,9 @@ namespace dxvk {
|
||||
ID3D11Resource* pSrcResource,
|
||||
UINT SrcSubresource,
|
||||
DXGI_FORMAT Format) {
|
||||
if (!pDstResource || !pSrcResource)
|
||||
return;
|
||||
|
||||
D3D11_RESOURCE_DIMENSION dstResourceType;
|
||||
D3D11_RESOURCE_DIMENSION srcResourceType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user