Skip to content

Commit

Permalink
v4.3 updates, 3d model viewer gltf dx12
Browse files Browse the repository at this point in the history
  • Loading branch information
NavNTCMP committed Jan 26, 2023
1 parent 00ee7de commit df1ab4e
Show file tree
Hide file tree
Showing 55 changed files with 202 additions and 182 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# this must be before add_executable
# link_directories(
# ${PROJECT_EXTERNAL_LIBDIR}/directxtex/DirectXTex-jun2020b/DirectXTex/Bin/Desktop_2017/x64
# ${PROJECT_EXTERNAL_LIBDIR}/directxtex/DirectXTex-jun2020b/DirectXTex/Bin/Desktop_2019/x64
# )

add_library(ModelViewer_DX12 SHARED)
Expand Down Expand Up @@ -45,14 +45,16 @@ target_include_directories(ModelViewer_DX12 PUBLIC
${PROJECT_SOURCE_DIR}/applications/_plugins/common/model_viewer
${PROJECT_SOURCE_DIR}/applications/_libs/cmp_meshoptimizer
${PROJECT_SOURCE_DIR}/applications/_plugins/common/qtimgui
${PROJECT_SOURCE_DIR}/external/imgui

${PROJECT_SOURCE_DIR}/../common/lib/ext/glm
${Qt5Gui_INCLUDE_DIRS}
)
${PROJECT_SOURCE_DIR}/../common/lib/ext/imgui
)

target_link_libraries(ModelViewer_DX12 PRIVATE
CMP_Compressonator
CMP_Framework
# CMP_MeshCompressor
CMP_GUI_Gltf
CMP_GpuDecode
CMP_Imgui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
// THE SOFTWARE.


#include "dynamicbufferringdx12.h"
#include "staticbufferpooldx12.h"
#include "uploadheapdx12.h"
#include "texturedx12.h"
#include "postprocps.h"
#include "texturedx12.h"
#include "bloom.h"
#include "cmp_dynamicbufferringdx12.h"
#include "cmp_staticbufferpooldx12.h"
#include "cmp_uploadheapdx12.h"
#include "cmp_texturedx12.h"
#include "cmp_postprocps.h"
#include "cmp_texturedx12.h"
#include "cmp_bloom.h"


void Bloom::OnCreate(
void CMP_Bloom::OnCreate(
ID3D12Device* pDevice,
UINT node,
ResourceViewHeapsDX12 *pHeaps,
Expand Down Expand Up @@ -75,7 +75,8 @@ void Bloom::OnCreate(
}
}

void Bloom::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD Width, DWORD Height, UINT node, UINT nodemask) {
void CMP_Bloom::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD Width, DWORD Height, UINT node, UINT nodemask)
{
m_Width = Width;
m_Height = Height;

Expand All @@ -95,30 +96,34 @@ void Bloom::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD Wi

}

void Bloom::OnDestroyWindowSizeDependentResources() {
void CMP_Bloom::OnDestroyWindowSizeDependentResources()
{
for (int i = 0; i < BLOOM_DEPTH; i++) {
m_mip[i].OnDestroy();
m_blurTempMip[i].OnDestroy();
}
}

void Bloom::OnDestroy() {
void CMP_Bloom::OnDestroy()
{
m_downscale.OnDestroy();
m_blurY.OnDestroy();
m_blurX.OnDestroy();
m_blendAdd.OnDestroy();
m_blendFactor.OnDestroy();
}

void Bloom::SetViewPortAndScissor(ID3D12GraphicsCommandList* pCommandList, int i) {
void CMP_Bloom::SetViewPortAndScissor(ID3D12GraphicsCommandList* pCommandList, int i)
{
D3D12_VIEWPORT viewPort = { 0.0f, 0.0f, static_cast<float>(m_Width >> (i + 1)), static_cast<float>(m_Height >> (i + 1)), 0.0f, 1.0f };
D3D12_RECT rectScissor = { 0, 0, (LONG)(m_Width >> (i + 1)), (LONG)(m_Height >> (i + 1)) };
pCommandList->RSSetViewports(1, &viewPort);
pCommandList->RSSetScissorRects(1, &rectScissor);

}

void Bloom::Draw(ID3D12GraphicsCommandList* pCommandList, TextureDX12 *pInput, float glowFactor) {
void CMP_Bloom::Draw(ID3D12GraphicsCommandList* pCommandList, TextureDX12* pInput, float glowFactor)
{
pInput->CreateRTV(0, &m_inputRTV);
pInput->CreateSRV(0, &m_inputSRV);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
// THE SOFTWARE.

#pragma once
#include "postprocps.h"
#include "cmp_postprocps.h"

#define BLOOM_DEPTH 6

class Bloom {
class CMP_Bloom {
public:
void OnCreate(
ID3D12Device* pDevice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "dynamicbufferringdx12.h"
#include "staticbufferpooldx12.h"
#include "uploadheapdx12.h"
#include "texturedx12.h"
#include "postprocps.h"
#include "blurps.h"
#include "cmp_dynamicbufferringdx12.h"
#include "cmp_staticbufferpooldx12.h"
#include "cmp_uploadheapdx12.h"
#include "cmp_texturedx12.h"
#include "cmp_postprocps.h"
#include "cmp_blurps.h"

#include <directxmath.h>

Expand Down Expand Up @@ -57,7 +57,7 @@ void GenerateGaussianWeights(int count, float *out) {
}
}

void BlurPS::OnCreate(
void CMP_BlurPS::OnCreate(
ID3D12Device* pDevice,
UINT node,
ResourceViewHeapsDX12 *pHeaps,
Expand Down Expand Up @@ -100,7 +100,8 @@ void BlurPS::OnCreate(
*/
}

void BlurPS::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD Width, DWORD Height, UINT node, UINT nodemask) {
void CMP_BlurPS::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD Width, DWORD Height, UINT node, UINT nodemask)
{
m_Width = Width;
m_Height = Height;

Expand All @@ -113,17 +114,20 @@ void BlurPS::OnCreateWindowSizeDependentResources(ID3D12Device* pDevice, DWORD W

}

void BlurPS::OnDestroyWindowSizeDependentResources() {
void CMP_BlurPS::OnDestroyWindowSizeDependentResources()
{
m_temp.OnDestroy();
}

void BlurPS::OnDestroy() {
void CMP_BlurPS::OnDestroy()
{
m_blurY.OnDestroy();
m_blurX.OnDestroy();
}


void BlurPS::Draw(ID3D12GraphicsCommandList* pCommandList, CBV_SRV_UAV *pSrcResource, D3D12_CPU_DESCRIPTOR_HANDLE *pDestination) {
void CMP_BlurPS::Draw(ID3D12GraphicsCommandList* pCommandList, CBV_SRV_UAV* pSrcResource, D3D12_CPU_DESCRIPTOR_HANDLE* pDestination)
{
D3D12_VIEWPORT viewPort = { 0.0f, 0.0f, static_cast<float>(m_Width), static_cast<float>(m_Height), 0.0f, 1.0f };
D3D12_RECT rectScissor = { 0, 0, (LONG)m_Width, (LONG)m_Height };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
// THE SOFTWARE.

#pragma once
#include "postprocps.h"
#include "cmp_postprocps.h"

class BlurPS {
class CMP_BlurPS
{
public:
void OnCreate(
ID3D12Device* pDevice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "camera.h"
#include "cmp_camera.h"

#include <windows.h>

Expand All @@ -31,7 +31,8 @@ using namespace DirectX;
// OnCreate
//
//--------------------------------------------------------------------------------------
void Camera::SetFov(float fovV, uint32_t width, uint32_t height) {
void CMP_Camera::SetFov(float fovV, uint32_t width, uint32_t height)
{
// fovV = fovV * 0.025f; avacado

m_aspectRatio = width *1.f / height;
Expand All @@ -57,7 +58,8 @@ void Camera::SetFov(float fovV, uint32_t width, uint32_t height) {
// LookAt
//
//--------------------------------------------------------------------------------------
void Camera::LookAt(XMVECTOR eyePos, XMVECTOR lookAt) {
void CMP_Camera::LookAt(XMVECTOR eyePos, XMVECTOR lookAt)
{
m_eyePos = eyePos;
XMVECTOR up = XMVectorSet(0, 1, 0, 0);
m_View = XMMatrixLookAtRH(eyePos, lookAt, up);
Expand All @@ -68,7 +70,8 @@ void Camera::LookAt(XMVECTOR eyePos, XMVECTOR lookAt) {
// UpdateCamera
//
//--------------------------------------------------------------------------------------
void Camera::UpdateCameraWASD(float roll, float pitch, const bool keyDown[256], double deltaTime) {
void CMP_Camera::UpdateCameraWASD(float roll, float pitch, const bool keyDown[256], double deltaTime)
{
float speed = 0.0003f * (keyDown[VK_SHIFT] ? 25.f * (float)deltaTime : 5.f * (float)deltaTime);

float eyeDir[3] = { 0,0,0 };
Expand Down Expand Up @@ -104,7 +107,8 @@ void Camera::UpdateCameraWASD(float roll, float pitch, const bool keyDown[256],
LookAt(m_eyePos, at);
}

void Camera::UpdateCamera(float roll, float pitch, float distance) {
void CMP_Camera::UpdateCamera(float roll, float pitch, float distance)
{
m_eyePos = XMVectorSet(distance * sinf(roll) * cosf(pitch), distance * sinf(pitch), distance * cosf(roll) * cosf(pitch), 0);
XMVECTOR at = XMVectorSet(0, 0, 0, 0);
LookAt(m_eyePos, at);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

// typical camera class

class Camera {
class CMP_Camera
{
public:
void LookAt(DirectX::XMVECTOR eyePos, DirectX::XMVECTOR lookAt);
void SetFov(float fov, uint32_t width, uint32_t height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "commandlistringdx12.h"
#include "cmp_commandlistringdx12.h"

#include <error.h>
#include "cmp_error.h"


//--------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// THE SOFTWARE.

#pragma once
#include "ring.h"
#include "cmp_ring.h"

#include <d3dx12.h>
#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
// THE SOFTWARE.
//

#include "drawcube.h"
#include "cmp_drawcube.h"

#include <error.h>
#include "cmp_error.h"

#include <d3dx12.h>
#include <d3dcompiler.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include "dynamicbufferringdx12.h"
#include "staticbufferpooldx12.h"
#include "uploadheapdx12.h"
#include "camera.h"
#include "cmp_dynamicbufferringdx12.h"
#include "cmp_staticbufferpooldx12.h"
#include "cmp_uploadheapdx12.h"
#include "cmp_camera.h"

#include <wrl.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "dynamicbufferringdx12.h"
#include "misc.h"
#include "cmp_dynamicbufferringdx12.h"
#include "cmp_misc.h"

#include <error.h>
#include "cmp_error.h"

#include <d3dx12.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// THE SOFTWARE.

#pragma once
#include "ring.h"
#include "resourceviewheapsdx12.h"
#include "cmp_ring.h"
#include "cmp_resourceviewheapsdx12.h"

// This class mimics the behaviour or the DX11 dynamic buffers.
// It does so by suballocating memory from a huge buffer. The buffer is used in a ring fashion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "fencedx12.h"
#include "cmp_fencedx12.h"

#include <error.h>
#include "cmp_error.h"

FenceDX12::FenceDX12() {
m_hEvent = CreateEventEx(nullptr, FALSE, FALSE, EVENT_ALL_ACCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// THE SOFTWARE.


#include "frameworkwindows.h"
#include "cmp_frameworkwindows.h"

// LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// THE SOFTWARE.


#include "gputimestampsdx12.h"
#include "cmp_gputimestampsdx12.h"

#include <error.h>
#include "cmp_error.h"


void GPUTimestampsDX12::OnCreate(ID3D12Device* pDevice, DWORD numberOfBackBuffers, UINT node, UINT nodemask) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "imguidx12.h"
#include "cmp_imguidx12.h"

// DirectX
#include <d3d11.h>
Expand Down Expand Up @@ -370,8 +370,9 @@ void ImGUIDX12::Draw(ID3D12GraphicsCommandList *pCommandList) {

bool ImGUIDX12_Init(void* hwnd) {
g_hWnd = (HWND)hwnd;

ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.DeltaTime = 1.0f / 60.0f; // for >
io.KeyMap[ImGuiKey_Tab] = VK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
Expand All @@ -392,14 +393,14 @@ bool ImGUIDX12_Init(void* hwnd) {
io.KeyMap[ImGuiKey_Y] = 'Y';
io.KeyMap[ImGuiKey_Z] = 'Z';

io.RenderDrawListsFn = NULL;
//io.RenderDrawListsFn = NULL;
io.ImeWindowHandle = g_hWnd;

return true;
}

void ImGUIDX12_Shutdown() {
ImGui::Shutdown();
//ImGui::Shutdown();
g_hWnd = (HWND)0;
}

Expand Down

0 comments on commit df1ab4e

Please sign in to comment.