private async Task ReloadTexture2DNoMip(Texture2D texture2D, ProcessingList processingList, string uri) { Uploader uploader = new Uploader(); uploader.Texture2D(await FileIO.ReadBufferAsync(await StorageFile.GetFileFromApplicationUriAsync(new Uri(uri))), false, false); processingList.AddObject(new Texture2DUploadPack(texture2D, uploader)); }
public async Task ReloadDefalutResources(ProcessingList processingList, MiscProcessContext miscProcessContext) { for (int i = 0; i < CameraDataBuffers.Length; i++) { CameraDataBuffers[i].Reload(deviceResources, c_presentDataSize); } for (int i = 0; i < LightCameraDataBuffers.Length; i++) { LightCameraDataBuffers[i].Reload(deviceResources, c_presentDataSize); } HighResolutionShadowNow = true; ChangeShadowMapsQuality(processingList, false); Uploader upTexLoading = new Uploader(); Uploader upTexError = new Uploader(); upTexLoading.Texture2DPure(1, 1, new Vector4(0, 1, 1, 1)); upTexError.Texture2DPure(1, 1, new Vector4(1, 0, 1, 1));; processingList.AddObject(new Texture2DUploadPack(TextureLoading, upTexLoading)); processingList.AddObject(new Texture2DUploadPack(TextureError, upTexError)); Uploader upTexPostprocessBackground = new Uploader(); upTexPostprocessBackground.Texture2DPure(64, 64, new Vector4(1, 1, 1, 0)); processingList.AddObject(new Texture2DUploadPack(postProcessBackground, upTexPostprocessBackground)); Uploader upTexEnvCube = new Uploader(); upTexEnvCube.TextureCubePure(32, 32, new Vector4[] { new Vector4(0.2f, 0.16f, 0.16f, 1), new Vector4(0.16f, 0.2f, 0.16f, 1), new Vector4(0.2f, 0.2f, 0.2f, 1), new Vector4(0.16f, 0.2f, 0.2f, 1), new Vector4(0.2f, 0.2f, 0.16f, 1), new Vector4(0.16f, 0.16f, 0.2f, 1) }); IrradianceMap.ReloadAsRTVUAV(32, 32, 1, DxgiFormat.DXGI_FORMAT_R32G32B32A32_FLOAT); EnvironmentMap.ReloadAsRTVUAV(1024, 1024, 7, DxgiFormat.DXGI_FORMAT_R16G16B16A16_FLOAT); miscProcessContext.Add(new P_Env_Data() { source = SkyBox, IrradianceMap = IrradianceMap, EnvMap = EnvironmentMap, Level = 16 }); processingList.AddObject(new TextureCubeUploadPack(SkyBox, upTexEnvCube)); processingList.AddObject(IrradianceMap); processingList.AddObject(EnvironmentMap); ndcQuadMesh.ReloadNDCQuad(); ndcQuadMeshIndexCount = ndcQuadMesh.m_indexCount; processingList.AddObject(ndcQuadMesh); cubeMesh.ReloadCube(); cubeMeshIndexCount = cubeMesh.m_indexCount; processingList.AddObject(cubeMesh); cubeWireMesh.ReloadCubeWire(); cubeWireMeshIndexCount = cubeWireMesh.m_indexCount; processingList.AddObject(cubeWireMesh); await ReloadTexture2DNoMip(BRDFLut, processingList, "ms-appx:///Assets/Textures/brdflut.png"); await ReloadTexture2DNoMip(UI1Texture, processingList, "ms-appx:///Assets/Textures/UI_1.png"); Initilized = true; }
public void ReloadShaders(ProcessingList processingList, RPAssetsManager RPAssetsManager, Action _RequireRender) { if (shaderTaskLocker.GetLocker()) { List <RPShaderPack> packs = new List <RPShaderPack>(); lock (RPShaderPackCaches) foreach (var shaderPack in RPShaderPackCaches.Values) { packs.Add(shaderPack); } for (int i = 0; i < packs.Count; i++) { var shaderPack1 = packs[i]; if (shaderPack1.loadLocker.GetLocker()) { Task.Factory.StartNew(async(object a) => { RPShaderPack pack1 = (RPShaderPack)a; try { var file = await pack1.folder.GetFileAsync(pack1.relativePath); var attr = await file.GetBasicPropertiesAsync(); if (attr.DateModified != pack1.lastModifiedTime || pack1.Status == GraphicsObjectStatus.error) { pack1.lastModifiedTime = attr.DateModified; pack1.Mark(GraphicsObjectStatus.loading); _RequireRender(); if (await pack1.Reload(file, RPAssetsManager, processingList)) { } _RequireRender(); } } catch { pack1.Mark(GraphicsObjectStatus.error); _RequireRender(); } finally { pack1.loadLocker.FreeLocker(); } }, shaderPack1); } } shaderTaskLocker.FreeLocker(); } }
public void ReloadTextures(ProcessingList processingList, Action _RequireRender) { if (textureTaskLocker.GetLocker()) { List <Texture2DPack> packs = new List <Texture2DPack>(); lock (TextureCaches) foreach (var texturePack in TextureCaches.Values) { packs.Add(texturePack); } for (int i = 0; i < packs.Count; i++) { var tex = packs[i]; if (tex.loadLocker.GetLocker()) { Task.Factory.StartNew(async(object a) => { Texture2DPack texturePack1 = (Texture2DPack)a; try { var file = await texturePack1.folder.GetFileAsync(texturePack1.relativePath); var attr = await file.GetBasicPropertiesAsync(); if (attr.DateModified != texturePack1.lastModifiedTime || texturePack1.texture2D.Status != GraphicsObjectStatus.loaded) { Uploader uploader = new Uploader(); if (await texturePack1.ReloadTexture(file, uploader)) { processingList.AddObject(new Texture2DUploadPack(texturePack1.texture2D, uploader)); } _RequireRender(); texturePack1.lastModifiedTime = attr.DateModified; } } catch { texturePack1.Mark(GraphicsObjectStatus.error); _RequireRender(); } finally { texturePack1.loadLocker.FreeLocker(); } }, tex); } } textureTaskLocker.FreeLocker(); } }
public void MoveToAnother(ProcessingList another) { Move1(TextureCubeLoadList, another.TextureCubeLoadList); Move1(Texture2DLoadList, another.Texture2DLoadList); Move1(RenderTextureUpdateList, another.RenderTextureUpdateList); Move1(MMDMeshLoadList, another.MMDMeshLoadList); Move1(MMDMeshLoadList2, another.MMDMeshLoadList2); Move1(readBackTextureList, another.readBackTextureList); Move1(twinBufferList, another.twinBufferList); Move1(pobjectList, another.pobjectList); for (int i = 0; i < computePObjectLists.Length; i++) { Move1(computePObjectLists[i], another.computePObjectLists[i]); } }
public void ChangeRenderTargetFormat(DeviceResources deviceResources, ProcessingList uploadProcess, DxgiFormat outputFormat, DxgiFormat middleFormat, DxgiFormat swapChainFormat, DxgiFormat depthFormat) { Ready = false; this.outputFormat = outputFormat; this.middleFormat = middleFormat; this.depthFormat = depthFormat; PObjectMMDSkinning.ReloadSkinning(VSMMDSkinning2, null); uploadProcess.UL(PObjectMMDSkinning, 1); PObjectMMD.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMD, outputFormat, depthFormat); PObjectMMDTransparent.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMDTransparent, outputFormat, depthFormat); PObjectMMD_DisneyBrdf.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMD_DisneyBrdf, outputFormat, depthFormat); PObjectMMD_Toon1.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMD_Toon1, outputFormat, depthFormat); PObjectMMDLoading.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMDLoading, outputFormat, depthFormat); PObjectMMDError.ReloadDrawing(BlendState.alpha, VSMMDTransform, null, PSMMDError, outputFormat, depthFormat); uploadProcess.UL(PObjectMMD, 0); uploadProcess.UL(PObjectMMDTransparent, 0); uploadProcess.UL(PObjectMMD_DisneyBrdf, 0); uploadProcess.UL(PObjectMMD_Toon1, 0); uploadProcess.UL(PObjectMMDLoading, 0); uploadProcess.UL(PObjectMMDError, 0); PObjectDeferredRenderGBuffer.ReloadDrawing(BlendState.none, VSMMDTransform, null, PSDeferredRenderGBuffer, middleFormat, depthFormat, 3); PObjectDeferredRenderIBL.ReloadDrawing(BlendState.add, VSSkyBox, null, PSDeferredRenderIBL, outputFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectDeferredRenderDirectLight.ReloadDrawing(BlendState.add, VSSkyBox, null, PSDeferredRenderDirectLight, outputFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectDeferredRenderPointLight.ReloadDrawing(BlendState.add, VSDeferredRenderPointLight, null, PSDeferredRenderPointLight, outputFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); uploadProcess.UL(PObjectDeferredRenderGBuffer, 0); uploadProcess.UL(PObjectDeferredRenderIBL, 0); uploadProcess.UL(PObjectDeferredRenderDirectLight, 0); uploadProcess.UL(PObjectDeferredRenderPointLight, 0); //PObjectMMDShadowDepth.ReloadDepthOnly(VSMMDTransform, PSMMDAlphaClip, 2500); PObjectMMDShadowDepth.ReloadDepthOnly(VSMMDTransform, null, 2500, depthFormat); PObjectMMDDepth.ReloadDepthOnly(VSMMDTransform, PSMMDAlphaClip1, 0, depthFormat); uploadProcess.UL(PObjectMMDShadowDepth, 0); uploadProcess.UL(PObjectMMDDepth, 0); PObjectSkyBox.Reload(deviceResources, rootSignature, eInputLayout.postProcess, BlendState.none, VSSkyBox, null, PSSkyBox, outputFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectPostProcess.Reload(deviceResources, rootSignaturePostProcess, eInputLayout.postProcess, BlendState.none, VSPostProcess, null, PSPostProcess, swapChainFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectWidgetUI1.Reload(deviceResources, rootSignaturePostProcess, eInputLayout.postProcess, BlendState.alpha, VSWidgetUI1, null, PSWidgetUI1, swapChainFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectWidgetUI2.Reload(deviceResources, rootSignaturePostProcess, eInputLayout.postProcess, BlendState.alpha, VSWidgetUI2, null, PSWidgetUI2, swapChainFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN); PObjectWidgetUILight.Reload(deviceResources, rootSignaturePostProcess, eInputLayout.postProcess, BlendState.alpha, VSWidgetUILight, null, PSWidgetUILight, swapChainFormat, DxgiFormat.DXGI_FORMAT_UNKNOWN, D3D12PrimitiveTopologyType.LINE); Ready = true; }
public void _DealStep3(DeviceResources deviceResources, ProcessingList uploadProcess) { foreach (var a in uploadProcess.pobjectLists[0]) { a.Upload(deviceResources, rootSignature); } foreach (var a in uploadProcess.pobjectLists[1]) { a.Upload(deviceResources, rootSignatureSkinning); } foreach (var a in uploadProcess.pobjectLists[2]) { a.Upload(deviceResources, rootSignaturePostProcess); } foreach (var a in uploadProcess.computePObjectLists[0]) { a.Upload(deviceResources, rootSignatureCompute); } }
public void ChangeShadowMapsQuality(ProcessingList processingList, bool highQuality) { if (HighResolutionShadowNow == highQuality) { return; } HighResolutionShadowNow = highQuality; void _Quality(int x, int y) { ShadowMapCube.ReloadAsDSV(x, y, depthFormat); processingList.UnsafeAdd(ShadowMapCube); } if (highQuality) { _Quality(c_shadowMapResolutionHigh, c_shadowMapResolutionHigh); } else { _Quality(c_shadowMapResolutionLow, c_shadowMapResolutionLow); } }
public void ReloadTextureSizeResources(ProcessingList processingList) { int x = Math.Max((int)Math.Round(deviceResources.GetOutputSize().Width), 1); int y = Math.Max((int)Math.Round(deviceResources.GetOutputSize().Height), 1); outputRTV.ReloadAsRTVUAV(x, y, outputFormat); processingList.UnsafeAdd(outputRTV); for (int i = 0; i < ScreenSizeRenderTextures.Length; i++) { ScreenSizeRenderTextures[i].ReloadAsRTVUAV(x, y, gBufferFormat); processingList.UnsafeAdd(ScreenSizeRenderTextures[i]); } for (int i = 0; i < ScreenSizeDSVs.Length; i++) { ScreenSizeDSVs[i].ReloadAsDepthStencil(x, y, depthFormat); processingList.UnsafeAdd(ScreenSizeDSVs[i]); } ReadBackTexture2D.Reload(x, y, 4); processingList.UnsafeAdd(ReadBackTexture2D); screenWidth = x; screenHeight = y; dpi = deviceResources.GetDpi(); logicScale = dpi / 96.0f; }