protected override void LoadFromMicrocode(D3D9.Device d3D9Device, D3D9.ShaderBytecode microcode) { D3D9.PixelShader pixelShader; var shaderWasFound = this._mapDeviceToPixelShader.TryGetValue(d3D9Device, out pixelShader); if (shaderWasFound) { pixelShader.SafeDispose(); } if (IsSupported) { // Create the shader pixelShader = new D3D9.PixelShader(d3D9Device, microcode); } else { LogManager.Instance.Write("Unsupported D3D9 pixel shader '{0}' was not loaded.", _name); pixelShader = null; } if (shaderWasFound) { this._mapDeviceToPixelShader[d3D9Device] = pixelShader; } else { this._mapDeviceToPixelShader.Add(d3D9Device, pixelShader); } }
public CPixelShader(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 PixelShader(device.D3DDevice, bytecode); bytecode.Dispose(); } catch (Exception e) { throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e); } }
protected override void LoadFromMicrocode( D3D9.Device d3D9Device, D3D9.ShaderBytecode microcode ) { D3D9.PixelShader pixelShader; var shaderWasFound = this._mapDeviceToPixelShader.TryGetValue( d3D9Device, out pixelShader ); if ( shaderWasFound ) { pixelShader.SafeDispose(); } if ( IsSupported ) { // Create the shader pixelShader = new D3D9.PixelShader( d3D9Device, microcode ); } else { LogManager.Instance.Write( "Unsupported D3D9 pixel shader '{0}' was not loaded.", _name ); pixelShader = null; } if ( shaderWasFound ) { this._mapDeviceToPixelShader[ d3D9Device ] = pixelShader; } else { this._mapDeviceToPixelShader.Add( d3D9Device, pixelShader ); } }