summaryrefslogtreecommitdiffstats
path: root/unityplugin/GhostCubePlugin/PluginSource/src/RenderAPI.cpp
blob: 73badff3e09cead672fb1e4a2e7678125c7cb7f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "RenderAPI.h"
#include "PlatformBase.h"
#include "Unity/IUnityGraphics.h"
#include "GraphicsAccessories.hpp"

using namespace Diligent;

void RenderAPI::CreateTextureViews(Diligent::ITexture *pRenderTarget, Diligent::ITexture *pDepthBuffer)
{
    m_RTV.Release();
    m_DSV.Release();
    {
        const auto &RTDesc = pRenderTarget->GetDesc();
        TextureViewDesc RTVDesc;
        RTVDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET;
        m_RenderTargetFormat = GetDefaultTextureViewFormat(RTDesc, TEXTURE_VIEW_RENDER_TARGET);
        RTVDesc.Format = m_RenderTargetFormat;
        pRenderTarget->CreateView(RTVDesc, &m_RTV);
    }

    {
        const auto &TexDesc = pDepthBuffer->GetDesc();
        TextureViewDesc DSVDesc;
        DSVDesc.ViewType = TEXTURE_VIEW_DEPTH_STENCIL;
        m_DepthBufferFormat = GetDefaultTextureViewFormat(TexDesc, TEXTURE_VIEW_DEPTH_STENCIL);
        DSVDesc.Format = m_DepthBufferFormat;
        pDepthBuffer->CreateView(DSVDesc, &m_DSV);
    }
}