File tree 2 files changed +53
-0
lines changed
tests/language-feature/interfaces
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -1189,6 +1189,32 @@ LegalType legalizeTypeImpl(
1189
1189
legalElementType);
1190
1190
1191
1191
}
1192
+ else if (auto bufferType = as<IRHLSLStructuredBufferTypeBase>(type))
1193
+ {
1194
+ auto legalElementType = legalizeType (context, bufferType->getElementType ());
1195
+ IRInst* newElementType = nullptr ;
1196
+ switch (legalElementType.flavor )
1197
+ {
1198
+ case LegalType::Flavor::simple:
1199
+ if (legalElementType.getSimple () == bufferType->getElementType ())
1200
+ return LegalType::simple (bufferType);
1201
+ newElementType = legalElementType.getSimple ();
1202
+ break ;
1203
+ case LegalType::Flavor::none:
1204
+ newElementType = context->getBuilder ()->getIntType ();
1205
+ break ;
1206
+ default :
1207
+ return LegalType::simple (bufferType);
1208
+ }
1209
+ ShortList<IRInst*> operands;
1210
+ for (UInt i = 0 ; i < bufferType->getOperandCount (); i++)
1211
+ operands.add (bufferType->getOperand (i));
1212
+ operands[0 ] = newElementType;
1213
+ return LegalType::simple (context->getBuilder ()->getType (
1214
+ bufferType->getOp (),
1215
+ bufferType->getOperandCount (),
1216
+ operands.getArrayView ().getBuffer ()));
1217
+ }
1192
1218
else if (isResourceType (type))
1193
1219
{
1194
1220
// We assume that any resource types not handled above
Original file line number Diff line number Diff line change
1
+ // Test that we allow empty type conformances.
2
+
3
+ // TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-dx11 -compute -output-using-type
4
+ // TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -output-using-type
5
+
6
+ interface TestInterface {
7
+ float sample();
8
+ }
9
+ struct TestImplementation : TestInterface {
10
+ float sample() {
11
+ return 1 . 0 f ;
12
+ }
13
+ };
14
+
15
+ // TEST_INPUT: set inBuffer = new StructuredBuffer<TestInterface>[new TestImplementation{}];
16
+ StructuredBuffer < TestInterface> inBuffer;
17
+
18
+ // TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4);
19
+ RWStructuredBuffer < float > outputBuffer;
20
+
21
+ [shader(" compute" )]
22
+ [numthreads(1 , 1 , 1 )]
23
+ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
24
+ {
25
+ // CHECK: 1.0
26
+ outputBuffer [0 ] = inBuffer [0 ].sample ();
27
+ }
You can’t perform that action at this time.
0 commit comments