File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -136,8 +136,15 @@ void MetalSourceEmitter::_emitHLSLTextureType(IRTextureTypeBase* texType)
136
136
switch (texType->getAccess ())
137
137
{
138
138
case SLANG_RESOURCE_ACCESS_READ:
139
- m_writer->emit (" access::sample" );
140
- break ;
139
+ {
140
+ // Metal does not support access::sample for texture buffers, so we need to emit
141
+ // access::read instead.
142
+ if (texType->GetBaseShape () == SLANG_TEXTURE_BUFFER)
143
+ m_writer->emit (" access::read" );
144
+ else
145
+ m_writer->emit (" access::sample" );
146
+ break ;
147
+ }
141
148
142
149
case SLANG_RESOURCE_ACCESS_WRITE:
143
150
m_writer->emit (" access::write" );
Original file line number Diff line number Diff line change
1
+ // Test that Buffer<T> maps to texture_buffer<uint, access::read> in Metal
2
+
3
+ // TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal
4
+
5
+
6
+ // METAL: texture_buffer<uint, access::read> inputBuffer_{{.*}}
7
+ Buffer < uint > inputBuffer;
8
+
9
+ RWStructuredBuffer < uint > outputBuffer;
10
+
11
+ [numthreads(4 , 1 , 1 )]
12
+ void computeMain(uint3 dtid : SV_DispatchThreadID)
13
+ {
14
+ uint idx = dtid .x ;
15
+ // Load values from the buffer to verify correct access
16
+ outputBuffer [idx] = inputBuffer .Load (idx);
17
+ }
You can’t perform that action at this time.
0 commit comments