コード例 #1
0
        /// <summary>
        /// Loads a value from texture.
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="position"></param>
        /// <param name="dst"></param>
        public void Load([NotNull] Operand texture, [NotNull] Operand position, Operand offset, [NotNull] Operand dst)
        {
            // We first validate.
            switch (texture.Format)
            {
            case PinFormat.Texture1D:
                if (position.Format != PinFormat.Integerx2)
                {
                    throw new ArgumentException("Position must be two-dimensional.");
                }
                break;

            case PinFormat.Texture1DArray:
                if (position.Format != PinFormat.Integerx3)
                {
                    throw new ArgumentException("Position must be three-dimensional.");
                }
                break;

            case PinFormat.Texture2D:
                if (position.Format != PinFormat.Integerx3)
                {
                    throw new ArgumentException("Position must be three-dimensional.");
                }
                break;

            case PinFormat.Texture2DArray:
                if (position.Format != PinFormat.Integerx4)
                {
                    throw new ArgumentException("Position must be four-dimensional.");
                }
                break;

            case PinFormat.Texture3D:
                if (position.Format != PinFormat.Integerx4)
                {
                    throw new ArgumentException("Position must be four-dimensional.");
                }
                break;

            case PinFormat.BufferTexture:
                if (position.Format != PinFormat.Integer)
                {
                    throw new ArgumentException("Position must be one dimensional.");
                }
                break;

            default:
                throw new NotImplementedException();
            }

            // We also validate offset.
            if (offset != null)
            {
                // TODO:
            }

            compiler.Load(texture.Name, position.Name,
                          offset != null ? offset.Name : -1, dst.Name);
        }