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); } }
protected void LoadFromSource(D3D9.Device d3D9Device) { //Entering critical section this.LockDeviceAccess(); D3D9.ShaderBytecode microcode = null; // Create the shader // Assemble source into microcode try { microcode = D3D9.ShaderBytecode.Assemble(Source, null, // no #define support null, // no #include support 0); // standard compile options } catch (DX.CompilationException e) { throw new AxiomException("Cannot assemble D3D9 shader {0} Errors:\n{1}", e, Name, e.Message); } LoadFromMicrocode(d3D9Device, microcode); microcode.SafeDispose(); //Leaving critical section this.UnlockDeviceAccess(); }
protected abstract void LoadFromMicrocode(D3D9.Device d3D9Device, D3D9.ShaderBytecode microcode);
/// <summary> /// Initializes a new instance of the <see cref="VertexShader"/> class. /// </summary> /// <param name="device">The device.</param> /// <param name="function">The function.</param> /// <unmanaged>HRESULT IDirect3DDevice9::CreateVertexShader([In] const void* pFunction,[Out, Fast] IDirect3DVertexShader9** ppShader)</unmanaged> public VertexShader(Device device, ShaderBytecode function) { device.CreateVertexShader(function.BufferPointer, this); this.function = function; }
/// <summary> /// Initializes a new instance of the <see cref="PixelShader"/> class. /// </summary> /// <param name="device">The device.</param> /// <param name="function">The function.</param> /// <unmanaged>HRESULT IDirect3DDevice9::CreatePixelShader([In] const void* pFunction,[Out, Fast] IDirect3DPixelShader9** ppShader)</unmanaged> public PixelShader(Device device, ShaderBytecode function) { device.CreatePixelShader(function.BufferPointer, this); this.function = function; }