Skip to content

Commit 11dc29f

Browse files
authored
Support for geometry shader (o3de#17266)
* Initial Geometry shader support * Fix enabling feature and set proper number of layers * Remove Tesselation related code * Change ShaderSubStageCountMax back to 2 to support DiffuseGI Signed-off-by: Umesh Rajesh Ramchandani <[email protected]>
1 parent b174ef8 commit 11dc29f

File tree

23 files changed

+53
-91
lines changed

23 files changed

+53
-91
lines changed

Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderBuilderUtility.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ namespace AZ
225225
return RHI::ShaderHardwareStage::Fragment;
226226
case RPI::ShaderStageType::Geometry:
227227
return RHI::ShaderHardwareStage::Geometry;
228-
case RPI::ShaderStageType::TessellationControl:
229-
return RHI::ShaderHardwareStage::TessellationControl;
230-
case RPI::ShaderStageType::TessellationEvaluation:
231-
return RHI::ShaderHardwareStage::TessellationEvaluation;
232228
case RPI::ShaderStageType::Vertex:
233229
return RHI::ShaderHardwareStage::Vertex;
234230
case RPI::ShaderStageType::RayTracing:

Gems/Atom/RHI/Code/Include/Atom/RHI.Edit/ShaderPlatformInterface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ namespace AZ::RHI
4040
Invalid = static_cast<uint32_t>(-1),
4141
Vertex = 0,
4242
Geometry,
43-
TessellationControl,
44-
TessellationEvaluation,
4543
Fragment,
4644
Compute,
4745
RayTracing,

Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/DeviceFeatures.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ namespace AZ::RHI
2020
{
2121
struct DeviceFeatures
2222
{
23-
//! Whether the adapter supports tessellation shaders.
24-
bool m_tessellationShader;
25-
2623
//! Whether the adapter supports geometry shaders.
2724
bool m_geometryShader;
2825

Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/ShaderStages.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ namespace AZ::RHI
3232
//! a vertex. On certain platforms like Metal, this stage may occur after tessellation.
3333
Vertex = 0,
3434

35-
//! This virtual stage contains platform-specific stages for hardware tessellation. The specifics
36-
//! of how tessellation is achieved varies per platform. PC platforms have dedicated stages to handle this,
37-
//! while others utilize compute.
38-
Tessellation,
35+
//! This virtual stage contains shader stages that expand an input assembly stream and manipulate
36+
//! a vertex Note: Not supported on metal.
37+
Geometry,
3938

4039
//! This virtual stage contains the platform-specific stages necessary to process screen space fragments.
4140
//! Currently, on all supported platforms, this maps 1-to-1 with a hardware shader stage.
@@ -66,11 +65,11 @@ namespace AZ::RHI
6665
{
6766
None = 0,
6867
Vertex = AZ_BIT(static_cast<uint32_t>(ShaderStage::Vertex)),
69-
Tessellation = AZ_BIT(static_cast<uint32_t>(ShaderStage::Tessellation)),
68+
Geometry = AZ_BIT(static_cast<uint32_t>(ShaderStage::Geometry)),
7069
Fragment = AZ_BIT(static_cast<uint32_t>(ShaderStage::Fragment)),
7170
Compute = AZ_BIT(static_cast<uint32_t>(ShaderStage::Compute)),
7271
RayTracing = AZ_BIT(static_cast<uint32_t>(ShaderStage::RayTracing)),
73-
All = Vertex | Tessellation | Fragment | Compute | RayTracing
72+
All = Vertex | Geometry | Fragment | Compute | RayTracing
7473
};
7574

7675
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::RHI::ShaderStageMask)

Gems/Atom/RHI/Code/Include/Atom/RHI/PipelineStateDescriptor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ namespace AZ::RHI
9898
/// [Required] The vertex function to compile.
9999
ConstPtr<ShaderStageFunction> m_vertexFunction;
100100

101-
/// [Optional] The tessellation function to compile.
102-
ConstPtr<ShaderStageFunction> m_tessellationFunction;
101+
/// [Optional] The geometry function to compile.
102+
ConstPtr<ShaderStageFunction> m_geometryFunction;
103103

104104
/// [Required] The fragment function used to compile.
105105
ConstPtr<ShaderStageFunction> m_fragmentFunction;

Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ namespace AZ::RHI
413413
case ShaderHardwareStage::Fragment:
414414
return RHI::ShaderStage::Fragment;
415415
case ShaderHardwareStage::Geometry:
416-
AZ_Assert(false, "RHI currently does not support geometry shaders");
417-
return RHI::ShaderStage::Unknown;
418-
case ShaderHardwareStage::TessellationControl:
419-
case ShaderHardwareStage::TessellationEvaluation:
420-
return RHI::ShaderStage::Tessellation;
416+
return RHI::ShaderStage::Geometry;
421417
case ShaderHardwareStage::Vertex:
422418
return RHI::ShaderStage::Vertex;
423419
case ShaderHardwareStage::RayTracing:

Gems/Atom/RHI/Code/Source/RHI/PipelineStateDescriptor.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ namespace AZ::RHI
6060
{
6161
seed = TypeHash64(m_vertexFunction->GetHash(), seed);
6262
}
63-
if (m_tessellationFunction)
63+
if (m_geometryFunction)
6464
{
65-
seed = TypeHash64(m_tessellationFunction->GetHash(), seed);
65+
seed = TypeHash64(m_geometryFunction->GetHash(), seed);
6666
}
6767
if (m_fragmentFunction)
6868
{
@@ -90,12 +90,9 @@ namespace AZ::RHI
9090

9191
bool PipelineStateDescriptorForDraw::operator == (const PipelineStateDescriptorForDraw& rhs) const
9292
{
93-
return m_fragmentFunction == rhs.m_fragmentFunction &&
94-
m_pipelineLayoutDescriptor == rhs.m_pipelineLayoutDescriptor &&
95-
m_renderStates == rhs.m_renderStates &&
96-
m_vertexFunction == rhs.m_vertexFunction &&
97-
m_tessellationFunction == rhs.m_tessellationFunction &&
98-
m_inputStreamLayout == rhs.m_inputStreamLayout &&
93+
return m_fragmentFunction == rhs.m_fragmentFunction && m_pipelineLayoutDescriptor == rhs.m_pipelineLayoutDescriptor &&
94+
m_renderStates == rhs.m_renderStates && m_vertexFunction == rhs.m_vertexFunction &&
95+
m_geometryFunction == rhs.m_geometryFunction && m_inputStreamLayout == rhs.m_inputStreamLayout &&
9996
m_renderAttachmentConfiguration == rhs.m_renderAttachmentConfiguration;
10097
}
10198

Gems/Atom/RHI/DX12/Code/Include/Atom/RHI.Reflect/DX12/ShaderStageFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ namespace AZ
4040
{
4141
/// Used when the sub-stage is 1-to-1 with the virtual stage.
4242
const uint32_t Default = 0;
43-
44-
/// Tessellation is composed of two physical stages in HLSL.
45-
const uint32_t TessellationHull = 0;
46-
const uint32_t TessellationDomain = 1;
4743
}
4844

4945
const uint32_t ShaderSubStageCountMax = 2;

Gems/Atom/RHI/DX12/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace AZ
4747
RHI::Ptr<ShaderStageFunction> newShaderStageFunction = ShaderStageFunction::Create(RHI::ToRHIShaderStage(stageDescriptor.m_stageType));
4848

4949
const DX12::ShaderByteCode& byteCode = stageDescriptor.m_byteCode;
50-
const int byteCodeIndex = (stageDescriptor.m_stageType == RHI::ShaderHardwareStage::TessellationEvaluation) ? 1 : 0;
50+
const int byteCodeIndex = 0;
5151
newShaderStageFunction->SetByteCode(byteCodeIndex, byteCode);
5252

5353
newShaderStageFunction->Finalize();
@@ -61,8 +61,7 @@ namespace AZ
6161

6262
hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::Vertex;
6363
hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::Fragment;
64-
hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::TessellationControl;
65-
hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::TessellationEvaluation;
64+
hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::Geometry;
6665

6766
return hasRasterProgram;
6867
}
@@ -229,8 +228,6 @@ namespace AZ
229228
{RHI::ShaderHardwareStage::Fragment, "ps_" + shaderModelVersion},
230229
{RHI::ShaderHardwareStage::Compute, "cs_" + shaderModelVersion},
231230
{RHI::ShaderHardwareStage::Geometry, "gs_" + shaderModelVersion},
232-
{RHI::ShaderHardwareStage::TessellationControl, "hs_" + shaderModelVersion},
233-
{RHI::ShaderHardwareStage::TessellationEvaluation, "ds_" + shaderModelVersion},
234231
{RHI::ShaderHardwareStage::RayTracing, "lib_6_3"}
235232
};
236233
auto profileIt = stageToProfileName.find(shaderStageType);

Gems/Atom/RHI/DX12/Code/Source/RHI/Conversions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,8 @@ namespace AZ
11931193
return D3D12_SHADER_VISIBILITY_ALL;
11941194
case RHI::ShaderStageMask::Vertex:
11951195
return D3D12_SHADER_VISIBILITY_VERTEX;
1196-
case RHI::ShaderStageMask::Tessellation:
1197-
return D3D12_SHADER_VISIBILITY_ALL;
1196+
case RHI::ShaderStageMask::Geometry:
1197+
return D3D12_SHADER_VISIBILITY_GEOMETRY;
11981198
case RHI::ShaderStageMask::Fragment:
11991199
return D3D12_SHADER_VISIBILITY_PIXEL;
12001200
case RHI::ShaderStageMask::Compute:

0 commit comments

Comments
 (0)