Exemple #1
0
        AmtQueueSubmission EnqueueSubmission(MgSubmitInfo sub)
        {
            var submit = new AmtQueueSubmission(mSubmissionKey, sub);

            // JUST LOOP AROUND
            Interlocked.CompareExchange(ref mSubmissionKey, 0, long.MaxValue);
            Interlocked.Increment(ref mSubmissionKey);
            if (mSubmissions.TryAdd(submit.Key, submit))
            {
                return(submit);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
		public void Render(AmtQueueSubmission request)
		{
			foreach (var buffer in request.CommandBuffers)
			{
				if (buffer.IsQueueReady)
				{
					// GENERATE METAL BUFFER
					var cb = mCommandQueue.CommandBuffer();
					cb.Label = "MyCommand";

					AmtCommandRecording recording = GenerateRecording(cb, buffer);

					foreach (var context in buffer.Record.Contexts)
					{
						if (context.Category == AmtEncoderCategory.Compute)
						{
							recording.Compute.Encoder = cb.ComputeCommandEncoder;
						}
						else if (context.Category == AmtEncoderCategory.Blit)
						{
							recording.Blit.Encoder = cb.BlitCommandEncoder;
						}

						for (var i = context.First; i <= context.Last; ++i)
						{
							buffer.Record.Instructions[i].Perform(recording);
						}

						if (context.Category == AmtEncoderCategory.Compute)
						{
							recording.Compute.Encoder.EndEncoding();
							recording.Compute.Encoder = null;
						}
						else if (context.Category == AmtEncoderCategory.Blit)
						{
							recording.Blit.Encoder.EndEncoding();
							recording.Blit.Encoder = null;
						}
					}

					TriggerSemaphores(request.Signals, cb);
					SignalFenceWhenCompleted(request.OrderFence, cb);

					cb.Commit();
				}
			}
		}