示例#1
0
        protected override void LoadFromMicrocode(D3D9.Device d3D9Device, D3D9.ShaderBytecode microcode)
        {
            D3D9.VertexShader vertexShader;
            var shaderWasFound = this._mapDeviceToVertexShader.TryGetValue(d3D9Device, out vertexShader);

            if (shaderWasFound)
            {
                vertexShader.SafeDispose();
            }

            if (IsSupported)
            {
                // Create the shader
                vertexShader = new D3D9.VertexShader(d3D9Device, microcode);
            }
            else
            {
                LogManager.Instance.Write("Unsupported D3D9 vertex shader '{0}' was not loaded.", _name);
                vertexShader = null;
            }

            if (shaderWasFound)
            {
                this._mapDeviceToVertexShader[d3D9Device] = vertexShader;
            }
            else
            {
                this._mapDeviceToVertexShader.Add(d3D9Device, vertexShader);
            }
        }
示例#2
0
        public CVertexShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            profile = ParseProfile(reflection.Profile);

            var text = GenerateText();
            try
            {
                var bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(profile), ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3);
                d3dShader = new VertexShader(device.D3DDevice, bytecode);
                bytecode.Dispose();
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a vertex shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }

            d3dVertexElementsDraft = CreateVertexElementsDraft(reflection);
        }
示例#3
0
		protected override void LoadFromMicrocode( D3D9.Device d3D9Device, D3D9.ShaderBytecode microcode )
		{
			D3D9.VertexShader vertexShader;
			var shaderWasFound = this._mapDeviceToVertexShader.TryGetValue( d3D9Device, out vertexShader );
			if ( shaderWasFound )
			{
				vertexShader.SafeDispose();
			}

			if ( IsSupported )
			{
				// Create the shader
				vertexShader = new D3D9.VertexShader( d3D9Device, microcode );
			}
			else
			{
				LogManager.Instance.Write( "Unsupported D3D9 vertex shader '{0}' was not loaded.", _name );
				vertexShader = null;
			}

			if ( shaderWasFound )
			{
				this._mapDeviceToVertexShader[ d3D9Device ] = vertexShader;
			}
			else
			{
				this._mapDeviceToVertexShader.Add( d3D9Device, vertexShader );
			}
		}