2
0
Эх сурвалжийг харах

Take extern as define to match fxc. (#138)

Xiang Li 8 жил өмнө
parent
commit
e84b71d22e

+ 1 - 0
tools/clang/lib/AST/Decl.cpp

@@ -1950,6 +1950,7 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const {
       getTemplateSpecializationKind() != TSK_ExplicitSpecialization)
     return DeclarationOnly;
 
+  if (!getASTContext().getLangOpts().HLSL) // HLSL Change - take extern as define to match fxc.
   if (hasExternalStorage())
     return DeclarationOnly;
 

+ 14 - 0
tools/clang/test/CodeGenHLSL/extern_res.hlsl

@@ -0,0 +1,14 @@
+// RUN: %dxc -E main -T ps_6_0 %s  | FileCheck %s
+
+// CHECK: @main
+
+SamplerState Samp;
+extern  Texture2D Tex1;
+
+  float4 foo;
+
+
+float4 main(int4 a : A, float4 coord : TEXCOORD) : SV_TARGET
+{
+  return Tex1.Sample(Samp, coord.xy) * foo;
+}

+ 5 - 0
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -341,6 +341,7 @@ public:
   TEST_METHOD(CodeGenEarlyDepthStencil)
   TEST_METHOD(CodeGenEval)
   TEST_METHOD(CodeGenEvalPos)
+  TEST_METHOD(CodeGenExternRes)
   TEST_METHOD(CodeGenFirstbitHi)
   TEST_METHOD(CodeGenFirstbitLo)
   TEST_METHOD(CodeGenFloatMaxtessfactor)
@@ -2074,6 +2075,10 @@ TEST_F(CompilerTest, CodeGenEvalPos) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\evalPos.hlsl");
 }
 
+TEST_F(CompilerTest, CodeGenExternRes) {
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\extern_res.hlsl");
+}
+
 TEST_F(CompilerTest, CodeGenFirstbitHi) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\firstbitHi.hlsl");
 }