fixed graphicsdevice memory leak #67
This commit is contained in:
@@ -54,7 +54,7 @@ void MainComponent::Initialize()
|
||||
{
|
||||
#ifdef WICKEDENGINE_BUILD_VULKAN
|
||||
wiRenderer::SetShaderPath(wiRenderer::GetShaderPath() + "spirv/");
|
||||
wiRenderer::SetDevice(new GraphicsDevice_Vulkan(window, fullscreen, debugdevice));
|
||||
wiRenderer::SetDevice(std::make_shared<GraphicsDevice_Vulkan>(window, fullscreen, debugdevice));
|
||||
#else
|
||||
wiHelper::messageBox("Vulkan SDK not found during building the application! Vulkan API disabled!", "Error");
|
||||
#endif
|
||||
@@ -65,13 +65,13 @@ void MainComponent::Initialize()
|
||||
{
|
||||
wiRenderer::SetShaderPath(wiRenderer::GetShaderPath() + "hlsl6/");
|
||||
}
|
||||
wiRenderer::SetDevice(new GraphicsDevice_DX12(window, fullscreen, debugdevice));
|
||||
wiRenderer::SetDevice(std::make_shared<GraphicsDevice_DX12>(window, fullscreen, debugdevice));
|
||||
}
|
||||
|
||||
// default graphics device:
|
||||
if (wiRenderer::GetDevice() == nullptr)
|
||||
{
|
||||
wiRenderer::SetDevice(new GraphicsDevice_DX11(window, fullscreen, debugdevice));
|
||||
wiRenderer::SetDevice(std::make_shared<GraphicsDevice_DX11>(window, fullscreen, debugdevice));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
#include "wiGraphicsResource.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace wiGraphics
|
||||
{
|
||||
typedef uint8_t CommandList;
|
||||
static const CommandList COMMANDLIST_COUNT = 16;
|
||||
|
||||
class GraphicsDevice
|
||||
class GraphicsDevice : public std::enable_shared_from_this<GraphicsDevice>
|
||||
{
|
||||
protected:
|
||||
uint64_t FRAMECOUNT = 0;
|
||||
|
||||
@@ -1293,7 +1293,7 @@ bool GraphicsDevice_DX11::CreateBuffer(const GPUBufferDesc *pDesc, const Subreso
|
||||
DestroyBuffer(pBuffer);
|
||||
DestroyResource(pBuffer);
|
||||
pBuffer->type = GPUResource::GPU_RESOURCE_TYPE::BUFFER;
|
||||
pBuffer->Register(this);
|
||||
pBuffer->Register(shared_from_this());
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = pDesc->ByteWidth;
|
||||
@@ -1403,7 +1403,7 @@ bool GraphicsDevice_DX11::CreateTexture(const TextureDesc* pDesc, const Subresou
|
||||
DestroyTexture(pTexture);
|
||||
DestroyResource(pTexture);
|
||||
pTexture->type = GPUResource::GPU_RESOURCE_TYPE::TEXTURE;
|
||||
pTexture->Register(this);
|
||||
pTexture->Register(shared_from_this());
|
||||
|
||||
pTexture->desc = *pDesc;
|
||||
|
||||
@@ -1476,7 +1476,7 @@ bool GraphicsDevice_DX11::CreateTexture(const TextureDesc* pDesc, const Subresou
|
||||
bool GraphicsDevice_DX11::CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, uint32_t NumElements, const ShaderByteCode* shaderCode, VertexLayout *pInputLayout)
|
||||
{
|
||||
DestroyInputLayout(pInputLayout);
|
||||
pInputLayout->Register(this);
|
||||
pInputLayout->Register(shared_from_this());
|
||||
|
||||
pInputLayout->desc.reserve((size_t)NumElements);
|
||||
|
||||
@@ -1505,7 +1505,7 @@ bool GraphicsDevice_DX11::CreateInputLayout(const VertexLayoutDesc *pInputElemen
|
||||
bool GraphicsDevice_DX11::CreateVertexShader(const void *pShaderBytecode, size_t BytecodeLength, VertexShader *pVertexShader)
|
||||
{
|
||||
DestroyVertexShader(pVertexShader);
|
||||
pVertexShader->Register(this);
|
||||
pVertexShader->Register(shared_from_this());
|
||||
|
||||
pVertexShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pVertexShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1515,7 +1515,7 @@ bool GraphicsDevice_DX11::CreateVertexShader(const void *pShaderBytecode, size_t
|
||||
bool GraphicsDevice_DX11::CreatePixelShader(const void *pShaderBytecode, size_t BytecodeLength, PixelShader *pPixelShader)
|
||||
{
|
||||
DestroyPixelShader(pPixelShader);
|
||||
pPixelShader->Register(this);
|
||||
pPixelShader->Register(shared_from_this());
|
||||
|
||||
pPixelShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pPixelShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1525,7 +1525,7 @@ bool GraphicsDevice_DX11::CreatePixelShader(const void *pShaderBytecode, size_t
|
||||
bool GraphicsDevice_DX11::CreateGeometryShader(const void *pShaderBytecode, size_t BytecodeLength, GeometryShader *pGeometryShader)
|
||||
{
|
||||
DestroyGeometryShader(pGeometryShader);
|
||||
pGeometryShader->Register(this);
|
||||
pGeometryShader->Register(shared_from_this());
|
||||
|
||||
pGeometryShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pGeometryShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1535,7 +1535,7 @@ bool GraphicsDevice_DX11::CreateGeometryShader(const void *pShaderBytecode, size
|
||||
bool GraphicsDevice_DX11::CreateHullShader(const void *pShaderBytecode, size_t BytecodeLength, HullShader *pHullShader)
|
||||
{
|
||||
DestroyHullShader(pHullShader);
|
||||
pHullShader->Register(this);
|
||||
pHullShader->Register(shared_from_this());
|
||||
|
||||
pHullShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pHullShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1545,7 +1545,7 @@ bool GraphicsDevice_DX11::CreateHullShader(const void *pShaderBytecode, size_t B
|
||||
bool GraphicsDevice_DX11::CreateDomainShader(const void *pShaderBytecode, size_t BytecodeLength, DomainShader *pDomainShader)
|
||||
{
|
||||
DestroyDomainShader(pDomainShader);
|
||||
pDomainShader->Register(this);
|
||||
pDomainShader->Register(shared_from_this());
|
||||
|
||||
pDomainShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pDomainShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1555,7 +1555,7 @@ bool GraphicsDevice_DX11::CreateDomainShader(const void *pShaderBytecode, size_t
|
||||
bool GraphicsDevice_DX11::CreateComputeShader(const void *pShaderBytecode, size_t BytecodeLength, ComputeShader *pComputeShader)
|
||||
{
|
||||
DestroyComputeShader(pComputeShader);
|
||||
pComputeShader->Register(this);
|
||||
pComputeShader->Register(shared_from_this());
|
||||
|
||||
pComputeShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pComputeShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -1565,7 +1565,7 @@ bool GraphicsDevice_DX11::CreateComputeShader(const void *pShaderBytecode, size_
|
||||
bool GraphicsDevice_DX11::CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState)
|
||||
{
|
||||
DestroyBlendState(pBlendState);
|
||||
pBlendState->Register(this);
|
||||
pBlendState->Register(shared_from_this());
|
||||
|
||||
D3D11_BLEND_DESC desc;
|
||||
desc.AlphaToCoverageEnable = pBlendStateDesc->AlphaToCoverageEnable;
|
||||
@@ -1588,7 +1588,7 @@ bool GraphicsDevice_DX11::CreateBlendState(const BlendStateDesc *pBlendStateDesc
|
||||
bool GraphicsDevice_DX11::CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState)
|
||||
{
|
||||
DestroyDepthStencilState(pDepthStencilState);
|
||||
pDepthStencilState->Register(this);
|
||||
pDepthStencilState->Register(shared_from_this());
|
||||
|
||||
D3D11_DEPTH_STENCIL_DESC desc;
|
||||
desc.DepthEnable = pDepthStencilStateDesc->DepthEnable;
|
||||
@@ -1612,7 +1612,7 @@ bool GraphicsDevice_DX11::CreateDepthStencilState(const DepthStencilStateDesc *p
|
||||
bool GraphicsDevice_DX11::CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState)
|
||||
{
|
||||
DestroyRasterizerState(pRasterizerState);
|
||||
pRasterizerState->Register(this);
|
||||
pRasterizerState->Register(shared_from_this());
|
||||
|
||||
pRasterizerState->desc = *pRasterizerStateDesc;
|
||||
|
||||
@@ -1690,7 +1690,7 @@ bool GraphicsDevice_DX11::CreateRasterizerState(const RasterizerStateDesc *pRast
|
||||
bool GraphicsDevice_DX11::CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState)
|
||||
{
|
||||
DestroySamplerState(pSamplerState);
|
||||
pSamplerState->Register(this);
|
||||
pSamplerState->Register(shared_from_this());
|
||||
|
||||
D3D11_SAMPLER_DESC desc;
|
||||
desc.Filter = _ConvertFilter(pSamplerDesc->Filter);
|
||||
@@ -1713,7 +1713,7 @@ bool GraphicsDevice_DX11::CreateSamplerState(const SamplerDesc *pSamplerDesc, Sa
|
||||
bool GraphicsDevice_DX11::CreateQuery(const GPUQueryDesc *pDesc, GPUQuery *pQuery)
|
||||
{
|
||||
DestroyQuery(pQuery);
|
||||
pQuery->Register(this);
|
||||
pQuery->Register(shared_from_this());
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
@@ -1751,7 +1751,7 @@ bool GraphicsDevice_DX11::CreateQuery(const GPUQueryDesc *pDesc, GPUQuery *pQuer
|
||||
bool GraphicsDevice_DX11::CreatePipelineState(const PipelineStateDesc* pDesc, PipelineState* pso)
|
||||
{
|
||||
DestroyPipelineState(pso);
|
||||
pso->Register(this);
|
||||
pso->Register(shared_from_this());
|
||||
|
||||
pso->desc = *pDesc;
|
||||
|
||||
@@ -1760,7 +1760,7 @@ bool GraphicsDevice_DX11::CreatePipelineState(const PipelineStateDesc* pDesc, Pi
|
||||
bool GraphicsDevice_DX11::CreateRenderPass(const RenderPassDesc* pDesc, RenderPass* renderpass)
|
||||
{
|
||||
DestroyRenderPass(renderpass);
|
||||
renderpass->Register(this);
|
||||
renderpass->Register(shared_from_this());
|
||||
|
||||
renderpass->desc = *pDesc;
|
||||
|
||||
|
||||
@@ -1949,7 +1949,7 @@ namespace wiGraphics
|
||||
DestroyBuffer(pBuffer);
|
||||
DestroyResource(pBuffer);
|
||||
pBuffer->type = GPUResource::GPU_RESOURCE_TYPE::BUFFER;
|
||||
pBuffer->Register(this);
|
||||
pBuffer->Register(shared_from_this());
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
@@ -2110,7 +2110,7 @@ namespace wiGraphics
|
||||
DestroyTexture(pTexture);
|
||||
DestroyResource(pTexture);
|
||||
pTexture->type = GPUResource::GPU_RESOURCE_TYPE::TEXTURE;
|
||||
pTexture->Register(this);
|
||||
pTexture->Register(shared_from_this());
|
||||
|
||||
pTexture->desc = *pDesc;
|
||||
|
||||
@@ -2276,7 +2276,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateInputLayout(const VertexLayoutDesc* pInputElementDescs, uint32_t NumElements, const ShaderByteCode* shaderCode, VertexLayout* pInputLayout)
|
||||
{
|
||||
DestroyInputLayout(pInputLayout);
|
||||
pInputLayout->Register(this);
|
||||
pInputLayout->Register(shared_from_this());
|
||||
|
||||
pInputLayout->desc.clear();
|
||||
pInputLayout->desc.reserve((size_t)NumElements);
|
||||
@@ -2290,7 +2290,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateVertexShader(const void* pShaderBytecode, size_t BytecodeLength, VertexShader* pVertexShader)
|
||||
{
|
||||
DestroyVertexShader(pVertexShader);
|
||||
pVertexShader->Register(this);
|
||||
pVertexShader->Register(shared_from_this());
|
||||
|
||||
pVertexShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pVertexShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2301,7 +2301,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreatePixelShader(const void* pShaderBytecode, size_t BytecodeLength, PixelShader* pPixelShader)
|
||||
{
|
||||
DestroyPixelShader(pPixelShader);
|
||||
pPixelShader->Register(this);
|
||||
pPixelShader->Register(shared_from_this());
|
||||
|
||||
pPixelShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pPixelShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2312,7 +2312,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateGeometryShader(const void* pShaderBytecode, size_t BytecodeLength, GeometryShader* pGeometryShader)
|
||||
{
|
||||
DestroyGeometryShader(pGeometryShader);
|
||||
pGeometryShader->Register(this);
|
||||
pGeometryShader->Register(shared_from_this());
|
||||
|
||||
pGeometryShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pGeometryShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2323,7 +2323,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateHullShader(const void* pShaderBytecode, size_t BytecodeLength, HullShader* pHullShader)
|
||||
{
|
||||
DestroyHullShader(pHullShader);
|
||||
pHullShader->Register(this);
|
||||
pHullShader->Register(shared_from_this());
|
||||
|
||||
pHullShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pHullShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2334,7 +2334,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateDomainShader(const void* pShaderBytecode, size_t BytecodeLength, DomainShader* pDomainShader)
|
||||
{
|
||||
DestroyDomainShader(pDomainShader);
|
||||
pDomainShader->Register(this);
|
||||
pDomainShader->Register(shared_from_this());
|
||||
|
||||
pDomainShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pDomainShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2345,7 +2345,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateComputeShader(const void* pShaderBytecode, size_t BytecodeLength, ComputeShader* pComputeShader)
|
||||
{
|
||||
DestroyComputeShader(pComputeShader);
|
||||
pComputeShader->Register(this);
|
||||
pComputeShader->Register(shared_from_this());
|
||||
|
||||
pComputeShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pComputeShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2364,7 +2364,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateBlendState(const BlendStateDesc* pBlendStateDesc, BlendState* pBlendState)
|
||||
{
|
||||
DestroyBlendState(pBlendState);
|
||||
pBlendState->Register(this);
|
||||
pBlendState->Register(shared_from_this());
|
||||
|
||||
pBlendState->desc = *pBlendStateDesc;
|
||||
return S_OK;
|
||||
@@ -2372,7 +2372,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateDepthStencilState(const DepthStencilStateDesc* pDepthStencilStateDesc, DepthStencilState* pDepthStencilState)
|
||||
{
|
||||
DestroyDepthStencilState(pDepthStencilState);
|
||||
pDepthStencilState->Register(this);
|
||||
pDepthStencilState->Register(shared_from_this());
|
||||
|
||||
pDepthStencilState->desc = *pDepthStencilStateDesc;
|
||||
return S_OK;
|
||||
@@ -2380,7 +2380,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateRasterizerState(const RasterizerStateDesc* pRasterizerStateDesc, RasterizerState* pRasterizerState)
|
||||
{
|
||||
DestroyRasterizerState(pRasterizerState);
|
||||
pRasterizerState->Register(this);
|
||||
pRasterizerState->Register(shared_from_this());
|
||||
|
||||
pRasterizerState->desc = *pRasterizerStateDesc;
|
||||
return S_OK;
|
||||
@@ -2388,7 +2388,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateSamplerState(const SamplerDesc* pSamplerDesc, Sampler* pSamplerState)
|
||||
{
|
||||
DestroySamplerState(pSamplerState);
|
||||
pSamplerState->Register(this);
|
||||
pSamplerState->Register(shared_from_this());
|
||||
|
||||
D3D12_SAMPLER_DESC desc;
|
||||
desc.Filter = _ConvertFilter(pSamplerDesc->Filter);
|
||||
@@ -2415,7 +2415,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateQuery(const GPUQueryDesc* pDesc, GPUQuery* pQuery)
|
||||
{
|
||||
DestroyQuery(pQuery);
|
||||
pQuery->Register(this);
|
||||
pQuery->Register(shared_from_this());
|
||||
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
@@ -2460,7 +2460,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreatePipelineState(const PipelineStateDesc* pDesc, PipelineState* pso)
|
||||
{
|
||||
DestroyPipelineState(pso);
|
||||
pso->Register(this);
|
||||
pso->Register(shared_from_this());
|
||||
|
||||
pso->desc = *pDesc;
|
||||
|
||||
@@ -2482,7 +2482,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_DX12::CreateRenderPass(const RenderPassDesc* pDesc, RenderPass* renderpass)
|
||||
{
|
||||
DestroyRenderPass(renderpass);
|
||||
renderpass->Register(this);
|
||||
renderpass->Register(shared_from_this());
|
||||
|
||||
renderpass->desc = *pDesc;
|
||||
|
||||
|
||||
@@ -2255,7 +2255,7 @@ namespace wiGraphics
|
||||
DestroyBuffer(pBuffer);
|
||||
DestroyResource(pBuffer);
|
||||
pBuffer->type = GPUResource::GPU_RESOURCE_TYPE::BUFFER;
|
||||
pBuffer->Register(this);
|
||||
pBuffer->Register(shared_from_this());
|
||||
|
||||
pBuffer->desc = *pDesc;
|
||||
|
||||
@@ -2441,7 +2441,7 @@ namespace wiGraphics
|
||||
DestroyTexture(pTexture);
|
||||
DestroyResource(pTexture);
|
||||
pTexture->type = GPUResource::GPU_RESOURCE_TYPE::TEXTURE;
|
||||
pTexture->Register(this);
|
||||
pTexture->Register(shared_from_this());
|
||||
|
||||
pTexture->desc = *pDesc;
|
||||
|
||||
@@ -2666,7 +2666,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, uint32_t NumElements, const ShaderByteCode* shaderCode, VertexLayout *pInputLayout)
|
||||
{
|
||||
DestroyInputLayout(pInputLayout);
|
||||
pInputLayout->Register(this);
|
||||
pInputLayout->Register(shared_from_this());
|
||||
|
||||
pInputLayout->desc.clear();
|
||||
pInputLayout->desc.reserve((size_t)NumElements);
|
||||
@@ -2680,7 +2680,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateVertexShader(const void *pShaderBytecode, size_t BytecodeLength, VertexShader *pVertexShader)
|
||||
{
|
||||
DestroyVertexShader(pVertexShader);
|
||||
pVertexShader->Register(this);
|
||||
pVertexShader->Register(shared_from_this());
|
||||
|
||||
pVertexShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pVertexShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2691,7 +2691,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreatePixelShader(const void *pShaderBytecode, size_t BytecodeLength, PixelShader *pPixelShader)
|
||||
{
|
||||
DestroyPixelShader(pPixelShader);
|
||||
pPixelShader->Register(this);
|
||||
pPixelShader->Register(shared_from_this());
|
||||
|
||||
pPixelShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pPixelShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2702,7 +2702,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateGeometryShader(const void *pShaderBytecode, size_t BytecodeLength, GeometryShader *pGeometryShader)
|
||||
{
|
||||
DestroyGeometryShader(pGeometryShader);
|
||||
pGeometryShader->Register(this);
|
||||
pGeometryShader->Register(shared_from_this());
|
||||
|
||||
pGeometryShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pGeometryShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2713,7 +2713,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateHullShader(const void *pShaderBytecode, size_t BytecodeLength, HullShader *pHullShader)
|
||||
{
|
||||
DestroyHullShader(pHullShader);
|
||||
pHullShader->Register(this);
|
||||
pHullShader->Register(shared_from_this());
|
||||
|
||||
pHullShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pHullShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2724,7 +2724,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateDomainShader(const void *pShaderBytecode, size_t BytecodeLength, DomainShader *pDomainShader)
|
||||
{
|
||||
DestroyDomainShader(pDomainShader);
|
||||
pDomainShader->Register(this);
|
||||
pDomainShader->Register(shared_from_this());
|
||||
|
||||
pDomainShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pDomainShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2735,7 +2735,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateComputeShader(const void *pShaderBytecode, size_t BytecodeLength, ComputeShader *pComputeShader)
|
||||
{
|
||||
DestroyComputeShader(pComputeShader);
|
||||
pComputeShader->Register(this);
|
||||
pComputeShader->Register(shared_from_this());
|
||||
|
||||
pComputeShader->code.data = new BYTE[BytecodeLength];
|
||||
memcpy(pComputeShader->code.data, pShaderBytecode, BytecodeLength);
|
||||
@@ -2778,7 +2778,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState)
|
||||
{
|
||||
DestroyBlendState(pBlendState);
|
||||
pBlendState->Register(this);
|
||||
pBlendState->Register(shared_from_this());
|
||||
|
||||
pBlendState->desc = *pBlendStateDesc;
|
||||
return true;
|
||||
@@ -2786,7 +2786,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState)
|
||||
{
|
||||
DestroyDepthStencilState(pDepthStencilState);
|
||||
pDepthStencilState->Register(this);
|
||||
pDepthStencilState->Register(shared_from_this());
|
||||
|
||||
pDepthStencilState->desc = *pDepthStencilStateDesc;
|
||||
return true;
|
||||
@@ -2794,7 +2794,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState)
|
||||
{
|
||||
DestroyRasterizerState(pRasterizerState);
|
||||
pRasterizerState->Register(this);
|
||||
pRasterizerState->Register(shared_from_this());
|
||||
|
||||
pRasterizerState->desc = *pRasterizerStateDesc;
|
||||
return true;
|
||||
@@ -2802,7 +2802,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState)
|
||||
{
|
||||
DestroySamplerState(pSamplerState);
|
||||
pSamplerState->Register(this);
|
||||
pSamplerState->Register(shared_from_this());
|
||||
|
||||
pSamplerState->desc = *pSamplerDesc;
|
||||
|
||||
@@ -2986,7 +2986,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateQuery(const GPUQueryDesc *pDesc, GPUQuery *pQuery)
|
||||
{
|
||||
DestroyQuery(pQuery);
|
||||
pQuery->Register(this);
|
||||
pQuery->Register(shared_from_this());
|
||||
|
||||
bool hr = false;
|
||||
|
||||
@@ -3031,7 +3031,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreatePipelineState(const PipelineStateDesc* pDesc, PipelineState* pso)
|
||||
{
|
||||
DestroyPipelineState(pso);
|
||||
pso->Register(this);
|
||||
pso->Register(shared_from_this());
|
||||
|
||||
pso->desc = *pDesc;
|
||||
|
||||
@@ -3053,7 +3053,7 @@ namespace wiGraphics
|
||||
bool GraphicsDevice_Vulkan::CreateRenderPass(const RenderPassDesc* pDesc, RenderPass* renderpass)
|
||||
{
|
||||
DestroyRenderPass(renderpass);
|
||||
renderpass->Register(this);
|
||||
renderpass->Register(shared_from_this());
|
||||
|
||||
renderpass->desc = *pDesc;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "CommonInclude.h"
|
||||
#include "wiGraphicsDescriptors.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace wiGraphics
|
||||
@@ -10,8 +11,8 @@ namespace wiGraphics
|
||||
|
||||
struct GraphicsDeviceChild
|
||||
{
|
||||
GraphicsDevice* device = nullptr;
|
||||
inline void Register(GraphicsDevice* dev) { device = dev; }
|
||||
std::shared_ptr<GraphicsDevice> device;
|
||||
inline void Register(std::shared_ptr<GraphicsDevice> dev) { device = dev; }
|
||||
inline bool IsValid() const { return device != nullptr; }
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ using namespace wiAllocators;
|
||||
namespace wiRenderer
|
||||
{
|
||||
|
||||
GraphicsDevice* graphicsDevice = nullptr;
|
||||
std::shared_ptr<GraphicsDevice> graphicsDevice;
|
||||
|
||||
VertexShader vertexShaders[VSTYPE_COUNT];
|
||||
PixelShader pixelShaders[PSTYPE_COUNT];
|
||||
@@ -178,13 +178,13 @@ unordered_map<const Texture*, wiRectPacker::rect_xywh> packedLightmaps;
|
||||
|
||||
|
||||
|
||||
void SetDevice(GraphicsDevice* newDevice)
|
||||
void SetDevice(std::shared_ptr<GraphicsDevice> newDevice)
|
||||
{
|
||||
graphicsDevice = newDevice;
|
||||
}
|
||||
GraphicsDevice* GetDevice()
|
||||
{
|
||||
return graphicsDevice;
|
||||
return graphicsDevice.get();
|
||||
}
|
||||
|
||||
// Direct reference to a renderable instance:
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "wiScene_Decl.h"
|
||||
#include "wiECS.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct RAY;
|
||||
|
||||
namespace wiRenderer
|
||||
@@ -37,7 +39,7 @@ namespace wiRenderer
|
||||
void ClearWorld();
|
||||
|
||||
// Set the main graphics device globally:
|
||||
void SetDevice(wiGraphics::GraphicsDevice* newDevice);
|
||||
void SetDevice(std::shared_ptr<wiGraphics::GraphicsDevice> newDevice);
|
||||
// Retrieve the main graphics device:
|
||||
wiGraphics::GraphicsDevice* GetDevice();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 36;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 3;
|
||||
const int revision = 4;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Reference in New Issue
Block a user