public Dictionary <BindpointMap, BoundResource[]> GetReadWriteResources(ShaderStageType stage) { var ret = new Dictionary <BindpointMap, BoundResource[]>(); if (LogLoaded) { if (IsLogD3D11) { if (stage == ShaderStageType.Compute) { for (int i = 0; i < m_D3D11.m_CS.UAVs.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = m_D3D11.m_CS.UAVs[i].Resource; val.HighestMip = (int)m_D3D11.m_CS.UAVs[i].HighestMip; val.FirstSlice = (int)m_D3D11.m_CS.UAVs[i].FirstArraySlice; ret.Add(key, new BoundResource[] { val }); } } else { for (int i = 0; i < m_D3D11.m_OM.UAVs.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = m_D3D11.m_OM.UAVs[i].Resource; val.HighestMip = (int)m_D3D11.m_OM.UAVs[i].HighestMip; val.FirstSlice = (int)m_D3D11.m_OM.UAVs[i].FirstArraySlice; ret.Add(key, new BoundResource[] { val }); } } return(ret); } else if (IsLogGL) { for (int i = 0; i < m_GL.Images.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = m_GL.Images[i].Resource; val.HighestMip = (int)m_GL.Images[i].Level; val.FirstSlice = (int)m_GL.Images[i].Layer; ret.Add(key, new BoundResource[] { val }); } return(ret); } else if (IsLogVK) { VulkanPipelineState.Pipeline.DescriptorSet[] descsets = m_Vulkan.graphics.DescSets; if (stage == ShaderStageType.Compute) { descsets = m_Vulkan.compute.DescSets; } ShaderStageBits mask = (ShaderStageBits)(1 << (int)stage); for (int set = 0; set < descsets.Length; set++) { var descset = descsets[set]; for (int slot = 0; slot < descset.bindings.Length; slot++) { var bind = descset.bindings[slot]; if ((bind.type == ShaderBindType.ReadWriteBuffer || bind.type == ShaderBindType.ReadWriteImage || bind.type == ShaderBindType.ReadWriteTBuffer ) && (bind.stageFlags & mask) == mask) { var key = new BindpointMap(set, slot); var val = new BoundResource[bind.descriptorCount]; for (UInt32 i = 0; i < bind.descriptorCount; i++) { val[i] = new BoundResource(); val[i].Id = bind.binds[i].res; val[i].HighestMip = (int)bind.binds[i].baseMip; val[i].FirstSlice = (int)bind.binds[i].baseLayer; } ret.Add(key, val); } } } return(ret); } } return(ret); }
public Dictionary <BindpointMap, BoundResource[]> GetReadOnlyResources(ShaderStageType stage) { var ret = new Dictionary <BindpointMap, BoundResource[]>(); if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } for (int i = 0; i < s.SRVs.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = s.SRVs[i].Resource; val.HighestMip = (int)s.SRVs[i].HighestMip; val.FirstSlice = (int)s.SRVs[i].FirstArraySlice; ret.Add(key, new BoundResource[] { val }); } return(ret); } else if (IsLogGL) { for (int i = 0; i < m_GL.Textures.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = m_GL.Textures[i].Resource; val.HighestMip = (int)m_GL.Textures[i].HighestMip; val.FirstSlice = (int)m_GL.Textures[i].FirstSlice; ret.Add(key, new BoundResource[] { val }); } return(ret); } else if (IsLogVK) { VulkanPipelineState.Pipeline.DescriptorSet[] descsets = m_Vulkan.graphics.DescSets; if (stage == ShaderStageType.Compute) { descsets = m_Vulkan.compute.DescSets; } ShaderStageBits mask = (ShaderStageBits)(1 << (int)stage); for (int set = 0; set < m_Vulkan.graphics.DescSets.Length; set++) { var descset = m_Vulkan.graphics.DescSets[set]; for (int slot = 0; slot < descset.bindings.Length; slot++) { var bind = descset.bindings[slot]; if ((bind.type == ShaderBindType.ImageSampler || bind.type == ShaderBindType.InputAttachment || bind.type == ShaderBindType.ReadOnlyImage || bind.type == ShaderBindType.ReadOnlyTBuffer ) && (bind.stageFlags & mask) == mask) { var key = new BindpointMap(set, slot); var val = new BoundResource[bind.descriptorCount]; for (UInt32 i = 0; i < bind.descriptorCount; i++) { val[i] = new BoundResource(); val[i].Id = bind.binds[i].res; val[i].HighestMip = (int)bind.binds[i].baseMip; val[i].FirstSlice = (int)bind.binds[i].baseLayer; } ret.Add(key, val); } } } return(ret); } } return(ret); }