Beispiel #1
0
        public GlobalShaderField CreateStaticField(ShaderType owningType, ShaderType fieldType, string name, IShaderIR initializerExpression)
        {
            // Static fields are a special storage class. Get the target storage class from the field type. If the field type is a special storage class then use that instead of private.
            var storageClass = StorageClass.Private;

            if (fieldType.mStorageClass == StorageClass.Uniform || fieldType.mStorageClass == StorageClass.UniformConstant)
            {
                storageClass = fieldType.mStorageClass;
            }

            // Also create the pointer type if needed.
            var staticFieldType = fieldType.FindPointerType(storageClass);

            if (staticFieldType == null)
            {
                staticFieldType = CreateType(fieldType, storageClass, true);
            }

            var shaderField = new GlobalShaderField();

            shaderField.mMeta          = new ShaderFieldMeta();
            shaderField.mType          = staticFieldType;
            shaderField.mMeta.mName    = name;
            shaderField.DebugInfo.Name = name;
            owningType.mStaticFields.Add(shaderField);

            shaderField.InstanceOp             = new ShaderOp();
            shaderField.InstanceOp.mOpType     = OpInstructionType.OpVariable;
            shaderField.InstanceOp.mResultType = staticFieldType;
            shaderField.InstanceOp.mParameters.Add(staticFieldType);
            mCurrentLibrary.mStaticGlobals.Add(shaderField, shaderField);
            return(shaderField);
        }
Beispiel #2
0
 public void FindStaticField(ShaderType owningType, string fieldName, out GlobalShaderField shaderField, out int fieldIndex)
 {
     FindField(owningType.mStaticFields, fieldName, out shaderField, out fieldIndex);
 }