示例#1
0
文件: Enums.cs 项目: msgfx/renderdoc
        public static string Str(this FormatComponentType compType)
        {
            switch (compType)
            {
            case FormatComponentType.None: return("Typeless");

            case FormatComponentType.Float: return("Float");

            case FormatComponentType.UNorm: return("UNorm");

            case FormatComponentType.SNorm: return("SNorm");

            case FormatComponentType.UInt: return("UInt");

            case FormatComponentType.SInt: return("SInt");

            case FormatComponentType.UScaled: return("UScaled");

            case FormatComponentType.SScaled: return("SScaled");

            case FormatComponentType.Depth: return("Depth/Stencil");

            case FormatComponentType.Double: return("Double");

            default: break;
            }

            return("Unknown");
        }
示例#2
0
        public ResourceFormat(FormatComponentType type, UInt32 count, UInt32 byteWidth)
        {
            special       = false;
            specialFormat = SpecialFormat.Unknown;

            compType      = type;
            compCount     = count;
            compByteWidth = byteWidth;
            bgraOrder     = false;
            srgbCorrected = false;

            strname = "";
        }
示例#3
0
 private static extern bool ReplayRenderer_GetHistogram(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, float minval, float maxval, bool[] channels, IntPtr outhistogram);
示例#4
0
 private void UI_SetHistogramRange(FetchTexture tex, FormatComponentType typeHint)
 {
     if (tex != null && (tex.format.compType == FormatComponentType.SNorm || typeHint == FormatComponentType.SNorm))
         rangeHistogram.SetRange(-1.0f, 1.0f);
     else
         rangeHistogram.SetRange(0.0f, 1.0f);
 }
示例#5
0
        public VertexInputAttribute[] GetVertexInputs()
        {
            if (LogLoaded)
            {
                if (IsLogD3D11)
                {
                    uint[] byteOffs = new uint[128];
                    for (int i = 0; i < 128; i++)
                    {
                        byteOffs[i] = 0;
                    }

                    var layouts = m_D3D11.m_IA.layouts;

                    VertexInputAttribute[] ret = new VertexInputAttribute[layouts.Length];
                    for (int i = 0; i < layouts.Length; i++)
                    {
                        bool needsSemanticIdx = false;
                        for (int j = 0; j < layouts.Length; j++)
                        {
                            if (i != j && layouts[i].SemanticName == layouts[j].SemanticName)
                            {
                                needsSemanticIdx = true;
                                break;
                            }
                        }

                        uint offs = layouts[i].ByteOffset;
                        if (offs == uint.MaxValue) // APPEND_ALIGNED
                        {
                            offs = byteOffs[layouts[i].InputSlot];
                        }
                        else
                        {
                            byteOffs[layouts[i].InputSlot] = offs = layouts[i].ByteOffset;
                        }

                        byteOffs[layouts[i].InputSlot] += layouts[i].Format.compByteWidth * layouts[i].Format.compCount;

                        ret[i].Name               = layouts[i].SemanticName + (needsSemanticIdx ? layouts[i].SemanticIndex.ToString() : "");
                        ret[i].VertexBuffer       = (int)layouts[i].InputSlot;
                        ret[i].RelativeByteOffset = offs;
                        ret[i].PerInstance        = layouts[i].PerInstance;
                        ret[i].InstanceRate       = (int)layouts[i].InstanceDataStepRate;
                        ret[i].Format             = layouts[i].Format;
                        ret[i].GenericValue       = null;
                        ret[i].Used               = false;

                        if (m_D3D11.m_IA.Bytecode != null)
                        {
                            for (int ia = 0; ia < m_D3D11.m_IA.Bytecode.InputSig.Length; ia++)
                            {
                                if (m_D3D11.m_IA.Bytecode.InputSig[ia].semanticName.ToUpperInvariant() == layouts[i].SemanticName.ToUpperInvariant() &&
                                    m_D3D11.m_IA.Bytecode.InputSig[ia].semanticIndex == layouts[i].SemanticIndex)
                                {
                                    ret[i].Used = true;
                                    break;
                                }
                            }
                        }
                    }

                    return(ret);
                }
                else if (IsLogGL)
                {
                    var attrs = m_GL.m_VtxIn.attributes;

                    int num = 0;
                    for (int i = 0; i < attrs.Length; i++)
                    {
                        int attrib = -1;
                        if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null)
                        {
                            attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i];
                        }
                        else
                        {
                            attrib = i;
                        }

                        if (attrib >= 0)
                        {
                            num++;
                        }
                    }

                    int a = 0;
                    VertexInputAttribute[] ret = new VertexInputAttribute[num];
                    for (int i = 0; i < attrs.Length && a < num; i++)
                    {
                        ret[a].Name               = String.Format("attr{0}", i);
                        ret[a].GenericValue       = null;
                        ret[a].VertexBuffer       = (int)attrs[i].BufferSlot;
                        ret[a].RelativeByteOffset = attrs[i].RelativeOffset;
                        ret[a].PerInstance        = m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor > 0;
                        ret[a].InstanceRate       = (int)m_GL.m_VtxIn.vbuffers[attrs[i].BufferSlot].Divisor;
                        ret[a].Format             = attrs[i].Format;
                        ret[a].Used               = true;

                        if (m_GL.m_VS.BindpointMapping != null && m_GL.m_VS.ShaderDetails != null)
                        {
                            int attrib = m_GL.m_VS.BindpointMapping.InputAttributes[i];

                            if (attrib >= 0 && attrib < m_GL.m_VS.ShaderDetails.InputSig.Length)
                            {
                                ret[a].Name = m_GL.m_VS.ShaderDetails.InputSig[attrib].varName;
                            }

                            if (attrib == -1)
                            {
                                continue;
                            }

                            if (!attrs[i].Enabled)
                            {
                                uint compCount = m_GL.m_VS.ShaderDetails.InputSig[attrib].compCount;
                                FormatComponentType compType = m_GL.m_VS.ShaderDetails.InputSig[attrib].compType;

                                ret[a].GenericValue = new object[compCount];

                                for (uint c = 0; c < compCount; c++)
                                {
                                    if (compType == FormatComponentType.Float)
                                    {
                                        ret[a].GenericValue[c] = attrs[i].GenericValue.f[c];
                                    }
                                    else if (compType == FormatComponentType.UInt)
                                    {
                                        ret[a].GenericValue[c] = attrs[i].GenericValue.u[c];
                                    }
                                    else if (compType == FormatComponentType.SInt)
                                    {
                                        ret[a].GenericValue[c] = attrs[i].GenericValue.i[c];
                                    }
                                }

                                ret[a].PerInstance          = false;
                                ret[a].InstanceRate         = 0;
                                ret[a].Format.compByteWidth = 4;
                                ret[a].Format.compCount     = compCount;
                                ret[a].Format.compType      = compType;
                                ret[a].Format.special       = false;
                                ret[a].Format.srgbCorrected = false;
                            }
                        }

                        a++;
                    }

                    return(ret);
                }
                else if (IsLogVK)
                {
                    var attrs = m_Vulkan.VI.attrs;

                    int num = 0;
                    for (int i = 0; i < attrs.Length; i++)
                    {
                        int attrib = -1;
                        if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null)
                        {
                            attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location];
                        }
                        else
                        {
                            attrib = i;
                        }

                        if (attrib >= 0)
                        {
                            num++;
                        }
                    }

                    int a = 0;
                    VertexInputAttribute[] ret = new VertexInputAttribute[num];
                    for (int i = 0; i < attrs.Length && a < num; i++)
                    {
                        ret[a].Name               = String.Format("attr{0}", i);
                        ret[a].GenericValue       = null;
                        ret[a].VertexBuffer       = (int)attrs[i].binding;
                        ret[a].RelativeByteOffset = attrs[i].byteoffset;
                        ret[a].PerInstance        = m_Vulkan.VI.binds[attrs[i].binding].perInstance;
                        ret[a].InstanceRate       = 1;
                        ret[a].Format             = attrs[i].format;
                        ret[a].Used               = true;

                        if (m_Vulkan.VS.BindpointMapping != null && m_Vulkan.VS.ShaderDetails != null)
                        {
                            int attrib = m_Vulkan.VS.BindpointMapping.InputAttributes[attrs[i].location];

                            if (attrib >= 0 && attrib < m_Vulkan.VS.ShaderDetails.InputSig.Length)
                            {
                                ret[a].Name = m_Vulkan.VS.ShaderDetails.InputSig[attrib].varName;
                            }

                            if (attrib == -1)
                            {
                                continue;
                            }
                        }

                        a++;
                    }

                    return(ret);
                }
            }

            return(null);
        }
示例#6
0
        public ResourceFormat()
        {
            rawType = 0;
            special = false;
            specialFormat = SpecialFormat.Unknown;

            compType = FormatComponentType.None;
            compCount = 0;
            compByteWidth = 0;
            bgraOrder = false;
            srgbCorrected = false;

            strname = "";
        }
示例#7
0
 private static extern bool ReplayOutput_AddThumbnail(IntPtr real, IntPtr wnd, ResourceId texID, FormatComponentType typeHint);
示例#8
0
        public bool GetMinMax(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, out PixelValue minval, out PixelValue maxval)
        {
            IntPtr mem1 = CustomMarshal.Alloc(typeof(PixelValue));
            IntPtr mem2 = CustomMarshal.Alloc(typeof(PixelValue));

            bool success = ReplayRenderer_GetMinMax(m_Real, tex, sliceFace, mip, sample, typeHint, mem1, mem2);

            if (success)
            {
                minval = (PixelValue)CustomMarshal.PtrToStructure(mem1, typeof(PixelValue), true);
                maxval = (PixelValue)CustomMarshal.PtrToStructure(mem2, typeof(PixelValue), true);
            }
            else
            {
                minval = null;
                maxval = null;
            }

            CustomMarshal.Free(mem1);
            CustomMarshal.Free(mem2);

            return(success);
        }
示例#9
0
 public bool AddThumbnail(IntPtr wnd, ResourceId texID, FormatComponentType typeHint)
 {
     // 1 == eWindowingSystem_Win32
     return ReplayOutput_AddThumbnail(m_Real, 1u, wnd, texID, typeHint);
 }
示例#10
0
 private static extern bool ReplayRenderer_PixelHistory(IntPtr real, ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx, FormatComponentType typeHint, IntPtr history);
示例#11
0
        public PixelModification[] PixelHistory(ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx, FormatComponentType typeHint)
        {
            IntPtr mem = CustomMarshal.Alloc(typeof(templated_array));

            bool success = ReplayRenderer_PixelHistory(m_Real, target, x, y, slice, mip, sampleIdx, typeHint, mem);

            PixelModification[] ret = null;

            if (success)
                ret = (PixelModification[])CustomMarshal.GetTemplatedArray(mem, typeof(PixelModification), true);

            CustomMarshal.Free(mem);

            return ret;
        }
示例#12
0
        public bool GetMinMax(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, out PixelValue minval, out PixelValue maxval)
        {
            IntPtr mem1 = CustomMarshal.Alloc(typeof(PixelValue));
            IntPtr mem2 = CustomMarshal.Alloc(typeof(PixelValue));

            bool success = ReplayRenderer_GetMinMax(m_Real, tex, sliceFace, mip, sample, typeHint, mem1, mem2);

            if (success)
            {
                minval = (PixelValue)CustomMarshal.PtrToStructure(mem1, typeof(PixelValue), true);
                maxval = (PixelValue)CustomMarshal.PtrToStructure(mem2, typeof(PixelValue), true);
            }
            else
            {
                minval = null;
                maxval = null;
            }

            CustomMarshal.Free(mem1);
            CustomMarshal.Free(mem2);

            return success;
        }
示例#13
0
        public bool GetHistogram(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, float minval, float maxval,
            bool Red, bool Green, bool Blue, bool Alpha,
            out UInt32[] histogram)
        {
            IntPtr mem = CustomMarshal.Alloc(typeof(templated_array));

            bool[] channels = new bool[] { Red, Green, Blue, Alpha };

            bool success = ReplayRenderer_GetHistogram(m_Real, tex, sliceFace, mip, sample, typeHint, minval, maxval, channels, mem);

            histogram = null;

            if (success)
                histogram = (UInt32[])CustomMarshal.GetTemplatedArray(mem, typeof(UInt32), true);

            CustomMarshal.Free(mem);

            return success;
        }
示例#14
0
 private static extern bool ReplayRenderer_GetMinMax(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, IntPtr outminval, IntPtr outmaxval);
示例#15
0
 private static extern bool ReplayRenderer_GetHistogram(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, float minval, float maxval, bool[] channels, IntPtr outhistogram);
示例#16
0
        public PixelModification[] PixelHistory(ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx, FormatComponentType typeHint)
        {
            IntPtr mem = CustomMarshal.Alloc(typeof(templated_array));

            bool success = ReplayRenderer_PixelHistory(m_Real, target, x, y, slice, mip, sampleIdx, typeHint, mem);

            PixelModification[] ret = null;

            if (success)
            {
                ret = (PixelModification[])CustomMarshal.GetTemplatedArray(mem, typeof(PixelModification), true);
            }

            CustomMarshal.Free(mem);

            return(ret);
        }
示例#17
0
 private static extern bool ReplayOutput_AddThumbnail(IntPtr real, UInt32 windowSystem, IntPtr wnd, ResourceId texID, FormatComponentType typeHint);
示例#18
0
        public bool GetHistogram(ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, float minval, float maxval,
                                 bool Red, bool Green, bool Blue, bool Alpha,
                                 out UInt32[] histogram)
        {
            IntPtr mem = CustomMarshal.Alloc(typeof(templated_array));

            bool[] channels = new bool[] { Red, Green, Blue, Alpha };

            bool success = ReplayRenderer_GetHistogram(m_Real, tex, sliceFace, mip, sample, typeHint, minval, maxval, channels, mem);

            histogram = null;

            if (success)
            {
                histogram = (UInt32[])CustomMarshal.GetTemplatedArray(mem, typeof(UInt32), true);
            }

            CustomMarshal.Free(mem);

            return(success);
        }
示例#19
0
 public BoundResource()
 {
     Id = ResourceId.Null; HighestMip = -1; FirstSlice = -1; typeHint = FormatComponentType.None;
 }
示例#20
0
        static public FormatElement[] ParseFormatString(string formatString, UInt64 maxLen, bool tightPacking, out string errors)
        {
            var elems = new List <FormatElement>();

            var formatReader = new StringReader(formatString);

            // regex doesn't account for trailing or preceeding whitespace, or comments

            var regExpr = @"^(row_major\s+)?" + // row_major matrix
                          @"(" +
                          @"uintten|unormten" +
                          @"|unormh|unormb" +
                          @"|snormh|snormb" +
                          @"|bool" +                            // bool is stored as 4-byte int
                          @"|byte|short|int" +                  // signed ints
                          @"|ubyte|ushort|uint" +               // unsigned ints
                          @"|xbyte|xshort|xint" +               // hex ints
                          @"|half|float|double" +               // float types
                          @"|vec|uvec|ivec" +                   // OpenGL vector types
                          @"|mat|umat|imat" +                   // OpenGL matrix types
                          @")" +
                          @"([1-9])?" +                         // might be a vector
                          @"(x[1-9])?" +                        // or a matrix
                          @"(\s+[A-Za-z_][A-Za-z0-9_]*)?" +     // get identifier name
                          @"(\[[0-9]+\])?" +                    // optional array dimension
                          @"(\s*:\s*[A-Za-z_][A-Za-z0-9_]*)?" + // optional semantic
                          @"$";

            Regex regParser = new Regex(regExpr, RegexOptions.Compiled);

            bool success = true;

            errors = "";

            var text = formatReader.ReadToEnd();

            text = text.Replace("{", "").Replace("}", "");

            Regex c_comments = new Regex(@"/\*[^*]*\*+(?:[^*/][^*]*\*+)*/", RegexOptions.Compiled);

            text = c_comments.Replace(text, "");

            Regex cpp_comments = new Regex(@"//.*", RegexOptions.Compiled);

            text = cpp_comments.Replace(text, "");

            uint offset = 0;

            // get each line and parse it to determine the format the user wanted
            foreach (var l in text.Split(';'))
            {
                var line = l;
                line = line.Trim();

                if (line.Length == 0)
                {
                    continue;
                }

                var match = regParser.Match(line);

                if (!match.Success)
                {
                    errors  = "Couldn't parse line:\n" + line;
                    success = false;
                    break;
                }

                var  basetype  = match.Groups[2].Value;
                bool row_major = match.Groups[1].Success;
                var  vectorDim = match.Groups[3].Success ? match.Groups[3].Value : "1";
                var  matrixDim = match.Groups[4].Success ? match.Groups[4].Value.Substring(1) : "1";
                var  name      = match.Groups[5].Success ? match.Groups[5].Value.Trim() : "data";
                var  arrayDim  = match.Groups[6].Success ? match.Groups[6].Value.Trim() : "[1]";
                arrayDim = arrayDim.Substring(1, arrayDim.Length - 2);

                if (match.Groups[4].Success)
                {
                    var a = vectorDim;
                    vectorDim = matrixDim;
                    matrixDim = a;
                }

                ResourceFormat fmt = new ResourceFormat(FormatComponentType.None, 0, 0);

                bool hex = false;

                FormatComponentType type = FormatComponentType.Float;
                uint count       = 0;
                uint arrayCount  = 1;
                uint matrixCount = 0;
                uint width       = 0;

                // check for square matrix declarations like 'mat4' and 'mat3'
                if (basetype == "mat" && !match.Groups[4].Success)
                {
                    matrixDim = vectorDim;
                }

                // calculate format
                {
                    if (!uint.TryParse(vectorDim, out count))
                    {
                        errors  = "Invalid vector dimension on line:\n" + line;
                        success = false;
                        break;
                    }
                    if (!uint.TryParse(arrayDim, out arrayCount))
                    {
                        arrayCount = 1;
                    }
                    arrayCount = Math.Max(0, arrayCount);
                    if (!uint.TryParse(matrixDim, out matrixCount))
                    {
                        errors  = "Invalid matrix second dimension on line:\n" + line;
                        success = false;
                        break;
                    }

                    if (basetype == "bool")
                    {
                        type  = FormatComponentType.UInt;
                        width = 4;
                    }
                    else if (basetype == "byte")
                    {
                        type  = FormatComponentType.SInt;
                        width = 1;
                    }
                    else if (basetype == "ubyte" || basetype == "xbyte")
                    {
                        type  = FormatComponentType.UInt;
                        width = 1;
                    }
                    else if (basetype == "short")
                    {
                        type  = FormatComponentType.SInt;
                        width = 2;
                    }
                    else if (basetype == "ushort" || basetype == "xshort")
                    {
                        type  = FormatComponentType.UInt;
                        width = 2;
                    }
                    else if (basetype == "int" || basetype == "ivec" || basetype == "imat")
                    {
                        type  = FormatComponentType.SInt;
                        width = 4;
                    }
                    else if (basetype == "uint" || basetype == "xint" || basetype == "uvec" || basetype == "umat")
                    {
                        type  = FormatComponentType.UInt;
                        width = 4;
                    }
                    else if (basetype == "half")
                    {
                        type  = FormatComponentType.Float;
                        width = 2;
                    }
                    else if (basetype == "float" || basetype == "vec" || basetype == "mat")
                    {
                        type  = FormatComponentType.Float;
                        width = 4;
                    }
                    else if (basetype == "double")
                    {
                        type  = FormatComponentType.Double;
                        width = 8;
                    }
                    else if (basetype == "unormh")
                    {
                        type  = FormatComponentType.UNorm;
                        width = 2;
                    }
                    else if (basetype == "unormb")
                    {
                        type  = FormatComponentType.UNorm;
                        width = 1;
                    }
                    else if (basetype == "snormh")
                    {
                        type  = FormatComponentType.SNorm;
                        width = 2;
                    }
                    else if (basetype == "snormb")
                    {
                        type  = FormatComponentType.SNorm;
                        width = 1;
                    }
                    else if (basetype == "uintten")
                    {
                        fmt               = new ResourceFormat(FormatComponentType.UInt, 4 * count, 1);
                        fmt.special       = true;
                        fmt.specialFormat = SpecialFormat.R10G10B10A2;
                    }
                    else if (basetype == "unormten")
                    {
                        fmt               = new ResourceFormat(FormatComponentType.UNorm, 4 * count, 1);
                        fmt.special       = true;
                        fmt.specialFormat = SpecialFormat.R10G10B10A2;
                    }
                    else
                    {
                        errors  = "Unrecognised basic type on line:\n" + line;
                        success = false;
                        break;
                    }
                }

                if (basetype == "xint" || basetype == "xshort" || basetype == "xbyte")
                {
                    hex = true;
                }

                if (fmt.compType == FormatComponentType.None)
                {
                    fmt = new ResourceFormat(type, count, width);
                }

                if (arrayCount == 1)
                {
                    FormatElement elem = new FormatElement(name, 0, offset, false, 1, row_major, matrixCount, fmt, hex);

                    uint advance = elem.ByteSize;

                    if (!tightPacking)
                    {
                        // cbuffer packing always works in floats
                        advance = (advance + 3U) & (~3U);

                        // cbuffer packing doesn't allow elements to cross float4 boundaries, nudge up if this was the case
                        if (offset / 16 != (offset + elem.ByteSize - 1) / 16)
                        {
                            elem.offset = offset = (offset + 0xFU) & (~0xFU);
                        }
                    }

                    elems.Add(elem);

                    offset += advance;
                }
                else
                {
                    // when cbuffer packing, arrays are always aligned at float4 boundary
                    if (!tightPacking)
                    {
                        if (offset % 16 != 0)
                        {
                            offset = (offset + 0xFU) & (~0xFU);
                        }
                    }

                    for (uint a = 0; a < arrayCount; a++)
                    {
                        FormatElement elem = new FormatElement(String.Format("{0}[{1}]", name, a), 0, offset, false, 1, row_major, matrixCount, fmt, hex);

                        elems.Add(elem);

                        uint advance = elem.ByteSize;

                        // cbuffer packing each array element is always float4 aligned
                        if (!tightPacking)
                        {
                            advance = (advance + 0xFU) & (~0xFU);
                        }

                        offset += advance;
                    }
                }
            }

            if (!success || elems.Count == 0)
            {
                elems.Clear();

                var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4);

                if (maxLen > 0 && maxLen < 16)
                {
                    fmt.compCount = 1;
                }
                if (maxLen > 0 && maxLen < 4)
                {
                    fmt.compByteWidth = 1;
                }

                elems.Add(new FormatElement("data", 0, 0, false, 1, false, 1, fmt, true));
            }

            return(elems.ToArray());
        }
示例#21
0
 public BoundResource(ResourceId id)
 {
     Id = id; HighestMip = -1; FirstSlice = -1; typeHint = FormatComponentType.None;
 }
示例#22
0
        public ResourceFormat(FormatComponentType type, UInt32 count, UInt32 byteWidth)
        {
            rawType = 0;
            special = false;
            specialFormat = SpecialFormat.Unknown;

            compType = type;
            compCount = count;
            compByteWidth = byteWidth;
            srgbCorrected = false;

            strname = "";
        }
        private string MakeGenericValueString(uint compCount, FormatComponentType compType, GLPipelineState.VertexInputs.VertexAttribute.GenericValueUnion val)
        {
            string fmtstr = "";
            if (compCount == 1) fmtstr = "<{0}>";
            else if (compCount == 2) fmtstr = "<{0}, {1}>";
            else if (compCount == 3) fmtstr = "<{0}, {1}, {2}>";
            else if (compCount == 4) fmtstr = "<{0}, {1}, {2}, {3}>";

            if (compType == FormatComponentType.UInt)
                return String.Format(fmtstr, val.u[0], val.u[1], val.u[2], val.u[3]);
            else if (compType == FormatComponentType.SInt)
                return String.Format(fmtstr, val.i[0], val.i[1], val.i[2], val.i[3]);
            else
                return String.Format(fmtstr, val.f[0], val.f[1], val.f[2], val.f[3]);
        }
示例#24
0
 public bool AddThumbnail(IntPtr wnd, ResourceId texID, FormatComponentType typeHint)
 {
     return(ReplayOutput_AddThumbnail(m_Real, wnd, texID, typeHint));
 }
示例#25
0
 private static extern bool ReplayRenderer_PixelHistory(IntPtr real, ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx, FormatComponentType typeHint, IntPtr history);
示例#26
0
        private void InitResourcePreview(ResourcePreview prev, ResourceId id, FormatComponentType typeHint, bool force, Following follow, string bindName, string slotName)
        {
            if (id != ResourceId.Null || force)
            {
                FetchTexture tex = null;
                foreach (var t in m_Core.CurTextures)
                    if (t.ID == id)
                        tex = t;

                FetchBuffer buf = null;
                foreach (var b in m_Core.CurBuffers)
                    if (b.ID == id)
                        buf = b;

                if (tex != null)
                {
                    string fullname = bindName;
                    if (tex.customName)
                    {
                        if (fullname.Length > 0)
                            fullname += " = ";
                        fullname += tex.name;
                    }
                    if (fullname.Length == 0)
                        fullname = tex.name;

                    prev.Init(fullname, tex.width, tex.height, tex.depth, tex.mips);
                    IntPtr handle = prev.ThumbnailHandle;
                    m_Core.Renderer.BeginInvoke((ReplayRenderer rep) =>
                    {
                        m_Output.AddThumbnail(handle, id, typeHint);
                    });
                }
                else if (buf != null)
                {
                    string fullname = bindName;
                    if (buf.customName)
                    {
                        if (fullname.Length > 0)
                            fullname += " = ";
                        fullname += buf.name;
                    }
                    if (fullname.Length == 0)
                        fullname = buf.name;

                    prev.Init(fullname, buf.length, 0, 0, 1);
                    IntPtr handle = prev.ThumbnailHandle;
                    m_Core.Renderer.BeginInvoke((ReplayRenderer rep) =>
                    {
                        m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None);
                    });
                }
                else
                {
                    prev.Init();
                    IntPtr handle = prev.ThumbnailHandle;
                    m_Core.Renderer.BeginInvoke((ReplayRenderer rep) =>
                    {
                        m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None);
                    });
                }

                prev.Tag = follow;
                prev.SlotName = slotName;
                prev.Visible = true;
                prev.Selected = (m_Following == follow);
            }
            else if (m_Following == follow)
            {
                FetchTexture tex = null;

                if(id != ResourceId.Null)
                    foreach (var t in m_Core.CurTextures)
                        if (t.ID == id)
                            tex = t;

                IntPtr handle = prev.ThumbnailHandle;
                if (id == ResourceId.Null || tex == null)
                    prev.Init();
                else
                    prev.Init("Unused", tex.width, tex.height, tex.depth, tex.mips);
                prev.Selected = true;
                m_Core.Renderer.BeginInvoke((ReplayRenderer rep) =>
                {
                    m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None);
                });
            }
            else
            {
                prev.Init();
                prev.Visible = false;
            }
        }
示例#27
0
 private static extern bool ReplayRenderer_GetMinMax(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, FormatComponentType typeHint, IntPtr outminval, IntPtr outmaxval);
示例#28
0
 public TexSettings()
 {
     r = g = b = true; a = false;
     mip = 0; slice = 0;
     minrange = 0.0f; maxrange = 1.0f;
     typeHint = FormatComponentType.None;
 }
示例#29
0
 public bool AddThumbnail(IntPtr wnd, ResourceId texID, FormatComponentType typeHint)
 {
     // 1 == eWindowingSystem_Win32
     return(ReplayOutput_AddThumbnail(m_Real, 1u, wnd, texID, typeHint));
 }