Skip to content

Commit

Permalink
Merge branch 'master' into fix/test_server_should_use_a_custom_d3d12c…
Browse files Browse the repository at this point in the history
…ore_dll
  • Loading branch information
jkwak-work authored Jan 18, 2025
2 parents 6084c06 + 9d99976 commit 1e8951f
Show file tree
Hide file tree
Showing 75 changed files with 4,794 additions and 4,710 deletions.
513 changes: 258 additions & 255 deletions source/slang/glsl.meta.slang

Large diffs are not rendered by default.

370 changes: 259 additions & 111 deletions source/slang/hlsl.meta.slang

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/slang/slang-ast-decl-ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void DeclRefBase::toText(StringBuilder& out)
return;
}

if (as<GenericTypeParamDecl>(this->getDecl()))
if (as<GenericTypeParamDeclBase>(this->getDecl()))
{
SLANG_ASSERT(as<DirectDeclRef>(this));
out << this->getDecl()->getName()->text;
Expand Down
1 change: 1 addition & 0 deletions source/slang/slang-ast-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ enum class TypeTag
Unsized = 1,
Incomplete = 2,
LinkTimeSized = 4,
Opaque = 8,
};

// Declaration of a type that represents some sort of aggregate
Expand Down
1 change: 1 addition & 0 deletions source/slang/slang-ast-support-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ enum class LookupOptions : uint8_t
/// checking to see if a keyword is shadowed.
IgnoreInheritance =
1 << 4, ///< Lookup only non inheritance children of a struct (including `extension`)
IgnoreTransparentMembers = 1 << 5,
};
inline LookupOptions operator&(LookupOptions a, LookupOptions b)
{
Expand Down
9 changes: 8 additions & 1 deletion source/slang/slang-check-conformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,16 @@ TypeTag SemanticsVisitor::getTypeTags(Type* type)
if (auto parameterGroupType = as<UniformParameterGroupType>(type))
{
auto elementTags = getTypeTags(parameterGroupType->getElementType());
elementTags = (TypeTag)((int)elementTags & ~(int)TypeTag::Unsized);
elementTags = (TypeTag)(((int)elementTags & ~(int)TypeTag::Unsized) | (int)TypeTag::Opaque);
return elementTags;
}
else if (
as<UntypedBufferResourceType>(type) || as<ResourceType>(type) ||
as<SamplerStateType>(type) || as<HLSLStructuredBufferTypeBase>(type) ||
as<DynamicResourceType>(type))
{
return TypeTag::Opaque;
}
else if (auto declRefType = as<DeclRefType>(type))
{
if (auto aggTypeDecl = as<AggTypeDecl>(declRefType->getDeclRef()))
Expand Down
23 changes: 17 additions & 6 deletions source/slang/slang-check-decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,18 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
{
getSink()->diagnose(varDecl, Diagnostics::varCannotBeUnsized);
}

bool isOpaque = (((int)varTypeTags & (int)TypeTag::Opaque) != 0);
if (isOpaque && isGlobalDecl(varDecl) && !varDecl->hasModifier<ConstModifier>() &&
varDecl->hasModifier<HLSLStaticModifier>())
{
// Opaque type global variable must be const.
getSink()->diagnose(varDecl, Diagnostics::globalVarCannotHaveOpaqueType);
if (varDecl->initExpr)
getSink()->diagnose(varDecl, Diagnostics::doYouMeanStaticConst);
else
getSink()->diagnose(varDecl, Diagnostics::doYouMeanUniform);
}
}

if (auto elementType = getConstantBufferElementType(varDecl->getType()))
Expand Down Expand Up @@ -2885,14 +2897,13 @@ void SemanticsDeclBasesVisitor::visitInheritanceDecl(InheritanceDecl* inheritanc
{
// check the type being inherited from
auto base = inheritanceDecl->base;
Decl* toExclude = nullptr;
Decl* parent = getParentDecl(inheritanceDecl);
// We exclude in the case that a circular reference is possible. This is when a parent is a
// transparent decl. If we just blanket "block" all ensure's of a parent a generic may fail when
// trying to fetch a parent
// We exclude transparent members in the case that a circular reference is
// possible. This is when a parent is also a transparent decl.
SemanticsContext context(*this);
if (parent->findModifier<TransparentModifier>())
toExclude = parent;
SemanticsDeclVisitorBase baseVistor(this->withDeclToExcludeFromLookup(toExclude));
context = context.excludeTransparentMembersFromLookup();
SemanticsDeclVisitorBase baseVistor(context);
baseVistor.CheckConstraintSubType(base);
base = baseVistor.TranslateTypeNode(base);
inheritanceDecl->base = base;
Expand Down
3 changes: 2 additions & 1 deletion source/slang/slang-check-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,8 @@ Expr* SemanticsExprVisitor::visitVarExpr(VarExpr* expr)
expr->scope,
LookupMask::Default,
false,
getDeclToExcludeFromLookup());
getDeclToExcludeFromLookup(),
getExcludeTransparentMembersFromLookup());

bool diagnosed = false;
lookupResult = filterLookupResultByVisibilityAndDiagnose(lookupResult, expr->loc, diagnosed);
Expand Down
11 changes: 11 additions & 0 deletions source/slang/slang-check-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,15 @@ struct SemanticsContext

Decl* getDeclToExcludeFromLookup() { return m_declToExcludeFromLookup; }

SemanticsContext excludeTransparentMembersFromLookup()
{
SemanticsContext result(*this);
result.m_excludeTransparentMembersFromLookup = true;
return result;
}

bool getExcludeTransparentMembersFromLookup() { return m_excludeTransparentMembersFromLookup; }

OrderedHashSet<Type*>* getCapturedTypePacks() { return m_capturedTypePacks; }

GLSLBindingOffsetTracker* getGLSLBindingOffsetTracker()
Expand All @@ -1084,6 +1093,8 @@ struct SemanticsContext

Decl* m_declToExcludeFromLookup = nullptr;

bool m_excludeTransparentMembersFromLookup = false;

protected:
// TODO: consider making more of this state `private`...

Expand Down
19 changes: 16 additions & 3 deletions source/slang/slang-check-inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,14 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
if (constraintDeclRef.getDecl()->checkState.isBeingChecked())
continue;

ensureDecl(&visitor, constraintDeclRef.getDecl(), DeclCheckState::CanSpecializeGeneric);
ensureDecl(&visitor, constraintDeclRef.getDecl(), DeclCheckState::ScopesWired);

auto subType = getSub(astBuilder, constraintDeclRef);
auto superType = getSup(astBuilder, constraintDeclRef);
// Check only the sub-type.
visitor.CheckConstraintSubType(constraintDeclRef.getDecl()->sub);
auto sub = constraintDeclRef.getDecl()->sub;
if (!sub.type)
sub = visitor.TranslateTypeNodeForced(sub);
auto subType = constraintDeclRef.substitute(astBuilder, sub.type);

// We only consider constraints where the type represented
// by `declRef` is the subtype, since those
Expand All @@ -489,6 +493,11 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
if (subDeclRefType->getDeclRef() != declRef)
continue;

// Further check the constraint, since we now need the sup-type.
ensureDecl(&visitor, constraintDeclRef.getDecl(), DeclCheckState::CanSpecializeGeneric);

auto superType = getSup(astBuilder, constraintDeclRef);

// Because the constraint is a declared inheritance relationship,
// adding the base to our list of direct bases is as straightforward
// as in all the preceding cases.
Expand Down Expand Up @@ -1149,6 +1158,10 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
info.facets = FacetList(directFacet);
return info;
}
else if (auto modifiedType = as<ModifiedType>(type))
{
return _calcInheritanceInfo(modifiedType->getBase(), circularityInfo);
}
else
{
// As a fallback, any type not covered by the above cases will
Expand Down
18 changes: 17 additions & 1 deletion source/slang/slang-check-overload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

namespace Slang
{

bool isFreeFormTypePackParam(SemanticsVisitor* visitor, Type* type, ParamDecl* paramDecl)
{
if (auto declRef = isDeclRefTypeOf<GenericTypePackParamDecl>(type))
{
return visitor->GetOuterGeneric(declRef.getDecl()) ==
visitor->GetOuterGeneric(paramDecl->parentDecl);
}
return false;
}

SemanticsVisitor::ParamCounts SemanticsVisitor::CountParameters(
FilteredMemberRefList<ParamDecl> params)
{
Expand All @@ -25,10 +36,15 @@ SemanticsVisitor::ParamCounts SemanticsVisitor::CountParameters(
counts.required += typePack->getTypeCount();
allowedArgCountToAdd = typePack->getTypeCount();
}
else
else if (isFreeFormTypePackParam(this, paramType, param.getDecl()))
{
counts.allowed = -1;
}
else
{
counts.required++;
counts.allowed++;
}
}
else if (!param.getDecl()->initExpr)
{
Expand Down
16 changes: 13 additions & 3 deletions source/slang/slang-compiler-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ void CompilerOptionSet::writeCommandLineArgs(Session* globalSession, StringBuild
switch (option.key)
{
case CompilerOptionName::Capability:
for (auto v : option.value)
{
sb << " " << optionInfo.names << " " << v.stringValue;
StringBuilder subBuilder;
for (auto v : option.value)
{
if (subBuilder.getLength() != 0)
subBuilder << "+";
if (v.kind == CompilerOptionValueKind::Int)
subBuilder << capabilityNameToString((CapabilityName)v.intValue);
else
subBuilder << v.stringValue;
}
if (subBuilder.getLength())
sb << " " << optionInfo.names << " " << subBuilder.produceString();
break;
}
break;
case CompilerOptionName::Include:
for (auto v : option.value)
{
Expand Down
16 changes: 15 additions & 1 deletion source/slang/slang-diagnostic-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ DIAGNOSTIC(
Warning,
unintendedEmptyStatement,
"potentially unintended empty statement at this location; use {} instead.")

DIAGNOSTIC(
20102,
Error,
unexpectedBodyAfterSemicolon,
"unexpected function body after signature declaration, is this ';' a typo?")
DIAGNOSTIC(30102, Error, declNotAllowed, "$0 is not allowed here.")

// 29xxx - Snippet parsing and inline asm
Expand Down Expand Up @@ -738,6 +742,10 @@ DIAGNOSTIC(
cannotSpecializeGeneric,
"cannot specialize generic '$0' with the provided arguments.")

DIAGNOSTIC(30076, Error, globalVarCannotHaveOpaqueType, "global variable cannot have opaque type.")
DIAGNOSTIC(-1, Note, doYouMeanStaticConst, "do you intend to define a `static const` instead?")
DIAGNOSTIC(-1, Note, doYouMeanUniform, "do you intend to define a `uniform` parameter instead?")

DIAGNOSTIC(
30100,
Error,
Expand Down Expand Up @@ -1658,6 +1666,12 @@ DIAGNOSTIC(
overloadedParameterToHigherOrderFunction,
"passing overloaded functions to higher order functions is not supported")

DIAGNOSTIC(
39999,
Error,
matrixColumnOrRowCountIsOne,
"matrices with 1 column or row are not supported by the current code generation target")

// 38xxx

DIAGNOSTIC(
Expand Down
Loading

0 comments on commit 1e8951f

Please sign in to comment.