/// <summary>
        /// Binds the specified texture to the specified texture at the given variable name and slot
        /// </summary>
        /// <param name="shader"></param>
        /// <param name="uniform"></param>
        /// <param name="texture"></param>
        /// <param name="slot"></param>
        public void BindShaderTexture(Shader shader, string uniform, Texture2D texture)
        {
            // Get the view and bind it to the shader
            ShaderResourceView view = AcquireResourceView(texture);
            shader.SetVariable(uniform, view);

            // See if the view is already bound to a slot
            // Whilst we're at it, see if there's a free slot we can use, and search for slot with the lowest uses
            int freeslot = -1;
            int lowestuses = resourceviewslots[0].NumUses;
            int lowestusesidx = 0;
            for (int i = 0; i < MaxPixelShaderResourceViewSlots; i++)
                if (resourceviewslots[i].View == view)
                {
                    resourceviewslots[i].NumUses++;
                    return;
                }
                else if (resourceviewslots[i].View == null && freeslot == -1)
                    freeslot = i;
                else if (resourceviewslots[i].NumUses < lowestuses)
                {
                    lowestuses = resourceviewslots[i].NumUses;
                    lowestusesidx = i;
                }

            // If we got this far, we need to find a slot
            // If there is none free, select the one with the lowest uses
            freeslot = lowestusesidx;

            // Use it
            context.PixelShader.SetShaderResource(view, freeslot);
            resourceviewslots[freeslot].View = view;
            resourceviewslots[freeslot].NumUses = 1;
        }