private PixelShaderConstant InitializePixelShaderConstantBuffer() { PixelShaderConstant pixelShaderConstant = new PixelShaderConstant(); pixelShaderConstant.InnerRadius = (float)m_configuration.InnerRadius; pixelShaderConstant.OuterRadius = (float)m_configuration.OuterRadius; pixelShaderConstant.MagnificationAmount = (float)m_configuration.MagnificationAmount; pixelShaderConstant.HorizontalPosition = (float)m_configuration.HorizontalPosition; pixelShaderConstant.VerticalPosition = (float)m_configuration.VerticalPosition; pixelShaderConstant.AspectRatio = (float)m_configuration.AspectRatio; return(pixelShaderConstant); }
public MagnifySmoothEffectDirect2DWorker(MagnifySmoothEffect configuration) { InputCount = 1; m_configuration = configuration; PixelShader = m_configuration.PixelShader; PixelShaderConstant pixelShaderConstant = InitializePixelShaderConstantBuffer(); PixelShaderConstantBuffer = StructureToIBuffer(pixelShaderConstant); }
private IBuffer StructureToIBuffer(PixelShaderConstant pixelShaderConstant) { int length = Marshal.SizeOf <PixelShaderConstant>(pixelShaderConstant); byte[] pixelShaderConstantArray = new byte[length]; IntPtr ptr = Marshal.AllocHGlobal(length); Marshal.StructureToPtr(pixelShaderConstant, ptr, true); Marshal.Copy(ptr, pixelShaderConstantArray, 0, length); Marshal.FreeHGlobal(ptr); return(pixelShaderConstantArray.AsBuffer()); }