public void Reload(DeviceResources deviceResources) { for (int i = 0; i < c_maxCameraPerRender; i++) { CameraDataBuffers[i].Reload(deviceResources, c_presentDataSize); } LightCameraDataBuffer.Reload(deviceResources, c_lightCameraDataSize); }
private void DesireLightingBuffers(DeviceResources deviceResources, int count) { while (lightingBuffers.Count < count) { ConstantBuffer constantBuffer = new ConstantBuffer(); constantBuffer.Reload(deviceResources, c_lightingDataSize); lightingBuffers.Add(constantBuffer); } }
public void DesireMaterialBuffers(int count) { while (MaterialBuffers.Count < count) { ConstantBuffer constantBuffer = new ConstantBuffer(); constantBuffer.Reload(deviceResources, c_materialDataSize); MaterialBuffers.Add(constantBuffer); } }
public void SetSlienceCount(DeviceResources deviceResources, int count) { int slience1 = (count + sliencesPerBuffer - 1) / sliencesPerBuffer; while (constantBuffers.Count < slience1) { ConstantBuffer buffer1 = new ConstantBuffer(); buffer1.Reload(deviceResources, bufferSize); constantBuffers.Add(buffer1); } }
public async Task ReloadDefalutResources(ProcessingList processingList, MiscProcessContext miscProcessContext) { for (int i = 0; i < CameraDataBuffers.Length; i++) { CameraDataBuffers[i].Reload(deviceResources, c_presentDataSize); } LightCameraDataBuffer.Reload(deviceResources, c_lightingBufferSize); 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 async Task ReloadAssets(DeviceResources deviceResources) { rootSignature.ReloadCompute(deviceResources, new GraphicSignatureDesc[] { GraphicSignatureDesc.CBV, GraphicSignatureDesc.CBV, GraphicSignatureDesc.SRVTable, GraphicSignatureDesc.UAVTable, }); constantBuffers.Reload(deviceResources, c_bufferSize); IrradianceMap0.Reload(deviceResources, rootSignature, await ReadFile("ms-appx:///Coocoo3DGraphics/G_IrradianceMap0.cso")); EnvironmentMap0.Reload(deviceResources, rootSignature, await ReadFile("ms-appx:///Coocoo3DGraphics/G_PreFilterEnv.cso")); ClearIrradianceMap.Reload(deviceResources, rootSignature, await ReadFile("ms-appx:///Coocoo3DGraphics/G_ClearIrradianceMap.cso")); Ready = true; }
public void UpdateGPUResource() { #region Update bone data int count = dynamicContextRead.entities.Count; while (CBs_Bone.Count < count) { ConstantBuffer constantBuffer = new ConstantBuffer(); constantBuffer.Reload(deviceResources, c_entityDataBufferSize); CBs_Bone.Add(constantBuffer); } _Data1 data1 = new _Data1(); Vector3 camPos = dynamicContextRead.cameras[0].Pos; for (int i = 0; i < count; i++) { var entity = dynamicContextRead.entities[i]; var rendererComponent = entity.rendererComponent; data1.vertexCount = rendererComponent.meshVertexCount; data1.indexCount = rendererComponent.meshIndexCount; IntPtr ptr1 = Marshal.UnsafeAddrOfPinnedArrayElement(bigBuffer, 0); Matrix4x4 world = Matrix4x4.CreateFromQuaternion(entity.Rotation) * Matrix4x4.CreateTranslation(entity.Position - camPos); Marshal.StructureToPtr(Matrix4x4.Transpose(world), ptr1, true); Marshal.StructureToPtr(rendererComponent.amountAB, ptr1 + 64, true); Marshal.StructureToPtr(rendererComponent.meshVertexCount, ptr1 + 68, true); Marshal.StructureToPtr(rendererComponent.meshIndexCount, ptr1 + 72, true); Marshal.StructureToPtr(data1, ptr1 + 80, true); graphicsContext.UpdateResource(CBs_Bone[i], bigBuffer, 256, 0); graphicsContext.UpdateResourceRegion(CBs_Bone[i], 256, dynamicContextRead.entities[i].boneComponent.boneMatricesData, 65280, 0); data1.vertexStart += rendererComponent.meshVertexCount; data1.indexStart += rendererComponent.meshIndexCount; if (rendererComponent.meshNeedUpdateA) { graphicsContext.UpdateVerticesPos(rendererComponent.meshAppend, rendererComponent.meshPosData1, 0); rendererComponent.meshNeedUpdateA = false; } if (rendererComponent.meshNeedUpdateB) { graphicsContext.UpdateVerticesPos(rendererComponent.meshAppend, rendererComponent.meshPosData2, 1); rendererComponent.meshNeedUpdateB = false; } } #endregion }