Ejemplo n.º 1
0
        public BoundResource[] GetOutputTargets()
        {
            if (LogLoaded)
            {
                if (IsLogD3D11)
                {
                    BoundResource[] ret = new BoundResource[m_D3D11.m_OM.RenderTargets.Length];
                    for (int i = 0; i < m_D3D11.m_OM.RenderTargets.Length; i++)
                    {
                        ret[i]            = new BoundResource();
                        ret[i].Id         = m_D3D11.m_OM.RenderTargets[i].Resource;
                        ret[i].HighestMip = (int)m_D3D11.m_OM.RenderTargets[i].HighestMip;
                        ret[i].FirstSlice = (int)m_D3D11.m_OM.RenderTargets[i].FirstArraySlice;
                    }

                    return(ret);
                }
                else if (IsLogGL)
                {
                    BoundResource[] ret = new BoundResource[m_GL.m_FB.m_DrawFBO.DrawBuffers.Length];
                    for (int i = 0; i < m_GL.m_FB.m_DrawFBO.DrawBuffers.Length; i++)
                    {
                        ret[i] = new BoundResource();

                        int db = m_GL.m_FB.m_DrawFBO.DrawBuffers[i];

                        if (db >= 0)
                        {
                            ret[i].Id         = m_GL.m_FB.m_DrawFBO.Color[db].Obj;
                            ret[i].HighestMip = (int)m_GL.m_FB.m_DrawFBO.Color[db].Mip;
                            ret[i].FirstSlice = (int)m_GL.m_FB.m_DrawFBO.Color[db].Layer;
                        }
                    }

                    return(ret);
                }
                else if (IsLogVK)
                {
                    var rp = m_Vulkan.Pass.renderpass;
                    var fb = m_Vulkan.Pass.framebuffer;

                    BoundResource[] ret = new BoundResource[rp.colorAttachments.Length];
                    for (int i = 0; i < rp.colorAttachments.Length; i++)
                    {
                        ret[i] = new BoundResource();

                        if (rp.colorAttachments[i] < fb.attachments.Length)
                        {
                            ret[i].Id         = fb.attachments[rp.colorAttachments[i]].img;
                            ret[i].HighestMip = (int)fb.attachments[rp.colorAttachments[i]].baseMip;
                            ret[i].FirstSlice = (int)fb.attachments[rp.colorAttachments[i]].baseArray;
                        }
                    }

                    return(ret);
                }
            }

            return(new BoundResource[0]);
        }
Ejemplo n.º 2
0
        public BoundResource GetDepthTarget()
        {
            if (LogLoaded)
            {
                if (IsLogD3D11)
                {
                    var ret = new BoundResource();
                    ret.Id         = m_D3D11.m_OM.DepthTarget.Resource;
                    ret.HighestMip = (int)m_D3D11.m_OM.DepthTarget.HighestMip;
                    ret.FirstSlice = (int)m_D3D11.m_OM.DepthTarget.FirstArraySlice;
                    return(ret);
                }
                else if (IsLogGL)
                {
                    var ret = new BoundResource();
                    ret.Id         = m_GL.m_FB.m_DrawFBO.Depth.Obj;
                    ret.HighestMip = (int)m_GL.m_FB.m_DrawFBO.Depth.Mip;
                    ret.FirstSlice = (int)m_GL.m_FB.m_DrawFBO.Depth.Layer;
                    return(ret);
                }
                else if (IsLogVK)
                {
                    var rp = m_Vulkan.Pass.renderpass;
                    var fb = m_Vulkan.Pass.framebuffer;

                    if (rp.depthstencilAttachment >= 0 && rp.depthstencilAttachment < fb.attachments.Length)
                    {
                        var ret = new BoundResource();
                        ret.Id         = fb.attachments[rp.depthstencilAttachment].img;
                        ret.HighestMip = (int)fb.attachments[rp.depthstencilAttachment].baseMip;
                        ret.FirstSlice = (int)fb.attachments[rp.depthstencilAttachment].baseArray;
                        return(ret);
                    }

                    return(new BoundResource());
                }
            }

            return(new BoundResource());
        }
Ejemplo n.º 3
0
            public BoundResource GetBoundResource(Core core, int arrayIdx)
            {
                BoundResource ret = new BoundResource();

                if (Type == FollowType.OutputColour)
                {
                    var outputs = GetOutputTargets(core);

                    if (index < outputs.Length)
                        ret = outputs[index];
                }
                else if (Type == FollowType.OutputDepth)
                {
                    ret = GetDepthTarget(core);
                }
                else if (Type == FollowType.ReadWrite)
                {
                    var rw = GetReadWriteResources(core);

                    var mapping = GetMapping(core);

                    if (index < mapping.ReadWriteResources.Length)
                    {
                        var key = mapping.ReadWriteResources[index];

                        if (rw.ContainsKey(key))
                            ret = rw[key][arrayIdx];
                    }
                }
                else if (Type == FollowType.ReadOnly)
                {
                    var res = GetReadOnlyResources(core);

                    var mapping = GetMapping(core);

                    if (index < mapping.ReadOnlyResources.Length)
                    {
                        var key = mapping.ReadOnlyResources[index];

                        if (res.ContainsKey(key))
                            ret = res[key][arrayIdx];
                    }
                }

                return ret;
            }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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;
                            val.typeHint = m_D3D11.m_CS.UAVs[i].Format.compType;

                            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;
                            val.typeHint = FormatComponentType.None;

                            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;
                        val.typeHint = m_GL.Images[i].Format.compType;

                        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;
                                    val[i].typeHint = bind.binds[i].viewfmt.compType;
                                }

                                ret.Add(key, val);
                            }
                        }
                    }

                    return ret;
                }
            }

            return ret;
        }
Ejemplo n.º 7
0
        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;
                        val.typeHint = s.SRVs[i].Format.compType;

                        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;
                        val.typeHint = FormatComponentType.None;

                        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.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;
                                    val[i].typeHint = bind.binds[i].viewfmt.compType;
                                }

                                ret.Add(key, val);
                            }
                        }
                    }

                    return ret;
                }
            }

            return ret;
        }
Ejemplo n.º 8
0
        public BoundResource[] GetOutputTargets()
        {
            if (LogLoaded)
            {
                if (IsLogD3D11)
                {
                    BoundResource[] ret = new BoundResource[m_D3D11.m_OM.RenderTargets.Length];
                    for (int i = 0; i < m_D3D11.m_OM.RenderTargets.Length; i++)
                    {
                        ret[i] = new BoundResource();
                        ret[i].Id = m_D3D11.m_OM.RenderTargets[i].Resource;
                        ret[i].HighestMip = (int)m_D3D11.m_OM.RenderTargets[i].HighestMip;
                        ret[i].FirstSlice = (int)m_D3D11.m_OM.RenderTargets[i].FirstArraySlice;
                        ret[i].typeHint = m_D3D11.m_OM.RenderTargets[i].Format.compType;
                    }

                    return ret;
                }
                else if (IsLogGL)
                {
                    BoundResource[] ret = new BoundResource[m_GL.m_FB.m_DrawFBO.DrawBuffers.Length];
                    for (int i = 0; i < m_GL.m_FB.m_DrawFBO.DrawBuffers.Length; i++)
                    {
                        ret[i] = new BoundResource();

                        int db = m_GL.m_FB.m_DrawFBO.DrawBuffers[i];

                        if (db >= 0)
                        {
                            ret[i].Id = m_GL.m_FB.m_DrawFBO.Color[db].Obj;
                            ret[i].HighestMip = (int)m_GL.m_FB.m_DrawFBO.Color[db].Mip;
                            ret[i].FirstSlice = (int)m_GL.m_FB.m_DrawFBO.Color[db].Layer;
                            ret[i].typeHint = FormatComponentType.None;
                        }
                    }

                    return ret;
                }
                else if (IsLogVK)
                {
                    var rp = m_Vulkan.Pass.renderpass;
                    var fb = m_Vulkan.Pass.framebuffer;

                    BoundResource[] ret = new BoundResource[rp.colorAttachments.Length];
                    for (int i = 0; i < rp.colorAttachments.Length; i++)
                    {
                        ret[i] = new BoundResource();

                        if(rp.colorAttachments[i] < fb.attachments.Length)
                        {
                            ret[i].Id = fb.attachments[rp.colorAttachments[i]].img;
                            ret[i].HighestMip = (int)fb.attachments[rp.colorAttachments[i]].baseMip;
                            ret[i].FirstSlice = (int)fb.attachments[rp.colorAttachments[i]].baseLayer;
                            ret[i].typeHint = fb.attachments[rp.colorAttachments[i]].viewfmt.compType;
                        }
                    }

                    return ret;
                }
            }

            return new BoundResource[0];
        }
Ejemplo n.º 9
0
        public BoundResource GetDepthTarget()
        {
            if (LogLoaded)
            {
                if (IsLogD3D11)
                {
                    var ret = new BoundResource();
                    ret.Id = m_D3D11.m_OM.DepthTarget.Resource;
                    ret.HighestMip = (int)m_D3D11.m_OM.DepthTarget.HighestMip;
                    ret.FirstSlice = (int)m_D3D11.m_OM.DepthTarget.FirstArraySlice;
                    ret.typeHint = m_D3D11.m_OM.DepthTarget.Format.compType;
                    return ret;
                }
                else if (IsLogGL)
                {
                    var ret = new BoundResource();
                    ret.Id = m_GL.m_FB.m_DrawFBO.Depth.Obj;
                    ret.HighestMip = (int)m_GL.m_FB.m_DrawFBO.Depth.Mip;
                    ret.FirstSlice = (int)m_GL.m_FB.m_DrawFBO.Depth.Layer;
                    ret.typeHint = FormatComponentType.None;
                    return ret;
                }
                else if (IsLogVK)
                {
                    var rp = m_Vulkan.Pass.renderpass;
                    var fb = m_Vulkan.Pass.framebuffer;

                    if (rp.depthstencilAttachment >= 0 && rp.depthstencilAttachment < fb.attachments.Length)
                    {
                        var ret = new BoundResource();
                        ret.Id = fb.attachments[rp.depthstencilAttachment].img;
                        ret.HighestMip = (int)fb.attachments[rp.depthstencilAttachment].baseMip;
                        ret.FirstSlice = (int)fb.attachments[rp.depthstencilAttachment].baseLayer;
                        ret.typeHint = fb.attachments[rp.depthstencilAttachment].viewfmt.compType;
                        return ret;
                    }

                    return new BoundResource();
                }
            }

            return new BoundResource();
        }