private static uint GenerateTextureIndex(MyLiveData emitter) { if (emitter.GPUEmitter.AtlasDimension.X >= MAX_ATLAS_DIMENSION) { MyRenderProxy.Error("emitter.AtlasDimension.X < " + MAX_ATLAS_DIMENSION); } if (emitter.GPUEmitter.AtlasDimension.Y >= MAX_ATLAS_DIMENSION) { MyRenderProxy.Error("emitter.AtlasDimension.Y < " + MAX_ATLAS_DIMENSION); } uint atlasOffset = (uint)emitter.GPUEmitter.AtlasFrameOffset; if (atlasOffset >= MAX_ATLAS_INDEX) { MyRenderProxy.Error("atlasOffset < " + MAX_ATLAS_INDEX); } if (emitter.GPUEmitter.AtlasFrameModulo >= ((1 << ATLAS_INDEX_BITS) - 1)) { MyRenderProxy.Error("emitter.AtlasFrameModulo < " + ((1 << ATLAS_INDEX_BITS) - 1)); } if ((emitter.GPUEmitter.AtlasFrameOffset + emitter.GPUEmitter.AtlasFrameModulo - 1) >= (emitter.GPUEmitter.AtlasDimension.X * emitter.GPUEmitter.AtlasDimension.Y)) { MyRenderProxy.Error("Emitter animation is out of bounds. (emitter.AtlasFrameOffset + emitter.AtlasFrameModulo - 1) < (emitter.AtlasDimension.X * emitter.AtlasDimension.Y)"); } return(atlasOffset | ((uint)emitter.GPUEmitter.AtlasDimension.X << (ATLAS_INDEX_BITS + ATLAS_DIMENSION_BITS)) | ((uint)emitter.GPUEmitter.AtlasDimension.Y << (ATLAS_INDEX_BITS))); }
public void Init(MyStandardMaterialKey key) { if (key.Technique == MyMeshDrawTechnique.MESH) { InitStandard(key.CmFilepath, key.NgFilepath, key.ExtFilepath); } else if (key.Technique == MyMeshDrawTechnique.DECAL) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, false); } else if (key.Technique == MyMeshDrawTechnique.DECAL_NOPREMULT) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, false, false); } else if (key.Technique == MyMeshDrawTechnique.DECAL_CUTOUT) { InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, true); } else if (key.Technique == MyMeshDrawTechnique.ALPHA_MASKED) { InitAlphamask(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath); } else if (key.Technique == MyMeshDrawTechnique.GLASS) { MyRenderProxy.Error("Glass material cannot be processed by this object"); } else { MyRenderProxy.Error("Material is not resolved, please extend the functionality of the new pipeline or move object to the old pipeline"); } }
MyVertexInputComponent[] GetVertexInputComponents(MyRenderPassType pass) { if (pass == MyRenderPassType.GBuffer) { List <MyVertexInputComponent> listGBuffer = new List <MyVertexInputComponent>(); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED)); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1)); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1)); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.SIMPLE_INSTANCE, 2, MyVertexInputComponentFreq.PER_INSTANCE)); listGBuffer.Add(new MyVertexInputComponent(MyVertexInputComponentType.SIMPLE_INSTANCE_COLORING, 2, MyVertexInputComponentFreq.PER_INSTANCE)); return(listGBuffer.ToArray()); } else if (pass == MyRenderPassType.Depth) { List <MyVertexInputComponent> listDepth = new List <MyVertexInputComponent>(); listDepth.Add(new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED)); listDepth.Add(new MyVertexInputComponent(MyVertexInputComponentType.SIMPLE_INSTANCE, 2, MyVertexInputComponentFreq.PER_INSTANCE)); return(listDepth.ToArray()); } else if (pass == MyRenderPassType.Highlight) { List <MyVertexInputComponent> listHighlight = new List <MyVertexInputComponent>(); listHighlight.Add(new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED)); listHighlight.Add(new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1)); listHighlight.Add(new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1)); listHighlight.Add(new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)); return(listHighlight.ToArray()); } MyRenderProxy.Error("Unknown pass"); return(null); }
void AddMacrosForRenderingPass(MyRenderPassType pass, ref List <ShaderMacro> macros) { if (pass == MyRenderPassType.GBuffer) { macros.AddRange(new ShaderMacro[] { new ShaderMacro("RENDERING_PASS", 0), new ShaderMacro("USE_SIMPLE_INSTANCING", null), new ShaderMacro("USE_SIMPLE_INSTANCING_COLORING", null), }); } else if (pass == MyRenderPassType.Depth) { macros.AddRange(new ShaderMacro[] { new ShaderMacro("RENDERING_PASS", 1), new ShaderMacro("USE_SIMPLE_INSTANCING", null), }); } else if (pass == MyRenderPassType.Highlight) { macros.AddRange(new ShaderMacro[] { new ShaderMacro("RENDERING_PASS", 3), }); } else { MyRenderProxy.Error("Unknown render pass type"); } }
public void OnDeviceInit() { ISrvBindable firstTex = MyManagers.FileTextures.GetTexture(m_listSubresourceFilenames[0], m_type, true); var srcDesc = firstTex.Srv.Description; Vector2I Size = firstTex.Size; Texture2DDescription desc = new Texture2DDescription(); desc.ArraySize = m_listSubresourceFilenames.Count; desc.BindFlags = BindFlags.ShaderResource; desc.CpuAccessFlags = CpuAccessFlags.None; desc.Format = srcDesc.Format; desc.Height = (int)Size.Y; desc.Width = (int)Size.X; desc.MipLevels = srcDesc.Texture2D.MipLevels; desc.SampleDescription.Count = 1; desc.SampleDescription.Quality = 0; desc.Usage = ResourceUsage.Default; m_resource = new Texture2D(MyRender11.Device, desc); m_resource.DebugName = m_resourceName; TextureFormat = srcDesc.Format; // foreach mip var mipmaps = srcDesc.Texture2D.MipLevels; int i = 0; foreach (var path in m_listSubresourceFilenames) { ISrvBindable tex = MyManagers.FileTextures.GetTexture(path, m_type, true); var tex2D = tex.Resource as Texture2D; MyRenderProxy.Assert(tex2D != null, "MyTextureArray supports only 2D textures. Inconsistent texture: " + tex.Name); bool consistent = MyResourceUtils.CheckTexturesConsistency(desc, tex2D.Description); if (!consistent) { string errorMsg = "All MyTextureArray has to have the same pixel format, width / height and # of mipmaps. Inconsistent textures: " + tex.Name + " / " + firstTex.Name; MyRenderProxy.Error(errorMsg); MyRender11.Log.WriteLine(errorMsg); } for (int m = 0; m < mipmaps; m++) { MyRender11.RC.CopySubresourceRegion(tex2D, Resource.CalculateSubResourceIndex(m, 0, mipmaps), null, Resource, Resource.CalculateSubResourceIndex(m, i, mipmaps)); int sizeX = Resource.CalculateMipSize(m, Size.X); int sizeY = Resource.CalculateMipSize(m, Size.Y); ByteSize += FormatHelper.ComputeScanlineCount(TextureFormat, sizeX) * 4 * FormatHelper.ComputeScanlineCount(TextureFormat, sizeY) * 4 * FormatHelper.SizeOfInBytes(TextureFormat); } i++; } m_srv = new ShaderResourceView(MyRender11.Device, Resource); }
static void DebugRecordMeshPartCommands(MeshId model, string sectionName, MyMeshMaterialId material) { MyRenderProxy.Error("DebugRecordMeshPartCommands2: Call Francesco"); MyLog.Default.WriteLine("DebugRecordMeshPartCommands2"); MyLog.Default.WriteLine("sectionName: " + sectionName); MyLog.Default.WriteLine("model.Info.Name: " + model.Info.Name); MyLog.Default.WriteLine("material.Info.Name: " + material.Info.Name); }
MyPart FindPart(List <MyPart> parts, string name) { foreach (var part in parts) { if (part.Name == name) { return(part); } } MyRenderProxy.Error("MaterialName in section cannot be found"); return(null); }
IBlendState GetAlphamaskBlendState(string cmFilepath, string ngFilepath, string extFilepath, bool isPremultipliedAlpha) { bool isCm = !string.IsNullOrEmpty(cmFilepath); bool isNg = !string.IsNullOrEmpty(ngFilepath); bool isExt = !string.IsNullOrEmpty(extFilepath); if (isCm && isNg && isExt) { if (isPremultipliedAlpha) { return(MyBlendStateManager.BlendDecalNormalColorExt); } else { return(MyBlendStateManager.BlendDecalNormalColorExtNoPremult); } } if (isCm && isNg && !isExt) { if (isPremultipliedAlpha) { return(MyBlendStateManager.BlendDecalNormalColor); } else { return(MyBlendStateManager.BlendDecalNormalColorNoPremult); } } if (!isCm && isNg && !isExt) { if (isPremultipliedAlpha) { return(MyBlendStateManager.BlendDecalNormal); } else { return(MyBlendStateManager.BlendDecalNormalNoPremult); } } if (isCm && !isNg && !isExt) { if (isPremultipliedAlpha) { return(MyBlendStateManager.BlendDecalColor); } else { return(MyBlendStateManager.BlendDecalColorNoPremult); } } MyRenderProxy.Error("Unknown alphamask texture pattern"); return(null); }
static void DebugRecordMeshPartCommands(MeshId model, string sectionName, MyRenderableComponent render, MyRenderLod renderLod, MyMeshSectionPartInfo1[] meshes, int index) { MyRenderProxy.Error("DebugRecordMeshPartCommands1: Call Francesco"); MyLog.Default.WriteLine("DebugRecordMeshPartCommands1"); MyLog.Default.WriteLine("sectionName: " + sectionName); MyLog.Default.WriteLine("model.Info.Name: " + model.Info.Name); MyLog.Default.WriteLine("render.CurrentLod: " + render.CurrentLod); MyLog.Default.WriteLine("renderLod.RenderableProxies.Length: " + renderLod.RenderableProxies.Length); MyLog.Default.WriteLine("meshes.Length: " + meshes.Length); MyLog.Default.WriteLine("Mesh index: " + index); MyLog.Default.WriteLine("Mesh part index: " + meshes[index].PartIndex); }
internal void Init() { var srcData = MyTextures.Textures.Data[m_mergeList[0].Index]; var srcDesc = MyTextures.GetView(m_mergeList[0]).Description; Size = MyTextures.GetSize(m_mergeList[0]); ArrayLen = m_mergeList.Length; Texture2DDescription desc = new Texture2DDescription(); desc.ArraySize = ArrayLen; desc.BindFlags = BindFlags.ShaderResource; desc.CpuAccessFlags = CpuAccessFlags.None; desc.Format = srcDesc.Format; desc.Height = (int)Size.Y; desc.Width = (int)Size.X; desc.MipLevels = srcDesc.Texture2D.MipLevels; desc.SampleDescription.Count = 1; desc.SampleDescription.Quality = 0; desc.Usage = ResourceUsage.Default; m_resource = new Texture2D(MyRender11.Device, desc); m_resource.DebugName = m_debugName; // foreach mip var mipmaps = srcDesc.Texture2D.MipLevels; for (int a = 0; a < ArrayLen; a++) { var data = MyTextures.Textures.Data[m_mergeList[a].Index]; var tex2D = data.Resource as Texture2D; MyRenderProxy.Assert(tex2D != null, "MyTextureArray supports only 2D textures. Inconsistent texture: " + data.Name); bool consistent = tex2D.Description.Format == desc.Format && tex2D.Description.MipLevels == desc.MipLevels && tex2D.Description.Width == desc.Width && tex2D.Description.Height == desc.Height; if (!consistent) { string errorMsg = "All MyTextureArray has to have the same pixel format, width / height and # of mipmaps. Inconsistent textures: " + data.Name + " / " + srcData.Name; MyRenderProxy.Error(errorMsg); MyRender11.Log.WriteLine(errorMsg); } for (int m = 0; m < mipmaps; m++) { MyRender11.DeviceContext.CopySubresourceRegion(tex2D, Resource.CalculateSubResourceIndex(m, 0, mipmaps), null, Resource, Resource.CalculateSubResourceIndex(m, a, mipmaps)); } } m_Srv = new ShaderResourceView(MyRender11.Device, Resource); }
public bool IsVisible(int passId) { if (MyPassIdResolver.IsGBufferPassId(passId)) { return(m_visibilityStrategy.GBufferVisibility); } else if (MyPassIdResolver.IsDepthPassId(passId)) { return(m_visibilityStrategy.DepthVisibility); } else { MyRenderProxy.Error("Unprocessed conditional"); } return(false); }
string GetShaderDirpath(MyMeshDrawTechnique technique) { switch (technique) { case MyMeshDrawTechnique.MESH: case MyMeshDrawTechnique.DECAL: case MyMeshDrawTechnique.DECAL_CUTOUT: case MyMeshDrawTechnique.DECAL_NOPREMULT: return("Geometry\\Materials\\Standard\\"); case MyMeshDrawTechnique.ALPHA_MASKED: return("Geometry\\Materials\\AlphaMasked\\"); default: MyRenderProxy.Error("Unknown technique"); return(""); } }
void AddMacrosForTechnique(MyMeshDrawTechnique technique, bool isCm, bool isNg, bool isExt, ref List <ShaderMacro> macros) { if (technique == MyMeshDrawTechnique.MESH) { } else if (technique == MyMeshDrawTechnique.ALPHA_MASKED) { macros.Add(new ShaderMacro("ALPHA_MASKED", null)); } else if (technique == MyMeshDrawTechnique.DECAL || technique == MyMeshDrawTechnique.DECAL_CUTOUT || technique == MyMeshDrawTechnique.DECAL_NOPREMULT) { if (technique == MyMeshDrawTechnique.DECAL_CUTOUT) { macros.Add(new ShaderMacro("STATIC_DECAL_CUTOUT", null)); } else { macros.Add(new ShaderMacro("STATIC_DECAL", null)); } if (isCm) { macros.Add(new ShaderMacro("USE_COLORMETAL_TEXTURE", null)); } if (isNg) { macros.Add(new ShaderMacro("USE_NORMALGLOSS_TEXTURE", null)); } if (isExt) { macros.Add(new ShaderMacro("USE_EXTENSION_TEXTURE", null)); } } else if (technique == MyMeshDrawTechnique.GLASS) { } else { MyRenderProxy.Error("The specific technique is not processed"); } }
string GetShaderFilepath(MyMeshDrawTechnique technique, MyShaderType type) { switch (technique) { case MyMeshDrawTechnique.MESH: case MyMeshDrawTechnique.DECAL: case MyMeshDrawTechnique.DECAL_CUTOUT: case MyMeshDrawTechnique.DECAL_NOPREMULT: case MyMeshDrawTechnique.GLASS: if (type == MyShaderType.SHADER_TYPE_VERTEX) { return("Geometry\\Materials\\Standard\\Vertex.hlsl"); } else if (type == MyShaderType.SHADER_TYPE_PIXEL) { return("Geometry\\Materials\\Standard\\Pixel.hlsl"); } else { MyRenderProxy.Error("Unresolved condition"); } return(""); case MyMeshDrawTechnique.ALPHA_MASKED: if (type == MyShaderType.SHADER_TYPE_VERTEX) { return("Geometry\\Materials\\AlphaMasked\\Vertex.hlsl"); } else if (type == MyShaderType.SHADER_TYPE_PIXEL) { return("Geometry\\Materials\\AlphaMasked\\Pixel.hlsl"); } return(""); default: MyRenderProxy.Error("Unknown technique"); return(""); } }
void SetSingleInstanceTransformStrategy() { if (m_transformStrategy is MySingleTransformStrategy) { return; } ITransformStrategy oldStrategy = m_transformStrategy; m_transformStrategy = MyObjectPoolManager.Allocate <MySingleTransformStrategy>(); m_transformStrategy.SetCoreMatrix(m_transformStrategy.GetCoreMatrixD()); if (oldStrategy is MyMultiTransformStrategy) { MyObjectPoolManager.Deallocate((MyMultiTransformStrategy)oldStrategy); } else if (oldStrategy is MySingleTransformStrategy) { MyObjectPoolManager.Deallocate((MySingleTransformStrategy)oldStrategy); } else { MyRenderProxy.Error("Unknown class"); } }
private void RenderCallback() { if (m_messageProcessingStart != MyTimeSpan.Zero) { MyTimeSpan messageQueueDuration = m_timer.Elapsed - m_messageProcessingStart; ProfilerShort.CustomValue("MessageQueue", 0, messageQueueDuration); } ProfilerShort.Begin("Wait"); m_waiter.Wait(); ProfilerShort.End(); m_frameStart = m_timer.Elapsed; ProfilerShort.Begin("PrepareDraw"); ProfilerShort.Begin("ProcessInvoke"); Action action; while (m_invokeQueue.TryDequeue(out action)) { action(); } ProfilerShort.End(); ProfilerShort.Begin("ApplyModeChanges"); ApplySettingsChanges(); ProfilerShort.End(); ProfilerShort.Begin("BeforeRender"); MyRenderStats.Generic.WriteFormat("Available GPU memory: {0} MB", (float)MyRenderProxy.GetAvailableTextureMemory() / 1024 / 1024, MyStatTypeEnum.CurrentValue, 300, 2); MyRenderProxy.BeforeRender(m_frameStart); ProfilerShort.End(); ProfilerShort.Begin("RenderWindow.BeforeDraw"); m_renderWindow.BeforeDraw(); ProfilerShort.End(); ProfilerShort.Begin("BeforeDraw(event)"); if (BeforeDraw != null) { BeforeDraw(); } ProfilerShort.End(); ProfilerShort.End(); ProfilerShort.Begin("Draw"); ProfilerShort.Begin("TestCooperativeLevel"); var deviceResult = MyRenderProxy.TestDeviceCooperativeLevel(); ProfilerShort.End(); if (!m_renderWindow.DrawEnabled) { ProfilerShort.Begin("ProcessMessages"); MyRenderProxy.ProcessMessages(); ProfilerShort.End(); } else if (deviceResult == MyRenderDeviceCooperativeLevel.Ok) { Draw(); } else { ProfilerShort.Begin("WaitForReset"); ProfilerShort.Begin("ProcessMessages"); MyRenderProxy.ProcessMessages(); ProfilerShort.End(); if (deviceResult == MyRenderDeviceCooperativeLevel.Lost) { ProfilerShort.Begin("DeviceLost"); Thread.Sleep(20); ProfilerShort.End(); } else if (deviceResult == MyRenderDeviceCooperativeLevel.NotReset) { ProfilerShort.Begin("DeviceReset"); Thread.Sleep(20); DeviceReset(); ProfilerShort.End(); } else { // TODO: OP! Log error code } ProfilerShort.End(); } ProfilerShort.End(); ProfilerShort.Begin("AfterRender"); MyRenderProxy.AfterRender(); ProfilerShort.End(); ProfilerShort.Begin("Present"); if (deviceResult == MyRenderDeviceCooperativeLevel.Ok && m_renderWindow.DrawEnabled) { this.DoBeforePresent(); try { MyRenderProxy.Present(); } catch (MyDeviceErrorException e) { // Present() ended up with an error -- don't try to recover MyRenderProxy.Error(e.Message, shouldTerminate: true); Exit(); } this.DoAfterPresent(); } ProfilerShort.End(); if (m_separateThread) { MyRenderProxy.GetRenderProfiler().Commit(); } m_messageProcessingStart = m_timer.Elapsed; if (MyRenderProxy.Settings.ForceSlowCPU) { Thread.Sleep(200); } }
public void OnDeviceInit() { MyFileTextureParams fileTexParams; bool ret = GetCorrectedFileTextureParams(out fileTexParams); //MyRenderProxy.Assert(ret, "It is not implemented mechanism, what to do, when none of the textures exist"); m_size = fileTexParams.Resolution; Texture2DDescription desc = new Texture2DDescription(); desc.ArraySize = m_listSubresourceFilenames.Count; desc.BindFlags = BindFlags.ShaderResource; desc.CpuAccessFlags = CpuAccessFlags.None; desc.Format = fileTexParams.Format; desc.Height = (int)Size.Y; desc.Width = (int)Size.X; var mipmaps = desc.MipLevels = fileTexParams.Mipmaps; desc.SampleDescription.Count = 1; desc.SampleDescription.Quality = 0; desc.Usage = ResourceUsage.Default; m_resource = new Texture2D(MyRender11.Device, desc); m_resource.DebugName = m_resourceName; TextureFormat = fileTexParams.Format; // foreach mip int i = 0; foreach (var path in m_listSubresourceFilenames) { bool isUsedCreatedGeneratedTexture = false; ISrvBindable tex = MyManagers.FileTextures.GetTexture(path, m_type, true); var tex2D = tex.Resource as Texture2D; MyRenderProxy.Assert(tex2D != null, "MyFileArrayTexture supports only 2D textures. Inconsistent texture: " + tex.Name); bool consistent = MyResourceUtils.CheckTexturesConsistency(desc, tex2D.Description); if (!consistent) { if (!string.IsNullOrEmpty(path) && MyFileSystem.FileExists(path)) { string msg = string.Format( "Texture {0} cannot be loaded. If this message is displayed on reloading textures, please restart the game. If it is not, please notify developers.", path); MyRenderProxy.Fail(msg); } } if (!consistent && m_recoverySystem.UseErrorTexture) // if the texture cannot be used, error texture will be used { tex = MyManagers.FileTextures.GetTexture(m_recoverySystem.TextureFilepath, m_type, true); tex2D = tex.Resource as Texture2D; MyRenderProxy.Assert(tex2D != null, "MyFileArrayTexture supports only 2D textures. Inconsistent texture: " + m_recoverySystem.TextureFilepath); consistent = MyResourceUtils.CheckTexturesConsistency(desc, tex2D.Description); } if (!consistent && m_recoverySystem.UseBytePattern) // if the texture cannot be used, byte pattern will be used to generate texture { tex = MyManagers.GeneratedTextures.CreateFromBytePattern("MyFileArrayTexture.Tmp", desc.Width, desc.Height, m_recoverySystem.FormatBytePattern, m_recoverySystem.BytePattern); tex2D = tex.Resource as Texture2D; MyRenderProxy.Assert(tex2D != null); consistent = MyResourceUtils.CheckTexturesConsistency(desc, tex2D.Description); isUsedCreatedGeneratedTexture = true; } if (!consistent) { Texture2DDescription desc1 = desc; Texture2DDescription desc2 = tex2D.Description; string errorMsg = string.Format("Textures ({0}) is not compatible within array texture! Width: ({1},{2}) Height: ({3},{4}) Mipmaps: ({5},{6}) Format: ({7},{8})", path, desc1.Width, desc2.Width, desc1.Height, desc2.Height, desc1.MipLevels, desc2.MipLevels, desc1.Format, desc2.Format); MyRenderProxy.Error(errorMsg); MyRender11.Log.WriteLine(errorMsg); } for (int m = 0; m < mipmaps; m++) { MyRender11.RC.CopySubresourceRegion(tex, Resource.CalculateSubResourceIndex(m, 0, mipmaps), null, Resource, Resource.CalculateSubResourceIndex(m, i, mipmaps)); int sizeX = Resource.CalculateMipSize(m, Size.X); int sizeY = Resource.CalculateMipSize(m, Size.Y); ByteSize += FormatHelper.ComputeScanlineCount(TextureFormat, sizeX) * 4 * FormatHelper.ComputeScanlineCount(TextureFormat, sizeY) * 4 * FormatHelper.SizeOfInBytes(TextureFormat); } if (isUsedCreatedGeneratedTexture) { IGeneratedTexture generatedTex = (IGeneratedTexture)tex; MyManagers.GeneratedTextures.DisposeTex(generatedTex); } i++; } m_srv = new ShaderResourceView(MyRender11.Device, Resource); }