Skip to content

Commit c3c399f

Browse files
committed
Turn ShaderTable::Init into a ctor with initializer list
1 parent c6fce45 commit c3c399f

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

tools/clang/unittests/HLSLExec/DXRUtil.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,16 @@ struct Instance {
4242

4343
class ShaderTable {
4444
public:
45-
void Init(ID3D12Device *Device, int RaygenCount, int MissCount,
46-
int HitGroupCount, int RayTypeCount, int RootTableDwords) {
47-
RayTypeCount = RayTypeCount;
48-
RaygenCount = RaygenCount;
49-
MissCount = MissCount * RayTypeCount;
50-
HitGroupCount = HitGroupCount * RayTypeCount;
51-
RootTableSizeInBytes = RootTableDwords * 4;
52-
ShaderRecordSizeInBytes =
53-
ROUND_UP(RootTableSizeInBytes + SHADER_ID_SIZE_IN_BYTES,
54-
D3D12_RAYTRACING_SHADER_RECORD_BYTE_ALIGNMENT);
55-
MissStartIdx = RaygenCount;
56-
HitGroupStartIdx = MissStartIdx + MissCount;
45+
ShaderTable(ID3D12Device *Device, int RaygenCount, int MissCount,
46+
int HitGroupCount, int RayTypeCount, int RootTableDwords)
47+
: RayTypeCount(RayTypeCount), RaygenCount(RaygenCount),
48+
MissCount(MissCount * RayTypeCount),
49+
HitGroupCount(HitGroupCount * RayTypeCount),
50+
RootTableSizeInBytes(RootTableDwords * 4),
51+
ShaderRecordSizeInBytes(
52+
ROUND_UP(RootTableSizeInBytes + SHADER_ID_SIZE_IN_BYTES,
53+
D3D12_RAYTRACING_SHADER_RECORD_BYTE_ALIGNMENT)),
54+
MissStartIdx(RaygenCount), HitGroupStartIdx(MissStartIdx + MissCount) {
5755

5856
const int TotalSizeInBytes =
5957
(RaygenCount + MissCount + HitGroupCount) * ShaderRecordSizeInBytes;

tools/clang/unittests/HLSLExec/ExecutionTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,13 +2499,13 @@ CComPtr<ID3D12Resource> ExecutionTest::RunDXRTest(
24992499
VERIFY_SUCCEEDED(StateObject->QueryInterface(&StateObjectProperties));
25002500

25012501
// Create SBT
2502-
ShaderTable ShaderTable;
2503-
ShaderTable.Init(Device,
2504-
1, // raygen count
2505-
1, // miss count
2506-
UseMesh && UseProceduralGeometry ? 2 : 1, // hit group count
2507-
1, // ray type count
2508-
4 // dwords per root table
2502+
ShaderTable ShaderTable(
2503+
Device,
2504+
1, // raygen count
2505+
1, // miss count
2506+
UseMesh && UseProceduralGeometry ? 2 : 1, // hit group count
2507+
1, // ray type count
2508+
4 // dwords per root table
25092509
);
25102510

25112511
int LocalRootConsts[4] = {12, 34, 56, 78};

0 commit comments

Comments
 (0)