Skip to content

Commit 252cbe5

Browse files
committed
preparements for split barriers
1 parent f3cb229 commit 252cbe5

Some content is hidden

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

85 files changed

+693
-225
lines changed

sources/DirectXFramework/D3D/Shaders.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,21 @@ namespace D3D
6767
std::unique_ptr<std::string> shader_include::load_file(std::string pFileName)
6868
{
6969

70-
auto sig = pFileName.find("sig:");
70+
/*auto sig = pFileName.find("sig:");
7171
if (sig!=std::string::npos)
7272
{
7373
pFileName = "autogen/" + pFileName.substr(sig+4) +".h";
7474
}
75+
76+
*/
77+
78+
auto sig = pFileName.find("autogen");
79+
if (sig != std::string::npos)
80+
{
81+
autogen.emplace_back(pFileName);
82+
}
83+
84+
7585
std::string file_name = dir + pFileName;
7686
auto file = FileSystem::get().get_file(convert(file_name));
7787

sources/DirectXFramework/DX12/CommandList.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ namespace DX12
10811081
void set_table(UINT index, const HandleTableLight& table)
10821082
{
10831083

1084-
1084+
assert(table.valid());
1085+
10851086
auto& row = tables[index];
10861087

10871088
row.type = type;

sources/DirectXFramework/DX12/PipelineState.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,32 @@ namespace DX12
9494
if (desc.root_signature)
9595
psoDesc.pRootSignature = desc.root_signature->get_native().Get();
9696

97+
slots.clear();
9798
if (desc.vertex)
99+
{
98100
psoDesc.VS = { reinterpret_cast<UINT8*>(const_cast<char*>(desc.vertex->get_blob().data())), static_cast<UINT>(desc.vertex->get_blob().size()) };
99-
101+
slots.merge(desc.vertex->slots_usage);
102+
}
100103
if (desc.pixel)
104+
{
101105
psoDesc.PS = { reinterpret_cast<UINT8*>(const_cast<char*>(desc.pixel->get_blob().data())), static_cast<UINT>(desc.pixel->get_blob().size()) };
102-
106+
slots.merge(desc.pixel->slots_usage);
107+
}
103108
if (desc.geometry)
109+
{
104110
psoDesc.GS = { reinterpret_cast<UINT8*>(const_cast<char*>(desc.geometry->get_blob().data())), static_cast<UINT>(desc.geometry->get_blob().size()) };
105-
111+
slots.merge(desc.geometry->slots_usage);
112+
}
106113
if (desc.domain)
114+
{
107115
psoDesc.DS = { reinterpret_cast<UINT8*>(const_cast<char*>(desc.domain->get_blob().data())), static_cast<UINT>(desc.domain->get_blob().size()) };
108-
116+
slots.merge(desc.domain->slots_usage);
117+
}
109118
if (desc.hull)
119+
{
110120
psoDesc.HS = { reinterpret_cast<UINT8*>(const_cast<char*>(desc.hull->get_blob().data())), static_cast<UINT>(desc.hull->get_blob().size()) };
111-
121+
slots.merge(desc.hull->slots_usage);
122+
}
112123
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
113124

114125
psoDesc.RasterizerState.CullMode = desc.rasterizer.cull_mode;

sources/DirectXFramework/DX12/PipelineState.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ namespace DX12
320320
};
321321
class PipelineStateBase: public Trackable<TrackedPipeline>
322322
{
323-
324-
protected:
325323

324+
protected:
325+
UsedSlots slots;
326326

327327
std::string cache;
328328

sources/DirectXFramework/DX12/Shader.h

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,55 @@
11
#pragma once
22

3+
std::map<UINT, UINT> get_used_slots(std::string slot_name);
34

45
namespace DX12
56
{
67
class PipelineStateBase;
78

9+
class UsedSlots
10+
{
11+
std::map<UINT, UINT> slots_usage;
12+
public:
813

14+
void merge(resource_file_depender & depender)
15+
{
16+
for (auto& d : depender.get_files())
17+
{
18+
auto autogen_start = d.file_name.find(L"autogen");
19+
if (autogen_start != std::wstring::npos)
20+
{
21+
auto autogen_end = autogen_start + 6;
22+
23+
auto last_slash = d.file_name.find_first_of(L"\\/", autogen_end);
24+
25+
if (last_slash == autogen_end + 1)
26+
{
27+
auto point = d.file_name.find(L".", last_slash);
28+
29+
auto name = d.file_name.substr(last_slash + 1, point - last_slash - 1);
30+
31+
slots_usage.merge(get_used_slots(convert(name)));
32+
}
33+
}
34+
}
35+
}
36+
void merge(UsedSlots& other)
37+
{
38+
39+
slots_usage.merge(other.slots_usage);
40+
}
41+
void clear()
42+
{
43+
slots_usage.clear();
44+
}
45+
private:
46+
friend class boost::serialization::access;
47+
template<class Archive>
48+
void serialize(Archive& ar, const unsigned int)
49+
{
50+
ar& NVP(slots_usage);
51+
}
52+
};
953

1054
template<class _shader_type>
1155
class Shader : public resource_manager<_shader_type, D3D::shader_header>
@@ -63,7 +107,7 @@ namespace DX12
63107
public:
64108
static Cache<std::string, size_t> shader_ids;
65109

66-
110+
UsedSlots slots_usage;
67111
Events::Event<void> on_change;
68112
const MD5& get_hash() const
69113
{
@@ -102,6 +146,7 @@ namespace DX12
102146
result->own_id();
103147
result->compile();
104148
result->hash = MD5(result->blob);
149+
result->slots_usage.merge(depender);
105150
return result;
106151
}
107152

@@ -134,6 +179,9 @@ namespace DX12
134179
result->compile();
135180
result->own_id();
136181
result->hash = MD5(result->blob);
182+
result->slots_usage.merge(depender);
183+
184+
137185
return result;
138186
}
139187
private:
@@ -144,7 +192,8 @@ namespace DX12
144192
ar& NVP(blob);
145193
ar& NVP(reflection);
146194
ar& NVP(hash);
147-
195+
ar& NVP(slots_usage);
196+
148197
if (Archive::is_loading::value)
149198
{
150199
own_id();

sources/DirectXFramework/SIG/Slots.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11

2-
template<class Slot>
2+
template<SlotID ID, class Table, class Slot>
33
struct CompiledData
44
{
55
Render::ResourceAddress cb;
66
Render::HandleTableLight table_srv;
77
Render::HandleTableLight table_uav;
88
Render::HandleTableLight table_smp;
99

10-
const CompiledData<Slot>& set(Render::SignatureDataSetter& graphics) const
10+
const CompiledData<ID, Table, Slot>& set(Render::SignatureDataSetter& graphics) const
1111
{
12-
if constexpr (TableHasSRV<Slot>) if (table_srv.is_valid()) graphics.set_table<Render::HandleType::SRV>(Slot::SRV_ID, table_srv);
13-
if constexpr (TableHasSMP<Slot>) if (table_smp.is_valid()) graphics.set_table<Render::HandleType::SMP>(Slot::SMP_ID, table_smp);
14-
if constexpr (TableHasUAV<Slot>) if (table_uav.is_valid()) graphics.set_table<Render::HandleType::UAV>(Slot::UAV_ID, table_uav);
12+
if constexpr (HasSRV<Table>) graphics.set_table<Render::HandleType::SRV>(Slot::SRV_ID, table_srv);
13+
if constexpr (HasSMP<Table>) graphics.set_table<Render::HandleType::SMP>(Slot::SMP_ID, table_smp);
14+
if constexpr (HasUAV<Table>) graphics.set_table<Render::HandleType::UAV>(Slot::UAV_ID, table_uav);
1515

16-
if (cb)
17-
graphics.set_cb(Slot::CB_ID, cb);
16+
if constexpr (HasCB<Table>) graphics.set_cb(Slot::CB_ID, cb);
1817

1918
return *this;
2019
}
2120

2221
};
2322

24-
template<class Table, class _Slot = Table::Slot>
23+
template<SlotID ID, class Table, class _Slot = Table::Slot>
2524
struct DataHolder : public Table
2625
{
2726
using Table::Table;
2827
using Slot = _Slot;
29-
using Compiled = CompiledData<Slot>;
30-
28+
using Compiled = CompiledData<ID, Table, Slot>;
29+
/*
3130
template<class Context, class SRV>
32-
void place_srv(CompiledData<Slot>& compiled, Context& context, SRV& srv) const
31+
void place_srv(Compiled& compiled, Context& context, SRV& srv) const
3332
{
3433
compiled.table_srv = context.get_gpu_heap(Render::DescriptorHeapType::CBV_SRV_UAV).place(sizeof(srv) / sizeof(Render::Handle));
3534
auto ptr = reinterpret_cast<Render::Handle*>(&srv);
@@ -41,7 +40,7 @@ struct DataHolder : public Table
4140
}
4241
4342
template<class Context, class SRV>
44-
void place_srv(CompiledData<Slot>& compiled, Context& context, SRV& srv, Render::Bindless& bindless) const
43+
void place_srv(Compiled& compiled, Context& context, SRV& srv, Render::Bindless& bindless) const
4544
{
4645
compiled.table_srv = context.get_gpu_heap(Render::DescriptorHeapType::CBV_SRV_UAV).place(sizeof(srv) / sizeof(Render::Handle));
4746
auto ptr = reinterpret_cast<Render::Handle*>(&srv);
@@ -52,9 +51,10 @@ struct DataHolder : public Table
5251
compiled.table_srv[i].place(*handle);
5352
}
5453
}
55-
54+
*/
55+
5656
template<class Context, class UAV>
57-
void place_uav(CompiledData<Slot>& compiled, Context& context, UAV& uav) const
57+
void place_uav(Compiled& compiled, Context& context, UAV& uav) const
5858
{
5959

6060
compiled.table_uav = context.get_gpu_heap(Render::DescriptorHeapType::CBV_SRV_UAV).place(sizeof(uav) / sizeof(Render::Handle));
@@ -72,7 +72,7 @@ struct DataHolder : public Table
7272
}
7373

7474
template<class Context, class SMP>
75-
void place_smp(CompiledData<Slot>& compiled, Context& context, SMP& smp) const
75+
void place_smp(Compiled& compiled, Context& context, SMP& smp) const
7676
{
7777

7878
compiled.table_smp = context.get_gpu_heap(Render::DescriptorHeapType::SAMPLER).place(sizeof(smp) / sizeof(Render::Handle));
@@ -86,10 +86,10 @@ struct DataHolder : public Table
8686

8787

8888
template<class Context>
89-
CompiledData<Slot> compile(Context& context) const
89+
Compiled compile(Context& context) const
9090
{
9191

92-
CompiledData<Slot> compiled;
92+
Compiled compiled;
9393

9494

9595
if constexpr (HasSRV<Table> || HasBindless<Table>)

sources/FileSystem/FileSystem/FileSystem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ class resource_file_depender
179179

180180
bool need_update();
181181
private:
182+
183+
inline const std::wstring& get_name() const { return file_name; }
182184
friend class boost::serialization::access;
183185
template<class Archive>
184186
void serialize(Archive& ar, const unsigned int)
@@ -188,6 +190,9 @@ class resource_file_depender
188190
};
189191
std::vector<depender> files;
190192
public:
193+
194+
inline const std::vector<depender>& get_files() const { return files; }
195+
191196
void add_depend(std::shared_ptr<file> _file);
192197
bool need_update();
193198
void clear();

sources/RenderSystem/Renderer/MeshRenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ void mesh_renderer::render_meshes(MeshRenderContext::ptr mesh_render_context, S
393393

394394
compiledScene.set(graphics);
395395
compiledFrame.set(graphics);
396+
if (mesh_render_context->render_type == RENDER_TYPE::VOXEL)
396397
mesh_render_context->voxelization_compiled.set(graphics);
397398
}
398399
{

sources/RenderSystem/autogen/enums.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,91 @@ enum class PSO: int
6262
TOTAL
6363
, GENERATE_OPS
6464
};
65+
enum class SlotID: unsigned int
66+
{
67+
TextureRenderer = "TextureRenderer"_crc32 ,
68+
BRDF = "BRDF"_crc32 ,
69+
DebugStruct = "DebugStruct"_crc32 ,
70+
DebugInfo = "DebugInfo"_crc32 ,
71+
FontRendering = "FontRendering"_crc32 ,
72+
FontRenderingConstants = "FontRenderingConstants"_crc32 ,
73+
Glyph = "Glyph"_crc32 ,
74+
FontRenderingGlyphs = "FontRenderingGlyphs"_crc32 ,
75+
Frustum = "Frustum"_crc32 ,
76+
Camera = "Camera"_crc32 ,
77+
FrameInfo = "FrameInfo"_crc32 ,
78+
MaterialInfo = "MaterialInfo"_crc32 ,
79+
mesh_vertex_input = "mesh_vertex_input"_crc32 ,
80+
AABB = "AABB"_crc32 ,
81+
node_data = "node_data"_crc32 ,
82+
MeshInfo = "MeshInfo"_crc32 ,
83+
DrawIndexedArguments = "DrawIndexedArguments"_crc32 ,
84+
DispatchArguments = "DispatchArguments"_crc32 ,
85+
GPUAddress = "GPUAddress"_crc32 ,
86+
MeshInstance = "MeshInstance"_crc32 ,
87+
CommandData = "CommandData"_crc32 ,
88+
MeshCommandData = "MeshCommandData"_crc32 ,
89+
MaterialCommandData = "MaterialCommandData"_crc32 ,
90+
GatherPipelineGlobal = "GatherPipelineGlobal"_crc32 ,
91+
GatherPipeline = "GatherPipeline"_crc32 ,
92+
BoxInfo = "BoxInfo"_crc32 ,
93+
GatherBoxes = "GatherBoxes"_crc32 ,
94+
DrawBoxes = "DrawBoxes"_crc32 ,
95+
InitDispatch = "InitDispatch"_crc32 ,
96+
GatherMeshesBoxes = "GatherMeshesBoxes"_crc32 ,
97+
MipMapping = "MipMapping"_crc32 ,
98+
CopyTexture = "CopyTexture"_crc32 ,
99+
DownsampleDepth = "DownsampleDepth"_crc32 ,
100+
GBuffer = "GBuffer"_crc32 ,
101+
GBufferDownsample = "GBufferDownsample"_crc32 ,
102+
GBufferQuality = "GBufferQuality"_crc32 ,
103+
PSSMConstants = "PSSMConstants"_crc32 ,
104+
PSSMData = "PSSMData"_crc32 ,
105+
PSSMDataGlobal = "PSSMDataGlobal"_crc32 ,
106+
PSSMLighting = "PSSMLighting"_crc32 ,
107+
RaytracingRays = "RaytracingRays"_crc32 ,
108+
RayCone = "RayCone"_crc32 ,
109+
RayPayload = "RayPayload"_crc32 ,
110+
ShadowPayload = "ShadowPayload"_crc32 ,
111+
Triangle = "Triangle"_crc32 ,
112+
Raytracing = "Raytracing"_crc32 ,
113+
SceneData = "SceneData"_crc32 ,
114+
SkyData = "SkyData"_crc32 ,
115+
SkyFace = "SkyFace"_crc32 ,
116+
EnvFilter = "EnvFilter"_crc32 ,
117+
EnvSource = "EnvSource"_crc32 ,
118+
SMAA_Global = "SMAA_Global"_crc32 ,
119+
SMAA_Weights = "SMAA_Weights"_crc32 ,
120+
SMAA_Blend = "SMAA_Blend"_crc32 ,
121+
Countour = "Countour"_crc32 ,
122+
DrawStencil = "DrawStencil"_crc32 ,
123+
PickerBuffer = "PickerBuffer"_crc32 ,
124+
Instance = "Instance"_crc32 ,
125+
Color = "Color"_crc32 ,
126+
Test = "Test"_crc32 ,
127+
vertex_input = "vertex_input"_crc32 ,
128+
NinePatch = "NinePatch"_crc32 ,
129+
ColorRect = "ColorRect"_crc32 ,
130+
FlowGraph = "FlowGraph"_crc32 ,
131+
VSLine = "VSLine"_crc32 ,
132+
LineRender = "LineRender"_crc32 ,
133+
VoxelTilingParams = "VoxelTilingParams"_crc32 ,
134+
VoxelInfo = "VoxelInfo"_crc32 ,
135+
Voxelization = "Voxelization"_crc32 ,
136+
VoxelScreen = "VoxelScreen"_crc32 ,
137+
VoxelOutput = "VoxelOutput"_crc32 ,
138+
VoxelBlur = "VoxelBlur"_crc32 ,
139+
VoxelUpscale = "VoxelUpscale"_crc32 ,
140+
VoxelVisibility = "VoxelVisibility"_crc32 ,
141+
VoxelMipMap = "VoxelMipMap"_crc32 ,
142+
VoxelCopy = "VoxelCopy"_crc32 ,
143+
VoxelZero = "VoxelZero"_crc32 ,
144+
VoxelLighting = "VoxelLighting"_crc32 ,
145+
VoxelDebug = "VoxelDebug"_crc32 ,
146+
DenoiserDownsample = "DenoiserDownsample"_crc32 ,
147+
TilingParams = "TilingParams"_crc32 ,
148+
DenoiserHistoryFix = "DenoiserHistoryFix"_crc32 ,
149+
FrameClassification = "FrameClassification"_crc32 ,
150+
FrameClassificationInitDispatch = "FrameClassificationInitDispatch"_crc32 ,
151+
GENERATE_OPS
152+
};

sources/RenderSystem/autogen/includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@
136136
void init_signatures();
137137
Render::RootLayout::ptr get_Signature(Layouts id);
138138
void init_pso(enum_array<PSO, PSOBase::ptr>&);
139+
std::map<UINT, UINT> get_used_slots(std::string slot_name);

0 commit comments

Comments
 (0)