コード例 #1
0
        protected void InitFinish(ref ComputeShaderDesc desc)
        {
            if (desc.constantBuffers != null)
            {
                constantBufferCount = desc.constantBuffers.Length;
            }
            if (desc.textures != null)
            {
                textureCount = desc.textures.Length;
            }
            if (desc.samplers != null)
            {
                samplerCount = desc.samplers.Length;
            }
            if (desc.randomAccessBuffers != null)
            {
                randomAccessBufferCount = desc.randomAccessBuffers.Length;
            }

            // calculate constant buffer variable mappings
            if (desc.constantBuffers != null && desc.constantBuffers.Length != 0)
            {
                var constantBufferVariables = new ShaderVariable[desc.constantBuffers.Length][];
                for (int i = 0; i != desc.constantBuffers.Length; ++i)
                {
                    constantBufferVariables[i] = desc.constantBuffers[i].variables;
                }
                CalculateContantBufferVariableMappings(constantBufferVariables, out var mappings);
                constantBufferMappings = mappings;
            }
        }
コード例 #2
0
        protected virtual bool InitFinish(ref ShaderEffectDesc desc)
        {
            if (desc.constantBuffers != null)
            {
                constantBufferCount = desc.constantBuffers.Length;
            }
            if (desc.textures != null)
            {
                textureCount = desc.textures.Length;
            }
            if (desc.samplers != null)
            {
                samplerCount = desc.samplers.Length;
            }
            if (desc.randomAccessBuffers != null)
            {
                randomAccessBufferCount = desc.randomAccessBuffers.Length;
            }

            // calculate constant buffer variable mappings
            if (desc.constantBuffers != null && desc.constantBuffers.Length != 0)
            {
                var constantBufferVariables = new ShaderVariable[desc.constantBuffers.Length][];
                for (int i = 0; i != desc.constantBuffers.Length; ++i)
                {
                    constantBufferVariables[i] = desc.constantBuffers[i].variables;
                }
                ShaderBase.CalculateContantBufferVariableMappings(constantBufferVariables, out var mappings);
                constantBufferMappings = mappings;
            }

            return(true);
        }