Exemplo n.º 1
0
 private ResourcePreview UI_CreateThumbnail(ThumbnailStrip strip)
 {
     var prev = new ResourcePreview(m_Core, m_Output);
     prev.Anchor = AnchorStyles.Top | AnchorStyles.Bottom;
     prev.MouseClick += thumbsLayout_MouseClick;
     prev.MouseDoubleClick += thumbsLayout_MouseDoubleClick;
     prev.Visible = false;
     strip.AddThumbnail(prev);
     return prev;
 }
Exemplo n.º 2
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);
                }
            }
        }