Skip to content

Commit

Permalink
#5: ported DX12 to Cauldron v1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ppenenko committed Oct 2, 2022
1 parent cfec7c0 commit bec443f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/cauldron
Submodule cauldron updated 174 files
4 changes: 2 additions & 2 deletions src/DX12/GLTFSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void GLTFSample::LoadScene(int sceneIndex)
if (m_pGltfLoader->m_lights.size() == 0)
{
tfNode n;
n.m_tranform.LookAt(PolarToVector(AMD_PI_OVER_2, 0.58f) * 3.5f, math::Vector4(0, 0, 0, 0));
n.m_transform.LookAt(PolarToVector(AMD_PI_OVER_2, 0.58f) * 3.5f, math::Vector4(0, 0, 0, 0));

tfLight l;
l.m_type = tfLight::LIGHT_SPOTLIGHT;
Expand Down Expand Up @@ -414,7 +414,7 @@ void GLTFSample::OnRender()
// Do any start of frame necessities
BeginFrame();

ImGUI_UpdateIO();
ImGUI_UpdateIO(m_Width,m_Height);
ImGui::NewFrame();

if (m_loadingScene)
Expand Down
24 changes: 21 additions & 3 deletions src/DX12/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,20 @@ void Renderer::OnCreate(Device* pDevice, SwapChain *pSwapChain, float FontSize)
m_ResourceViewHeaps.AllocCBV_SRV_UAVDescriptor(1, &m_ShadowMaskSRV);
#endif

m_SkyDome.OnCreate(pDevice, &m_UploadHeap, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool, "..\\media\\cauldron-media\\envmaps\\papermill\\diffuse.dds", "..\\media\\cauldron-media\\envmaps\\papermill\\specular.dds", DXGI_FORMAT_R16G16B16A16_FLOAT, 4);
m_SkyDomeProc.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool, DXGI_FORMAT_R16G16B16A16_FLOAT, 1);
constexpr bool bInvertedDepth = false;
m_SkyDome.OnCreate(
pDevice,
&m_UploadHeap,
&m_ResourceViewHeaps,
&m_ConstantBufferRing,
&m_VidMemBufferPool,
"..\\media\\cauldron-media\\envmaps\\papermill\\diffuse.dds",
"..\\media\\cauldron-media\\envmaps\\papermill\\specular.dds",
DXGI_FORMAT_R16G16B16A16_FLOAT,
4,
bInvertedDepth
);
m_SkyDomeProc.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool, DXGI_FORMAT_R16G16B16A16_FLOAT, 1, bInvertedDepth);
m_Wireframe.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool, DXGI_FORMAT_R16G16B16A16_FLOAT, 1);
m_WireframeBox.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool);
m_DownSample.OnCreate(pDevice, &m_ResourceViewHeaps, &m_ConstantBufferRing, &m_VidMemBufferPool, DXGI_FORMAT_R16G16B16A16_FLOAT);
Expand Down Expand Up @@ -403,7 +415,13 @@ void Renderer::AllocateShadowMaps(GLTFCommon* pGLTFCommon)
std::vector<SceneShadowInfo>::iterator CurrentShadow = m_shadowMapPool.begin();
for( uint32_t i = 0; CurrentShadow < m_shadowMapPool.end(); ++i, ++CurrentShadow)
{
CurrentShadow->ShadowMap.InitDepthStencil(m_pDevice, "m_pShadowMap", &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_D32_FLOAT, CurrentShadow->ShadowResolution, CurrentShadow->ShadowResolution, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL));
constexpr float fClearValue = 1.0f;
CurrentShadow->ShadowMap.InitDepthStencil(
m_pDevice,
"m_pShadowMap",
&CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_D32_FLOAT, CurrentShadow->ShadowResolution, CurrentShadow->ShadowResolution, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL),
fClearValue
);
CurrentShadow->ShadowMap.CreateDSV(CurrentShadow->ShadowIndex, &m_ShadowMapPoolDSV);
CurrentShadow->ShadowMap.CreateSRV(CurrentShadow->ShadowIndex, &m_ShadowMapPoolSRV);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DX12/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void GLTFSample::BuildUI()
if (ImGui::Button("Set Spot Light 0 to Camera's View"))
{
int idx = m_pGltfLoader->m_lightInstances[0].m_nodeIndex;
m_pGltfLoader->m_nodes[idx].m_tranform.LookAt(m_camera.GetPosition(), m_camera.GetPosition() - m_camera.GetDirection());
m_pGltfLoader->m_animatedMats[idx] = m_pGltfLoader->m_nodes[idx].m_tranform.GetWorldMat();
m_pGltfLoader->m_nodes[idx].m_transform.LookAt(m_camera.GetPosition(), m_camera.GetPosition() - m_camera.GetDirection());
m_pGltfLoader->m_animatedMats[idx] = m_pGltfLoader->m_nodes[idx].m_transform.GetWorldMat();
}
}

Expand Down

0 comments on commit bec443f

Please sign in to comment.