summaryrefslogtreecommitdiffstats
path: root/unityplugin
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-21 18:01:10 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-21 18:01:10 +0000
commit41e5a5404dd18c748a8355c0796d5e53f793c3b9 (patch)
tree58af8fabc3132d1edce8248ae5f5eaf53bbd6f42 /unityplugin
parentFixed release history (diff)
downloadDiligentEngine-41e5a5404dd18c748a8355c0796d5e53f793c3b9.tar.gz
DiligentEngine-41e5a5404dd18c748a8355c0796d5e53f793c3b9.zip
Implemented explicit resource state transitions
Diffstat (limited to 'unityplugin')
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp4
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp4
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp4
-rw-r--r--unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp1
-rw-r--r--unityplugin/GhostCubeScene/src/GhostCubeScene.cpp2
-rw-r--r--unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp4
-rw-r--r--unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp4
7 files changed, 12 insertions, 11 deletions
diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp
index 85c81ba..46d3ac8 100644
--- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp
+++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D11.cpp
@@ -80,11 +80,11 @@ void RenderAPI_D3D11::AttachToNativeRenderTexture(void *nativeRenderTargetHandle
auto *pd3d11RenderTarget = reinterpret_cast<ID3D11Texture2D *>(nativeRenderTargetHandle);
RefCntAutoPtr<ITexture> pRenderTarget;
- pDeviceD3D11->CreateTextureFromD3DResource(pd3d11RenderTarget, &pRenderTarget);
+ pDeviceD3D11->CreateTextureFromD3DResource(pd3d11RenderTarget, RESOURCE_STATE_UNDEFINED, &pRenderTarget);
auto *pd3d11DepthBuffer = reinterpret_cast<ID3D11Texture2D *>(nativeDepthTextureHandle);
RefCntAutoPtr<ITexture> pDepthBuffer;
- pDeviceD3D11->CreateTextureFromD3DResource(pd3d11DepthBuffer, &pDepthBuffer);
+ pDeviceD3D11->CreateTextureFromD3DResource(pd3d11DepthBuffer, RESOURCE_STATE_UNDEFINED, &pDepthBuffer);
CreateTextureViews(pRenderTarget, pDepthBuffer);
}
diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp
index 8befeb0..3f4f9ea 100644
--- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp
+++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_D3D12.cpp
@@ -189,14 +189,14 @@ void RenderAPI_D3D12::AttachToNativeRenderTexture(void *nativeRenderTargetHandle
{
auto *pd3d12RenderTarget = reinterpret_cast<ID3D12Resource*>(nativeRenderTargetHandle);
RefCntAutoPtr<ITexture> pRenderTarget;
- pDeviceD3D12->CreateTextureFromD3DResource(pd3d12RenderTarget, &pRenderTarget);
+ pDeviceD3D12->CreateTextureFromD3DResource(pd3d12RenderTarget, RESOURCE_STATE_UNDEFINED, &pRenderTarget);
pRenderTarget->QueryInterface(IID_TextureD3D12, reinterpret_cast<IObject**>(static_cast<ITextureD3D12**>(&m_RenderTarget)));
}
{
auto *pd3d12DepthBuffer = reinterpret_cast<ID3D12Resource *>(nativeDepthTextureHandle);
RefCntAutoPtr<ITexture> pDepthBuffer;
- pDeviceD3D12->CreateTextureFromD3DResource(pd3d12DepthBuffer, &pDepthBuffer);
+ pDeviceD3D12->CreateTextureFromD3DResource(pd3d12DepthBuffer, RESOURCE_STATE_UNDEFINED, &pDepthBuffer);
pDepthBuffer->QueryInterface(IID_TextureD3D12, reinterpret_cast<IObject**>(static_cast<ITextureD3D12**>(&m_DepthBuffer)));
}
CreateTextureViews(m_RenderTarget, m_DepthBuffer);
diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp
index 4e9b345..cac774d 100644
--- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp
+++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI_OpenGLCoreES.cpp
@@ -83,7 +83,7 @@ void RenderAPI_OpenGLCoreES::CreateRenderTargetAndDepthBuffer()
RenderTargetDesc.Height = 1024;
RenderTargetDesc.Format = TEX_FORMAT_RGBA8_UNORM_SRGB;
#endif
- pDeviceGL->CreateTextureFromGLHandle(m_GLRenderTargetHandle, RenderTargetDesc, &pRenderTarget);
+ pDeviceGL->CreateTextureFromGLHandle(m_GLRenderTargetHandle, RenderTargetDesc, RESOURCE_STATE_UNKNOWN, &pRenderTarget);
RefCntAutoPtr<ITexture> pDepthBuffer;
TextureDesc DepthBufferDesc;
@@ -98,7 +98,7 @@ void RenderAPI_OpenGLCoreES::CreateRenderTargetAndDepthBuffer()
DepthBufferDesc.Height = 1024;
DepthBufferDesc.Format = TEX_FORMAT_D32_FLOAT;
#endif
- pDeviceGL->CreateTextureFromGLHandle(m_GLDepthTextureHandle, DepthBufferDesc, &pDepthBuffer);
+ pDeviceGL->CreateTextureFromGLHandle(m_GLDepthTextureHandle, DepthBufferDesc, RESOURCE_STATE_UNKNOWN, &pDepthBuffer);
CreateTextureViews(pRenderTarget, pDepthBuffer);
}
diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp
index b54e84a..aee52b2 100644
--- a/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp
+++ b/unityplugin/GhostCubePlugin/PluginSource/src/SamplePlugin.cpp
@@ -169,5 +169,6 @@ void SamplePlugin::Render(Diligent::IDeviceContext *pContext, const float4x4 &Vi
DrawAttrs.IsIndexed = true;
DrawAttrs.IndexType = VT_UINT32;
DrawAttrs.NumIndices = 36;
+ DrawAttrs.Flags = DRAW_FLAG_TRANSITION_INDEX_BUFFER | DRAW_FLAG_TRANSITION_VERTEX_BUFFERS;
pContext->Draw(DrawAttrs);
}
diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp
index 87ef39e..62fa900 100644
--- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp
+++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp
@@ -189,7 +189,7 @@ void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc)
// Call the plugin
RenderEventFunc(0);
}
-
+
// We need to invalidate the context state since the plugin has used d3d11 context
pCtx->InvalidateState();
pCtx->SetRenderTargets(0, nullptr, nullptr);
diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp
index f804e90..13d91da 100644
--- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp
+++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D11.cpp
@@ -66,7 +66,7 @@ public:
RefCntAutoPtr<IRenderDeviceD3D11> pRenderDeviceD3D11(m_pRenderDevice, IID_RenderDeviceD3D11);
RefCntAutoPtr<ITexture> pBackBuffer;
- pRenderDeviceD3D11->CreateTextureFromD3DResource(pd3dTex2DBackBuffer, &pBackBuffer);
+ pRenderDeviceD3D11->CreateTextureFromD3DResource(pd3dTex2DBackBuffer, RESOURCE_STATE_UNDEFINED, &pBackBuffer);
TextureViewDesc RTVDesc;
RTVDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
RTVDesc.Format = m_SwapChainDesc.ColorBufferFormat;
@@ -75,7 +75,7 @@ public:
m_pRTV = RefCntAutoPtr<ITextureViewD3D11>(pRTV, IID_TextureViewD3D11);
RefCntAutoPtr<ITexture> pDepthBuffer;
- pRenderDeviceD3D11->CreateTextureFromD3DResource(pd3dTex2DDepthBuffer, &pDepthBuffer);
+ pRenderDeviceD3D11->CreateTextureFromD3DResource(pd3dTex2DDepthBuffer, RESOURCE_STATE_UNDEFINED, &pDepthBuffer);
m_pDSV = RefCntAutoPtr<ITextureViewD3D11>(pDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL), IID_TextureViewD3D11);
}
diff --git a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp
index 1ef8671..1ce1442 100644
--- a/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp
+++ b/unityplugin/UnityEmulator/src/DiligentGraphicsAdapterD3D12.cpp
@@ -163,7 +163,7 @@ public:
if(FAILED(hr))
LOG_ERROR_AND_THROW("Failed to get back buffer ", backbuff," from the swap chain");
RefCntAutoPtr<ITexture> pBackBuffer;
- pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12BackBuffer, &pBackBuffer);
+ pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12BackBuffer, RESOURCE_STATE_UNDEFINED, &pBackBuffer);
m_BackBuffers.emplace_back( RefCntAutoPtr<ITextureD3D12>(pBackBuffer, IID_TextureD3D12) );
TextureViewDesc TexViewDesc;
TexViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
@@ -174,7 +174,7 @@ public:
}
RefCntAutoPtr<ITexture> pDepthBuffer;
- pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12DepthBuffer, &pDepthBuffer);
+ pRenderDeviceD3D12->CreateTextureFromD3DResource(pd3d12DepthBuffer, RESOURCE_STATE_UNDEFINED, &pDepthBuffer);
m_DepthBuffer = RefCntAutoPtr<ITextureD3D12>(pDepthBuffer, IID_TextureD3D12);
auto *pDSV = m_DepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL);
m_DSV = RefCntAutoPtr<ITextureViewD3D12>(pDSV, IID_TextureViewD3D12);