cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

licoah
Journeyman III

about constant buffer

I had written my program as follows:

for(CALuint i = 0; i < cNum; i++)
    {
        r = calResAllocRemote1D(&_Res[offset + i], device, 1, 1, CAL_FORMAT_BYTE_4, 0);
            if(r != CAL_RESULT_OK)
            {
                fprintf(stderr, "AllocateRes: constants: There is an error in calResAllocLocal1D\n");
                return 0;
            }
            r = calCtxGetMem(&_Mem[offset + i], *ctx, _Res[offset + i]);
            if(r != CAL_RESULT_OK)
            {
                fprintf(stderr, "AllocateRes: constants:There is an error in calCtxGetMem\n");
                return 0;
            }
    }

...

 

for(CALuint i = 0; i < cNum; i++)
    {
        sprintf(buffer, "cb%d", i);
        r = calModuleGetName(&progName, *ctx, *module, buffer);
        if(r != CAL_RESULT_OK)
        {
            fprintf(stderr, "BindIOName: constants: Error string is %s\n",calGetErrorString());
            fprintf(stderr, "Failing name binding was %s\n", buffer);
            return 0;
        }
        r = calCtxSetMem(*ctx, progName, _Mem[offset + i]);
        if(r != CAL_RESULT_OK)
        {
            fprintf(stderr, "BindIOName: calCtxSetMem: constants: Error string is %s %d\n",calGetErrorString(),i);
            return 0;
        }
    }

then I got this error message:

BindIOName: calCtxSetMem:constants: Error string is Invalid format for constant buffer " 0

I don't know the reason for this.

Can somebody help me?

Tags (1)
0 Likes
6 Replies
gaurav_garg
Adept I

about constant buffer

8-bit, 16-bit datatypes are not supported for constant buffers, use 32-bit formats for constant buffer allocation.

0 Likes
licoah
Journeyman III

about constant buffer

thank you

but now there is new problem

for(CALuint i = 0; i < cNum; i++)
    {
        r = calResAllocRemote1D(&_Res[offset + i], device, 1, 1, CAL_FORMAT_INT_4, 0);
            if(r != CAL_RESULT_OK)
            {
                fprintf(stderr, "AllocateRes: constants: There is an error in calResAllocLocal1D\n");
                return 0;
            }
            r = calCtxGetMem(&_Mem[offset + i], *ctx, _Res[offset + i]);
            if(r != CAL_RESULT_OK)
            {
                fprintf(stderr, "AllocateRes: constants:There is an error in calCtxGetMem\n");
                return 0;
            }
    }

....

for(CALuint i = 0; i < cNum; i++)
    {
        sprintf(buffer, "cb%d", i);
        r = calModuleGetName(&progName, *ctx, *module, buffer);
        if(r != CAL_RESULT_OK)
        {
            fprintf(stderr, "BindIOName: constants: Error string is %s\n",calGetErrorString());
            fprintf(stderr, "Failing name binding was %s\n", buffer);
            return 0;
        }
        r = calCtxSetMem(*ctx, progName, _Mem[offset + i]);
        if(r != CAL_RESULT_OK)
        {
            fprintf(stderr, "BindIOName: calCtxSetMem: constants: Error string is %s %d\n",calGetErrorString(),i);
            return 0;
        }
    }

error message:

BindIOName: constants: Error string is Operational error
Failing name binding was cb1

0 Likes
gaurav_garg
Adept I

about constant buffer

Looks like rutime is not able to find "cb1" symbol in your IL shader. Make sure you are declaring cb1 in your IL shader

0 Likes
licoah
Journeyman III

about constant buffer

in my IL shader there is only cb0[8].

but how can I allocate resources and get name?

0 Likes
gaurav_garg
Adept I

about constant buffer

It means you are using a single constant buffer with size 8. You need to allocate only one resource, but with the width of 8.

calResAllocRemote1D(&_Res[offset + i], device, 1, 8, CAL_FORMAT_INT_4, 0);

0 Likes
licoah
Journeyman III

about constant buffer

thank you

I got it

0 Likes