Skip to content

Commit 669e588

Browse files
HybridDetect Public Release
1 parent 02bc31d commit 669e588

File tree

344 files changed

+163803
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+163803
-21
lines changed

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
*.ipch
14+
15+
# Compiled Dynamic libraries
16+
*.so
17+
*.dylib
18+
#*.dll
19+
20+
# Fortran module files
21+
*.mod
22+
*.smod
23+
24+
# Compiled Static libraries
25+
*.lai
26+
*.la
27+
*.a
28+
#*.lib
29+
30+
# Executables
31+
*.exe
32+
*.out
33+
*.app
34+
35+
#misc files
36+
*.pdb
37+
*.db

D3D12Multithreading/readme.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Direct3D 12 multithreading sample
8+
urlFragment: d3d12-multithreading-sample-win32
9+
description: This sample demonstrates the use of multiple threads with Direct3D 12.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
15+
# Direct3D 12 multithreading sample
16+
![Multithreading GUI](src/D3D12Multithreading.png)
17+
18+
This sample demonstrates the use of multiple threads with Direct3D 12. An app can use multithreading to improve efficiency by building command lists on multiple threads asynchronously. The majority of the CPU cost is associated with command list building, not command list execution. Apps must ensure they never concurrently call methods on the same command list or command allocator.
19+
20+
### Optional features
21+
This sample has been updated to build against the Windows 10 Anniversary Update SDK. In this SDK a new revision of Root Signatures is available for Direct3D 12 apps to use. Root Signature 1.1 allows for apps to declare when descriptors in a descriptor heap won't change or the data descriptors point to won't change. This allows the option for drivers to make optimizations that might be possible knowing that something (like a descriptor or the memory it points to) is static for some period of time.

D3D12Multithreading/src/Camera.cpp

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//*********************************************************
2+
//
3+
// Copyright (c) Microsoft. All rights reserved.
4+
// This code is licensed under the MIT License (MIT).
5+
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6+
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7+
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8+
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9+
//
10+
//*********************************************************
11+
12+
#include "stdafx.h"
13+
#include "Camera.h"
14+
15+
Camera* Camera::mCamera = nullptr;
16+
17+
Camera::Camera()
18+
{
19+
Reset();
20+
mCamera = this;
21+
}
22+
23+
Camera::~Camera()
24+
{
25+
mCamera = nullptr;
26+
}
27+
28+
Camera* Camera::get()
29+
{
30+
return mCamera;
31+
}
32+
33+
void Camera::Get3DViewProjMatrices(XMFLOAT4X4 *view, XMFLOAT4X4 *proj, float fovInDegrees, float screenWidth, float screenHeight)
34+
{
35+
36+
float aspectRatio = (float)screenWidth / (float)screenHeight;
37+
float fovAngleY = fovInDegrees * XM_PI / 180.0f;
38+
39+
if (aspectRatio < 1.0f)
40+
{
41+
fovAngleY /= aspectRatio;
42+
}
43+
44+
XMStoreFloat4x4(view, XMMatrixTranspose(XMMatrixLookAtRH(mEye, mAt, mUp)));
45+
XMStoreFloat4x4(proj, XMMatrixTranspose(XMMatrixPerspectiveFovRH(fovAngleY, aspectRatio, 0.01f, 125.0f)));
46+
}
47+
48+
void Camera::GetOrthoProjMatrices(XMFLOAT4X4 *view, XMFLOAT4X4 *proj, float width, float height)
49+
{
50+
XMStoreFloat4x4(view, XMMatrixTranspose(XMMatrixLookAtRH(mEye, mAt, mUp)));
51+
XMStoreFloat4x4(proj, XMMatrixTranspose(XMMatrixOrthographicRH(width, height, 0.01f, 125.0f)));
52+
}
53+
void Camera::RotateYaw(float deg)
54+
{
55+
XMMATRIX rotation = XMMatrixRotationAxis(mUp, deg);
56+
57+
mEye = XMVector3TransformCoord(mEye, rotation);
58+
}
59+
60+
void Camera::RotatePitch(float deg)
61+
{
62+
XMVECTOR right = XMVector3Normalize(XMVector3Cross(mEye, mUp));
63+
XMMATRIX rotation = XMMatrixRotationAxis(right, deg);
64+
65+
mEye = XMVector3TransformCoord(mEye, rotation);
66+
}
67+
68+
void Camera::Reset()
69+
{
70+
mEye = XMVectorSet(0.0f, 15.0f, -30.0f, 0.0f);
71+
mAt = XMVectorSet(0.0f, 8.0f, 0.0f, 0.0f);
72+
mUp = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
73+
}
74+
75+
void Camera::Set(XMVECTOR eye, XMVECTOR at, XMVECTOR up)
76+
{
77+
mEye = eye;
78+
mAt = at;
79+
mUp = up;
80+
}

D3D12Multithreading/src/Camera.h

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//*********************************************************
2+
//
3+
// Copyright (c) Microsoft. All rights reserved.
4+
// This code is licensed under the MIT License (MIT).
5+
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6+
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7+
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8+
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9+
//
10+
//*********************************************************
11+
12+
#pragma once
13+
#include "stdafx.h"
14+
15+
using namespace DirectX;
16+
17+
class Camera
18+
{
19+
public:
20+
Camera();
21+
~Camera();
22+
23+
void Get3DViewProjMatrices(XMFLOAT4X4 *view, XMFLOAT4X4 *proj, float fovInDegrees, float screenWidth, float screenHeight);
24+
void Reset();
25+
void Set(XMVECTOR eye, XMVECTOR at, XMVECTOR up);
26+
static Camera *get();
27+
void RotateYaw(float deg);
28+
void RotatePitch(float deg);
29+
void GetOrthoProjMatrices(XMFLOAT4X4 *view, XMFLOAT4X4 *proj, float width, float height);
30+
XMVECTOR mEye; // Where the camera is in world space. Z increases into of the screen when using LH coord system (which we are and DX uses)
31+
XMVECTOR mAt; // What the camera is looking at (world origin)
32+
XMVECTOR mUp; // Which way is up
33+
private:
34+
static Camera* mCamera;
35+
};

0 commit comments

Comments
 (0)