Beispiel #1
0
        public unsafe ReflectInterfaceVariable GetInputVariableByLocation(uint location)
        {
            fixed(SpirvReflectNative.SpvReflectShaderModule *inmodule = &NativeShaderModule)
            {
                var reflt = new ReflectInterfaceVariable();

                SpirvReflectNative.SpvReflectResult result = SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_NOT_READY;
                var nativeOut = SpirvReflectNative.spvReflectGetInputVariableByLocation(inmodule, location, &result);

                SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);
                ReflectInterfaceVariable.PopulateReflectInterfaceVariable(ref *nativeOut, ref reflt);
                return(reflt);
            }
        }
Beispiel #2
0
        public unsafe ReflectInterfaceVariable[] EnumerateInterfaceVariables()
        {
            fixed(SpirvReflectNative.SpvReflectShaderModule *inmodule = &NativeShaderModule)
            {
                uint var_count = 0;
                var  result    = SpirvReflectNative.spvReflectEnumerateInterfaceVariables(inmodule, &var_count, null);

                SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);

                SpirvReflectNative.SpvReflectInterfaceVariable **interface_vars =
                    stackalloc SpirvReflectNative.SpvReflectInterfaceVariable *[(int)(var_count * sizeof(SpirvReflectNative.SpvReflectInterfaceVariable))];

                result = SpirvReflectNative.spvReflectEnumerateInterfaceVariables(inmodule, &var_count, interface_vars);
                SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);

                // Convert to managed
                return(ReflectInterfaceVariable.ToManaged(interface_vars, var_count));
            }
        }
Beispiel #3
0
        public unsafe ReflectInterfaceVariable GetInputVariableBySemantic(string semantic)
        {
            fixed(SpirvReflectNative.SpvReflectShaderModule *inmodule = &NativeShaderModule)
            {
                var reflt = new ReflectInterfaceVariable();

                SpirvReflectNative.SpvReflectResult result = SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_NOT_READY;
                byte[] semanticBytes = Encoding.ASCII.GetBytes(semantic);

                fixed(byte *ptr = semanticBytes)
                {
                    var nativeOut = SpirvReflectNative.spvReflectGetInputVariableBySemantic(inmodule, (sbyte *)ptr, &result);

                    SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);
                    ReflectInterfaceVariable.PopulateReflectInterfaceVariable(ref *nativeOut, ref reflt);
                    return(reflt);
                }
            }
        }