diff --git a/util/test/demos/d3d11/d3d11_binding_hazards.cpp b/util/test/demos/d3d11/d3d11_binding_hazards.cpp index 5142d23e4..069be9f25 100644 --- a/util/test/demos/d3d11/d3d11_binding_hazards.cpp +++ b/util/test/demos/d3d11/d3d11_binding_hazards.cpp @@ -78,13 +78,14 @@ void main() ctx->CSSetShader(cs, NULL, 0); - ID3D11ShaderResourceView *tempSRV = MakeSRV(buf2).Format(DXGI_FORMAT_R32_UINT).NumElements(128); + ID3D11ShaderResourceViewPtr tempSRV = + MakeSRV(buf2).Format(DXGI_FORMAT_R32_UINT).NumElements(128); - ctx->CSSetShaderResources(1, 1, &tempSRV); + ctx->CSSetShaderResources(1, 1, &tempSRV.GetInterfacePtr()); ULONG refcount = tempSRV->Release(); - ID3D11ShaderResourceView *srvs[2] = {NULL, tempSRV}; + ID3D11ShaderResourceView *srvs[2] = {NULL, tempSRV.GetInterfacePtr()}; ctx->CSSetShaderResources(1, 2, srvs); diff --git a/util/test/demos/d3d11/d3d11_helpers.cpp b/util/test/demos/d3d11/d3d11_helpers.cpp index a78649eb9..3ae1b8416 100644 --- a/util/test/demos/d3d11/d3d11_helpers.cpp +++ b/util/test/demos/d3d11/d3d11_helpers.cpp @@ -240,9 +240,9 @@ D3D11BufferCreator &D3D11BufferCreator::Size(UINT size) return *this; } -D3D11BufferCreator::operator ID3D11Buffer *() const +D3D11BufferCreator::operator ID3D11BufferPtr() const { - ID3D11Buffer *buf = NULL; + ID3D11BufferPtr buf; CHECK_HR(m_Test->dev->CreateBuffer(&m_BufDesc, m_Initdata.pSysMem ? &m_Initdata : NULL, &buf)); return buf; } @@ -314,7 +314,7 @@ D3D11TextureCreator &D3D11TextureCreator::Staging() return *this; } -D3D11TextureCreator::operator ID3D11Texture1D *() const +D3D11TextureCreator::operator ID3D11Texture1DPtr() const { D3D11_TEXTURE1D_DESC texdesc; @@ -327,12 +327,12 @@ D3D11TextureCreator::operator ID3D11Texture1D *() const texdesc.BindFlags = BindFlags; texdesc.Format = Format; - ID3D11Texture1D *tex = NULL; + ID3D11Texture1DPtr tex; CHECK_HR(m_Test->dev->CreateTexture1D(&texdesc, NULL, &tex)); return tex; } -D3D11TextureCreator::operator ID3D11Texture2D *() const +D3D11TextureCreator::operator ID3D11Texture2DPtr() const { D3D11_TEXTURE2D_DESC texdesc; @@ -348,12 +348,12 @@ D3D11TextureCreator::operator ID3D11Texture2D *() const texdesc.SampleDesc.Count = SampleDesc.Count; texdesc.SampleDesc.Quality = SampleDesc.Quality; - ID3D11Texture2D *tex = NULL; + ID3D11Texture2DPtr tex; CHECK_HR(m_Test->dev->CreateTexture2D(&texdesc, NULL, &tex)); return tex; } -D3D11TextureCreator::operator ID3D11Texture3D *() const +D3D11TextureCreator::operator ID3D11Texture3DPtr() const { D3D11_TEXTURE3D_DESC texdesc; @@ -367,7 +367,7 @@ D3D11TextureCreator::operator ID3D11Texture3D *() const texdesc.BindFlags = BindFlags; texdesc.Format = Format; - ID3D11Texture3D *tex = NULL; + ID3D11Texture3DPtr tex; CHECK_HR(m_Test->dev->CreateTexture3D(&texdesc, NULL, &tex)); return tex; } @@ -733,7 +733,7 @@ D3D11ViewCreator &D3D11ViewCreator::ReadOnlyStencil() return *this; } -D3D11ViewCreator::operator ID3D11ShaderResourceView *() +D3D11ViewCreator::operator ID3D11ShaderResourceViewPtr() { if(desc.srv.ViewDimension == D3D11_SRV_DIMENSION_BUFFER) { @@ -761,12 +761,12 @@ D3D11ViewCreator::operator ID3D11ShaderResourceView *() TEST_ASSERT(m_Res, "Must have resource"); TEST_ASSERT(m_Type == ViewType::SRV, "Casting non-SRV ViewCreator to SRV"); - ID3D11ShaderResourceView *srv = NULL; + ID3D11ShaderResourceViewPtr srv; CHECK_HR(m_Test->dev->CreateShaderResourceView(m_Res, &desc.srv, &srv)); return srv; } -D3D11ViewCreator::operator ID3D11UnorderedAccessView *() +D3D11ViewCreator::operator ID3D11UnorderedAccessViewPtr() { if(desc.uav.ViewDimension == D3D11_UAV_DIMENSION_BUFFER) { @@ -791,27 +791,27 @@ D3D11ViewCreator::operator ID3D11UnorderedAccessView *() TEST_ASSERT(m_Res, "Must have resource"); TEST_ASSERT(m_Type == ViewType::UAV, "Casting non-UAV ViewCreator to UAV"); - ID3D11UnorderedAccessView *uav = NULL; + ID3D11UnorderedAccessViewPtr uav; CHECK_HR(m_Test->dev->CreateUnorderedAccessView(m_Res, &desc.uav, &uav)); return uav; } -D3D11ViewCreator::operator ID3D11RenderTargetView *() +D3D11ViewCreator::operator ID3D11RenderTargetViewPtr() { TEST_ASSERT(m_Res, "Must have resource"); TEST_ASSERT(m_Type == ViewType::RTV, "Casting non-RTV ViewCreator to RTV"); - ID3D11RenderTargetView *rtv = NULL; + ID3D11RenderTargetViewPtr rtv; CHECK_HR(m_Test->dev->CreateRenderTargetView(m_Res, &desc.rtv, &rtv)); return rtv; } -D3D11ViewCreator::operator ID3D11DepthStencilView *() +D3D11ViewCreator::operator ID3D11DepthStencilViewPtr() { TEST_ASSERT(m_Res, "Must have resource"); TEST_ASSERT(m_Type == ViewType::DSV, "Casting non-DSV ViewCreator to DSV"); - ID3D11DepthStencilView *dsv = NULL; + ID3D11DepthStencilViewPtr dsv; CHECK_HR(m_Test->dev->CreateDepthStencilView(m_Res, &desc.dsv, &dsv)); return dsv; } diff --git a/util/test/demos/d3d11/d3d11_helpers.h b/util/test/demos/d3d11/d3d11_helpers.h index 611347903..1dce1afc6 100644 --- a/util/test/demos/d3d11/d3d11_helpers.h +++ b/util/test/demos/d3d11/d3d11_helpers.h @@ -112,8 +112,8 @@ public: return Data(data.data()).Size(UINT(data.size() * sizeof(T))); } - operator ID3D11Buffer *() const; - operator ID3D11BufferPtr() const { return ID3D11BufferPtr((ID3D11Buffer *)*this); } + operator ID3D11BufferPtr() const; + private: D3D11GraphicsTest *m_Test; @@ -139,12 +139,10 @@ public: D3D11TextureCreator &Mappable(); D3D11TextureCreator &Staging(); - operator ID3D11Texture1D *() const; - operator ID3D11Texture1DPtr() const { return ID3D11Texture1DPtr((ID3D11Texture1D *)*this); } - operator ID3D11Texture2D *() const; - operator ID3D11Texture2DPtr() const { return ID3D11Texture2DPtr((ID3D11Texture2D *)*this); } - operator ID3D11Texture3D *() const; - operator ID3D11Texture3DPtr() const { return ID3D11Texture3DPtr((ID3D11Texture3D *)*this); } + operator ID3D11Texture1DPtr() const; + operator ID3D11Texture2DPtr() const; + operator ID3D11Texture3DPtr() const; + protected: D3D11GraphicsTest *m_Test; @@ -206,27 +204,10 @@ public: D3D11ViewCreator &ReadOnlyDepth(); D3D11ViewCreator &ReadOnlyStencil(); - operator ID3D11ShaderResourceView *(); - operator ID3D11ShaderResourceViewPtr() - { - return ID3D11ShaderResourceViewPtr((ID3D11ShaderResourceView *)*this); - } - operator ID3D11RenderTargetView *(); - operator ID3D11RenderTargetViewPtr() - { - return ID3D11RenderTargetViewPtr((ID3D11RenderTargetView *)*this); - } - operator ID3D11DepthStencilView *(); - operator ID3D11DepthStencilViewPtr() - { - return ID3D11DepthStencilViewPtr((ID3D11DepthStencilView *)*this); - } - - operator ID3D11UnorderedAccessView *(); - operator ID3D11UnorderedAccessViewPtr() - { - return ID3D11UnorderedAccessViewPtr((ID3D11UnorderedAccessView *)*this); - } + operator ID3D11ShaderResourceViewPtr(); + operator ID3D11RenderTargetViewPtr(); + operator ID3D11DepthStencilViewPtr(); + operator ID3D11UnorderedAccessViewPtr(); private: void SetupDescriptors(ViewType viewType, ResourceType resType); diff --git a/util/test/demos/d3d11/d3d11_test.cpp b/util/test/demos/d3d11/d3d11_test.cpp index d6651d24f..19761889c 100644 --- a/util/test/demos/d3d11/d3d11_test.cpp +++ b/util/test/demos/d3d11/d3d11_test.cpp @@ -235,6 +235,21 @@ void D3D11GraphicsTest::PostDeviceCreate() D3D11GraphicsTest::~D3D11GraphicsTest() { delete mainWindow; + + swap = NULL; + defaultLayout = NULL; + + bbTex = NULL; + bbRTV = NULL; + + annot = NULL; + ctx2 = NULL; + ctx1 = NULL; + ctx = NULL; + + dev1 = NULL; + dev2 = NULL; + dev = NULL; } bool D3D11GraphicsTest::Running() diff --git a/util/test/demos/d3d12/d3d12_helpers.cpp b/util/test/demos/d3d12/d3d12_helpers.cpp index 64d21cda0..3724c5c18 100644 --- a/util/test/demos/d3d12/d3d12_helpers.cpp +++ b/util/test/demos/d3d12/d3d12_helpers.cpp @@ -249,9 +249,9 @@ D3D12BufferCreator &D3D12BufferCreator::Size(UINT size) return *this; } -D3D12BufferCreator::operator ID3D12Resource *() const +D3D12BufferCreator::operator ID3D12ResourcePtr() const { - ID3D12Resource *buf = NULL; + ID3D12ResourcePtr buf; CHECK_HR(m_Test->dev->CreateCommittedResource(&m_HeapDesc, D3D12_HEAP_FLAG_NONE, &m_BufDesc, D3D12_RESOURCE_STATE_COMMON, NULL, __uuidof(ID3D12Resource), (void **)&buf)); @@ -347,9 +347,9 @@ D3D12TextureCreator &D3D12TextureCreator::InitialState(D3D12_RESOURCE_STATES sta return *this; } -D3D12TextureCreator::operator ID3D12Resource *() const +D3D12TextureCreator::operator ID3D12ResourcePtr() const { - ID3D12Resource *tex = NULL; + ID3D12ResourcePtr tex; CHECK_HR(m_Test->dev->CreateCommittedResource(&m_HeapDesc, D3D12_HEAP_FLAG_NONE, &m_TexDesc, m_InitialState, NULL, __uuidof(ID3D12Resource), (void **)&tex)); @@ -894,20 +894,18 @@ D3D12PSOCreator &D3D12PSOCreator::DSV(DXGI_FORMAT fmt) return *this; } -D3D12PSOCreator::operator ID3D12PipelineState *() const +D3D12PSOCreator::operator ID3D12PipelineStatePtr() const { + ID3D12PipelineStatePtr pso; if(ComputeDesc.CS.BytecodeLength > 0) { - ID3D12PipelineState *pso = NULL; CHECK_HR(m_Test->dev->CreateComputePipelineState(&ComputeDesc, __uuidof(ID3D12PipelineState), (void **)&pso)); - return pso; } else { - ID3D12PipelineState *pso = NULL; CHECK_HR(m_Test->dev->CreateGraphicsPipelineState(&GraphicsDesc, __uuidof(ID3D12PipelineState), (void **)&pso)); - return pso; } + return pso; } \ No newline at end of file diff --git a/util/test/demos/d3d12/d3d12_helpers.h b/util/test/demos/d3d12/d3d12_helpers.h index fb8c2d318..22d03d73b 100644 --- a/util/test/demos/d3d12/d3d12_helpers.h +++ b/util/test/demos/d3d12/d3d12_helpers.h @@ -82,11 +82,7 @@ public: D3D12PSOCreator &RTVs(const std::vector &fmts); D3D12PSOCreator &DSV(DXGI_FORMAT fmt); - operator ID3D12PipelineState *() const; - operator ID3D12PipelineStatePtr() const - { - return ID3D12PipelineStatePtr((ID3D12PipelineState *)*this); - } + operator ID3D12PipelineStatePtr() const; D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDesc = {}; D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDesc = {}; @@ -120,8 +116,8 @@ public: return Data(data.data()).Size(UINT(data.size() * sizeof(T))); } - operator ID3D12Resource *() const; - operator ID3D12ResourcePtr() const { return ID3D12ResourcePtr((ID3D12Resource *)*this); } + operator ID3D12ResourcePtr() const; + private: D3D12GraphicsTest *m_Test; @@ -149,8 +145,8 @@ public: D3D12TextureCreator &InitialState(D3D12_RESOURCE_STATES state); - operator ID3D12Resource *() const; - operator ID3D12ResourcePtr() const { return ID3D12ResourcePtr((ID3D12Resource *)*this); } + operator ID3D12ResourcePtr() const; + protected: D3D12GraphicsTest *m_Test; diff --git a/util/test/demos/d3d12/d3d12_test.cpp b/util/test/demos/d3d12/d3d12_test.cpp index e87867487..2329b5a65 100644 --- a/util/test/demos/d3d12/d3d12_test.cpp +++ b/util/test/demos/d3d12/d3d12_test.cpp @@ -329,6 +329,8 @@ D3D12GraphicsTest::~D3D12GraphicsTest() GPUSync(); + infoqueue = NULL; + pendingCommandBuffers.clear(); freeCommandBuffers.clear(); @@ -338,16 +340,19 @@ D3D12GraphicsTest::~D3D12GraphicsTest() m_RTV = m_DSV = m_CBVUAVSRV = m_Sampler = NULL; m_Alloc = NULL; - - queue = NULL; + m_DebugList = NULL; m_GPUSyncFence = NULL; CloseHandle(m_GPUSyncHandle); - dev = NULL; + bbTex[0] = bbTex[1] = NULL; + swap = NULL; m_Factory = NULL; delete mainWindow; + + queue = NULL; + dev = NULL; } bool D3D12GraphicsTest::Running()