Skip to content

Commit 7cd5ae1

Browse files
Add a Minimal Mesh Shader Test that runs on the DX12 backend. (#1175)
1 parent 6328072 commit 7cd5ae1

11 files changed

Lines changed: 407 additions & 83 deletions

File tree

include/API/Encoder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ class RenderEncoder : public CommandEncoder {
109109
uint32_t InstanceCount,
110110
uint32_t FirstVertex = 0,
111111
uint32_t FirstInstance = 0) = 0;
112+
113+
virtual llvm::Error dispatchMesh(const PipelineState &PSO,
114+
uint32_t GroupCountX, uint32_t GroupCountY,
115+
uint32_t GroupCountZ) = 0;
112116
};
113117

114118
} // namespace offloadtest

include/Support/Pipeline.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,25 @@
2626

2727
namespace offloadtest {
2828

29-
enum class Stages { Compute, Vertex, Pixel };
29+
enum class Stages {
30+
// Compute
31+
Compute,
32+
33+
// Traditional Raster
34+
Vertex,
35+
Pixel,
36+
37+
// Mesh Shader Raster
38+
Amplification,
39+
Mesh
40+
};
3041
inline constexpr std::array AllStages = {
31-
Stages::Compute,
32-
Stages::Vertex,
33-
Stages::Pixel,
42+
Stages::Compute, Stages::Vertex, Stages::Pixel,
43+
Stages::Amplification, Stages::Mesh,
3444
};
3545
inline constexpr size_t NumStages = AllStages.size();
3646

37-
enum class ShaderPipelineKind { Compute, TraditionalRaster };
47+
enum class ShaderPipelineKind { Compute, TraditionalRaster, MeshShaderRaster };
3848

3949
enum class Rule { BufferExact, BufferFloatULP, BufferFloatEpsilon };
4050

@@ -503,6 +513,12 @@ struct Pipeline {
503513
bool isTraditionalRaster() const {
504514
return Kind == ShaderPipelineKind::TraditionalRaster;
505515
}
516+
bool isMeshShaderRaster() const {
517+
return Kind == ShaderPipelineKind::MeshShaderRaster;
518+
}
519+
bool isRaster() const {
520+
return isTraditionalRaster() || isMeshShaderRaster();
521+
}
506522
};
507523
} // namespace offloadtest
508524

@@ -713,6 +729,8 @@ template <> struct ScalarEnumerationTraits<offloadtest::Stages> {
713729
ENUM_CASE(Compute);
714730
ENUM_CASE(Vertex);
715731
ENUM_CASE(Pixel);
732+
ENUM_CASE(Amplification);
733+
ENUM_CASE(Mesh);
716734
#undef ENUM_CASE
717735
}
718736
};

lib/API/DX/DXFeatures.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ static ArrayRef<EnumEntry<RootSignature>> getRootSignatures() {
3434
return ArrayRef(RootSignatureNames);
3535
}
3636

37+
#define MESH_SHADER_TIER_ENUM(NewCase, Str, Value) {#Str, NewCase},
38+
static const EnumEntry<directx::MeshShaderTier> MeshShaderTierNames[]{
39+
#include "DXFeatures.def"
40+
};
41+
42+
static ArrayRef<EnumEntry<MeshShaderTier>> getMeshShaderTiers() {
43+
return ArrayRef(MeshShaderTierNames);
44+
}
45+
3746
template <typename T>
3847
static std::string enumEntryToString(ArrayRef<EnumEntry<T>> EnumValues,
3948
T Value) {
@@ -52,3 +61,8 @@ std::string CapabilityPrinter<directx::RootSignature>::toString(
5261
const directx::RootSignature &V) {
5362
return enumEntryToString(getRootSignatures(), V);
5463
}
64+
65+
std::string CapabilityPrinter<directx::MeshShaderTier>::toString(
66+
const directx::MeshShaderTier &V) {
67+
return enumEntryToString(getMeshShaderTiers(), V);
68+
}

lib/API/DX/DXFeatures.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ ROOT_SIGNATURE_ENUM(RootSig_v1_2, 1.2, 0x3)
2222
#undef ROOT_SIGNATURE_ENUM
2323
#endif
2424

25+
#ifdef MESH_SHADER_TIER_ENUM
26+
MESH_SHADER_TIER_ENUM(MeshShaderNotSupported, NotSupported, 0)
27+
MESH_SHADER_TIER_ENUM(MeshShaderTier1, Tier1,10)
28+
#undef MESH_SHADER_TIER_ENUM
29+
#endif
30+
2531
#ifdef D3D_FEATURE_ENUM
2632
D3D_FEATURE_ENUM(directx::ShaderModel, HighestShaderModel)
2733
D3D_FEATURE_ENUM(directx::RootSignature, HighestRootSignatureVersion)
34+
D3D_FEATURE_ENUM(directx::MeshShaderTier, MeshShaderTier)
2835
#undef D3D_FEATURE_ENUM
2936
#endif
3037

lib/API/DX/DXFeatures.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ enum RootSignature {
3232
#include "DXFeatures.def"
3333
};
3434

35+
#define MESH_SHADER_TIER_ENUM(NewCase, Str, Value) NewCase = Value,
36+
enum MeshShaderTier {
37+
#include "DXFeatures.def"
38+
};
39+
3540
} // namespace directx
3641

3742
template <> struct CapabilityPrinter<directx::ShaderModel> {
@@ -42,6 +47,10 @@ template <> struct CapabilityPrinter<directx::RootSignature> {
4247
static std::string toString(const directx::RootSignature &V);
4348
};
4449

50+
template <> struct CapabilityPrinter<directx::MeshShaderTier> {
51+
static std::string toString(const directx::MeshShaderTier &V);
52+
};
53+
4554
} // namespace offloadtest
4655

4756
#endif // OFFLOADTEST_API_DXFEATURES_H

0 commit comments

Comments
 (0)