M
Manda Rajo
Guest
In HLSL the calling of the functions on arguments is the reverse as in C++, it's like a bug. It's important for me because I have a dual program working both on CPU and GPU (HLSL), the results must match each other. Please report that bug on HLSL.
#include <stdio.h>
int g_x = 100;
int F()
{
g_x++;
return g_x;
}
void Function(int a, int b, int c)
{
printf("a = %d\n", a);
printf("b = %d\n", b);
printf("c = %d\n", c);
}
int main()
{
Function(F(), F(), F());
return 0;
}
Output:
a = 103
b = 102
c = 101
You can test it here: http://cpp.sh/22wrq (press the button Run) http://cpp.sh/22wrq
The problem is same in Visual Studio C++ 2015.
If HLSL can print then the result would be 101, 102, 103 instead of 103, 102, 101.
Continue reading...
#include <stdio.h>
int g_x = 100;
int F()
{
g_x++;
return g_x;
}
void Function(int a, int b, int c)
{
printf("a = %d\n", a);
printf("b = %d\n", b);
printf("c = %d\n", c);
}
int main()
{
Function(F(), F(), F());
return 0;
}
Output:
a = 103
b = 102
c = 101
You can test it here: http://cpp.sh/22wrq (press the button Run) http://cpp.sh/22wrq
The problem is same in Visual Studio C++ 2015.
If HLSL can print then the result would be 101, 102, 103 instead of 103, 102, 101.
Continue reading...