My understanding is that MTLFence don't work across command buffers. That's so you don't get a race on a resource that is changed within a command buffer. So when you go to untracked resources, Metal stops injecting fences for you. You said you had two command buffers. MTLEvent for cross command buffer, and MTLSharedEvent for synchronization across command queues, but few people do that.
Post
Replies
Boosts
Views
Activity
Since there are never any responds to posts to the forums. I'll just post the solution for now. This is less than ideal, since it creates a whole new matrix, when a cast should be fine and is in HLSL. Neither cast not construction works directly from a float4x4/half4x4, but this does.
inline float3x3 tofloat3x3(float4x4 m) {
return float3x3(m[0].xyz, m[1].xyz, m[2].xyz);
}
inline half3x3 tohalf3x3(half4x4 m) {
return half3x3(m[0].xyz, m[1].xyz, m[2].xyz);
}
MTLEvent is what you need. You have to prevent concurrent execution of commands when you have two separate command buffers. Even with one, the compute and render passes can overlap, so then fences/barriers are needed.
For uint64_t, the specification states "Since Metal 2.2". So you have to compile to that, and make sure your iOS/macOS target is correct.
GL and ES are all dead everywhere. Vulkan has supplanted them on Android/Windows/Linux. ES 3.2 and GL 4.6 is probably the last version. On macOS, you only have GL4.1 which lacks compute, glClipControl, error callbacks, BC6/7 support, and much more. You can still use GL on M1, but it is emulated atop Metal. So it's time for devs to move on.
You have to tile it yourself, or use one of Apple's tiling classes. UIKit has some of these. But handling blurs across tiles isn't fun. The M1/iOS hw is TBDR, so it's further tiling up the image into 32x32 tiles, and only drawing elements within. So that is how you reduce bandwidth. Otherwise, you need a dirty rect system. The sparse texture is mostly for reading textures. Like in game, having a megatexture, and only pulling int tiles that were needed to display. It's also only on A13 and higher.
There are multiple CUs processing both Vertex and Fragment work. So that's what you are seeing the capture.
You really shouldn't have one draw per command buffer. You should have one (or a small number of command buffers) that are enqued in the order you want the queue to process them in, and then use a series of render passes on the command buffer to submit draws that pertain to a particular set of render targets. The encoders of the render passes will run in sequence within a command buffer, but command buffers are allowed to execute out of order if there are no dependencies.
CommandBuffers aren't cheap.
I finally got the dummy project to print warnings/errors from running the CLI tool. Quinn had posted a message 7 years ago on the forums, but printf needs the following format. This doesn't fix the lack of syntax highlighting, but at least does provide error clickthrough.
/AbsolutePath/filename.metal:12: error: mesage
/AbsolutePath/filename.metal:12: warning: mesage
Log_Error("%s:%d: %s: %s\n", m_fileName, m_lineNumber, isError ? "error" : "warning", buffer);
Somehow setting the all cases to "thread depth2d&" gets this to work. There are no samples using references in the MSL language document on how and when to use these.
I added a dummy xcodeproject and add the files to that project and even that doesn't help. I use the syntax highlighting for metal even though I have source hlsl files. These have u/int, float, half elements that are valid MSL types. These should be highlighted but are not. It's like Xcode tries to parse them as MSL, but fails, and then doesn't highlight anything. Syntax highlighting should be simple name lookup and coloring at a basic level. It shouldn't need complex parsing. Also the plugin architecture for the editor seems undocumented, but there are few brave souls that reverse engineered it for lua/typescript. A code editor shouldn't be this hard to use and extend.
Contrast this with VSCode that highlights any .metal or .hlsl file or containing folder dropped onto it. The files are in the project. They are just not a part of the build. The files are a result of what the CLI tools build.
Also limiting that console can’t click through to error file/line like every other IDE. The console cannot jump to files or url links.
Nvidia's Tensor float is 1 + 7 + 10. Might be some funky AI float. There's already bfloat.
Clears wipe the whole texture out. They have since DX10, and Metal is no different. You need to draw rectangles to color, depth, or stencil for any kinds of partial clears. The whole point is to do a fast clear of the content where the hw doesn't even touch pixels. If it had to scissor test then that doesn't work.
Also setting C source, C++ source, Metal source, OpenGL Shading Language on the .hlsl makes no difference. I at least get some highlighting on includes that are set to "Default - C header". The .metal file is set to "Default - Metal Shading Language" but doesn't syntax highlight properly as described above.
Fixed the missing drop of folder by adding "public.directory" to the list of UTI array. Still missing glb/gltf UTI in this library. These are older than usd/usb files, so seems like they should be in there.