Skip to content

Commit

Permalink
remove WAR for global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhangNV committed Jan 16, 2025
1 parent 66b3bf5 commit 8be343e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 1 addition & 6 deletions source/slang/slang-check-conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,11 +843,6 @@ bool SemanticsVisitor::_coerceInitializerList(
!canCoerce(toType, fromInitializerListExpr->type, nullptr))
return _failedCoercion(toType, outToExpr, fromInitializerListExpr);

// TODO: See issue #4874, we cannot handle the case of calling a constructor with
// resource types at global scope. So we will still use the legacy initializer list
// for the global variable.
bool isGlobalDecl = (m_outerScope && as<ModuleDecl>(m_outerScope->containerDecl));

// Try to invoke the user-defined constructor if it exists. This call will
// report error diagnostics if the used-defined constructor exists but does not
// match the initialize list.
Expand All @@ -857,7 +852,7 @@ bool SemanticsVisitor::_coerceInitializerList(
}

// Try to invoke the synthesized constructor if it exists
if (_invokeExprForSynthesizedCtor(toType, fromInitializerListExpr, outToExpr) && !isGlobalDecl)
if (_invokeExprForSynthesizedCtor(toType, fromInitializerListExpr, outToExpr))
{
return true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/compute/type-legalize-global-with-init.slang
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// resources.
//
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
//
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
Expand Down

0 comments on commit 8be343e

Please sign in to comment.