Skip to content

Commit

Permalink
Remove the shader input IsOffChip
Browse files Browse the repository at this point in the history
This SGPR was originally for pre-GFX9 when tessellation on-chip mode is
available. Now, this SGPR is necessary when merged shader doesn't
provide it since tessellation is always in off-chip mode.

Also, always make the SGPR corresponding to offChipLdsBase present
because we are always on off-chip tessellation mode.
  • Loading branch information
amdrexu committed Dec 4, 2023
1 parent 7eb4d8a commit 2e2ebcd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
1 change: 0 additions & 1 deletion lgc/include/lgc/patch/ShaderInputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ enum class ShaderInput : unsigned {
GsWaveId, // GS wave ID

// Unmerged hardware ES SGPRs
IsOffChip, // is_off_chip
EsGsOffset, // ES to GS offset

// Unmerged hardware HS SGPRs
Expand Down
8 changes: 1 addition & 7 deletions lgc/patch/NggPrimShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3118,9 +3118,7 @@ void NggPrimShader::runEs(ArrayRef<Argument *> args) {
if (m_hasTes) {
// Set up system value SGPRs
if (m_pipelineState->isTessOffChip()) {
Value *isOffChip = PoisonValue::get(m_builder.getInt32Ty()); // Unused
esArgs.push_back(m_hasGs ? offChipLdsBase : isOffChip);
esArgs.push_back(m_hasGs ? isOffChip : offChipLdsBase);
esArgs.push_back(offChipLdsBase);
}

if (m_hasGs)
Expand Down Expand Up @@ -3336,8 +3334,6 @@ Value *NggPrimShader::runPartEs(ArrayRef<Argument *> args, Value *position) {
if (m_hasTes) {
// Set up system value SGPRs
if (m_pipelineState->isTessOffChip()) {
Value *isOffChip = PoisonValue::get(m_builder.getInt32Ty()); // Unused
partEsArgs.push_back(isOffChip);
partEsArgs.push_back(offChipLdsBase);
}

Expand Down Expand Up @@ -7511,8 +7507,6 @@ Value *NggPrimShader::fetchXfbOutput(Function *target, ArrayRef<Argument *> args
if (m_hasTes) {
// Set up system value SGPRs
if (m_pipelineState->isTessOffChip()) {
Value *isOffChip = PoisonValue::get(m_builder.getInt32Ty()); // Unused
xfbFetcherArgs.push_back(isOffChip);
xfbFetcherArgs.push_back(offChipLdsBase);
}

Expand Down
27 changes: 5 additions & 22 deletions lgc/patch/ShaderInputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ const char *ShaderInputs::getInputName(ShaderInput inputKind) {
return "GsVsOffset";
case ShaderInput::GsWaveId:
return "GsWaveId";
case ShaderInput::IsOffChip:
return "IsOffChip";
case ShaderInput::EsGsOffset:
return "EsGsOffset";
case ShaderInput::TfBufferBase:
Expand Down Expand Up @@ -458,8 +456,7 @@ static const ShaderInputDesc VsAsVsSgprInputs[] = {

// SGPRs: TES as hardware ES
static const ShaderInputDesc TesAsEsSgprInputs[] = {
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tes.offChipLdsBase)},
{ShaderInput::IsOffChip, 0},
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tes.offChipLdsBase), true},
{ShaderInput::EsGsOffset, offsetof(InterfaceData, entryArgIdxs.tes.esGsOffset), true},
};

Expand All @@ -471,12 +468,12 @@ static const ShaderInputDesc TesAsVsSgprInputs[] = {
{ShaderInput::StreamOutOffset1, offsetof(InterfaceData, entryArgIdxs.tes.streamOutData.streamOffsets[1])},
{ShaderInput::StreamOutOffset2, offsetof(InterfaceData, entryArgIdxs.tes.streamOutData.streamOffsets[2])},
{ShaderInput::StreamOutOffset3, offsetof(InterfaceData, entryArgIdxs.tes.streamOutData.streamOffsets[3])},
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tes.offChipLdsBase)},
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tes.offChipLdsBase), true},
};

// SGPRs: TCS
static const ShaderInputDesc TcsSgprInputs[] = {
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tcs.offChipLdsBase)},
{ShaderInput::OffChipLdsBase, offsetof(InterfaceData, entryArgIdxs.tcs.offChipLdsBase), true},
{ShaderInput::TfBufferBase, offsetof(InterfaceData, entryArgIdxs.tcs.tfBufferBase), true},
};

Expand Down Expand Up @@ -608,25 +605,11 @@ uint64_t ShaderInputs::getShaderArgTys(PipelineState *pipelineState, ShaderStage
getShaderInputUsage(shaderStage, ShaderInput::InstanceId)->enable();
}
break;
case ShaderStageTessControl:
if (pipelineState->isTessOffChip()) {
// LDS buffer base for off-chip
getShaderInputUsage(shaderStage, ShaderInput::OffChipLdsBase)->enable();
}
break;
case ShaderStageTessEval:
if (pipelineState->isTessOffChip()) {
// LDS buffer base for off-chip
getShaderInputUsage(shaderStage, ShaderInput::OffChipLdsBase)->enable();
// is_off_chip register. Enabling it here only has an effect when TES is hardware ES.
getShaderInputUsage(shaderStage, ShaderInput::IsOffChip)->enable();
}
if (!hasGs) {
// TES as hardware VS: handle HW stream-out. StreamOutInfo is required for off-chip even if there is no
// stream-out.
if (pipelineState->isTessOffChip() || enableHwXfb)
getShaderInputUsage(shaderStage, ShaderInput::StreamOutInfo)->enable();
// TES as hardware VS: handle HW stream-out.
if (enableHwXfb) {
getShaderInputUsage(shaderStage, ShaderInput::StreamOutInfo)->enable();
getShaderInputUsage(shaderStage, ShaderInput::StreamOutWriteIndex)->enable();
for (unsigned i = 0; i < MaxTransformFeedbackBuffers; ++i) {
if (xfbStrides[i] > 0)
Expand Down

0 comments on commit 2e2ebcd

Please sign in to comment.