summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-lower-buffer-element-type.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-20 12:24:00 -0800
committerGitHub <noreply@github.com>2024-02-20 12:24:00 -0800
commit4d20fd329956ac89408b1628a8291fea01bc9a6d (patch)
tree8e62d9c1ec05142fd25d0b31073fdb56d44691b0 /source/slang/slang-ir-lower-buffer-element-type.cpp
parent8e9b61e3bac69dbb37a1451b62302e688a017ced (diff)
Refactor compiler option representations. (#3598)
* Refactor compiler option representation. * Fix binary compatibility. * Add a test for specifying compiler options at link time. * Fix binary compatibility. * Fix binary compatibility. * Fix backward compatibility on matrix layout. * Fix. * Fix. * Fix. * Fix gfx. * Fix gfx. * Fix dynamic dispatch. * Polish.
Diffstat (limited to 'source/slang/slang-ir-lower-buffer-element-type.cpp')
-rw-r--r--source/slang/slang-ir-lower-buffer-element-type.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp
index 182b101df..5c797ab23 100644
--- a/source/slang/slang-ir-lower-buffer-element-type.cpp
+++ b/source/slang/slang-ir-lower-buffer-element-type.cpp
@@ -23,9 +23,9 @@ namespace Slang
Dictionary<IRType*, LoweredElementTypeInfo> mapLoweredTypeToInfo[(int)IRTypeLayoutRuleName::_Count];
SlangMatrixLayoutMode defaultMatrixLayout = SLANG_MATRIX_LAYOUT_ROW_MAJOR;
- TargetRequest* target;
+ TargetProgram* target;
- LoweredElementTypeContext(TargetRequest* target, SlangMatrixLayoutMode inDefaultMatrixLayout)
+ LoweredElementTypeContext(TargetProgram* target, SlangMatrixLayoutMode inDefaultMatrixLayout)
: target(target), defaultMatrixLayout(inDefaultMatrixLayout)
{}
@@ -230,7 +230,7 @@ namespace Slang
{
// For spirv, we always want to lower all matrix types, because matrix types
// are considered abstract types.
- if (!target->shouldEmitSPIRVDirectly())
+ if (!target->getOptionSet().shouldEmitSPIRVDirectly())
{
// For other targets, we only lower the matrix types if they differ from the default
// matrix layout.
@@ -257,7 +257,7 @@ namespace Slang
auto vectorType = builder.getVectorType(matrixType->getElementType(),
isColMajor?matrixType->getRowCount():matrixType->getColumnCount());
IRSizeAndAlignment elementSizeAlignment;
- getSizeAndAlignment(target, rules, vectorType, &elementSizeAlignment);
+ getSizeAndAlignment(target->getOptionSet(), rules, vectorType, &elementSizeAlignment);
elementSizeAlignment = rules->alignCompositeElement(elementSizeAlignment);
auto arrayType = builder.getArrayType(
@@ -279,7 +279,7 @@ namespace Slang
// For spirv backend, we always want to lower all array types, even if the element type
// comes out the same. This is because different layout rules may have different array
// stride requirements.
- if (!target->shouldEmitSPIRVDirectly())
+ if (!target->getOptionSet().shouldEmitSPIRVDirectly())
{
if (!loweredInnerTypeInfo.convertLoweredToOriginal)
{
@@ -297,7 +297,7 @@ namespace Slang
auto structKey = builder.createStructKey();
builder.addNameHintDecoration(structKey, UnownedStringSlice("data"));
IRSizeAndAlignment elementSizeAlignment;
- getSizeAndAlignment(target, rules, loweredInnerTypeInfo.loweredType, &elementSizeAlignment);
+ getSizeAndAlignment(target->getOptionSet(), rules, loweredInnerTypeInfo.loweredType, &elementSizeAlignment);
elementSizeAlignment = rules->alignCompositeElement(elementSizeAlignment);
auto innerArrayType = builder.getArrayType(
loweredInnerTypeInfo.loweredType,
@@ -326,7 +326,7 @@ namespace Slang
// For spirv backend, we always want to lower all array types, even if the element type
// comes out the same. This is because different layout rules may have different array
// stride requirements.
- if (!target->shouldEmitSPIRVDirectly())
+ if (!target->getOptionSet().shouldEmitSPIRVDirectly())
{
// For non-spirv target, we skip lowering this type if all field types are unchanged.
if (isTrivial)
@@ -403,9 +403,9 @@ namespace Slang
return info;
}
- if (target->shouldEmitSPIRVDirectly())
+ if (target->getOptionSet().shouldEmitSPIRVDirectly())
{
- switch (target->getTarget())
+ switch (target->getTargetReq()->getTarget())
{
case CodeGenTarget::SPIRV:
case CodeGenTarget::SPIRVAssembly:
@@ -465,7 +465,7 @@ namespace Slang
return info;
info = getLoweredTypeInfoImpl(type, rules);
IRSizeAndAlignment sizeAlignment;
- getSizeAndAlignment(target, rules, info.loweredType, &sizeAlignment);
+ getSizeAndAlignment(target->getOptionSet(), rules, info.loweredType, &sizeAlignment);
loweredTypeInfo[(int)rules->ruleName].set(type, info);
mapLoweredTypeToInfo[(int)rules->ruleName].set(info.loweredType, info);
return info;
@@ -801,9 +801,9 @@ namespace Slang
}
};
- void lowerBufferElementTypeToStorageType(TargetRequest* target, IRModule* module)
+ void lowerBufferElementTypeToStorageType(TargetProgram* target, IRModule* module)
{
- SlangMatrixLayoutMode defaultMatrixMode = (SlangMatrixLayoutMode)target->getDefaultMatrixLayoutMode();
+ SlangMatrixLayoutMode defaultMatrixMode = (SlangMatrixLayoutMode)target->getOptionSet().getMatrixLayoutMode();
if (defaultMatrixMode == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN)
defaultMatrixMode = SLANG_MATRIX_LAYOUT_ROW_MAJOR;
LoweredElementTypeContext context(target, defaultMatrixMode);
@@ -811,17 +811,17 @@ namespace Slang
}
- IRTypeLayoutRules* getTypeLayoutRuleForBuffer(TargetRequest* target, IRType* bufferType)
+ IRTypeLayoutRules* getTypeLayoutRuleForBuffer(TargetProgram* target, IRType* bufferType)
{
- if (!isKhronosTarget(target))
+ if (!isKhronosTarget(target->getTargetReq()))
return IRTypeLayoutRules::getNatural();
// If we are just emitting GLSL, we can just use the general layout rule.
- if (!target->shouldEmitSPIRVDirectly())
+ if (!target->getOptionSet().shouldEmitSPIRVDirectly())
return IRTypeLayoutRules::getNatural();
// If the user specified a scalar buffer layout, then just use that.
- if (target->getForceGLSLScalarBufferLayout())
+ if (target->getOptionSet().shouldUseScalarLayout())
return IRTypeLayoutRules::getNatural();
// The default behavior is to use std140 for constant buffers and std430 for other buffers.