public DrawPassCtrl(DrawSystem.D3DData d3d, DrawResourceRepository repository, HmdDevice hmd, bool bStereoRendering, int multiThreadCount) { m_d3d = d3d; m_repository = repository; m_bStereoRendering = bStereoRendering; m_hmd = hmd; m_factory = new DrawContext.Factory(d3d, repository); if (bStereoRendering) { m_stereoContext = new StereoDrawContext(d3d, repository, hmd, m_factory.CreateDeferredDrawContext()); } else { m_monoralContext = new MonoralDrawContext(d3d, repository, m_factory.CreateImmediateDrawContext()); } // Init settings m_d3d.Device.QueryInterface <Device1>().MaximumFrameLatency = 1; m_subThreadCtxList = new List <_SubThreadContextData>(); for (int index = 0; index < multiThreadCount; ++index) { var drawContext = m_factory.CreateDeferredDrawContext(); m_subThreadCtxList.Add(new _SubThreadContextData() { DrawContext = drawContext }); } }
private DrawSystem(IntPtr hWnd, Device device, SwapChain swapChain, HmdDevice hmd, bool bStereoRendering, int multiThreadCount) { m_d3d = new D3DData { Device = device, SwapChain = swapChain, WindowHandle = hWnd, }; m_debug = new DrawDebugCtrl(); m_repository = new DrawResourceRepository(m_d3d); m_passCtrl = new DrawPassCtrl(m_d3d, m_repository, hmd, bStereoRendering, multiThreadCount); m_bStereoRendering = bStereoRendering; m_hmd = hmd; if (m_hmd != null) { m_hmd.Setup(m_d3d, m_repository.GetDefaultRenderTarget()); } m_drawBuffer = new DrawBuffer(); }
public StereoDrawContext(DrawSystem.D3DData d3d, DrawResourceRepository repository, HmdDevice hmd, DrawContext context) { m_d3d = d3d; m_repository = repository; m_context = context; m_hmd = hmd; // Create render targets for each HMD eye m_textureSets = new HmdSwapTextureSet[2]; var eyeResolution = hmd.EyeResolution; var resNames = new string[] { "OVRLeftEye", "OVRRightEye" }; for (int index = 0; index < 2; ++index) { var textureSet = m_hmd.CreateSwapTextureSet(d3d.Device, eyeResolution.Width, eyeResolution.Height); m_textureSets[index] = textureSet; var renderTargetList = RenderTarget.FromSwapTextureSet(m_d3d, resNames[index], textureSet); foreach (var renderTarget in renderTargetList) { m_repository.AddResource(renderTarget); } } // Create temporaly render target var tmpRt = RenderTarget.CreateRenderTarget(d3d, "Temp", eyeResolution.Width, eyeResolution.Height); m_repository.AddResource(tmpRt); // Create texture for Mirroring Size defaultRenderTargetSize = m_repository.GetDefaultRenderTarget().Resolution; m_mirrorTexture = m_hmd.CreateMirrorTexture(m_d3d.Device, defaultRenderTargetSize.Width, defaultRenderTargetSize.Height); m_commandListTable = new List <CommandList>(); }
public Factory(DrawSystem.D3DData d3d, DrawResourceRepository repository) { m_initParam.D3D = d3d; m_initParam.Repository = repository; m_initParam.WorldVtxConst = DrawUtil.CreateConstantBuffer <_VertexShaderConst_World>(d3d, 1); m_initParam.WorldPixConst = DrawUtil.CreateConstantBuffer <_PixelShaderConst_World>(d3d, 1); m_initParam.RasterizerState = new RasterizerState(d3d.Device, new RasterizerStateDescription() { CullMode = CullMode.Back, FillMode = FillMode.Solid, IsAntialiasedLineEnabled = false, // we do not use wireframe IsDepthClipEnabled = true, IsMultisampleEnabled = false, }); var renderModes = new[] { DrawSystem.RenderMode.Opaque, DrawSystem.RenderMode.Transparency }; m_initParam.BlendStates = new BlendState[renderModes.Length]; foreach (DrawSystem.RenderMode mode in renderModes) { int index = (int)mode; m_initParam.BlendStates[index] = _CreateBlendState(d3d, mode); } m_initParam.DepthStencilStates = new DepthStencilState[renderModes.Length]; foreach (DrawSystem.RenderMode mode in renderModes) { int index = (int)mode; m_initParam.DepthStencilStates[index] = _CreateDepthStencilState(d3d, mode); } { var shader = new Effect( "Std", d3d, new InputElement[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 28, 0), new InputElement("TANGENT", 0, Format.R32G32B32_Float, 0, 1), new InputElement("BONEINDEX", 0, Format.R32G32B32A32_UInt, 0, 2), new InputElement("BONEWEIGHT", 0, Format.R32G32B32A32_Float, 16, 2), }, "Shader/VS_Std.fx", "Shader/PS_Std.fx"); repository.AddResource(shader); } { var shader = new Effect( "Minimap", d3d, new InputElement[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("NORMAL", 0, Format.R32G32B32_Float, 16, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 28, 0), new InputElement("TANGENT", 0, Format.R32G32B32_Float, 0, 1), new InputElement("BONEINDEX", 0, Format.R32G32B32A32_UInt, 0, 2), new InputElement("BONEWEIGHT", 0, Format.R32G32B32A32_Float, 16, 2), }, "Shader/VS_Std.fx", "Shader/PS_Minimap.fx"); repository.AddResource(shader); } { var shader = new Effect( "Debug", d3d, new InputElement[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0), }, "Shader/VS_Debug.fx", "Shader/PS_Debug.fx"); repository.AddResource(shader); } }
public MonoralDrawContext(DrawSystem.D3DData d3d, DrawResourceRepository repository, DrawContext context) { m_d3d = d3d; m_repository = repository; m_context = context; }