Beispiel #1
0
        private void InitStageResourcePreviews(ShaderStageType stage, ShaderResource[] resourceDetails, BindpointMap[] mapping,
            Dictionary<BindpointMap, BoundResource[]> ResList,
            ThumbnailStrip prevs, ref int prevIndex,
            bool copy, bool rw)
        {
            for (int idx = 0; idx < mapping.Length; idx++)
            {
                var key = mapping[idx];

                BoundResource[] resArray = null;

                if (ResList.ContainsKey(key))
                    resArray = ResList[key];

                int arrayLen = resArray != null ? resArray.Length : 1;

                for (int arrayIdx = 0; arrayIdx < arrayLen; arrayIdx++)
                {
                    ResourceId id = resArray != null ? resArray[arrayIdx].Id : ResourceId.Null;
                    FormatComponentType typeHint = resArray != null ? resArray[arrayIdx].typeHint : FormatComponentType.None;

                    bool used = key.used;
                    bool samplerBind = false;
                    bool otherBind = false;

                    string bindName = "";

                    foreach (var bind in resourceDetails)
                    {
                        if (bind.bindPoint == idx && bind.IsSRV)
                        {
                            bindName = bind.name;
                            otherBind = true;
                            break;
                        }

                        if (bind.bindPoint == idx)
                        {
                            if(bind.IsSampler && !bind.IsSRV)
                                samplerBind = true;
                            else
                                otherBind = true;
                        }
                    }

                    if (samplerBind && !otherBind)
                        continue;

                    if (copy)
                    {
                        used = true;
                        bindName = "Source";
                    }

                    Following follow = new Following(rw ? FollowType.ReadWrite : FollowType.ReadOnly, stage, idx, arrayIdx);
                    string slotName = String.Format("{0} {1}{2}", m_Core.CurPipelineState.Abbrev(stage), rw ? "RW " : "", idx);

                    if (arrayLen > 1)
                        slotName += String.Format("[{0}]", arrayIdx);

                    if (copy)
                        slotName = "SRC";

                    // show if
                    bool show = (used || // it's referenced by the shader - regardless of empty or not
                        (showDisabled.Checked && !used && id != ResourceId.Null) || // it's bound, but not referenced, and we have "show disabled"
                        (showEmpty.Checked && id == ResourceId.Null) // it's empty, and we have "show empty"
                        );

                    ResourcePreview prev;

                    if (prevIndex < prevs.Thumbnails.Length)
                    {
                        prev = prevs.Thumbnails[prevIndex];
                    }
                    else
                    {
                        // don't create it if we're not actually going to show it
                        if (!show)
                            continue;

                        prev = UI_CreateThumbnail(prevs);
                    }

                    prevIndex++;

                    InitResourcePreview(prev, show ? id : ResourceId.Null, typeHint, show, follow, bindName, slotName);
                }
            }
        }
Beispiel #2
0
        private void AddResourceRegister(ShaderResource slot, D3D11PipelineState.ShaderStage.ResourceView res)
        {
            bool found = false;

            var name = slot.bindPoint + " (" + slot.name + ")";

            foreach (var tex in m_Core.CurTextures)
            {
                if (tex.ID == res.Resource)
                {
                    var node = new TreelistView.Node(new object[] {
                "t" + name, "Texture",
                tex.width + "x" + tex.height + "x" + (tex.depth > 1 ? tex.depth : tex.arraysize) +
                "[" + tex.mips + "] @ " + tex.format + " - " + tex.name
            });
                    node.Tag = null;

                    constantRegs.Nodes.Add(node);

                    found = true;
                    break;
                }
            }

            if (!found)
            {
                foreach (var buf in m_Core.CurBuffers)
                {
                    if (buf.ID == res.Resource)
                    {
                        string prefix = "u";

                        if (slot.IsSRV)
                            prefix = "t";

                        var node = new TreelistView.Node(new object[] {
                    prefix + name, "Buffer",
                    buf.length + " - " + buf.name
                });
                        node.Tag = null;
                        constantRegs.Nodes.Add(node);

                        found = true;
                        break;
                    }
                }
            }

            if (!found)
            {
                string prefix = "u";

                if (slot.IsSRV)
                    prefix = "t";

                var node = new TreelistView.Node(new object[] {
                    prefix + name, "Resource",
                    "unknown"
                });
                node.Tag = null;
                constantRegs.Nodes.Add(node);
            }
        }
 public ViewTexTag(D3D12PipelineState.ResourceView v, FetchTexture t, bool u, ShaderResource r)
 {
     view = v;
     tex = t;
     uav = u;
     res = r;
 }
        private GLReadWriteType GetGLReadWriteType(ShaderResource res)
        {
            GLReadWriteType ret = GLReadWriteType.Image;

            if (res.IsTexture)
            {
                ret = GLReadWriteType.Image;
            }
            else
            {
                if (res.variableType.descriptor.rows == 1 &&
                    res.variableType.descriptor.cols == 1 &&
                    res.variableType.descriptor.type == VarType.UInt)
                {
                    ret = GLReadWriteType.Atomic;
                }
                else
                {
                    ret = GLReadWriteType.SSBO;
                }
            }

            return ret;
        }
 public ViewBufTag(D3D12PipelineState.ResourceView v, FetchBuffer b, bool u, ShaderResource r)
 {
     view = v;
     buf = b;
     uav = u;
     res = r;
 }