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); } }
/// <summary> /// Creates a <see cref="ShaderModule"/> given SPIR-V bytecode /// </summary> /// <param name="shaderBytes">Compiled SPIR-V bytecode</param> /// <returns>A <see cref="ShaderModule"/></returns> public static ShaderModule ReflectCreateShaderModule(byte[] shaderBytes) { fixed(void *shdrBytecode = &shaderBytes[0]) { SpirvReflectNative.SpvReflectShaderModule module; SpirvReflectNative.SpvReflectResult result = SpirvReflectNative.spvReflectCreateShaderModule(Convert.ToUInt64(shaderBytes.LongLength), shdrBytecode, &module); if (result == SpirvReflectNative.SpvReflectResult.SPV_REFLECT_RESULT_SUCCESS) { return(new ShaderModule(module)); } else { throw new SpirvReflectException(result); } } }
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); } } }
internal SpirvReflectException(SpirvReflectNative.SpvReflectResult result) : base(result.ToString()) { }