summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-hlsl.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-05-17 17:27:12 -0400
committerGitHub <noreply@github.com>2022-05-17 17:27:12 -0400
commit05c4c2679ae979cfcb61e4c2acdb432c34384ddb (patch)
treeda146d2f90a28319a32bcb27ea33acec21537265 /source/slang/slang-emit-hlsl.cpp
parent39fb45484996f9d71b6551239dbf55eaaaf8db1f (diff)
Refactor prelude emit (#2236)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor how prelude output works in emit. * Small improvement to emit output. * Move around comment on target specific language directives based on review. Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
-rw-r--r--source/slang/slang-emit-hlsl.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index c319f2738..2d42aef83 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -665,20 +665,6 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
return false;
}
-void HLSLSourceEmitter::emitLayoutDirectivesImpl(TargetRequest* targetReq)
-{
- switch (targetReq->getDefaultMatrixLayoutMode())
- {
- case kMatrixLayoutMode_RowMajor:
- default:
- m_writer->emit("#pragma pack_matrix(row_major)\n");
- break;
- case kMatrixLayoutMode_ColumnMajor:
- m_writer->emit("#pragma pack_matrix(column_major)\n");
- break;
- }
-}
-
void HLSLSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerValue elementCount)
{
// In some cases we *need* to use the built-in syntax sugar for vector types,
@@ -1133,9 +1119,9 @@ void HLSLSourceEmitter::handleRequiredCapabilitiesImpl(IRInst* inst)
}
}
-void HLSLSourceEmitter::emitPreludeDirectivesImpl()
+void HLSLSourceEmitter::emitFrontMatterImpl(TargetRequest* targetReq)
{
- if( m_extensionTracker->m_requiresNVAPI )
+ if (m_extensionTracker->m_requiresNVAPI)
{
// If the generated code includes implicit NVAPI use,
// then we need to ensure that NVAPI support is included
@@ -1159,7 +1145,7 @@ void HLSLSourceEmitter::emitPreludeDirectivesImpl()
// they could pass in these `#define`s using command-line
// or API options.
//
- if( auto decor = m_irModule->getModuleInst()->findDecoration<IRNVAPISlotDecoration>() )
+ if (auto decor = m_irModule->getModuleInst()->findDecoration<IRNVAPISlotDecoration>())
{
m_writer->emit("#define NV_SHADER_EXTN_SLOT ");
m_writer->emit(decor->getRegisterName());
@@ -1171,7 +1157,7 @@ void HLSLSourceEmitter::emitPreludeDirectivesImpl()
// understanding of `space`s).
//
auto spaceName = decor->getSpaceName();
- if( spaceName != "space0" )
+ if (spaceName != "space0")
{
m_writer->emit("#define NV_SHADER_EXTN_REGISTER_SPACE ");
m_writer->emit(spaceName);
@@ -1179,6 +1165,19 @@ void HLSLSourceEmitter::emitPreludeDirectivesImpl()
}
}
}
+
+ // Emit any layout declarations
+
+ switch (targetReq->getDefaultMatrixLayoutMode())
+ {
+ case kMatrixLayoutMode_RowMajor:
+ default:
+ m_writer->emit("#pragma pack_matrix(row_major)\n");
+ break;
+ case kMatrixLayoutMode_ColumnMajor:
+ m_writer->emit("#pragma pack_matrix(column_major)\n");
+ break;
+ }
}
void HLSLSourceEmitter::emitGlobalInstImpl(IRInst* inst)