Exemple #1
0
        void AllocateResource(ResourceDescriptor desc)
        {
            var t = desc.sType.type;

            if (t == typeof(ComputeBuffer))
            {
                desc.allocatedBuffer = AllocComputeBuffer(desc.bufferSize, desc.bufferStride);
            }
            else if (typeof(Texture).IsAssignableFrom(t))
            {
                int expectedWidth  = desc.textureAllocMode == TextureAllocMode.SameAsOutput ? rtSettings.GetWidth(graph) : (int)desc.textureAllocMode;
                int expectedHeight = desc.textureAllocMode == TextureAllocMode.SameAsOutput ? rtSettings.GetHeight(graph) : (int)desc.textureAllocMode;
                int expectedDepth  = desc.textureAllocMode == TextureAllocMode.SameAsOutput ? rtSettings.GetDepth(graph) : (int)desc.textureAllocMode;

                RenderTextureDescriptor descriptor = new RenderTextureDescriptor
                {
                    // TODO: custom size
                    width             = expectedWidth,
                    height            = expectedHeight,
                    volumeDepth       = expectedDepth,
                    autoGenerateMips  = false,
                    useMipMap         = false,
                    graphicsFormat    = GraphicsFormat.R16G16B16A16_SFloat,
                    enableRandomWrite = true,
                    depthBufferBits   = 0,
                    dimension         = TextureUtils.GetDimensionFromType(t),
                    msaaSamples       = 1,
                };
                desc.allocatedTexture = new RenderTexture(descriptor)
                {
                    name      = "AutoAllocated - " + name,
                    hideFlags = HideFlags.HideAndDontSave,
                };
                desc.allocatedTexture.Create();
            }
        }