Пример #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);
            }
        }
Пример #2
0
        public unsafe ReflectBlockVariable[] EnumeratePushConstants()
        {
            fixed(SpirvReflectNative.SpvReflectShaderModule *inmodule = &NativeShaderModule)
            {
                uint var_count = 0;
                var  result    = SpirvReflectNative.spvReflectEnumeratePushConstants(inmodule, &var_count, null);

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

                SpirvReflectNative.SpvReflectBlockVariable **push_consts =
                    stackalloc SpirvReflectNative.SpvReflectBlockVariable *[(int)(var_count * sizeof(SpirvReflectNative.SpvReflectBlockVariable))];

                result = SpirvReflectNative.spvReflectEnumeratePushConstants(inmodule, &var_count, push_consts);
                SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);

                // Convert to managed
                return(ReflectBlockVariable.ToManaged(push_consts, var_count));
            }
        }
Пример #3
0
        public unsafe ReflectInterfaceVariable[] EnumerateOutputVariables()
        {
            fixed(SpirvReflectNative.SpvReflectShaderModule *inmodule = &NativeShaderModule)
            {
                uint var_count = 0;
                var  result    = SpirvReflectNative.spvReflectEnumerateOutputVariables(inmodule, &var_count, null);

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

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

                result = SpirvReflectNative.spvReflectEnumerateOutputVariables(inmodule, &var_count, output_vars);
                SpirvReflectUtils.Assert(result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS);

                // Convert to managed
                return(ReflectInterfaceVariable.ToManaged(output_vars, var_count));
            }
        }
Пример #4
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);
                }
            }
        }