 adcc7e8163
			
		
	
	
		adcc7e8163
		
	
	
	
	
		
			
			There are 3 separate tests added to cover the 3 cases in visitSelection(). With SPIR-V versions prior to 1.4, control flow is generated, with GLSL generating code to execute only the appropriate branch of the conditional while HLSL executes both branches and uses the control flow to select the appropriate one. Finally, with SPIR-V versions newer than 1.4, OpSelect can be used on structs. Note that the hlsl.structcopy.comp and hlsl.structcopylogical.comp tests have identical shader code, but are compiled with different versions of SPIR-V and result in different codepaths being used and different SPIR-V generated.
		
			
				
	
	
		
			29 lines
		
	
	
		
			568 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			568 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| struct MyStruct {
 | |
|     uint a;
 | |
|     uint b;
 | |
|     uint c;
 | |
| };
 | |
| 
 | |
| struct MyStructs {
 | |
|     uint count;
 | |
|     MyStruct data[];
 | |
| };
 | |
| 
 | |
| StructuredBuffer<MyStructs> sb;
 | |
| StructuredBuffer<MyStruct> o;
 | |
| 
 | |
| groupshared MyStruct s[128];
 | |
| static const MyStruct deflt = { 1u, 2u, 3u };
 | |
| 
 | |
| [numthreads(128, 1, 1)]
 | |
| void main(uint id : SV_GroupIndex)
 | |
| {
 | |
|         s[0] = deflt;
 | |
|         uint count = sb.Load(0).count;
 | |
|         MyStruct ms = id > count ? s[id - count] : sb.Load(0).data[id];
 | |
| 
 | |
|         InterlockedAdd(o[0].a, ms.a);
 | |
|         InterlockedAdd(o[0].b, ms.b);
 | |
|         InterlockedAdd(o[0].c, ms.c);
 | |
| }
 |