mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 15:05:43 +00:00
Fixed an issue where "const unsigned [type] [pointer]" parameters where not parsed correctly. Solves issue [#1300]: "[OpenCL] Possible bug at CL.CreateProgramWithBinary".
This commit is contained in:
parent
ff572e83b7
commit
041c491f19
|
@ -168,7 +168,7 @@
|
|||
<token name="DEVICE_TYPE_DEFAULT" value="(1 << 0)" />
|
||||
<token name="DEVICE_TYPE_GPU" value="(1 << 2)" />
|
||||
</enum>
|
||||
<enum name="ErrorCode" type="int">
|
||||
<enum name="ErrorCodes" type="int">
|
||||
<token name="BUILD_PROGRAM_FAILURE" value="-11" />
|
||||
<token name="COMPILER_NOT_AVAILABLE" value="-3" />
|
||||
<token name="DEVICE_NOT_AVAILABLE" value="-2" />
|
||||
|
@ -418,7 +418,7 @@
|
|||
<param type="cl_uint" name="num_devices" flow="in" />
|
||||
<param type="cl_device_id*" name="device_list" flow="in" />
|
||||
<param type="size_t*" name="lengths" flow="in" />
|
||||
<param type="uchar" name="char" flow="in" />
|
||||
<param type="uchar**" name="binaries" flow="in" />
|
||||
<param type="cl_int*" name="binary_status" flow="in" />
|
||||
<param type="cl_int*" name="errcode_ret" flow="out" />
|
||||
</function>
|
||||
|
|
|
@ -209,13 +209,17 @@ namespace CHeaderToXML
|
|||
var paramaters_string = Regex.Match(line, @"\(.*\)").Captures[0].Value.TrimStart('(').TrimEnd(')');
|
||||
|
||||
// This regex matches function parameters.
|
||||
// The first part matches functions pointers in the following format:
|
||||
// The first part matches function pointers in the following format:
|
||||
// '[return type] (*[function pointer name])([parameter list]) [parameter name]
|
||||
// where [parameter name] may or may not be in comments.
|
||||
// The second part (before the '|') matches parameters of the following formats:
|
||||
// '[return type] [parameter name]', '[return type] * [parameter name]', 'const [return type]* [parameter name]'
|
||||
// where [parameter name] can either be inside comments (/* ... */) or not.
|
||||
var get_param = new Regex(@"(\w+\s\(\*\w+\)\s*\(.*\)\s*(/\*.*?\*/|\w+)? | (const\s)?\w+\s*\**\s*(/\*.*?\*/|\w+(\[.*?\])?)),?", RegexOptions.IgnorePatternWhitespace);
|
||||
// The second part (after the '|') matches parameters of the following formats:
|
||||
// '[parameter type] [parameter name]', '[parameter type] [pointer] [parameter name]', 'const [parameter type][pointer] [parameter name]'
|
||||
// where [parameter name] may be inside comments (/* ... */) and [pointer] is '', '*', '**', etc.
|
||||
var get_param = new Regex(@"(\w+\s\(\*\w+\)\s*\(.*\)\s*(/\*.*?\*/|\w+)? | (const\s)?(\w+\s*)+\**\s*(/\*.*?\*/|\w+(\[.*?\])?)),?", RegexOptions.IgnorePatternWhitespace);
|
||||
|
||||
var parameters =
|
||||
(from item in get_param.Matches(paramaters_string).OfType<Match>()
|
||||
select item.Captures[0].Value.TrimEnd(',')).ToList();
|
||||
|
||||
var fun =
|
||||
new
|
||||
|
@ -257,7 +261,9 @@ namespace CHeaderToXML
|
|||
Count = has_array_size ? Int32.Parse(array_size.Match(param_name).Value.Trim('[', ']')) : 0,
|
||||
Flow =
|
||||
param_name.EndsWith("ret") ||
|
||||
((funcname.StartsWith("Get") || funcname.StartsWith("Gen")) && indirection_level > 0) ?
|
||||
((funcname.StartsWith("Get") || funcname.StartsWith("Gen")) &&
|
||||
indirection_level > 0 &&
|
||||
!(funcname.EndsWith("Info") || funcname.EndsWith("IDs") || funcname.EndsWith("ImageFormats"))) ? // OpenCL contains Get*[Info|IDs|ImageFormats] methods with 'in' pointer parameters
|
||||
"out" : "in"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2607,86 +2607,80 @@ namespace OpenTK.Compute.CL10
|
|||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
|
||||
{
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte)@char, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte**)binaries, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr[] device_list, IntPtr[] lengths, byte @char, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr[] device_list, IntPtr[] lengths, byte*[] binaries, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
|
||||
{
|
||||
unsafe
|
||||
fixed (IntPtr* device_list_ptr = device_list)
|
||||
fixed (IntPtr* lengths_ptr = lengths)
|
||||
fixed (byte** binaries_ptr = binaries)
|
||||
fixed (int* binary_status_ptr = binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = device_list)
|
||||
fixed (IntPtr* lengths_ptr = lengths)
|
||||
fixed (int* binary_status_ptr = binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
|
||||
{
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, ref IntPtr device_list, ref IntPtr lengths, byte @char, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = &device_list)
|
||||
fixed (IntPtr* lengths_ptr = &lengths)
|
||||
fixed (int* binary_status_ptr = &binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
|
||||
{
|
||||
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
errcode_ret = *errcode_ret_ptr;
|
||||
return retval;
|
||||
}
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, ref IntPtr device_list, ref IntPtr lengths, ref byte* binaries, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
|
||||
{
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte)@char, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte @char, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
|
||||
{
|
||||
unsafe
|
||||
fixed (IntPtr* device_list_ptr = &device_list)
|
||||
fixed (IntPtr* lengths_ptr = &lengths)
|
||||
fixed (byte** binaries_ptr = &binaries)
|
||||
fixed (int* binary_status_ptr = &binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = device_list)
|
||||
fixed (IntPtr* lengths_ptr = lengths)
|
||||
fixed (int* binary_status_ptr = binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
|
||||
{
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
}
|
||||
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
errcode_ret = *errcode_ret_ptr;
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, ref IntPtr device_list, ref IntPtr lengths, byte @char, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
|
||||
{
|
||||
unsafe
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte**)binaries, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte*[] binaries, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = device_list)
|
||||
fixed (IntPtr* lengths_ptr = lengths)
|
||||
fixed (byte** binaries_ptr = binaries)
|
||||
fixed (int* binary_status_ptr = binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = &device_list)
|
||||
fixed (IntPtr* lengths_ptr = &lengths)
|
||||
fixed (int* binary_status_ptr = &binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
|
||||
{
|
||||
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
errcode_ret = *errcode_ret_ptr;
|
||||
return retval;
|
||||
}
|
||||
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
[System.CLSCompliant(false)]
|
||||
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
|
||||
public static
|
||||
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, ref IntPtr device_list, ref IntPtr lengths, ref byte* binaries, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
|
||||
{
|
||||
fixed (IntPtr* device_list_ptr = &device_list)
|
||||
fixed (IntPtr* lengths_ptr = &lengths)
|
||||
fixed (byte** binaries_ptr = &binaries)
|
||||
fixed (int* binary_status_ptr = &binary_status)
|
||||
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
|
||||
{
|
||||
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
|
||||
errcode_ret = *errcode_ret_ptr;
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace OpenTK.Compute.CL10
|
|||
internal extern static unsafe int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret);
|
||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||
[System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithBinary", ExactSpelling = true)]
|
||||
internal extern static unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
internal extern static unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||
[System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithSource", ExactSpelling = true)]
|
||||
internal extern static unsafe IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace OpenTK.Compute.CL10
|
|||
internal unsafe delegate int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret);
|
||||
internal unsafe static CreateKernelsInProgram clCreateKernelsInProgram;
|
||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||
internal unsafe delegate IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
internal unsafe delegate IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
internal unsafe static CreateProgramWithBinary clCreateProgramWithBinary;
|
||||
[System.Security.SuppressUnmanagedCodeSecurity()]
|
||||
internal unsafe delegate IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
|
||||
|
|
Loading…
Reference in a new issue