Having problems with .NET + CAL
Hello. I'm trying to use CAL from MS .NET. I'm new to GPU programming, thus I started with "hellocal" example.
I made managed C++ DLL-project with following code:
#include "stdafx.h"
#include
#include
#include "calcl.h"
#include
using namespace System;
#pragma unmanaged
// CAL Testing...
std::string programIL =
"il_ps_2_0\n"
"dcl_input_interp(linear) v0.xy\n"
"dcl_output_generic o0\n"
"dcl_cb cb0[1]\n"
"dcl_resource_id(0)_type(2d,unnorm)_fmtx(float)_fmty(float)_fmtz(float)_fmtw(float)\n"
"sample_resource(0)_sampler(0) r0, v0.xyxx\n"
"mul o0, r0, cb0[0]\n"
"ret_dyn\n"
"end\n";
extern "C" __declspec(dllexport) void CAL_Test()
{
// Here goes code from hellocal's main();
}
#pragma managed
// Some .NET code;
It compiles successfully, and CAL_Test() Procedure can be called normally (I tried it on general C++.NET console application).
But when I try to use this assembly form C# project, I got an error:
Invalid Buffer, unable to write to file
Fatal Error: Translator succeeded but returned null pointer
Fatal Error: Failed to compile program with IL front-end compiler!
Program compilation failed. Exiting.
Corresponding C#-code:
using Mg2Umg_Test;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
[DllImport(@"D:\Projects\C++\Mg2Umg_Test\Debug\Mg2Umg_Test.dll")]
public static extern void CAL_Test();
static void Main(string[] args)
{
CAL_Test();
}
}
}
What do I do wrong? How can I make possible to use CAL form .NET application?