public static CompiledShaderReader ReadCompiledShader(string path) { if (File.Exists(path) && (Path.GetExtension(path) == ".cso")) { byte[] bytes = File.ReadAllBytes(path); ShaderReflection reflecter = new ShaderReflection(bytes); ShaderBytecode bytecode = new ShaderBytecode(bytes); ShaderProfile profile = bytecode.GetVersion(); ConstantBuffer[] cbuffers = new ConstantBuffer[reflecter.Description.ConstantBuffers]; for (int i = 0; i < reflecter.Description.ConstantBuffers; i++) { cbuffers[i] = reflecter.GetConstantBuffer(i);//this might not work } ShaderParameterDescription[] paramdescriptions = new ShaderParameterDescription[reflecter.Description.InputParameters]; for (int i = 0; i < reflecter.Description.InputParameters; i++) { paramdescriptions[i] = reflecter.GetInputParameterDescription(i); } InputBindingDescription[] bindings = new InputBindingDescription[reflecter.Description.BoundResources]; for (int i = 0; i < reflecter.Description.BoundResources; i++) { bindings[i] = reflecter.GetResourceBindingDescription(i); } ConstantBuffer[] cbuffersCOPY = cbuffers.ToArray(); return new CompiledShaderReader(path, profile.GetTypePrefix(), cbuffersCOPY, paramdescriptions.ToArray(), bindings.ToArray(), reflecter, bytecode); } else throw new Exception("Bad path " + path); }