Post

Replies

Boosts

Views

Created

Is it legal to use 2d array in shaders?
Hello, I'm going to use C's 2d array in my shaders. The reason is to use 2d index in buffer, instead using textures. Someone from the developers can dissuade me from doing this? #include <metal_stdlib> using namespace metal; struct DebugCell {     float4 info; }; struct DebugBuffer {     DebugCell cells[5][3]; // Column number(x), Row number(y). (x, y)  }; kernel void debugCells(device DebugBuffer *current [[buffer(0)]], uint2 id [[thread_position_in_grid]]) {     current[0].cells[id.x][id.y].info.xy = float2(id); } /*  after reshape for printing on CPU it prints  [[0.0,0.0], [1.0,0.0], [2.0,0.0], [3.0,0.0], [4.0,0.0], [5.0,0.0], [6.0,0.0], [7.0,0.0]]  [[0.0,1.0], [1.0,1.0], [2.0,1.0], [3.0,1.0], [4.0,1.0], [5.0,1.0], [6.0,1.0], [7.0,1.0]]  [[0.0,2.0], [1.0,2.0], [2.0,2.0], [3.0,2.0], [4.0,2.0], [5.0,2.0], [6.0,2.0], [7.0,2.0]]  */
1
1
749
Jul ’21
Is it legal to use 2d array in shaders?
Hello, I'm going to use C's 2d array in my shaders. The reason is to use 2d index in buffer, instead using textures. Someone from the developers can dissuade me from doing this? #include <metal_stdlib> using namespace metal; struct DebugCell {     float4 info; }; struct DebugBuffer {     DebugCell cells[5][3]; // Column number(x), Row number(y). (x, y)  }; kernel void debugCells(device DebugBuffer *current [[buffer(0)]], uint2 id [[thread_position_in_grid]]) {     current[0].cells[id.x][id.y].info.xy = float2(id); } /*  after reshape for printing on CPU it prints  [[0.0,0.0], [1.0,0.0], [2.0,0.0], [3.0,0.0], [4.0,0.0], [5.0,0.0], [6.0,0.0], [7.0,0.0]]  [[0.0,1.0], [1.0,1.0], [2.0,1.0], [3.0,1.0], [4.0,1.0], [5.0,1.0], [6.0,1.0], [7.0,1.0]]  [[0.0,2.0], [1.0,2.0], [2.0,2.0], [3.0,2.0], [4.0,2.0], [5.0,2.0], [6.0,2.0], [7.0,2.0]]  */
Replies
1
Boosts
1
Views
749
Activity
Jul ’21
How does V/HStack update on Avatar Picker App on macOS?
Hello. How does V/HStack update on Avatar Picker App (The Contacts App) on macOS so smoothly? Can you share some source code, please?
Replies
0
Boosts
0
Views
810
Activity
Nov ’21
Why do UI elements only work on the main thread?
I am trying modeling run loop in a simple project. Could you post the source code of RunLoop?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
1
Boosts
0
Views
522
Activity
Jun ’22
Why is there no Metal on Apple Watch?
subj And how in this case are beautiful system dials made with smoke effects and other particles?
Replies
1
Boosts
0
Views
322
Activity
Oct ’25