private void InitBundles()
        {
            // Create and record the bundle.
            bundle = device.CreateCommandList(0, CommandListType.Bundle, bundleAllocator, pipelineState);
            bundle.SetGraphicsRootSignature(rootSignature);
            bundle.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            bundle.SetVertexBuffer(0, vertexBufferView);
            bundle.SetIndexBuffer(indexBufferView);

            bundle.SetDescriptorHeaps(1, new DescriptorHeap[] { constantBufferViewHeap });

            //first cube
            GpuDescriptorHandle heapStart = constantBufferViewHeap.GPUDescriptorHandleForHeapStart;

            for (int i = 0; i < NumCubes; i++)
            {
                bundle.SetGraphicsRootDescriptorTable(0, heapStart);
                bundle.DrawIndexedInstanced(36, 1, 0, 0, 0);
                heapStart += constantBufferDescriptorSize;
            }

            bundle.Close();

            // Create synchronization objects.
            {
                fence = device.CreateFence(0, FenceFlags.None);
                fenceValue = 1;

                // Create an event handle to use for frame synchronization.
                fenceEvent = new AutoResetEvent(false);
            }
        }
Пример #2
0
        private void InitBundles()
        {
            // Create and record the bundle.
            bundleAllocator.Reset();
            bundle = device.CreateCommandList(0, CommandListType.Bundle, bundleAllocator, pipelineState);

            //Set Heap
            bundle.SetDescriptorHeaps(2, new DescriptorHeap[] { constantBufferViewHeap, samplerViewHeap });

            bundle.SetGraphicsRootSignature(rootSignature);
            bundle.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            bundle.SetVertexBuffer(0, vertexBufferView);
            bundle.SetIndexBuffer(indexBufferView);

            //model
            GpuDescriptorHandle heapStart = constantBufferViewHeap.GPUDescriptorHandleForHeapStart;

            //constant buffer
            bundle.SetGraphicsRootDescriptorTable(0, heapStart);
            heapStart += constantBufferDescriptorSize;

            //sampler
            bundle.SetGraphicsRootDescriptorTable(2, samplerViewHeap.GPUDescriptorHandleForHeapStart);

            int offset = 0;
            foreach (var count in faceCounts)
            {
                //Texture coordinates start after constant buffer
                bundle.SetGraphicsRootDescriptorTable(1, heapStart);
                bundle.DrawIndexedInstanced(count, 1, offset, 0, 0);
                offset += count;
                heapStart += constantBufferDescriptorSize;
            }

            heapStart += constantBufferDescriptorSize;

            bundle.Close();
        }