Skip to content

Commit c223248

Browse files
committed
Fix Formatting
1 parent f07aa98 commit c223248

File tree

24 files changed

+268
-156
lines changed

24 files changed

+268
-156
lines changed

src/Cpp/1-getting-started/1-1-3-HelloTriangle-Refactored/DeviceContext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ void DeviceContext::SetVertexBuffer(
3232
{
3333
D3D11_BUFFER_DESC description = {};
3434
triangleVertices->GetDesc(&description);
35-
_deviceContext->IASetVertexBuffers(0, 1, &triangleVertices, &_activePipeline->_vertexSize, &vertexOffset);
35+
_deviceContext->IASetVertexBuffers(
36+
0,
37+
1,
38+
&triangleVertices,
39+
&_activePipeline->_vertexSize,
40+
&vertexOffset);
3641
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
3742
}
3843

src/Cpp/1-getting-started/1-2-2-DebugLayer/DeviceContext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ void DeviceContext::SetVertexBuffer(
3232
{
3333
D3D11_BUFFER_DESC description = {};
3434
triangleVertices->GetDesc(&description);
35-
_deviceContext->IASetVertexBuffers(0, 1, &triangleVertices, &_activePipeline->_vertexSize, &vertexOffset);
35+
_deviceContext->IASetVertexBuffers(
36+
0,
37+
1,
38+
&triangleVertices,
39+
&_activePipeline->_vertexSize,
40+
&vertexOffset);
3641
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
3742
}
3843

src/Cpp/1-getting-started/1-2-3-NamingThings/DeviceContext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ void DeviceContext::SetVertexBuffer(
3232
{
3333
D3D11_BUFFER_DESC description = {};
3434
triangleVertices->GetDesc(&description);
35-
_deviceContext->IASetVertexBuffers(0, 1, &triangleVertices, &_activePipeline->_vertexSize, &vertexOffset);
35+
_deviceContext->IASetVertexBuffers(
36+
0,
37+
1,
38+
&triangleVertices,
39+
&_activePipeline->_vertexSize,
40+
&vertexOffset);
3641
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
3742
}
3843

src/Cpp/1-getting-started/1-3-1-ImageLibrary/DeviceContext.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ void DeviceContext::SetPipeline(const Pipeline* pipeline)
2626

2727
for (auto [descriptor, resource] : pipeline->_resources)
2828
{
29-
switch (descriptor.type)
29+
switch (descriptor.Type)
3030
{
3131
case ResourceType::Sampler:
32-
_deviceContext->PSSetSamplers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
32+
_deviceContext->PSSetSamplers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
3333
break;
3434

3535
case ResourceType::Texture:
36-
_deviceContext->PSSetShaderResources(descriptor.slotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
36+
_deviceContext->PSSetShaderResources(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
3737
break;
3838
}
3939
}
@@ -47,7 +47,12 @@ void DeviceContext::SetVertexBuffer(
4747
{
4848
D3D11_BUFFER_DESC description = {};
4949
triangleVertices->GetDesc(&description);
50-
_deviceContext->IASetVertexBuffers(0, 1, &triangleVertices, &_activePipeline->_vertexSize, &vertexOffset);
50+
_deviceContext->IASetVertexBuffers(
51+
0,
52+
1,
53+
&triangleVertices,
54+
&_activePipeline->_vertexSize,
55+
&vertexOffset);
5156
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
5257
}
5358

src/Cpp/1-getting-started/1-3-1-ImageLibrary/Pipeline.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
void Pipeline::BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture)
44
{
55
ResourceDescriptor descriptor = {};
6-
descriptor.slotIndex = slotIndex;
7-
descriptor.type = ResourceType::Texture;
6+
descriptor.SlotIndex = slotIndex;
7+
descriptor.Type = ResourceType::Texture;
88
_resources[descriptor] = static_cast<ID3D11DeviceChild*>(texture);
99
}
1010

1111
void Pipeline::BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler)
1212
{
1313
ResourceDescriptor descriptor = {};
14-
descriptor.slotIndex = slotIndex;
15-
descriptor.type = ResourceType::Sampler;
14+
descriptor.SlotIndex = slotIndex;
15+
descriptor.Type = ResourceType::Sampler;
1616
_resources[descriptor] = static_cast<ID3D11DeviceChild*>(sampler);
1717
}
1818

src/Cpp/1-getting-started/1-3-1-ImageLibrary/ResourceDescriptor.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
#include <unordered_map>
44
#include <cstdint>
55

6-
enum class ResourceType : uint32_t {
6+
enum class ResourceType : uint32_t
7+
{
78
Texture,
89
Sampler,
910
Buffer
1011
};
1112

12-
struct ResourceDescriptor {
13-
ResourceType type;
14-
uint32_t slotIndex;
13+
struct ResourceDescriptor
14+
{
15+
ResourceType Type;
16+
uint32_t SlotIndex;
1517
};
1618

1719
namespace std
@@ -22,7 +24,7 @@ namespace std
2224
size_t operator ()(const ResourceDescriptor& resource) const noexcept
2325
{
2426
const hash<uint64_t> hash;
25-
return hash(static_cast<uint64_t>(resource.slotIndex) << 32) ^ hash(static_cast<uint32_t>(resource.type));
27+
return hash(static_cast<uint64_t>(resource.SlotIndex) << 32) ^ hash(static_cast<uint32_t>(resource.Type));
2628
}
2729
};
2830

@@ -34,8 +36,8 @@ namespace std
3436
const ResourceDescriptor& rhs) const noexcept
3537
{
3638
return
37-
lhs.slotIndex == rhs.slotIndex &&
38-
lhs.type == rhs.type;
39+
lhs.SlotIndex == rhs.SlotIndex &&
40+
lhs.Type == rhs.Type;
3941
}
4042
};
4143
}

src/Cpp/1-getting-started/1-3-2-LoadingMeshes-Refactored/DeviceContext.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ void DeviceContext::SetPipeline(const Pipeline* pipeline)
2626

2727
for (auto [descriptor, resource] : pipeline->_resources)
2828
{
29-
switch (descriptor.type)
29+
switch (descriptor.Type)
3030
{
3131
case ResourceType::Sampler:
32-
_deviceContext->PSSetSamplers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
32+
_deviceContext->PSSetSamplers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
3333
break;
3434

3535
case ResourceType::Texture:
36-
_deviceContext->PSSetShaderResources(descriptor.slotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
36+
_deviceContext->PSSetShaderResources(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
3737
break;
3838

3939
case ResourceType::Buffer:
40-
switch (descriptor.stage)
40+
switch (descriptor.Stage)
4141
{
4242
case ResourceStage::VertexStage:
43-
_deviceContext->VSSetConstantBuffers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
43+
_deviceContext->VSSetConstantBuffers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
4444
break;
4545
case ResourceStage::PixelStage:
46-
_deviceContext->PSSetConstantBuffers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
46+
_deviceContext->PSSetConstantBuffers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
4747
break;
4848
}
4949
break;
@@ -59,21 +59,35 @@ void DeviceContext::SetVertexBuffer(
5959
{
6060
D3D11_BUFFER_DESC description = {};
6161
vertexBuffer->GetDesc(&description);
62-
_deviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &_activePipeline->_vertexSize, &vertexOffset);
62+
_deviceContext->IASetVertexBuffers(
63+
0,
64+
1,
65+
&vertexBuffer,
66+
&_activePipeline->_vertexSize,
67+
&vertexOffset);
6368
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
6469
}
6570

6671
void DeviceContext::SetIndexBuffer(ID3D11Buffer* indexBuffer, uint32_t indexOffset)
6772
{
6873
D3D11_BUFFER_DESC description = {};
6974
indexBuffer->GetDesc(&description);
70-
_deviceContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT::DXGI_FORMAT_R32_UINT, indexOffset);
75+
_deviceContext->IASetIndexBuffer(
76+
indexBuffer,
77+
DXGI_FORMAT::DXGI_FORMAT_R32_UINT,
78+
indexOffset);
7179
_drawIndices = description.ByteWidth / sizeof(uint32_t);
7280
}
7381

7482
void DeviceContext::UpdateSubresource(ID3D11Buffer* buffer, const void* data) const
7583
{
76-
_deviceContext->UpdateSubresource(buffer, 0, nullptr, data, 0, 0);
84+
_deviceContext->UpdateSubresource(
85+
buffer,
86+
0,
87+
nullptr,
88+
data,
89+
0,
90+
0);
7791
}
7892

7993
void DeviceContext::Draw() const

src/Cpp/1-getting-started/1-3-2-LoadingMeshes-Refactored/Pipeline.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
void Pipeline::BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture)
44
{
55
ResourceDescriptor descriptor = {};
6-
descriptor.slotIndex = slotIndex;
7-
descriptor.type = ResourceType::Texture;
6+
descriptor.SlotIndex = slotIndex;
7+
descriptor.Type = ResourceType::Texture;
88
_resources[descriptor] = static_cast<ID3D11DeviceChild*>(texture);
99
}
1010

1111
void Pipeline::BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler)
1212
{
1313
ResourceDescriptor descriptor = {};
14-
descriptor.slotIndex = slotIndex;
15-
descriptor.type = ResourceType::Sampler;
14+
descriptor.SlotIndex = slotIndex;
15+
descriptor.Type = ResourceType::Sampler;
1616
_resources[descriptor] = static_cast<ID3D11DeviceChild*>(sampler);
1717
}
1818

1919
void Pipeline::BindVertexStageConstantBuffer(uint32_t slotIndex, ID3D11Buffer* buffer)
2020
{
2121
ResourceDescriptor descriptor = {};
22-
descriptor.slotIndex = slotIndex;
23-
descriptor.stage = ResourceStage::VertexStage;
24-
descriptor.type = ResourceType::Buffer;
22+
descriptor.SlotIndex = slotIndex;
23+
descriptor.Stage = ResourceStage::VertexStage;
24+
descriptor.Type = ResourceType::Buffer;
2525
_resources[descriptor] = static_cast<ID3D11DeviceChild*>(buffer);
2626
}
2727

src/Cpp/1-getting-started/1-3-2-LoadingMeshes-Refactored/ResourceDescriptor.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ enum class ResourceStage : uint32_t
1616
PixelStage
1717
};
1818

19-
struct ResourceDescriptor {
20-
ResourceType type;
21-
ResourceStage stage;
22-
uint32_t slotIndex;
19+
struct ResourceDescriptor
20+
{
21+
ResourceType Type;
22+
ResourceStage Stage;
23+
uint32_t SlotIndex;
2324
};
2425

2526
namespace std
@@ -30,7 +31,7 @@ namespace std
3031
size_t operator ()(const ResourceDescriptor& resource) const noexcept
3132
{
3233
const hash<uint64_t> hash;
33-
return hash(static_cast<uint64_t>(resource.slotIndex) << 32) ^ hash(static_cast<uint32_t>(resource.type));
34+
return hash(static_cast<uint64_t>(resource.SlotIndex) << 32) ^ hash(static_cast<uint32_t>(resource.Type));
3435
}
3536
};
3637

@@ -42,8 +43,8 @@ namespace std
4243
const ResourceDescriptor& rhs) const noexcept
4344
{
4445
return
45-
lhs.slotIndex == rhs.slotIndex &&
46-
lhs.type == rhs.type;
46+
lhs.SlotIndex == rhs.SlotIndex &&
47+
lhs.Type == rhs.Type;
4748
}
4849
};
4950
}

src/Cpp/1-getting-started/1-3-2-LoadingMeshes/DeviceContext.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ void DeviceContext::SetPipeline(const Pipeline* pipeline)
2626

2727
for (auto [descriptor, resource] : pipeline->_resources)
2828
{
29-
switch (descriptor.type)
29+
switch (descriptor.Type)
3030
{
3131
case ResourceType::Sampler:
32-
_deviceContext->PSSetSamplers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
32+
_deviceContext->PSSetSamplers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11SamplerState**>(&resource));
3333
break;
3434

3535
case ResourceType::Texture:
36-
_deviceContext->PSSetShaderResources(descriptor.slotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
36+
_deviceContext->PSSetShaderResources(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11ShaderResourceView**>(&resource));
3737
break;
3838

3939
case ResourceType::Buffer:
40-
switch (descriptor.stage)
40+
switch (descriptor.Stage)
4141
{
4242
case ResourceStage::VertexStage:
43-
_deviceContext->VSSetConstantBuffers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
43+
_deviceContext->VSSetConstantBuffers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
4444
break;
4545
case ResourceStage::PixelStage:
46-
_deviceContext->PSSetConstantBuffers(descriptor.slotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
46+
_deviceContext->PSSetConstantBuffers(descriptor.SlotIndex, 1, reinterpret_cast<ID3D11Buffer**>(&resource));
4747
break;
4848
}
4949
break;
@@ -59,21 +59,35 @@ void DeviceContext::SetVertexBuffer(
5959
{
6060
D3D11_BUFFER_DESC description = {};
6161
vertexBuffer->GetDesc(&description);
62-
_deviceContext->IASetVertexBuffers(0, 1, &vertexBuffer, &_activePipeline->_vertexSize, &vertexOffset);
62+
_deviceContext->IASetVertexBuffers(
63+
0,
64+
1,
65+
&vertexBuffer,
66+
&_activePipeline->_vertexSize,
67+
&vertexOffset);
6368
_drawVertices = description.ByteWidth / _activePipeline->_vertexSize;
6469
}
6570

6671
void DeviceContext::SetIndexBuffer(ID3D11Buffer* indexBuffer, uint32_t indexOffset)
6772
{
6873
D3D11_BUFFER_DESC description = {};
6974
indexBuffer->GetDesc(&description);
70-
_deviceContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT::DXGI_FORMAT_R32_UINT, indexOffset);
75+
_deviceContext->IASetIndexBuffer(
76+
indexBuffer,
77+
DXGI_FORMAT::DXGI_FORMAT_R32_UINT,
78+
indexOffset);
7179
_drawIndices = description.ByteWidth / sizeof(uint32_t);
7280
}
7381

7482
void DeviceContext::UpdateSubresource(ID3D11Buffer* buffer, const void* data) const
7583
{
76-
_deviceContext->UpdateSubresource(buffer, 0, nullptr, data, 0, 0);
84+
_deviceContext->UpdateSubresource(
85+
buffer,
86+
0,
87+
nullptr,
88+
data,
89+
0,
90+
0);
7791
}
7892

7993
void DeviceContext::Draw() const

0 commit comments

Comments
 (0)