Beispiel #1
0
        unsafe public override void Render(Renderer.IndirectDrawEncoder encoder, SceneRenderPipeline sp)
        {
            if (!IsVisible)
            {
                return;
            }

            if (NvmResource == null || !NvmResource.IsLoaded || NvmResource.Get() == null)
            {
                return;
            }

            if (NvmResource.TryLock())
            {
                var resource   = NvmResource.Get();
                var geombuffer = resource.GeomBuffer;

                if (geombuffer.AllocStatus != VertexIndexBufferAllocator.VertexIndexBufferHandle.Status.Resident)
                {
                    NvmResource.Unlock();
                    return;
                }

                uint indexStart = geombuffer.IAllocationStart / 4u;
                var  args       = new Renderer.IndirectDrawIndexedArgumentsPacked();
                args.FirstInstance = WorldBuffer.AllocationStart / (uint)sizeof(InstanceData);
                args.VertexOffset  = (int)(geombuffer.VAllocationStart / Resource.CollisionLayout.SizeInBytes);
                args.InstanceCount = 1;
                args.FirstIndex    = indexStart;
                args.IndexCount    = geombuffer.IAllocationSize / 4u;
                encoder.AddDraw(ref args, geombuffer.BufferIndex, RenderPipeline, PerObjRS, IndexFormat.UInt32);
                NvmResource.Unlock();
            }
        }
Beispiel #2
0
 public void OnResourceLoaded(IResourceHandle handle)
 {
     if (Resource != null && Resource.TryLock())
     {
         CreateSubmeshes();
         OnWorldMatrixChanged();
         Renderer.AddBackgroundUploadTask((d, cl) =>
         {
             if (Submeshes != null && Resource.TryLock())
             {
                 foreach (var sm in Submeshes)
                 {
                     sm.CreateDeviceObjects(d, cl, null);
                 }
                 if (AutoRegister)
                 {
                     RegisterWithScene(RenderScene);
                 }
                 Created = true;
                 Resource.Unlock();
             }
         });
         Resource.Unlock();
     }
 }
Beispiel #3
0
 public override void Unlock()
 {
     _resource.Unlock();
 }