Ejemplo n.º 1
0
        public InputLayout GetInputLayout(EffectInputSignature effectInputSignature, VertexArrayLayout vertexArrayLayout)
        {
            var inputKey = new InputKey(effectInputSignature, vertexArrayLayout);

            InputLayout inputLayout;

            // TODO: Check if it is really worth to use ConcurrentDictionary
            lock (registeredSignatures)
            {
                if (!registeredSignatures.TryGetValue(inputKey, out inputLayout))
                {
                    try
                    {
                        inputLayout = new InputLayout(graphicsDevice.NativeDevice, effectInputSignature.NativeSignature, vertexArrayLayout.InputElements);
                    }
                    catch (Exception)
                    {
                        throw new InvalidOperationException("The provided vertex array input elements are not matching the ones of the shader." +
                                                            " [Details: EffectInputSignature='{0}', VertexArrayLayout='{1}]".ToFormat(effectInputSignature.ToString(), vertexArrayLayout.ToString()));
                    }
                    registeredSignatures.Add(inputKey, inputLayout);
                }

                ((IUnknown)inputLayout).AddReference();
            }
            return(inputLayout);
        }